From 2ea6847ef9cfa2aae0a6b02db08988eb267e134d Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 9 May 2022 08:16:00 -0400 Subject: [PATCH] major release --- CHANGELOG.md | 5 +- TODO.md | 21 - dist/human.esm-nobundle.js | 2 +- dist/human.esm.js | 19780 ++++++++-------- dist/human.esm.js.map | 4 +- dist/human.js | 1281 +- dist/human.node-gpu.js | 2 +- dist/human.node-wasm.js | 2 +- dist/human.node.js | 2 +- dist/tfjs.esm.js | 1075 +- test/build.log | 49 +- test/test.log | 814 +- typedoc/classes/Env.html | 2 +- typedoc/classes/GraphModel.html | 22 +- typedoc/classes/Human.html | 2 +- typedoc/classes/Tensor.html | 2 +- typedoc/classes/models.Models.html | 2 +- typedoc/enums/Rank.html | 2 +- typedoc/index.html | 2 +- typedoc/interfaces/BodyConfig.html | 2 +- typedoc/interfaces/BodyKeypoint.html | 2 +- typedoc/interfaces/BodyResult.html | 2 +- typedoc/interfaces/Config.html | 2 +- typedoc/interfaces/FaceAntiSpoofConfig.html | 2 +- typedoc/interfaces/FaceAttentionConfig.html | 2 +- typedoc/interfaces/FaceConfig.html | 2 +- typedoc/interfaces/FaceDescriptionConfig.html | 2 +- typedoc/interfaces/FaceDetectorConfig.html | 2 +- typedoc/interfaces/FaceEmotionConfig.html | 2 +- typedoc/interfaces/FaceIrisConfig.html | 2 +- typedoc/interfaces/FaceLivenessConfig.html | 2 +- typedoc/interfaces/FaceMeshConfig.html | 2 +- typedoc/interfaces/FaceResult.html | 2 +- typedoc/interfaces/FilterConfig.html | 2 +- typedoc/interfaces/GenericConfig.html | 2 +- typedoc/interfaces/GestureConfig.html | 2 +- typedoc/interfaces/HandConfig.html | 2 +- typedoc/interfaces/HandResult.html | 2 +- typedoc/interfaces/ObjectConfig.html | 2 +- typedoc/interfaces/ObjectResult.html | 2 +- typedoc/interfaces/PersonResult.html | 2 +- typedoc/interfaces/Result.html | 2 +- typedoc/interfaces/SegmentationConfig.html | 2 +- typedoc/modules/Tensor.html | 2 +- typedoc/modules/draw.html | 2 +- typedoc/modules/match.html | 2 +- typedoc/modules/models.html | 2 +- 47 files changed, 11757 insertions(+), 11370 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 803e8b6bd..1e72068a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # @vladmandic/human - Version: **2.7.0** + Version: **2.7.1** Description: **Human: AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition, Body Pose Tracking, 3D Hand & Finger Tracking, Iris Analysis, Age & Gender & Emotion Prediction, Gesture Recognition** Author: **Vladimir Mandic ** @@ -9,8 +9,9 @@ ## Changelog -### **HEAD -> main** 2022/04/21 mandic00@live.com +### **2.7.1** 2022/05/09 mandic00@live.com +- support 4k input ### **origin/main** 2022/04/18 mandic00@live.com diff --git a/TODO.md b/TODO.md index ac5c12e38..5c8ac7aa5 100644 --- a/TODO.md +++ b/TODO.md @@ -29,24 +29,3 @@ Feature is automatically disabled in NodeJS without user impact ## Pending Release Notes -Release 2.7: -- Add **MediaPipe FaceMesh-with-Attention** model - model is available in `@vladmandic/human-models` repository - to enable, set `config.face.attention = true` - model replaces **iris**, **eyes** and **lips** keypoints with high-detailed ones -- Add model **pre-compile** phase to `warmup` method - result is speed-up to first inference by around ~30% for browser environments -- Changed default face crop from 120% to 140% - to better utilize caching between frames and face mesh mapping -- Refactor **draw** methods into separate modules and fix coloring function -- Add highlights to attention keypoints - enabled when both points and attention draw are enabled: - `human.draw.options.drawAttention = true` and `human.draw.options.drawPoints = true` -- Add **ElectronJS** demo: - see -- Enhanced **3D** demos: - see -- Support for **4K** input -- Support for **NodeJS** 8.0.0 -- Update **TFJS** to 3.16.0 -- Update build platform and dependencies diff --git a/dist/human.esm-nobundle.js b/dist/human.esm-nobundle.js index 86426fdf6..61f4c4609 100644 --- a/dist/human.esm-nobundle.js +++ b/dist/human.esm-nobundle.js @@ -96,7 +96,7 @@ var Zt=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var pn=Objec c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var qt=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,s)=>(o[s]=0,r))},Ut=class{constructor(t,o,n){k(this,"uniform",{});k(this,"attribute",{});k(this,"gl");k(this,"id");k(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(h(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(h("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),s=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!s)){if(!this.id){h("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,s),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){h(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),qt(o,"attribute",this.attribute);for(let a in this.attribute)this.attribute[a]=this.gl.getAttribLocation(this.id,a);qt(o,"uniform",this.uniform),qt(n,"uniform",this.uniform);for(let a in this.uniform)this.uniform[a]=this.gl.getUniformLocation(this.id,a)}}};function L2(){let e=0,t=null,o=!1,n=-1,r=[null,null],s=[],a=null,i=null,l=i0(100,100),x={},d={INTERMEDIATE:1},y=l.getContext("webgl");if(!y){h("filter: cannot get webgl context");return}this.gl=y;function c(u,p){if(!(u===l.width&&p===l.height)){if(l.width=u,l.height=p,!a){let v=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);a=y.createBuffer(),y.bindBuffer(y.ARRAY_BUFFER,a),y.bufferData(y.ARRAY_BUFFER,v,y.STATIC_DRAW),y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}y.viewport(0,0,l.width,l.height),r=[null,null]}}function f(u,p){let v=y.createFramebuffer();y.bindFramebuffer(y.FRAMEBUFFER,v);let w=y.createRenderbuffer();y.bindRenderbuffer(y.RENDERBUFFER,w);let S=y.createTexture();return y.bindTexture(y.TEXTURE_2D,S),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,u,p,0,y.RGBA,y.UNSIGNED_BYTE,null),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.LINEAR),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.LINEAR),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.framebufferTexture2D(y.FRAMEBUFFER,y.COLOR_ATTACHMENT0,y.TEXTURE_2D,S,0),y.bindTexture(y.TEXTURE_2D,null),y.bindFramebuffer(y.FRAMEBUFFER,null),{fbo:v,texture:S}}function b(u){return r[u]=r[u]||f(l.width,l.height),r[u]}function m(u=0){if(!i)return;let p=null,v=null,w=!1;e===0?p=t:p=b(n).texture||null,e++,o&&!(u&d.INTERMEDIATE)?(v=null,w=e%2===0):(n=(n+1)%2,v=b(n).fbo||null),y.bindTexture(y.TEXTURE_2D,p),y.bindFramebuffer(y.FRAMEBUFFER,v),y.uniform1f(i.uniform.flipY,w?-1:1),y.drawArrays(y.TRIANGLES,0,6)}function M(u){if(x[u])return i=x[u],y.useProgram((i?i.id:null)||null),i;if(i=new Ut(y,z2,u),!i)return h("filter: could not get webgl program"),null;let p=Float32Array.BYTES_PER_ELEMENT,v=4*p;return y.enableVertexAttribArray(i.attribute.pos),y.vertexAttribPointer(i.attribute.pos,2,y.FLOAT,!1,v,0*p),y.enableVertexAttribArray(i.attribute.uv),y.vertexAttribPointer(i.attribute.uv,2,y.FLOAT,!1,v,2*p),x[u]=i,i}let P={colorMatrix:u=>{let p=new Float32Array(u);p[4]/=255,p[9]/=255,p[14]/=255,p[19]/=255;let v=p[18]===1&&p[3]===0&&p[8]===0&&p[13]===0&&p[15]===0&&p[16]===0&&p[17]===0&&p[19]===0?S2:j2,w=M(v);!w||(y.uniform1fv(w.uniform.m,p),m())},brightness:u=>{let p=(u||0)+1;P.colorMatrix([p,0,0,0,0,0,p,0,0,0,0,0,p,0,0,0,0,0,1,0])},saturation:u=>{let p=(u||0)*2/3+1,v=(p-1)*-.5;P.colorMatrix([p,v,v,0,0,v,p,v,0,0,v,v,p,0,0,0,0,0,1,0])},desaturate:()=>{P.saturation(-1)},contrast:u=>{let p=(u||0)+1,v=-128*(p-1);P.colorMatrix([p,0,0,0,v,0,p,0,0,v,0,0,p,0,v,0,0,0,1,0])},negative:()=>{P.contrast(-2)},hue:u=>{u=(u||0)/180*Math.PI;let p=Math.cos(u),v=Math.sin(u),w=.213,S=.715,O=.072;P.colorMatrix([w+p*(1-w)+v*-w,S+p*-S+v*-S,O+p*-O+v*(1-O),0,0,w+p*-w+v*.143,S+p*(1-S)+v*.14,O+p*-O+v*-.283,0,0,w+p*-w+v*-(1-w),S+p*-S+v*S,O+p*(1-O)+v*O,0,0,0,0,0,1,0])},desaturateLuminance:()=>{P.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{P.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{P.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{P.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{P.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{P.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{P.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{P.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:u=>{let p=new Float32Array(u),v=1/l.width,w=1/l.height,S=M(O2);!S||(y.uniform1fv(S.uniform.m,p),y.uniform2f(S.uniform.px,v,w),m())},detectEdges:()=>{P.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{P.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{P.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:u=>{let p=u||1;P.convolution.call(this,[0,-1*p,0,-1*p,1+4*p,-1*p,0,-1*p,0])},emboss:u=>{let p=u||1;P.convolution.call(this,[-2*p,-1*p,0,-1*p,1,1*p,0,1*p,2*p])},blur:u=>{let p=u/7/l.width,v=u/7/l.height,w=M(W2);!w||(y.uniform2f(w.uniform.px,0,v),m(d.INTERMEDIATE),y.uniform2f(w.uniform.px,p,0),m())},pixelate:u=>{let p=u/l.width,v=u/l.height,w=M(C2);!w||(y.uniform2f(w.uniform.size,p,v),m())}};this.add=function(u){let p=Array.prototype.slice.call(arguments,1),v=P[u];s.push({func:v,args:p})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(u){c(u.width,u.height),e=0,t||(t=y.createTexture()),y.bindTexture(y.TEXTURE_2D,t),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.NEAREST),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,y.RGBA,y.UNSIGNED_BYTE,u);for(let p=0;pf.data())),a=.99*Math.max(s[0][0],s[1][0],s[2][0]),i=[A.sub(o[0],n[0]),A.sub(o[1],n[1]),A.sub(o[2],n[2])],l=[A.sub(r[0],n[0]),A.sub(r[1],n[1]),A.sub(r[2],n[2])],x=[A.div(a,l[0]),A.div(a,l[1]),A.div(a,l[2])],d=[A.mul(i[0],x[0]),A.mul(i[1],x[1]),A.mul(i[2],x[2])],y=A.stack([d[0],d[1],d[2]],2),c=A.reshape(y,[1,t.shape[0],t.shape[1],3]);return A.dispose([...o,...n,...r,...i,...l,...x,...d,y,t]),c}var nt=3840,B=null,$=null,me=null,q,I0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function i0(e,t){let o;if(T.browser)if(T.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof T.Canvas!="undefined"?o=new T.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function rt(e,t){let o=t||i0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function pe(e,t,o=!0){if(!e)return t.debug&&h("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof fe)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof T.Canvas!="undefined"&&e instanceof T.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof fe){let n=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)n=A.expandDims(e,0);else if(e.shape[2]===4){let r=A.slice3d(e,[0,0,0],[-1,-1,3]);n=A.expandDims(r,0),A.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=A.clone(e):e.shape[3]===4&&(n=A.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=A.cast(n,"float32");A.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?$:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&h("input stream is not ready"),{tensor:null,canvas:B};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&h("cannot determine input dimensions"),{tensor:null,canvas:B};let s=n,a=r;if(s>nt&&(s=nt,a=Math.trunc(s*r/n)),a>nt&&(a=nt,s=Math.trunc(a*n/r)),(t.filter.width||0)>0?s=t.filter.width:(t.filter.height||0)>0&&(s=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?a=t.filter.height:(t.filter.width||0)>0&&(a=r*((t.filter.width||0)/n)),!s||!a)throw new Error("input error: cannot determine dimension");(!B||(B==null?void 0:B.width)!==s||(B==null?void 0:B.height)!==a)&&(B=i0(s,a));let i=B.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?i.putImageData(e,0,0):t.filter.flip&&typeof i.translate!="undefined"?(i.translate(n,0),i.scale(-1,1),i.drawImage(e,0,0,n,r,0,0,B==null?void 0:B.width,B==null?void 0:B.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,n,r,0,0,B==null?void 0:B.width,B==null?void 0:B.height),(!$||B.width!==$.width||(B==null?void 0:B.height)!==($==null?void 0:$.height))&&($=i0(B.width,B.height)),t.filter.enabled&&T.webgl.supported?(q||(q=T.browser?new L2:null),T.filter=!!q,!q||!q.add?(t.debug&&h("input process error: cannot initialize filters"),T.webgl.supported=!1,t.filter.enabled=!1,rt(B,$)):(q.reset(),t.filter.brightness!==0&&q.add("brightness",t.filter.brightness),t.filter.contrast!==0&&q.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&q.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&q.add("blur",t.filter.blur),t.filter.saturation!==0&&q.add("saturation",t.filter.saturation),t.filter.hue!==0&&q.add("hue",t.filter.hue),t.filter.negative&&q.add("negative"),t.filter.sepia&&q.add("sepia"),t.filter.vintage&&q.add("brownie"),t.filter.sepia&&q.add("sepia"),t.filter.kodachrome&&q.add("kodachrome"),t.filter.technicolor&&q.add("technicolor"),t.filter.polaroid&&q.add("polaroid"),t.filter.pixelate!==0&&q.add("pixelate",t.filter.pixelate),q.get()>0?$=q.apply(B):$=q.draw(B))):(rt(B,$),q&&(q=null),T.filter=!!q),!o)return{tensor:null,canvas:$};if(!$)throw new Error("canvas error: cannot create output");let l,x=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(T.browser&&A.browser)l=A.browser?A.browser.fromPixels(e):null;else{x=e.data.length/e.height/e.width;let c=new Uint8Array(e.data.buffer);l=A.tensor(c,[e.height,e.width,x],"int32")}else if((!me||$.width!==me.width||$.height!==me.height)&&(me=i0($.width,$.height)),A.browser&&T.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=A.browser.fromPixels($):(me=rt($),l=A.browser.fromPixels(me));else{let b=rt($).getContext("2d").getImageData(0,0,s,a);x=b.data.length/s/a;let m=new Uint8Array(b.data.buffer);l=A.tensor(m,[s,a,x])}if(x===4){let c=A.slice3d(l,[0,0,0],[-1,-1,3]);A.dispose(l),l=c}if(!l)throw new Error("input error: cannot create tensor");let d=A.cast(l,"float32"),y=t.filter.equalization?await ot(d):A.expandDims(d,0);return A.dispose([l,d]),{tensor:y,canvas:t.filter.return?$:null}}}async function I2(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!I0.inputTensor)I0.inputTensor=A.clone(t);else if(I0.inputTensor.shape[1]!==t.shape[1]||I0.inputTensor.shape[2]!==t.shape[2])A.dispose(I0.inputTensor),I0.inputTensor=A.clone(t);else{let n={};n.diff=A.sub(t,I0.inputTensor),n.squared=A.mul(n.diff,n.diff),n.sum=A.sum(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;A.dispose([I0.inputTensor,n.diff,n.squared,n.sum]),I0.inputTensor=A.clone(t),o=s<=(e.cacheSensitivity||0)}return o}async function N2(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||h("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||h("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=A.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?A.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):A.clone(o),n.diff=A.sub(n.input1,n.input2),n.squared=A.mul(n.diff,n.diff),n.sum=A.sum(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return A.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),s}var Jt=class{constructor(){k(this,"browser");k(this,"node");k(this,"worker");k(this,"platform","");k(this,"agent","");k(this,"backends",[]);k(this,"initial");k(this,"filter");k(this,"tfjs");k(this,"offscreen");k(this,"perfadd",!1);k(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});k(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});k(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});k(this,"cpu",{model:void 0,flags:[]});k(this,"kernels",[]);k(this,"Canvas");k(this,"Image");k(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:Ve["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(A.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&A.getBackend()==="wasm"&&(this.wasm.simd=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=i0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(A.getBackend()==="webgl"||A.getBackend()==="humangl")){let n=A.backend().gpgpu!=="undefined"?await A.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=A.getKernelsForBackend(A.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},T=new Jt;var N0={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function zn(e,t){return N0.debug&&h("load model fetch:",e,t),fetch(e,t)}function F2(e){N0.cacheModels=e.cacheModels,N0.verbose=e.debug,N0.modelBasePath=e.modelBasePath}async function I(e){let t=E2(N0.modelBasePath,e||""),o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await A.io.listModels(),s=N0.cacheModels&&Object.keys(r).includes(n),a=typeof fetch=="undefined"?{}:{fetchFunc:(x,d)=>zn(x,d)},i=new Xt(s?n:t,a),l=!1;try{i.findIOHandler(),N0.debug&&h("model load handler:",i.handler);let x=await i.handler.load();i.loadSync(x),N0.verbose&&h("load model:",i.modelUrl),l=!0}catch(x){h("error loading model:",t,x)}if(l&&N0.cacheModels&&!s)try{let x=await i.save(n);h("model saved:",n,x)}catch(x){h("error saving model:",t,x)}return i}var Yt="2.7.0";var y2={};ne(y2,{Models:()=>_e,load:()=>i2,reset:()=>Ft,validate:()=>l2});var P0,Kt=[],Cn=["white","black","asian","indian","other"],Wn=[15,23,28,35.5,45.5,55.5,65],G2=0,B2=0,Qt=Number.MAX_SAFE_INTEGER;async function H2(e){return T.initial&&(P0=null),P0?e.debug&&h("cached model:",P0.modelUrl):P0=await I(e.face.gear),P0}async function _t(e,t,o,n){var a,i;if(!P0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=Qt<(((a=t.face.gear)==null?void 0:a.skipFrames)||0),s=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>g()-B2;return t.skipAllowed&&s&&r&&G2===n&&Kt[o]?(Qt++,Kt[o]):(Qt=0,new Promise(async l=>{var P,u;if(!(P0!=null&&P0.inputs[0].shape))return;let x={},d=[[0,.1,.9,.9]];x.resize=A.image.cropAndResize(e,d,[0],[P0.inputs[0].shape[2],P0.inputs[0].shape[1]]);let y={age:0,gender:"unknown",genderScore:0,race:[]};(P=t.face.gear)!=null&&P.enabled&&([x.age,x.gender,x.race]=P0.execute(x.resize,["age_output","gender_output","race_output"]));let c=await x.gender.data();y.gender=c[0]>c[1]?"male":"female",y.genderScore=Math.round(100*(c[0]>c[1]?c[0]:c[1]))/100;let f=await x.race.data();for(let p=0;p(((u=t.face.gear)==null?void 0:u.minConfidence)||.2)&&y.race.push({score:Math.round(100*f[p])/100,race:Cn[p]});y.race.sort((p,v)=>v.score-p.score);let m=Array.from(await x.age.data()).map((p,v)=>[Wn[v],p]).sort((p,v)=>v[1]-p[1]),M=m[0][0];for(let p=1;pA.dispose(x[p])),Kt[o]=y,G2=n,B2=g(),l(y)}))}var N={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Z2(){N.tf255=A.scalar(255,"float32"),N.tf1=A.scalar(1,"float32"),N.tf2=A.scalar(2,"float32"),N.tf05=A.scalar(.5,"float32"),N.tf127=A.scalar(127.5,"float32"),N.rgb=A.tensor1d([.2989,.587,.114],"float32")}var x0,At=[],D2=0,X2=0,$t=Number.MAX_SAFE_INTEGER;async function q2(e){return T.initial&&(x0=null),x0?e.debug&&h("cached model:",x0.modelUrl):x0=await I(e.face.ssrnet.modelPathAge),x0}async function e5(e,t,o,n){var a,i,l,x;if(!x0)return{age:0};let r=$t<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>g()-X2;return t.skipAllowed&&r&&s&&D2===n&&((l=At[o])==null?void 0:l.age)&&((x=At[o])==null?void 0:x.age)>0?($t++,At[o]):($t=0,new Promise(async d=>{if(!(x0!=null&&x0.inputs)||!x0.inputs[0]||!x0.inputs[0].shape)return;let y={};y.resize=A.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),y.enhance=A.mul(y.resize,N.tf255);let c={age:0};if(t.face.ssrnet.enabled&&(y.age=x0.execute(y.enhance)),y.age){let f=await y.age.data();c.age=Math.trunc(10*f[0])/10}Object.keys(y).forEach(f=>A.dispose(y[f])),At[o]=c,D2=n,X2=g(),d(c)}))}var v0,st=[],J2=0,Y2=0,t5=Number.MAX_SAFE_INTEGER,o5=[.2989,.587,.114];async function K2(e){return T.initial&&(v0=null),v0?e.debug&&h("cached model:",v0.modelUrl):v0=await I(e.face.ssrnet.modelPathGender),v0}async function n5(e,t,o,n){var a,i,l,x;if(!v0)return{gender:"unknown",genderScore:0};let r=t5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>g()-Y2;return t.skipAllowed&&r&&s&&J2===n&&((l=st[o])==null?void 0:l.gender)&&((x=st[o])==null?void 0:x.genderScore)>0?(t5++,st[o]):(t5=0,new Promise(async d=>{if(!(v0!=null&&v0.inputs[0].shape))return;let y={};y.resize=A.image.resizeBilinear(e,[v0.inputs[0].shape[2],v0.inputs[0].shape[1]],!1),y.enhance=A.tidy(()=>{let[b,m,M]=A.split(y.resize,3,3),P=A.mul(b,o5[0]),u=A.mul(m,o5[1]),p=A.mul(M,o5[2]),v=A.addN([P,u,p]);return A.mul(A.sub(v,N.tf05),2)});let c={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(y.gender=v0.execute(y.enhance));let f=await y.gender.data();c.gender=f[0]>f[1]?"female":"male",c.genderScore=f[0]>f[1]?Math.trunc(100*f[0])/100:Math.trunc(100*f[1])/100,Object.keys(y).forEach(b=>A.dispose(y[b])),st[o]=c,J2=n,Y2=g(),d(c)}))}var r0,at=[],r5=Number.MAX_SAFE_INTEGER,_2=0,$2=0;async function e1(e){var t;return T.initial&&(r0=null),r0?e.debug&&h("cached model:",r0.modelUrl):r0=await I((t=e.face.antispoof)==null?void 0:t.modelPath),r0}async function A5(e,t,o,n){var a,i;if(!r0)return 0;let r=(((a=t.face.antispoof)==null?void 0:a.skipTime)||0)>g()-$2,s=r5<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&_2===n&&at[o]?(r5++,at[o]):(r5=0,new Promise(async l=>{let x=A.image.resizeBilinear(e,[r0!=null&&r0.inputs[0].shape?r0.inputs[0].shape[2]:0,r0!=null&&r0.inputs[0].shape?r0.inputs[0].shape[1]:0],!1),d=r0==null?void 0:r0.execute(x),y=(await d.data())[0];at[o]=Math.round(100*y)/100,_2=n,$2=g(),A.dispose([x,d]),l(at[o])}))}var M0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[61,185,40,39,37,0,267,269,270,409,291],lipsLowerOuter:[146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[78,191,80,81,82,13,312,311,310,415,308],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},s5={count:468,mouth:13,symmetryLine:[13,M0.midwayBetweenEyes[0]]},De={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},a5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],Xe=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],Ae=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var Ln=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],In=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],Nn=[33,133,362,263,1,78,308],qA=Ln.map(e=>Xe[e]),UA=In.map(e=>Xe[e]),JA=Nn.map(e=>Xe[e]);function q0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Fn=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],Gn=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Bn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Hn=[[474,475],[475,476],[476,477],[477,474]],Vn=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Zn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Dn=[[469,470],[470,471],[471,472],[472,469]],Xn=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],YA={lips:q0(Fn),leftEye:q0(Gn),leftEyebrow:q0(Bn),leftIris:q0(Hn),rightEye:q0(Vn),rightEyebrow:q0(Zn),rightIris:q0(Dn),faceOval:q0(Xn)};var ue=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],it=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],x5=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],c5=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],r1=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},l5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],s=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],a=A.image.cropAndResize(t,[s],[0],o),i=A.div(a,N.tf255);return A.dispose(a),i},lt=(e,t)=>{let o=it(e),n=ue(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},yt=e=>{let t=it(e),o=ue(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},A1=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},y5=[[1,0,0],[0,1,0],[0,0,1]],qn=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Un=(e,t)=>qn(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var o1=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],se=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],s=o1(t[0],t[1]),a=n1(s,r),i=o1(-t[0],-t[1]);return n1(a,i)},Yn=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-se(t[0],o),-se(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},Kn=(e,t)=>[se(e,t[0]),se(e,t[1])];function a1(e){let t={strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[s[0]/r*(f[0]-r/2),s[1]/r*(f[1]-r/2),f[2]||0]),i=o&&o!==0&&Math.abs(o)>.2,l=i?s1(o,[0,0]):y5,x=i?a.map(f=>[...Kn(f,l),f[2]]):a,d=i?Yn(n):y5,y=it(t),c=[se(y,d[0]),se(y,d[1])];return x.map(f=>[Math.trunc(f[0]+c[0]),Math.trunc(f[1]+c[1]),Math.trunc(f[2]||0)])}function l1(e,t,o,n){let r=t.landmarks.length>=s5.count?s5.symmetryLine:De.symmetryLine,s=0,a=y5,i;if(e&&T.kernels.includes("rotatewithoffset"))if(s=Un(t.landmarks[r[0]],t.landmarks[r[1]]),s&&s!==0&&Math.abs(s)>.2){let x=it(t),d=[x[0]/o.shape[2],x[1]/o.shape[1]],y=A.image.rotateWithOffset(o,s,0,d);a=s1(-s,x),i=l5(t,y,[n,n]),A.dispose(y)}else i=l5(t,o,[n,n]);else i=l5(t,o,[n,n]);return[s,a,i]}var Qn=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},y1=(e,t)=>{let o=Qn(e),n=ue(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var x1=6,_n=1.4,z0,c1=null,U0=0,qe=null,xt=()=>U0;async function d1(e){var t;return T.initial&&(z0=null),z0?e.debug&&h("cached model:",z0.modelUrl):z0=await I((t=e.face.detector)==null?void 0:t.modelPath),U0=z0.inputs[0].shape?z0.inputs[0].shape[2]:0,qe=A.scalar(U0,"int32"),c1=A.tensor2d(a1(U0)),z0}function $n(e){let t={};t.boxStarts=A.slice(e,[0,1],[-1,2]),t.centers=A.add(t.boxStarts,c1),t.boxSizes=A.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=A.div(t.boxSizes,qe),t.centersNormalized=A.div(t.centers,qe),t.halfBoxSize=A.div(t.boxSizesNormalized,N.tf2),t.starts=A.sub(t.centersNormalized,t.halfBoxSize),t.ends=A.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=A.mul(t.starts,qe),t.endNormalized=A.mul(t.ends,qe);let o=A.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>A.dispose(t[n])),o}async function f1(e,t){var i,l,x,d;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=A.image.resizeBilinear(e,[U0,U0]),o.div=A.div(o.resized,N.tf127),o.normalized=A.sub(o.div,N.tf05);let n=z0==null?void 0:z0.execute(o.normalized);if(Array.isArray(n)){let y=n.sort((c,f)=>c.size-f.size);o.concat384=A.concat([y[0],y[2]],2),o.concat512=A.concat([y[1],y[3]],2),o.concat=A.concat([o.concat512,o.concat384],1),o.batch=A.squeeze(o.concat,0)}else o.batch=A.squeeze(n);A.dispose(n),o.boxes=$n(o.batch),o.logits=A.slice(o.batch,[0,0],[-1,1]),o.sigmoid=A.sigmoid(o.logits),o.scores=A.squeeze(o.sigmoid),o.nms=await A.image.nonMaxSuppressionAsync(o.boxes,o.scores,((i=t.face.detector)==null?void 0:i.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((x=t.face.detector)==null?void 0:x.minConfidence)||0);let r=await o.nms.array(),s=[],a=await o.scores.data();for(let y=0;y(((d=t.face.detector)==null?void 0:d.minConfidence)||0)){let f={};f.bbox=A.slice(o.boxes,[r[y],0],[1,-1]),f.slice=A.slice(o.batch,[r[y],x1-1],[1,-1]),f.squeeze=A.squeeze(f.slice),f.landmarks=A.reshape(f.squeeze,[x1,-1]);let b=await f.bbox.data(),m={startPoint:[b[0],b[1]],endPoint:[b[2],b[3]],landmarks:await f.landmarks.array(),confidence:c},M=r1(m,[(e.shape[2]||0)/U0,(e.shape[1]||0)/U0]),P=lt(M,t.face.scale||_n),u=yt(P);s.push(u),Object.keys(f).forEach(p=>A.dispose(f[p]))}}return Object.keys(o).forEach(y=>A.dispose(o[y])),s}var ct={};ne(ct,{connected:()=>m5,kpt:()=>f5});var f5=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],m5={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var p1=224,er,tr=5,dt=[8,16,32,32,32];async function u1(){let e=[],t=0;for(;to.x)),y:A.tensor1d(e.map(o=>o.y))}}function F0(e,t=[1,1]){let o=[e.map(i=>i[0]),e.map(i=>i[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],s=[n[0],n[1],r[0]-n[0],r[1]-n[1]],a=[s[0]/t[0],s[1]/t[1],s[2]/t[0],s[3]/t[1]];return{box:s,boxRaw:a}}function h1(e,t=[1,1]){let o=[e.map(x=>x[0]),e.map(x=>x[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],s=[(n[0]+r[0])/2,(n[1]+r[1])/2],a=Math.max(s[0]-n[0],s[1]-n[1],-s[0]+r[0],-s[1]+r[1]),i=[Math.trunc(s[0]-a),Math.trunc(s[1]-a),Math.trunc(2*a),Math.trunc(2*a)],l=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:l}}function ft(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var P1={initial:!0},c0={detector:null,landmarks:null},he={detector:[224,224],landmarks:[256,256]},p5=Number.MAX_SAFE_INTEGER,nr={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},pt=null,Ue,J0=[[0,0],[0,0],[0,0],[0,0]],b1=0,g1=e=>1-1/(1+Math.exp(e));async function v1(e){if(P1.initial&&(c0.detector=null),!c0.detector&&e.body.detector&&e.body.detector.modelPath){c0.detector=await I(e.body.detector.modelPath);let t=Object.values(c0.detector.modelSignature.inputs);he.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,he.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&c0.detector&&h("cached model:",c0.detector.modelUrl);return await u1(),c0.detector}async function M1(e){if(P1.initial&&(c0.landmarks=null),c0.landmarks)e.debug&&h("cached model:",c0.landmarks.modelUrl);else{c0.landmarks=await I(e.body.modelPath);let t=Object.values(c0.landmarks.modelSignature.inputs);he.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,he.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return c0.landmarks}async function rr(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(Ue&&(o.cropped=A.image.cropAndResize(e,[Ue],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],s=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];J0=[[0,0],r,s,[0,0]],o.pad=A.pad(o.cropped||e,J0),o.resize=A.image.resizeBilinear(o.pad,[t,t]),n=A.div(o.resize,N.tf255)}else e.shape[1]!==t?(o.resize=A.image.resizeBilinear(o.cropped||e,[t,t]),n=A.div(o.resize,N.tf255)):n=A.div(o.cropped||e,N.tf255);return Object.keys(o).forEach(r=>A.dispose(o[r])),n}function Ar(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+J0[2][0]+J0[2][1])/t[0]-J0[2][0]),Math.trunc(o.position[1]*(t[1]+J0[1][0]+J0[1][1])/t[1]-J0[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(Ue)for(let o of e)o.positionRaw=[o.positionRaw[0]+Ue[1],o.positionRaw[1]+Ue[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}async function sr(e){let t=e.find(i=>i.part==="leftPalm"),o=e.find(i=>i.part==="leftWrist"),n=e.find(i=>i.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(i=>i.part==="rightPalm"),s=e.find(i=>i.part==="rightWrist"),a=e.find(i=>i.part==="rightIndex");r.position[2]=((s.position[2]||0)+(a.position[2]||0))/2}async function ar(e,t,o){var b;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(b=c0.landmarks)==null?void 0:b.execute(e,nr.landmarks);let r=(await n.poseflag.data())[0],s=await n.ld.data(),a=await n.world.data();Object.keys(n).forEach(m=>A.dispose(n[m]));let i=[],l=5;for(let m=0;mm.position),y=F0(d,[o[0],o[1]]),c={};for(let[m,M]of Object.entries(m5)){let P=[];for(let u=0;uw.part===M[u]),v=x.find(w=>w.part===M[u+1]);p&&v&&P.push([p.position,v.position])}c[m]=P}return{id:0,score:Math.trunc(100*r)/100,box:y.box,boxRaw:y.boxRaw,keypoints:x,annotations:c}}async function u5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>g()-b1,r=p5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&pt!==null)p5++;else{let s={};s.landmarks=await rr(e,256),pt=await ar(s.landmarks,t,o),Object.keys(s).forEach(a=>A.dispose(s[a])),b1=g(),p5=0}return pt?[pt]:[]}var be=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var G0,ae=0,h5=[],T1=0,b5=Number.MAX_SAFE_INTEGER;async function w1(e){if(T.initial&&(G0=null),G0)e.debug&&h("cached model:",G0.modelUrl);else{G0=await I(e.object.modelPath);let t=Object.values(G0.modelSignature.inputs);ae=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return G0}async function ir(e,t,o){if(!e)return[];let n={},r=[],s=await e.array();n.squeeze=A.squeeze(e);let a=A.split(n.squeeze,6,1);n.stack=A.stack([a[1],a[0],a[3],a[2]],1),n.boxes=A.squeeze(n.stack),n.scores=A.squeeze(a[4]),n.classes=A.squeeze(a[5]),A.dispose([e,...a]),n.nms=await A.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let i=await n.nms.data(),l=0;for(let x of Array.from(i)){let d=Math.trunc(100*s[0][x][4])/100,y=s[0][x][5],c=be[y].label,[f,b]=[s[0][x][0]/ae,s[0][x][1]/ae],m=[f,b,s[0][x][2]/ae-f,s[0][x][3]/ae-b],M=[Math.trunc(m[0]*t[0]),Math.trunc(m[1]*t[1]),Math.trunc(m[2]*t[0]),Math.trunc(m[3]*t[1])];r.push({id:l++,score:d,class:y,label:c,box:M,boxRaw:m})}return Object.keys(n).forEach(x=>A.dispose(n[x])),r}async function g5(e,t){let o=(t.object.skipTime||0)>g()-T1,n=b5<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&h5.length>0?(b5++,h5):(b5=0,new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[ae,ae]),i=t.object.enabled?G0==null?void 0:G0.execute(a,["tower_0/detections"]):null;T1=g(),A.dispose(a);let l=await ir(i,s,t);h5=l,r(l)}))}var ut={};ne(ut,{connected:()=>v5,kpt:()=>P5});var P5=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],v5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var A0,E1=0,l0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},M5=Number.MAX_SAFE_INTEGER;async function z1(e){return T.initial&&(A0=null),A0?e.debug&&h("cached model:",A0.modelUrl):A0=await I(e.body.modelPath),A0}async function lr(e,t){let[o,n]=e.shape,r=A.reshape(e,[n*o]),s=A.max(r,0),a=(await s.data())[0];if(A.dispose([r,s]),a>t){let i=A.argMax(r,0),l=A.mod(i,o),x=(await l.data())[0],d=A.div(i,A.scalar(o,"int32")),y=(await d.data())[0];return A.dispose([l,d]),[x,y,a]}return[0,0,a]}async function R5(e,t){let o=(t.body.skipTime||0)>g()-E1,n=M5<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(l0.keypoints).length>0?(M5++,[l0]):(M5=0,new Promise(async r=>{var y;let s=A.tidy(()=>{if(!(A0!=null&&A0.inputs[0].shape))return null;let c=A.image.resizeBilinear(e,[A0.inputs[0].shape[2],A0.inputs[0].shape[1]],!1),f=A.mul(c,N.tf2);return A.sub(f,N.tf1)}),a;if(t.body.enabled&&(a=A0==null?void 0:A0.execute(s)),E1=g(),A.dispose(s),a){l0.keypoints.length=0;let c=a.squeeze();A.dispose(a);let f=c.unstack(2);A.dispose(c);for(let b=0;b(((y=t.body)==null?void 0:y.minConfidence)||0)&&l0.keypoints.push({score:Math.round(100*P)/100,part:P5[b],positionRaw:[m/A0.inputs[0].shape[2],M/A0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/A0.inputs[0].shape[2]),Math.round(e.shape[1]*M/A0.inputs[0].shape[1])]})}f.forEach(b=>A.dispose(b))}l0.score=l0.keypoints.reduce((c,f)=>f.score>c?f.score:c,0);let i=l0.keypoints.map(c=>c.position[0]),l=l0.keypoints.map(c=>c.position[1]);l0.box=[Math.min(...i),Math.min(...l),Math.max(...i)-Math.min(...i),Math.max(...l)-Math.min(...l)];let x=l0.keypoints.map(c=>c.positionRaw[0]),d=l0.keypoints.map(c=>c.positionRaw[1]);l0.boxRaw=[Math.min(...x),Math.min(...d),Math.max(...x)-Math.min(...x),Math.max(...d)-Math.min(...d)];for(let[c,f]of Object.entries(v5)){let b=[];for(let m=0;mu.part===f[m]),P=l0.keypoints.find(u=>u.part===f[m+1]);M&&P&&M.score>(t.body.minConfidence||0)&&P.score>(t.body.minConfidence||0)&&b.push([M.position,P.position])}l0.annotations[c]=b}r([l0])}))}var yr=["angry","disgust","fear","happy","sad","surprise","neutral"],b0,ht=[],S1=0,C1=0,T5=Number.MAX_SAFE_INTEGER;async function W1(e){var t;return T.initial&&(b0=null),b0?e.debug&&h("cached model:",b0.modelUrl):b0=await I((t=e.face.emotion)==null?void 0:t.modelPath),b0}async function w5(e,t,o,n){var a,i;if(!b0)return[];let r=T5<(((a=t.face.emotion)==null?void 0:a.skipFrames)||0),s=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>g()-C1;return t.skipAllowed&&s&&r&&S1===n&&ht[o]&&ht[o].length>0?(T5++,ht[o]):(T5=0,new Promise(async l=>{var d,y;let x=[];if((d=t.face.emotion)!=null&&d.enabled){let c={},f=b0!=null&&b0.inputs[0].shape?b0.inputs[0].shape[2]:0;c.resize=A.image.resizeBilinear(e,[f,f],!1),c.channels=A.mul(c.resize,N.rgb),c.grayscale=A.sum(c.channels,3,!0),c.grayscaleSub=A.sub(c.grayscale,N.tf05),c.grayscaleMul=A.mul(c.grayscaleSub,N.tf2),c.emotion=b0==null?void 0:b0.execute(c.grayscaleMul),C1=g();let b=await c.emotion.data();for(let m=0;m(((y=t.face.emotion)==null?void 0:y.minConfidence)||0)&&x.push({score:Math.min(.99,Math.trunc(100*b[m])/100),emotion:yr[m]});x.sort((m,M)=>M.score-m.score),Object.keys(c).forEach(m=>A.dispose(c[m]))}ht[o]=x,S1=n,l(x)}))}var d0,k5=[],L1=0,I1=0,N1=Number.MAX_SAFE_INTEGER;async function F1(e){return T.initial&&(d0=null),d0?e.debug&&h("cached model:",d0.modelUrl):d0=await I(e.face.mobilefacenet.modelPath),d0}async function E5(e,t,o,n){var a,i;if(!d0)return[];let r=N1<(((a=t.face.embedding)==null?void 0:a.skipFrames)||0),s=(((i=t.face.embedding)==null?void 0:i.skipTime)||0)>g()-I1;return t.skipAllowed&&s&&r&&L1===n&&k5[o]?(N1++,k5[o]):new Promise(async l=>{var d;let x=[];if(((d=t.face.embedding)==null?void 0:d.enabled)&&(d0==null?void 0:d0.inputs[0].shape)){let y={};y.crop=A.image.resizeBilinear(e,[d0.inputs[0].shape[2],d0.inputs[0].shape[1]],!1),y.data=d0==null?void 0:d0.execute(y.crop);let c=await y.data.data();x=Array.from(c)}k5[o]=x,L1=n,I1=g(),l(x)})}var B0,Y0=0,xr=2.3,z5=M0.leftEyeLower0,j5=M0.rightEyeLower0,ge={leftBounds:[z5[0],z5[z5.length-1]],rightBounds:[j5[0],j5[j5.length-1]]},Pe={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function Z1(e){var t;return T.initial&&(B0=null),B0?e.debug&&h("cached model:",B0.modelUrl):B0=await I((t=e.face.iris)==null?void 0:t.modelPath),Y0=B0.inputs[0].shape?B0.inputs[0].shape[2]:0,Y0===-1&&(Y0=64),B0}function bt(e,t,o,n){for(let r=0;r{let t=e[ge.leftBounds[0]][2],o=e[ge.rightBounds[0]][2];return t-o},B1=(e,t,o,n,r,s=!1)=>{let a=yt(lt(A1([e[o],e[n]]),xr)),i=ue(a),l=A.image.cropAndResize(t,[[a.startPoint[1]/r,a.startPoint[0]/r,a.endPoint[1]/r,a.endPoint[0]/r]],[0],[Y0,Y0]);if(s&&T.kernels.includes("flipleftright")){let x=A.image.flipLeftRight(l);A.dispose(l),l=x}return{box:a,boxSize:i,crop:l}},H1=(e,t,o,n=!1)=>{let r=[];for(let s=0;s{let n=e[M0[`${o}EyeUpper0`][Pe.upperCenter]][2],r=e[M0[`${o}EyeLower0`][Pe.lowerCenter]][2],s=(n+r)/2;return t.map((a,i)=>{let l=s;return i===2?l=n:i===4&&(l=r),[a[0],a[1],l]})};async function D1(e,t,o,n){if(!B0)return o.debug&&h("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:s,crop:a}=B1(e,t,ge.leftBounds[0],ge.leftBounds[1],n,!0),{box:i,boxSize:l,crop:x}=B1(e,t,ge.rightBounds[0],ge.rightBounds[1],n,!0),d=A.concat([a,x]);A.dispose(a),A.dispose(x);let y=B0.execute(d);A.dispose(d);let c=await y.data();A.dispose(y);let f=c.slice(0,Pe.numCoordinates*3),{rawCoords:b,iris:m}=H1(f,r,s,!0),M=c.slice(Pe.numCoordinates*3),{rawCoords:P,iris:u}=H1(M,i,l,!1),p=cr(e);Math.abs(p)<30?(bt(e,b,"left",null),bt(e,P,"right",null)):p<1?bt(e,b,"left",["EyeUpper0","EyeLower0"]):bt(e,P,"right",["EyeUpper0","EyeLower0"]);let v=V1(e,m,"left"),w=V1(e,u,"right");return e.concat(v).concat(w)}var f0={eyeLLower:[33,7,163,144,145,153,154,155,133],eyeRLower:[263,249,390,373,374,380,381,382,362],lips:[185,96,90,181,84,17,314,405,320,307,409,40,39,73,37,0,267,269,270,409,40,88,178,178,87,14,268,402,318,324,409,80,41,38,87,12,268,303,318,324,185,95,80,81,85,16,315,404,319,325,409,40,39,73,72,0,302,303,270,408,185,88,88,81,82,15,316,403,319,324,409,80,41,38,87,12,268,303,318,324],eyeL:[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],eyeR:[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417]};async function q1(e,t){let o={irisL:t[3].dataSync(),irisR:t[1].dataSync(),eyeL:t[0].dataSync(),eyeR:t[6].dataSync(),lips:t[5].dataSync()},n=f0.eyeRLower.reduce((s,a)=>s+=e[a][2],0)/f0.eyeRLower.length;for(let s=0;ss+=e[a][2],0)/f0.eyeLLower.length;for(let s=0;sg()-j0.timestamp,n=j0.skipped<(((l=t.face.detector)==null?void 0:l.skipFrames)||0);!t.skipAllowed||!o||!n||j0.boxes.length===0?(j0.boxes=await f1(e,t),j0.timestamp=g(),j0.skipped=0):j0.skipped++;let r=[],s=[],a=0;for(let P=0;PG.shape[G.shape.length-1]===1),C=S.find(G=>G.shape[G.shape.length-1]===1404),L=await O.data();w.faceScore=Math.round(100*L[0])/100;let Z=A.reshape(C,[-1,3]),F=await Z.array();if(w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1))u.confidence=w.faceScore;else{(b=t.face.attention)!=null&&b.enabled?F=await q1(F,S):(m=t.face.iris)!=null&&m.enabled&&(F=await D1(F,w.tensor,t,ve)),w.mesh=i1(F,u,p,v,ve),w.meshRaw=w.mesh.map(Y=>[Y[0]/(e.shape[2]||0),Y[1]/(e.shape[1]||0),(Y[2]||0)/ve]);for(let Y of Object.keys(M0))w.annotations[Y]=M0[Y].map(z=>w.mesh[z]);w.score=w.faceScore;let G={...y1(w.mesh,u),confidence:u.confidence,landmarks:u.landmarks};w.box=x5(G,e),w.boxRaw=c5(G,e),s.push(G)}A.dispose([...S,Z])}else{w.box=x5(u,e),w.boxRaw=c5(u,e),w.score=w.boxScore,w.mesh=u.landmarks.map(S=>[(u.startPoint[0]+u.endPoint[0])/2+(u.endPoint[0]+u.startPoint[0])*S[0]/xt(),(u.startPoint[1]+u.endPoint[1])/2+(u.endPoint[1]+u.startPoint[1])*S[1]/xt()]),w.meshRaw=w.mesh.map(S=>[S[0]/(e.shape[2]||0),S[1]/(e.shape[1]||0),(S[2]||0)/ve]);for(let S of Object.keys(De))w.annotations[S]=[w.mesh[De[S]]]}w.score>(((M=t.face.detector)==null?void 0:M.minConfidence)||1)?r.push(w):A.dispose(w.tensor)}return j0.boxes=s,r}async function J1(e){var t,o,n;return T.initial&&(S0=null),S0?e.debug&&h("cached model:",S0.modelUrl):(t=e.face.attention)!=null&&t.enabled?S0=await I((o=e.face.attention)==null?void 0:o.modelPath):S0=await I((n=e.face.mesh)==null?void 0:n.modelPath),ve=S0.inputs[0].shape?S0.inputs[0].shape[2]:0,S0}var Y1=Ae,K1=Xe;var m0,gt=[],Q1=0,_1=0,C5=Number.MAX_SAFE_INTEGER;async function $1(e){var t;return T.initial&&(m0=null),m0?e.debug&&h("cached model:",m0.modelUrl):m0=await I((t=e.face.description)==null?void 0:t.modelPath),m0}function W5(e){let t=e.image||e.tensor||e;if(!(m0!=null&&m0.inputs[0].shape))return t;let o=A.image.resizeBilinear(t,[m0.inputs[0].shape[2],m0.inputs[0].shape[1]],!1),n=A.mul(o,N.tf255);return A.dispose(o),n}async function O5(e,t,o,n){var a,i,l,x;if(!m0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=C5<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((i=t.face.description)==null?void 0:i.skipTime)||0)>g()-Q1;return t.skipAllowed&&r&&s&&_1===n&&((l=gt[o])==null?void 0:l.age)&&((x=gt[o])==null?void 0:x.age)>0?(C5++,gt[o]):(C5=0,new Promise(async d=>{var c,f;let y={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((c=t.face.description)!=null&&c.enabled){let b=W5(e),m=m0==null?void 0:m0.execute(b);Q1=g(),A.dispose(b);let P=await(await m.find(L=>L.shape[1]===1)).data(),u=Math.trunc(200*Math.abs(P[0]-.5))/100;u>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(y.gender=P[0]<=.5?"female":"male",y.genderScore=Math.min(.99,u));let p=A.argMax(m.find(L=>L.shape[1]===100),1),v=(await p.data())[0];A.dispose(p);let S=await m.find(L=>L.shape[1]===100).data();y.age=Math.round(S[v-1]>S[v+1]?10*v-100*S[v-1]:10*v+100*S[v+1])/10;let O=m.find(L=>L.shape[1]===1024),C=O?await O.data():[];y.descriptor=Array.from(C),m.forEach(L=>A.dispose(L))}gt[o]=y,_1=n,d(y)}))}function Pt(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function Je(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function oo(e,t,o){let n=t.shape[1],r=t.shape[2],s=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return A.image.cropAndResize(t,s,[0],o)}function no(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(s=>[s[0]*t[0],s[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function vt(e,t=1.5){let o=Je(e),n=Pt(e),r=[t*n[0]/2,t*n[1]/2],s=[o[0]-r[0],o[1]-r[1]],a=[o[0]+r[0],o[1]+r[1]];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function Mt(e){let t=Je(e),o=Pt(e),r=Math.max(...o)/2,s=[t[0]-r,t[1]-r],a=[t[0]+r,t[1]+r];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function fr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function ro(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return fr(o)}var eo=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function K0(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=A.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=A.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=A.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=A.slice(t,[0,0],[-1,2]),o.boxSizes=A.slice(t,[0,2],[-1,2]),o.div=A.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=A.add(o.div,this.anchorsTensor),o.halfBoxSizes=A.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=A.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=A.mul(o.sub,this.inputSizeTensor),o.add=A.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=A.mul(o.add,this.inputSizeTensor);let n=A.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>A.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=A.reshape(t,[-1,7,2]),n.div=A.div(n.reshape,this.inputSizeTensor),n.landmarks=A.add(n.div,this.anchors[o]);let r=A.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(s=>A.dispose(n[s])),r}async predict(t,o){let n={};n.resize=A.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=A.div(n.resize,N.tf127),n.image=A.sub(n.div,N.tf1),n.batched=this.model.execute(n.image),n.predictions=A.squeeze(n.batched),n.slice=A.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=A.sigmoid(n.slice),n.scores=A.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=A.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await A.image.nonMaxSuppressionAsync(n.norm,n.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let s=await n.nms.array(),a=[];for(let i of s){let l={};l.box=A.slice(n.norm,[i,0],[1,-1]),l.slice=A.slice(n.predictions,[i,5],[1,14]),l.norm=this.normalizeLandmarks(l.slice,i),l.palmLandmarks=A.reshape(l.norm,[-1,2]);let x=await l.box.data(),d=x.slice(0,2),y=x.slice(2,4),c=await l.palmLandmarks.array(),f={startPoint:d,endPoint:y,palmLandmarks:c,confidence:r[i]},b=no(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);a.push(b),Object.keys(l).forEach(m=>A.dispose(l[m]))}return Object.keys(n).forEach(i=>A.dispose(n[i])),a}};var hr=5,io=1.65,lo=[0,5,9,13,17,1,2],br=0,gr=2,yo=0,Tt=class{constructor(t,o){k(this,"handDetector");k(this,"handPoseModel");k(this,"inputSize");k(this,"storedBoxes");k(this,"skipped");k(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[2]:0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(a=>a[0]),n=t.map(a=>a[1]),r=[Math.min(...o),Math.min(...n)],s=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:s}}getBoxForPalmLandmarks(t,o){let n=t.map(s=>N5([...s,1],o)),r=this.calculateLandmarksBoundingBox(n);return vt(Mt(r),hr)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=vt(Mt(o),io);n.palmLandmarks=[];for(let r=0;r[a[0]*(f[0]-this.inputSize/2),a[1]*(f[1]-this.inputSize/2),a[2]*f[2]]),l=I5(n,[0,0]),x=i.map(f=>[...N5(f,l),f[2]]),d=Ao(r),y=[...Je(o),1],c=[K0(y,d[0]),K0(y,d[1])];return x.map(f=>[Math.trunc(f[0]+c[0]),Math.trunc(f[1]+c[1]),Math.trunc(f[2])])}async estimateHands(t,o){let n=!1,r,s=(o.hand.skipTime||0)>g()-yo,a=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&s&&a&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let i=[];for(let l=0;l=o.hand.minConfidence/4){let w=A.reshape(p,[-1,3]),S=await w.array();A.dispose(p),A.dispose(w);let O=this.transformRawCoords(S,m,d,b),C=this.getBoxForHandLandmarks(O);this.storedBoxes[l]={...C,confidence:v};let L={landmarks:O,confidence:v,boxConfidence:x.confidence,fingerConfidence:v,box:{topLeft:C.startPoint,bottomRight:C.endPoint}};i.push(L)}else this.storedBoxes[l]=null;A.dispose(p)}else{let d=vt(Mt(x),io),y={confidence:x.confidence,boxConfidence:x.confidence,fingerConfidence:0,box:{topLeft:d.startPoint,bottomRight:d.endPoint},landmarks:[]};i.push(y)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=i.length,i.length>o.hand.maxDetected&&(i.length=o.hand.maxDetected),i}};var y0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>y0.nameMapping[e],getPoints:e=>y0.pointsMapping[e]},_0={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>_0.nameMapping[e]},J={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>J.nameMapping[e]},Q0=class{constructor(t){k(this,"name");k(this,"curls");k(this,"directions");k(this,"weights");k(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,s)=>r+s,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let s=t[r],a=this.curls[r];if(typeof a=="undefined"){n+=this.weightsRelative[r];continue}for(let[i,l]of a)if(s===i){n+=l*this.weightsRelative[r];break}}for(let r in o){let s=o[r],a=this.directions[r];if(typeof a=="undefined"){n+=this.weightsRelative[r];continue}for(let[i,l]of a)if(s===i){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:T0,index:H0,middle:V0,ring:ie,pinky:le}=y0,{none:w0,half:vr,full:k0}=_0,{verticalUp:Me,verticalDown:F3,horizontalLeft:F5,horizontalRight:Mr,diagonalUpRight:Rr,diagonalUpLeft:Re,diagonalDownRight:G3,diagonalDownLeft:B3}=J,$0=new Q0("thumbs up");$0.curl(T0,w0,1);$0.direction(T0,Me,1);$0.direction(T0,Re,.25);$0.direction(T0,Rr,.25);for(let e of[y0.index,y0.middle,y0.ring,y0.pinky])$0.curl(e,k0,1),$0.direction(e,F5,1),$0.direction(e,Mr,1);var e0=new Q0("victory");e0.curl(T0,vr,.5);e0.curl(T0,w0,.5);e0.direction(T0,Me,1);e0.direction(T0,Re,1);e0.curl(H0,w0,1);e0.direction(H0,Me,.75);e0.direction(H0,Re,1);e0.curl(V0,w0,1);e0.direction(V0,Me,1);e0.direction(V0,Re,.75);e0.curl(ie,k0,1);e0.direction(ie,Me,.2);e0.direction(ie,Re,1);e0.direction(ie,F5,.2);e0.curl(le,k0,1);e0.direction(le,Me,.2);e0.direction(le,Re,1);e0.direction(le,F5,.2);e0.weight(H0,2);e0.weight(V0,2);var ee=new Q0("point");ee.curl(T0,k0,1);ee.curl(H0,w0,.5);ee.curl(V0,k0,.5);ee.curl(ie,k0,.5);ee.curl(le,k0,.5);ee.weight(H0,2);ee.weight(V0,2);var te=new Q0("middle finger");te.curl(T0,w0,1);te.curl(H0,k0,.5);te.curl(V0,k0,.5);te.curl(ie,k0,.5);te.curl(le,k0,.5);te.weight(H0,2);te.weight(V0,2);var Te=new Q0("open palm");Te.curl(T0,w0,.75);Te.curl(H0,w0,.75);Te.curl(V0,w0,.75);Te.curl(ie,w0,.75);Te.curl(le,w0,.75);var xo=[$0,e0,ee,te,Te];var Tr=.7,ye={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function co(e,t,o,n){let r=(t-n)/(e-o),s=Math.atan(r)*180/Math.PI;return s<=0?s=-s:s>0&&(s=180-s),s}function mo(e,t){if(!e||!t)return[0,0];let o=co(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=co(e[1],e[2],t[1],t[2]);return[o,n]}function fo(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function wr(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],i=e[1]-o[1],l=t[1]-o[1],x=e[2]-t[2],d=e[2]-o[2],y=t[2]-o[2],c=Math.sqrt(n*n+a*a+x*x),f=Math.sqrt(r*r+i*i+d*d),b=Math.sqrt(s*s+l*l+y*y),m=(b*b+c*c-f*f)/(2*b*c);m>1?m=1:m<-1&&(m=-1);let M=Math.acos(m);M=57.2958*M%180;let P;return M>ye.NO_CURL_START_LIMIT?P=_0.none:M>ye.HALF_CURL_START_LIMIT?P=_0.half:P=_0.full,P}function po(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=J.horizontalLeft:r=J.horizontalRight:n===Math.abs(t)?t>0?r=J.horizontalLeft:r=J.horizontalRight:o>0?r=J.horizontalLeft:r=J.horizontalRight,r}function uo(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=J.verticalDown:r=J.verticalUp:n===Math.abs(t)?t<0?r=J.verticalDown:r=J.verticalUp:o<0?r=J.verticalDown:r=J.verticalUp,r}function kr(e,t,o,n,r,s,a,i){let l,x=uo(e,t,o,n),d=po(r,s,a,i);return x===J.verticalUp?d===J.horizontalLeft?l=J.diagonalUpLeft:l=J.diagonalUpRight:d===J.horizontalLeft?l=J.diagonalDownLeft:l=J.diagonalDownRight,l}function Er(e,t,o,n){let r=e[0]-t[0],s=e[0]-o[0],a=t[0]-o[0],i=e[1]-t[1],l=e[1]-o[1],x=t[1]-o[1],d=Math.max(Math.abs(r),Math.abs(s),Math.abs(a)),y=Math.max(Math.abs(i),Math.abs(l),Math.abs(x)),c=0,f=0,b=0,m=y/(d+1e-5);m>1.5?c+=ye.DISTANCE_VOTE_POWER:m>.66?f+=ye.DISTANCE_VOTE_POWER:b+=ye.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+i*i),P=Math.sqrt(s*s+l*l),u=Math.sqrt(a*a+x*x),p=Math.max(M,P,u),v=e[0],w=e[1],S=o[0],O=o[1];p===M?(S=o[0],O=o[1]):p===u&&(v=t[0],w=t[1]);let Z=mo([v,w],[S,O]),F=fo(Z,ye.TOTAL_ANGLE_VOTE_POWER);c+=F[0],f+=F[1],b+=F[2];for(let Y of n){let z=fo(Y,ye.SINGLE_ANGLE_VOTE_POWER);c+=z[0],f+=z[1],b+=z[2]}let G;return c===Math.max(c,f,b)?G=uo(l,i,x,y):b===Math.max(f,b)?G=po(s,r,a,d):G=kr(l,i,x,y,s,r,a,d),G}function ho(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let s of y0.all){let a=y0.getPoints(s),i=[],l=[];for(let x of a){let d=e[x[0]],y=e[x[1]],c=mo(d,y),f=c[0],b=c[1];i.push(f),l.push(b)}t.push(i),o.push(l)}for(let s of y0.all){let a=s===y0.thumb?1:0,i=y0.getPoints(s),l=e[i[a][0]],x=e[i[a+1][1]],d=e[i[3][1]],y=wr(l,x,d),c=Er(l,x,d,t[s].slice(a));n[s]=y,r[s]=c}return{curls:n,directions:r}}function wt(e){if(!e||e.length===0)return null;let t=ho(e),o={};for(let n of y0.all)o[y0.getName(n)]={curl:_0.getName(t.curls[n]),direction:J.getName(t.directions[n])};return o}function bo(e){let t=[];if(!e||e.length===0)return t;let o=ho(e);for(let n of xo){let r=n.matchAgainst(o.curls,o.directions);r>=Tr&&t.push({name:n.name,confidence:r})}return t}var go={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},we,ke,Po;async function B5(e,t){let o=await Po.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[y]);let a=o[r].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(a&&a.length>0){for(let d of a)d[0]i[2]&&(i[2]=d[0]),d[1]>i[3]&&(i[3]=d[1]);i[2]-=i[0],i[3]-=i[1],l=[i[0]/(e.shape[2]||0),i[1]/(e.shape[1]||0),i[2]/(e.shape[2]||0),i[3]/(e.shape[1]||0)]}else i=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],l=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let x=wt(a);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:i,boxRaw:l,keypoints:a,annotations:s,landmarks:x})}return n}async function H5(e){var o,n;T.initial&&(we=null,ke=null),!we||!ke?[we,ke]=await Promise.all([e.hand.enabled?I((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?I((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&h("cached model:",we.modelUrl),e.debug&&h("cached model:",ke.modelUrl));let t=new Rt(we);return Po=new Tt(t,ke),[we,ke]}var o0=[null,null],zr=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],oe=[[0,0],[0,0]],jr=["hand","fist","pinch","point","face","tip","pinchtip"],Mo=4,Ro=1.6,Sr=512,Cr=1.4,kt=Number.MAX_SAFE_INTEGER,V5=0,Z0=[0,0],Q={boxes:[],hands:[]},To={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function wo(e){var t;if(T.initial&&(o0[0]=null),o0[0])e.debug&&h("cached model:",o0[0].modelUrl);else{Et(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),o0[0]=await I((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(o0[0].modelSignature.inputs);oe[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,oe[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return o0[0]}async function ko(e){var t;if(T.initial&&(o0[1]=null),o0[1])e.debug&&h("cached model:",o0[1].modelUrl);else{o0[1]=await I((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(o0[1].modelSignature.inputs);oe[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,oe[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return o0[1]}async function Wr(e,t){let o=[];if(!e||!o0[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),s=Math.min(Math.round((e.shape[1]||0)/8)*8,Sr),a=Math.round(s*r/8)*8;n.resize=A.image.resizeBilinear(e,[s,a]),n.cast=A.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await o0[0].executeAsync(n.cast,zr),n.boxes=A.squeeze(n.rawBoxes,[0,2]),n.scores=A.squeeze(n.rawScores,[0]);let i=A.unstack(n.scores,1);A.dispose(i[Mo]),i.splice(Mo,1),n.filtered=A.stack(i,1),A.dispose(i),n.max=A.max(n.filtered,1),n.argmax=A.argMax(n.filtered,1);let l=0;n.nms=await A.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let x=await n.nms.data(),d=await n.max.data(),y=await n.argmax.data();for(let c of Array.from(x)){let f=A.slice(n.boxes,c,1),b=await f.data();A.dispose(f);let m=[b[1],b[0],b[3]-b[1],b[2]-b[0]],M=ft(m,Cr),P=[Math.trunc(m[0]*Z0[0]),Math.trunc(m[1]*Z0[1]),Math.trunc(m[2]*Z0[0]),Math.trunc(m[3]*Z0[1])],u=d[c],p=jr[y[c]],v={id:l++,score:u,box:P,boxRaw:M,label:p};o.push(v)}return Object.keys(n).forEach(c=>A.dispose(n[c])),o.sort((c,f)=>f.score-c.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function Z5(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&o0[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},s=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=A.image.cropAndResize(e,[s],[0],[oe[1][0],oe[1][1]],"bilinear"),r.div=A.div(r.crop,N.tf255),[r.score,r.keypoints]=o0[1].execute(r.div,["Identity_1","Identity"]);let a=(await r.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(a))))/100;if(i>=(o.hand.minConfidence||0)){n.fingerScore=i,r.reshaped=A.reshape(r.keypoints,[-1,3]);let d=(await r.reshaped.array()).map(y=>[y[0]/oe[1][1],y[1]/oe[1][0],y[2]||0]).map(y=>[y[0]*t.boxRaw[2],y[1]*t.boxRaw[3],y[2]||0]);n.keypoints=d.map(y=>[Z0[0]*(y[0]+t.boxRaw[0]),Z0[1]*(y[1]+t.boxRaw[1]),y[2]||0]),n.landmarks=wt(n.keypoints);for(let y of Object.keys(To))n.annotations[y]=To[y].map(c=>n.landmarks&&n.keypoints[c]?n.keypoints[c]:null)}Object.keys(r).forEach(l=>A.dispose(r[l]))}return n}async function D5(e,t){var r,s;if(!o0[0]||!o0[1]||!((r=o0[0])!=null&&r.inputs[0].shape)||!((s=o0[1])!=null&&s.inputs[0].shape))return[];Z0=[e.shape[2]||0,e.shape[1]||0],kt++;let o=(t.hand.skipTime||0)>g()-V5,n=kt<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?Q.hands:new Promise(async a=>{let i=3*(t.hand.skipTime||0)>g()-V5,l=kt<3*(t.hand.skipFrames||0);t.skipAllowed&&Q.hands.length===t.hand.maxDetected?Q.hands=await Promise.all(Q.boxes.map(d=>Z5(e,d,t))):t.skipAllowed&&i&&l&&Q.hands.length>0?Q.hands=await Promise.all(Q.boxes.map(d=>Z5(e,d,t))):(Q.boxes=await Wr(e,t),V5=g(),Q.hands=await Promise.all(Q.boxes.map(d=>Z5(e,d,t))),kt=0);let x=[...Q.boxes];if(Q.boxes.length=0,t.cacheSensitivity>0)for(let d=0;d.05&&y.box[3]/(e.shape[1]||1)>.05&&Q.hands[d].fingerScore&&Q.hands[d].fingerScore>(t.hand.minConfidence||0)){let c=ft(y.box,Ro),f=ft(y.boxRaw,Ro);Q.boxes.push({...x[d],box:c,boxRaw:f})}}for(let d=0;dg()-jo,s=X5<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&zo===n&&zt[o]?(X5++,zt[o]):(X5=0,new Promise(async l=>{let x=A.image.resizeBilinear(e,[s0!=null&&s0.inputs[0].shape?s0.inputs[0].shape[2]:0,s0!=null&&s0.inputs[0].shape?s0.inputs[0].shape[1]:0],!1),d=s0==null?void 0:s0.execute(x),y=(await d.data())[0];zt[o]=Math.round(100*y)/100,zo=n,jo=g(),A.dispose([x,d]),l(zt[o])}))}var Ye={};ne(Ye,{connected:()=>St,horizontal:()=>U5,kpt:()=>jt,relative:()=>Y5,vertical:()=>J5});var jt=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],U5=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],J5=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],Y5=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],St={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Wo=.005,p0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function K5(e){for(let t of U5){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]x&&x.part===t[0]),r=e.keypoints.findIndex(x=>x&&x.part===t[1]),s=e.keypoints.findIndex(x=>x&&x.part===o[0]),a=e.keypoints.findIndex(x=>x&&x.part===o[1]);if(!e.keypoints[s]||!e.keypoints[a])continue;let i=e.keypoints[n]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0])]:[0,0];if(i[0]>i[1]||l[0]>l[1]){let x=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=x}}}function Oo(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=A.pad(e,p0.padding),o.resize=A.image.resizeBilinear(o.pad,[t,t]);let n=A.cast(o.resize,"int32");return Object.keys(o).forEach(r=>A.dispose(o[r])),n}function Io(e,t){e.keypoints=e.keypoints.filter(n=>n&&n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+p0.padding[2][0]+p0.padding[2][1])/t[0]-p0.padding[2][0],n.position[1]*(t[1]+p0.padding[1][0]+p0.padding[1][1])/t[1]-p0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=F0(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var u0,Ct=0,Q5=Number.MAX_SAFE_INTEGER,xe={boxes:[],bodies:[],last:0};async function No(e){return T.initial&&(u0=null),u0?e.debug&&h("cached model:",u0.modelUrl):(Et(["size"],e),u0=await I(e.body.modelPath)),Ct=u0.inputs[0].shape?u0.inputs[0].shape[2]:0,Ct<64&&(Ct=256),u0}async function Lr(e,t,o){let n=e[0][0],r=[],s=0;for(let d=0;dt.body.minConfidence){let y=[n[d][1],n[d][0]];r.push({score:Math.round(100*s)/100,part:jt[d],positionRaw:y,position:[Math.round((o.shape[2]||0)*y[0]),Math.round((o.shape[1]||0)*y[1])]})}s=r.reduce((d,y)=>y.score>d?y.score:d,0);let a=[],i=F0(r.map(d=>d.position),[o.shape[2],o.shape[1]]),l={};for(let[d,y]of Object.entries(St)){let c=[];for(let f=0;fM.part===y[f]),m=r.find(M=>M.part===y[f+1]);b&&m&&b.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&c.push([b.position,m.position])}l[d]=c}let x={id:0,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:r,annotations:l};return K5(x),a.push(x),a}async function Ir(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let i=[];for(let y=0;y<17;y++){let c=s[3*y+2];if(c>t.body.minConfidence){let f=[s[3*y+1],s[3*y+0]];i.push({part:jt[y],score:Math.round(100*c)/100,positionRaw:f,position:[Math.round((o.shape[2]||0)*f[0]),Math.round((o.shape[1]||0)*f[1])]})}}let l=F0(i.map(y=>y.position),[o.shape[2],o.shape[1]]),x={};for(let[y,c]of Object.entries(St)){let f=[];for(let b=0;bP.part===c[b]),M=i.find(P=>P.part===c[b+1]);m&&M&&m.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&f.push([m.position,M.position])}x[y]=f}let d={id:r,score:a,box:l.box,boxRaw:l.boxRaw,keypoints:[...i],annotations:x};K5(d),n.push(d)}}return n.sort((r,s)=>s.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function _5(e,t){if(!u0||!(u0!=null&&u0.inputs[0].shape))return[];t.skipAllowed||(xe.boxes.length=0),Q5++;let o=(t.body.skipTime||0)>g()-xe.last,n=Q5<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?xe.bodies:new Promise(async r=>{let s={};Q5=0,s.input=Lo(e,Ct),s.res=u0==null?void 0:u0.execute(s.input),xe.last=g();let a=await s.res.array();xe.bodies=s.res.shape[2]===17?await Lr(a,t,e):await Ir(a,t,e);for(let i of xe.bodies)Io(i,[e.shape[2]||1,e.shape[1]||1]),Oo(i.keypoints);Object.keys(s).forEach(i=>A.dispose(s[i])),r(xe.bodies)})}var Ee,Wt=[],Go=0,$5=Number.MAX_SAFE_INTEGER,Lt=0,Ot=2.5;async function Bo(e){if(!Ee||T.initial){Ee=await I(e.object.modelPath);let t=Object.values(Ee.modelSignature.inputs);Lt=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&h("cached model:",Ee.modelUrl);return Ee}async function Nr(e,t,o){let n=0,r=[];for(let l of[1,2,4])A.tidy(async()=>{let x=l*13,d=A.squeeze(e.find(m=>m.shape[1]===x**2&&(m.shape[2]||0)===be.length)),y=A.squeeze(e.find(m=>m.shape[1]===x**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&M!==61){let u=(.5+Math.trunc(m%x))/x,p=(.5+Math.trunc(m/x))/x,v=f[m].map(G=>G*(x/l/Lt)),[w,S]=[u-Ot/l*v[0],p-Ot/l*v[1]],[O,C]=[u+Ot/l*v[2]-w,p+Ot/l*v[3]-S],L=[w,S,O,C];L=L.map(G=>Math.max(0,Math.min(G,1)));let Z=[L[0]*t[0],L[1]*t[1],L[2]*t[0],L[3]*t[1]],F={id:n++,score:Math.round(100*P)/100,class:M+1,label:be[M].label,box:Z.map(G=>Math.trunc(G)),boxRaw:L};r.push(F)}}});e.forEach(l=>A.dispose(l));let s=r.map(l=>[l.boxRaw[1],l.boxRaw[0],l.boxRaw[3],l.boxRaw[2]]),a=r.map(l=>l.score),i=[];if(s&&s.length>0){let l=await A.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);i=await l.data(),A.dispose(l)}return r=r.filter((l,x)=>i.includes(x)).sort((l,x)=>x.score-l.score),r}async function e2(e,t){let o=(t.object.skipTime||0)>g()-Go,n=$5<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&Wt.length>0?($5++,Wt):($5=0,!T.kernels.includes("mod")||!T.kernels.includes("sparsetodense")?Wt:new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[Lt,Lt],!1),i=A.div(a,N.tf255),l=i.transpose([0,3,1,2]);A.dispose(i),A.dispose(a);let x;t.object.enabled&&(x=Ee.execute(l)),Go=g(),A.dispose(l);let d=await Nr(x,s,t);Wt=d,r(d)}))}var Qe=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Fr=Qe.length,Ke=Qe.reduce((e,t,o)=>(e[t]=o,e),{}),Gr=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],ys=Gr.map(([e,t])=>[Ke[e],Ke[t]]),Vo=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function Zo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:s},{position:{x:a,y:i}})=>({maxX:Math.max(o,a),maxY:Math.max(n,i),minX:Math.min(r,a),minY:Math.min(s,i)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function Do(e,[t,o],[n,r]){let s=t/n,a=o/r,i=(x,d)=>({id:d,score:x.score,boxRaw:[x.box[0]/r,x.box[1]/n,x.box[2]/r,x.box[3]/n],box:[Math.trunc(x.box[0]*a),Math.trunc(x.box[1]*s),Math.trunc(x.box[2]*a),Math.trunc(x.box[3]*s)],keypoints:x.keypoints.map(({score:y,part:c,position:f})=>({score:y,part:c,position:[Math.trunc(f.x*a),Math.trunc(f.y*s)],positionRaw:[f.x/n,f.y/n]})),annotations:{}});return e.map((x,d)=>i(x,d))}var It=class{constructor(t,o){k(this,"priorityQueue");k(this,"numberOfElements");k(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function Xo(e,t,o,n){let r=o-e,s=n-t;return r*r+s*s}function r2(e,t){return{x:e.x+t.x,y:e.y+t.y}}var E0,Hr=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],Nt=1,ze=16,Vr=50**2;function qo(e,t,o,n,r,s,a=2){let i=P=>({y:s.get(P.y,P.x,e),x:s.get(P.y,P.x,s.shape[2]/2+e)}),l=(P,u,p)=>({y:n2(Math.round(P.y/ze),0,u-1),x:n2(Math.round(P.x/ze),0,p-1)}),[x,d]=n.shape,y=l(t.position,x,d),c=i(y),b=r2(t.position,c);for(let P=0;P[Ke[c],Ke[f]]),a=s.map(([,c])=>c),i=s.map(([c])=>c),l=t.shape[2],x=a.length,d=new Array(l),y=o2(e.part,ze,o);d[e.part.id]={score:e.score,part:Qe[e.part.id],position:y};for(let c=x-1;c>=0;--c){let f=a[c],b=i[c];d[f]&&!d[b]&&(d[b]=qo(c,d[f],b,t,o,r))}for(let c=0;ct){i=!1;break}if(!i)break}return i}function Xr(e,t){let[o,n,r]=t.shape,s=new It(o*n*r,({score:a})=>a);for(let a=0;a{var a;let s=(a=r[n])==null?void 0:a.position;return s?Xo(o,t,s.y,s.x)<=Vr:!1})}function qr(e,t){return t.reduce((n,{position:r,score:s},a)=>(Uo(e,r,a)||(n+=s),n),0)/t.length}function Ur(e,t,o,n,r,s){let a=[],i=Xr(s,t);for(;a.lengthf.score>s);let y=qr(a,d),c=Zo(d);y>s&&a.push({keypoints:d,box:c,score:Math.round(100*y)/100})}return a}async function A2(e,t){let o=A.tidy(()=>{if(!E0.inputs[0].shape)return[];let a=A.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]]),i=A.sub(A.div(A.cast(a,"float32"),127.5),1),x=E0.execute(i,Hr).map(d=>A.squeeze(d,[0]));return x[1]=A.sigmoid(x[1]),x}),n=await Promise.all(o.map(a=>a.buffer()));for(let a of o)A.dispose(a);let r=await Ur(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return E0.inputs[0].shape?Do(r,[e.shape[1],e.shape[2]],[E0.inputs[0].shape[2],E0.inputs[0].shape[1]]):[]}async function Jo(e){return!E0||T.initial?E0=await I(e.body.modelPath):e.debug&&h("cached model:",E0.modelUrl),E0}var C0,s2=!1;async function a2(e){return!C0||T.initial?C0=await I(e.segmentation.modelPath):e.debug&&h("cached model:",C0.modelUrl),C0}async function Ko(e,t,o){var m,M;if(s2)return{data:[],canvas:null,alpha:null};s2=!0,C0||await a2(o);let n=await pe(e,o),r=((m=n.tensor)==null?void 0:m.shape[2])||0,s=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let a={};a.resize=A.image.resizeBilinear(n.tensor,[C0.inputs[0].shape?C0.inputs[0].shape[1]:0,C0.inputs[0].shape?C0.inputs[0].shape[2]:0],!1),A.dispose(n.tensor),a.norm=A.div(a.resize,N.tf255),a.res=C0.execute(a.norm),a.squeeze=A.squeeze(a.res,0),a.squeeze.shape[2]===2?(a.softmax=A.softmax(a.squeeze),[a.bg,a.fg]=A.unstack(a.softmax,2),a.expand=A.expandDims(a.fg,2),a.pad=A.expandDims(a.expand,0),a.crop=A.image.cropAndResize(a.pad,[[0,0,.5,.5]],[0],[r,s]),a.data=A.squeeze(a.crop,0)):a.data=A.image.resizeBilinear(a.squeeze,[s,r]);let i=Array.from(await a.data.data());if(T.node&&!T.Canvas&&typeof ImageData=="undefined")return o.debug&&h("canvas support missing"),Object.keys(a).forEach(P=>A.dispose(a[P])),{data:i,canvas:null,alpha:null};let l=i0(r,s);A.browser&&await A.browser.toPixels(a.data,l);let x=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`);let d=x.getImageData(0,0,r,s),y=i0(r,s),c=y.getContext("2d");n.canvas&&c.drawImage(n.canvas,0,0),c.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`),c.drawImage(l,0,0),c.globalCompositeOperation="source-over",c.filter="none";let f=c.getImageData(0,0,r,s);for(let P=0;PA.dispose(a[P])),s2=!1,{data:i,canvas:y,alpha:l}}var _e=class{constructor(){k(this,"ssrnetage",null);k(this,"gear",null);k(this,"blazeposedetect",null);k(this,"blazepose",null);k(this,"centernet",null);k(this,"efficientpose",null);k(this,"mobilefacenet",null);k(this,"emotion",null);k(this,"facedetect",null);k(this,"faceiris",null);k(this,"facemesh",null);k(this,"faceres",null);k(this,"ssrnetgender",null);k(this,"handpose",null);k(this,"handskeleton",null);k(this,"handtrack",null);k(this,"liveness",null);k(this,"movenet",null);k(this,"nanodet",null);k(this,"posenet",null);k(this,"segmentation",null);k(this,"antispoof",null)}};function Ft(e){for(let t of Object.keys(e.models))e.models[t]=null}async function i2(e){var t,o,n,r,s,a,i,l,x,d,y,c,f,b,m,M,P,u,p,v,w,S,O,C,L,Z,F,G,Y,z,R0;T.initial&&Ft(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await H5(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await H5(e.config))),e.config.body.enabled&&!e.models.blazepose&&((a=(s=e.config.body)==null?void 0:s.modelPath)==null?void 0:a.includes("blazepose"))&&(e.models.blazepose=M1(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=v1(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((l=(i=e.config.body)==null?void 0:i.modelPath)==null?void 0:l.includes("efficientpose"))&&(e.models.efficientpose=z1(e.config)),e.config.body.enabled&&!e.models.movenet&&((d=(x=e.config.body)==null?void 0:x.modelPath)==null?void 0:d.includes("movenet"))&&(e.models.movenet=No(e.config)),e.config.body.enabled&&!e.models.posenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("posenet"))&&(e.models.posenet=Jo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=d1(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=e1(e.config)),e.config.face.enabled&&((b=e.config.face.liveness)==null?void 0:b.enabled)&&!e.models.liveness&&(e.models.liveness=So(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=$1(e.config)),e.config.face.enabled&&((M=e.config.face.emotion)==null?void 0:M.enabled)&&!e.models.emotion&&(e.models.emotion=W1(e.config)),e.config.face.enabled&&((P=e.config.face.iris)==null?void 0:P.enabled)&&!((u=e.config.face.attention)!=null&&u.enabled)&&!e.models.faceiris&&(e.models.faceiris=Z1(e.config)),e.config.face.enabled&&((p=e.config.face.mesh)==null?void 0:p.enabled)&&!e.models.facemesh&&(e.models.facemesh=J1(e.config)),e.config.face.enabled&&((v=e.config.face.gear)==null?void 0:v.enabled)&&!e.models.gear&&(e.models.gear=H2(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=q2(e.config)),e.config.face.enabled&&((S=e.config.face.ssrnet)==null?void 0:S.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=K2(e.config)),e.config.face.enabled&&((O=e.config.face.mobilefacenet)==null?void 0:O.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=F1(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((L=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:L.includes("handtrack"))&&(e.models.handtrack=wo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((F=(Z=e.config.hand.detector)==null?void 0:Z.modelPath)==null?void 0:F.includes("handtrack"))&&(e.models.handskeleton=ko(e.config)),e.config.object.enabled&&!e.models.centernet&&((Y=(G=e.config.object)==null?void 0:G.modelPath)==null?void 0:Y.includes("centernet"))&&(e.models.centernet=w1(e.config)),e.config.object.enabled&&!e.models.nanodet&&((R0=(z=e.config.object)==null?void 0:z.modelPath)==null?void 0:R0.includes("nanodet"))&&(e.models.nanodet=Bo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=a2(e.config));for await(let h0 of Object.keys(e.models))e.models[h0]&&typeof e.models[h0]!="undefined"&&(e.models[h0]=await e.models[h0])}async function l2(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],s=n==null?void 0:n.executor;if(s&&s.graph.nodes)for(let i of Object.values(s.graph.nodes)){let l=i.op.toLowerCase();r.includes(l)||r.push(l)}else!s&&e.config.debug&&h("model signature not determined:",o);let a=[];for(let i of r)!t.includes(i)&&!e.env.kernels.includes(i)&&!e.env.kernels.includes(i.replace("_",""))&&!e.env.kernels.includes(i.replace("native",""))&&!e.env.kernels.includes(i.replace("v2",""))&&a.push(i);e.config.debug&&a.length>0&&h("model validation failed:",o,a)}}var U={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function Jr(){let e=U.gl;!e||(U.extensions=e.getSupportedExtensions())}async function _o(e){var t;if(e.config.backend==="humangl"&&(U.name in A.engine().registry&&(!U.gl||!U.gl.getParameter(U.gl.VERSION))&&(h("error: humangl backend invalid context"),Ft(e)),!A.findBackend(U.name))){try{U.canvas=await i0(100,100)}catch(n){h("error: cannot create canvas:",n);return}try{if(U.gl=(t=U.canvas)==null?void 0:t.getContext("webgl2",U.webGLattr),!U.gl.getParameter(U.gl.VERSION).includes("2.0")){h("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}U.canvas&&(U.canvas.addEventListener("webglcontextlost",async r=>{throw h("error: humangl:",r.type),h("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),U.canvas.addEventListener("webglcontextrestored",r=>{h("error: humangl context restored:",r)}),U.canvas.addEventListener("webglcontextcreationerror",r=>{h("error: humangl context create:",r)}))}catch(n){h("error: cannot get WebGL context:",n);return}try{A.setWebGLContext(2,U.gl)}catch(n){h("error: cannot set WebGL context:",n);return}try{let n=new A.GPGPUContext(U.gl);A.registerBackend(U.name,()=>new A.MathBackendWebGL(n),U.priority)}catch(n){h("error: cannot register WebGL backend:",n);return}try{A.getKernelsForBackend("webgl").forEach(r=>{let s={...r,backendName:U.name};A.registerKernel(s)})}catch(n){h("error: cannot update WebGL backend registration:",n);return}let o=A.backend().getGPGPUContext?A.backend().getGPGPUContext().gl:null;if(o)h(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{h("error: no current gl context:",o,U.gl);return}try{A.ENV.set("WEBGL_VERSION",2)}catch(n){h("error: cannot set WebGL backend flags:",n);return}Jr(),h("backend registered:",U.name)}}function Yr(){if(!T.kernels.includes("mod")){let e={kernelName:"Mod",backendName:A.getBackend(),kernelFunc:t=>A.tidy(()=>A.sub(t.inputs.a,A.mul(A.div(t.inputs.a,t.inputs.b),t.inputs.b)))};A.registerKernel(e),T.kernels.push("mod")}if(!T.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:A.getBackend(),kernelFunc:t=>A.tidy(()=>A.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+A.mod(t.inputs.a,t.inputs.b))};A.registerKernel(e),T.kernels.push("floormod")}}async function Gt(e,t=!1){if(e.state="backend",t||T.initial||e.config.backend&&e.config.backend.length>0&&A.getBackend()!==e.config.backend){let o=g();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&h("running inside web worker"),T.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&h("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),T.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&h(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),T.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")h("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();e.config.debug&&h("enumerated webgpu adapter:",r)}e.config.backend==="humangl"&&await _o(e);let n=Object.keys(A.engine().registryFactory);if(e.config.debug&&h("available backends:",n),n.includes(e.config.backend)||(h(`error: backend ${e.config.backend} not found in registry`),e.config.backend=T.node?"tensorflow":"webgl",e.config.debug&&h(`override: setting backend ${e.config.backend}`)),e.config.debug&&h("setting backend:",e.config.backend),e.config.backend==="wasm"){if(e.config.debug&&h("wasm path:",e.config.wasmPath),typeof(A==null?void 0:A.setWasmPaths)!="undefined")await A.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&h(`wasm execution: ${r?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&h("warning: wasm simd support is not enabled")}try{await A.setBackend(e.config.backend),await A.ready(),Z2()}catch(r){return h("error: cannot set backend:",e.config.backend,r),!1}}if(A.getBackend()==="humangl"&&(A.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),A.ENV.set("WEBGL_CPU_FORWARD",!0),A.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),A.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(h("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),A.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),A.backend().getGPGPUContext)){let n=await A.backend().getGPGPUContext().gl;e.config.debug&&h(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}A.getBackend(),A.enableProdMode(),await A.ready(),e.performance.initBackend=Math.trunc(g()-o),e.config.backend=A.getBackend(),await T.updateBackend(),Yr()}return!0}function Et(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&h("kernelFunc",o,t.backend)}};A.registerKernel(n)}T.kernels=A.getKernelsForBackend(A.getBackend()).map(o=>o.kernelName.toLowerCase())}var tn={};ne(tn,{all:()=>p2,body:()=>Se,canvas:()=>m2,face:()=>je,gesture:()=>Oe,hand:()=>Ce,object:()=>We,options:()=>a0,person:()=>f2});var g0=e=>{if(!e)h("draw error: invalid canvas");else if(!e.getContext)h("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)h("draw error: cannot get canvas context");else return t}return null},ce=e=>Math.round(e*180/Math.PI),D0=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function X0(e,t,o,n,r){e.fillStyle=D0(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function W0(e,t,o,n,r,s){if(e.beginPath(),e.lineWidth=s.lineWidth,s.useCurves){let a=(t+t+n)/2,i=(o+o+r)/2;e.ellipse(a,i,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+s.roundRect,o),e.lineTo(t+n-s.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+s.roundRect),e.lineTo(t+n,o+r-s.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-s.roundRect,o+r),e.lineTo(t+s.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-s.roundRect),e.lineTo(t,o+s.roundRect),e.quadraticCurveTo(t,o,t+s.roundRect,o),e.closePath();e.stroke()}function x2(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=D0(n[2],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function en(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){x2(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${ce(e.rotation.angle.roll)}\xB0 yaw:${ce(e.rotation.angle.yaw)}\xB0 pitch:${ce(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${ce(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=H.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),s=n*H.lineHeight+e.box[1];H.shadowColor&&H.shadowColor!==""&&(t.fillStyle=H.shadowColor,t.fillText(o[n],r+5,s+16)),t.fillStyle=H.labelColor,t.fillText(o[n],r+4,s+15)}}}function _r(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=H.useDepth?"rgba(255, 200, 255, 0.3)":H.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],o,n,0,0,2*Math.PI),t.stroke(),H.fillPolygons&&(t.fillStyle=H.useDepth?"rgba(255, 255, 200, 0.3)":H.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=H.useDepth?"rgba(255, 200, 255, 0.3)":H.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],o,n,0,0,2*Math.PI),t.stroke(),H.fillPolygons&&(t.fillStyle=H.useDepth?"rgba(255, 255, 200, 0.3)":H.color,t.fill())}}function $r(e,t){var o;if(H.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*ce(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*ce(e.rotation.angle.pitch)/90,s=new Path2D(` +`;var qt=(e,t,o)=>{let n=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(n,(r,s)=>(o[s]=0,r))},Ut=class{constructor(t,o,n){k(this,"uniform",{});k(this,"attribute",{});k(this,"gl");k(this,"id");k(this,"compile",(t,o)=>{let n=this.gl.createShader(o);return n?(this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(h(`filter: gl compile failed: ${this.gl.getShaderInfoLog(n)}`),null)):(h("filter: could not create shader"),null)});this.gl=t;let r=this.compile(o,this.gl.VERTEX_SHADER),s=this.compile(n,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!r||!s)){if(!this.id){h("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,r),this.gl.attachShader(this.id,s),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){h(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),qt(o,"attribute",this.attribute);for(let a in this.attribute)this.attribute[a]=this.gl.getAttribLocation(this.id,a);qt(o,"uniform",this.uniform),qt(n,"uniform",this.uniform);for(let a in this.uniform)this.uniform[a]=this.gl.getUniformLocation(this.id,a)}}};function L2(){let e=0,t=null,o=!1,n=-1,r=[null,null],s=[],a=null,i=null,l=i0(100,100),x={},d={INTERMEDIATE:1},y=l.getContext("webgl");if(!y){h("filter: cannot get webgl context");return}this.gl=y;function c(u,p){if(!(u===l.width&&p===l.height)){if(l.width=u,l.height=p,!a){let v=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);a=y.createBuffer(),y.bindBuffer(y.ARRAY_BUFFER,a),y.bufferData(y.ARRAY_BUFFER,v,y.STATIC_DRAW),y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}y.viewport(0,0,l.width,l.height),r=[null,null]}}function f(u,p){let v=y.createFramebuffer();y.bindFramebuffer(y.FRAMEBUFFER,v);let w=y.createRenderbuffer();y.bindRenderbuffer(y.RENDERBUFFER,w);let S=y.createTexture();return y.bindTexture(y.TEXTURE_2D,S),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,u,p,0,y.RGBA,y.UNSIGNED_BYTE,null),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.LINEAR),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.LINEAR),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.framebufferTexture2D(y.FRAMEBUFFER,y.COLOR_ATTACHMENT0,y.TEXTURE_2D,S,0),y.bindTexture(y.TEXTURE_2D,null),y.bindFramebuffer(y.FRAMEBUFFER,null),{fbo:v,texture:S}}function b(u){return r[u]=r[u]||f(l.width,l.height),r[u]}function m(u=0){if(!i)return;let p=null,v=null,w=!1;e===0?p=t:p=b(n).texture||null,e++,o&&!(u&d.INTERMEDIATE)?(v=null,w=e%2===0):(n=(n+1)%2,v=b(n).fbo||null),y.bindTexture(y.TEXTURE_2D,p),y.bindFramebuffer(y.FRAMEBUFFER,v),y.uniform1f(i.uniform.flipY,w?-1:1),y.drawArrays(y.TRIANGLES,0,6)}function M(u){if(x[u])return i=x[u],y.useProgram((i?i.id:null)||null),i;if(i=new Ut(y,z2,u),!i)return h("filter: could not get webgl program"),null;let p=Float32Array.BYTES_PER_ELEMENT,v=4*p;return y.enableVertexAttribArray(i.attribute.pos),y.vertexAttribPointer(i.attribute.pos,2,y.FLOAT,!1,v,0*p),y.enableVertexAttribArray(i.attribute.uv),y.vertexAttribPointer(i.attribute.uv,2,y.FLOAT,!1,v,2*p),x[u]=i,i}let P={colorMatrix:u=>{let p=new Float32Array(u);p[4]/=255,p[9]/=255,p[14]/=255,p[19]/=255;let v=p[18]===1&&p[3]===0&&p[8]===0&&p[13]===0&&p[15]===0&&p[16]===0&&p[17]===0&&p[19]===0?S2:j2,w=M(v);!w||(y.uniform1fv(w.uniform.m,p),m())},brightness:u=>{let p=(u||0)+1;P.colorMatrix([p,0,0,0,0,0,p,0,0,0,0,0,p,0,0,0,0,0,1,0])},saturation:u=>{let p=(u||0)*2/3+1,v=(p-1)*-.5;P.colorMatrix([p,v,v,0,0,v,p,v,0,0,v,v,p,0,0,0,0,0,1,0])},desaturate:()=>{P.saturation(-1)},contrast:u=>{let p=(u||0)+1,v=-128*(p-1);P.colorMatrix([p,0,0,0,v,0,p,0,0,v,0,0,p,0,v,0,0,0,1,0])},negative:()=>{P.contrast(-2)},hue:u=>{u=(u||0)/180*Math.PI;let p=Math.cos(u),v=Math.sin(u),w=.213,S=.715,O=.072;P.colorMatrix([w+p*(1-w)+v*-w,S+p*-S+v*-S,O+p*-O+v*(1-O),0,0,w+p*-w+v*.143,S+p*(1-S)+v*.14,O+p*-O+v*-.283,0,0,w+p*-w+v*-(1-w),S+p*-S+v*S,O+p*(1-O)+v*O,0,0,0,0,0,1,0])},desaturateLuminance:()=>{P.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},sepia:()=>{P.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{P.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},vintagePinhole:()=>{P.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},kodachrome:()=>{P.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},technicolor:()=>{P.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},polaroid:()=>{P.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},shiftToBGR:()=>{P.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:u=>{let p=new Float32Array(u),v=1/l.width,w=1/l.height,S=M(O2);!S||(y.uniform1fv(S.uniform.m,p),y.uniform2f(S.uniform.px,v,w),m())},detectEdges:()=>{P.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{P.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{P.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:u=>{let p=u||1;P.convolution.call(this,[0,-1*p,0,-1*p,1+4*p,-1*p,0,-1*p,0])},emboss:u=>{let p=u||1;P.convolution.call(this,[-2*p,-1*p,0,-1*p,1,1*p,0,1*p,2*p])},blur:u=>{let p=u/7/l.width,v=u/7/l.height,w=M(W2);!w||(y.uniform2f(w.uniform.px,0,v),m(d.INTERMEDIATE),y.uniform2f(w.uniform.px,p,0),m())},pixelate:u=>{let p=u/l.width,v=u/l.height,w=M(C2);!w||(y.uniform2f(w.uniform.size,p,v),m())}};this.add=function(u){let p=Array.prototype.slice.call(arguments,1),v=P[u];s.push({func:v,args:p})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(u){c(u.width,u.height),e=0,t||(t=y.createTexture()),y.bindTexture(y.TEXTURE_2D,t),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.NEAREST),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,y.RGBA,y.UNSIGNED_BYTE,u);for(let p=0;pf.data())),a=.99*Math.max(s[0][0],s[1][0],s[2][0]),i=[A.sub(o[0],n[0]),A.sub(o[1],n[1]),A.sub(o[2],n[2])],l=[A.sub(r[0],n[0]),A.sub(r[1],n[1]),A.sub(r[2],n[2])],x=[A.div(a,l[0]),A.div(a,l[1]),A.div(a,l[2])],d=[A.mul(i[0],x[0]),A.mul(i[1],x[1]),A.mul(i[2],x[2])],y=A.stack([d[0],d[1],d[2]],2),c=A.reshape(y,[1,t.shape[0],t.shape[1],3]);return A.dispose([...o,...n,...r,...i,...l,...x,...d,y,t]),c}var nt=3840,B=null,$=null,me=null,q,I0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function i0(e,t){let o;if(T.browser)if(T.worker){if(typeof OffscreenCanvas=="undefined")throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");o=new OffscreenCanvas(e,t)}else{if(typeof document=="undefined")throw new Error("canvas error: attempted to run in browser but DOM is not defined");o=document.createElement("canvas"),o.width=e,o.height=t}else typeof T.Canvas!="undefined"?o=new T.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function rt(e,t){let o=t||i0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function pe(e,t,o=!0){if(!e)return t.debug&&h("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof fe)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof T.Canvas!="undefined"&&e instanceof T.Canvas)&&!(typeof globalThis.Canvas!="undefined"&&e instanceof globalThis.Canvas)&&!(typeof ImageData!="undefined"&&e instanceof ImageData)&&!(typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap)&&!(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)&&!(typeof HTMLMediaElement!="undefined"&&e instanceof HTMLMediaElement)&&!(typeof HTMLVideoElement!="undefined"&&e instanceof HTMLVideoElement)&&!(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas))throw new Error("input error: type is not recognized");if(e instanceof fe){let n=null;if(e.isDisposedInternal)throw new Error("input error: attempted to use tensor but it is disposed");if(!e.shape)throw new Error("input error: attempted to use tensor without a shape");if(e.shape.length===3){if(e.shape[2]===3)n=A.expandDims(e,0);else if(e.shape[2]===4){let r=A.slice3d(e,[0,0,0],[-1,-1,3]);n=A.expandDims(r,0),A.dispose(r)}}else e.shape.length===4&&(e.shape[3]===3?n=A.clone(e):e.shape[3]===4&&(n=A.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(n==null||n.shape.length!==4||n.shape[0]!==1||n.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(n.dtype==="int32"){let r=A.cast(n,"float32");A.dispose(n),n=r}return{tensor:n,canvas:t.filter.return?$:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&h("input stream is not ready"),{tensor:null,canvas:B};let n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,r=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!n||!r)return t.debug&&h("cannot determine input dimensions"),{tensor:null,canvas:B};let s=n,a=r;if(s>nt&&(s=nt,a=Math.trunc(s*r/n)),a>nt&&(a=nt,s=Math.trunc(a*n/r)),(t.filter.width||0)>0?s=t.filter.width:(t.filter.height||0)>0&&(s=n*((t.filter.height||0)/r)),(t.filter.height||0)>0?a=t.filter.height:(t.filter.width||0)>0&&(a=r*((t.filter.width||0)/n)),!s||!a)throw new Error("input error: cannot determine dimension");(!B||(B==null?void 0:B.width)!==s||(B==null?void 0:B.height)!==a)&&(B=i0(s,a));let i=B.getContext("2d");if(typeof ImageData!="undefined"&&e instanceof ImageData?i.putImageData(e,0,0):t.filter.flip&&typeof i.translate!="undefined"?(i.translate(n,0),i.scale(-1,1),i.drawImage(e,0,0,n,r,0,0,B==null?void 0:B.width,B==null?void 0:B.height),i.setTransform(1,0,0,1,0,0)):i.drawImage(e,0,0,n,r,0,0,B==null?void 0:B.width,B==null?void 0:B.height),(!$||B.width!==$.width||(B==null?void 0:B.height)!==($==null?void 0:$.height))&&($=i0(B.width,B.height)),t.filter.enabled&&T.webgl.supported?(q||(q=T.browser?new L2:null),T.filter=!!q,!q||!q.add?(t.debug&&h("input process error: cannot initialize filters"),T.webgl.supported=!1,t.filter.enabled=!1,rt(B,$)):(q.reset(),t.filter.brightness!==0&&q.add("brightness",t.filter.brightness),t.filter.contrast!==0&&q.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&q.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&q.add("blur",t.filter.blur),t.filter.saturation!==0&&q.add("saturation",t.filter.saturation),t.filter.hue!==0&&q.add("hue",t.filter.hue),t.filter.negative&&q.add("negative"),t.filter.sepia&&q.add("sepia"),t.filter.vintage&&q.add("brownie"),t.filter.sepia&&q.add("sepia"),t.filter.kodachrome&&q.add("kodachrome"),t.filter.technicolor&&q.add("technicolor"),t.filter.polaroid&&q.add("polaroid"),t.filter.pixelate!==0&&q.add("pixelate",t.filter.pixelate),q.get()>0?$=q.apply(B):$=q.draw(B))):(rt(B,$),q&&(q=null),T.filter=!!q),!o)return{tensor:null,canvas:$};if(!$)throw new Error("canvas error: cannot create output");let l,x=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(T.browser&&A.browser)l=A.browser?A.browser.fromPixels(e):null;else{x=e.data.length/e.height/e.width;let c=new Uint8Array(e.data.buffer);l=A.tensor(c,[e.height,e.width,x],"int32")}else if((!me||$.width!==me.width||$.height!==me.height)&&(me=i0($.width,$.height)),A.browser&&T.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?l=A.browser.fromPixels($):(me=rt($),l=A.browser.fromPixels(me));else{let b=rt($).getContext("2d").getImageData(0,0,s,a);x=b.data.length/s/a;let m=new Uint8Array(b.data.buffer);l=A.tensor(m,[s,a,x])}if(x===4){let c=A.slice3d(l,[0,0,0],[-1,-1,3]);A.dispose(l),l=c}if(!l)throw new Error("input error: cannot create tensor");let d=A.cast(l,"float32"),y=t.filter.equalization?await ot(d):A.expandDims(d,0);return A.dispose([l,d]),{tensor:y,canvas:t.filter.return?$:null}}}async function I2(e,t){let o=!1;if(e.cacheSensitivity===0||!t.shape||t.shape.length!==4||t.shape[1]>2048||t.shape[2]>2048)return o;if(!I0.inputTensor)I0.inputTensor=A.clone(t);else if(I0.inputTensor.shape[1]!==t.shape[1]||I0.inputTensor.shape[2]!==t.shape[2])A.dispose(I0.inputTensor),I0.inputTensor=A.clone(t);else{let n={};n.diff=A.sub(t,I0.inputTensor),n.squared=A.mul(n.diff,n.diff),n.sum=A.sum(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;A.dispose([I0.inputTensor,n.diff,n.squared,n.sum]),I0.inputTensor=A.clone(t),o=s<=(e.cacheSensitivity||0)}return o}async function N2(e,t,o){let n={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||h("invalid input tensor or tensor shapes do not match:",t.shape,o.shape),0;if(t.shape[0]!==1||o.shape[0]!==1||t.shape[3]!==3||o.shape[3]!==3)return e.debug||h("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;n.input1=A.clone(t),n.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?A.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):A.clone(o),n.diff=A.sub(n.input1,n.input2),n.squared=A.mul(n.diff,n.diff),n.sum=A.sum(n.squared);let s=(await n.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return A.dispose([n.input1,n.input2,n.diff,n.squared,n.sum]),s}var Jt=class{constructor(){k(this,"browser");k(this,"node");k(this,"worker");k(this,"platform","");k(this,"agent","");k(this,"backends",[]);k(this,"initial");k(this,"filter");k(this,"tfjs");k(this,"offscreen");k(this,"perfadd",!1);k(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});k(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});k(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});k(this,"cpu",{model:void 0,flags:[]});k(this,"kernels",[]);k(this,"Canvas");k(this,"Image");k(this,"ImageData");if(this.browser=typeof navigator!="undefined",this.node=typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined",this.tfjs={version:Ve["tfjs-core"]},this.offscreen=typeof OffscreenCanvas!="undefined",this.initial=!0,this.worker=this.browser&&this.offscreen?typeof WorkerGlobalScope!="undefined":void 0,typeof navigator!="undefined"){let t=navigator.userAgent.match(/\(([^()]+)\)/g);if(t&&t[0]){let o=t[0].match(/\(([^()]+)\)/g);this.platform=o&&o[0]?o[0].replace(/\(|\)/g,""):"",this.agent=navigator.userAgent.replace(t[0],""),this.platform[1]&&(this.agent=this.agent.replace(t[1],"")),this.agent=this.agent.replace(/ /g," ")}}else typeof process!="undefined"&&(this.platform=`${process.platform} ${process.arch}`,this.agent=`NodeJS ${process.version}`)}async updateBackend(){this.backends=Object.keys(A.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&A.getBackend()==="wasm"&&(this.wasm.simd=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=i0(100,100),o=t?t.getContext("webgl2"):void 0;if(this.webgl.supported=typeof o!="undefined",this.webgl.backend=this.backends.includes("webgl"),this.webgl.supported&&this.webgl.backend&&(A.getBackend()==="webgl"||A.getBackend()==="humangl")){let n=A.backend().gpgpu!=="undefined"?await A.backend().getGPGPUContext().gl:null;n&&(this.webgl.version=n.getParameter(n.VERSION),this.webgl.renderer=n.getParameter(n.RENDERER))}this.webgpu.supported=this.browser&&typeof navigator.gpu!="undefined",this.webgpu.backend=this.backends.includes("webgpu");try{this.webgpu.supported&&(this.webgpu.adapter=(await navigator.gpu.requestAdapter()).name)}catch(n){this.webgpu.supported=!1}try{this.kernels=A.getKernelsForBackend(A.getBackend()).map(n=>n.kernelName.toLowerCase())}catch(n){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},T=new Jt;var N0={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function zn(e,t){return N0.debug&&h("load model fetch:",e,t),fetch(e,t)}function F2(e){N0.cacheModels=e.cacheModels,N0.verbose=e.debug,N0.modelBasePath=e.modelBasePath}async function I(e){let t=E2(N0.modelBasePath,e||""),o=t.split("/"),n="indexeddb://"+o[o.length-1].replace(".json",""),r=await A.io.listModels(),s=N0.cacheModels&&Object.keys(r).includes(n),a=typeof fetch=="undefined"?{}:{fetchFunc:(x,d)=>zn(x,d)},i=new Xt(s?n:t,a),l=!1;try{i.findIOHandler(),N0.debug&&h("model load handler:",i.handler);let x=await i.handler.load();i.loadSync(x),N0.verbose&&h("load model:",i.modelUrl),l=!0}catch(x){h("error loading model:",t,x)}if(l&&N0.cacheModels&&!s)try{let x=await i.save(n);h("model saved:",n,x)}catch(x){h("error saving model:",t,x)}return i}var Yt="2.7.1";var y2={};ne(y2,{Models:()=>_e,load:()=>i2,reset:()=>Ft,validate:()=>l2});var P0,Kt=[],Cn=["white","black","asian","indian","other"],Wn=[15,23,28,35.5,45.5,55.5,65],G2=0,B2=0,Qt=Number.MAX_SAFE_INTEGER;async function H2(e){return T.initial&&(P0=null),P0?e.debug&&h("cached model:",P0.modelUrl):P0=await I(e.face.gear),P0}async function _t(e,t,o,n){var a,i;if(!P0)return{age:0,gender:"unknown",genderScore:0,race:[]};let r=Qt<(((a=t.face.gear)==null?void 0:a.skipFrames)||0),s=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>g()-B2;return t.skipAllowed&&s&&r&&G2===n&&Kt[o]?(Qt++,Kt[o]):(Qt=0,new Promise(async l=>{var P,u;if(!(P0!=null&&P0.inputs[0].shape))return;let x={},d=[[0,.1,.9,.9]];x.resize=A.image.cropAndResize(e,d,[0],[P0.inputs[0].shape[2],P0.inputs[0].shape[1]]);let y={age:0,gender:"unknown",genderScore:0,race:[]};(P=t.face.gear)!=null&&P.enabled&&([x.age,x.gender,x.race]=P0.execute(x.resize,["age_output","gender_output","race_output"]));let c=await x.gender.data();y.gender=c[0]>c[1]?"male":"female",y.genderScore=Math.round(100*(c[0]>c[1]?c[0]:c[1]))/100;let f=await x.race.data();for(let p=0;p(((u=t.face.gear)==null?void 0:u.minConfidence)||.2)&&y.race.push({score:Math.round(100*f[p])/100,race:Cn[p]});y.race.sort((p,v)=>v.score-p.score);let m=Array.from(await x.age.data()).map((p,v)=>[Wn[v],p]).sort((p,v)=>v[1]-p[1]),M=m[0][0];for(let p=1;pA.dispose(x[p])),Kt[o]=y,G2=n,B2=g(),l(y)}))}var N={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Z2(){N.tf255=A.scalar(255,"float32"),N.tf1=A.scalar(1,"float32"),N.tf2=A.scalar(2,"float32"),N.tf05=A.scalar(.5,"float32"),N.tf127=A.scalar(127.5,"float32"),N.rgb=A.tensor1d([.2989,.587,.114],"float32")}var x0,At=[],D2=0,X2=0,$t=Number.MAX_SAFE_INTEGER;async function q2(e){return T.initial&&(x0=null),x0?e.debug&&h("cached model:",x0.modelUrl):x0=await I(e.face.ssrnet.modelPathAge),x0}async function e5(e,t,o,n){var a,i,l,x;if(!x0)return{age:0};let r=$t<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>g()-X2;return t.skipAllowed&&r&&s&&D2===n&&((l=At[o])==null?void 0:l.age)&&((x=At[o])==null?void 0:x.age)>0?($t++,At[o]):($t=0,new Promise(async d=>{if(!(x0!=null&&x0.inputs)||!x0.inputs[0]||!x0.inputs[0].shape)return;let y={};y.resize=A.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),y.enhance=A.mul(y.resize,N.tf255);let c={age:0};if(t.face.ssrnet.enabled&&(y.age=x0.execute(y.enhance)),y.age){let f=await y.age.data();c.age=Math.trunc(10*f[0])/10}Object.keys(y).forEach(f=>A.dispose(y[f])),At[o]=c,D2=n,X2=g(),d(c)}))}var v0,st=[],J2=0,Y2=0,t5=Number.MAX_SAFE_INTEGER,o5=[.2989,.587,.114];async function K2(e){return T.initial&&(v0=null),v0?e.debug&&h("cached model:",v0.modelUrl):v0=await I(e.face.ssrnet.modelPathGender),v0}async function n5(e,t,o,n){var a,i,l,x;if(!v0)return{gender:"unknown",genderScore:0};let r=t5<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>g()-Y2;return t.skipAllowed&&r&&s&&J2===n&&((l=st[o])==null?void 0:l.gender)&&((x=st[o])==null?void 0:x.genderScore)>0?(t5++,st[o]):(t5=0,new Promise(async d=>{if(!(v0!=null&&v0.inputs[0].shape))return;let y={};y.resize=A.image.resizeBilinear(e,[v0.inputs[0].shape[2],v0.inputs[0].shape[1]],!1),y.enhance=A.tidy(()=>{let[b,m,M]=A.split(y.resize,3,3),P=A.mul(b,o5[0]),u=A.mul(m,o5[1]),p=A.mul(M,o5[2]),v=A.addN([P,u,p]);return A.mul(A.sub(v,N.tf05),2)});let c={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(y.gender=v0.execute(y.enhance));let f=await y.gender.data();c.gender=f[0]>f[1]?"female":"male",c.genderScore=f[0]>f[1]?Math.trunc(100*f[0])/100:Math.trunc(100*f[1])/100,Object.keys(y).forEach(b=>A.dispose(y[b])),st[o]=c,J2=n,Y2=g(),d(c)}))}var r0,at=[],r5=Number.MAX_SAFE_INTEGER,_2=0,$2=0;async function e1(e){var t;return T.initial&&(r0=null),r0?e.debug&&h("cached model:",r0.modelUrl):r0=await I((t=e.face.antispoof)==null?void 0:t.modelPath),r0}async function A5(e,t,o,n){var a,i;if(!r0)return 0;let r=(((a=t.face.antispoof)==null?void 0:a.skipTime)||0)>g()-$2,s=r5<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&_2===n&&at[o]?(r5++,at[o]):(r5=0,new Promise(async l=>{let x=A.image.resizeBilinear(e,[r0!=null&&r0.inputs[0].shape?r0.inputs[0].shape[2]:0,r0!=null&&r0.inputs[0].shape?r0.inputs[0].shape[1]:0],!1),d=r0==null?void 0:r0.execute(x),y=(await d.data())[0];at[o]=Math.round(100*y)/100,_2=n,$2=g(),A.dispose([x,d]),l(at[o])}))}var M0={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[61,185,40,39,37,0,267,269,270,409,291],lipsLowerOuter:[146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[78,191,80,81,82,13,312,311,310,415,308],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]},s5={count:468,mouth:13,symmetryLine:[13,M0.midwayBetweenEyes[0]]},De={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},a5=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}],Xe=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],Ae=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255];var Ln=[127,234,132,58,172,150,149,148,152,377,378,379,397,288,361,454,356,70,63,105,66,107,336,296,334,293,300,168,6,195,4,98,97,2,326,327,33,160,158,133,153,144,362,385,387,263,373,380,57,40,37,0,267,270,287,321,314,17,84,91,78,81,13,311,308,402,14,178],In=[33,133,362,263,1,62,308,159,145,386,374,6,102,331,2,13,14,70,105,107,336,334,300,54,10,284,50,280,234,454,58,288,152],Nn=[33,133,362,263,1,78,308],qA=Ln.map(e=>Xe[e]),UA=In.map(e=>Xe[e]),JA=Nn.map(e=>Xe[e]);function q0(e){let t=e.map(o=>o[0]);return t.push(e[e.length-1][1]),t}var Fn=[[61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]],Gn=[[263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]],Bn=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Hn=[[474,475],[475,476],[476,477],[477,474]],Vn=[[33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]],Zn=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Dn=[[469,470],[470,471],[471,472],[472,469]],Xn=[[10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]],YA={lips:q0(Fn),leftEye:q0(Gn),leftEyebrow:q0(Bn),leftIris:q0(Hn),rightEye:q0(Vn),rightEyebrow:q0(Zn),rightIris:q0(Dn),faceOval:q0(Xn)};var ue=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],it=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],x5=(e,t)=>e?[Math.trunc(Math.max(0,e.startPoint[0])),Math.trunc(Math.max(0,e.startPoint[1])),Math.trunc(Math.min(t.shape[2]||0,e.endPoint[0])-Math.max(0,e.startPoint[0])),Math.trunc(Math.min(t.shape[1]||0,e.endPoint[1])-Math.max(0,e.startPoint[1]))]:[0,0,0,0],c5=(e,t)=>e?[e.startPoint[0]/(t.shape[2]||0),e.startPoint[1]/(t.shape[1]||0),(e.endPoint[0]-e.startPoint[0])/(t.shape[2]||0),(e.endPoint[1]-e.startPoint[1])/(t.shape[1]||0)]:[0,0,0,0],r1=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n,landmarks:e.landmarks,confidence:e.confidence}},l5=(e,t,o)=>{let n=t.shape[1],r=t.shape[2],s=[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r],a=A.image.cropAndResize(t,[s],[0],o),i=A.div(a,N.tf255);return A.dispose(a),i},lt=(e,t)=>{let o=it(e),n=ue(e),r=[t*n[0]/2,t*n[1]/2];return{startPoint:[o[0]-r[0],o[1]-r[1]],endPoint:[o[0]+r[0],o[1]+r[1]],landmarks:e.landmarks,confidence:e.confidence}},yt=e=>{let t=it(e),o=ue(e),n=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-n),Math.round(t[1]-n)],endPoint:[Math.round(t[0]+n),Math.round(t[1]+n)],landmarks:e.landmarks,confidence:e.confidence}},A1=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},y5=[[1,0,0],[0,1,0],[0,0,1]],qn=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Un=(e,t)=>qn(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var o1=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],se=(e,t)=>{let o=0;for(let n=0;n{let o=[];for(let n=0;n{let o=[],n=e.length;for(let r=0;r{let o=Math.cos(e),n=Math.sin(e),r=[[o,-n,0],[n,o,0],[0,0,1]],s=o1(t[0],t[1]),a=n1(s,r),i=o1(-t[0],-t[1]);return n1(a,i)},Yn=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-se(t[0],o),-se(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]},Kn=(e,t)=>[se(e,t[0]),se(e,t[1])];function a1(e){let t={strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n[s[0]/r*(f[0]-r/2),s[1]/r*(f[1]-r/2),f[2]||0]),i=o&&o!==0&&Math.abs(o)>.2,l=i?s1(o,[0,0]):y5,x=i?a.map(f=>[...Kn(f,l),f[2]]):a,d=i?Yn(n):y5,y=it(t),c=[se(y,d[0]),se(y,d[1])];return x.map(f=>[Math.trunc(f[0]+c[0]),Math.trunc(f[1]+c[1]),Math.trunc(f[2]||0)])}function l1(e,t,o,n){let r=t.landmarks.length>=s5.count?s5.symmetryLine:De.symmetryLine,s=0,a=y5,i;if(e&&T.kernels.includes("rotatewithoffset"))if(s=Un(t.landmarks[r[0]],t.landmarks[r[1]]),s&&s!==0&&Math.abs(s)>.2){let x=it(t),d=[x[0]/o.shape[2],x[1]/o.shape[1]],y=A.image.rotateWithOffset(o,s,0,d);a=s1(-s,x),i=l5(t,y,[n,n]),A.dispose(y)}else i=l5(t,o,[n,n]);else i=l5(t,o,[n,n]);return[s,a,i]}var Qn=e=>{let t=e.map(n=>n[0]),o=e.map(n=>n[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},y1=(e,t)=>{let o=Qn(e),n=ue(t);return{startPoint:[o[0]-n[0]/2,o[1]-n[1]/2],endPoint:[o[0]+n[0]/2,o[1]+n[1]/2]}};var x1=6,_n=1.4,z0,c1=null,U0=0,qe=null,xt=()=>U0;async function d1(e){var t;return T.initial&&(z0=null),z0?e.debug&&h("cached model:",z0.modelUrl):z0=await I((t=e.face.detector)==null?void 0:t.modelPath),U0=z0.inputs[0].shape?z0.inputs[0].shape[2]:0,qe=A.scalar(U0,"int32"),c1=A.tensor2d(a1(U0)),z0}function $n(e){let t={};t.boxStarts=A.slice(e,[0,1],[-1,2]),t.centers=A.add(t.boxStarts,c1),t.boxSizes=A.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=A.div(t.boxSizes,qe),t.centersNormalized=A.div(t.centers,qe),t.halfBoxSize=A.div(t.boxSizesNormalized,N.tf2),t.starts=A.sub(t.centersNormalized,t.halfBoxSize),t.ends=A.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=A.mul(t.starts,qe),t.endNormalized=A.mul(t.ends,qe);let o=A.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(n=>A.dispose(t[n])),o}async function f1(e,t){var i,l,x,d;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=A.image.resizeBilinear(e,[U0,U0]),o.div=A.div(o.resized,N.tf127),o.normalized=A.sub(o.div,N.tf05);let n=z0==null?void 0:z0.execute(o.normalized);if(Array.isArray(n)){let y=n.sort((c,f)=>c.size-f.size);o.concat384=A.concat([y[0],y[2]],2),o.concat512=A.concat([y[1],y[3]],2),o.concat=A.concat([o.concat512,o.concat384],1),o.batch=A.squeeze(o.concat,0)}else o.batch=A.squeeze(n);A.dispose(n),o.boxes=$n(o.batch),o.logits=A.slice(o.batch,[0,0],[-1,1]),o.sigmoid=A.sigmoid(o.logits),o.scores=A.squeeze(o.sigmoid),o.nms=await A.image.nonMaxSuppressionAsync(o.boxes,o.scores,((i=t.face.detector)==null?void 0:i.maxDetected)||0,((l=t.face.detector)==null?void 0:l.iouThreshold)||0,((x=t.face.detector)==null?void 0:x.minConfidence)||0);let r=await o.nms.array(),s=[],a=await o.scores.data();for(let y=0;y(((d=t.face.detector)==null?void 0:d.minConfidence)||0)){let f={};f.bbox=A.slice(o.boxes,[r[y],0],[1,-1]),f.slice=A.slice(o.batch,[r[y],x1-1],[1,-1]),f.squeeze=A.squeeze(f.slice),f.landmarks=A.reshape(f.squeeze,[x1,-1]);let b=await f.bbox.data(),m={startPoint:[b[0],b[1]],endPoint:[b[2],b[3]],landmarks:await f.landmarks.array(),confidence:c},M=r1(m,[(e.shape[2]||0)/U0,(e.shape[1]||0)/U0]),P=lt(M,t.face.scale||_n),u=yt(P);s.push(u),Object.keys(f).forEach(p=>A.dispose(f[p]))}}return Object.keys(o).forEach(y=>A.dispose(o[y])),s}var ct={};ne(ct,{connected:()=>m5,kpt:()=>f5});var f5=["nose","leftEyeInside","leftEye","leftEyeOutside","rightEyeInside","rightEye","rightEyeOutside","leftEar","rightEar","leftMouth","rightMouth","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftPinky","rightPinky","leftIndex","rightIndex","leftThumb","rightThumb","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle","leftHeel","rightHeel","leftFoot","rightFoot","bodyCenter","bodyTop","leftPalm","leftHand","rightPalm","rightHand"],m5={shoulders:["leftShoulder","rightShoulder"],hips:["rightHip","leftHip"],mouth:["leftMouth","rightMouth"],leftLegUpper:["leftHip","leftKnee"],leftLegLower:["leftKnee","leftAnkle"],leftFoot:["leftAnkle","leftHeel","leftFoot"],leftTorso:["leftShoulder","leftHip"],leftArmUpper:["leftShoulder","leftElbow"],leftArmLower:["leftElbow","leftWrist"],leftHand:["leftWrist","leftPalm"],leftHandPinky:["leftPalm","leftPinky"],leftHandIndex:["leftPalm","leftIndex"],leftHandThumb:["leftPalm","leftThumb"],leftEyeOutline:["leftEyeInside","leftEyeOutside"],rightLegUpper:["rightHip","rightKnee"],rightLegLower:["rightKnee","rightAnkle"],rightFoot:["rightAnkle","rightHeel","rightFoot"],rightTorso:["rightShoulder","rightHip"],rightArmUpper:["rightShoulder","rightElbow"],rightArmLower:["rightElbow","rightWrist"],rightHand:["rightWrist","rightPalm"],rightHandPinky:["rightPalm","rightPinky"],rightHandIndex:["rightPalm","rightIndex"],rightHandThumb:["rightPalm","rightThumb"],rightEyeOutline:["rightEyeInside","rightEyeOutside"]};var p1=224,er,tr=5,dt=[8,16,32,32,32];async function u1(){let e=[],t=0;for(;to.x)),y:A.tensor1d(e.map(o=>o.y))}}function F0(e,t=[1,1]){let o=[e.map(i=>i[0]),e.map(i=>i[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],s=[n[0],n[1],r[0]-n[0],r[1]-n[1]],a=[s[0]/t[0],s[1]/t[1],s[2]/t[0],s[3]/t[1]];return{box:s,boxRaw:a}}function h1(e,t=[1,1]){let o=[e.map(x=>x[0]),e.map(x=>x[1])],n=[Math.min(...o[0]),Math.min(...o[1])],r=[Math.max(...o[0]),Math.max(...o[1])],s=[(n[0]+r[0])/2,(n[1]+r[1])/2],a=Math.max(s[0]-n[0],s[1]-n[1],-s[0]+r[0],-s[1]+r[1]),i=[Math.trunc(s[0]-a),Math.trunc(s[1]-a),Math.trunc(2*a),Math.trunc(2*a)],l=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:l}}function ft(e,t){let o=[e[2]*t,e[3]*t];return[e[0]-(o[0]-e[2])/2,e[1]-(o[1]-e[3])/2,o[0],o[1]]}var P1={initial:!0},c0={detector:null,landmarks:null},he={detector:[224,224],landmarks:[256,256]},p5=Number.MAX_SAFE_INTEGER,nr={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},pt=null,Ue,J0=[[0,0],[0,0],[0,0],[0,0]],b1=0,g1=e=>1-1/(1+Math.exp(e));async function v1(e){if(P1.initial&&(c0.detector=null),!c0.detector&&e.body.detector&&e.body.detector.modelPath){c0.detector=await I(e.body.detector.modelPath);let t=Object.values(c0.detector.modelSignature.inputs);he.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,he.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&c0.detector&&h("cached model:",c0.detector.modelUrl);return await u1(),c0.detector}async function M1(e){if(P1.initial&&(c0.landmarks=null),c0.landmarks)e.debug&&h("cached model:",c0.landmarks.modelUrl);else{c0.landmarks=await I(e.body.modelPath);let t=Object.values(c0.landmarks.modelSignature.inputs);he.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,he.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return c0.landmarks}async function rr(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let n;if(Ue&&(o.cropped=A.image.cropAndResize(e,[Ue],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let r=[e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],s=[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0];J0=[[0,0],r,s,[0,0]],o.pad=A.pad(o.cropped||e,J0),o.resize=A.image.resizeBilinear(o.pad,[t,t]),n=A.div(o.resize,N.tf255)}else e.shape[1]!==t?(o.resize=A.image.resizeBilinear(o.cropped||e,[t,t]),n=A.div(o.resize,N.tf255)):n=A.div(o.cropped||e,N.tf255);return Object.keys(o).forEach(r=>A.dispose(o[r])),n}function Ar(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+J0[2][0]+J0[2][1])/t[0]-J0[2][0]),Math.trunc(o.position[1]*(t[1]+J0[1][0]+J0[1][1])/t[1]-J0[1][0]),o.position[2]],o.positionRaw=[o.position[0]/t[0],o.position[1]/t[1],2*o.position[2]/(t[0]+t[1])];if(Ue)for(let o of e)o.positionRaw=[o.positionRaw[0]+Ue[1],o.positionRaw[1]+Ue[0],o.positionRaw[2]],o.position=[Math.trunc(o.positionRaw[0]*t[0]),Math.trunc(o.positionRaw[1]*t[1]),o.positionRaw[2]];return e}async function sr(e){let t=e.find(i=>i.part==="leftPalm"),o=e.find(i=>i.part==="leftWrist"),n=e.find(i=>i.part==="leftIndex");t.position[2]=((o.position[2]||0)+(n.position[2]||0))/2;let r=e.find(i=>i.part==="rightPalm"),s=e.find(i=>i.part==="rightWrist"),a=e.find(i=>i.part==="rightIndex");r.position[2]=((s.position[2]||0)+(a.position[2]||0))/2}async function ar(e,t,o){var b;let n={};[n.ld,n.segmentation,n.heatmap,n.world,n.poseflag]=(b=c0.landmarks)==null?void 0:b.execute(e,nr.landmarks);let r=(await n.poseflag.data())[0],s=await n.ld.data(),a=await n.world.data();Object.keys(n).forEach(m=>A.dispose(n[m]));let i=[],l=5;for(let m=0;mm.position),y=F0(d,[o[0],o[1]]),c={};for(let[m,M]of Object.entries(m5)){let P=[];for(let u=0;uw.part===M[u]),v=x.find(w=>w.part===M[u+1]);p&&v&&P.push([p.position,v.position])}c[m]=P}return{id:0,score:Math.trunc(100*r)/100,box:y.box,boxRaw:y.boxRaw,keypoints:x,annotations:c}}async function u5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],n=(t.body.skipTime||0)>g()-b1,r=p5<(t.body.skipFrames||0);if(t.skipAllowed&&n&&r&&pt!==null)p5++;else{let s={};s.landmarks=await rr(e,256),pt=await ar(s.landmarks,t,o),Object.keys(s).forEach(a=>A.dispose(s[a])),b1=g(),p5=0}return pt?[pt]:[]}var be=[{class:1,label:"person"},{class:2,label:"bicycle"},{class:3,label:"car"},{class:4,label:"motorcycle"},{class:5,label:"airplane"},{class:6,label:"bus"},{class:7,label:"train"},{class:8,label:"truck"},{class:9,label:"boat"},{class:10,label:"traffic light"},{class:11,label:"fire hydrant"},{class:12,label:"stop sign"},{class:13,label:"parking meter"},{class:14,label:"bench"},{class:15,label:"bird"},{class:16,label:"cat"},{class:17,label:"dog"},{class:18,label:"horse"},{class:19,label:"sheep"},{class:20,label:"cow"},{class:21,label:"elephant"},{class:22,label:"bear"},{class:23,label:"zebra"},{class:24,label:"giraffe"},{class:25,label:"backpack"},{class:26,label:"umbrella"},{class:27,label:"handbag"},{class:28,label:"tie"},{class:29,label:"suitcase"},{class:30,label:"frisbee"},{class:31,label:"skis"},{class:32,label:"snowboard"},{class:33,label:"sports ball"},{class:34,label:"kite"},{class:35,label:"baseball bat"},{class:36,label:"baseball glove"},{class:37,label:"skateboard"},{class:38,label:"surfboard"},{class:39,label:"tennis racket"},{class:40,label:"bottle"},{class:41,label:"wine glass"},{class:42,label:"cup"},{class:43,label:"fork"},{class:44,label:"knife"},{class:45,label:"spoon"},{class:46,label:"bowl"},{class:47,label:"banana"},{class:48,label:"apple"},{class:49,label:"sandwich"},{class:50,label:"orange"},{class:51,label:"broccoli"},{class:52,label:"carrot"},{class:53,label:"hot dog"},{class:54,label:"pizza"},{class:55,label:"donut"},{class:56,label:"cake"},{class:57,label:"chair"},{class:58,label:"couch"},{class:59,label:"potted plant"},{class:60,label:"bed"},{class:61,label:"dining table"},{class:62,label:"toilet"},{class:63,label:"tv"},{class:64,label:"laptop"},{class:65,label:"mouse"},{class:66,label:"remote"},{class:67,label:"keyboard"},{class:68,label:"cell phone"},{class:69,label:"microwave"},{class:70,label:"oven"},{class:71,label:"toaster"},{class:72,label:"sink"},{class:73,label:"refrigerator"},{class:74,label:"book"},{class:75,label:"clock"},{class:76,label:"vase"},{class:77,label:"scissors"},{class:78,label:"teddy bear"},{class:79,label:"hair drier"},{class:80,label:"toothbrush"}];var G0,ae=0,h5=[],T1=0,b5=Number.MAX_SAFE_INTEGER;async function w1(e){if(T.initial&&(G0=null),G0)e.debug&&h("cached model:",G0.modelUrl);else{G0=await I(e.object.modelPath);let t=Object.values(G0.modelSignature.inputs);ae=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return G0}async function ir(e,t,o){if(!e)return[];let n={},r=[],s=await e.array();n.squeeze=A.squeeze(e);let a=A.split(n.squeeze,6,1);n.stack=A.stack([a[1],a[0],a[3],a[2]],1),n.boxes=A.squeeze(n.stack),n.scores=A.squeeze(a[4]),n.classes=A.squeeze(a[5]),A.dispose([e,...a]),n.nms=await A.image.nonMaxSuppressionAsync(n.boxes,n.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let i=await n.nms.data(),l=0;for(let x of Array.from(i)){let d=Math.trunc(100*s[0][x][4])/100,y=s[0][x][5],c=be[y].label,[f,b]=[s[0][x][0]/ae,s[0][x][1]/ae],m=[f,b,s[0][x][2]/ae-f,s[0][x][3]/ae-b],M=[Math.trunc(m[0]*t[0]),Math.trunc(m[1]*t[1]),Math.trunc(m[2]*t[0]),Math.trunc(m[3]*t[1])];r.push({id:l++,score:d,class:y,label:c,box:M,boxRaw:m})}return Object.keys(n).forEach(x=>A.dispose(n[x])),r}async function g5(e,t){let o=(t.object.skipTime||0)>g()-T1,n=b5<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&h5.length>0?(b5++,h5):(b5=0,new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[ae,ae]),i=t.object.enabled?G0==null?void 0:G0.execute(a,["tower_0/detections"]):null;T1=g(),A.dispose(a);let l=await ir(i,s,t);h5=l,r(l)}))}var ut={};ne(ut,{connected:()=>v5,kpt:()=>P5});var P5=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],v5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var A0,E1=0,l0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},M5=Number.MAX_SAFE_INTEGER;async function z1(e){return T.initial&&(A0=null),A0?e.debug&&h("cached model:",A0.modelUrl):A0=await I(e.body.modelPath),A0}async function lr(e,t){let[o,n]=e.shape,r=A.reshape(e,[n*o]),s=A.max(r,0),a=(await s.data())[0];if(A.dispose([r,s]),a>t){let i=A.argMax(r,0),l=A.mod(i,o),x=(await l.data())[0],d=A.div(i,A.scalar(o,"int32")),y=(await d.data())[0];return A.dispose([l,d]),[x,y,a]}return[0,0,a]}async function R5(e,t){let o=(t.body.skipTime||0)>g()-E1,n=M5<(t.body.skipFrames||0);return t.skipAllowed&&o&&n&&Object.keys(l0.keypoints).length>0?(M5++,[l0]):(M5=0,new Promise(async r=>{var y;let s=A.tidy(()=>{if(!(A0!=null&&A0.inputs[0].shape))return null;let c=A.image.resizeBilinear(e,[A0.inputs[0].shape[2],A0.inputs[0].shape[1]],!1),f=A.mul(c,N.tf2);return A.sub(f,N.tf1)}),a;if(t.body.enabled&&(a=A0==null?void 0:A0.execute(s)),E1=g(),A.dispose(s),a){l0.keypoints.length=0;let c=a.squeeze();A.dispose(a);let f=c.unstack(2);A.dispose(c);for(let b=0;b(((y=t.body)==null?void 0:y.minConfidence)||0)&&l0.keypoints.push({score:Math.round(100*P)/100,part:P5[b],positionRaw:[m/A0.inputs[0].shape[2],M/A0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/A0.inputs[0].shape[2]),Math.round(e.shape[1]*M/A0.inputs[0].shape[1])]})}f.forEach(b=>A.dispose(b))}l0.score=l0.keypoints.reduce((c,f)=>f.score>c?f.score:c,0);let i=l0.keypoints.map(c=>c.position[0]),l=l0.keypoints.map(c=>c.position[1]);l0.box=[Math.min(...i),Math.min(...l),Math.max(...i)-Math.min(...i),Math.max(...l)-Math.min(...l)];let x=l0.keypoints.map(c=>c.positionRaw[0]),d=l0.keypoints.map(c=>c.positionRaw[1]);l0.boxRaw=[Math.min(...x),Math.min(...d),Math.max(...x)-Math.min(...x),Math.max(...d)-Math.min(...d)];for(let[c,f]of Object.entries(v5)){let b=[];for(let m=0;mu.part===f[m]),P=l0.keypoints.find(u=>u.part===f[m+1]);M&&P&&M.score>(t.body.minConfidence||0)&&P.score>(t.body.minConfidence||0)&&b.push([M.position,P.position])}l0.annotations[c]=b}r([l0])}))}var yr=["angry","disgust","fear","happy","sad","surprise","neutral"],b0,ht=[],S1=0,C1=0,T5=Number.MAX_SAFE_INTEGER;async function W1(e){var t;return T.initial&&(b0=null),b0?e.debug&&h("cached model:",b0.modelUrl):b0=await I((t=e.face.emotion)==null?void 0:t.modelPath),b0}async function w5(e,t,o,n){var a,i;if(!b0)return[];let r=T5<(((a=t.face.emotion)==null?void 0:a.skipFrames)||0),s=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>g()-C1;return t.skipAllowed&&s&&r&&S1===n&&ht[o]&&ht[o].length>0?(T5++,ht[o]):(T5=0,new Promise(async l=>{var d,y;let x=[];if((d=t.face.emotion)!=null&&d.enabled){let c={},f=b0!=null&&b0.inputs[0].shape?b0.inputs[0].shape[2]:0;c.resize=A.image.resizeBilinear(e,[f,f],!1),c.channels=A.mul(c.resize,N.rgb),c.grayscale=A.sum(c.channels,3,!0),c.grayscaleSub=A.sub(c.grayscale,N.tf05),c.grayscaleMul=A.mul(c.grayscaleSub,N.tf2),c.emotion=b0==null?void 0:b0.execute(c.grayscaleMul),C1=g();let b=await c.emotion.data();for(let m=0;m(((y=t.face.emotion)==null?void 0:y.minConfidence)||0)&&x.push({score:Math.min(.99,Math.trunc(100*b[m])/100),emotion:yr[m]});x.sort((m,M)=>M.score-m.score),Object.keys(c).forEach(m=>A.dispose(c[m]))}ht[o]=x,S1=n,l(x)}))}var d0,k5=[],L1=0,I1=0,N1=Number.MAX_SAFE_INTEGER;async function F1(e){return T.initial&&(d0=null),d0?e.debug&&h("cached model:",d0.modelUrl):d0=await I(e.face.mobilefacenet.modelPath),d0}async function E5(e,t,o,n){var a,i;if(!d0)return[];let r=N1<(((a=t.face.embedding)==null?void 0:a.skipFrames)||0),s=(((i=t.face.embedding)==null?void 0:i.skipTime)||0)>g()-I1;return t.skipAllowed&&s&&r&&L1===n&&k5[o]?(N1++,k5[o]):new Promise(async l=>{var d;let x=[];if(((d=t.face.embedding)==null?void 0:d.enabled)&&(d0==null?void 0:d0.inputs[0].shape)){let y={};y.crop=A.image.resizeBilinear(e,[d0.inputs[0].shape[2],d0.inputs[0].shape[1]],!1),y.data=d0==null?void 0:d0.execute(y.crop);let c=await y.data.data();x=Array.from(c)}k5[o]=x,L1=n,I1=g(),l(x)})}var B0,Y0=0,xr=2.3,z5=M0.leftEyeLower0,j5=M0.rightEyeLower0,ge={leftBounds:[z5[0],z5[z5.length-1]],rightBounds:[j5[0],j5[j5.length-1]]},Pe={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function Z1(e){var t;return T.initial&&(B0=null),B0?e.debug&&h("cached model:",B0.modelUrl):B0=await I((t=e.face.iris)==null?void 0:t.modelPath),Y0=B0.inputs[0].shape?B0.inputs[0].shape[2]:0,Y0===-1&&(Y0=64),B0}function bt(e,t,o,n){for(let r=0;r{let t=e[ge.leftBounds[0]][2],o=e[ge.rightBounds[0]][2];return t-o},B1=(e,t,o,n,r,s=!1)=>{let a=yt(lt(A1([e[o],e[n]]),xr)),i=ue(a),l=A.image.cropAndResize(t,[[a.startPoint[1]/r,a.startPoint[0]/r,a.endPoint[1]/r,a.endPoint[0]/r]],[0],[Y0,Y0]);if(s&&T.kernels.includes("flipleftright")){let x=A.image.flipLeftRight(l);A.dispose(l),l=x}return{box:a,boxSize:i,crop:l}},H1=(e,t,o,n=!1)=>{let r=[];for(let s=0;s{let n=e[M0[`${o}EyeUpper0`][Pe.upperCenter]][2],r=e[M0[`${o}EyeLower0`][Pe.lowerCenter]][2],s=(n+r)/2;return t.map((a,i)=>{let l=s;return i===2?l=n:i===4&&(l=r),[a[0],a[1],l]})};async function D1(e,t,o,n){if(!B0)return o.debug&&h("face mesh iris detection requested, but model is not loaded"),e;let{box:r,boxSize:s,crop:a}=B1(e,t,ge.leftBounds[0],ge.leftBounds[1],n,!0),{box:i,boxSize:l,crop:x}=B1(e,t,ge.rightBounds[0],ge.rightBounds[1],n,!0),d=A.concat([a,x]);A.dispose(a),A.dispose(x);let y=B0.execute(d);A.dispose(d);let c=await y.data();A.dispose(y);let f=c.slice(0,Pe.numCoordinates*3),{rawCoords:b,iris:m}=H1(f,r,s,!0),M=c.slice(Pe.numCoordinates*3),{rawCoords:P,iris:u}=H1(M,i,l,!1),p=cr(e);Math.abs(p)<30?(bt(e,b,"left",null),bt(e,P,"right",null)):p<1?bt(e,b,"left",["EyeUpper0","EyeLower0"]):bt(e,P,"right",["EyeUpper0","EyeLower0"]);let v=V1(e,m,"left"),w=V1(e,u,"right");return e.concat(v).concat(w)}var f0={eyeLLower:[33,7,163,144,145,153,154,155,133],eyeRLower:[263,249,390,373,374,380,381,382,362],lips:[185,96,90,181,84,17,314,405,320,307,409,40,39,73,37,0,267,269,270,409,40,88,178,178,87,14,268,402,318,324,409,80,41,38,87,12,268,303,318,324,185,95,80,81,85,16,315,404,319,325,409,40,39,73,72,0,302,303,270,408,185,88,88,81,82,15,316,403,319,324,409,80,41,38,87,12,268,303,318,324],eyeL:[33,7,163,144,145,153,154,155,133,246,161,160,159,158,157,173,130,25,110,24,23,22,26,112,243,247,30,29,27,28,56,190,226,31,228,229,230,231,232,233,244,113,225,224,223,222,221,189,35,124,46,53,52,65,143,111,117,118,119,120,121,128,245,156,70,63,105,66,107,55,193],eyeR:[263,249,390,373,374,380,381,382,362,466,388,387,386,385,384,398,359,255,339,254,253,252,256,341,463,467,260,259,257,258,286,414,446,261,448,449,450,451,452,453,464,342,445,444,443,442,441,413,265,353,276,283,282,295,372,340,346,347,348,349,350,357,465,383,300,293,334,296,336,285,417]};async function q1(e,t){let o={irisL:t[3].dataSync(),irisR:t[1].dataSync(),eyeL:t[0].dataSync(),eyeR:t[6].dataSync(),lips:t[5].dataSync()},n=f0.eyeRLower.reduce((s,a)=>s+=e[a][2],0)/f0.eyeRLower.length;for(let s=0;ss+=e[a][2],0)/f0.eyeLLower.length;for(let s=0;sg()-j0.timestamp,n=j0.skipped<(((l=t.face.detector)==null?void 0:l.skipFrames)||0);!t.skipAllowed||!o||!n||j0.boxes.length===0?(j0.boxes=await f1(e,t),j0.timestamp=g(),j0.skipped=0):j0.skipped++;let r=[],s=[],a=0;for(let P=0;PG.shape[G.shape.length-1]===1),C=S.find(G=>G.shape[G.shape.length-1]===1404),L=await O.data();w.faceScore=Math.round(100*L[0])/100;let Z=A.reshape(C,[-1,3]),F=await Z.array();if(w.faceScore<(((f=t.face.detector)==null?void 0:f.minConfidence)||1))u.confidence=w.faceScore;else{(b=t.face.attention)!=null&&b.enabled?F=await q1(F,S):(m=t.face.iris)!=null&&m.enabled&&(F=await D1(F,w.tensor,t,ve)),w.mesh=i1(F,u,p,v,ve),w.meshRaw=w.mesh.map(Y=>[Y[0]/(e.shape[2]||0),Y[1]/(e.shape[1]||0),(Y[2]||0)/ve]);for(let Y of Object.keys(M0))w.annotations[Y]=M0[Y].map(z=>w.mesh[z]);w.score=w.faceScore;let G={...y1(w.mesh,u),confidence:u.confidence,landmarks:u.landmarks};w.box=x5(G,e),w.boxRaw=c5(G,e),s.push(G)}A.dispose([...S,Z])}else{w.box=x5(u,e),w.boxRaw=c5(u,e),w.score=w.boxScore,w.mesh=u.landmarks.map(S=>[(u.startPoint[0]+u.endPoint[0])/2+(u.endPoint[0]+u.startPoint[0])*S[0]/xt(),(u.startPoint[1]+u.endPoint[1])/2+(u.endPoint[1]+u.startPoint[1])*S[1]/xt()]),w.meshRaw=w.mesh.map(S=>[S[0]/(e.shape[2]||0),S[1]/(e.shape[1]||0),(S[2]||0)/ve]);for(let S of Object.keys(De))w.annotations[S]=[w.mesh[De[S]]]}w.score>(((M=t.face.detector)==null?void 0:M.minConfidence)||1)?r.push(w):A.dispose(w.tensor)}return j0.boxes=s,r}async function J1(e){var t,o,n;return T.initial&&(S0=null),S0?e.debug&&h("cached model:",S0.modelUrl):(t=e.face.attention)!=null&&t.enabled?S0=await I((o=e.face.attention)==null?void 0:o.modelPath):S0=await I((n=e.face.mesh)==null?void 0:n.modelPath),ve=S0.inputs[0].shape?S0.inputs[0].shape[2]:0,S0}var Y1=Ae,K1=Xe;var m0,gt=[],Q1=0,_1=0,C5=Number.MAX_SAFE_INTEGER;async function $1(e){var t;return T.initial&&(m0=null),m0?e.debug&&h("cached model:",m0.modelUrl):m0=await I((t=e.face.description)==null?void 0:t.modelPath),m0}function W5(e){let t=e.image||e.tensor||e;if(!(m0!=null&&m0.inputs[0].shape))return t;let o=A.image.resizeBilinear(t,[m0.inputs[0].shape[2],m0.inputs[0].shape[1]],!1),n=A.mul(o,N.tf255);return A.dispose(o),n}async function O5(e,t,o,n){var a,i,l,x;if(!m0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let r=C5<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((i=t.face.description)==null?void 0:i.skipTime)||0)>g()-Q1;return t.skipAllowed&&r&&s&&_1===n&&((l=gt[o])==null?void 0:l.age)&&((x=gt[o])==null?void 0:x.age)>0?(C5++,gt[o]):(C5=0,new Promise(async d=>{var c,f;let y={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((c=t.face.description)!=null&&c.enabled){let b=W5(e),m=m0==null?void 0:m0.execute(b);Q1=g(),A.dispose(b);let P=await(await m.find(L=>L.shape[1]===1)).data(),u=Math.trunc(200*Math.abs(P[0]-.5))/100;u>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(y.gender=P[0]<=.5?"female":"male",y.genderScore=Math.min(.99,u));let p=A.argMax(m.find(L=>L.shape[1]===100),1),v=(await p.data())[0];A.dispose(p);let S=await m.find(L=>L.shape[1]===100).data();y.age=Math.round(S[v-1]>S[v+1]?10*v-100*S[v-1]:10*v+100*S[v+1])/10;let O=m.find(L=>L.shape[1]===1024),C=O?await O.data():[];y.descriptor=Array.from(C),m.forEach(L=>A.dispose(L))}gt[o]=y,_1=n,d(y)}))}function Pt(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function Je(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function oo(e,t,o){let n=t.shape[1],r=t.shape[2],s=[[e.startPoint[1]/n,e.startPoint[0]/r,e.endPoint[1]/n,e.endPoint[0]/r]];return A.image.cropAndResize(t,s,[0],o)}function no(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],r=e.palmLandmarks.map(s=>[s[0]*t[0],s[1]*t[1]]);return{startPoint:o,endPoint:n,palmLandmarks:r,confidence:e.confidence}}function vt(e,t=1.5){let o=Je(e),n=Pt(e),r=[t*n[0]/2,t*n[1]/2],s=[o[0]-r[0],o[1]-r[1]],a=[o[0]+r[0],o[1]+r[1]];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function Mt(e){let t=Je(e),o=Pt(e),r=Math.max(...o)/2,s=[t[0]-r,t[1]-r],a=[t[0]+r,t[1]+r];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function fr(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function ro(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return fr(o)}var eo=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function K0(e,t){let o=0;for(let n=0;n[o.x,o.y]),this.anchorsTensor=A.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=A.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=A.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=A.slice(t,[0,0],[-1,2]),o.boxSizes=A.slice(t,[0,2],[-1,2]),o.div=A.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=A.add(o.div,this.anchorsTensor),o.halfBoxSizes=A.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=A.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=A.mul(o.sub,this.inputSizeTensor),o.add=A.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=A.mul(o.add,this.inputSizeTensor);let n=A.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(r=>A.dispose(o[r])),n}normalizeLandmarks(t,o){let n={};n.reshape=A.reshape(t,[-1,7,2]),n.div=A.div(n.reshape,this.inputSizeTensor),n.landmarks=A.add(n.div,this.anchors[o]);let r=A.mul(n.landmarks,this.inputSizeTensor);return Object.keys(n).forEach(s=>A.dispose(n[s])),r}async predict(t,o){let n={};n.resize=A.image.resizeBilinear(t,[this.inputSize,this.inputSize]),n.div=A.div(n.resize,N.tf127),n.image=A.sub(n.div,N.tf1),n.batched=this.model.execute(n.image),n.predictions=A.squeeze(n.batched),n.slice=A.slice(n.predictions,[0,0],[-1,1]),n.sigmoid=A.sigmoid(n.slice),n.scores=A.squeeze(n.sigmoid);let r=await n.scores.data();n.boxes=A.slice(n.predictions,[0,1],[-1,4]),n.norm=this.normalizeBoxes(n.boxes),n.nms=await A.image.nonMaxSuppressionAsync(n.norm,n.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let s=await n.nms.array(),a=[];for(let i of s){let l={};l.box=A.slice(n.norm,[i,0],[1,-1]),l.slice=A.slice(n.predictions,[i,5],[1,14]),l.norm=this.normalizeLandmarks(l.slice,i),l.palmLandmarks=A.reshape(l.norm,[-1,2]);let x=await l.box.data(),d=x.slice(0,2),y=x.slice(2,4),c=await l.palmLandmarks.array(),f={startPoint:d,endPoint:y,palmLandmarks:c,confidence:r[i]},b=no(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);a.push(b),Object.keys(l).forEach(m=>A.dispose(l[m]))}return Object.keys(n).forEach(i=>A.dispose(n[i])),a}};var hr=5,io=1.65,lo=[0,5,9,13,17,1,2],br=0,gr=2,yo=0,Tt=class{constructor(t,o){k(this,"handDetector");k(this,"handPoseModel");k(this,"inputSize");k(this,"storedBoxes");k(this,"skipped");k(this,"detectedHands");this.handDetector=t,this.handPoseModel=o,this.inputSize=this.handPoseModel&&this.handPoseModel.inputs[0].shape?this.handPoseModel.inputs[0].shape[2]:0,this.storedBoxes=[],this.skipped=Number.MAX_SAFE_INTEGER,this.detectedHands=0}calculateLandmarksBoundingBox(t){let o=t.map(a=>a[0]),n=t.map(a=>a[1]),r=[Math.min(...o),Math.min(...n)],s=[Math.max(...o),Math.max(...n)];return{startPoint:r,endPoint:s}}getBoxForPalmLandmarks(t,o){let n=t.map(s=>N5([...s,1],o)),r=this.calculateLandmarksBoundingBox(n);return vt(Mt(r),hr)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),n=vt(Mt(o),io);n.palmLandmarks=[];for(let r=0;r[a[0]*(f[0]-this.inputSize/2),a[1]*(f[1]-this.inputSize/2),a[2]*f[2]]),l=I5(n,[0,0]),x=i.map(f=>[...N5(f,l),f[2]]),d=Ao(r),y=[...Je(o),1],c=[K0(y,d[0]),K0(y,d[1])];return x.map(f=>[Math.trunc(f[0]+c[0]),Math.trunc(f[1]+c[1]),Math.trunc(f[2])])}async estimateHands(t,o){let n=!1,r,s=(o.hand.skipTime||0)>g()-yo,a=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&s&&a&&(r=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,r&&r.length>0&&(r.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...r],this.storedBoxes.length>0&&(n=!0));let i=[];for(let l=0;l=o.hand.minConfidence/4){let w=A.reshape(p,[-1,3]),S=await w.array();A.dispose(p),A.dispose(w);let O=this.transformRawCoords(S,m,d,b),C=this.getBoxForHandLandmarks(O);this.storedBoxes[l]={...C,confidence:v};let L={landmarks:O,confidence:v,boxConfidence:x.confidence,fingerConfidence:v,box:{topLeft:C.startPoint,bottomRight:C.endPoint}};i.push(L)}else this.storedBoxes[l]=null;A.dispose(p)}else{let d=vt(Mt(x),io),y={confidence:x.confidence,boxConfidence:x.confidence,fingerConfidence:0,box:{topLeft:d.startPoint,bottomRight:d.endPoint},landmarks:[]};i.push(y)}}return this.storedBoxes=this.storedBoxes.filter(l=>l!==null),this.detectedHands=i.length,i.length>o.hand.maxDetected&&(i.length=o.hand.maxDetected),i}};var y0={thumb:0,index:1,middle:2,ring:3,pinky:4,all:[0,1,2,3,4],nameMapping:{0:"thumb",1:"index",2:"middle",3:"ring",4:"pinky"},pointsMapping:{0:[[0,1],[1,2],[2,3],[3,4]],1:[[0,5],[5,6],[6,7],[7,8]],2:[[0,9],[9,10],[10,11],[11,12]],3:[[0,13],[13,14],[14,15],[15,16]],4:[[0,17],[17,18],[18,19],[19,20]]},getName:e=>y0.nameMapping[e],getPoints:e=>y0.pointsMapping[e]},_0={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>_0.nameMapping[e]},J={verticalUp:0,verticalDown:1,horizontalLeft:2,horizontalRight:3,diagonalUpRight:4,diagonalUpLeft:5,diagonalDownRight:6,diagonalDownLeft:7,nameMapping:{0:"verticalUp",1:"verticalDown",2:"horizontalLeft",3:"horizontalRight",4:"diagonalUpRight",5:"diagonalUpLeft",6:"diagonalDownRight",7:"diagonalDownLeft"},getName:e=>J.nameMapping[e]},Q0=class{constructor(t){k(this,"name");k(this,"curls");k(this,"directions");k(this,"weights");k(this,"weightsRelative");this.name=t,this.curls={},this.directions={},this.weights=[1,1,1,1,1],this.weightsRelative=[1,1,1,1,1]}curl(t,o,n){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,n])}direction(t,o,n){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,n])}weight(t,o){this.weights[t]=o;let n=this.weights.reduce((r,s)=>r+s,0);this.weightsRelative=this.weights.map(r=>r*5/n)}matchAgainst(t,o){let n=0;for(let r in t){let s=t[r],a=this.curls[r];if(typeof a=="undefined"){n+=this.weightsRelative[r];continue}for(let[i,l]of a)if(s===i){n+=l*this.weightsRelative[r];break}}for(let r in o){let s=o[r],a=this.directions[r];if(typeof a=="undefined"){n+=this.weightsRelative[r];continue}for(let[i,l]of a)if(s===i){n+=l*this.weightsRelative[r];break}}return n/10}};var{thumb:T0,index:H0,middle:V0,ring:ie,pinky:le}=y0,{none:w0,half:vr,full:k0}=_0,{verticalUp:Me,verticalDown:F3,horizontalLeft:F5,horizontalRight:Mr,diagonalUpRight:Rr,diagonalUpLeft:Re,diagonalDownRight:G3,diagonalDownLeft:B3}=J,$0=new Q0("thumbs up");$0.curl(T0,w0,1);$0.direction(T0,Me,1);$0.direction(T0,Re,.25);$0.direction(T0,Rr,.25);for(let e of[y0.index,y0.middle,y0.ring,y0.pinky])$0.curl(e,k0,1),$0.direction(e,F5,1),$0.direction(e,Mr,1);var e0=new Q0("victory");e0.curl(T0,vr,.5);e0.curl(T0,w0,.5);e0.direction(T0,Me,1);e0.direction(T0,Re,1);e0.curl(H0,w0,1);e0.direction(H0,Me,.75);e0.direction(H0,Re,1);e0.curl(V0,w0,1);e0.direction(V0,Me,1);e0.direction(V0,Re,.75);e0.curl(ie,k0,1);e0.direction(ie,Me,.2);e0.direction(ie,Re,1);e0.direction(ie,F5,.2);e0.curl(le,k0,1);e0.direction(le,Me,.2);e0.direction(le,Re,1);e0.direction(le,F5,.2);e0.weight(H0,2);e0.weight(V0,2);var ee=new Q0("point");ee.curl(T0,k0,1);ee.curl(H0,w0,.5);ee.curl(V0,k0,.5);ee.curl(ie,k0,.5);ee.curl(le,k0,.5);ee.weight(H0,2);ee.weight(V0,2);var te=new Q0("middle finger");te.curl(T0,w0,1);te.curl(H0,k0,.5);te.curl(V0,k0,.5);te.curl(ie,k0,.5);te.curl(le,k0,.5);te.weight(H0,2);te.weight(V0,2);var Te=new Q0("open palm");Te.curl(T0,w0,.75);Te.curl(H0,w0,.75);Te.curl(V0,w0,.75);Te.curl(ie,w0,.75);Te.curl(le,w0,.75);var xo=[$0,e0,ee,te,Te];var Tr=.7,ye={HALF_CURL_START_LIMIT:60,NO_CURL_START_LIMIT:130,DISTANCE_VOTE_POWER:1.1,SINGLE_ANGLE_VOTE_POWER:.9,TOTAL_ANGLE_VOTE_POWER:1.6};function co(e,t,o,n){let r=(t-n)/(e-o),s=Math.atan(r)*180/Math.PI;return s<=0?s=-s:s>0&&(s=180-s),s}function mo(e,t){if(!e||!t)return[0,0];let o=co(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let n=co(e[1],e[2],t[1],t[2]);return[o,n]}function fo(e,t=1){let o=0,n=0,r=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?n=1*t:r=1*t,[o,n,r]}function wr(e,t,o){let n=e[0]-t[0],r=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],i=e[1]-o[1],l=t[1]-o[1],x=e[2]-t[2],d=e[2]-o[2],y=t[2]-o[2],c=Math.sqrt(n*n+a*a+x*x),f=Math.sqrt(r*r+i*i+d*d),b=Math.sqrt(s*s+l*l+y*y),m=(b*b+c*c-f*f)/(2*b*c);m>1?m=1:m<-1&&(m=-1);let M=Math.acos(m);M=57.2958*M%180;let P;return M>ye.NO_CURL_START_LIMIT?P=_0.none:M>ye.HALF_CURL_START_LIMIT?P=_0.half:P=_0.full,P}function po(e,t,o,n){let r;return n===Math.abs(e)?e>0?r=J.horizontalLeft:r=J.horizontalRight:n===Math.abs(t)?t>0?r=J.horizontalLeft:r=J.horizontalRight:o>0?r=J.horizontalLeft:r=J.horizontalRight,r}function uo(e,t,o,n){let r;return n===Math.abs(e)?e<0?r=J.verticalDown:r=J.verticalUp:n===Math.abs(t)?t<0?r=J.verticalDown:r=J.verticalUp:o<0?r=J.verticalDown:r=J.verticalUp,r}function kr(e,t,o,n,r,s,a,i){let l,x=uo(e,t,o,n),d=po(r,s,a,i);return x===J.verticalUp?d===J.horizontalLeft?l=J.diagonalUpLeft:l=J.diagonalUpRight:d===J.horizontalLeft?l=J.diagonalDownLeft:l=J.diagonalDownRight,l}function Er(e,t,o,n){let r=e[0]-t[0],s=e[0]-o[0],a=t[0]-o[0],i=e[1]-t[1],l=e[1]-o[1],x=t[1]-o[1],d=Math.max(Math.abs(r),Math.abs(s),Math.abs(a)),y=Math.max(Math.abs(i),Math.abs(l),Math.abs(x)),c=0,f=0,b=0,m=y/(d+1e-5);m>1.5?c+=ye.DISTANCE_VOTE_POWER:m>.66?f+=ye.DISTANCE_VOTE_POWER:b+=ye.DISTANCE_VOTE_POWER;let M=Math.sqrt(r*r+i*i),P=Math.sqrt(s*s+l*l),u=Math.sqrt(a*a+x*x),p=Math.max(M,P,u),v=e[0],w=e[1],S=o[0],O=o[1];p===M?(S=o[0],O=o[1]):p===u&&(v=t[0],w=t[1]);let Z=mo([v,w],[S,O]),F=fo(Z,ye.TOTAL_ANGLE_VOTE_POWER);c+=F[0],f+=F[1],b+=F[2];for(let Y of n){let z=fo(Y,ye.SINGLE_ANGLE_VOTE_POWER);c+=z[0],f+=z[1],b+=z[2]}let G;return c===Math.max(c,f,b)?G=uo(l,i,x,y):b===Math.max(f,b)?G=po(s,r,a,d):G=kr(l,i,x,y,s,r,a,d),G}function ho(e){let t=[],o=[],n=[],r=[];if(!e)return{curls:n,directions:r};for(let s of y0.all){let a=y0.getPoints(s),i=[],l=[];for(let x of a){let d=e[x[0]],y=e[x[1]],c=mo(d,y),f=c[0],b=c[1];i.push(f),l.push(b)}t.push(i),o.push(l)}for(let s of y0.all){let a=s===y0.thumb?1:0,i=y0.getPoints(s),l=e[i[a][0]],x=e[i[a+1][1]],d=e[i[3][1]],y=wr(l,x,d),c=Er(l,x,d,t[s].slice(a));n[s]=y,r[s]=c}return{curls:n,directions:r}}function wt(e){if(!e||e.length===0)return null;let t=ho(e),o={};for(let n of y0.all)o[y0.getName(n)]={curl:_0.getName(t.curls[n]),direction:J.getName(t.directions[n])};return o}function bo(e){let t=[];if(!e||e.length===0)return t;let o=ho(e);for(let n of xo){let r=n.matchAgainst(o.curls,o.directions);r>=Tr&&t.push({name:n.name,confidence:r})}return t}var go={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],palm:[0]},we,ke,Po;async function B5(e,t){let o=await Po.estimateHands(e,t);if(!o)return[];let n=[];for(let r=0;ro[r].landmarks[y]);let a=o[r].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],l=[0,0,0,0];if(a&&a.length>0){for(let d of a)d[0]i[2]&&(i[2]=d[0]),d[1]>i[3]&&(i[3]=d[1]);i[2]-=i[0],i[3]-=i[1],l=[i[0]/(e.shape[2]||0),i[1]/(e.shape[1]||0),i[2]/(e.shape[2]||0),i[3]/(e.shape[1]||0)]}else i=o[r].box?[Math.trunc(Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.max(0,o[r].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[r].box.bottomRight[0])-Math.max(0,o[r].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[r].box.bottomRight[1])-Math.max(0,o[r].box.topLeft[1]))]:[0,0,0,0],l=[o[r].box.topLeft[0]/(e.shape[2]||0),o[r].box.topLeft[1]/(e.shape[1]||0),(o[r].box.bottomRight[0]-o[r].box.topLeft[0])/(e.shape[2]||0),(o[r].box.bottomRight[1]-o[r].box.topLeft[1])/(e.shape[1]||0)];let x=wt(a);n.push({id:r,score:Math.round(100*o[r].confidence)/100,boxScore:Math.round(100*o[r].boxConfidence)/100,fingerScore:Math.round(100*o[r].fingerConfidence)/100,label:"hand",box:i,boxRaw:l,keypoints:a,annotations:s,landmarks:x})}return n}async function H5(e){var o,n;T.initial&&(we=null,ke=null),!we||!ke?[we,ke]=await Promise.all([e.hand.enabled?I((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?I((n=e.hand.skeleton)==null?void 0:n.modelPath):null]):(e.debug&&h("cached model:",we.modelUrl),e.debug&&h("cached model:",ke.modelUrl));let t=new Rt(we);return Po=new Tt(t,ke),[we,ke]}var o0=[null,null],zr=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],oe=[[0,0],[0,0]],jr=["hand","fist","pinch","point","face","tip","pinchtip"],Mo=4,Ro=1.6,Sr=512,Cr=1.4,kt=Number.MAX_SAFE_INTEGER,V5=0,Z0=[0,0],Q={boxes:[],hands:[]},To={thumb:[1,2,3,4],index:[5,6,7,8],middle:[9,10,11,12],ring:[13,14,15,16],pinky:[17,18,19,20],base:[0],palm:[0,17,13,9,5,1,0]};async function wo(e){var t;if(T.initial&&(o0[0]=null),o0[0])e.debug&&h("cached model:",o0[0].modelUrl);else{Et(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),o0[0]=await I((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values(o0[0].modelSignature.inputs);oe[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,oe[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return o0[0]}async function ko(e){var t;if(T.initial&&(o0[1]=null),o0[1])e.debug&&h("cached model:",o0[1].modelUrl);else{o0[1]=await I((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values(o0[1].modelSignature.inputs);oe[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,oe[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return o0[1]}async function Wr(e,t){let o=[];if(!e||!o0[0])return o;let n={},r=(e.shape[2]||1)/(e.shape[1]||1),s=Math.min(Math.round((e.shape[1]||0)/8)*8,Sr),a=Math.round(s*r/8)*8;n.resize=A.image.resizeBilinear(e,[s,a]),n.cast=A.cast(n.resize,"int32"),[n.rawScores,n.rawBoxes]=await o0[0].executeAsync(n.cast,zr),n.boxes=A.squeeze(n.rawBoxes,[0,2]),n.scores=A.squeeze(n.rawScores,[0]);let i=A.unstack(n.scores,1);A.dispose(i[Mo]),i.splice(Mo,1),n.filtered=A.stack(i,1),A.dispose(i),n.max=A.max(n.filtered,1),n.argmax=A.argMax(n.filtered,1);let l=0;n.nms=await A.image.nonMaxSuppressionAsync(n.boxes,n.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let x=await n.nms.data(),d=await n.max.data(),y=await n.argmax.data();for(let c of Array.from(x)){let f=A.slice(n.boxes,c,1),b=await f.data();A.dispose(f);let m=[b[1],b[0],b[3]-b[1],b[2]-b[0]],M=ft(m,Cr),P=[Math.trunc(m[0]*Z0[0]),Math.trunc(m[1]*Z0[1]),Math.trunc(m[2]*Z0[0]),Math.trunc(m[3]*Z0[1])],u=d[c],p=jr[y[c]],v={id:l++,score:u,box:P,boxRaw:M,label:p};o.push(v)}return Object.keys(n).forEach(c=>A.dispose(n[c])),o.sort((c,f)=>f.score-c.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function Z5(e,t,o){let n={id:t.id,score:Math.round(100*t.score)/100,boxScore:Math.round(100*t.score)/100,fingerScore:0,box:t.box,boxRaw:t.boxRaw,label:t.label,keypoints:[],landmarks:{},annotations:{}};if(e&&o0[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let r={},s=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];r.crop=A.image.cropAndResize(e,[s],[0],[oe[1][0],oe[1][1]],"bilinear"),r.div=A.div(r.crop,N.tf255),[r.score,r.keypoints]=o0[1].execute(r.div,["Identity_1","Identity"]);let a=(await r.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(a))))/100;if(i>=(o.hand.minConfidence||0)){n.fingerScore=i,r.reshaped=A.reshape(r.keypoints,[-1,3]);let d=(await r.reshaped.array()).map(y=>[y[0]/oe[1][1],y[1]/oe[1][0],y[2]||0]).map(y=>[y[0]*t.boxRaw[2],y[1]*t.boxRaw[3],y[2]||0]);n.keypoints=d.map(y=>[Z0[0]*(y[0]+t.boxRaw[0]),Z0[1]*(y[1]+t.boxRaw[1]),y[2]||0]),n.landmarks=wt(n.keypoints);for(let y of Object.keys(To))n.annotations[y]=To[y].map(c=>n.landmarks&&n.keypoints[c]?n.keypoints[c]:null)}Object.keys(r).forEach(l=>A.dispose(r[l]))}return n}async function D5(e,t){var r,s;if(!o0[0]||!o0[1]||!((r=o0[0])!=null&&r.inputs[0].shape)||!((s=o0[1])!=null&&s.inputs[0].shape))return[];Z0=[e.shape[2]||0,e.shape[1]||0],kt++;let o=(t.hand.skipTime||0)>g()-V5,n=kt<(t.hand.skipFrames||0);return t.skipAllowed&&o&&n?Q.hands:new Promise(async a=>{let i=3*(t.hand.skipTime||0)>g()-V5,l=kt<3*(t.hand.skipFrames||0);t.skipAllowed&&Q.hands.length===t.hand.maxDetected?Q.hands=await Promise.all(Q.boxes.map(d=>Z5(e,d,t))):t.skipAllowed&&i&&l&&Q.hands.length>0?Q.hands=await Promise.all(Q.boxes.map(d=>Z5(e,d,t))):(Q.boxes=await Wr(e,t),V5=g(),Q.hands=await Promise.all(Q.boxes.map(d=>Z5(e,d,t))),kt=0);let x=[...Q.boxes];if(Q.boxes.length=0,t.cacheSensitivity>0)for(let d=0;d.05&&y.box[3]/(e.shape[1]||1)>.05&&Q.hands[d].fingerScore&&Q.hands[d].fingerScore>(t.hand.minConfidence||0)){let c=ft(y.box,Ro),f=ft(y.boxRaw,Ro);Q.boxes.push({...x[d],box:c,boxRaw:f})}}for(let d=0;dg()-jo,s=X5<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&r&&s&&zo===n&&zt[o]?(X5++,zt[o]):(X5=0,new Promise(async l=>{let x=A.image.resizeBilinear(e,[s0!=null&&s0.inputs[0].shape?s0.inputs[0].shape[2]:0,s0!=null&&s0.inputs[0].shape?s0.inputs[0].shape[1]:0],!1),d=s0==null?void 0:s0.execute(x),y=(await d.data())[0];zt[o]=Math.round(100*y)/100,zo=n,jo=g(),A.dispose([x,d]),l(zt[o])}))}var Ye={};ne(Ye,{connected:()=>St,horizontal:()=>U5,kpt:()=>jt,relative:()=>Y5,vertical:()=>J5});var jt=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],U5=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],J5=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],Y5=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],St={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var Wo=.005,p0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function K5(e){for(let t of U5){let o=e.keypoints.findIndex(r=>r.part===t[0]),n=e.keypoints.findIndex(r=>r.part===t[1]);if(e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[0]r&&r.part===t[0]),n=e.keypoints.findIndex(r=>r&&r.part===t[1]);e.keypoints[o]&&e.keypoints[n]&&e.keypoints[o].position[1]x&&x.part===t[0]),r=e.keypoints.findIndex(x=>x&&x.part===t[1]),s=e.keypoints.findIndex(x=>x&&x.part===o[0]),a=e.keypoints.findIndex(x=>x&&x.part===o[1]);if(!e.keypoints[s]||!e.keypoints[a])continue;let i=e.keypoints[n]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[n].position[0])]:[0,0],l=e.keypoints[r]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[r].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[r].position[0])]:[0,0];if(i[0]>i[1]||l[0]>l[1]){let x=e.keypoints[n];e.keypoints[n]=e.keypoints[r],e.keypoints[r]=x}}}function Oo(e){for(let t=0;te.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0,e.shape[2]>e.shape[1]?Math.trunc((e.shape[2]-e.shape[1])/2):0],[e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0,e.shape[1]>e.shape[2]?Math.trunc((e.shape[1]-e.shape[2])/2):0],[0,0]],o.pad=A.pad(e,p0.padding),o.resize=A.image.resizeBilinear(o.pad,[t,t]);let n=A.cast(o.resize,"int32");return Object.keys(o).forEach(r=>A.dispose(o[r])),n}function Io(e,t){e.keypoints=e.keypoints.filter(n=>n&&n.position);for(let n of e.keypoints)n.position=[n.position[0]*(t[0]+p0.padding[2][0]+p0.padding[2][1])/t[0]-p0.padding[2][0],n.position[1]*(t[1]+p0.padding[1][0]+p0.padding[1][1])/t[1]-p0.padding[1][0]],n.positionRaw=[n.position[0]/t[0],n.position[1]/t[1]];let o=F0(e.keypoints.map(n=>n.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var u0,Ct=0,Q5=Number.MAX_SAFE_INTEGER,xe={boxes:[],bodies:[],last:0};async function No(e){return T.initial&&(u0=null),u0?e.debug&&h("cached model:",u0.modelUrl):(Et(["size"],e),u0=await I(e.body.modelPath)),Ct=u0.inputs[0].shape?u0.inputs[0].shape[2]:0,Ct<64&&(Ct=256),u0}async function Lr(e,t,o){let n=e[0][0],r=[],s=0;for(let d=0;dt.body.minConfidence){let y=[n[d][1],n[d][0]];r.push({score:Math.round(100*s)/100,part:jt[d],positionRaw:y,position:[Math.round((o.shape[2]||0)*y[0]),Math.round((o.shape[1]||0)*y[1])]})}s=r.reduce((d,y)=>y.score>d?y.score:d,0);let a=[],i=F0(r.map(d=>d.position),[o.shape[2],o.shape[1]]),l={};for(let[d,y]of Object.entries(St)){let c=[];for(let f=0;fM.part===y[f]),m=r.find(M=>M.part===y[f+1]);b&&m&&b.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&c.push([b.position,m.position])}l[d]=c}let x={id:0,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:r,annotations:l};return K5(x),a.push(x),a}async function Ir(e,t,o){let n=[];for(let r=0;rt.body.minConfidence){let i=[];for(let y=0;y<17;y++){let c=s[3*y+2];if(c>t.body.minConfidence){let f=[s[3*y+1],s[3*y+0]];i.push({part:jt[y],score:Math.round(100*c)/100,positionRaw:f,position:[Math.round((o.shape[2]||0)*f[0]),Math.round((o.shape[1]||0)*f[1])]})}}let l=F0(i.map(y=>y.position),[o.shape[2],o.shape[1]]),x={};for(let[y,c]of Object.entries(St)){let f=[];for(let b=0;bP.part===c[b]),M=i.find(P=>P.part===c[b+1]);m&&M&&m.score>(t.body.minConfidence||0)&&M.score>(t.body.minConfidence||0)&&f.push([m.position,M.position])}x[y]=f}let d={id:r,score:a,box:l.box,boxRaw:l.boxRaw,keypoints:[...i],annotations:x};K5(d),n.push(d)}}return n.sort((r,s)=>s.score-r.score),n.length>t.body.maxDetected&&(n.length=t.body.maxDetected),n}async function _5(e,t){if(!u0||!(u0!=null&&u0.inputs[0].shape))return[];t.skipAllowed||(xe.boxes.length=0),Q5++;let o=(t.body.skipTime||0)>g()-xe.last,n=Q5<(t.body.skipFrames||0);return t.skipAllowed&&o&&n?xe.bodies:new Promise(async r=>{let s={};Q5=0,s.input=Lo(e,Ct),s.res=u0==null?void 0:u0.execute(s.input),xe.last=g();let a=await s.res.array();xe.bodies=s.res.shape[2]===17?await Lr(a,t,e):await Ir(a,t,e);for(let i of xe.bodies)Io(i,[e.shape[2]||1,e.shape[1]||1]),Oo(i.keypoints);Object.keys(s).forEach(i=>A.dispose(s[i])),r(xe.bodies)})}var Ee,Wt=[],Go=0,$5=Number.MAX_SAFE_INTEGER,Lt=0,Ot=2.5;async function Bo(e){if(!Ee||T.initial){Ee=await I(e.object.modelPath);let t=Object.values(Ee.modelSignature.inputs);Lt=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&h("cached model:",Ee.modelUrl);return Ee}async function Nr(e,t,o){let n=0,r=[];for(let l of[1,2,4])A.tidy(async()=>{let x=l*13,d=A.squeeze(e.find(m=>m.shape[1]===x**2&&(m.shape[2]||0)===be.length)),y=A.squeeze(e.find(m=>m.shape[1]===x**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&M!==61){let u=(.5+Math.trunc(m%x))/x,p=(.5+Math.trunc(m/x))/x,v=f[m].map(G=>G*(x/l/Lt)),[w,S]=[u-Ot/l*v[0],p-Ot/l*v[1]],[O,C]=[u+Ot/l*v[2]-w,p+Ot/l*v[3]-S],L=[w,S,O,C];L=L.map(G=>Math.max(0,Math.min(G,1)));let Z=[L[0]*t[0],L[1]*t[1],L[2]*t[0],L[3]*t[1]],F={id:n++,score:Math.round(100*P)/100,class:M+1,label:be[M].label,box:Z.map(G=>Math.trunc(G)),boxRaw:L};r.push(F)}}});e.forEach(l=>A.dispose(l));let s=r.map(l=>[l.boxRaw[1],l.boxRaw[0],l.boxRaw[3],l.boxRaw[2]]),a=r.map(l=>l.score),i=[];if(s&&s.length>0){let l=await A.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);i=await l.data(),A.dispose(l)}return r=r.filter((l,x)=>i.includes(x)).sort((l,x)=>x.score-l.score),r}async function e2(e,t){let o=(t.object.skipTime||0)>g()-Go,n=$5<(t.object.skipFrames||0);return t.skipAllowed&&o&&n&&Wt.length>0?($5++,Wt):($5=0,!T.kernels.includes("mod")||!T.kernels.includes("sparsetodense")?Wt:new Promise(async r=>{let s=[e.shape[2]||0,e.shape[1]||0],a=A.image.resizeBilinear(e,[Lt,Lt],!1),i=A.div(a,N.tf255),l=i.transpose([0,3,1,2]);A.dispose(i),A.dispose(a);let x;t.object.enabled&&(x=Ee.execute(l)),Go=g(),A.dispose(l);let d=await Nr(x,s,t);Wt=d,r(d)}))}var Qe=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Fr=Qe.length,Ke=Qe.reduce((e,t,o)=>(e[t]=o,e),{}),Gr=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],ys=Gr.map(([e,t])=>[Ke[e],Ke[t]]),Vo=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];function Zo(e){let t=e.reduce(({maxX:o,maxY:n,minX:r,minY:s},{position:{x:a,y:i}})=>({maxX:Math.max(o,a),maxY:Math.max(n,i),minX:Math.min(r,a),minY:Math.min(s,i)}),{maxX:Number.NEGATIVE_INFINITY,maxY:Number.NEGATIVE_INFINITY,minX:Number.POSITIVE_INFINITY,minY:Number.POSITIVE_INFINITY});return[t.minX,t.minY,t.maxX-t.minX,t.maxY-t.minY]}function Do(e,[t,o],[n,r]){let s=t/n,a=o/r,i=(x,d)=>({id:d,score:x.score,boxRaw:[x.box[0]/r,x.box[1]/n,x.box[2]/r,x.box[3]/n],box:[Math.trunc(x.box[0]*a),Math.trunc(x.box[1]*s),Math.trunc(x.box[2]*a),Math.trunc(x.box[3]*s)],keypoints:x.keypoints.map(({score:y,part:c,position:f})=>({score:y,part:c,position:[Math.trunc(f.x*a),Math.trunc(f.y*s)],positionRaw:[f.x/n,f.y/n]})),annotations:{}});return e.map((x,d)=>i(x,d))}var It=class{constructor(t,o){k(this,"priorityQueue");k(this,"numberOfElements");k(this,"getElementValue");this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=o}enqueue(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements)}dequeue(){let t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(t){for(;t>0&&this.less(Math.floor(t/2),t);)this.exchange(t,Math.floor(t/2)),t=Math.floor(t/2)}sink(t){for(;2*t<=this.numberOfElements;){let o=2*t;if(oo?o:e}function Xo(e,t,o,n){let r=o-e,s=n-t;return r*r+s*s}function r2(e,t){return{x:e.x+t.x,y:e.y+t.y}}var E0,Hr=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],Nt=1,ze=16,Vr=50**2;function qo(e,t,o,n,r,s,a=2){let i=P=>({y:s.get(P.y,P.x,e),x:s.get(P.y,P.x,s.shape[2]/2+e)}),l=(P,u,p)=>({y:n2(Math.round(P.y/ze),0,u-1),x:n2(Math.round(P.x/ze),0,p-1)}),[x,d]=n.shape,y=l(t.position,x,d),c=i(y),b=r2(t.position,c);for(let P=0;P[Ke[c],Ke[f]]),a=s.map(([,c])=>c),i=s.map(([c])=>c),l=t.shape[2],x=a.length,d=new Array(l),y=o2(e.part,ze,o);d[e.part.id]={score:e.score,part:Qe[e.part.id],position:y};for(let c=x-1;c>=0;--c){let f=a[c],b=i[c];d[f]&&!d[b]&&(d[b]=qo(c,d[f],b,t,o,r))}for(let c=0;ct){i=!1;break}if(!i)break}return i}function Xr(e,t){let[o,n,r]=t.shape,s=new It(o*n*r,({score:a})=>a);for(let a=0;a{var a;let s=(a=r[n])==null?void 0:a.position;return s?Xo(o,t,s.y,s.x)<=Vr:!1})}function qr(e,t){return t.reduce((n,{position:r,score:s},a)=>(Uo(e,r,a)||(n+=s),n),0)/t.length}function Ur(e,t,o,n,r,s){let a=[],i=Xr(s,t);for(;a.lengthf.score>s);let y=qr(a,d),c=Zo(d);y>s&&a.push({keypoints:d,box:c,score:Math.round(100*y)/100})}return a}async function A2(e,t){let o=A.tidy(()=>{if(!E0.inputs[0].shape)return[];let a=A.image.resizeBilinear(e,[E0.inputs[0].shape[2],E0.inputs[0].shape[1]]),i=A.sub(A.div(A.cast(a,"float32"),127.5),1),x=E0.execute(i,Hr).map(d=>A.squeeze(d,[0]));return x[1]=A.sigmoid(x[1]),x}),n=await Promise.all(o.map(a=>a.buffer()));for(let a of o)A.dispose(a);let r=await Ur(n[0],n[1],n[2],n[3],t.body.maxDetected,t.body.minConfidence);return E0.inputs[0].shape?Do(r,[e.shape[1],e.shape[2]],[E0.inputs[0].shape[2],E0.inputs[0].shape[1]]):[]}async function Jo(e){return!E0||T.initial?E0=await I(e.body.modelPath):e.debug&&h("cached model:",E0.modelUrl),E0}var C0,s2=!1;async function a2(e){return!C0||T.initial?C0=await I(e.segmentation.modelPath):e.debug&&h("cached model:",C0.modelUrl),C0}async function Ko(e,t,o){var m,M;if(s2)return{data:[],canvas:null,alpha:null};s2=!0,C0||await a2(o);let n=await pe(e,o),r=((m=n.tensor)==null?void 0:m.shape[2])||0,s=((M=n.tensor)==null?void 0:M.shape[1])||0;if(!n.tensor)return{data:[],canvas:null,alpha:null};let a={};a.resize=A.image.resizeBilinear(n.tensor,[C0.inputs[0].shape?C0.inputs[0].shape[1]:0,C0.inputs[0].shape?C0.inputs[0].shape[2]:0],!1),A.dispose(n.tensor),a.norm=A.div(a.resize,N.tf255),a.res=C0.execute(a.norm),a.squeeze=A.squeeze(a.res,0),a.squeeze.shape[2]===2?(a.softmax=A.softmax(a.squeeze),[a.bg,a.fg]=A.unstack(a.softmax,2),a.expand=A.expandDims(a.fg,2),a.pad=A.expandDims(a.expand,0),a.crop=A.image.cropAndResize(a.pad,[[0,0,.5,.5]],[0],[r,s]),a.data=A.squeeze(a.crop,0)):a.data=A.image.resizeBilinear(a.squeeze,[s,r]);let i=Array.from(await a.data.data());if(T.node&&!T.Canvas&&typeof ImageData=="undefined")return o.debug&&h("canvas support missing"),Object.keys(a).forEach(P=>A.dispose(a[P])),{data:i,canvas:null,alpha:null};let l=i0(r,s);A.browser&&await A.browser.toPixels(a.data,l);let x=l.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(x.filter=`blur(${o.segmentation.blur}px)`);let d=x.getImageData(0,0,r,s),y=i0(r,s),c=y.getContext("2d");n.canvas&&c.drawImage(n.canvas,0,0),c.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`),c.drawImage(l,0,0),c.globalCompositeOperation="source-over",c.filter="none";let f=c.getImageData(0,0,r,s);for(let P=0;PA.dispose(a[P])),s2=!1,{data:i,canvas:y,alpha:l}}var _e=class{constructor(){k(this,"ssrnetage",null);k(this,"gear",null);k(this,"blazeposedetect",null);k(this,"blazepose",null);k(this,"centernet",null);k(this,"efficientpose",null);k(this,"mobilefacenet",null);k(this,"emotion",null);k(this,"facedetect",null);k(this,"faceiris",null);k(this,"facemesh",null);k(this,"faceres",null);k(this,"ssrnetgender",null);k(this,"handpose",null);k(this,"handskeleton",null);k(this,"handtrack",null);k(this,"liveness",null);k(this,"movenet",null);k(this,"nanodet",null);k(this,"posenet",null);k(this,"segmentation",null);k(this,"antispoof",null)}};function Ft(e){for(let t of Object.keys(e.models))e.models[t]=null}async function i2(e){var t,o,n,r,s,a,i,l,x,d,y,c,f,b,m,M,P,u,p,v,w,S,O,C,L,Z,F,G,Y,z,R0;T.initial&&Ft(e),e.config.hand.enabled&&(!e.models.handpose&&((o=(t=e.config.hand.detector)==null?void 0:t.modelPath)==null?void 0:o.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await H5(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((r=(n=e.config.hand.detector)==null?void 0:n.modelPath)==null?void 0:r.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await H5(e.config))),e.config.body.enabled&&!e.models.blazepose&&((a=(s=e.config.body)==null?void 0:s.modelPath)==null?void 0:a.includes("blazepose"))&&(e.models.blazepose=M1(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=v1(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((l=(i=e.config.body)==null?void 0:i.modelPath)==null?void 0:l.includes("efficientpose"))&&(e.models.efficientpose=z1(e.config)),e.config.body.enabled&&!e.models.movenet&&((d=(x=e.config.body)==null?void 0:x.modelPath)==null?void 0:d.includes("movenet"))&&(e.models.movenet=No(e.config)),e.config.body.enabled&&!e.models.posenet&&((c=(y=e.config.body)==null?void 0:y.modelPath)==null?void 0:c.includes("posenet"))&&(e.models.posenet=Jo(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=d1(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=e1(e.config)),e.config.face.enabled&&((b=e.config.face.liveness)==null?void 0:b.enabled)&&!e.models.liveness&&(e.models.liveness=So(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=$1(e.config)),e.config.face.enabled&&((M=e.config.face.emotion)==null?void 0:M.enabled)&&!e.models.emotion&&(e.models.emotion=W1(e.config)),e.config.face.enabled&&((P=e.config.face.iris)==null?void 0:P.enabled)&&!((u=e.config.face.attention)!=null&&u.enabled)&&!e.models.faceiris&&(e.models.faceiris=Z1(e.config)),e.config.face.enabled&&((p=e.config.face.mesh)==null?void 0:p.enabled)&&!e.models.facemesh&&(e.models.facemesh=J1(e.config)),e.config.face.enabled&&((v=e.config.face.gear)==null?void 0:v.enabled)&&!e.models.gear&&(e.models.gear=H2(e.config)),e.config.face.enabled&&((w=e.config.face.ssrnet)==null?void 0:w.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=q2(e.config)),e.config.face.enabled&&((S=e.config.face.ssrnet)==null?void 0:S.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=K2(e.config)),e.config.face.enabled&&((O=e.config.face.mobilefacenet)==null?void 0:O.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=F1(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((L=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:L.includes("handtrack"))&&(e.models.handtrack=wo(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((F=(Z=e.config.hand.detector)==null?void 0:Z.modelPath)==null?void 0:F.includes("handtrack"))&&(e.models.handskeleton=ko(e.config)),e.config.object.enabled&&!e.models.centernet&&((Y=(G=e.config.object)==null?void 0:G.modelPath)==null?void 0:Y.includes("centernet"))&&(e.models.centernet=w1(e.config)),e.config.object.enabled&&!e.models.nanodet&&((R0=(z=e.config.object)==null?void 0:z.modelPath)==null?void 0:R0.includes("nanodet"))&&(e.models.nanodet=Bo(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=a2(e.config));for await(let h0 of Object.keys(e.models))e.models[h0]&&typeof e.models[h0]!="undefined"&&(e.models[h0]=await e.models[h0])}async function l2(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let n=e.models[o];if(!n)continue;let r=[],s=n==null?void 0:n.executor;if(s&&s.graph.nodes)for(let i of Object.values(s.graph.nodes)){let l=i.op.toLowerCase();r.includes(l)||r.push(l)}else!s&&e.config.debug&&h("model signature not determined:",o);let a=[];for(let i of r)!t.includes(i)&&!e.env.kernels.includes(i)&&!e.env.kernels.includes(i.replace("_",""))&&!e.env.kernels.includes(i.replace("native",""))&&!e.env.kernels.includes(i.replace("v2",""))&&a.push(i);e.config.debug&&a.length>0&&h("model validation failed:",o,a)}}var U={name:"humangl",priority:999,canvas:null,gl:null,extensions:[],webGLattr:{alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!1,desynchronized:!0}};function Jr(){let e=U.gl;!e||(U.extensions=e.getSupportedExtensions())}async function _o(e){var t;if(e.config.backend==="humangl"&&(U.name in A.engine().registry&&(!U.gl||!U.gl.getParameter(U.gl.VERSION))&&(h("error: humangl backend invalid context"),Ft(e)),!A.findBackend(U.name))){try{U.canvas=await i0(100,100)}catch(n){h("error: cannot create canvas:",n);return}try{if(U.gl=(t=U.canvas)==null?void 0:t.getContext("webgl2",U.webGLattr),!U.gl.getParameter(U.gl.VERSION).includes("2.0")){h("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}U.canvas&&(U.canvas.addEventListener("webglcontextlost",async r=>{throw h("error: humangl:",r.type),h("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),U.canvas.addEventListener("webglcontextrestored",r=>{h("error: humangl context restored:",r)}),U.canvas.addEventListener("webglcontextcreationerror",r=>{h("error: humangl context create:",r)}))}catch(n){h("error: cannot get WebGL context:",n);return}try{A.setWebGLContext(2,U.gl)}catch(n){h("error: cannot set WebGL context:",n);return}try{let n=new A.GPGPUContext(U.gl);A.registerBackend(U.name,()=>new A.MathBackendWebGL(n),U.priority)}catch(n){h("error: cannot register WebGL backend:",n);return}try{A.getKernelsForBackend("webgl").forEach(r=>{let s={...r,backendName:U.name};A.registerKernel(s)})}catch(n){h("error: cannot update WebGL backend registration:",n);return}let o=A.backend().getGPGPUContext?A.backend().getGPGPUContext().gl:null;if(o)h(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{h("error: no current gl context:",o,U.gl);return}try{A.ENV.set("WEBGL_VERSION",2)}catch(n){h("error: cannot set WebGL backend flags:",n);return}Jr(),h("backend registered:",U.name)}}function Yr(){if(!T.kernels.includes("mod")){let e={kernelName:"Mod",backendName:A.getBackend(),kernelFunc:t=>A.tidy(()=>A.sub(t.inputs.a,A.mul(A.div(t.inputs.a,t.inputs.b),t.inputs.b)))};A.registerKernel(e),T.kernels.push("mod")}if(!T.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:A.getBackend(),kernelFunc:t=>A.tidy(()=>A.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+A.mod(t.inputs.a,t.inputs.b))};A.registerKernel(e),T.kernels.push("floormod")}}async function Gt(e,t=!1){if(e.state="backend",t||T.initial||e.config.backend&&e.config.backend.length>0&&A.getBackend()!==e.config.backend){let o=g();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&h("running inside web worker"),T.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&h("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),T.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&h(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),T.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")h("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let r=await navigator.gpu.requestAdapter();e.config.debug&&h("enumerated webgpu adapter:",r)}e.config.backend==="humangl"&&await _o(e);let n=Object.keys(A.engine().registryFactory);if(e.config.debug&&h("available backends:",n),n.includes(e.config.backend)||(h(`error: backend ${e.config.backend} not found in registry`),e.config.backend=T.node?"tensorflow":"webgl",e.config.debug&&h(`override: setting backend ${e.config.backend}`)),e.config.debug&&h("setting backend:",e.config.backend),e.config.backend==="wasm"){if(e.config.debug&&h("wasm path:",e.config.wasmPath),typeof(A==null?void 0:A.setWasmPaths)!="undefined")await A.setWasmPaths(e.config.wasmPath,e.config.wasmPlatformFetch);else throw new Error("backend error: attempting to use wasm backend but wasm path is not set");let r=await A.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await A.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&h(`wasm execution: ${r?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),e.config.debug&&!r&&h("warning: wasm simd support is not enabled")}try{await A.setBackend(e.config.backend),await A.ready(),Z2()}catch(r){return h("error: cannot set backend:",e.config.backend,r),!1}}if(A.getBackend()==="humangl"&&(A.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),A.ENV.set("WEBGL_CPU_FORWARD",!0),A.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),A.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(h("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),A.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),A.backend().getGPGPUContext)){let n=await A.backend().getGPGPUContext().gl;e.config.debug&&h(`gl version:${n.getParameter(n.VERSION)} renderer:${n.getParameter(n.RENDERER)}`)}A.getBackend(),A.enableProdMode(),await A.ready(),e.performance.initBackend=Math.trunc(g()-o),e.config.backend=A.getBackend(),await T.updateBackend(),Yr()}return!0}function Et(e,t){for(let o of e){let n={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&h("kernelFunc",o,t.backend)}};A.registerKernel(n)}T.kernels=A.getKernelsForBackend(A.getBackend()).map(o=>o.kernelName.toLowerCase())}var tn={};ne(tn,{all:()=>p2,body:()=>Se,canvas:()=>m2,face:()=>je,gesture:()=>Oe,hand:()=>Ce,object:()=>We,options:()=>a0,person:()=>f2});var g0=e=>{if(!e)h("draw error: invalid canvas");else if(!e.getContext)h("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)h("draw error: cannot get canvas context");else return t}return null},ce=e=>Math.round(e*180/Math.PI),D0=(e,t)=>{if(!t.useDepth||typeof e=="undefined")return t.color;let o=Uint8ClampedArray.from([127+2*e,127-2*e,255]);return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${t.alpha})`};function X0(e,t,o,n,r){e.fillStyle=D0(n,r),e.beginPath(),e.arc(t,o,r.pointSize,0,2*Math.PI),e.fill()}function W0(e,t,o,n,r,s){if(e.beginPath(),e.lineWidth=s.lineWidth,s.useCurves){let a=(t+t+n)/2,i=(o+o+r)/2;e.ellipse(a,i,n/2,r/2,0,0,2*Math.PI)}else e.moveTo(t+s.roundRect,o),e.lineTo(t+n-s.roundRect,o),e.quadraticCurveTo(t+n,o,t+n,o+s.roundRect),e.lineTo(t+n,o+r-s.roundRect),e.quadraticCurveTo(t+n,o+r,t+n-s.roundRect,o+r),e.lineTo(t+s.roundRect,o+r),e.quadraticCurveTo(t,o+r,t,o+r-s.roundRect),e.lineTo(t,o+s.roundRect),e.quadraticCurveTo(t,o,t+s.roundRect,o),e.closePath();e.stroke()}function x2(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let n of t)e.strokeStyle=D0(n[2],o),e.lineTo(Math.trunc(n[0]),Math.trunc(n[1]));e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function en(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){x2(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let n=0;n0){let n=e.emotion.map(r=>`${Math.trunc(100*r.score)}% ${r.emotion}`);n.length>3&&(n.length=3),o.push(n.join(" "))}e.rotation&&e.rotation.angle&&e.rotation.gaze&&(e.rotation.angle.roll&&o.push(`roll: ${ce(e.rotation.angle.roll)}\xB0 yaw:${ce(e.rotation.angle.yaw)}\xB0 pitch:${ce(e.rotation.angle.pitch)}\xB0`),e.rotation.gaze.bearing&&o.push(`gaze: ${ce(e.rotation.gaze.bearing)}\xB0`)),o.length===0&&o.push("face"),t.fillStyle=H.color;for(let n=o.length-1;n>=0;n--){let r=Math.max(e.box[0],0),s=n*H.lineHeight+e.box[1];H.shadowColor&&H.shadowColor!==""&&(t.fillStyle=H.shadowColor,t.fillText(o[n],r+5,s+16)),t.fillStyle=H.labelColor,t.fillText(o[n],r+4,s+15)}}}function _r(e,t){if(e.annotations&&e.annotations.leftEyeIris&&e.annotations.leftEyeIris[0]){t.strokeStyle=H.useDepth?"rgba(255, 200, 255, 0.3)":H.color,t.beginPath();let o=Math.abs(e.annotations.leftEyeIris[3][0]-e.annotations.leftEyeIris[1][0])/2,n=Math.abs(e.annotations.leftEyeIris[4][1]-e.annotations.leftEyeIris[2][1])/2;t.ellipse(e.annotations.leftEyeIris[0][0],e.annotations.leftEyeIris[0][1],o,n,0,0,2*Math.PI),t.stroke(),H.fillPolygons&&(t.fillStyle=H.useDepth?"rgba(255, 255, 200, 0.3)":H.color,t.fill())}if(e.annotations&&e.annotations.rightEyeIris&&e.annotations.rightEyeIris[0]){t.strokeStyle=H.useDepth?"rgba(255, 200, 255, 0.3)":H.color,t.beginPath();let o=Math.abs(e.annotations.rightEyeIris[3][0]-e.annotations.rightEyeIris[1][0])/2,n=Math.abs(e.annotations.rightEyeIris[4][1]-e.annotations.rightEyeIris[2][1])/2;t.ellipse(e.annotations.rightEyeIris[0][0],e.annotations.rightEyeIris[0][1],o,n,0,0,2*Math.PI),t.stroke(),H.fillPolygons&&(t.fillStyle=H.useDepth?"rgba(255, 255, 200, 0.3)":H.color,t.fill())}}function $r(e,t){var o;if(H.drawGaze&&((o=e.rotation)==null?void 0:o.angle)&&typeof Path2D!="undefined"){t.strokeStyle="pink";let n=e.box[0]+e.box[2]/2-e.box[3]*ce(e.rotation.angle.yaw)/90,r=e.box[1]+e.box[3]/2+e.box[2]*ce(e.rotation.angle.pitch)/90,s=new Path2D(` M ${e.box[0]+e.box[2]/2} ${e.box[1]} C ${n} ${e.box[1]}, diff --git a/dist/human.esm.js b/dist/human.esm.js index 3282bfcb0..b67f2ca70 100644 --- a/dist/human.esm.js +++ b/dist/human.esm.js @@ -219,524 +219,530 @@ var config = { // dist/tfjs.esm.js var tfjs_esm_exports = {}; __export(tfjs_esm_exports, { - Abs: () => uo, - Acos: () => rl, - Acosh: () => al, - AdadeltaOptimizer: () => gb, - AdagradOptimizer: () => bb, - AdamOptimizer: () => yb, - AdamaxOptimizer: () => vb, + Abs: () => co, + Acos: () => al, + Acosh: () => il, + AdadeltaOptimizer: () => vb, + AdagradOptimizer: () => xb, + AdamOptimizer: () => wb, + AdamaxOptimizer: () => kb, Add: () => Sr, - AddN: () => Ia, - All: () => il, - Any: () => ol, - ArgMax: () => Sa, - ArgMin: () => ul, - Asin: () => ll, - Asinh: () => cl, - Atan: () => dl, - Atan2: () => hl, - Atanh: () => pl, + AddN: () => Sa, + All: () => ol, + Any: () => ul, + ArgMax: () => Ia, + ArgMin: () => ll, + Asin: () => cl, + Asinh: () => dl, + Atan: () => pl, + Atan2: () => fl, + Atanh: () => hl, AvgPool: () => Ca, - AvgPool3D: () => Kd, - AvgPool3DGrad: () => lg, - AvgPoolGrad: () => ug, - BackendWasm: () => Pde, + AvgPool3D: () => Qd, + AvgPool3DGrad: () => dg, + AvgPoolGrad: () => cg, + BackendWasm: () => Xde, BatchMatMul: () => Na, - BatchToSpaceND: () => lo, - Bincount: () => cg, - BroadcastArgs: () => dg, - BroadcastTo: () => O$, - Callback: () => FW, - CallbackList: () => YL, + BatchToSpaceND: () => po, + Bincount: () => pg, + BroadcastArgs: () => hg, + BroadcastTo: () => L$, + Callback: () => VW, + CallbackList: () => sB, Cast: () => Ta, Ceil: () => $a, - ClipByValue: () => Cr, - Complex: () => Xd, - ComplexAbs: () => Yd, - Concat: () => co, + ClipByValue: () => Ir, + Complex: () => Zd, + ComplexAbs: () => Jd, + Concat: () => ho, Conv2D: () => _a, - Conv2DBackpropFilter: () => pg, + Conv2DBackpropFilter: () => fg, Conv2DBackpropInput: () => Aa, - Conv3D: () => Qd, - Conv3DBackpropFilterV2: () => hg, - Conv3DBackpropInputV2: () => fg, + Conv3D: () => ep, + Conv3DBackpropFilterV2: () => mg, + Conv3DBackpropInputV2: () => gg, Cos: () => Ea, Cosh: () => Ra, - CropAndResize: () => ho, - Cumprod: () => po, + CropAndResize: () => mo, + Cumprod: () => fo, Cumsum: () => Da, - CustomCallback: () => JL, - DataStorage: () => Hd, - DenseBincount: () => mg, - DepthToSpace: () => fo, + CustomCallback: () => iB, + DataStorage: () => Kd, + DenseBincount: () => bg, + DepthToSpace: () => go, DepthwiseConv2dNative: () => Fa, - DepthwiseConv2dNativeBackpropFilter: () => gg, - DepthwiseConv2dNativeBackpropInput: () => bg, - Diag: () => yg, - Dilation2D: () => Zd, - Dilation2DBackpropFilter: () => Zf, - Dilation2DBackpropInput: () => Qf, - ENV: () => rk, - EarlyStopping: () => OW, - Einsum: () => Jd, + DepthwiseConv2dNativeBackpropFilter: () => yg, + DepthwiseConv2dNativeBackpropInput: () => vg, + Diag: () => xg, + Dilation2D: () => tp, + Dilation2DBackpropFilter: () => tm, + Dilation2DBackpropInput: () => em, + ENV: () => ok, + EarlyStopping: () => WW, + Einsum: () => np, Elu: () => Pa, - EluGrad: () => vg, - Environment: () => _$, - Equal: () => mo, - Erf: () => fl, + EluGrad: () => wg, + Environment: () => D$, + Equal: () => bo, + Erf: () => ml, Exp: () => za, - ExpandDims: () => go, - Expm1: () => bo, - FFT: () => xg, - Fill: () => ml, - FlipLeftRight: () => yo, + ExpandDims: () => yo, + Expm1: () => vo, + FFT: () => kg, + Fill: () => gl, + FlipLeftRight: () => xo, Floor: () => Ma, FloorDiv: () => La, - FromPixels: () => fd, + FromPixels: () => bd, FusedBatchNorm: () => Ba, FusedConv2D: () => ia, FusedDepthwiseConv2D: () => oa, - GPGPUContext: () => Xf, - GatherNd: () => xo, - GatherV2: () => vo, - GraphModel: () => B4, - Greater: () => wo, + GPGPUContext: () => Zf, + GatherNd: () => ko, + GatherV2: () => wo, + GraphModel: () => j4, + Greater: () => So, GreaterEqual: () => Va, - History: () => ZL, - IFFT: () => wg, + History: () => aB, + IFFT: () => Sg, Identity: () => Wa, - Imag: () => ep, + Imag: () => sp, InputSpec: () => Dt, - IsFinite: () => gl, - IsInf: () => bl, - IsNan: () => yl, - KernelBackend: () => sl, - LRN: () => np, - LRNGrad: () => Ig, - LayerVariable: () => dz, - LayersModel: () => hr, + IsFinite: () => bl, + IsInf: () => yl, + IsNan: () => vl, + KernelBackend: () => rl, + LRN: () => ap, + LRNGrad: () => Cg, + LayerVariable: () => yz, + LayersModel: () => dr, LeakyRelu: () => Ua, - Less: () => ko, - LessEqual: () => Io, - LinSpace: () => kg, + Less: () => Io, + LessEqual: () => Co, + LinSpace: () => Ig, Log: () => Ga, - Log1p: () => vl, - LogSoftmax: () => P$, - LogicalAnd: () => So, - LogicalNot: () => xl, - LogicalOr: () => tp, - MathBackendCPU: () => HS, - MathBackendWebGL: () => G1, + Log1p: () => xl, + LogSoftmax: () => B$, + LogicalAnd: () => No, + LogicalNot: () => wl, + LogicalOr: () => rp, + LowerBound: () => tpe, + MathBackendCPU: () => X0, + MathBackendWebGL: () => K1, Max: () => Ha, MaxPool: () => ja, - MaxPool3D: () => sp, - MaxPool3DGrad: () => Cg, - MaxPoolGrad: () => Sg, - MaxPoolWithArgmax: () => Ng, + MaxPool3D: () => ip, + MaxPool3DGrad: () => Tg, + MaxPoolGrad: () => Ng, + MaxPoolWithArgmax: () => $g, Maximum: () => qa, Mean: () => Ka, Min: () => Xa, Minimum: () => Ya, MirrorPad: () => Qa, - Mod: () => wl, - MomentumOptimizer: () => xb, - Multinomial: () => Tg, + Mod: () => kl, + MomentumOptimizer: () => Sb, + Multinomial: () => _g, Multiply: () => Za, - Neg: () => Co, - NonMaxSuppressionV3: () => To, - NonMaxSuppressionV4: () => kl, - NonMaxSuppressionV5: () => $o, - NotEqual: () => No, - OP_SCOPE_SUFFIX: () => f_, - OneHot: () => Ao, - OnesLike: () => _o, - Optimizer: () => Ar, + Neg: () => To, + NonMaxSuppressionV3: () => _o, + NonMaxSuppressionV4: () => Sl, + NonMaxSuppressionV5: () => Ao, + NotEqual: () => $o, + OP_SCOPE_SUFFIX: () => y_, + OneHot: () => Ro, + OnesLike: () => Eo, + Optimizer: () => _r, OptimizerConstructors: () => Ur, - Pack: () => Eo, + Pack: () => Do, PadV2: () => Ja, - Pool: () => Wde, + Pool: () => npe, Pow: () => ei, Prelu: () => ti, Prod: () => ni, - RMSPropOptimizer: () => wb, - RNN: () => Er, + RMSPropOptimizer: () => Ib, + RNN: () => Ar, Range: () => Il, - Rank: () => a_, - Real: () => rp, + Rank: () => l_, + Real: () => op, RealDiv: () => Oa, - Reciprocal: () => Sl, - Reduction: () => dO, + Reciprocal: () => Cl, + Reduction: () => yO, Relu: () => si, Relu6: () => ai, - Reshape: () => Ro, + Reshape: () => Fo, ResizeBilinear: () => ri, - ResizeBilinearGrad: () => _g, - ResizeNearestNeighbor: () => Cl, - ResizeNearestNeighborGrad: () => $g, - Reverse: () => Do, - RotateWithOffset: () => jo, - Round: () => Fo, + ResizeBilinearGrad: () => Eg, + ResizeNearestNeighbor: () => Nl, + ResizeNearestNeighborGrad: () => Ag, + Reverse: () => Oo, + RotateWithOffset: () => Xo, + Round: () => Po, Rsqrt: () => ii, - SGDOptimizer: () => Cp, - ScatterNd: () => Oo, - Select: () => Po, - Selu: () => Nl, - Sequential: () => Hb, + SGDOptimizer: () => $p, + ScatterNd: () => zo, + SearchSorted: () => Rg, + Select: () => Mo, + Selu: () => Tl, + Sequential: () => Kb, Sigmoid: () => ui, - Sign: () => Tl, + Sign: () => $l, Sin: () => oi, - Sinh: () => Mo, - Slice: () => zo, + Sinh: () => Bo, + Slice: () => Lo, Softmax: () => di, - Softplus: () => $l, - SpaceToBatchND: () => Lo, - SparseFillEmptyRows: () => ap, - SparseReshape: () => _l, - SparseSegmentMean: () => ip, - SparseSegmentSum: () => op, - SparseToDense: () => up, - SplitV: () => Bo, + Softplus: () => _l, + SpaceToBatchND: () => Vo, + SparseFillEmptyRows: () => up, + SparseReshape: () => Al, + SparseSegmentMean: () => lp, + SparseSegmentSum: () => cp, + SparseToDense: () => dp, + SplitV: () => Wo, Sqrt: () => li, - Square: () => Al, + Square: () => El, SquaredDifference: () => pi, Step: () => gi, - StridedSlice: () => Vo, - StringNGrams: () => lp, - StringSplit: () => Ag, - StringToHashBucketFast: () => Eg, + StridedSlice: () => Uo, + StringNGrams: () => pp, + StringSplit: () => Dg, + StringToHashBucketFast: () => Fg, Sub: () => hi, Sum: () => ci, SymbolicTensor: () => $s, - Tan: () => Wo, + Tan: () => Go, Tanh: () => fi, Tensor: () => et, - TensorBuffer: () => Vt, - Tile: () => Nr, - TopK: () => Uo, - Transform: () => Go, + TensorBuffer: () => Wt, + Tile: () => Cr, + TopK: () => Ho, + Transform: () => qo, Transpose: () => mi, - Unique: () => Rg, - Unpack: () => Ho, - UnsortedSegmentSum: () => cp, - Variable: () => gd, - ZerosLike: () => qo, + Unique: () => Og, + Unpack: () => jo, + UnsortedSegmentSum: () => hp, + UpperBound: () => spe, + Variable: () => vd, + ZerosLike: () => Ko, _FusedMatMul: () => aa, - abs: () => Mt, - acos: () => XA, - acosh: () => QA, + abs: () => Lt, + acos: () => JA, + acosh: () => tE, add: () => ie, - addN: () => JA, - all: () => Qk, - any: () => hm, - argMax: () => qu, - argMin: () => rE, - asin: () => iE, - asinh: () => uE, - atan: () => cE, - atan2: () => pE, - atanh: () => fE, - avgPool: () => qg, - avgPool3d: () => tI, - backend: () => WA, + addN: () => sE, + all: () => eS, + any: () => gm, + argMax: () => ju, + argMin: () => uE, + asin: () => cE, + asinh: () => pE, + atan: () => fE, + atan2: () => gE, + atanh: () => yE, + avgPool: () => Xg, + avgPool3d: () => rS, + backend: () => qA, backend_util: () => C, - basicLSTMCell: () => ipe, - batchNorm: () => Ku, - batchNorm2d: () => DE, - batchNorm3d: () => OE, - batchNorm4d: () => zE, - batchToSpaceND: () => jg, - bincount: () => nI, - booleanMaskAsync: () => Fpe, - broadcastArgs: () => BE, - broadcastTo: () => nd, - broadcast_util: () => Ko, - browser: () => Ek, + basicLSTMCell: () => wpe, + batchNorm: () => Xu, + batchNorm2d: () => zE, + batchNorm3d: () => LE, + batchNorm4d: () => VE, + batchToSpaceND: () => Yg, + bincount: () => aS, + booleanMaskAsync: () => Xpe, + broadcastArgs: () => GE, + broadcastTo: () => rd, + broadcast_util: () => bi, + browser: () => Fk, buffer: () => De, - callbacks: () => Gpe, - cast: () => ce, - ceil: () => UE, + callbacks: () => ahe, + cast: () => le, + ceil: () => jE, clipByValue: () => Vn, - clone: () => cr, + clone: () => ur, complex: () => ua, concat: () => Ft, - concat1d: () => qE, - concat2d: () => KE, - concat3d: () => YE, - concat4d: () => ZE, - constraints: () => TL, - conv1d: () => sI, + concat1d: () => YE, + concat2d: () => ZE, + concat3d: () => eR, + concat4d: () => nR, + constraints: () => FL, + conv1d: () => iS, conv2d: () => da, - conv2dTranspose: () => rI, - conv3d: () => aI, - conv3dTranspose: () => iR, - copyRegisteredKernels: () => Hde, - cos: () => Xg, - cosh: () => oI, - cosineWindow: () => RI, - cumprod: () => mm, - cumsum: () => uI, - customGrad: () => js, - data: () => V4, - denseBincount: () => pR, - deprecationWarn: () => Xk, - depthToSpace: () => fR, - depthwiseConv2d: () => mp, - deregisterOp: () => qpe, - device_util: () => hp, - diag: () => ope, - dilation2d: () => yR, - disableDeprecationWarnings: () => Xde, + conv2dTranspose: () => oS, + conv3d: () => uS, + conv3dTranspose: () => cR, + copyRegisteredKernels: () => ipe, + cos: () => Zg, + cosh: () => cS, + cosineWindow: () => PS, + cumprod: () => ym, + cumsum: () => dS, + customGrad: () => qs, + data: () => K4, + denseBincount: () => gR, + deprecationWarn: () => Zk, + depthToSpace: () => yR, + depthwiseConv2d: () => yp, + deregisterOp: () => ohe, + device_util: () => gp, + diag: () => kpe, + dilation2d: () => kR, + disableDeprecationWarnings: () => cpe, dispose: () => Re, - disposeVariables: () => Yde, + disposeVariables: () => dpe, div: () => xe, - divNoNan: () => IR, - dot: () => upe, - dropout: () => iF, - einsum: () => NR, - elu: () => gp, - enableDebugMode: () => Kde, - enableProdMode: () => jde, - enclosingPowerOfTwo: () => oF, - engine: () => Ss, - env: () => X, + divNoNan: () => TR, + dot: () => Spe, + dropout: () => hF, + einsum: () => AR, + elu: () => vp, + enableDebugMode: () => lpe, + enableProdMode: () => upe, + enclosingPowerOfTwo: () => fF, + engine: () => ds, + env: () => K, equal: () => Xn, - erf: () => _R, + erf: () => DR, exp: () => Yn, expandDims: () => Pn, - expm1: () => DR, - eye: () => lI, - fft: () => db, - fill: () => Pl, - findBackend: () => spe, - findBackendFactory: () => rpe, - floor: () => bp, - floorDiv: () => Yk, - forceHalfFloat: () => JX, + expm1: () => zR, + eye: () => pS, + fft: () => fb, + fill: () => zl, + findBackend: () => ype, + findBackendFactory: () => vpe, + floor: () => xp, + floorDiv: () => Jk, + forceHalfFloat: () => d8, fused: () => fa, - gather: () => Xu, - gatherND: () => sF, - gather_util: () => Dk, - getBackend: () => tpe, - getGradient: () => rx, - getKernel: () => Jf, - getKernelsForBackend: () => em, - getThreadsCount: () => nhe, - gpgpu_util: () => VK, - grad: () => dpe, - grads: () => ppe, + gather: () => Yu, + gatherND: () => cF, + gather_util: () => Pk, + getBackend: () => gpe, + getGradient: () => ox, + getKernel: () => nm, + getKernelsForBackend: () => sm, + getThreadsCount: () => bhe, + gpgpu_util: () => JK, + grad: () => Npe, + grads: () => Tpe, greater: () => Un, - greaterEqual: () => Xo, - ifft: () => Id, - imag: () => Yg, + greaterEqual: () => Yo, + ifft: () => Nd, + imag: () => Jg, image: () => jn, - inTopKAsync: () => Ppe, - initializers: () => RL, - input: () => GB, + inTopKAsync: () => Qpe, + initializers: () => LL, + input: () => QB, io: () => An, - irfft: () => CI, - isFinite: () => lpe, - isInf: () => cpe, - isNaN: () => GR, - keep: () => Ht, - kernel_impls: () => xs, - layers: () => KL, - leakyRelu: () => Qg, - less: () => cI, - lessEqual: () => Yo, - linalg: () => HO, - linspace: () => KR, - loadGraphModel: () => jpe, - loadLayersModel: () => Wpe, - localResponseNormalization: () => YR, + irfft: () => _S, + isFinite: () => Ipe, + isInf: () => Cpe, + isNaN: () => KR, + keep: () => qt, + kernel_impls: () => ws, + layers: () => tB, + leakyRelu: () => eb, + less: () => hS, + lessEqual: () => Qo, + linalg: () => ZO, + linspace: () => ZR, + loadGraphModel: () => uhe, + loadLayersModel: () => she, + localResponseNormalization: () => eD, log: () => Qn, - log1p: () => Zg, - logSigmoid: () => mpe, - logSoftmax: () => dI, - logSumExp: () => cD, + log1p: () => tb, + logSigmoid: () => Ape, + logSoftmax: () => fS, + logSumExp: () => fD, logicalAnd: () => Ds, - logicalNot: () => tb, - logicalOr: () => mI, - logicalXor: () => gpe, - losses: () => Lpe, - matMul: () => We, - math: () => dA, + logicalNot: () => rb, + logicalOr: () => yS, + logicalXor: () => Epe, + losses: () => ehe, + lowerBound: () => xD, + matMul: () => Ve, + math: () => mA, max: () => As, - maxPool: () => nb, - maxPool3d: () => gI, - maxPoolWithArgmax: () => yD, - maximum: () => _r, - mean: () => St, - memory: () => pm, - meshgrid: () => bpe, - metrics: () => hW, - min: () => gm, - minimum: () => vp, - mirrorPad: () => SD, - mod: () => ND, - model: () => Bpe, - models: () => _W, - moments: () => sb, - movingAverage: () => Ope, + maxPool: () => ab, + maxPool3d: () => xS, + maxPoolWithArgmax: () => ID, + maximum: () => $r, + mean: () => It, + memory: () => mm, + meshgrid: () => Rpe, + metrics: () => xW, + min: () => vm, + minimum: () => kp, + mirrorPad: () => AD, + mod: () => RD, + model: () => the, + models: () => PW, + moments: () => ib, + movingAverage: () => Ype, mul: () => V, - multiRNNCell: () => ype, - multinomial: () => ED, + multiRNNCell: () => Dpe, + multinomial: () => zD, neg: () => kt, - nextFrame: () => BI, - norm: () => AI, - notEqual: () => Yu, - oneHot: () => vd, + nextFrame: () => GS, + norm: () => FS, + notEqual: () => Qu, + oneHot: () => kd, ones: () => Mn, onesLike: () => Zn, op: () => L, - outerProduct: () => vpe, - pad: () => bi, - pad1d: () => xpe, - pad2d: () => wpe, - pad3d: () => kpe, - pad4d: () => Ipe, - pool: () => Spe, + outerProduct: () => Fpe, + pad: () => yi, + pad1d: () => Ope, + pad2d: () => Ppe, + pad3d: () => zpe, + pad4d: () => Mpe, + pool: () => Lpe, pow: () => ha, - prelu: () => ab, - print: () => K_, - prod: () => bI, - profile: () => Qde, - rand: () => Cpe, - randomGamma: () => Npe, - randomNormal: () => ZD, - randomUniform: () => Ml, - range: () => Qu, - ready: () => epe, - real: () => wd, - reciprocal: () => n3, - registerBackend: () => fp, - registerCallbackConstructor: () => Upe, - registerGradient: () => M$, - registerKernel: () => El, - registerOp: () => Hpe, - regularizers: () => AW, - relu: () => Ys, - relu6: () => yI, - removeBackend: () => npe, - reshape: () => G, + prelu: () => ub, + print: () => Z_, + prod: () => wS, + profile: () => ppe, + rand: () => Bpe, + randomGamma: () => Vpe, + randomNormal: () => r3, + randomUniform: () => Ll, + range: () => Zu, + ready: () => mpe, + real: () => Id, + reciprocal: () => u3, + registerBackend: () => bp, + registerCallbackConstructor: () => rhe, + registerGradient: () => W$, + registerKernel: () => Rl, + registerOp: () => ihe, + regularizers: () => zW, + relu: () => Xs, + relu6: () => kS, + removeBackend: () => bpe, + reshape: () => U, reverse: () => Jn, - reverse1d: () => Tpe, - reverse2d: () => $pe, - reverse3d: () => _pe, - reverse4d: () => Ape, - rfft: () => pb, - round: () => vI, - rsqrt: () => xI, + reverse1d: () => Wpe, + reverse2d: () => Upe, + reverse3d: () => Gpe, + reverse4d: () => Hpe, + rfft: () => mb, + round: () => SS, + rsqrt: () => IS, scalar: () => we, - scatterND: () => J3, - scatter_util: () => Ok, - selu: () => wI, - separableConv2d: () => f3, - sequential: () => Vpe, - serialization: () => ae, - setBackend: () => Jde, - setPlatform: () => ape, - setThreadsCount: () => the, - setWasmPath: () => Jpe, - setWasmPaths: () => ehe, - setWebGLContext: () => D5, - setdiff1dAsync: () => g3, - shared: () => ev, - sigmoid: () => qs, - sign: () => y3, - signal: () => Mpe, - sin: () => kI, - sinh: () => II, + scatterND: () => iF, + scatter_util: () => Mk, + searchSorted: () => vS, + selu: () => CS, + separableConv2d: () => x3, + sequential: () => nhe, + serialization: () => re, + setBackend: () => fpe, + setPlatform: () => xpe, + setThreadsCount: () => ghe, + setWasmPath: () => fhe, + setWasmPaths: () => mhe, + setWebGLContext: () => H5, + setdiff1dAsync: () => k3, + shared: () => sv, + sigmoid: () => Hs, + sign: () => I3, + signal: () => Jpe, + sin: () => NS, + sinh: () => TS, slice: () => qe, - slice1d: () => ub, - slice2d: () => SI, - slice3d: () => lb, - slice4d: () => kd, + slice1d: () => db, + slice2d: () => $S, + slice3d: () => pb, + slice4d: () => Cd, slice_util: () => wt, - softmax: () => cb, - softplus: () => zl, - spaceToBatchND: () => rb, - sparse: () => Wc, - sparseToDense: () => EI, - spectral: () => zpe, + softmax: () => hb, + softplus: () => Ml, + spaceToBatchND: () => ob, + sparse: () => Gc, + sparseToDense: () => OS, + spectral: () => Zpe, split: () => Bn, - sqrt: () => cn, + sqrt: () => dn, square: () => ct, - squaredDifference: () => NI, - squeeze: () => gr, + squaredDifference: () => AS, + squeeze: () => mr, stack: () => es, - step: () => xp, - stridedSlice: () => z3, - string: () => Bf, + step: () => Sp, + stridedSlice: () => U3, + string: () => Uf, sub: () => ge, sum: () => ve, - sumOutType: () => pp, - tan: () => L3, - tanh: () => ju, - tensor: () => fs, - tensor1d: () => Qt, - tensor2d: () => Yi, - tensor3d: () => bA, - tensor4d: () => Epe, - tensor5d: () => Rpe, - tensor6d: () => Dpe, + sumOutType: () => mp, + tan: () => H3, + tanh: () => Ku, + tensor: () => ms, + tensor1d: () => Zt, + tensor2d: () => Zi, + tensor3d: () => wA, + tensor4d: () => qpe, + tensor5d: () => jpe, + tensor6d: () => Kpe, tensor_util: () => _s, - test_util: () => FA, - tidy: () => j, - tile: () => ps, - time: () => Zde, - topk: () => V3, - train: () => Mi, + test_util: () => MA, + tidy: () => q, + tile: () => hs, + time: () => hpe, + topk: () => j3, + train: () => Bi, transpose: () => Ge, - truncatedNormal: () => hb, - unique: () => mx, - unregisterGradient: () => Gde, - unregisterKernel: () => Ude, - unsortedSegmentSum: () => H3, + truncatedNormal: () => gb, + unique: () => yx, + unregisterGradient: () => ape, + unregisterKernel: () => rpe, + unsortedSegmentSum: () => Q3, unstack: () => Fs, - upcastType: () => ln, + upcastType: () => cn, + upperBound: () => J3, util: () => w, - valueAndGrad: () => hpe, - valueAndGrads: () => fpe, - variable: () => j3, - variableGrads: () => JR, - version: () => rhe, - version_converter: () => Kpe, - version_core: () => qde, - version_cpu: () => Xpe, - version_layers: () => f0, - version_wasm: () => she, - version_webgl: () => Ype, - webgl: () => Qpe, - webgl_util: () => R5, - webgpu: () => yoe, + valueAndGrad: () => $pe, + valueAndGrads: () => _pe, + variable: () => eF, + variableGrads: () => sD, + version: () => vhe, + version_converter: () => lhe, + version_core: () => ope, + version_cpu: () => che, + version_layers: () => yI, + version_wasm: () => yhe, + version_webgl: () => dhe, + webgl: () => phe, + webgl_util: () => G5, + webgpu: () => Eoe, where: () => vn, - whereAsync: () => $I, + whereAsync: () => RS, zeros: () => $t, zerosLike: () => je }); -var GT = Object.create; -var Ud = Object.defineProperty; -var HT = Object.getOwnPropertyDescriptor; -var qw = Object.getOwnPropertyNames; -var qT = Object.getPrototypeOf; -var jT = Object.prototype.hasOwnProperty; -var KT = (e) => Ud(e, "__esModule", { value: true }); -var zt = (e, t) => function() { - return t || (0, e[qw(e)[0]])((t = { exports: {} }).exports, t), t.exports; +var KT = Object.create; +var qd = Object.defineProperty; +var XT = Object.getOwnPropertyDescriptor; +var Xw = Object.getOwnPropertyNames; +var YT = Object.getPrototypeOf; +var QT = Object.prototype.hasOwnProperty; +var ZT = (e) => qd(e, "__esModule", { value: true }); +var Mt = (e, t) => function() { + return t || (0, e[Xw(e)[0]])((t = { exports: {} }).exports, t), t.exports; }; var Ae = (e, t) => { for (var n in t) - Ud(e, n, { get: t[n], enumerable: true }); + qd(e, n, { get: t[n], enumerable: true }); }; -var XT = (e, t, n, s) => { +var JT = (e, t, n, s) => { if (t && typeof t == "object" || typeof t == "function") - for (let r of qw(t)) - !jT.call(e, r) && (n || r !== "default") && Ud(e, r, { get: () => t[r], enumerable: !(s = HT(t, r)) || s.enumerable }); + for (let r of Xw(t)) + !QT.call(e, r) && (n || r !== "default") && qd(e, r, { get: () => t[r], enumerable: !(s = XT(t, r)) || s.enumerable }); return e; }; -var wa = (e, t) => XT(KT(Ud(e != null ? GT(qT(e)) : {}, "default", !t && e && e.__esModule ? { get: () => e.default, enumerable: true } : { value: e, enumerable: true })), e); -var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { +var wa = (e, t) => JT(ZT(qd(e != null ? KT(YT(e)) : {}, "default", !t && e && e.__esModule ? { get: () => e.default, enumerable: true } : { value: e, enumerable: true })), e); +var e$ = Mt({ "src/node_modules/long/src/long.js"(e, t) { t.exports = s; var n = null; try { @@ -753,8 +759,8 @@ var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { s.isLong = r; var a = {}, i = {}; function o(F, T) { - var z, W, q; - return T ? (F >>>= 0, (q = 0 <= F && F < 256) && (W = i[F], W) ? W : (z = l(F, (F | 0) < 0 ? -1 : 0, true), q && (i[F] = z), z)) : (F |= 0, (q = -128 <= F && F < 128) && (W = a[F], W) ? W : (z = l(F, F < 0 ? -1 : 0, false), q && (a[F] = z), z)); + var z, W, j; + return T ? (F >>>= 0, (j = 0 <= F && F < 256) && (W = i[F], W) ? W : (z = l(F, (F | 0) < 0 ? -1 : 0, true), j && (i[F] = z), z)) : (F |= 0, (j = -128 <= F && F < 128) && (W = a[F], W) ? W : (z = l(F, F < 0 ? -1 : 0, false), j && (a[F] = z), z)); } s.fromInt = o; function u(F, T) { @@ -791,15 +797,15 @@ var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { throw Error("interior hyphen"); if (W === 0) return p(F.substring(1), T, z).neg(); - for (var q = u(c(z, 8)), K = v, Y = 0; Y < F.length; Y += 8) { + for (var j = u(c(z, 8)), X = v, Y = 0; Y < F.length; Y += 8) { var Z = Math.min(8, F.length - Y), te = parseInt(F.substring(Y, Y + Z), z); if (Z < 8) { - var ee = u(c(z, Z)); - K = K.mul(ee).add(u(te)); + var J = u(c(z, Z)); + X = X.mul(J).add(u(te)); } else - K = K.mul(q), K = K.add(u(te)); + X = X.mul(j), X = X.add(u(te)); } - return K.unsigned = T, K; + return X.unsigned = T, X; } s.fromString = p; function d(F, T) { @@ -812,8 +818,8 @@ var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { s.UZERO = x; var k = o(1); s.ONE = k; - var S = o(1, true); - s.UONE = S; + var I = o(1, true); + s.UONE = I; var $ = o(-1); s.NEG_ONE = $; var E = l(-1, 2147483647, false); @@ -834,12 +840,12 @@ var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { return "0"; if (this.isNegative()) if (this.eq(P)) { - var z = u(T), W = this.div(z), q = W.mul(z).sub(this); - return W.toString(T) + q.toInt().toString(T); + var z = u(T), W = this.div(z), j = W.mul(z).sub(this); + return W.toString(T) + j.toInt().toString(T); } else return "-" + this.neg().toString(T); - for (var K = u(c(T, 6), this.unsigned), Y = this, Z = ""; ; ) { - var te = Y.div(K), ee = Y.sub(te.mul(K)).toInt() >>> 0, se = ee.toString(T); + for (var X = u(c(T, 6), this.unsigned), Y = this, Z = ""; ; ) { + var te = Y.div(X), J = Y.sub(te.mul(X)).toInt() >>> 0, se = J.toString(T); if (Y = te, Y.isZero()) return se + Z; for (; se.length < 6; ) @@ -891,8 +897,8 @@ var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { return !this.unsigned && this.eq(P) ? P : this.not().add(k); }, R.neg = R.negate, R.add = function(T) { r(T) || (T = d(T)); - var z = this.high >>> 16, W = this.high & 65535, q = this.low >>> 16, K = this.low & 65535, Y = T.high >>> 16, Z = T.high & 65535, te = T.low >>> 16, ee = T.low & 65535, se = 0, ne = 0, oe = 0, re = 0; - return re += K + ee, oe += re >>> 16, re &= 65535, oe += q + te, ne += oe >>> 16, oe &= 65535, ne += W + Z, se += ne >>> 16, ne &= 65535, se += z + Y, se &= 65535, l(oe << 16 | re, se << 16 | ne, this.unsigned); + var z = this.high >>> 16, W = this.high & 65535, j = this.low >>> 16, X = this.low & 65535, Y = T.high >>> 16, Z = T.high & 65535, te = T.low >>> 16, J = T.low & 65535, se = 0, ne = 0, oe = 0, ae = 0; + return ae += X + J, oe += ae >>> 16, ae &= 65535, oe += j + te, ne += oe >>> 16, oe &= 65535, ne += W + Z, se += ne >>> 16, ne &= 65535, se += z + Y, se &= 65535, l(oe << 16 | ae, se << 16 | ne, this.unsigned); }, R.subtract = function(T) { return r(T) || (T = d(T)), this.add(T.neg()); }, R.sub = R.subtract, R.multiply = function(T) { @@ -914,8 +920,8 @@ var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { return this.mul(T.neg()).neg(); if (this.lt(y) && T.lt(y)) return u(this.toNumber() * T.toNumber(), this.unsigned); - var W = this.high >>> 16, q = this.high & 65535, K = this.low >>> 16, Y = this.low & 65535, Z = T.high >>> 16, te = T.high & 65535, ee = T.low >>> 16, se = T.low & 65535, ne = 0, oe = 0, re = 0, le = 0; - return le += Y * se, re += le >>> 16, le &= 65535, re += K * se, oe += re >>> 16, re &= 65535, re += Y * ee, oe += re >>> 16, re &= 65535, oe += q * se, ne += oe >>> 16, oe &= 65535, oe += K * ee, ne += oe >>> 16, oe &= 65535, oe += Y * te, ne += oe >>> 16, oe &= 65535, ne += W * se + q * ee + K * te + Y * Z, ne &= 65535, l(re << 16 | le, ne << 16 | oe, this.unsigned); + var W = this.high >>> 16, j = this.high & 65535, X = this.low >>> 16, Y = this.low & 65535, Z = T.high >>> 16, te = T.high & 65535, J = T.low >>> 16, se = T.low & 65535, ne = 0, oe = 0, ae = 0, de = 0; + return de += Y * se, ae += de >>> 16, de &= 65535, ae += X * se, oe += ae >>> 16, ae &= 65535, ae += Y * J, oe += ae >>> 16, ae &= 65535, oe += j * se, ne += oe >>> 16, oe &= 65535, oe += X * J, ne += oe >>> 16, oe &= 65535, oe += Y * te, ne += oe >>> 16, oe &= 65535, ne += W * se + j * J + X * te + Y * Z, ne &= 65535, l(ae << 16 | de, ne << 16 | oe, this.unsigned); }, R.mul = R.multiply, R.divide = function(T) { if (r(T) || (T = d(T)), T.isZero()) throw Error("division by zero"); @@ -927,13 +933,13 @@ var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { } if (this.isZero()) return this.unsigned ? x : v; - var W, q, K; + var W, j, X; if (this.unsigned) { if (T.unsigned || (T = T.toUnsigned()), T.gt(this)) return x; if (T.gt(this.shru(1))) - return S; - K = x; + return I; + X = x; } else { if (this.eq(P)) { if (T.eq(k) || T.eq($)) @@ -941,22 +947,22 @@ var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { if (T.eq(P)) return k; var Y = this.shr(1); - return W = Y.div(T).shl(1), W.eq(v) ? T.isNegative() ? k : $ : (q = this.sub(T.mul(W)), K = W.add(q.div(T)), K); + return W = Y.div(T).shl(1), W.eq(v) ? T.isNegative() ? k : $ : (j = this.sub(T.mul(W)), X = W.add(j.div(T)), X); } else if (T.eq(P)) return this.unsigned ? x : v; if (this.isNegative()) return T.isNegative() ? this.neg().div(T.neg()) : this.neg().div(T).neg(); if (T.isNegative()) return this.div(T.neg()).neg(); - K = v; + X = v; } - for (q = this; q.gte(T); ) { - W = Math.max(1, Math.floor(q.toNumber() / T.toNumber())); - for (var Z = Math.ceil(Math.log(W) / Math.LN2), te = Z <= 48 ? 1 : c(2, Z - 48), ee = u(W), se = ee.mul(T); se.isNegative() || se.gt(q); ) - W -= te, ee = u(W, this.unsigned), se = ee.mul(T); - ee.isZero() && (ee = k), K = K.add(ee), q = q.sub(se); + for (j = this; j.gte(T); ) { + W = Math.max(1, Math.floor(j.toNumber() / T.toNumber())); + for (var Z = Math.ceil(Math.log(W) / Math.LN2), te = Z <= 48 ? 1 : c(2, Z - 48), J = u(W), se = J.mul(T); se.isNegative() || se.gt(j); ) + W -= te, J = u(W, this.unsigned), se = J.mul(T); + J.isZero() && (J = k), X = X.add(J), j = j.sub(se); } - return K; + return X; }, R.div = R.divide, R.modulo = function(T) { if (r(T) || (T = d(T)), n) { var z = (this.unsigned ? n.rem_u : n.rem_s)(this.low, this.high, T.low, T.high); @@ -1004,11 +1010,11 @@ var YT = zt({ "src/node_modules/long/src/long.js"(e, t) { return new s(T[4] << 24 | T[5] << 16 | T[6] << 8 | T[7], T[0] << 24 | T[1] << 16 | T[2] << 8 | T[3], z); }; } }); -var QT = zt({ "(disabled):src/node_modules/node-fetch/browser.js"() { +var t$ = Mt({ "(disabled):src/node_modules/node-fetch/browser.js"() { } }); -var ZT = zt({ "(disabled):util"() { +var n$ = Mt({ "(disabled):util"() { } }); -var JT = zt({ "src/node_modules/seedrandom/lib/alea.js"(e, t) { +var s$ = Mt({ "src/node_modules/seedrandom/lib/alea.js"(e, t) { (function(n, s, r) { function a(l) { var c = this, p = u(); @@ -1047,7 +1053,7 @@ var JT = zt({ "src/node_modules/seedrandom/lib/alea.js"(e, t) { }) : this.alea = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); -var e$ = zt({ "src/node_modules/seedrandom/lib/xor128.js"(e, t) { +var r$ = Mt({ "src/node_modules/seedrandom/lib/xor128.js"(e, t) { (function(n, s, r) { function a(u) { var l = this, c = ""; @@ -1079,7 +1085,7 @@ var e$ = zt({ "src/node_modules/seedrandom/lib/xor128.js"(e, t) { }) : this.xor128 = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); -var t$ = zt({ "src/node_modules/seedrandom/lib/xorwow.js"(e, t) { +var a$ = Mt({ "src/node_modules/seedrandom/lib/xorwow.js"(e, t) { (function(n, s, r) { function a(u) { var l = this, c = ""; @@ -1111,7 +1117,7 @@ var t$ = zt({ "src/node_modules/seedrandom/lib/xorwow.js"(e, t) { }) : this.xorwow = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); -var n$ = zt({ "src/node_modules/seedrandom/lib/xorshift7.js"(e, t) { +var i$ = Mt({ "src/node_modules/seedrandom/lib/xorshift7.js"(e, t) { (function(n, s, r) { function a(u) { var l = this; @@ -1157,7 +1163,7 @@ var n$ = zt({ "src/node_modules/seedrandom/lib/xorshift7.js"(e, t) { }) : this.xorshift7 = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); -var s$ = zt({ "src/node_modules/seedrandom/lib/xor4096.js"(e, t) { +var o$ = Mt({ "src/node_modules/seedrandom/lib/xor4096.js"(e, t) { (function(n, s, r) { function a(u) { var l = this; @@ -1197,7 +1203,7 @@ var s$ = zt({ "src/node_modules/seedrandom/lib/xor4096.js"(e, t) { }) : this.xor4096 = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); -var r$ = zt({ "src/node_modules/seedrandom/lib/tychei.js"(e, t) { +var u$ = Mt({ "src/node_modules/seedrandom/lib/tychei.js"(e, t) { (function(n, s, r) { function a(u) { var l = this, c = ""; @@ -1229,15 +1235,15 @@ var r$ = zt({ "src/node_modules/seedrandom/lib/tychei.js"(e, t) { }) : this.tychei = o; })(e, typeof t == "object" && t, typeof define == "function" && define); } }); -var a$ = zt({ "(disabled):crypto"() { +var l$ = Mt({ "(disabled):crypto"() { } }); -var i$ = zt({ "src/node_modules/seedrandom/seedrandom.js"(e, t) { +var c$ = Mt({ "src/node_modules/seedrandom/seedrandom.js"(e, t) { (function(n, s, r) { var a = 256, i = 6, o = 52, u = "random", l = r.pow(a, i), c = r.pow(2, o), p = c * 2, d = a - 1, h; - function f(k, S, $) { + function f(k, I, $) { var E = []; - S = S == true ? { entropy: true } : S || {}; - var A = y(b(S.entropy ? [k, x(s)] : k == null ? v() : k, 3), E), P = new m(E), R = function() { + I = I == true ? { entropy: true } : I || {}; + var A = y(b(I.entropy ? [k, x(s)] : k == null ? v() : k, 3), E), P = new m(E), R = function() { for (var F = P.g(i), T = l, z = 0; F < c; ) F = (F + z) * a, T *= a, z = P.g(1); for (; F >= p; ) @@ -1248,48 +1254,48 @@ var i$ = zt({ "src/node_modules/seedrandom/seedrandom.js"(e, t) { return P.g(4) | 0; }, R.quick = function() { return P.g(4) / 4294967296; - }, R.double = R, y(x(P.S), s), (S.pass || $ || function(F, T, z, W) { + }, R.double = R, y(x(P.S), s), (I.pass || $ || function(F, T, z, W) { return W && (W.S && g(W, P), F.state = function() { return g(P, {}); }), z ? (r[u] = F, T) : F; - })(R, A, "global" in S ? S.global : this == r, S.state); + })(R, A, "global" in I ? I.global : this == r, I.state); } function m(k) { - var S, $ = k.length, E = this, A = 0, P = E.i = E.j = 0, R = E.S = []; + var I, $ = k.length, E = this, A = 0, P = E.i = E.j = 0, R = E.S = []; for ($ || (k = [$++]); A < a; ) R[A] = A++; for (A = 0; A < a; A++) - R[A] = R[P = d & P + k[A % $] + (S = R[A])], R[P] = S; + R[A] = R[P = d & P + k[A % $] + (I = R[A])], R[P] = I; (E.g = function(F) { - for (var T, z = 0, W = E.i, q = E.j, K = E.S; F--; ) - T = K[W = d & W + 1], z = z * a + K[d & (K[W] = K[q = d & q + T]) + (K[q] = T)]; - return E.i = W, E.j = q, z; + for (var T, z = 0, W = E.i, j = E.j, X = E.S; F--; ) + T = X[W = d & W + 1], z = z * a + X[d & (X[W] = X[j = d & j + T]) + (X[j] = T)]; + return E.i = W, E.j = j, z; })(a); } - function g(k, S) { - return S.i = k.i, S.j = k.j, S.S = k.S.slice(), S; + function g(k, I) { + return I.i = k.i, I.j = k.j, I.S = k.S.slice(), I; } - function b(k, S) { + function b(k, I) { var $ = [], E = typeof k, A; - if (S && E == "object") + if (I && E == "object") for (A in k) try { - $.push(b(k[A], S - 1)); + $.push(b(k[A], I - 1)); } catch (P) { } return $.length ? $ : E == "string" ? k : k + "\0"; } - function y(k, S) { + function y(k, I) { for (var $ = k + "", E, A = 0; A < $.length; ) - S[d & A] = d & (E ^= S[d & A] * 19) + $.charCodeAt(A++); - return x(S); + I[d & A] = d & (E ^= I[d & A] * 19) + $.charCodeAt(A++); + return x(I); } function v() { try { var k; return h && (k = h.randomBytes) ? k = k(a) : (k = new Uint8Array(a), (n.crypto || n.msCrypto).getRandomValues(k)), x(k); } catch (E) { - var S = n.navigator, $ = S && S.plugins; + var I = n.navigator, $ = I && I.plugins; return [+new Date(), n, $, n.screen, x(s)]; } } @@ -1299,7 +1305,7 @@ var i$ = zt({ "src/node_modules/seedrandom/seedrandom.js"(e, t) { if (y(r.random(), s), typeof t == "object" && t.exports) { t.exports = f; try { - h = a$(); + h = l$(); } catch (k) { } } else @@ -1308,47 +1314,47 @@ var i$ = zt({ "src/node_modules/seedrandom/seedrandom.js"(e, t) { }) : r["seed" + u] = f; })(typeof self != "undefined" ? self : e, [], Math); } }); -var Gd = zt({ "src/node_modules/seedrandom/index.js"(e, t) { - var n = JT(), s = e$(), r = t$(), a = n$(), i = s$(), o = r$(), u = i$(); +var jd = Mt({ "src/node_modules/seedrandom/index.js"(e, t) { + var n = s$(), s = r$(), r = a$(), a = i$(), i = o$(), o = u$(), u = c$(); u.alea = n, u.xor128 = s, u.xorwow = r, u.xorshift7 = a, u.xor4096 = i, u.tychei = o, t.exports = u; } }); -var jw = zt({ "(disabled):src/node_modules/string_decoder/index.js"() { +var Yw = Mt({ "(disabled):src/node_modules/string_decoder/index.js"() { } }); -var sg = zt({ "(disabled):fs"() { +var ag = Mt({ "(disabled):fs"() { } }); -var dd = zt({ "(disabled):path"() { +var fd = Mt({ "(disabled):path"() { } }); -var o$ = zt({ "(disabled):worker_threads"() { +var d$ = Mt({ "(disabled):worker_threads"() { } }); -var u$ = zt({ "(disabled):perf_hooks"() { +var p$ = Mt({ "(disabled):perf_hooks"() { } }); -var l$ = zt({ "(disabled):os"() { +var h$ = Mt({ "(disabled):os"() { } }); -var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js"(e, t) { +var f$ = Mt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js"(e, t) { var n = (() => { var s = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (s = s || __filename), function(r) { r = r || {}; function a() { - return Ce.buffer != tn && rs(Ce.buffer), ic; + return Ce.buffer != nn && rs(Ce.buffer), oc; } function i() { - return Ce.buffer != tn && rs(Ce.buffer), oc; + return Ce.buffer != nn && rs(Ce.buffer), uc; } function o() { - return Ce.buffer != tn && rs(Ce.buffer), fu; + return Ce.buffer != nn && rs(Ce.buffer), mu; } function u() { - return Ce.buffer != tn && rs(Ce.buffer), uc; + return Ce.buffer != nn && rs(Ce.buffer), lc; } function l() { - return Ce.buffer != tn && rs(Ce.buffer), lc; + return Ce.buffer != nn && rs(Ce.buffer), cc; } function c() { - return Ce.buffer != tn && rs(Ce.buffer), cc; + return Ce.buffer != nn && rs(Ce.buffer), dc; } function p() { - return Ce.buffer != tn && rs(Ce.buffer), dc; + return Ce.buffer != nn && rs(Ce.buffer), pc; } var d = typeof r != "undefined" ? r : {}, h, f; d.ready = new Promise(function(N, D) { @@ -1358,7 +1364,7 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js typeof process != "undefined" && process.listeners && (m = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") }); var g = Object.assign({}, d), b = [], y = "./this.program", v = (N, D) => { throw D; - }, x = typeof window == "object", k = typeof importScripts == "function", S = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", $ = d.ENVIRONMENT_IS_PTHREAD || false, E = ""; + }, x = typeof window == "object", k = typeof importScripts == "function", I = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", $ = d.ENVIRONMENT_IS_PTHREAD || false, E = ""; function A(N) { return d.locateFile ? d.locateFile(N, E) : E + N; } @@ -1366,19 +1372,19 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js function z(N) { if (N instanceof Iu) return; - ee("exiting due to exception: " + N); + J("exiting due to exception: " + N); } - var W, q, K; - if (S) { - k ? E = dd().dirname(E) + "/" : E = __dirname + "/", K = () => { - q || (W = sg(), q = dd()); + var W, j, X; + if (I) { + k ? E = fd().dirname(E) + "/" : E = __dirname + "/", X = () => { + j || (W = ag(), j = fd()); }, P = function(B, Q) { - return K(), B = q.normalize(B), W.readFileSync(B, Q ? void 0 : "utf8"); + return X(), B = j.normalize(B), W.readFileSync(B, Q ? void 0 : "utf8"); }, F = (D) => { var B = P(D, true); return B.buffer || (B = new Uint8Array(B)), B; }, R = (D, B, Q) => { - K(), D = q.normalize(D), W.readFile(D, function(ue, pe) { + X(), D = j.normalize(D), W.readFile(D, function(ue, pe) { ue ? Q(ue) : B(pe.buffer); }); }, process.argv.length > 1 && (y = process.argv[1].replace(/\\/g, "/")), b = process.argv.slice(2), process.on("uncaughtException", function(D) { @@ -1395,13 +1401,13 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js }; let N; try { - N = o$(); + N = d$(); } catch (D) { throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'), D; } global.Worker = N.Worker; } else - (x || k) && (k ? E = self.location.href : typeof document != "undefined" && document.currentScript && (E = document.currentScript.src), typeof s != "undefined" && s && (E = s), E.indexOf("blob:") !== 0 ? E = E.substr(0, E.replace(/[?#].*/, "").lastIndexOf("/") + 1) : E = "", S || (P = (N) => { + (x || k) && (k ? E = self.location.href : typeof document != "undefined" && document.currentScript && (E = document.currentScript.src), typeof s != "undefined" && s && (E = s), E.indexOf("blob:") !== 0 ? E = E.substr(0, E.replace(/[?#].*/, "").lastIndexOf("/") + 1) : E = "", I || (P = (N) => { var D = new XMLHttpRequest(); return D.open("GET", N, false), D.send(null), D.responseText; }, k && (F = (N) => { @@ -1417,16 +1423,16 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js B(); }, Q.onerror = B, Q.send(null); }), T = (N) => document.title = N); - S && typeof performance == "undefined" && (global.performance = u$().performance); + I && typeof performance == "undefined" && (global.performance = p$().performance); var Y = console.log.bind(console), Z = console.warn.bind(console); - S && (K(), Y = (N) => W.writeSync(1, N + ` + I && (X(), Y = (N) => W.writeSync(1, N + ` `), Z = (N) => W.writeSync(2, N + ` `)); - var te = d.print || Y, ee = d.printErr || Z; + var te = d.print || Y, J = d.printErr || Z; Object.assign(d, g), g = null, d.arguments && (b = d.arguments), d.thisProgram && (y = d.thisProgram), d.quit && (v = d.quit); var se = 4; function ne(N) { - ne.shown || (ne.shown = {}), ne.shown[N] || (ne.shown[N] = 1, ee(N)); + ne.shown || (ne.shown = {}), ne.shown[N] || (ne.shown[N] = 1, J(N)); } function oe(N, D) { if (typeof WebAssembly.Function == "function") { @@ -1439,13 +1445,13 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js for (var ue = 0; ue < Te.length; ++ue) pe.push(bt[Te[ue]]); ye == "v" ? pe.push(0) : pe = pe.concat([1, bt[ye]]), pe[1] = pe.length - 2; - var us = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(pe, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), ls = new WebAssembly.Module(us), Bc = new WebAssembly.Instance(ls, { e: { f: N } }), Su = Bc.exports.f; - return Su; + var us = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(pe, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), ls = new WebAssembly.Module(us), Vc = new WebAssembly.Instance(ls, { e: { f: N } }), Cu = Vc.exports.f; + return Cu; } - var re = [], le; + var ae = [], de; function me() { - if (re.length) - return re.pop(); + if (ae.length) + return ae.pop(); try { Fn.grow(1); } catch (N) { @@ -1455,57 +1461,57 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js } function ke(N, D) { for (var B = N; B < N + D; B++) { - var Q = Ai(B); - Q && le.set(Q, B); + var Q = Ri(B); + Q && de.set(Q, B); } } - var Se = 0, Ee = (N) => { - Se = N; + var Ie = 0, Ee = (N) => { + Ie = N; }, Pe = Atomics.load, Xe = Atomics.store, Je = Atomics.compareExchange, Ye; d.wasmBinary && (Ye = d.wasmBinary); var tt = d.noExitRuntime || true; - typeof WebAssembly != "object" && Ti("no native wasm support detected"); - var Ce, ut, rt = false, Zt; + typeof WebAssembly != "object" && _i("no native wasm support detected"); + var Ce, ut, rt = false, Jt; function Nt(N, D) { - N || Ti(D); + N || _i(D); } - function Sn(N) { + function In(N) { var D = d["_" + N]; return D; } function Et(N, D, B, Q, ue) { var pe = { string: function(Tn) { - var zi = 0; + var Li = 0; if (Tn != null && Tn !== 0) { - var nx = (Tn.length << 2) + 1; - zi = Pi(nx), Ls(Tn, zi, nx); + var ax = (Tn.length << 2) + 1; + Li = Mi(ax), Ms(Tn, Li, ax); } - return zi; + return Li; }, array: function(Tn) { - var zi = Pi(Tn.length); - return Bs(Tn, zi), zi; + var Li = Mi(Tn.length); + return Ls(Tn, Li), Li; } }; function ye(Tn) { - return D === "string" ? en(Tn) : D === "boolean" ? Boolean(Tn) : Tn; + return D === "string" ? tn(Tn) : D === "boolean" ? Boolean(Tn) : Tn; } - var Te = Sn(N), bt = [], us = 0; + var Te = In(N), bt = [], us = 0; if (Q) for (var ls = 0; ls < Q.length; ls++) { - var Bc = pe[B[ls]]; - Bc ? (us === 0 && (us = Df()), bt[ls] = Bc(Q[ls])) : bt[ls] = Q[ls]; + var Vc = pe[B[ls]]; + Vc ? (us === 0 && (us = Pf()), bt[ls] = Vc(Q[ls])) : bt[ls] = Q[ls]; } - var Su = Te.apply(null, bt); - function UT(Tn) { - return us !== 0 && Pc(us), ye(Tn); + var Cu = Te.apply(null, bt); + function jT(Tn) { + return us !== 0 && zc(us), ye(Tn); } - return Su = UT(Su), Su; + return Cu = jT(Cu), Cu; } - function Jt(N, D, B, Q) { + function en(N, D, B, Q) { B = B || []; var ue = B.every(function(ye) { return ye === "number"; }), pe = D !== "string"; - return pe && ue && !Q ? Sn(N) : function() { + return pe && ue && !Q ? In(N) : function() { return Et(N, D, B, arguments, Q); }; } @@ -1514,12 +1520,12 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js var D = new TextDecoder(N); this.decode = (B) => (B.buffer instanceof SharedArrayBuffer && (B = new Uint8Array(B)), D.decode.call(D, B)); } - var Xt = typeof TextDecoder != "undefined" ? new Nn("utf8") : void 0; + var Yt = typeof TextDecoder != "undefined" ? new Nn("utf8") : void 0; function Dn(N, D, B) { for (var Q = D + B, ue = D; N[ue] && !(ue >= Q); ) ++ue; - if (ue - D > 16 && N.subarray && Xt) - return Xt.decode(N.subarray(D, ue)); + if (ue - D > 16 && N.subarray && Yt) + return Yt.decode(N.subarray(D, ue)); for (var pe = ""; D < ue; ) { var ye = N[D++]; if (!(ye & 128)) { @@ -1541,10 +1547,10 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js } return pe; } - function en(N, D) { + function tn(N, D) { return N ? Dn(i(), N, D) : ""; } - function Ms(N, D, B, Q) { + function zs(N, D, B, Q) { if (!(Q > 0)) return 0; for (var ue = B, pe = B + Q - 1, ye = 0; ye < N.length; ++ye) { @@ -1573,162 +1579,162 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js } return D[B] = 0, B - ue; } - function Ls(N, D, B) { - return Ms(N, i(), D, B); + function Ms(N, D, B) { + return zs(N, i(), D, B); } - function Si(N) { + function Ni(N) { for (var D = 0, B = 0; B < N.length; ++B) { var Q = N.charCodeAt(B); Q >= 55296 && Q <= 57343 && (Q = 65536 + ((Q & 1023) << 10) | N.charCodeAt(++B) & 1023), Q <= 127 ? ++D : Q <= 2047 ? D += 2 : Q <= 65535 ? D += 3 : D += 4; } return D; } - var er = typeof TextDecoder != "undefined" ? new Nn("utf-16le") : void 0; - function Bs(N, D) { + var Zs = typeof TextDecoder != "undefined" ? new Nn("utf-16le") : void 0; + function Ls(N, D) { a().set(N, D); } - function hu(N, D, B) { + function fu(N, D, B) { for (var Q = 0; Q < N.length; ++Q) a()[D++ >> 0] = N.charCodeAt(Q); B || (a()[D >> 0] = 0); } - function Ci(N, D) { + function Ti(N, D) { return N % D > 0 && (N += D - N % D), N; } - var tn, ic, oc, fu, uc, lc, Pv, cc, dc; - $ && (tn = d.buffer); + var nn, oc, uc, mu, lc, cc, Lv, dc, pc; + $ && (nn = d.buffer); function rs(N) { - tn = N, d.HEAP8 = ic = new Int8Array(N), d.HEAP16 = fu = new Int16Array(N), d.HEAP32 = lc = new Int32Array(N), d.HEAPU8 = oc = new Uint8Array(N), d.HEAPU16 = uc = new Uint16Array(N), d.HEAPU32 = Pv = new Uint32Array(N), d.HEAPF32 = cc = new Float32Array(N), d.HEAPF64 = dc = new Float64Array(N); + nn = N, d.HEAP8 = oc = new Int8Array(N), d.HEAP16 = mu = new Int16Array(N), d.HEAP32 = cc = new Int32Array(N), d.HEAPU8 = uc = new Uint8Array(N), d.HEAPU16 = lc = new Uint16Array(N), d.HEAPU32 = Lv = new Uint32Array(N), d.HEAPF32 = dc = new Float32Array(N), d.HEAPF64 = pc = new Float64Array(N); } - var pc = d.INITIAL_MEMORY || 16777216; + var hc = d.INITIAL_MEMORY || 16777216; if ($) - Ce = d.wasmMemory, tn = d.buffer; + Ce = d.wasmMemory, nn = d.buffer; else if (d.wasmMemory) Ce = d.wasmMemory; - else if (Ce = new WebAssembly.Memory({ initial: pc / 65536, maximum: 32768, shared: true }), !(Ce.buffer instanceof SharedArrayBuffer)) - throw ee("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"), S && console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"), Error("bad memory"); - Ce && (tn = Ce.buffer), pc = tn.byteLength, rs(tn); - var Fn, Ni = [], tr = [], sh = [], hc = [], Pr = false, rh = false, fc = 0; + else if (Ce = new WebAssembly.Memory({ initial: hc / 65536, maximum: 32768, shared: true }), !(Ce.buffer instanceof SharedArrayBuffer)) + throw J("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"), I && console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"), Error("bad memory"); + Ce && (nn = Ce.buffer), hc = nn.byteLength, rs(nn); + var Fn, $i = [], Js = [], ih = [], fc = [], Pr = false, oh = false, mc = 0; function zr() { - return tt || fc > 0; + return tt || mc > 0; } - function nn() { + function sn() { if (d.preRun) for (typeof d.preRun == "function" && (d.preRun = [d.preRun]); d.preRun.length; ) - zv(d.preRun.shift()); - vc(Ni); + Bv(d.preRun.shift()); + xc($i); } - function mu() { - Pr = true, !$ && vc(tr); + function gu() { + Pr = true, !$ && xc(Js); } - function ah() { - $ || (_e.terminateAllThreads(), rh = true); + function uh() { + $ || ($e.terminateAllThreads(), oh = true); } - function ih() { + function lh() { if (!$) { if (d.postRun) for (typeof d.postRun == "function" && (d.postRun = [d.postRun]); d.postRun.length; ) - gu(d.postRun.shift()); - vc(hc); + bu(d.postRun.shift()); + xc(fc); } } - function zv(N) { - Ni.unshift(N); - } - function Mv(N) { - tr.unshift(N); + function Bv(N) { + $i.unshift(N); } - function gu(N) { - hc.unshift(N); + function Vv(N) { + Js.unshift(N); } - var nr = 0, mc = null, as = null; function bu(N) { - nr++, d.monitorRunDependencies && d.monitorRunDependencies(nr); + fc.unshift(N); } - function Lv(N) { - if (nr--, d.monitorRunDependencies && d.monitorRunDependencies(nr), nr == 0 && (mc !== null && (clearInterval(mc), mc = null), as)) { + var er = 0, gc = null, as = null; + function yu(N) { + er++, d.monitorRunDependencies && d.monitorRunDependencies(er); + } + function Wv(N) { + if (er--, d.monitorRunDependencies && d.monitorRunDependencies(er), er == 0 && (gc !== null && (clearInterval(gc), gc = null), as)) { var D = as; as = null, D(); } } d.preloadedImages = {}, d.preloadedAudios = {}; - function Ti(N) { - $ ? postMessage({ cmd: "onAbort", arg: N }) : d.onAbort && d.onAbort(N), N = "Aborted(" + N + ")", ee(N), rt = true, Zt = 1, N += ". Build with -s ASSERTIONS=1 for more info."; + function _i(N) { + $ ? postMessage({ cmd: "onAbort", arg: N }) : d.onAbort && d.onAbort(N), N = "Aborted(" + N + ")", J(N), rt = true, Jt = 1, N += ". Build with -s ASSERTIONS=1 for more info."; var D = new WebAssembly.RuntimeError(N); throw f(D), D; } - var oh = "data:application/octet-stream;base64,"; - function gc(N) { - return N.startsWith(oh); - } + var ch = "data:application/octet-stream;base64,"; function bc(N) { - return N.startsWith("file://"); + return N.startsWith(ch); } - var sn; - sn = "tfjs-backend-wasm-threaded-simd.wasm", gc(sn) || (sn = A(sn)); function yc(N) { + return N.startsWith("file://"); + } + var rn; + rn = "tfjs-backend-wasm-threaded-simd.wasm", bc(rn) || (rn = A(rn)); + function vc(N) { try { - if (N == sn && Ye) + if (N == rn && Ye) return new Uint8Array(Ye); if (F) return F(N); throw "both async and sync fetching of the wasm failed"; } catch (D) { - Ti(D); + _i(D); } } - function $i() { + function Ai() { if (!Ye && (x || k)) { - if (typeof fetch == "function" && !bc(sn)) - return fetch(sn, { credentials: "same-origin" }).then(function(N) { + if (typeof fetch == "function" && !yc(rn)) + return fetch(rn, { credentials: "same-origin" }).then(function(N) { if (!N.ok) - throw "failed to load wasm binary file at '" + sn + "'"; + throw "failed to load wasm binary file at '" + rn + "'"; return N.arrayBuffer(); }).catch(function() { - return yc(sn); + return vc(rn); }); if (R) return new Promise(function(N, D) { - R(sn, function(B) { + R(rn, function(B) { N(new Uint8Array(B)); }, D); }); } return Promise.resolve().then(function() { - return yc(sn); + return vc(rn); }); } - function uh() { - var N = { env: Ec, wasi_snapshot_preview1: Ec }; + function dh() { + var N = { env: Rc, wasi_snapshot_preview1: Rc }; function D(ye, Te) { var bt = ye.exports; - if (d.asm = bt, mh(d.asm.emscripten_tls_init), Fn = d.asm.__indirect_function_table, Mv(d.asm.__wasm_call_ctors), ut = Te, !$) { - var us = _e.unusedWorkers.length; - _e.unusedWorkers.forEach(function(ls) { - _e.loadWasmModuleToWorker(ls, function() { - --us || Lv("wasm-instantiate"); + if (d.asm = bt, yh(d.asm.emscripten_tls_init), Fn = d.asm.__indirect_function_table, Vv(d.asm.__wasm_call_ctors), ut = Te, !$) { + var us = $e.unusedWorkers.length; + $e.unusedWorkers.forEach(function(ls) { + $e.loadWasmModuleToWorker(ls, function() { + --us || Wv("wasm-instantiate"); }); }); } } - $ || bu("wasm-instantiate"); + $ || yu("wasm-instantiate"); function B(ye) { D(ye.instance, ye.module); } function Q(ye) { - return $i().then(function(Te) { + return Ai().then(function(Te) { return WebAssembly.instantiate(Te, N); }).then(function(Te) { return Te; }).then(ye, function(Te) { - ee("failed to asynchronously prepare wasm: " + Te), Ti(Te); + J("failed to asynchronously prepare wasm: " + Te), _i(Te); }); } function ue() { - return !Ye && typeof WebAssembly.instantiateStreaming == "function" && !gc(sn) && !bc(sn) && typeof fetch == "function" ? fetch(sn, { credentials: "same-origin" }).then(function(ye) { + return !Ye && typeof WebAssembly.instantiateStreaming == "function" && !bc(rn) && !yc(rn) && typeof fetch == "function" ? fetch(rn, { credentials: "same-origin" }).then(function(ye) { var Te = WebAssembly.instantiateStreaming(ye, N); return Te.then(B, function(bt) { - return ee("wasm streaming compile failed: " + bt), ee("falling back to ArrayBuffer instantiation"), Q(B); + return J("wasm streaming compile failed: " + bt), J("falling back to ArrayBuffer instantiation"), Q(B); }); }) : Q(B); } @@ -1737,12 +1743,12 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js var pe = d.instantiateWasm(N, D); return pe; } catch (ye) { - return ee("Module.instantiateWasm callback failed with error: " + ye), false; + return J("Module.instantiateWasm callback failed with error: " + ye), false; } return ue().catch(f), {}; } - var Bv, Vv, lh = {}; - function vc(N) { + var Uv, Gv, ph = {}; + function xc(N) { for (; N.length > 0; ) { var D = N.shift(); if (typeof D == "function") { @@ -1750,95 +1756,95 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js continue; } var B = D.func; - typeof B == "number" ? D.arg === void 0 ? Ai(B)() : Ai(B)(D.arg) : B(D.arg === void 0 ? null : D.arg); + typeof B == "number" ? D.arg === void 0 ? Ri(B)() : Ri(B)(D.arg) : B(D.arg === void 0 ? null : D.arg); } } - function _i(N) { - var D = Df(), B = N(); - return Pc(D), B; + function Ei(N) { + var D = Pf(), B = N(); + return zc(D), B; } - function QN(N) { + function tT(N) { return N; } - function Wv(N) { + function Hv(N) { var D = /\b_Z[\w\d_]+/g; return N.replace(D, function(B) { var Q = B; return B === Q ? B : Q + " [" + B + "]"; }); } - function ch(N) { + function hh(N) { l()[N >> 2] = 0; - var D = _e.pthreads[N]; - delete _e.pthreads[N], D.worker.terminate(), Rf(N), _e.runningWorkers.splice(_e.runningWorkers.indexOf(D.worker), 1), D.worker.pthread = void 0; + var D = $e.pthreads[N]; + delete $e.pthreads[N], D.worker.terminate(), Of(N), $e.runningWorkers.splice($e.runningWorkers.indexOf(D.worker), 1), D.worker.pthread = void 0; } - function dh(N) { - var D = _e.pthreads[N]; + function fh(N) { + var D = $e.pthreads[N]; D.worker.postMessage({ cmd: "cancel" }); } - function xc(N) { - var D = _e.pthreads[N]; + function wc(N) { + var D = $e.pthreads[N]; if (D) { l()[N >> 2] = 0; var B = D.worker; - _e.returnWorkerToPool(B); + $e.returnWorkerToPool(B); } } - function wc(N) { - BT(N); + function kc(N) { + GT(N); } - function ph(N) { + function mh(N) { if (N instanceof Iu || N == "unwind") - return Zt; + return Jt; v(1, N); } - var _e = { unusedWorkers: [], runningWorkers: [], tlsInitFunctions: [], init: function() { - $ ? _e.initWorker() : _e.initMainThread(); + var $e = { unusedWorkers: [], runningWorkers: [], tlsInitFunctions: [], init: function() { + $ ? $e.initWorker() : $e.initMainThread(); }, initMainThread: function() { for (var N = 8, D = 0; D < N; ++D) - _e.allocateUnusedWorker(); + $e.allocateUnusedWorker(); }, initWorker: function() { tt = false; }, pthreads: {}, setExitStatus: function(N) { - Zt = N; + Jt = N; }, terminateAllThreads: function() { - for (var N in _e.pthreads) { - var D = _e.pthreads[N]; - D && D.worker && _e.returnWorkerToPool(D.worker); + for (var N in $e.pthreads) { + var D = $e.pthreads[N]; + D && D.worker && $e.returnWorkerToPool(D.worker); } - for (var B = 0; B < _e.unusedWorkers.length; ++B) { - var Q = _e.unusedWorkers[B]; + for (var B = 0; B < $e.unusedWorkers.length; ++B) { + var Q = $e.unusedWorkers[B]; Q.terminate(); } - _e.unusedWorkers = []; + $e.unusedWorkers = []; }, returnWorkerToPool: function(N) { - _e.runWithoutMainThreadQueuedCalls(function() { - delete _e.pthreads[N.pthread.threadInfoStruct], _e.unusedWorkers.push(N), _e.runningWorkers.splice(_e.runningWorkers.indexOf(N), 1), Rf(N.pthread.threadInfoStruct), N.pthread = void 0; + $e.runWithoutMainThreadQueuedCalls(function() { + delete $e.pthreads[N.pthread.threadInfoStruct], $e.unusedWorkers.push(N), $e.runningWorkers.splice($e.runningWorkers.indexOf(N), 1), Of(N.pthread.threadInfoStruct), N.pthread = void 0; }); }, runWithoutMainThreadQueuedCalls: function(N) { - l()[tx >> 2] = 0; + l()[rx >> 2] = 0; try { N(); } finally { - l()[tx >> 2] = 1; + l()[rx >> 2] = 1; } }, receiveObjectTransfer: function(N) { }, threadInit: function() { - for (var N in _e.tlsInitFunctions) - _e.tlsInitFunctions[N](); + for (var N in $e.tlsInitFunctions) + $e.tlsInitFunctions[N](); }, loadWasmModuleToWorker: function(N, D) { N.onmessage = (B) => { var Q = B.data, ue = Q.cmd; - if (N.pthread && (_e.currentProxiedOperationCallerThread = N.pthread.threadInfoStruct), Q.targetThread && Q.targetThread != Oc()) { - var pe = _e.pthreads[Q.targetThread]; - pe ? pe.worker.postMessage(Q, Q.transferList) : ee('Internal error! Worker sent a message "' + ue + '" to target pthread ' + Q.targetThread + ", but that thread no longer exists!"), _e.currentProxiedOperationCallerThread = void 0; + if (N.pthread && ($e.currentProxiedOperationCallerThread = N.pthread.threadInfoStruct), Q.targetThread && Q.targetThread != Pc()) { + var pe = $e.pthreads[Q.targetThread]; + pe ? pe.worker.postMessage(Q, Q.transferList) : J('Internal error! Worker sent a message "' + ue + '" to target pthread ' + Q.targetThread + ", but that thread no longer exists!"), $e.currentProxiedOperationCallerThread = void 0; return; } - ue === "processQueuedMainThreadWork" ? Yv() : ue === "spawnThread" ? Ic(Q) : ue === "cleanupThread" ? xc(Q.thread) : ue === "killThread" ? ch(Q.thread) : ue === "cancelThread" ? dh(Q.thread) : ue === "loaded" ? (N.loaded = true, D && D(N), N.runPthread && (N.runPthread(), delete N.runPthread)) : ue === "print" ? te("Thread " + Q.threadId + ": " + Q.text) : ue === "printErr" ? ee("Thread " + Q.threadId + ": " + Q.text) : ue === "alert" ? alert("Thread " + Q.threadId + ": " + Q.text) : Q.target === "setimmediate" ? N.postMessage(Q) : ue === "onAbort" ? d.onAbort && d.onAbort(Q.arg) : ee("worker sent an unknown command " + ue), _e.currentProxiedOperationCallerThread = void 0; + ue === "processQueuedMainThreadWork" ? Jv() : ue === "spawnThread" ? Ic(Q) : ue === "cleanupThread" ? wc(Q.thread) : ue === "killThread" ? hh(Q.thread) : ue === "cancelThread" ? fh(Q.thread) : ue === "loaded" ? (N.loaded = true, D && D(N), N.runPthread && (N.runPthread(), delete N.runPthread)) : ue === "print" ? te("Thread " + Q.threadId + ": " + Q.text) : ue === "printErr" ? J("Thread " + Q.threadId + ": " + Q.text) : ue === "alert" ? alert("Thread " + Q.threadId + ": " + Q.text) : Q.target === "setimmediate" ? N.postMessage(Q) : ue === "onAbort" ? d.onAbort && d.onAbort(Q.arg) : J("worker sent an unknown command " + ue), $e.currentProxiedOperationCallerThread = void 0; }, N.onerror = (B) => { var Q = "worker sent an error!"; - throw ee(Q + " " + B.filename + ":" + B.lineno + ": " + B.message), B; - }, S && (N.on("message", function(B) { + throw J(Q + " " + B.filename + ":" + B.lineno + ": " + B.message), B; + }, I && (N.on("message", function(B) { N.onmessage({ data: B }); }), N.on("error", function(B) { N.onerror(B); @@ -1846,34 +1852,34 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js })), N.postMessage({ cmd: "load", urlOrBlob: d.mainScriptUrlOrBlob || s, wasmMemory: Ce, wasmModule: ut }); }, allocateUnusedWorker: function() { var N = A("tfjs-backend-wasm-threaded-simd.worker.js"); - _e.unusedWorkers.push(new Worker(N)); + $e.unusedWorkers.push(new Worker(N)); }, getNewWorker: function() { - return _e.unusedWorkers.length == 0 && (_e.allocateUnusedWorker(), _e.loadWasmModuleToWorker(_e.unusedWorkers[0])), _e.unusedWorkers.pop(); + return $e.unusedWorkers.length == 0 && ($e.allocateUnusedWorker(), $e.loadWasmModuleToWorker($e.unusedWorkers[0])), $e.unusedWorkers.pop(); } }; - function hh() { - var N = Oc(), D = l()[N + 44 >> 2], B = l()[N + 48 >> 2], Q = D - B; - ex(D, Q), Pc(D); + function gh() { + var N = Pc(), D = l()[N + 44 >> 2], B = l()[N + 48 >> 2], Q = D - B; + sx(D, Q), zc(D); } - d.establishStackSpace = hh; - function kc(N) { + d.establishStackSpace = gh; + function Sc(N) { if ($) return Br(1, 0, N); try { - wc(N); + kc(N); } catch (D) { - ph(D); + mh(D); } } var Mr = []; - function Ai(N) { + function Ri(N) { var D = Mr[N]; return D || (N >= Mr.length && (Mr.length = N + 1), Mr[N] = D = Fn.get(N)), D; } - function fh(N, D) { - return Ai(N)(D); + function bh(N, D) { + return Ri(N)(D); } - d.invokeEntryPoint = fh; - function Uv() { + d.invokeEntryPoint = bh; + function qv() { var N = new Error(); if (!N.stack) { try { @@ -1886,140 +1892,140 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js } return N.stack.toString(); } - function mh(N, D, B) { - _e.tlsInitFunctions.push(N); + function yh(N, D, B) { + $e.tlsInitFunctions.push(N); } - function Gv(N, D) { + function jv(N, D) { Fn.set(N, D), Mr[N] = D; } var Lr; - S ? Lr = () => { + I ? Lr = () => { var N = process.hrtime(); return N[0] * 1e3 + N[1] / 1e6; } : $ ? Lr = () => performance.now() - d.__performance_now_clock_drift : Lr = () => performance.now(); - var gh = true; - function bh(N) { - return l()[Xv() >> 2] = N, N; + var vh = true; + function xh(N) { + return l()[Zv() >> 2] = N, N; } - function yh(N, D) { + function wh(N, D) { var B; if (N === 0) B = Date.now(); - else if ((N === 1 || N === 4) && gh) + else if ((N === 1 || N === 4) && vh) B = Lr(); else - return bh(28), -1; + return xh(28), -1; return l()[D >> 2] = B / 1e3 | 0, l()[D + 4 >> 2] = B % 1e3 * 1e3 * 1e3 | 0, 0; } - function vh(N, D) { - return yh(N, D); + function kh(N, D) { + return wh(N, D); } - function xh(N) { - Qv(N, !k, 1, !x), _e.threadInit(); + function Sh(N) { + ex(N, !k, 1, !x), $e.threadInit(); } - function wh(N) { - $ ? postMessage({ cmd: "cleanupThread", thread: N }) : xc(N); + function Ih(N) { + $ ? postMessage({ cmd: "cleanupThread", thread: N }) : wc(N); } function Ic(N) { - var D = _e.getNewWorker(); + var D = $e.getNewWorker(); if (!D) return 6; - _e.runningWorkers.push(D); - var B = _e.pthreads[N.pthread_ptr] = { worker: D, threadInfoStruct: N.pthread_ptr }; + $e.runningWorkers.push(D); + var B = $e.pthreads[N.pthread_ptr] = { worker: D, threadInfoStruct: N.pthread_ptr }; D.pthread = B; var Q = { cmd: "run", start_routine: N.startRoutine, arg: N.arg, threadInfoStruct: N.pthread_ptr }; return D.runPthread = () => { Q.time = performance.now(), D.postMessage(Q, N.transferList); }, D.loaded && (D.runPthread(), delete D.runPthread), 0; } - function kh(N, D, B, Q) { + function Ch(N, D, B, Q) { if (typeof SharedArrayBuffer == "undefined") - return ee("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6; + return J("Current environment does not support SharedArrayBuffer, pthreads are not available!"), 6; var ue = [], pe = 0; if ($ && (ue.length === 0 || pe)) - return Zv(687865856, N, D, B, Q); + return tx(687865856, N, D, B, Q); if (pe) return pe; var ye = { startRoutine: B, pthread_ptr: N, arg: Q, transferList: ue }; return $ ? (ye.cmd = "spawnThread", postMessage(ye, ue), 0) : Ic(ye); } - function Ih() { + function Nh() { return 2097152; } - function Sh(N, D) { + function Th(N, D) { if (N == D) postMessage({ cmd: "processQueuedMainThreadWork" }); else if ($) postMessage({ targetThread: N, cmd: "processThreadQueue" }); else { - var B = _e.pthreads[N], Q = B && B.worker; + var B = $e.pthreads[N], Q = B && B.worker; if (!Q) return; Q.postMessage({ cmd: "processThreadQueue" }); } return 1; } - function Ch() { - Ti(""); + function $h() { + _i(""); } - function Nh() { - S || k || ne("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"); + function _h() { + I || k || ne("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"); } - function Sc() { + function Cc() { return 2147483648; } - function Th(N, D, B) { + function Ah(N, D, B) { i().copyWithin(N, D, D + B); } - function $h() { - return S ? l$().cpus().length : navigator.hardwareConcurrency; + function Eh() { + return I ? h$().cpus().length : navigator.hardwareConcurrency; } function Br(N, D) { var B = arguments.length - 2, Q = arguments; - return _i(function() { - for (var ue = B, pe = Pi(ue * 8), ye = pe >> 3, Te = 0; Te < B; Te++) { + return Ei(function() { + for (var ue = B, pe = Mi(ue * 8), ye = pe >> 3, Te = 0; Te < B; Te++) { var bt = Q[2 + Te]; p()[ye + Te] = bt; } - return Jv(N, ue, pe, D); + return nx(N, ue, pe, D); }); } - var yu = []; - function _h(N, D, B) { - yu.length = D; + var vu = []; + function Rh(N, D, B) { + vu.length = D; for (var Q = B >> 3, ue = 0; ue < D; ue++) - yu[ue] = p()[Q + ue]; - var pe = N < 0, ye = pe ? lh[-N - 1] : Kh[N]; - return ye.apply(null, yu); + vu[ue] = p()[Q + ue]; + var pe = N < 0, ye = pe ? ph[-N - 1] : Qh[N]; + return ye.apply(null, vu); } - function Ah(N) { + function Dh(N) { try { - return Ce.grow(N - tn.byteLength + 65535 >>> 16), rs(Ce.buffer), 1; + return Ce.grow(N - nn.byteLength + 65535 >>> 16), rs(Ce.buffer), 1; } catch (D) { } } - function Eh(N) { + function Fh(N) { var D = i().length; if (N = N >>> 0, N <= D) return false; - var B = Sc(); + var B = Cc(); if (N > B) return false; for (var Q = 1; Q <= 4; Q *= 2) { var ue = D * (1 + 0.2 / Q); ue = Math.min(ue, N + 100663296); - var pe = Math.min(B, Ci(Math.max(N, ue), 65536)), ye = Ah(pe); + var pe = Math.min(B, Ti(Math.max(N, ue), 65536)), ye = Dh(pe); if (ye) return true; } return false; } - var Be = { inEventHandler: 0, removeAllEventListeners: function() { - for (var N = Be.eventHandlers.length - 1; N >= 0; --N) - Be._removeHandler(N); - Be.eventHandlers = [], Be.deferredCalls = []; + var Me = { inEventHandler: 0, removeAllEventListeners: function() { + for (var N = Me.eventHandlers.length - 1; N >= 0; --N) + Me._removeHandler(N); + Me.eventHandlers = [], Me.deferredCalls = []; }, registerRemoveEventListeners: function() { - Be.removeEventListenersRegistered || (sh.push(Be.removeAllEventListeners), Be.removeEventListenersRegistered = true); + Me.removeEventListenersRegistered || (ih.push(Me.removeAllEventListeners), Me.removeEventListenersRegistered = true); }, deferredCalls: [], deferCall: function(N, D, B) { function Q(ye, Te) { if (ye.length != Te.length) @@ -2029,51 +2035,51 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js return false; return true; } - for (var ue in Be.deferredCalls) { - var pe = Be.deferredCalls[ue]; + for (var ue in Me.deferredCalls) { + var pe = Me.deferredCalls[ue]; if (pe.targetFunction == N && Q(pe.argsList, B)) return; } - Be.deferredCalls.push({ targetFunction: N, precedence: D, argsList: B }), Be.deferredCalls.sort(function(ye, Te) { + Me.deferredCalls.push({ targetFunction: N, precedence: D, argsList: B }), Me.deferredCalls.sort(function(ye, Te) { return ye.precedence < Te.precedence; }); }, removeDeferredCalls: function(N) { - for (var D = 0; D < Be.deferredCalls.length; ++D) - Be.deferredCalls[D].targetFunction == N && (Be.deferredCalls.splice(D, 1), --D); + for (var D = 0; D < Me.deferredCalls.length; ++D) + Me.deferredCalls[D].targetFunction == N && (Me.deferredCalls.splice(D, 1), --D); }, canPerformEventHandlerRequests: function() { - return Be.inEventHandler && Be.currentEventHandler.allowsDeferredCalls; + return Me.inEventHandler && Me.currentEventHandler.allowsDeferredCalls; }, runDeferredCalls: function() { - if (!!Be.canPerformEventHandlerRequests()) - for (var N = 0; N < Be.deferredCalls.length; ++N) { - var D = Be.deferredCalls[N]; - Be.deferredCalls.splice(N, 1), --N, D.targetFunction.apply(null, D.argsList); + if (!!Me.canPerformEventHandlerRequests()) + for (var N = 0; N < Me.deferredCalls.length; ++N) { + var D = Me.deferredCalls[N]; + Me.deferredCalls.splice(N, 1), --N, D.targetFunction.apply(null, D.argsList); } }, eventHandlers: [], removeAllHandlersOnTarget: function(N, D) { - for (var B = 0; B < Be.eventHandlers.length; ++B) - Be.eventHandlers[B].target == N && (!D || D == Be.eventHandlers[B].eventTypeString) && Be._removeHandler(B--); + for (var B = 0; B < Me.eventHandlers.length; ++B) + Me.eventHandlers[B].target == N && (!D || D == Me.eventHandlers[B].eventTypeString) && Me._removeHandler(B--); }, _removeHandler: function(N) { - var D = Be.eventHandlers[N]; - D.target.removeEventListener(D.eventTypeString, D.eventListenerFunc, D.useCapture), Be.eventHandlers.splice(N, 1); + var D = Me.eventHandlers[N]; + D.target.removeEventListener(D.eventTypeString, D.eventListenerFunc, D.useCapture), Me.eventHandlers.splice(N, 1); }, registerOrRemoveHandler: function(N) { var D = function(ue) { - ++Be.inEventHandler, Be.currentEventHandler = N, Be.runDeferredCalls(), N.handlerFunc(ue), Be.runDeferredCalls(), --Be.inEventHandler; + ++Me.inEventHandler, Me.currentEventHandler = N, Me.runDeferredCalls(), N.handlerFunc(ue), Me.runDeferredCalls(), --Me.inEventHandler; }; if (N.callbackfunc) - N.eventListenerFunc = D, N.target.addEventListener(N.eventTypeString, D, N.useCapture), Be.eventHandlers.push(N), Be.registerRemoveEventListeners(); + N.eventListenerFunc = D, N.target.addEventListener(N.eventTypeString, D, N.useCapture), Me.eventHandlers.push(N), Me.registerRemoveEventListeners(); else - for (var B = 0; B < Be.eventHandlers.length; ++B) - Be.eventHandlers[B].target == N.target && Be.eventHandlers[B].eventTypeString == N.eventTypeString && Be._removeHandler(B--); + for (var B = 0; B < Me.eventHandlers.length; ++B) + Me.eventHandlers[B].target == N.target && Me.eventHandlers[B].eventTypeString == N.eventTypeString && Me._removeHandler(B--); }, queueEventHandlerOnThread_iiii: function(N, D, B, Q, ue) { - _i(function() { - var pe = Pi(12); - l()[pe >> 2] = B, l()[pe + 4 >> 2] = Q, l()[pe + 8 >> 2] = ue, Ef(N, 637534208, D, Q, pe); + Ei(function() { + var pe = Mi(12); + l()[pe >> 2] = B, l()[pe + 4 >> 2] = Q, l()[pe + 8 >> 2] = ue, Ff(N, 637534208, D, Q, pe); }); }, getTargetThreadForEventCallback: function(N) { switch (N) { case 1: return 0; case 2: - return _e.currentProxiedOperationCallerThread; + return $e.currentProxiedOperationCallerThread; default: return N; } @@ -2082,33 +2088,33 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js }, fullscreenEnabled: function() { return document.fullscreenEnabled || document.webkitFullscreenEnabled; } }; - function Rh(N) { - var D = Si(N) + 1, B = Af(D); - return Ls(N, B, D), B; - } - function Dh(N, D, B, Q) { - _i(function() { - var ue = Pi(12), pe = 0; - D && (pe = Rh(D)), l()[ue >> 2] = pe, l()[ue + 4 >> 2] = B, l()[ue + 8 >> 2] = Q, Ef(N, 657457152, 0, pe, ue); + function Oh(N) { + var D = Ni(N) + 1, B = Df(D); + return Ms(N, B, D), B; + } + function Ph(N, D, B, Q) { + Ei(function() { + var ue = Mi(12), pe = 0; + D && (pe = Oh(D)), l()[ue >> 2] = pe, l()[ue + 4 >> 2] = B, l()[ue + 8 >> 2] = Q, Ff(N, 657457152, 0, pe, ue); }); } - function Fh(N, D, B, Q) { - D = D ? en(D) : "", Dh(N, D, B, Q); + function zh(N, D, B, Q) { + D = D ? tn(D) : "", Ph(N, D, B, Q); } - function Oh(N) { - return N > 2 ? en(N) : N; + function Mh(N) { + return N > 2 ? tn(N) : N; } - var Ph = [0, typeof document != "undefined" ? document : 0, typeof window != "undefined" ? window : 0]; - function zh(N) { - N = Oh(N); - var D = Ph[N] || (typeof document != "undefined" ? document.querySelector(N) : void 0); + var Lh = [0, typeof document != "undefined" ? document : 0, typeof window != "undefined" ? window : 0]; + function Bh(N) { + N = Mh(N); + var D = Lh[N] || (typeof document != "undefined" ? document.querySelector(N) : void 0); return D; } - function vu(N) { - return zh(N); + function xu(N) { + return Bh(N); } - function Cc(N, D, B) { - var Q = vu(N); + function Nc(N, D, B) { + var Q = xu(N); if (!Q) return -4; if (Q.canvasSharedPtr && (l()[Q.canvasSharedPtr >> 2] = D, l()[Q.canvasSharedPtr + 4 >> 2] = B), Q.offscreenCanvas || !Q.controlTransferredOffscreen) { @@ -2121,22 +2127,22 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js Q.width = D, Q.height = B, ue && Q.GLctxObject.GLctx.viewport(0, 0, D, B); } else if (Q.canvasSharedPtr) { var ye = l()[Q.canvasSharedPtr + 8 >> 2]; - return Fh(ye, N, D, B), 1; + return zh(ye, N, D, B), 1; } else return -4; return 0; } - function Nc(N, D, B) { - return $ ? Br(2, 1, N, D, B) : Cc(N, D, B); + function Tc(N, D, B) { + return $ ? Br(2, 1, N, D, B) : Nc(N, D, B); } - function Mh(N, D, B) { - var Q = vu(N); - return Q ? Cc(N, D, B) : Nc(N, D, B); + function Vh(N, D, B) { + var Q = xu(N); + return Q ? Nc(N, D, B) : Tc(N, D, B); } - function Lh() { + function Wh() { throw "unwind"; } - function Bh(N) { + function Uh(N) { var D = N.getExtension("ANGLE_instanced_arrays"); if (D) return N.vertexAttribDivisor = function(B, Q) { @@ -2147,7 +2153,7 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js D.drawElementsInstancedANGLE(B, Q, ue, pe, ye); }, 1; } - function Vh(N) { + function Gh(N) { var D = N.getExtension("OES_vertex_array_object"); if (D) return N.createVertexArray = function() { @@ -2160,14 +2166,14 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js return D.isVertexArrayOES(B); }, 1; } - function Wh(N) { + function Hh(N) { var D = N.getExtension("WEBGL_draw_buffers"); if (D) return N.drawBuffers = function(B, Q) { D.drawBuffersWEBGL(B, Q); }, 1; } - function Uh(N) { + function qh(N) { return !!(N.multiDrawWebgl = N.getExtension("WEBGL_multi_draw")); } var gt = { counter: 1, buffers: [], programs: [], framebuffers: [], renderbuffers: [], textures: [], shaders: [], vaos: [], contexts: {}, offscreenCanvases: {}, queries: [], stringCache: {}, unpackAlignment: 4, recordError: function(D) { @@ -2179,7 +2185,7 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js }, getSource: function(N, D, B, Q) { for (var ue = "", pe = 0; pe < D; ++pe) { var ye = Q ? l()[Q + pe * 4 >> 2] : -1; - ue += en(l()[B + pe * 4 >> 2], ye < 0 ? void 0 : ye); + ue += tn(l()[B + pe * 4 >> 2], ye < 0 ? void 0 : ye); } return ue; }, createContext: function(N, D) { @@ -2193,171 +2199,171 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js var Q = gt.registerContext(B, D); return Q; }, registerContext: function(N, D) { - var B = Af(8); - l()[B + 4 >> 2] = Oc(); + var B = Df(8); + l()[B + 4 >> 2] = Pc(); var Q = { handle: B, attributes: D, version: D.majorVersion, GLctx: N }; return N.canvas && (N.canvas.GLctxObject = Q), gt.contexts[B] = Q, (typeof D.enableExtensionsByDefault == "undefined" || D.enableExtensionsByDefault) && gt.initExtensions(Q), B; }, makeContextCurrent: function(N) { - return gt.currentContext = gt.contexts[N], d.ctx = Ac = gt.currentContext && gt.currentContext.GLctx, !(N && !Ac); + return gt.currentContext = gt.contexts[N], d.ctx = Ec = gt.currentContext && gt.currentContext.GLctx, !(N && !Ec); }, getContext: function(N) { return gt.contexts[N]; }, deleteContext: function(N) { - gt.currentContext === gt.contexts[N] && (gt.currentContext = null), typeof Be == "object" && Be.removeAllHandlersOnTarget(gt.contexts[N].GLctx.canvas), gt.contexts[N] && gt.contexts[N].GLctx.canvas && (gt.contexts[N].GLctx.canvas.GLctxObject = void 0), Kv(gt.contexts[N].handle), gt.contexts[N] = null; + gt.currentContext === gt.contexts[N] && (gt.currentContext = null), typeof Me == "object" && Me.removeAllHandlersOnTarget(gt.contexts[N].GLctx.canvas), gt.contexts[N] && gt.contexts[N].GLctx.canvas && (gt.contexts[N].GLctx.canvas.GLctxObject = void 0), Qv(gt.contexts[N].handle), gt.contexts[N] = null; }, initExtensions: function(N) { if (N || (N = gt.currentContext), !N.initExtensionsDone) { N.initExtensionsDone = true; var D = N.GLctx; - Bh(D), Vh(D), Wh(D), D.disjointTimerQueryExt = D.getExtension("EXT_disjoint_timer_query"), Uh(D); + Uh(D), Gh(D), Hh(D), D.disjointTimerQueryExt = D.getExtension("EXT_disjoint_timer_query"), qh(D); var B = D.getSupportedExtensions() || []; B.forEach(function(Q) { !Q.includes("lose_context") && !Q.includes("debug") && D.getExtension(Q); }); } - } }, Gh = ["default", "low-power", "high-performance"]; - function Hh(N, D) { - var B = D >> 2, Q = l()[B + 6], ue = { alpha: !!l()[B + 0], depth: !!l()[B + 1], stencil: !!l()[B + 2], antialias: !!l()[B + 3], premultipliedAlpha: !!l()[B + 4], preserveDrawingBuffer: !!l()[B + 5], powerPreference: Gh[Q], failIfMajorPerformanceCaveat: !!l()[B + 7], majorVersion: l()[B + 8], minorVersion: l()[B + 9], enableExtensionsByDefault: l()[B + 10], explicitSwapControl: l()[B + 11], proxyContextToMainThread: l()[B + 12], renderViaOffscreenBackBuffer: l()[B + 13] }, pe = vu(N); + } }, jh = ["default", "low-power", "high-performance"]; + function Kh(N, D) { + var B = D >> 2, Q = l()[B + 6], ue = { alpha: !!l()[B + 0], depth: !!l()[B + 1], stencil: !!l()[B + 2], antialias: !!l()[B + 3], premultipliedAlpha: !!l()[B + 4], preserveDrawingBuffer: !!l()[B + 5], powerPreference: jh[Q], failIfMajorPerformanceCaveat: !!l()[B + 7], majorVersion: l()[B + 8], minorVersion: l()[B + 9], enableExtensionsByDefault: l()[B + 10], explicitSwapControl: l()[B + 11], proxyContextToMainThread: l()[B + 12], renderViaOffscreenBackBuffer: l()[B + 13] }, pe = xu(N); if (!pe || ue.explicitSwapControl) return 0; var ye = gt.createContext(pe, ue); return ye; } - function qh(N, D) { - return Hh(N, D); + function Xh(N, D) { + return Kh(N, D); } - var Ei = { mappings: {}, buffers: [null, [], []], printChar: function(N, D) { - var B = Ei.buffers[N]; - D === 0 || D === 10 ? ((N === 1 ? te : ee)(Dn(B, 0)), B.length = 0) : B.push(D); + var Di = { mappings: {}, buffers: [null, [], []], printChar: function(N, D) { + var B = Di.buffers[N]; + D === 0 || D === 10 ? ((N === 1 ? te : J)(Dn(B, 0)), B.length = 0) : B.push(D); }, varargs: void 0, get: function() { - Ei.varargs += 4; - var N = l()[Ei.varargs - 4 >> 2]; + Di.varargs += 4; + var N = l()[Di.varargs - 4 >> 2]; return N; }, getStr: function(N) { - var D = en(N); + var D = tn(N); return D; }, get64: function(N, D) { return N; } }; - function Tc(N) { + function $c(N) { return $ ? Br(3, 1, N) : 0; } - function $c(N, D, B, Q, ue) { + function _c(N, D, B, Q, ue) { if ($) return Br(4, 1, N, D, B, Q, ue); } - function _c(N, D, B, Q) { + function Ac(N, D, B, Q) { if ($) return Br(5, 1, N, D, B, Q); for (var ue = 0, pe = 0; pe < B; pe++) { var ye = l()[D >> 2], Te = l()[D + 4 >> 2]; D += 8; for (var bt = 0; bt < Te; bt++) - Ei.printChar(N, i()[ye + bt]); + Di.printChar(N, i()[ye + bt]); ue += Te; } return l()[Q >> 2] = ue, 0; } - function jh(N) { + function Yh(N) { Ee(N); } - _e.init(); - var Ac, Kh = [null, kc, Nc, Tc, $c, _c], Hv = false, Ec = { __clock_gettime: vh, __emscripten_init_main_thread_js: xh, __emscripten_thread_cleanup: wh, __pthread_create_js: kh, _emscripten_default_pthread_stack_size: Ih, _emscripten_notify_thread_queue: Sh, abort: Ch, emscripten_check_blocking_allowed: Nh, emscripten_get_heap_max: Sc, emscripten_get_now: Lr, emscripten_memcpy_big: Th, emscripten_num_logical_cores: $h, emscripten_receive_on_main_thread_js: _h, emscripten_resize_heap: Eh, emscripten_set_canvas_element_size: Mh, emscripten_unwind_to_js_event_loop: Lh, emscripten_webgl_create_context: qh, exit: wc, fd_close: Tc, fd_seek: $c, fd_write: _c, memory: Ce || d.wasmMemory, setTempRet0: jh }, qv = uh(), Xh = d.___wasm_call_ctors = function() { - return (Xh = d.___wasm_call_ctors = d.asm.__wasm_call_ctors).apply(null, arguments); - }, Yh = d._init = function() { - return (Yh = d._init = d.asm.init).apply(null, arguments); - }, Qh = d._init_with_threads_count = function() { - return (Qh = d._init_with_threads_count = d.asm.init_with_threads_count).apply(null, arguments); - }, Zh = d._get_threads_count = function() { - return (Zh = d._get_threads_count = d.asm.get_threads_count).apply(null, arguments); - }, Jh = d._register_tensor = function() { - return (Jh = d._register_tensor = d.asm.register_tensor).apply(null, arguments); - }, ef = d._dispose_data = function() { - return (ef = d._dispose_data = d.asm.dispose_data).apply(null, arguments); - }, tf = d._dispose = function() { - return (tf = d._dispose = d.asm.dispose).apply(null, arguments); - }, nf = d._Abs = function() { - return (nf = d._Abs = d.asm.Abs).apply(null, arguments); - }, sf = d._Add = function() { - return (sf = d._Add = d.asm.Add).apply(null, arguments); - }, rf = d._AddN = function() { - return (rf = d._AddN = d.asm.AddN).apply(null, arguments); - }, af = d._All = function() { - return (af = d._All = d.asm.All).apply(null, arguments); - }, of = d._Any = function() { - return (of = d._Any = d.asm.Any).apply(null, arguments); - }, uf = d._ArgMax = function() { - return (uf = d._ArgMax = d.asm.ArgMax).apply(null, arguments); - }, lf = d._AvgPool = function() { - return (lf = d._AvgPool = d.asm.AvgPool).apply(null, arguments); - }, cf = d._BatchMatMul = function() { - return (cf = d._BatchMatMul = d.asm.BatchMatMul).apply(null, arguments); - }, df = d._Ceil = function() { - return (df = d._Ceil = d.asm.Ceil).apply(null, arguments); - }, pf = d._ClipByValue = function() { - return (pf = d._ClipByValue = d.asm.ClipByValue).apply(null, arguments); - }, hf = d._Conv2D = function() { - return (hf = d._Conv2D = d.asm.Conv2D).apply(null, arguments); - }, ff = d._Conv2DBackpropInput = function() { - return (ff = d._Conv2DBackpropInput = d.asm.Conv2DBackpropInput).apply(null, arguments); - }, mf = d._Cos = function() { - return (mf = d._Cos = d.asm.Cos).apply(null, arguments); - }, gf = d._Cosh = function() { - return (gf = d._Cosh = d.asm.Cosh).apply(null, arguments); - }, bf = d._CropAndResize = function() { - return (bf = d._CropAndResize = d.asm.CropAndResize).apply(null, arguments); - }, yf = d._Cumprod = function() { - return (yf = d._Cumprod = d.asm.Cumprod).apply(null, arguments); - }, vf = d._Cumsum = function() { - return (vf = d._Cumsum = d.asm.Cumsum).apply(null, arguments); - }, xf = d._DepthToSpace = function() { - return (xf = d._DepthToSpace = d.asm.DepthToSpace).apply(null, arguments); - }, wf = d._DepthwiseConv2dNative = function() { - return (wf = d._DepthwiseConv2dNative = d.asm.DepthwiseConv2dNative).apply(null, arguments); - }, kf = d._Elu = function() { - return (kf = d._Elu = d.asm.Elu).apply(null, arguments); - }, If = d._Equal = function() { - return (If = d._Equal = d.asm.Equal).apply(null, arguments); - }, Sf = d._Exp = function() { - return (Sf = d._Exp = d.asm.Exp).apply(null, arguments); - }, Cf = d._FlipLeftRight = function() { - return (Cf = d._FlipLeftRight = d.asm.FlipLeftRight).apply(null, arguments); - }, Rc = d._Floor = function() { - return (Rc = d._Floor = d.asm.Floor).apply(null, arguments); - }, Dc = d._FloorDiv = function() { - return (Dc = d._FloorDiv = d.asm.FloorDiv).apply(null, arguments); - }, xu = d._FusedBatchNorm = function() { - return (xu = d._FusedBatchNorm = d.asm.FusedBatchNorm).apply(null, arguments); - }, Nf = d._FusedConv2D = function() { - return (Nf = d._FusedConv2D = d.asm.FusedConv2D).apply(null, arguments); - }, Tf = d._FusedDepthwiseConv2D = function() { - return (Tf = d._FusedDepthwiseConv2D = d.asm.FusedDepthwiseConv2D).apply(null, arguments); - }, Ri = d._Gather = function() { - return (Ri = d._Gather = d.asm.Gather).apply(null, arguments); - }, wu = d._GatherNd = function() { - return (wu = d._GatherNd = d.asm.GatherNd).apply(null, arguments); - }, ku = d._Greater = function() { - return (ku = d._Greater = d.asm.Greater).apply(null, arguments); - }, jv = d._GreaterEqual = function() { - return (jv = d._GreaterEqual = d.asm.GreaterEqual).apply(null, arguments); - }, Di = d._LeakyRelu = function() { - return (Di = d._LeakyRelu = d.asm.LeakyRelu).apply(null, arguments); - }, Fi = d._Less = function() { - return (Fi = d._Less = d.asm.Less).apply(null, arguments); - }, $f = d._LessEqual = function() { - return ($f = d._LessEqual = d.asm.LessEqual).apply(null, arguments); + $e.init(); + var Ec, Qh = [null, Sc, Tc, $c, _c, Ac], Kv = false, Rc = { __clock_gettime: kh, __emscripten_init_main_thread_js: Sh, __emscripten_thread_cleanup: Ih, __pthread_create_js: Ch, _emscripten_default_pthread_stack_size: Nh, _emscripten_notify_thread_queue: Th, abort: $h, emscripten_check_blocking_allowed: _h, emscripten_get_heap_max: Cc, emscripten_get_now: Lr, emscripten_memcpy_big: Ah, emscripten_num_logical_cores: Eh, emscripten_receive_on_main_thread_js: Rh, emscripten_resize_heap: Fh, emscripten_set_canvas_element_size: Vh, emscripten_unwind_to_js_event_loop: Wh, emscripten_webgl_create_context: Xh, exit: kc, fd_close: $c, fd_seek: _c, fd_write: Ac, memory: Ce || d.wasmMemory, setTempRet0: Yh }, Xv = dh(), Zh = d.___wasm_call_ctors = function() { + return (Zh = d.___wasm_call_ctors = d.asm.__wasm_call_ctors).apply(null, arguments); + }, Jh = d._init = function() { + return (Jh = d._init = d.asm.init).apply(null, arguments); + }, ef = d._init_with_threads_count = function() { + return (ef = d._init_with_threads_count = d.asm.init_with_threads_count).apply(null, arguments); + }, tf = d._get_threads_count = function() { + return (tf = d._get_threads_count = d.asm.get_threads_count).apply(null, arguments); + }, nf = d._register_tensor = function() { + return (nf = d._register_tensor = d.asm.register_tensor).apply(null, arguments); + }, sf = d._dispose_data = function() { + return (sf = d._dispose_data = d.asm.dispose_data).apply(null, arguments); + }, rf = d._dispose = function() { + return (rf = d._dispose = d.asm.dispose).apply(null, arguments); + }, af = d._Abs = function() { + return (af = d._Abs = d.asm.Abs).apply(null, arguments); + }, of = d._Add = function() { + return (of = d._Add = d.asm.Add).apply(null, arguments); + }, uf = d._AddN = function() { + return (uf = d._AddN = d.asm.AddN).apply(null, arguments); + }, lf = d._All = function() { + return (lf = d._All = d.asm.All).apply(null, arguments); + }, cf = d._Any = function() { + return (cf = d._Any = d.asm.Any).apply(null, arguments); + }, df = d._ArgMax = function() { + return (df = d._ArgMax = d.asm.ArgMax).apply(null, arguments); + }, pf = d._AvgPool = function() { + return (pf = d._AvgPool = d.asm.AvgPool).apply(null, arguments); + }, hf = d._BatchMatMul = function() { + return (hf = d._BatchMatMul = d.asm.BatchMatMul).apply(null, arguments); + }, ff = d._Ceil = function() { + return (ff = d._Ceil = d.asm.Ceil).apply(null, arguments); + }, mf = d._ClipByValue = function() { + return (mf = d._ClipByValue = d.asm.ClipByValue).apply(null, arguments); + }, gf = d._Conv2D = function() { + return (gf = d._Conv2D = d.asm.Conv2D).apply(null, arguments); + }, bf = d._Conv2DBackpropInput = function() { + return (bf = d._Conv2DBackpropInput = d.asm.Conv2DBackpropInput).apply(null, arguments); + }, yf = d._Cos = function() { + return (yf = d._Cos = d.asm.Cos).apply(null, arguments); + }, vf = d._Cosh = function() { + return (vf = d._Cosh = d.asm.Cosh).apply(null, arguments); + }, xf = d._CropAndResize = function() { + return (xf = d._CropAndResize = d.asm.CropAndResize).apply(null, arguments); + }, wf = d._Cumprod = function() { + return (wf = d._Cumprod = d.asm.Cumprod).apply(null, arguments); + }, kf = d._Cumsum = function() { + return (kf = d._Cumsum = d.asm.Cumsum).apply(null, arguments); + }, Sf = d._DepthToSpace = function() { + return (Sf = d._DepthToSpace = d.asm.DepthToSpace).apply(null, arguments); + }, If = d._DepthwiseConv2dNative = function() { + return (If = d._DepthwiseConv2dNative = d.asm.DepthwiseConv2dNative).apply(null, arguments); + }, Cf = d._Elu = function() { + return (Cf = d._Elu = d.asm.Elu).apply(null, arguments); + }, Nf = d._Equal = function() { + return (Nf = d._Equal = d.asm.Equal).apply(null, arguments); + }, Tf = d._Exp = function() { + return (Tf = d._Exp = d.asm.Exp).apply(null, arguments); + }, $f = d._FlipLeftRight = function() { + return ($f = d._FlipLeftRight = d.asm.FlipLeftRight).apply(null, arguments); + }, Dc = d._Floor = function() { + return (Dc = d._Floor = d.asm.Floor).apply(null, arguments); + }, Fc = d._FloorDiv = function() { + return (Fc = d._FloorDiv = d.asm.FloorDiv).apply(null, arguments); + }, wu = d._FusedBatchNorm = function() { + return (wu = d._FusedBatchNorm = d.asm.FusedBatchNorm).apply(null, arguments); + }, _f = d._FusedConv2D = function() { + return (_f = d._FusedConv2D = d.asm.FusedConv2D).apply(null, arguments); + }, Af = d._FusedDepthwiseConv2D = function() { + return (Af = d._FusedDepthwiseConv2D = d.asm.FusedDepthwiseConv2D).apply(null, arguments); + }, Fi = d._Gather = function() { + return (Fi = d._Gather = d.asm.Gather).apply(null, arguments); + }, ku = d._GatherNd = function() { + return (ku = d._GatherNd = d.asm.GatherNd).apply(null, arguments); + }, Su = d._Greater = function() { + return (Su = d._Greater = d.asm.Greater).apply(null, arguments); + }, Yv = d._GreaterEqual = function() { + return (Yv = d._GreaterEqual = d.asm.GreaterEqual).apply(null, arguments); + }, Oi = d._LeakyRelu = function() { + return (Oi = d._LeakyRelu = d.asm.LeakyRelu).apply(null, arguments); + }, Pi = d._Less = function() { + return (Pi = d._Less = d.asm.Less).apply(null, arguments); + }, Ef = d._LessEqual = function() { + return (Ef = d._LessEqual = d.asm.LessEqual).apply(null, arguments); }, H = d._Log = function() { return (H = d._Log = d.asm.Log).apply(null, arguments); - }, J = d._LogicalAnd = function() { - return (J = d._LogicalAnd = d.asm.LogicalAnd).apply(null, arguments); - }, de = d._Max = function() { - return (de = d._Max = d.asm.Max).apply(null, arguments); - }, Ie = d._MaxPool = function() { - return (Ie = d._MaxPool = d.asm.MaxPool).apply(null, arguments); + }, ee = d._LogicalAnd = function() { + return (ee = d._LogicalAnd = d.asm.LogicalAnd).apply(null, arguments); + }, ce = d._Max = function() { + return (ce = d._Max = d.asm.Max).apply(null, arguments); + }, Se = d._MaxPool = function() { + return (Se = d._MaxPool = d.asm.MaxPool).apply(null, arguments); }, Qe = d._Maximum = function() { return (Qe = d._Maximum = d.asm.Maximum).apply(null, arguments); }, Ze = d._Mean = function() { return (Ze = d._Mean = d.asm.Mean).apply(null, arguments); - }, Ve = d._Min = function() { - return (Ve = d._Min = d.asm.Min).apply(null, arguments); + }, Le = d._Min = function() { + return (Le = d._Min = d.asm.Min).apply(null, arguments); }, ze = d._Minimum = function() { return (ze = d._Minimum = d.asm.Minimum).apply(null, arguments); }, Tt = d._MirrorPad = function() { @@ -2366,150 +2372,150 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js return (is = d._Multiply = d.asm.Multiply).apply(null, arguments); }, os = d._Neg = function() { return (os = d._Neg = d.asm.Neg).apply(null, arguments); - }, Oi = d._NonMaxSuppressionV3 = function() { - return (Oi = d._NonMaxSuppressionV3 = d.asm.NonMaxSuppressionV3).apply(null, arguments); + }, zi = d._NonMaxSuppressionV3 = function() { + return (zi = d._NonMaxSuppressionV3 = d.asm.NonMaxSuppressionV3).apply(null, arguments); }, Vr = d._NonMaxSuppressionV4 = function() { return (Vr = d._NonMaxSuppressionV4 = d.asm.NonMaxSuppressionV4).apply(null, arguments); - }, _f = d._NonMaxSuppressionV5 = function() { - return (_f = d._NonMaxSuppressionV5 = d.asm.NonMaxSuppressionV5).apply(null, arguments); - }, rn = d._NotEqual = function() { - return (rn = d._NotEqual = d.asm.NotEqual).apply(null, arguments); - }, sr = d._OneHot = function() { - return (sr = d._OneHot = d.asm.OneHot).apply(null, arguments); - }, Fc = d._PadV2 = function() { - return (Fc = d._PadV2 = d.asm.PadV2).apply(null, arguments); - }, ZN = d._Pow = function() { - return (ZN = d._Pow = d.asm.Pow).apply(null, arguments); - }, JN = d._Prelu = function() { - return (JN = d._Prelu = d.asm.Prelu).apply(null, arguments); - }, eT = d._Prod = function() { - return (eT = d._Prod = d.asm.Prod).apply(null, arguments); - }, tT = d._RealDiv = function() { - return (tT = d._RealDiv = d.asm.RealDiv).apply(null, arguments); - }, nT = d._Relu = function() { - return (nT = d._Relu = d.asm.Relu).apply(null, arguments); - }, sT = d._Relu6 = function() { - return (sT = d._Relu6 = d.asm.Relu6).apply(null, arguments); - }, rT = d._ResizeBilinear = function() { - return (rT = d._ResizeBilinear = d.asm.ResizeBilinear).apply(null, arguments); - }, aT = d._Reverse = function() { - return (aT = d._Reverse = d.asm.Reverse).apply(null, arguments); - }, iT = d._RotateWithOffset = function() { - return (iT = d._RotateWithOffset = d.asm.RotateWithOffset).apply(null, arguments); - }, oT = d._Round = function() { - return (oT = d._Round = d.asm.Round).apply(null, arguments); - }, uT = d._Rsqrt = function() { - return (uT = d._Rsqrt = d.asm.Rsqrt).apply(null, arguments); - }, lT = d._ScatterNd = function() { - return (lT = d._ScatterNd = d.asm.ScatterNd).apply(null, arguments); - }, cT = d._SelectV2 = function() { - return (cT = d._SelectV2 = d.asm.SelectV2).apply(null, arguments); - }, dT = d._Sigmoid = function() { - return (dT = d._Sigmoid = d.asm.Sigmoid).apply(null, arguments); - }, pT = d._Sin = function() { - return (pT = d._Sin = d.asm.Sin).apply(null, arguments); - }, hT = d._Softmax = function() { - return (hT = d._Softmax = d.asm.Softmax).apply(null, arguments); - }, fT = d._SparseFillEmptyRows = function() { - return (fT = d._SparseFillEmptyRows = d.asm.SparseFillEmptyRows).apply(null, arguments); - }, mT = d._SparseReshape = function() { - return (mT = d._SparseReshape = d.asm.SparseReshape).apply(null, arguments); - }, gT = d._SparseSegmentReduction = function() { - return (gT = d._SparseSegmentReduction = d.asm.SparseSegmentReduction).apply(null, arguments); - }, bT = d._Sqrt = function() { - return (bT = d._Sqrt = d.asm.Sqrt).apply(null, arguments); - }, yT = d._Square = function() { - return (yT = d._Square = d.asm.Square).apply(null, arguments); - }, vT = d._SquaredDifference = function() { - return (vT = d._SquaredDifference = d.asm.SquaredDifference).apply(null, arguments); - }, xT = d._Step = function() { - return (xT = d._Step = d.asm.Step).apply(null, arguments); - }, wT = d._StridedSlice = function() { - return (wT = d._StridedSlice = d.asm.StridedSlice).apply(null, arguments); - }, kT = d._Sub = function() { - return (kT = d._Sub = d.asm.Sub).apply(null, arguments); - }, IT = d._Sum = function() { - return (IT = d._Sum = d.asm.Sum).apply(null, arguments); - }, ST = d._Tan = function() { - return (ST = d._Tan = d.asm.Tan).apply(null, arguments); - }, CT = d._Tanh = function() { - return (CT = d._Tanh = d.asm.Tanh).apply(null, arguments); - }, NT = d._Tile = function() { - return (NT = d._Tile = d.asm.Tile).apply(null, arguments); - }, TT = d._TopK = function() { - return (TT = d._TopK = d.asm.TopK).apply(null, arguments); - }, $T = d._Transform = function() { - return ($T = d._Transform = d.asm.Transform).apply(null, arguments); - }, _T = d._Transpose = function() { - return (_T = d._Transpose = d.asm.Transpose).apply(null, arguments); - }, AT = d.__FusedMatMul = function() { - return (AT = d.__FusedMatMul = d.asm._FusedMatMul).apply(null, arguments); - }, Af = d._malloc = function() { - return (Af = d._malloc = d.asm.malloc).apply(null, arguments); - }, Kv = d._free = function() { - return (Kv = d._free = d.asm.free).apply(null, arguments); - }, ET = d._emscripten_tls_init = function() { - return (ET = d._emscripten_tls_init = d.asm.emscripten_tls_init).apply(null, arguments); - }, Xv = d.___errno_location = function() { - return (Xv = d.___errno_location = d.asm.__errno_location).apply(null, arguments); - }, Oc = d._pthread_self = function() { - return (Oc = d._pthread_self = d.asm.pthread_self).apply(null, arguments); - }, Yv = d._emscripten_main_thread_process_queued_calls = function() { - return (Yv = d._emscripten_main_thread_process_queued_calls = d.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); - }, RT = d.__emscripten_thread_crashed = function() { - return (RT = d.__emscripten_thread_crashed = d.asm._emscripten_thread_crashed).apply(null, arguments); - }, Qv = d.__emscripten_thread_init = function() { - return (Qv = d.__emscripten_thread_init = d.asm._emscripten_thread_init).apply(null, arguments); - }, DT = d._emscripten_current_thread_process_queued_calls = function() { - return (DT = d._emscripten_current_thread_process_queued_calls = d.asm.emscripten_current_thread_process_queued_calls).apply(null, arguments); - }, FT = d._emscripten_main_browser_thread_id = function() { - return (FT = d._emscripten_main_browser_thread_id = d.asm.emscripten_main_browser_thread_id).apply(null, arguments); - }, OT = d._emscripten_sync_run_in_main_thread_2 = function() { - return (OT = d._emscripten_sync_run_in_main_thread_2 = d.asm.emscripten_sync_run_in_main_thread_2).apply(null, arguments); - }, Zv = d._emscripten_sync_run_in_main_thread_4 = function() { - return (Zv = d._emscripten_sync_run_in_main_thread_4 = d.asm.emscripten_sync_run_in_main_thread_4).apply(null, arguments); - }, Jv = d._emscripten_run_in_main_runtime_thread_js = function() { - return (Jv = d._emscripten_run_in_main_runtime_thread_js = d.asm.emscripten_run_in_main_runtime_thread_js).apply(null, arguments); - }, Ef = d._emscripten_dispatch_to_thread_ = function() { - return (Ef = d._emscripten_dispatch_to_thread_ = d.asm.emscripten_dispatch_to_thread_).apply(null, arguments); - }, Rf = d.__emscripten_thread_free_data = function() { - return (Rf = d.__emscripten_thread_free_data = d.asm._emscripten_thread_free_data).apply(null, arguments); - }, PT = d.__emscripten_thread_exit = function() { - return (PT = d.__emscripten_thread_exit = d.asm._emscripten_thread_exit).apply(null, arguments); - }, zT = d._memalign = function() { - return (zT = d._memalign = d.asm.memalign).apply(null, arguments); - }, ex = d._emscripten_stack_set_limits = function() { - return (ex = d._emscripten_stack_set_limits = d.asm.emscripten_stack_set_limits).apply(null, arguments); - }, Df = d.stackSave = function() { - return (Df = d.stackSave = d.asm.stackSave).apply(null, arguments); - }, Pc = d.stackRestore = function() { - return (Pc = d.stackRestore = d.asm.stackRestore).apply(null, arguments); - }, Pi = d.stackAlloc = function() { - return (Pi = d.stackAlloc = d.asm.stackAlloc).apply(null, arguments); - }, MT = d.dynCall_iijjiiii = function() { - return (MT = d.dynCall_iijjiiii = d.asm.dynCall_iijjiiii).apply(null, arguments); - }, LT = d.dynCall_jiji = function() { - return (LT = d.dynCall_jiji = d.asm.dynCall_jiji).apply(null, arguments); - }, tx = d.__emscripten_allow_main_runtime_queued_calls = 21456; - d.cwrap = Jt, d.keepRuntimeAlive = zr, d.PThread = _e, d.PThread = _e, d.wasmMemory = Ce, d.ExitStatus = Iu; - var zc; + }, Rf = d._NonMaxSuppressionV5 = function() { + return (Rf = d._NonMaxSuppressionV5 = d.asm.NonMaxSuppressionV5).apply(null, arguments); + }, an = d._NotEqual = function() { + return (an = d._NotEqual = d.asm.NotEqual).apply(null, arguments); + }, tr = d._OneHot = function() { + return (tr = d._OneHot = d.asm.OneHot).apply(null, arguments); + }, Oc = d._PadV2 = function() { + return (Oc = d._PadV2 = d.asm.PadV2).apply(null, arguments); + }, nT = d._Pow = function() { + return (nT = d._Pow = d.asm.Pow).apply(null, arguments); + }, sT = d._Prelu = function() { + return (sT = d._Prelu = d.asm.Prelu).apply(null, arguments); + }, rT = d._Prod = function() { + return (rT = d._Prod = d.asm.Prod).apply(null, arguments); + }, aT = d._RealDiv = function() { + return (aT = d._RealDiv = d.asm.RealDiv).apply(null, arguments); + }, iT = d._Relu = function() { + return (iT = d._Relu = d.asm.Relu).apply(null, arguments); + }, oT = d._Relu6 = function() { + return (oT = d._Relu6 = d.asm.Relu6).apply(null, arguments); + }, uT = d._ResizeBilinear = function() { + return (uT = d._ResizeBilinear = d.asm.ResizeBilinear).apply(null, arguments); + }, lT = d._Reverse = function() { + return (lT = d._Reverse = d.asm.Reverse).apply(null, arguments); + }, cT = d._RotateWithOffset = function() { + return (cT = d._RotateWithOffset = d.asm.RotateWithOffset).apply(null, arguments); + }, dT = d._Round = function() { + return (dT = d._Round = d.asm.Round).apply(null, arguments); + }, pT = d._Rsqrt = function() { + return (pT = d._Rsqrt = d.asm.Rsqrt).apply(null, arguments); + }, hT = d._ScatterNd = function() { + return (hT = d._ScatterNd = d.asm.ScatterNd).apply(null, arguments); + }, fT = d._SelectV2 = function() { + return (fT = d._SelectV2 = d.asm.SelectV2).apply(null, arguments); + }, mT = d._Sigmoid = function() { + return (mT = d._Sigmoid = d.asm.Sigmoid).apply(null, arguments); + }, gT = d._Sin = function() { + return (gT = d._Sin = d.asm.Sin).apply(null, arguments); + }, bT = d._Softmax = function() { + return (bT = d._Softmax = d.asm.Softmax).apply(null, arguments); + }, yT = d._SparseFillEmptyRows = function() { + return (yT = d._SparseFillEmptyRows = d.asm.SparseFillEmptyRows).apply(null, arguments); + }, vT = d._SparseReshape = function() { + return (vT = d._SparseReshape = d.asm.SparseReshape).apply(null, arguments); + }, xT = d._SparseSegmentReduction = function() { + return (xT = d._SparseSegmentReduction = d.asm.SparseSegmentReduction).apply(null, arguments); + }, wT = d._Sqrt = function() { + return (wT = d._Sqrt = d.asm.Sqrt).apply(null, arguments); + }, kT = d._Square = function() { + return (kT = d._Square = d.asm.Square).apply(null, arguments); + }, ST = d._SquaredDifference = function() { + return (ST = d._SquaredDifference = d.asm.SquaredDifference).apply(null, arguments); + }, IT = d._Step = function() { + return (IT = d._Step = d.asm.Step).apply(null, arguments); + }, CT = d._StridedSlice = function() { + return (CT = d._StridedSlice = d.asm.StridedSlice).apply(null, arguments); + }, NT = d._Sub = function() { + return (NT = d._Sub = d.asm.Sub).apply(null, arguments); + }, TT = d._Sum = function() { + return (TT = d._Sum = d.asm.Sum).apply(null, arguments); + }, $T = d._Tan = function() { + return ($T = d._Tan = d.asm.Tan).apply(null, arguments); + }, _T = d._Tanh = function() { + return (_T = d._Tanh = d.asm.Tanh).apply(null, arguments); + }, AT = d._Tile = function() { + return (AT = d._Tile = d.asm.Tile).apply(null, arguments); + }, ET = d._TopK = function() { + return (ET = d._TopK = d.asm.TopK).apply(null, arguments); + }, RT = d._Transform = function() { + return (RT = d._Transform = d.asm.Transform).apply(null, arguments); + }, DT = d._Transpose = function() { + return (DT = d._Transpose = d.asm.Transpose).apply(null, arguments); + }, FT = d.__FusedMatMul = function() { + return (FT = d.__FusedMatMul = d.asm._FusedMatMul).apply(null, arguments); + }, Df = d._malloc = function() { + return (Df = d._malloc = d.asm.malloc).apply(null, arguments); + }, Qv = d._free = function() { + return (Qv = d._free = d.asm.free).apply(null, arguments); + }, OT = d._emscripten_tls_init = function() { + return (OT = d._emscripten_tls_init = d.asm.emscripten_tls_init).apply(null, arguments); + }, Zv = d.___errno_location = function() { + return (Zv = d.___errno_location = d.asm.__errno_location).apply(null, arguments); + }, Pc = d._pthread_self = function() { + return (Pc = d._pthread_self = d.asm.pthread_self).apply(null, arguments); + }, Jv = d._emscripten_main_thread_process_queued_calls = function() { + return (Jv = d._emscripten_main_thread_process_queued_calls = d.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); + }, PT = d.__emscripten_thread_crashed = function() { + return (PT = d.__emscripten_thread_crashed = d.asm._emscripten_thread_crashed).apply(null, arguments); + }, ex = d.__emscripten_thread_init = function() { + return (ex = d.__emscripten_thread_init = d.asm._emscripten_thread_init).apply(null, arguments); + }, zT = d._emscripten_current_thread_process_queued_calls = function() { + return (zT = d._emscripten_current_thread_process_queued_calls = d.asm.emscripten_current_thread_process_queued_calls).apply(null, arguments); + }, MT = d._emscripten_main_browser_thread_id = function() { + return (MT = d._emscripten_main_browser_thread_id = d.asm.emscripten_main_browser_thread_id).apply(null, arguments); + }, LT = d._emscripten_sync_run_in_main_thread_2 = function() { + return (LT = d._emscripten_sync_run_in_main_thread_2 = d.asm.emscripten_sync_run_in_main_thread_2).apply(null, arguments); + }, tx = d._emscripten_sync_run_in_main_thread_4 = function() { + return (tx = d._emscripten_sync_run_in_main_thread_4 = d.asm.emscripten_sync_run_in_main_thread_4).apply(null, arguments); + }, nx = d._emscripten_run_in_main_runtime_thread_js = function() { + return (nx = d._emscripten_run_in_main_runtime_thread_js = d.asm.emscripten_run_in_main_runtime_thread_js).apply(null, arguments); + }, Ff = d._emscripten_dispatch_to_thread_ = function() { + return (Ff = d._emscripten_dispatch_to_thread_ = d.asm.emscripten_dispatch_to_thread_).apply(null, arguments); + }, Of = d.__emscripten_thread_free_data = function() { + return (Of = d.__emscripten_thread_free_data = d.asm._emscripten_thread_free_data).apply(null, arguments); + }, BT = d.__emscripten_thread_exit = function() { + return (BT = d.__emscripten_thread_exit = d.asm._emscripten_thread_exit).apply(null, arguments); + }, VT = d._memalign = function() { + return (VT = d._memalign = d.asm.memalign).apply(null, arguments); + }, sx = d._emscripten_stack_set_limits = function() { + return (sx = d._emscripten_stack_set_limits = d.asm.emscripten_stack_set_limits).apply(null, arguments); + }, Pf = d.stackSave = function() { + return (Pf = d.stackSave = d.asm.stackSave).apply(null, arguments); + }, zc = d.stackRestore = function() { + return (zc = d.stackRestore = d.asm.stackRestore).apply(null, arguments); + }, Mi = d.stackAlloc = function() { + return (Mi = d.stackAlloc = d.asm.stackAlloc).apply(null, arguments); + }, WT = d.dynCall_iijjiiii = function() { + return (WT = d.dynCall_iijjiiii = d.asm.dynCall_iijjiiii).apply(null, arguments); + }, UT = d.dynCall_jiji = function() { + return (UT = d.dynCall_jiji = d.asm.dynCall_jiji).apply(null, arguments); + }, rx = d.__emscripten_allow_main_runtime_queued_calls = 21456; + d.cwrap = en, d.keepRuntimeAlive = zr, d.PThread = $e, d.PThread = $e, d.wasmMemory = Ce, d.ExitStatus = Iu; + var Mc; function Iu(N) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + N + ")", this.status = N; } as = function N() { - zc || Ff(), zc || (as = N); + Mc || zf(), Mc || (as = N); }; - function Ff(N) { - if (N = N || b, nr > 0) + function zf(N) { + if (N = N || b, er > 0) return; if ($) { - h(d), mu(), postMessage({ cmd: "loaded" }); + h(d), gu(), postMessage({ cmd: "loaded" }); return; } - if (nn(), nr > 0) + if (sn(), er > 0) return; function D() { - zc || (zc = true, d.calledRun = true, !rt && (mu(), h(d), d.onRuntimeInitialized && d.onRuntimeInitialized(), ih())); + Mc || (Mc = true, d.calledRun = true, !rt && (gu(), h(d), d.onRuntimeInitialized && d.onRuntimeInitialized(), lh())); } d.setStatus ? (d.setStatus("Running..."), setTimeout(function() { setTimeout(function() { @@ -2517,38 +2523,38 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js }, 1), D(); }, 1)) : D(); } - d.run = Ff; - function BT(N, D) { - if (Zt = N, !D && $) - throw kc(N), "unwind"; - zr() || ah(), VT(N); + d.run = zf; + function GT(N, D) { + if (Jt = N, !D && $) + throw Sc(N), "unwind"; + zr() || uh(), HT(N); } - function VT(N) { - Zt = N, zr() || (_e.terminateAllThreads(), d.onExit && d.onExit(N), rt = true), v(N, new Iu(N)); + function HT(N) { + Jt = N, zr() || ($e.terminateAllThreads(), d.onExit && d.onExit(N), rt = true), v(N, new Iu(N)); } if (d.preInit) for (typeof d.preInit == "function" && (d.preInit = [d.preInit]); d.preInit.length > 0; ) d.preInit.pop()(); - Ff(); - var Mc; - m && (Mc = { uncaughtException: process.listeners("uncaughtException").filter(function(N) { + zf(); + var Lc; + m && (Lc = { uncaughtException: process.listeners("uncaughtException").filter(function(N) { return !m.uncaughtException.indexOf(N) > -1; }), unhandledRejection: process.listeners("unhandledRejection").filter(function(N) { return !m.unhandledRejection.indexOf(N) > -1; }) }); - var Lc; + var Bc; if (typeof WasmBackendModule != "undefined") - Lc = WasmBackendModule; + Bc = WasmBackendModule; else if (typeof r != "undefined") - Lc = r; + Bc = r; else throw new Error("Could not find wasm module in post.js"); - if (Mc) { - var WT = Lc._dispose; - Lc._dispose = function() { - WT(), Mc.uncaughtException.forEach(function(N) { + if (Lc) { + var qT = Bc._dispose; + Bc._dispose = function() { + qT(), Lc.uncaughtException.forEach(function(N) { process.removeListener("uncaughtException", N); - }), Mc.unhandledRejection.forEach(function(N) { + }), Lc.unhandledRejection.forEach(function(N) { process.removeListener("unhandledRejection", N); }); }; @@ -2560,67 +2566,67 @@ var c$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js return n; }) : typeof e == "object" && (e.WasmBackendModuleThreadedSimd = n); } }); -var d$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { +var m$ = Mt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { var n = (() => { var s = typeof document != "undefined" && document.currentScript ? document.currentScript.src : void 0; return typeof __filename != "undefined" && (s = s || __filename), function(r) { r = r || {}; var a = typeof r != "undefined" ? r : {}, i, o; - a.ready = new Promise(function(H, J) { - i = H, o = J; + a.ready = new Promise(function(H, ee) { + i = H, o = ee; }); var u; typeof process != "undefined" && process.listeners && (u = { uncaughtException: process.listeners("uncaughtException"), unhandledRejection: process.listeners("unhandledRejection") }); - var l = Object.assign({}, a), c = [], p = "./this.program", d = (H, J) => { - throw J; + var l = Object.assign({}, a), c = [], p = "./this.program", d = (H, ee) => { + throw ee; }, h = typeof window == "object", f = typeof importScripts == "function", m = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", g = ""; function b(H) { return a.locateFile ? a.locateFile(H, g) : g + H; } var y, v, x, k; - function S(H) { - if (H instanceof wu) + function I(H) { + if (H instanceof ku) return; R("exiting due to exception: " + H); } var $, E, A; - m ? (f ? g = dd().dirname(g) + "/" : g = __dirname + "/", A = () => { - E || ($ = sg(), E = dd()); - }, y = function(J, de) { - return A(), J = E.normalize(J), $.readFileSync(J, de ? void 0 : "utf8"); + m ? (f ? g = fd().dirname(g) + "/" : g = __dirname + "/", A = () => { + E || ($ = ag(), E = fd()); + }, y = function(ee, ce) { + return A(), ee = E.normalize(ee), $.readFileSync(ee, ce ? void 0 : "utf8"); }, x = (H) => { - var J = y(H, true); - return J.buffer || (J = new Uint8Array(J)), J; - }, v = (H, J, de) => { - A(), H = E.normalize(H), $.readFile(H, function(Ie, Qe) { - Ie ? de(Ie) : J(Qe.buffer); + var ee = y(H, true); + return ee.buffer || (ee = new Uint8Array(ee)), ee; + }, v = (H, ee, ce) => { + A(), H = E.normalize(H), $.readFile(H, function(Se, Qe) { + Se ? ce(Se) : ee(Qe.buffer); }); }, process.argv.length > 1 && (p = process.argv[1].replace(/\\/g, "/")), c = process.argv.slice(2), process.on("uncaughtException", function(H) { - if (!(H instanceof wu)) + if (!(H instanceof ku)) throw H; }), process.on("unhandledRejection", function(H) { throw H; - }), d = (H, J) => { - if (fu()) - throw process.exitCode = H, J; - S(J), process.exit(H); + }), d = (H, ee) => { + if (mu()) + throw process.exitCode = H, ee; + I(ee), process.exit(H); }, a.inspect = function() { return "[Emscripten Module object]"; }) : (h || f) && (f ? g = self.location.href : typeof document != "undefined" && document.currentScript && (g = document.currentScript.src), s && (g = s), g.indexOf("blob:") !== 0 ? g = g.substr(0, g.replace(/[?#].*/, "").lastIndexOf("/") + 1) : g = "", y = (H) => { - var J = new XMLHttpRequest(); - return J.open("GET", H, false), J.send(null), J.responseText; + var ee = new XMLHttpRequest(); + return ee.open("GET", H, false), ee.send(null), ee.responseText; }, f && (x = (H) => { - var J = new XMLHttpRequest(); - return J.open("GET", H, false), J.responseType = "arraybuffer", J.send(null), new Uint8Array(J.response); - }), v = (H, J, de) => { - var Ie = new XMLHttpRequest(); - Ie.open("GET", H, true), Ie.responseType = "arraybuffer", Ie.onload = () => { - if (Ie.status == 200 || Ie.status == 0 && Ie.response) { - J(Ie.response); + var ee = new XMLHttpRequest(); + return ee.open("GET", H, false), ee.responseType = "arraybuffer", ee.send(null), new Uint8Array(ee.response); + }), v = (H, ee, ce) => { + var Se = new XMLHttpRequest(); + Se.open("GET", H, true), Se.responseType = "arraybuffer", Se.onload = () => { + if (Se.status == 200 || Se.status == 0 && Se.response) { + ee(Se.response); return; } - de(); - }, Ie.onerror = de, Ie.send(null); + ce(); + }, Se.onerror = ce, Se.send(null); }, k = (H) => document.title = H); var P = a.print || console.log.bind(console), R = a.printErr || console.warn.bind(console); Object.assign(a, l), l = null, a.arguments && (c = a.arguments), a.thisProgram && (p = a.thisProgram), a.quit && (d = a.quit); @@ -2628,650 +2634,650 @@ var d$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { function T(H) { T.shown || (T.shown = {}), T.shown[H] || (T.shown[H] = 1, R(H)); } - function z(H, J) { + function z(H, ee) { if (typeof WebAssembly.Function == "function") { - for (var de = { i: "i32", j: "i64", f: "f32", d: "f64" }, Ie = { parameters: [], results: J[0] == "v" ? [] : [de[J[0]]] }, Qe = 1; Qe < J.length; ++Qe) - Ie.parameters.push(de[J[Qe]]); - return new WebAssembly.Function(Ie, H); + for (var ce = { i: "i32", j: "i64", f: "f32", d: "f64" }, Se = { parameters: [], results: ee[0] == "v" ? [] : [ce[ee[0]]] }, Qe = 1; Qe < ee.length; ++Qe) + Se.parameters.push(ce[ee[Qe]]); + return new WebAssembly.Function(Se, H); } - var Ze = [1, 0, 1, 96], Ve = J.slice(0, 1), ze = J.slice(1), Tt = { i: 127, j: 126, f: 125, d: 124 }; + var Ze = [1, 0, 1, 96], Le = ee.slice(0, 1), ze = ee.slice(1), Tt = { i: 127, j: 126, f: 125, d: 124 }; Ze.push(ze.length); for (var Qe = 0; Qe < ze.length; ++Qe) Ze.push(Tt[ze[Qe]]); - Ve == "v" ? Ze.push(0) : Ze = Ze.concat([1, Tt[Ve]]), Ze[1] = Ze.length - 2; - var is = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(Ze, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), os = new WebAssembly.Module(is), Oi = new WebAssembly.Instance(os, { e: { f: H } }), Vr = Oi.exports.f; + Le == "v" ? Ze.push(0) : Ze = Ze.concat([1, Tt[Le]]), Ze[1] = Ze.length - 2; + var is = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(Ze, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), os = new WebAssembly.Module(is), zi = new WebAssembly.Instance(os, { e: { f: H } }), Vr = zi.exports.f; return Vr; } - var W = [], q; - function K() { + var W = [], j; + function X() { if (W.length) return W.pop(); try { - er.grow(1); + Zs.grow(1); } catch (H) { throw H instanceof RangeError ? "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." : H; } - return er.length - 1; + return Zs.length - 1; } - function Y(H, J) { - for (var de = H; de < H + J; de++) { - var Ie = bu(de); - Ie && q.set(Ie, de); + function Y(H, ee) { + for (var ce = H; ce < H + ee; ce++) { + var Se = yu(ce); + Se && j.set(Se, ce); } } var Z = 0, te = (H) => { Z = H; - }, ee; - a.wasmBinary && (ee = a.wasmBinary); + }, J; + a.wasmBinary && (J = a.wasmBinary); var se = a.noExitRuntime || true; typeof WebAssembly != "object" && Pr("no native wasm support detected"); - var ne, oe = false, re; - function le(H, J) { - H || Pr(J); + var ne, oe = false, ae; + function de(H, ee) { + H || Pr(ee); } function me(H) { - var J = a["_" + H]; - return J; - } - function ke(H, J, de, Ie, Qe) { - var Ze = { string: function(rn) { - var sr = 0; - if (rn != null && rn !== 0) { - var Fc = (rn.length << 2) + 1; - sr = xu(Fc), tt(rn, sr, Fc); + var ee = a["_" + H]; + return ee; + } + function ke(H, ee, ce, Se, Qe) { + var Ze = { string: function(an) { + var tr = 0; + if (an != null && an !== 0) { + var Oc = (an.length << 2) + 1; + tr = wu(Oc), tt(an, tr, Oc); } - return sr; - }, array: function(rn) { - var sr = xu(rn.length); - return rt(rn, sr), sr; + return tr; + }, array: function(an) { + var tr = wu(an.length); + return rt(an, tr), tr; } }; - function Ve(rn) { - return J === "string" ? Je(rn) : J === "boolean" ? Boolean(rn) : rn; + function Le(an) { + return ee === "string" ? Je(an) : ee === "boolean" ? Boolean(an) : an; } var ze = me(H), Tt = [], is = 0; - if (Ie) - for (var os = 0; os < Ie.length; os++) { - var Oi = Ze[de[os]]; - Oi ? (is === 0 && (is = Rc()), Tt[os] = Oi(Ie[os])) : Tt[os] = Ie[os]; + if (Se) + for (var os = 0; os < Se.length; os++) { + var zi = Ze[ce[os]]; + zi ? (is === 0 && (is = Dc()), Tt[os] = zi(Se[os])) : Tt[os] = Se[os]; } var Vr = ze.apply(null, Tt); - function _f(rn) { - return is !== 0 && Dc(is), Ve(rn); - } - return Vr = _f(Vr), Vr; - } - function Se(H, J, de, Ie) { - de = de || []; - var Qe = de.every(function(Ve) { - return Ve === "number"; - }), Ze = J !== "string"; - return Ze && Qe && !Ie ? me(H) : function() { - return ke(H, J, de, arguments, Ie); + function Rf(an) { + return is !== 0 && Fc(is), Le(an); + } + return Vr = Rf(Vr), Vr; + } + function Ie(H, ee, ce, Se) { + ce = ce || []; + var Qe = ce.every(function(Le) { + return Le === "number"; + }), Ze = ee !== "string"; + return Ze && Qe && !Se ? me(H) : function() { + return ke(H, ee, ce, arguments, Se); }; } var Ee = 1, Pe = typeof TextDecoder != "undefined" ? new TextDecoder("utf8") : void 0; - function Xe(H, J, de) { - for (var Ie = J + de, Qe = J; H[Qe] && !(Qe >= Ie); ) + function Xe(H, ee, ce) { + for (var Se = ee + ce, Qe = ee; H[Qe] && !(Qe >= Se); ) ++Qe; - if (Qe - J > 16 && H.subarray && Pe) - return Pe.decode(H.subarray(J, Qe)); - for (var Ze = ""; J < Qe; ) { - var Ve = H[J++]; - if (!(Ve & 128)) { - Ze += String.fromCharCode(Ve); + if (Qe - ee > 16 && H.subarray && Pe) + return Pe.decode(H.subarray(ee, Qe)); + for (var Ze = ""; ee < Qe; ) { + var Le = H[ee++]; + if (!(Le & 128)) { + Ze += String.fromCharCode(Le); continue; } - var ze = H[J++] & 63; - if ((Ve & 224) == 192) { - Ze += String.fromCharCode((Ve & 31) << 6 | ze); + var ze = H[ee++] & 63; + if ((Le & 224) == 192) { + Ze += String.fromCharCode((Le & 31) << 6 | ze); continue; } - var Tt = H[J++] & 63; - if ((Ve & 240) == 224 ? Ve = (Ve & 15) << 12 | ze << 6 | Tt : Ve = (Ve & 7) << 18 | ze << 12 | Tt << 6 | H[J++] & 63, Ve < 65536) - Ze += String.fromCharCode(Ve); + var Tt = H[ee++] & 63; + if ((Le & 240) == 224 ? Le = (Le & 15) << 12 | ze << 6 | Tt : Le = (Le & 7) << 18 | ze << 12 | Tt << 6 | H[ee++] & 63, Le < 65536) + Ze += String.fromCharCode(Le); else { - var is = Ve - 65536; + var is = Le - 65536; Ze += String.fromCharCode(55296 | is >> 10, 56320 | is & 1023); } } return Ze; } - function Je(H, J) { - return H ? Xe(Jt, H, J) : ""; + function Je(H, ee) { + return H ? Xe(en, H, ee) : ""; } - function Ye(H, J, de, Ie) { - if (!(Ie > 0)) + function Ye(H, ee, ce, Se) { + if (!(Se > 0)) return 0; - for (var Qe = de, Ze = de + Ie - 1, Ve = 0; Ve < H.length; ++Ve) { - var ze = H.charCodeAt(Ve); + for (var Qe = ce, Ze = ce + Se - 1, Le = 0; Le < H.length; ++Le) { + var ze = H.charCodeAt(Le); if (ze >= 55296 && ze <= 57343) { - var Tt = H.charCodeAt(++Ve); + var Tt = H.charCodeAt(++Le); ze = 65536 + ((ze & 1023) << 10) | Tt & 1023; } if (ze <= 127) { - if (de >= Ze) + if (ce >= Ze) break; - J[de++] = ze; + ee[ce++] = ze; } else if (ze <= 2047) { - if (de + 1 >= Ze) + if (ce + 1 >= Ze) break; - J[de++] = 192 | ze >> 6, J[de++] = 128 | ze & 63; + ee[ce++] = 192 | ze >> 6, ee[ce++] = 128 | ze & 63; } else if (ze <= 65535) { - if (de + 2 >= Ze) + if (ce + 2 >= Ze) break; - J[de++] = 224 | ze >> 12, J[de++] = 128 | ze >> 6 & 63, J[de++] = 128 | ze & 63; + ee[ce++] = 224 | ze >> 12, ee[ce++] = 128 | ze >> 6 & 63, ee[ce++] = 128 | ze & 63; } else { - if (de + 3 >= Ze) + if (ce + 3 >= Ze) break; - J[de++] = 240 | ze >> 18, J[de++] = 128 | ze >> 12 & 63, J[de++] = 128 | ze >> 6 & 63, J[de++] = 128 | ze & 63; + ee[ce++] = 240 | ze >> 18, ee[ce++] = 128 | ze >> 12 & 63, ee[ce++] = 128 | ze >> 6 & 63, ee[ce++] = 128 | ze & 63; } } - return J[de] = 0, de - Qe; + return ee[ce] = 0, ce - Qe; } - function tt(H, J, de) { - return Ye(H, Jt, J, de); + function tt(H, ee, ce) { + return Ye(H, en, ee, ce); } function Ce(H) { - for (var J = 0, de = 0; de < H.length; ++de) { - var Ie = H.charCodeAt(de); - Ie >= 55296 && Ie <= 57343 && (Ie = 65536 + ((Ie & 1023) << 10) | H.charCodeAt(++de) & 1023), Ie <= 127 ? ++J : Ie <= 2047 ? J += 2 : Ie <= 65535 ? J += 3 : J += 4; + for (var ee = 0, ce = 0; ce < H.length; ++ce) { + var Se = H.charCodeAt(ce); + Se >= 55296 && Se <= 57343 && (Se = 65536 + ((Se & 1023) << 10) | H.charCodeAt(++ce) & 1023), Se <= 127 ? ++ee : Se <= 2047 ? ee += 2 : Se <= 65535 ? ee += 3 : ee += 4; } - return J; + return ee; } var ut = typeof TextDecoder != "undefined" ? new TextDecoder("utf-16le") : void 0; - function rt(H, J) { - Et.set(H, J); + function rt(H, ee) { + Et.set(H, ee); } - function Zt(H, J, de) { - for (var Ie = 0; Ie < H.length; ++Ie) - Et[J++ >> 0] = H.charCodeAt(Ie); - de || (Et[J >> 0] = 0); + function Jt(H, ee, ce) { + for (var Se = 0; Se < H.length; ++Se) + Et[ee++ >> 0] = H.charCodeAt(Se); + ce || (Et[ee >> 0] = 0); } - function Nt(H, J) { - return H % J > 0 && (H += J - H % J), H; + function Nt(H, ee) { + return H % ee > 0 && (H += ee - H % ee), H; } - var Sn, Et, Jt, Cn, Nn, Xt, Dn, en, Ms; - function Ls(H) { - Sn = H, a.HEAP8 = Et = new Int8Array(H), a.HEAP16 = Cn = new Int16Array(H), a.HEAP32 = Xt = new Int32Array(H), a.HEAPU8 = Jt = new Uint8Array(H), a.HEAPU16 = Nn = new Uint16Array(H), a.HEAPU32 = Dn = new Uint32Array(H), a.HEAPF32 = en = new Float32Array(H), a.HEAPF64 = Ms = new Float64Array(H); + var In, Et, en, Cn, Nn, Yt, Dn, tn, zs; + function Ms(H) { + In = H, a.HEAP8 = Et = new Int8Array(H), a.HEAP16 = Cn = new Int16Array(H), a.HEAP32 = Yt = new Int32Array(H), a.HEAPU8 = en = new Uint8Array(H), a.HEAPU16 = Nn = new Uint16Array(H), a.HEAPU32 = Dn = new Uint32Array(H), a.HEAPF32 = tn = new Float32Array(H), a.HEAPF64 = zs = new Float64Array(H); } - var Si = a.INITIAL_MEMORY || 16777216, er, Bs = [], hu = [], Ci = [], tn = false, ic = false, oc = 0; - function fu() { - return se || oc > 0; + var Ni = a.INITIAL_MEMORY || 16777216, Zs, Ls = [], fu = [], Ti = [], nn = false, oc = false, uc = 0; + function mu() { + return se || uc > 0; } - function uc() { + function lc() { if (a.preRun) for (typeof a.preRun == "function" && (a.preRun = [a.preRun]); a.preRun.length; ) - dc(a.preRun.shift()); - gu(Bs); + pc(a.preRun.shift()); + bu(Ls); } - function lc() { - tn = true, gu(hu); + function cc() { + nn = true, bu(fu); } - function Pv() { - ic = true; + function Lv() { + oc = true; } - function cc() { + function dc() { if (a.postRun) for (typeof a.postRun == "function" && (a.postRun = [a.postRun]); a.postRun.length; ) - pc(a.postRun.shift()); - gu(Ci); + hc(a.postRun.shift()); + bu(Ti); } - function dc(H) { - Bs.unshift(H); + function pc(H) { + Ls.unshift(H); } function rs(H) { - hu.unshift(H); + fu.unshift(H); } - function pc(H) { - Ci.unshift(H); + function hc(H) { + Ti.unshift(H); } - var Fn = 0, Ni = null, tr = null; - function sh(H) { + var Fn = 0, $i = null, Js = null; + function ih(H) { Fn++, a.monitorRunDependencies && a.monitorRunDependencies(Fn); } - function hc(H) { - if (Fn--, a.monitorRunDependencies && a.monitorRunDependencies(Fn), Fn == 0 && (Ni !== null && (clearInterval(Ni), Ni = null), tr)) { - var J = tr; - tr = null, J(); + function fc(H) { + if (Fn--, a.monitorRunDependencies && a.monitorRunDependencies(Fn), Fn == 0 && ($i !== null && (clearInterval($i), $i = null), Js)) { + var ee = Js; + Js = null, ee(); } } a.preloadedImages = {}, a.preloadedAudios = {}; function Pr(H) { - a.onAbort && a.onAbort(H), H = "Aborted(" + H + ")", R(H), oe = true, re = 1, H += ". Build with -s ASSERTIONS=1 for more info."; - var J = new WebAssembly.RuntimeError(H); - throw o(J), J; + a.onAbort && a.onAbort(H), H = "Aborted(" + H + ")", R(H), oe = true, ae = 1, H += ". Build with -s ASSERTIONS=1 for more info."; + var ee = new WebAssembly.RuntimeError(H); + throw o(ee), ee; } - var rh = "data:application/octet-stream;base64,"; - function fc(H) { - return H.startsWith(rh); + var oh = "data:application/octet-stream;base64,"; + function mc(H) { + return H.startsWith(oh); } function zr(H) { return H.startsWith("file://"); } - var nn; - nn = "tfjs-backend-wasm.wasm", fc(nn) || (nn = b(nn)); - function mu(H) { + var sn; + sn = "tfjs-backend-wasm.wasm", mc(sn) || (sn = b(sn)); + function gu(H) { try { - if (H == nn && ee) - return new Uint8Array(ee); + if (H == sn && J) + return new Uint8Array(J); if (x) return x(H); throw "both async and sync fetching of the wasm failed"; - } catch (J) { - Pr(J); + } catch (ee) { + Pr(ee); } } - function ah() { - if (!ee && (h || f)) { - if (typeof fetch == "function" && !zr(nn)) - return fetch(nn, { credentials: "same-origin" }).then(function(H) { + function uh() { + if (!J && (h || f)) { + if (typeof fetch == "function" && !zr(sn)) + return fetch(sn, { credentials: "same-origin" }).then(function(H) { if (!H.ok) - throw "failed to load wasm binary file at '" + nn + "'"; + throw "failed to load wasm binary file at '" + sn + "'"; return H.arrayBuffer(); }).catch(function() { - return mu(nn); + return gu(sn); }); if (v) - return new Promise(function(H, J) { - v(nn, function(de) { - H(new Uint8Array(de)); - }, J); + return new Promise(function(H, ee) { + v(sn, function(ce) { + H(new Uint8Array(ce)); + }, ee); }); } return Promise.resolve().then(function() { - return mu(nn); + return gu(sn); }); } - function ih() { - var H = { env: _i, wasi_snapshot_preview1: _i }; - function J(Ve, ze) { - var Tt = Ve.exports; - a.asm = Tt, ne = a.asm.memory, Ls(ne.buffer), er = a.asm.__indirect_function_table, rs(a.asm.__wasm_call_ctors), hc("wasm-instantiate"); + function lh() { + var H = { env: Ei, wasi_snapshot_preview1: Ei }; + function ee(Le, ze) { + var Tt = Le.exports; + a.asm = Tt, ne = a.asm.memory, Ms(ne.buffer), Zs = a.asm.__indirect_function_table, rs(a.asm.__wasm_call_ctors), fc("wasm-instantiate"); } - sh("wasm-instantiate"); - function de(Ve) { - J(Ve.instance); + ih("wasm-instantiate"); + function ce(Le) { + ee(Le.instance); } - function Ie(Ve) { - return ah().then(function(ze) { + function Se(Le) { + return uh().then(function(ze) { return WebAssembly.instantiate(ze, H); }).then(function(ze) { return ze; - }).then(Ve, function(ze) { + }).then(Le, function(ze) { R("failed to asynchronously prepare wasm: " + ze), Pr(ze); }); } function Qe() { - return !ee && typeof WebAssembly.instantiateStreaming == "function" && !fc(nn) && !zr(nn) && typeof fetch == "function" ? fetch(nn, { credentials: "same-origin" }).then(function(Ve) { - var ze = WebAssembly.instantiateStreaming(Ve, H); - return ze.then(de, function(Tt) { - return R("wasm streaming compile failed: " + Tt), R("falling back to ArrayBuffer instantiation"), Ie(de); + return !J && typeof WebAssembly.instantiateStreaming == "function" && !mc(sn) && !zr(sn) && typeof fetch == "function" ? fetch(sn, { credentials: "same-origin" }).then(function(Le) { + var ze = WebAssembly.instantiateStreaming(Le, H); + return ze.then(ce, function(Tt) { + return R("wasm streaming compile failed: " + Tt), R("falling back to ArrayBuffer instantiation"), Se(ce); }); - }) : Ie(de); + }) : Se(ce); } if (a.instantiateWasm) try { - var Ze = a.instantiateWasm(H, J); + var Ze = a.instantiateWasm(H, ee); return Ze; - } catch (Ve) { - return R("Module.instantiateWasm callback failed with error: " + Ve), false; + } catch (Le) { + return R("Module.instantiateWasm callback failed with error: " + Le), false; } return Qe().catch(o), {}; } - var zv, Mv; - function gu(H) { + var Bv, Vv; + function bu(H) { for (; H.length > 0; ) { - var J = H.shift(); - if (typeof J == "function") { - J(a); + var ee = H.shift(); + if (typeof ee == "function") { + ee(a); continue; } - var de = J.func; - typeof de == "number" ? J.arg === void 0 ? bu(de)() : bu(de)(J.arg) : de(J.arg === void 0 ? null : J.arg); + var ce = ee.func; + typeof ce == "number" ? ee.arg === void 0 ? yu(ce)() : yu(ce)(ee.arg) : ce(ee.arg === void 0 ? null : ee.arg); } } - function nr(H) { + function er(H) { return H; } - function mc(H) { - var J = /\b_Z[\w\d_]+/g; - return H.replace(J, function(de) { - var Ie = de; - return de === Ie ? de : Ie + " [" + de + "]"; + function gc(H) { + var ee = /\b_Z[\w\d_]+/g; + return H.replace(ee, function(ce) { + var Se = ce; + return ce === Se ? ce : Se + " [" + ce + "]"; }); } var as = []; - function bu(H) { - var J = as[H]; - return J || (H >= as.length && (as.length = H + 1), as[H] = J = er.get(H)), J; + function yu(H) { + var ee = as[H]; + return ee || (H >= as.length && (as.length = H + 1), as[H] = ee = Zs.get(H)), ee; } - function Lv() { + function Wv() { var H = new Error(); if (!H.stack) { try { throw new Error(); - } catch (J) { - H = J; + } catch (ee) { + H = ee; } if (!H.stack) return "(no stack trace available)"; } return H.stack.toString(); } - function Ti(H, J) { - er.set(H, J), as[H] = J; + function _i(H, ee) { + Zs.set(H, ee), as[H] = ee; } - function oh() { + function ch() { Pr(""); } - function gc(H, J, de) { - Jt.copyWithin(H, J, J + de); + function bc(H, ee, ce) { + en.copyWithin(H, ee, ee + ce); } - function bc() { + function yc() { return 2147483648; } - function sn(H) { + function rn(H) { try { - return ne.grow(H - Sn.byteLength + 65535 >>> 16), Ls(ne.buffer), 1; - } catch (J) { + return ne.grow(H - In.byteLength + 65535 >>> 16), Ms(ne.buffer), 1; + } catch (ee) { } } - function yc(H) { - var J = Jt.length; + function vc(H) { + var ee = en.length; H = H >>> 0; - var de = bc(); - if (H > de) + var ce = yc(); + if (H > ce) return false; - for (var Ie = 1; Ie <= 4; Ie *= 2) { - var Qe = J * (1 + 0.2 / Ie); + for (var Se = 1; Se <= 4; Se *= 2) { + var Qe = ee * (1 + 0.2 / Se); Qe = Math.min(Qe, H + 100663296); - var Ze = Math.min(de, Nt(Math.max(H, Qe), 65536)), Ve = sn(Ze); - if (Ve) + var Ze = Math.min(ce, Nt(Math.max(H, Qe), 65536)), Le = rn(Ze); + if (Le) return true; } return false; } - var $i = { mappings: {}, buffers: [null, [], []], printChar: function(H, J) { - var de = $i.buffers[H]; - J === 0 || J === 10 ? ((H === 1 ? P : R)(Xe(de, 0)), de.length = 0) : de.push(J); + var Ai = { mappings: {}, buffers: [null, [], []], printChar: function(H, ee) { + var ce = Ai.buffers[H]; + ee === 0 || ee === 10 ? ((H === 1 ? P : R)(Xe(ce, 0)), ce.length = 0) : ce.push(ee); }, varargs: void 0, get: function() { - $i.varargs += 4; - var H = Xt[$i.varargs - 4 >> 2]; + Ai.varargs += 4; + var H = Yt[Ai.varargs - 4 >> 2]; return H; }, getStr: function(H) { - var J = Je(H); - return J; - }, get64: function(H, J) { + var ee = Je(H); + return ee; + }, get64: function(H, ee) { return H; } }; - function uh(H) { + function dh(H) { return 0; } - function Bv(H, J, de, Ie, Qe) { + function Uv(H, ee, ce, Se, Qe) { } - function Vv(H, J, de, Ie) { - for (var Qe = 0, Ze = 0; Ze < de; Ze++) { - var Ve = Xt[J >> 2], ze = Xt[J + 4 >> 2]; - J += 8; + function Gv(H, ee, ce, Se) { + for (var Qe = 0, Ze = 0; Ze < ce; Ze++) { + var Le = Yt[ee >> 2], ze = Yt[ee + 4 >> 2]; + ee += 8; for (var Tt = 0; Tt < ze; Tt++) - $i.printChar(H, Jt[Ve + Tt]); + Ai.printChar(H, en[Le + Tt]); Qe += ze; } - return Xt[Ie >> 2] = Qe, 0; + return Yt[Se >> 2] = Qe, 0; } - function lh(H) { + function ph(H) { te(H); } - var vc = false, _i = { abort: oh, emscripten_memcpy_big: gc, emscripten_resize_heap: yc, fd_close: uh, fd_seek: Bv, fd_write: Vv, setTempRet0: lh }, QN = ih(), Wv = a.___wasm_call_ctors = function() { - return (Wv = a.___wasm_call_ctors = a.asm.__wasm_call_ctors).apply(null, arguments); - }, ch = a._init = function() { - return (ch = a._init = a.asm.init).apply(null, arguments); - }, dh = a._init_with_threads_count = function() { - return (dh = a._init_with_threads_count = a.asm.init_with_threads_count).apply(null, arguments); - }, xc = a._get_threads_count = function() { - return (xc = a._get_threads_count = a.asm.get_threads_count).apply(null, arguments); - }, wc = a._register_tensor = function() { - return (wc = a._register_tensor = a.asm.register_tensor).apply(null, arguments); - }, ph = a._dispose_data = function() { - return (ph = a._dispose_data = a.asm.dispose_data).apply(null, arguments); - }, _e = a._dispose = function() { - return (_e = a._dispose = a.asm.dispose).apply(null, arguments); - }, hh = a._Abs = function() { - return (hh = a._Abs = a.asm.Abs).apply(null, arguments); - }, kc = a._Add = function() { - return (kc = a._Add = a.asm.Add).apply(null, arguments); + var xc = false, Ei = { abort: ch, emscripten_memcpy_big: bc, emscripten_resize_heap: vc, fd_close: dh, fd_seek: Uv, fd_write: Gv, setTempRet0: ph }, tT = lh(), Hv = a.___wasm_call_ctors = function() { + return (Hv = a.___wasm_call_ctors = a.asm.__wasm_call_ctors).apply(null, arguments); + }, hh = a._init = function() { + return (hh = a._init = a.asm.init).apply(null, arguments); + }, fh = a._init_with_threads_count = function() { + return (fh = a._init_with_threads_count = a.asm.init_with_threads_count).apply(null, arguments); + }, wc = a._get_threads_count = function() { + return (wc = a._get_threads_count = a.asm.get_threads_count).apply(null, arguments); + }, kc = a._register_tensor = function() { + return (kc = a._register_tensor = a.asm.register_tensor).apply(null, arguments); + }, mh = a._dispose_data = function() { + return (mh = a._dispose_data = a.asm.dispose_data).apply(null, arguments); + }, $e = a._dispose = function() { + return ($e = a._dispose = a.asm.dispose).apply(null, arguments); + }, gh = a._Abs = function() { + return (gh = a._Abs = a.asm.Abs).apply(null, arguments); + }, Sc = a._Add = function() { + return (Sc = a._Add = a.asm.Add).apply(null, arguments); }, Mr = a._AddN = function() { return (Mr = a._AddN = a.asm.AddN).apply(null, arguments); - }, Ai = a._All = function() { - return (Ai = a._All = a.asm.All).apply(null, arguments); - }, fh = a._Any = function() { - return (fh = a._Any = a.asm.Any).apply(null, arguments); - }, Uv = a._ArgMax = function() { - return (Uv = a._ArgMax = a.asm.ArgMax).apply(null, arguments); - }, mh = a._AvgPool = function() { - return (mh = a._AvgPool = a.asm.AvgPool).apply(null, arguments); - }, Gv = a._BatchMatMul = function() { - return (Gv = a._BatchMatMul = a.asm.BatchMatMul).apply(null, arguments); + }, Ri = a._All = function() { + return (Ri = a._All = a.asm.All).apply(null, arguments); + }, bh = a._Any = function() { + return (bh = a._Any = a.asm.Any).apply(null, arguments); + }, qv = a._ArgMax = function() { + return (qv = a._ArgMax = a.asm.ArgMax).apply(null, arguments); + }, yh = a._AvgPool = function() { + return (yh = a._AvgPool = a.asm.AvgPool).apply(null, arguments); + }, jv = a._BatchMatMul = function() { + return (jv = a._BatchMatMul = a.asm.BatchMatMul).apply(null, arguments); }, Lr = a._Ceil = function() { return (Lr = a._Ceil = a.asm.Ceil).apply(null, arguments); - }, gh = a._ClipByValue = function() { - return (gh = a._ClipByValue = a.asm.ClipByValue).apply(null, arguments); - }, bh = a._Conv2D = function() { - return (bh = a._Conv2D = a.asm.Conv2D).apply(null, arguments); - }, yh = a._Conv2DBackpropInput = function() { - return (yh = a._Conv2DBackpropInput = a.asm.Conv2DBackpropInput).apply(null, arguments); - }, vh = a._Cos = function() { - return (vh = a._Cos = a.asm.Cos).apply(null, arguments); - }, xh = a._Cosh = function() { - return (xh = a._Cosh = a.asm.Cosh).apply(null, arguments); - }, wh = a._CropAndResize = function() { - return (wh = a._CropAndResize = a.asm.CropAndResize).apply(null, arguments); + }, vh = a._ClipByValue = function() { + return (vh = a._ClipByValue = a.asm.ClipByValue).apply(null, arguments); + }, xh = a._Conv2D = function() { + return (xh = a._Conv2D = a.asm.Conv2D).apply(null, arguments); + }, wh = a._Conv2DBackpropInput = function() { + return (wh = a._Conv2DBackpropInput = a.asm.Conv2DBackpropInput).apply(null, arguments); + }, kh = a._Cos = function() { + return (kh = a._Cos = a.asm.Cos).apply(null, arguments); + }, Sh = a._Cosh = function() { + return (Sh = a._Cosh = a.asm.Cosh).apply(null, arguments); + }, Ih = a._CropAndResize = function() { + return (Ih = a._CropAndResize = a.asm.CropAndResize).apply(null, arguments); }, Ic = a._Cumprod = function() { return (Ic = a._Cumprod = a.asm.Cumprod).apply(null, arguments); - }, kh = a._Cumsum = function() { - return (kh = a._Cumsum = a.asm.Cumsum).apply(null, arguments); - }, Ih = a._DepthToSpace = function() { - return (Ih = a._DepthToSpace = a.asm.DepthToSpace).apply(null, arguments); - }, Sh = a._DepthwiseConv2dNative = function() { - return (Sh = a._DepthwiseConv2dNative = a.asm.DepthwiseConv2dNative).apply(null, arguments); - }, Ch = a._Elu = function() { - return (Ch = a._Elu = a.asm.Elu).apply(null, arguments); - }, Nh = a._Equal = function() { - return (Nh = a._Equal = a.asm.Equal).apply(null, arguments); - }, Sc = a._Exp = function() { - return (Sc = a._Exp = a.asm.Exp).apply(null, arguments); - }, Th = a._FlipLeftRight = function() { - return (Th = a._FlipLeftRight = a.asm.FlipLeftRight).apply(null, arguments); - }, $h = a._Floor = function() { - return ($h = a._Floor = a.asm.Floor).apply(null, arguments); + }, Ch = a._Cumsum = function() { + return (Ch = a._Cumsum = a.asm.Cumsum).apply(null, arguments); + }, Nh = a._DepthToSpace = function() { + return (Nh = a._DepthToSpace = a.asm.DepthToSpace).apply(null, arguments); + }, Th = a._DepthwiseConv2dNative = function() { + return (Th = a._DepthwiseConv2dNative = a.asm.DepthwiseConv2dNative).apply(null, arguments); + }, $h = a._Elu = function() { + return ($h = a._Elu = a.asm.Elu).apply(null, arguments); + }, _h = a._Equal = function() { + return (_h = a._Equal = a.asm.Equal).apply(null, arguments); + }, Cc = a._Exp = function() { + return (Cc = a._Exp = a.asm.Exp).apply(null, arguments); + }, Ah = a._FlipLeftRight = function() { + return (Ah = a._FlipLeftRight = a.asm.FlipLeftRight).apply(null, arguments); + }, Eh = a._Floor = function() { + return (Eh = a._Floor = a.asm.Floor).apply(null, arguments); }, Br = a._FloorDiv = function() { return (Br = a._FloorDiv = a.asm.FloorDiv).apply(null, arguments); - }, yu = a._FusedBatchNorm = function() { - return (yu = a._FusedBatchNorm = a.asm.FusedBatchNorm).apply(null, arguments); - }, _h = a._FusedConv2D = function() { - return (_h = a._FusedConv2D = a.asm.FusedConv2D).apply(null, arguments); - }, Ah = a._FusedDepthwiseConv2D = function() { - return (Ah = a._FusedDepthwiseConv2D = a.asm.FusedDepthwiseConv2D).apply(null, arguments); - }, Eh = a._Gather = function() { - return (Eh = a._Gather = a.asm.Gather).apply(null, arguments); - }, Be = a._GatherNd = function() { - return (Be = a._GatherNd = a.asm.GatherNd).apply(null, arguments); - }, Rh = a._Greater = function() { - return (Rh = a._Greater = a.asm.Greater).apply(null, arguments); - }, Dh = a._GreaterEqual = function() { - return (Dh = a._GreaterEqual = a.asm.GreaterEqual).apply(null, arguments); - }, Fh = a._LeakyRelu = function() { - return (Fh = a._LeakyRelu = a.asm.LeakyRelu).apply(null, arguments); - }, Oh = a._Less = function() { - return (Oh = a._Less = a.asm.Less).apply(null, arguments); - }, Ph = a._LessEqual = function() { - return (Ph = a._LessEqual = a.asm.LessEqual).apply(null, arguments); - }, zh = a._Log = function() { - return (zh = a._Log = a.asm.Log).apply(null, arguments); - }, vu = a._LogicalAnd = function() { - return (vu = a._LogicalAnd = a.asm.LogicalAnd).apply(null, arguments); - }, Cc = a._Max = function() { - return (Cc = a._Max = a.asm.Max).apply(null, arguments); - }, Nc = a._MaxPool = function() { - return (Nc = a._MaxPool = a.asm.MaxPool).apply(null, arguments); - }, Mh = a._Maximum = function() { - return (Mh = a._Maximum = a.asm.Maximum).apply(null, arguments); - }, Lh = a._Mean = function() { - return (Lh = a._Mean = a.asm.Mean).apply(null, arguments); - }, Bh = a._Min = function() { - return (Bh = a._Min = a.asm.Min).apply(null, arguments); - }, Vh = a._Minimum = function() { - return (Vh = a._Minimum = a.asm.Minimum).apply(null, arguments); - }, Wh = a._MirrorPad = function() { - return (Wh = a._MirrorPad = a.asm.MirrorPad).apply(null, arguments); - }, Uh = a._Multiply = function() { - return (Uh = a._Multiply = a.asm.Multiply).apply(null, arguments); + }, vu = a._FusedBatchNorm = function() { + return (vu = a._FusedBatchNorm = a.asm.FusedBatchNorm).apply(null, arguments); + }, Rh = a._FusedConv2D = function() { + return (Rh = a._FusedConv2D = a.asm.FusedConv2D).apply(null, arguments); + }, Dh = a._FusedDepthwiseConv2D = function() { + return (Dh = a._FusedDepthwiseConv2D = a.asm.FusedDepthwiseConv2D).apply(null, arguments); + }, Fh = a._Gather = function() { + return (Fh = a._Gather = a.asm.Gather).apply(null, arguments); + }, Me = a._GatherNd = function() { + return (Me = a._GatherNd = a.asm.GatherNd).apply(null, arguments); + }, Oh = a._Greater = function() { + return (Oh = a._Greater = a.asm.Greater).apply(null, arguments); + }, Ph = a._GreaterEqual = function() { + return (Ph = a._GreaterEqual = a.asm.GreaterEqual).apply(null, arguments); + }, zh = a._LeakyRelu = function() { + return (zh = a._LeakyRelu = a.asm.LeakyRelu).apply(null, arguments); + }, Mh = a._Less = function() { + return (Mh = a._Less = a.asm.Less).apply(null, arguments); + }, Lh = a._LessEqual = function() { + return (Lh = a._LessEqual = a.asm.LessEqual).apply(null, arguments); + }, Bh = a._Log = function() { + return (Bh = a._Log = a.asm.Log).apply(null, arguments); + }, xu = a._LogicalAnd = function() { + return (xu = a._LogicalAnd = a.asm.LogicalAnd).apply(null, arguments); + }, Nc = a._Max = function() { + return (Nc = a._Max = a.asm.Max).apply(null, arguments); + }, Tc = a._MaxPool = function() { + return (Tc = a._MaxPool = a.asm.MaxPool).apply(null, arguments); + }, Vh = a._Maximum = function() { + return (Vh = a._Maximum = a.asm.Maximum).apply(null, arguments); + }, Wh = a._Mean = function() { + return (Wh = a._Mean = a.asm.Mean).apply(null, arguments); + }, Uh = a._Min = function() { + return (Uh = a._Min = a.asm.Min).apply(null, arguments); + }, Gh = a._Minimum = function() { + return (Gh = a._Minimum = a.asm.Minimum).apply(null, arguments); + }, Hh = a._MirrorPad = function() { + return (Hh = a._MirrorPad = a.asm.MirrorPad).apply(null, arguments); + }, qh = a._Multiply = function() { + return (qh = a._Multiply = a.asm.Multiply).apply(null, arguments); }, gt = a._Neg = function() { return (gt = a._Neg = a.asm.Neg).apply(null, arguments); - }, Gh = a._NonMaxSuppressionV3 = function() { - return (Gh = a._NonMaxSuppressionV3 = a.asm.NonMaxSuppressionV3).apply(null, arguments); - }, Hh = a._NonMaxSuppressionV4 = function() { - return (Hh = a._NonMaxSuppressionV4 = a.asm.NonMaxSuppressionV4).apply(null, arguments); - }, qh = a._NonMaxSuppressionV5 = function() { - return (qh = a._NonMaxSuppressionV5 = a.asm.NonMaxSuppressionV5).apply(null, arguments); - }, Ei = a._NotEqual = function() { - return (Ei = a._NotEqual = a.asm.NotEqual).apply(null, arguments); - }, Tc = a._OneHot = function() { - return (Tc = a._OneHot = a.asm.OneHot).apply(null, arguments); - }, $c = a._PadV2 = function() { - return ($c = a._PadV2 = a.asm.PadV2).apply(null, arguments); - }, _c = a._Pow = function() { - return (_c = a._Pow = a.asm.Pow).apply(null, arguments); - }, jh = a._Prelu = function() { - return (jh = a._Prelu = a.asm.Prelu).apply(null, arguments); - }, Ac = a._Prod = function() { - return (Ac = a._Prod = a.asm.Prod).apply(null, arguments); - }, Kh = a._RealDiv = function() { - return (Kh = a._RealDiv = a.asm.RealDiv).apply(null, arguments); - }, Hv = a._Relu = function() { - return (Hv = a._Relu = a.asm.Relu).apply(null, arguments); - }, Ec = a._Relu6 = function() { - return (Ec = a._Relu6 = a.asm.Relu6).apply(null, arguments); - }, qv = a._ResizeBilinear = function() { - return (qv = a._ResizeBilinear = a.asm.ResizeBilinear).apply(null, arguments); - }, Xh = a._Reverse = function() { - return (Xh = a._Reverse = a.asm.Reverse).apply(null, arguments); - }, Yh = a._RotateWithOffset = function() { - return (Yh = a._RotateWithOffset = a.asm.RotateWithOffset).apply(null, arguments); - }, Qh = a._Round = function() { - return (Qh = a._Round = a.asm.Round).apply(null, arguments); - }, Zh = a._Rsqrt = function() { - return (Zh = a._Rsqrt = a.asm.Rsqrt).apply(null, arguments); - }, Jh = a._ScatterNd = function() { - return (Jh = a._ScatterNd = a.asm.ScatterNd).apply(null, arguments); - }, ef = a._SelectV2 = function() { - return (ef = a._SelectV2 = a.asm.SelectV2).apply(null, arguments); - }, tf = a._Sigmoid = function() { - return (tf = a._Sigmoid = a.asm.Sigmoid).apply(null, arguments); - }, nf = a._Sin = function() { - return (nf = a._Sin = a.asm.Sin).apply(null, arguments); - }, sf = a._Softmax = function() { - return (sf = a._Softmax = a.asm.Softmax).apply(null, arguments); - }, rf = a._SparseFillEmptyRows = function() { - return (rf = a._SparseFillEmptyRows = a.asm.SparseFillEmptyRows).apply(null, arguments); - }, af = a._SparseReshape = function() { - return (af = a._SparseReshape = a.asm.SparseReshape).apply(null, arguments); - }, of = a._SparseSegmentReduction = function() { - return (of = a._SparseSegmentReduction = a.asm.SparseSegmentReduction).apply(null, arguments); - }, uf = a._Sqrt = function() { - return (uf = a._Sqrt = a.asm.Sqrt).apply(null, arguments); - }, lf = a._Square = function() { - return (lf = a._Square = a.asm.Square).apply(null, arguments); - }, cf = a._SquaredDifference = function() { - return (cf = a._SquaredDifference = a.asm.SquaredDifference).apply(null, arguments); - }, df = a._Step = function() { - return (df = a._Step = a.asm.Step).apply(null, arguments); - }, pf = a._StridedSlice = function() { - return (pf = a._StridedSlice = a.asm.StridedSlice).apply(null, arguments); - }, hf = a._Sub = function() { - return (hf = a._Sub = a.asm.Sub).apply(null, arguments); - }, ff = a._Sum = function() { - return (ff = a._Sum = a.asm.Sum).apply(null, arguments); - }, mf = a._Tan = function() { - return (mf = a._Tan = a.asm.Tan).apply(null, arguments); - }, gf = a._Tanh = function() { - return (gf = a._Tanh = a.asm.Tanh).apply(null, arguments); - }, bf = a._Tile = function() { - return (bf = a._Tile = a.asm.Tile).apply(null, arguments); - }, yf = a._TopK = function() { - return (yf = a._TopK = a.asm.TopK).apply(null, arguments); - }, vf = a._Transform = function() { - return (vf = a._Transform = a.asm.Transform).apply(null, arguments); - }, xf = a._Transpose = function() { - return (xf = a._Transpose = a.asm.Transpose).apply(null, arguments); - }, wf = a.__FusedMatMul = function() { - return (wf = a.__FusedMatMul = a.asm._FusedMatMul).apply(null, arguments); - }, kf = a._malloc = function() { - return (kf = a._malloc = a.asm.malloc).apply(null, arguments); - }, If = a._free = function() { - return (If = a._free = a.asm.free).apply(null, arguments); - }, Sf = a.___errno_location = function() { - return (Sf = a.___errno_location = a.asm.__errno_location).apply(null, arguments); - }, Cf = a._emscripten_main_thread_process_queued_calls = function() { - return (Cf = a._emscripten_main_thread_process_queued_calls = a.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); - }, Rc = a.stackSave = function() { - return (Rc = a.stackSave = a.asm.stackSave).apply(null, arguments); - }, Dc = a.stackRestore = function() { - return (Dc = a.stackRestore = a.asm.stackRestore).apply(null, arguments); - }, xu = a.stackAlloc = function() { - return (xu = a.stackAlloc = a.asm.stackAlloc).apply(null, arguments); - }, Nf = a.dynCall_iijjiiii = function() { - return (Nf = a.dynCall_iijjiiii = a.asm.dynCall_iijjiiii).apply(null, arguments); - }, Tf = a.dynCall_jiji = function() { - return (Tf = a.dynCall_jiji = a.asm.dynCall_jiji).apply(null, arguments); + }, jh = a._NonMaxSuppressionV3 = function() { + return (jh = a._NonMaxSuppressionV3 = a.asm.NonMaxSuppressionV3).apply(null, arguments); + }, Kh = a._NonMaxSuppressionV4 = function() { + return (Kh = a._NonMaxSuppressionV4 = a.asm.NonMaxSuppressionV4).apply(null, arguments); + }, Xh = a._NonMaxSuppressionV5 = function() { + return (Xh = a._NonMaxSuppressionV5 = a.asm.NonMaxSuppressionV5).apply(null, arguments); + }, Di = a._NotEqual = function() { + return (Di = a._NotEqual = a.asm.NotEqual).apply(null, arguments); + }, $c = a._OneHot = function() { + return ($c = a._OneHot = a.asm.OneHot).apply(null, arguments); + }, _c = a._PadV2 = function() { + return (_c = a._PadV2 = a.asm.PadV2).apply(null, arguments); + }, Ac = a._Pow = function() { + return (Ac = a._Pow = a.asm.Pow).apply(null, arguments); + }, Yh = a._Prelu = function() { + return (Yh = a._Prelu = a.asm.Prelu).apply(null, arguments); + }, Ec = a._Prod = function() { + return (Ec = a._Prod = a.asm.Prod).apply(null, arguments); + }, Qh = a._RealDiv = function() { + return (Qh = a._RealDiv = a.asm.RealDiv).apply(null, arguments); + }, Kv = a._Relu = function() { + return (Kv = a._Relu = a.asm.Relu).apply(null, arguments); + }, Rc = a._Relu6 = function() { + return (Rc = a._Relu6 = a.asm.Relu6).apply(null, arguments); + }, Xv = a._ResizeBilinear = function() { + return (Xv = a._ResizeBilinear = a.asm.ResizeBilinear).apply(null, arguments); + }, Zh = a._Reverse = function() { + return (Zh = a._Reverse = a.asm.Reverse).apply(null, arguments); + }, Jh = a._RotateWithOffset = function() { + return (Jh = a._RotateWithOffset = a.asm.RotateWithOffset).apply(null, arguments); + }, ef = a._Round = function() { + return (ef = a._Round = a.asm.Round).apply(null, arguments); + }, tf = a._Rsqrt = function() { + return (tf = a._Rsqrt = a.asm.Rsqrt).apply(null, arguments); + }, nf = a._ScatterNd = function() { + return (nf = a._ScatterNd = a.asm.ScatterNd).apply(null, arguments); + }, sf = a._SelectV2 = function() { + return (sf = a._SelectV2 = a.asm.SelectV2).apply(null, arguments); + }, rf = a._Sigmoid = function() { + return (rf = a._Sigmoid = a.asm.Sigmoid).apply(null, arguments); + }, af = a._Sin = function() { + return (af = a._Sin = a.asm.Sin).apply(null, arguments); + }, of = a._Softmax = function() { + return (of = a._Softmax = a.asm.Softmax).apply(null, arguments); + }, uf = a._SparseFillEmptyRows = function() { + return (uf = a._SparseFillEmptyRows = a.asm.SparseFillEmptyRows).apply(null, arguments); + }, lf = a._SparseReshape = function() { + return (lf = a._SparseReshape = a.asm.SparseReshape).apply(null, arguments); + }, cf = a._SparseSegmentReduction = function() { + return (cf = a._SparseSegmentReduction = a.asm.SparseSegmentReduction).apply(null, arguments); + }, df = a._Sqrt = function() { + return (df = a._Sqrt = a.asm.Sqrt).apply(null, arguments); + }, pf = a._Square = function() { + return (pf = a._Square = a.asm.Square).apply(null, arguments); + }, hf = a._SquaredDifference = function() { + return (hf = a._SquaredDifference = a.asm.SquaredDifference).apply(null, arguments); + }, ff = a._Step = function() { + return (ff = a._Step = a.asm.Step).apply(null, arguments); + }, mf = a._StridedSlice = function() { + return (mf = a._StridedSlice = a.asm.StridedSlice).apply(null, arguments); + }, gf = a._Sub = function() { + return (gf = a._Sub = a.asm.Sub).apply(null, arguments); + }, bf = a._Sum = function() { + return (bf = a._Sum = a.asm.Sum).apply(null, arguments); + }, yf = a._Tan = function() { + return (yf = a._Tan = a.asm.Tan).apply(null, arguments); + }, vf = a._Tanh = function() { + return (vf = a._Tanh = a.asm.Tanh).apply(null, arguments); + }, xf = a._Tile = function() { + return (xf = a._Tile = a.asm.Tile).apply(null, arguments); + }, wf = a._TopK = function() { + return (wf = a._TopK = a.asm.TopK).apply(null, arguments); + }, kf = a._Transform = function() { + return (kf = a._Transform = a.asm.Transform).apply(null, arguments); + }, Sf = a._Transpose = function() { + return (Sf = a._Transpose = a.asm.Transpose).apply(null, arguments); + }, If = a.__FusedMatMul = function() { + return (If = a.__FusedMatMul = a.asm._FusedMatMul).apply(null, arguments); + }, Cf = a._malloc = function() { + return (Cf = a._malloc = a.asm.malloc).apply(null, arguments); + }, Nf = a._free = function() { + return (Nf = a._free = a.asm.free).apply(null, arguments); + }, Tf = a.___errno_location = function() { + return (Tf = a.___errno_location = a.asm.__errno_location).apply(null, arguments); + }, $f = a._emscripten_main_thread_process_queued_calls = function() { + return ($f = a._emscripten_main_thread_process_queued_calls = a.asm.emscripten_main_thread_process_queued_calls).apply(null, arguments); + }, Dc = a.stackSave = function() { + return (Dc = a.stackSave = a.asm.stackSave).apply(null, arguments); + }, Fc = a.stackRestore = function() { + return (Fc = a.stackRestore = a.asm.stackRestore).apply(null, arguments); + }, wu = a.stackAlloc = function() { + return (wu = a.stackAlloc = a.asm.stackAlloc).apply(null, arguments); + }, _f = a.dynCall_iijjiiii = function() { + return (_f = a.dynCall_iijjiiii = a.asm.dynCall_iijjiiii).apply(null, arguments); + }, Af = a.dynCall_jiji = function() { + return (Af = a.dynCall_jiji = a.asm.dynCall_jiji).apply(null, arguments); }; - a.cwrap = Se; - var Ri; - function wu(H) { + a.cwrap = Ie; + var Fi; + function ku(H) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + H + ")", this.status = H; } - tr = function H() { - Ri || ku(), Ri || (tr = H); + Js = function H() { + Fi || Su(), Fi || (Js = H); }; - function ku(H) { - if (H = H || c, Fn > 0 || (uc(), Fn > 0)) + function Su(H) { + if (H = H || c, Fn > 0 || (lc(), Fn > 0)) return; - function J() { - Ri || (Ri = true, a.calledRun = true, !oe && (lc(), i(a), a.onRuntimeInitialized && a.onRuntimeInitialized(), cc())); + function ee() { + Fi || (Fi = true, a.calledRun = true, !oe && (cc(), i(a), a.onRuntimeInitialized && a.onRuntimeInitialized(), dc())); } a.setStatus ? (a.setStatus("Running..."), setTimeout(function() { setTimeout(function() { a.setStatus(""); - }, 1), J(); - }, 1)) : J(); + }, 1), ee(); + }, 1)) : ee(); } - a.run = ku; - function jv(H) { - re = H, fu() || (a.onExit && a.onExit(H), oe = true), d(H, new wu(H)); + a.run = Su; + function Yv(H) { + ae = H, mu() || (a.onExit && a.onExit(H), oe = true), d(H, new ku(H)); } if (a.preInit) for (typeof a.preInit == "function" && (a.preInit = [a.preInit]); a.preInit.length > 0; ) a.preInit.pop()(); - ku(); - var Di; - u && (Di = { uncaughtException: process.listeners("uncaughtException").filter(function(H) { + Su(); + var Oi; + u && (Oi = { uncaughtException: process.listeners("uncaughtException").filter(function(H) { return !u.uncaughtException.indexOf(H) > -1; }), unhandledRejection: process.listeners("unhandledRejection").filter(function(H) { return !u.unhandledRejection.indexOf(H) > -1; }) }); - var Fi; + var Pi; if (typeof r != "undefined") - Fi = r; + Pi = r; else if (typeof WasmBackendModuleThreadedSimd != "undefined") - Fi = WasmBackendModuleThreadedSimd; + Pi = WasmBackendModuleThreadedSimd; else throw new Error("Could not find wasm module in post.js"); - if (Di) { - var $f = Fi._dispose; - Fi._dispose = function() { - $f(), Di.uncaughtException.forEach(function(H) { + if (Oi) { + var Ef = Pi._dispose; + Pi._dispose = function() { + Ef(), Oi.uncaughtException.forEach(function(H) { process.removeListener("uncaughtException", H); - }), Di.unhandledRejection.forEach(function(H) { + }), Oi.unhandledRejection.forEach(function(H) { process.removeListener("unhandledRejection", H); }); }; @@ -3283,9 +3289,9 @@ var d$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { return n; }) : typeof e == "object" && (e.WasmBackendModule = n); } }); -var p$ = 1e-7; -var h$ = 1e-4; -var Hd = class { +var g$ = 1e-7; +var b$ = 1e-4; +var Kd = class { constructor(e, t) { this.backend = e, this.dataMover = t, this.data = /* @__PURE__ */ new WeakMap(), this.dataIdsCount = 0; } @@ -3305,7 +3311,7 @@ var Hd = class { return this.dataIdsCount; } }; -var sl = class { +var rl = class { refCount(e) { return On("refCount"); } @@ -3346,7 +3352,7 @@ var sl = class { return On("floatPrecision"); } epsilon() { - return this.floatPrecision() === 32 ? p$ : h$; + return this.floatPrecision() === 32 ? g$ : b$; } dispose() { return On("dispose"); @@ -3355,39 +3361,39 @@ var sl = class { function On(e) { throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`); } -function Kw(e) { +function Qw(e) { let t = e.length, n = 0; for (; t > 0; ) - n = Math.random() * t | 0, t--, pd(e, t, n); + n = Math.random() * t | 0, t--, md(e, t, n); } -function f$(e, t) { +function y$(e, t) { if (e.length !== t.length) throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`); let n = e.length, s = 0; for (; n > 0; ) - s = Math.random() * n | 0, n--, pd(e, n, s), pd(t, n, s); + s = Math.random() * n | 0, n--, md(e, n, s), md(t, n, s); } -function Wu(e, t, n) { +function Uu(e, t, n) { return Math.max(e, Math.min(t, n)); } -function m$(e) { +function v$(e) { return e % 2 === 0 ? e : e + 1; } -function pd(e, t, n) { +function md(e, t, n) { let s = e[t]; e[t] = e[n], e[n] = s; } -function g$(e) { +function x$(e) { let t = 0; for (let n = 0; n < e.length; n++) t += e[n]; return t; } -function b$(e, t) { +function w$(e, t) { let n = Math.random(); return t * n + (1 - n) * e; } -function y$(e, t) { +function k$(e, t) { let n = 0; for (let s = 0; s < e.length; s++) { let r = Number(e[s]) - Number(t[s]); @@ -3400,20 +3406,20 @@ function O(e, t) { throw new Error(typeof t == "string" ? t : t()); } function pn(e, t, n = "") { - O(Ir(e, t), () => n + ` Shapes ${e} and ${t} must match`); + O(kr(e, t), () => n + ` Shapes ${e} and ${t} must match`); } function ka(e) { O(e != null, () => "The input to the tensor constructor must be a non-null value."); } function ra(e, t = [], n = false) { - if (t == null && (t = []), Array.isArray(e) || Yt(e) && !n) + if (t == null && (t = []), Array.isArray(e) || Qt(e) && !n) for (let s = 0; s < e.length; ++s) ra(e[s], t, n); else t.push(e); return t; } -function pt(e) { +function dt(e) { if (e.length === 0) return 1; let t = e[0]; @@ -3421,10 +3427,10 @@ function pt(e) { t *= e[n]; return t; } -function v$(e) { +function S$(e) { return e.length === 0; } -function Ir(e, t) { +function kr(e, t) { if (e === t) return true; if (e == null || t == null || e.length !== t.length) @@ -3434,10 +3440,10 @@ function Ir(e, t) { return false; return true; } -function Zi(e) { +function eo(e) { return e % 1 === 0; } -function x$(e) { +function I$(e) { if (Math.tanh != null) return Math.tanh(e); if (e === 1 / 0) @@ -3449,20 +3455,20 @@ function x$(e) { return (t - 1) / (t + 1); } } -function w$(e) { +function C$(e) { let t = Math.ceil(Math.sqrt(e)); return [t, Math.ceil(e / t)]; } -function k$(e) { +function N$(e) { let t = new Uint32Array(e); for (let n = 0; n < e; ++n) t[n] = n; - return Kw(t), t; + return Qw(t), t; } -function Mu(e, t) { +function Lu(e, t) { return t <= e.length ? e : e + " ".repeat(t - e.length); } -function I$(e, t = (s) => 0, n) { +function T$(e, t = (s) => 0, n) { return new Promise((s, r) => { let a = 0, i = () => { if (e()) { @@ -3480,7 +3486,7 @@ function I$(e, t = (s) => 0, n) { i(); }); } -function S$(e, t) { +function $$(e, t) { let n = 1, s = -1; for (let a = 0; a < e.length; ++a) if (e[a] >= 0) @@ -3505,9 +3511,9 @@ function S$(e, t) { } function ts(e, t) { let n = t.length; - return e = e == null ? t.map((s, r) => r) : [].concat(e), O(e.every((s) => s >= -n && s < n), () => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`), O(e.every((s) => Zi(s)), () => `All values in axis param must be integers but got axis ${e}`), e.map((s) => s < 0 ? n + s : s); + return e = e == null ? t.map((s, r) => r) : [].concat(e), O(e.every((s) => s >= -n && s < n), () => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`), O(e.every((s) => eo(s)), () => `All values in axis param must be integers but got axis ${e}`), e.map((s) => s < 0 ? n + s : s); } -function Xw(e, t) { +function Zw(e, t) { let n = [], s = [], r = t != null && Array.isArray(t) && t.length === 0, a = t == null || r ? null : ts(t, e).sort(), i = 0; for (let o = 0; o < e.length; ++o) { if (a != null) { @@ -3519,7 +3525,7 @@ function Xw(e, t) { } return { newShape: n, keptDims: s }; } -function Yw(e, t) { +function Jw(e, t) { let n = null; if (e == null || e === "float32") n = new Float32Array(t); @@ -3531,7 +3537,7 @@ function Yw(e, t) { throw new Error(`Unknown data type ${e}`); return n; } -function Qw(e, t) { +function ek(e, t) { let n = null; if (e == null || e === "float32") n = new Float32Array(t); @@ -3545,23 +3551,23 @@ function Qw(e, t) { throw new Error(`Unknown data type ${e}`); return n; } -function Zw(e, t) { +function tk(e, t) { for (let n = 0; n < e.length; n++) { let s = e[n]; if (isNaN(s) || !isFinite(s)) throw Error(`A tensor of type ${t} being uploaded contains ${s}.`); } } -function Jw(e) { +function nk(e) { return e === "bool" || e === "complex64" || e === "float32" || e === "int32" || e === "string"; } -function C$(e, t) { +function _$(e, t) { return !(t === "complex64" || t === "float32" && e !== "complex64" || t === "int32" && e !== "float32" && e !== "complex64" || t === "bool" && e === "bool"); } -function Yt(e) { +function Qt(e) { return e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray; } -function Yf(e) { +function Jf(e) { if (e === "float32" || e === "int32") return 4; if (e === "complex64") @@ -3570,34 +3576,34 @@ function Yf(e) { return 1; throw new Error(`Unknown dtype ${e}`); } -function ek(e) { +function sk(e) { if (e == null) return 0; let t = 0; return e.forEach((n) => t += n.length), t; } -function or(e) { +function ar(e) { return typeof e == "string" || e instanceof String; } -function tk(e) { +function rk(e) { return typeof e == "boolean"; } -function nk(e) { +function ak(e) { return typeof e == "number"; } -function qd(e) { - return Array.isArray(e) ? qd(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : nk(e) ? "float32" : or(e) ? "string" : tk(e) ? "bool" : "float32"; +function Xd(e) { + return Array.isArray(e) ? Xd(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : ak(e) ? "float32" : ar(e) ? "string" : rk(e) ? "bool" : "float32"; } -function fr(e) { +function hr(e) { return !!(e && e.constructor && e.call && e.apply); } -function hd(e, t) { +function gd(e, t) { for (let n = t; n < e; ++n) if (e % n === 0) return n; return e; } -function oo(e) { +function lo(e) { let t = e.length; if (t < 2) return []; @@ -3607,7 +3613,7 @@ function oo(e) { n[s] = n[s + 1] * e[s + 1]; return n; } -function sk(e, t, n, s = false) { +function ik(e, t, n, s = false) { let r = new Array(); if (t.length === 1) { let a = t[0] * (s ? 2 : 1); @@ -3616,11 +3622,11 @@ function sk(e, t, n, s = false) { } else { let a = t[0], i = t.slice(1), o = i.reduce((u, l) => u * l) * (s ? 2 : 1); for (let u = 0; u < a; u++) - r[u] = sk(e + u * o, i, n, s); + r[u] = ik(e + u * o, i, n, s); } return r; } -function ji(e, t, n = false) { +function Xi(e, t, n = false) { if (e.length === 0) return t[0]; let s = e.reduce((r, a) => r * a) * (n ? 2 : 1); @@ -3628,15 +3634,15 @@ function ji(e, t, n = false) { return []; if (s !== t.length) throw new Error(`[${e}] does not match the input size ${t.length}${n ? " for a complex tensor" : ""}.`); - return sk(0, e, t, n); + return ik(0, e, t, n); } -function rg(e, t) { - let n = jd(e, t); +function ig(e, t) { + let n = Yd(e, t); for (let s = 0; s < n.length; s++) n[s] = 1; return n; } -function jd(e, t) { +function Yd(e, t) { if (t == null || t === "float32" || t === "complex64") return new Float32Array(e); if (t === "int32") @@ -3645,22 +3651,22 @@ function jd(e, t) { return new Uint8Array(e); throw new Error(`Unknown data type ${t}`); } -function N$(e, t) { +function A$(e, t) { let n = e.reduce((s, r) => s * r, 1); if (t == null || t === "float32") - return ji(e, new Float32Array(n)); + return Xi(e, new Float32Array(n)); if (t === "int32") - return ji(e, new Int32Array(n)); + return Xi(e, new Int32Array(n)); if (t === "bool") - return ji(e, new Uint8Array(n)); + return Xi(e, new Uint8Array(n)); throw new Error(`Unknown data type ${t}`); } -function ag(e) { +function og(e) { e.forEach((t) => { O(Number.isInteger(t) && t >= 0, () => `Tensor must have a shape comprised of positive integers but got shape [${e}].`); }); } -function T$(e, t, n) { +function E$(e, t, n) { if (t === 0) return 0; if (t === 1) @@ -3670,7 +3676,7 @@ function T$(e, t, n) { s += n[r] * e[r]; return s; } -function $$(e, t, n) { +function R$(e, t, n) { if (t === 0) return []; if (t === 1) @@ -3680,21 +3686,21 @@ function $$(e, t, n) { s[r] = Math.floor(e / n[r]), e -= s[r] * n[r]; return s[s.length - 1] = e, s; } -function ig(e) { +function ug(e) { return e && e.then && typeof e.then == "function"; } -var sx = "tfjsflags"; -var _$ = class { +var ix = "tfjsflags"; +var D$ = class { constructor(e) { - this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = A$, this.populateURLFlags(); + this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = F$, this.populateURLFlags(); } setPlatform(e, t) { - this.platform != null && (X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)), this.platformName = e, this.platform = t; + this.platform != null && (K().getBool("IS_TEST") || K().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)), this.platformName = e, this.platform = t; } registerFlag(e, t, n) { if (this.flagRegistry[e] = { evaluationFn: t, setHook: n }, this.urlFlags[e] != null) { let s = this.urlFlags[e]; - X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(`Setting feature override from URL ${e}: ${s}.`), this.set(e, s); + K().getBool("IS_TEST") || K().getBool("PROD") || console.warn(`Setting feature override from URL ${e}: ${s}.`), this.set(e, s); } } async getAsync(e) { @@ -3704,7 +3710,7 @@ var _$ = class { if (e in this.flags) return this.flags[e]; let t = this.evaluateFlag(e); - if (ig(t)) + if (ug(t)) throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`); return this.flags[e] = t, this.flags[e]; } @@ -3740,36 +3746,36 @@ var _$ = class { if (typeof this.global == "undefined" || typeof this.global.location == "undefined" || typeof this.global.location.search == "undefined") return; let e = this.getQueryParams(this.global.location.search); - sx in e && e[sx].split(",").forEach((n) => { + ix in e && e[ix].split(",").forEach((n) => { let [s, r] = n.split(":"); - this.urlFlags[s] = R$(s, r); + this.urlFlags[s] = P$(s, r); }); } }; -function A$(e) { +function F$(e) { let t = {}; - return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (n, ...s) => (E$(t, s[0], s[1]), s.join("="))), t; + return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, (n, ...s) => (O$(t, s[0], s[1]), s.join("="))), t; } -function E$(e, t, n) { +function O$(e, t, n) { e[decodeURIComponent(t)] = decodeURIComponent(n || ""); } -function R$(e, t) { +function P$(e, t) { if (t = t.toLowerCase(), t === "true" || t === "false") return t === "true"; if (`${+t}` === t) return +t; throw new Error(`Could not parse value flag value ${t} for flag ${e}.`); } -function X() { - return rk; +function K() { + return ok; } -var rk = null; -function D$(e) { - rk = e; +var ok = null; +function z$(e) { + ok = e; } -var Of; -function ak() { - if (Of == null) { +var Mf; +function uk() { + if (Mf == null) { let e; if (typeof window != "undefined") e = window; @@ -3781,16 +3787,16 @@ function ak() { e = self; else throw new Error("Could not find a global object"); - Of = e; + Mf = e; } - return Of; + return Mf; } -function F$() { - let e = ak(); +function M$() { + let e = uk(); return e._tfGlobals == null && (e._tfGlobals = /* @__PURE__ */ new Map()), e._tfGlobals; } -function og(e, t) { - let n = F$(); +function lg(e, t) { + let n = M$(); if (n.has(e)) return n.get(e); { @@ -3798,191 +3804,194 @@ function og(e, t) { return n.set(e, s), n.get(e); } } -var uo = "Abs"; -var rl = "Acos"; -var al = "Acosh"; +var co = "Abs"; +var al = "Acos"; +var il = "Acosh"; var Sr = "Add"; -var Ia = "AddN"; -var il = "All"; -var ol = "Any"; -var Sa = "ArgMax"; -var ul = "ArgMin"; -var ll = "Asin"; -var cl = "Asinh"; -var dl = "Atan"; -var pl = "Atanh"; -var hl = "Atan2"; +var Sa = "AddN"; +var ol = "All"; +var ul = "Any"; +var Ia = "ArgMax"; +var ll = "ArgMin"; +var cl = "Asin"; +var dl = "Asinh"; +var pl = "Atan"; +var hl = "Atanh"; +var fl = "Atan2"; var Ca = "AvgPool"; -var ug = "AvgPoolGrad"; -var Kd = "AvgPool3D"; -var lg = "AvgPool3DGrad"; +var cg = "AvgPoolGrad"; +var Qd = "AvgPool3D"; +var dg = "AvgPool3DGrad"; var Na = "BatchMatMul"; -var lo = "BatchToSpaceND"; -var cg = "Bincount"; -var O$ = "BroadcastTo"; -var dg = "BroadcastArgs"; +var po = "BatchToSpaceND"; +var pg = "Bincount"; +var L$ = "BroadcastTo"; +var hg = "BroadcastArgs"; var Ta = "Cast"; var $a = "Ceil"; -var Cr = "ClipByValue"; -var Xd = "Complex"; -var Yd = "ComplexAbs"; -var co = "Concat"; +var Ir = "ClipByValue"; +var Zd = "Complex"; +var Jd = "ComplexAbs"; +var ho = "Concat"; var _a = "Conv2D"; -var pg = "Conv2DBackpropFilter"; +var fg = "Conv2DBackpropFilter"; var Aa = "Conv2DBackpropInput"; -var Qd = "Conv3D"; -var hg = "Conv3DBackpropFilterV2"; -var fg = "Conv3DBackpropInputV2"; +var ep = "Conv3D"; +var mg = "Conv3DBackpropFilterV2"; +var gg = "Conv3DBackpropInputV2"; var Ea = "Cos"; var Ra = "Cosh"; -var po = "Cumprod"; +var fo = "Cumprod"; var Da = "Cumsum"; -var ho = "CropAndResize"; -var mg = "DenseBincount"; -var fo = "DepthToSpace"; +var mo = "CropAndResize"; +var bg = "DenseBincount"; +var go = "DepthToSpace"; var Fa = "DepthwiseConv2dNative"; -var gg = "DepthwiseConv2dNativeBackpropFilter"; -var bg = "DepthwiseConv2dNativeBackpropInput"; -var yg = "Diag"; -var Zd = "Dilation2D"; -var Qf = "Dilation2DBackpropInput"; -var Zf = "Dilation2DBackpropFilter"; +var yg = "DepthwiseConv2dNativeBackpropFilter"; +var vg = "DepthwiseConv2dNativeBackpropInput"; +var xg = "Diag"; +var tp = "Dilation2D"; +var em = "Dilation2DBackpropInput"; +var tm = "Dilation2DBackpropFilter"; var Oa = "RealDiv"; -var Jd = "Einsum"; +var np = "Einsum"; var Pa = "Elu"; -var vg = "EluGrad"; -var fl = "Erf"; -var mo = "Equal"; +var wg = "EluGrad"; +var ml = "Erf"; +var bo = "Equal"; var za = "Exp"; -var go = "ExpandDims"; -var bo = "Expm1"; -var xg = "FFT"; -var ml = "Fill"; -var yo = "FlipLeftRight"; +var yo = "ExpandDims"; +var vo = "Expm1"; +var kg = "FFT"; +var gl = "Fill"; +var xo = "FlipLeftRight"; var Ma = "Floor"; var La = "FloorDiv"; var Ba = "FusedBatchNorm"; -var vo = "GatherV2"; -var xo = "GatherNd"; -var wo = "Greater"; +var wo = "GatherV2"; +var ko = "GatherNd"; +var So = "Greater"; var Va = "GreaterEqual"; var Wa = "Identity"; -var wg = "IFFT"; -var ep = "Imag"; -var gl = "IsFinite"; -var bl = "IsInf"; -var yl = "IsNan"; +var Sg = "IFFT"; +var sp = "Imag"; +var bl = "IsFinite"; +var yl = "IsInf"; +var vl = "IsNan"; var Ua = "LeakyRelu"; -var ko = "Less"; -var Io = "LessEqual"; -var kg = "LinSpace"; +var Io = "Less"; +var Co = "LessEqual"; +var Ig = "LinSpace"; var Ga = "Log"; -var vl = "Log1p"; -var So = "LogicalAnd"; -var xl = "LogicalNot"; -var tp = "LogicalOr"; -var P$ = "LogSoftmax"; -var np = "LRN"; -var Ig = "LRNGrad"; +var xl = "Log1p"; +var No = "LogicalAnd"; +var wl = "LogicalNot"; +var rp = "LogicalOr"; +var B$ = "LogSoftmax"; +var tpe = "LowerBound"; +var ap = "LRN"; +var Cg = "LRNGrad"; var Ha = "Max"; var qa = "Maximum"; var ja = "MaxPool"; -var Sg = "MaxPoolGrad"; -var sp = "MaxPool3D"; -var Cg = "MaxPool3DGrad"; -var Ng = "MaxPoolWithArgmax"; +var Ng = "MaxPoolGrad"; +var ip = "MaxPool3D"; +var Tg = "MaxPool3DGrad"; +var $g = "MaxPoolWithArgmax"; var Ka = "Mean"; var Xa = "Min"; var Ya = "Minimum"; var Qa = "MirrorPad"; -var wl = "Mod"; -var Tg = "Multinomial"; +var kl = "Mod"; +var _g = "Multinomial"; var Za = "Multiply"; -var Co = "Neg"; -var No = "NotEqual"; -var To = "NonMaxSuppressionV3"; -var kl = "NonMaxSuppressionV4"; -var $o = "NonMaxSuppressionV5"; -var _o = "OnesLike"; -var Ao = "OneHot"; -var Eo = "Pack"; +var To = "Neg"; +var $o = "NotEqual"; +var _o = "NonMaxSuppressionV3"; +var Sl = "NonMaxSuppressionV4"; +var Ao = "NonMaxSuppressionV5"; +var Eo = "OnesLike"; +var Ro = "OneHot"; +var Do = "Pack"; var Ja = "PadV2"; -var Wde = "Pool"; +var npe = "Pool"; var ei = "Pow"; var ti = "Prelu"; var ni = "Prod"; var Il = "Range"; -var rp = "Real"; -var Sl = "Reciprocal"; +var op = "Real"; +var Cl = "Reciprocal"; var si = "Relu"; -var Ro = "Reshape"; -var Cl = "ResizeNearestNeighbor"; -var $g = "ResizeNearestNeighborGrad"; +var Fo = "Reshape"; +var Nl = "ResizeNearestNeighbor"; +var Ag = "ResizeNearestNeighborGrad"; var ri = "ResizeBilinear"; -var _g = "ResizeBilinearGrad"; +var Eg = "ResizeBilinearGrad"; var ai = "Relu6"; -var Do = "Reverse"; -var Fo = "Round"; +var Oo = "Reverse"; +var Po = "Round"; var ii = "Rsqrt"; -var Oo = "ScatterNd"; -var Po = "Select"; -var Nl = "Selu"; -var zo = "Slice"; +var zo = "ScatterNd"; +var Rg = "SearchSorted"; +var Mo = "Select"; +var Tl = "Selu"; +var Lo = "Slice"; var oi = "Sin"; -var Mo = "Sinh"; -var Tl = "Sign"; +var Bo = "Sinh"; +var $l = "Sign"; var ui = "Sigmoid"; -var $l = "Softplus"; +var _l = "Softplus"; var li = "Sqrt"; var ci = "Sum"; -var Lo = "SpaceToBatchND"; -var Bo = "SplitV"; +var Vo = "SpaceToBatchND"; +var Wo = "SplitV"; var di = "Softmax"; -var ap = "SparseFillEmptyRows"; -var _l = "SparseReshape"; -var ip = "SparseSegmentMean"; -var op = "SparseSegmentSum"; -var up = "SparseToDense"; +var up = "SparseFillEmptyRows"; +var Al = "SparseReshape"; +var lp = "SparseSegmentMean"; +var cp = "SparseSegmentSum"; +var dp = "SparseToDense"; var pi = "SquaredDifference"; -var Al = "Square"; -var Vo = "StridedSlice"; -var lp = "StringNGrams"; -var Ag = "StringSplit"; -var Eg = "StringToHashBucketFast"; +var El = "Square"; +var Uo = "StridedSlice"; +var pp = "StringNGrams"; +var Dg = "StringSplit"; +var Fg = "StringToHashBucketFast"; var hi = "Sub"; -var Wo = "Tan"; +var Go = "Tan"; var fi = "Tanh"; -var Nr = "Tile"; -var Uo = "TopK"; -var Go = "Transform"; +var Cr = "Tile"; +var Ho = "TopK"; +var qo = "Transform"; var mi = "Transpose"; -var Rg = "Unique"; -var Ho = "Unpack"; -var cp = "UnsortedSegmentSum"; -var qo = "ZerosLike"; +var Og = "Unique"; +var jo = "Unpack"; +var hp = "UnsortedSegmentSum"; +var spe = "UpperBound"; +var Ko = "ZerosLike"; var gi = "Step"; -var fd = "FromPixels"; -var jo = "RotateWithOffset"; +var bd = "FromPixels"; +var Xo = "RotateWithOffset"; var aa = "_FusedMatMul"; var ia = "FusedConv2D"; var oa = "FusedDepthwiseConv2D"; -function ir(...e) { - X().getBool("IS_TEST") || X().getBool("PROD") || console.warn(...e); +function rr(...e) { + K().getBool("IS_TEST") || K().getBool("PROD") || console.warn(...e); } -function z$(...e) { - X().getBool("IS_TEST") || X().getBool("PROD") || console.log(...e); +function V$(...e) { + K().getBool("IS_TEST") || K().getBool("PROD") || console.log(...e); } -var Ji = og("kernelRegistry", () => /* @__PURE__ */ new Map()); -var Uu = og("gradRegistry", () => /* @__PURE__ */ new Map()); -function Jf(e, t) { - let n = Dg(e, t); - return Ji.get(n); +var to = lg("kernelRegistry", () => /* @__PURE__ */ new Map()); +var Gu = lg("gradRegistry", () => /* @__PURE__ */ new Map()); +function nm(e, t) { + let n = Pg(e, t); + return to.get(n); } -function rx(e) { - return Uu.get(e); +function ox(e) { + return Gu.get(e); } -function em(e) { - let t = Ji.entries(), n = []; +function sm(e) { + let t = to.entries(), n = []; for (; ; ) { let { done: s, value: r } = t.next(); if (s) @@ -3992,122 +4001,122 @@ function em(e) { } return n; } -function El(e) { - let { kernelName: t, backendName: n } = e, s = Dg(t, n); - Ji.has(s) && ir(`The kernel '${t}' for backend '${n}' is already registered`), Ji.set(s, e); +function Rl(e) { + let { kernelName: t, backendName: n } = e, s = Pg(t, n); + to.has(s) && rr(`The kernel '${t}' for backend '${n}' is already registered`), to.set(s, e); } -function M$(e) { +function W$(e) { let { kernelName: t } = e; - Uu.has(t) && X().getBool("DEBUG") && ir(`Overriding the gradient for '${t}'`), Uu.set(t, e); + Gu.has(t) && K().getBool("DEBUG") && rr(`Overriding the gradient for '${t}'`), Gu.set(t, e); } -function Ude(e, t) { - let n = Dg(e, t); - if (!Ji.has(n)) +function rpe(e, t) { + let n = Pg(e, t); + if (!to.has(n)) throw new Error(`The kernel '${e}' for backend '${t}' is not registered`); - Ji.delete(n); + to.delete(n); } -function Gde(e) { - if (!Uu.has(e)) +function ape(e) { + if (!Gu.has(e)) throw new Error(`The gradient '${e}' for backend is not registered`); - Uu.delete(e); + Gu.delete(e); } -function Hde(e, t) { - em(e).forEach((s) => { +function ipe(e, t) { + sm(e).forEach((s) => { let r = Object.assign({}, s, { backendName: t }); - El(r); + Rl(r); }); } -function Dg(e, t) { +function Pg(e, t) { return `${t}_${e}`; } var w = {}; -Ae(w, { arraysEqual: () => Ir, assert: () => O, assertNonNegativeIntegerDimensions: () => ag, assertNonNull: () => ka, assertShapesMatch: () => pn, bytesFromStringArray: () => ek, bytesPerElement: () => Yf, checkConversionForErrors: () => Zw, clamp: () => Wu, computeStrides: () => oo, createScalarValue: () => G$, createShuffledIndices: () => k$, decodeString: () => md, distSquared: () => y$, encodeString: () => Dl, fetch: () => q$, fingerPrint64: () => U$, flatten: () => ra, getArrayFromDType: () => Qw, getTypedArrayFromDType: () => Yw, hasEncodingLoss: () => C$, hexToLong: () => Rl, indexToLoc: () => $$, inferDtype: () => qd, inferFromImplicitShape: () => S$, isBoolean: () => tk, isFunction: () => fr, isInt: () => Zi, isNumber: () => nk, isPromise: () => ig, isScalarShape: () => v$, isString: () => or, isTypedArray: () => Yt, isValidDtype: () => Jw, locToIndex: () => T$, makeOnesTypedArray: () => rg, makeZerosNestedTypedArray: () => N$, makeZerosTypedArray: () => jd, nearestDivisor: () => hd, nearestLargerEven: () => m$, now: () => Gu, parseAxisParam: () => ts, randUniform: () => b$, repeatedTry: () => I$, rightPad: () => Mu, shuffle: () => Kw, shuffleCombo: () => f$, sizeFromShape: () => pt, sizeToSquarishShape: () => w$, squeezeShape: () => Xw, sum: () => g$, swap: () => pd, tanh: () => x$, toNestedArray: () => ji, toTypedArray: () => dp }); -var ax = wa(YT()); -var jr = ax.default || ax; -function Rl(e) { +Ae(w, { arraysEqual: () => kr, assert: () => O, assertNonNegativeIntegerDimensions: () => og, assertNonNull: () => ka, assertShapesMatch: () => pn, bytesFromStringArray: () => sk, bytesPerElement: () => Jf, checkConversionForErrors: () => tk, clamp: () => Uu, computeStrides: () => lo, createScalarValue: () => K$, createShuffledIndices: () => N$, decodeString: () => yd, distSquared: () => k$, encodeString: () => Fl, fetch: () => Y$, fingerPrint64: () => j$, flatten: () => ra, getArrayFromDType: () => ek, getTypedArrayFromDType: () => Jw, hasEncodingLoss: () => _$, hexToLong: () => Dl, indexToLoc: () => R$, inferDtype: () => Xd, inferFromImplicitShape: () => $$, isBoolean: () => rk, isFunction: () => hr, isInt: () => eo, isNumber: () => ak, isPromise: () => ug, isScalarShape: () => S$, isString: () => ar, isTypedArray: () => Qt, isValidDtype: () => nk, locToIndex: () => E$, makeOnesTypedArray: () => ig, makeZerosNestedTypedArray: () => A$, makeZerosTypedArray: () => Yd, nearestDivisor: () => gd, nearestLargerEven: () => v$, now: () => Hu, parseAxisParam: () => ts, randUniform: () => w$, repeatedTry: () => T$, rightPad: () => Lu, shuffle: () => Qw, shuffleCombo: () => y$, sizeFromShape: () => dt, sizeToSquarishShape: () => C$, squeezeShape: () => Zw, sum: () => x$, swap: () => md, tanh: () => I$, toNestedArray: () => Xi, toTypedArray: () => fp }); +var ux = wa(e$()); +var jr = ux.default || ux; +function Dl(e) { return jr.fromString(e, true, 16); } -var ik = Rl("c3a5c85c97cb3127"); -var Hr = Rl("b492b66fbe98f273"); -var an = Rl("9ae16a3b2f90404f"); -function tm(e) { +var lk = Dl("c3a5c85c97cb3127"); +var Hr = Dl("b492b66fbe98f273"); +var on = Dl("9ae16a3b2f90404f"); +function rm(e) { return e.xor(e.shru(47)); } -function ok(e, t, n) { +function ck(e, t, n) { let s = e.slice(t, t + n); return jr.fromBytes(Array.from(s), true, true); } function lt(e, t) { - return ok(e, t, 8); + return ck(e, t, 8); } -function ix(e, t) { - return ok(e, t, 4); +function lx(e, t) { + return ck(e, t, 4); } -function Lt(e, t) { +function Bt(e, t) { return t === 0 ? e : e.shru(t).or(e.shl(64 - t)); } -function lr(e, t, n = Rl("9ddfea08eb382d69")) { +function or(e, t, n = Dl("9ddfea08eb382d69")) { let s = e.xor(t).mul(n); s = s.xor(s.shru(47)); let r = t.xor(s).mul(n); return r = r.xor(r.shru(47)), r = r.mul(n), r; } -function L$(e, t, n, s, r, a) { - r = r.add(e), a = Lt(a.add(r).add(s), 21); +function U$(e, t, n, s, r, a) { + r = r.add(e), a = Bt(a.add(r).add(s), 21); let i = r; - return r = r.add(t), r = r.add(n), a = a.add(Lt(r, 44)), [r.add(s), a.add(i)]; + return r = r.add(t), r = r.add(n), a = a.add(Bt(r, 44)), [r.add(s), a.add(i)]; } -function Vc(e, t, n, s) { - return L$(lt(e, t), lt(e, t + 8), lt(e, t + 16), lt(e, t + 24), n, s); +function Wc(e, t, n, s) { + return U$(lt(e, t), lt(e, t + 8), lt(e, t + 16), lt(e, t + 24), n, s); } -function B$(e, t = e.length) { +function G$(e, t = e.length) { if (t >= 8) { - let n = an.add(t * 2), s = lt(e, 0).add(an), r = lt(e, t - 8), a = Lt(r, 37).mul(n).add(s), i = Lt(s, 25).add(r).mul(n); - return lr(a, i, n); + let n = on.add(t * 2), s = lt(e, 0).add(on), r = lt(e, t - 8), a = Bt(r, 37).mul(n).add(s), i = Bt(s, 25).add(r).mul(n); + return or(a, i, n); } if (t >= 4) { - let n = an.add(t * 2), s = ix(e, 0); - return lr(s.shl(3).add(t), ix(e, t - 4), n); + let n = on.add(t * 2), s = lx(e, 0); + return or(s.shl(3).add(t), lx(e, t - 4), n); } if (t > 0) { let n = e[0], s = e[t >> 1], r = e[t - 1], a = n + (s << 8), i = t + (r << 2); - return tm(an.mul(a).xor(ik.mul(i))).mul(an); + return rm(on.mul(a).xor(lk.mul(i))).mul(on); } - return an; + return on; } -function V$(e, t = e.length) { - let n = an.add(t * 2), s = lt(e, 0).mul(Hr), r = lt(e, 8), a = lt(e, t - 8).mul(n), i = lt(e, t - 16).mul(an); - return lr(Lt(s.add(r), 43).add(Lt(a, 30)).add(i), s.add(Lt(r.add(an), 18)).add(a), n); +function H$(e, t = e.length) { + let n = on.add(t * 2), s = lt(e, 0).mul(Hr), r = lt(e, 8), a = lt(e, t - 8).mul(n), i = lt(e, t - 16).mul(on); + return or(Bt(s.add(r), 43).add(Bt(a, 30)).add(i), s.add(Bt(r.add(on), 18)).add(a), n); } -function W$(e, t = e.length) { - let n = an.add(t * 2), s = lt(e, 0).mul(an), r = lt(e, 8), a = lt(e, t - 8).mul(n), i = lt(e, t - 16).mul(an), o = Lt(s.add(r), 43).add(Lt(a, 30)).add(i), u = lr(o, s.add(Lt(r.add(an), 18)).add(a), n), l = lt(e, 16).mul(n), c = lt(e, 24), p = o.add(lt(e, t - 32)).mul(n), d = u.add(lt(e, t - 24)).mul(n); - return lr(Lt(l.add(c), 43).add(Lt(p, 30)).add(d), l.add(Lt(c.add(s), 18)).add(p), n); +function q$(e, t = e.length) { + let n = on.add(t * 2), s = lt(e, 0).mul(on), r = lt(e, 8), a = lt(e, t - 8).mul(n), i = lt(e, t - 16).mul(on), o = Bt(s.add(r), 43).add(Bt(a, 30)).add(i), u = or(o, s.add(Bt(r.add(on), 18)).add(a), n), l = lt(e, 16).mul(n), c = lt(e, 24), p = o.add(lt(e, t - 32)).mul(n), d = u.add(lt(e, t - 24)).mul(n); + return or(Bt(l.add(c), 43).add(Bt(p, 30)).add(d), l.add(Bt(c.add(s), 18)).add(p), n); } -function U$(e, t = e.length) { +function j$(e, t = e.length) { let n = jr.fromNumber(81, true); if (t <= 32) - return t <= 16 ? B$(e, t) : V$(e, t); + return t <= 16 ? G$(e, t) : H$(e, t); if (t <= 64) - return W$(e, t); - let s = n, r = n.mul(Hr).add(113), a = tm(r.mul(an).add(113)).mul(an), i = [jr.UZERO, jr.UZERO], o = [jr.UZERO, jr.UZERO]; - s = s.mul(an).add(lt(e, 0)); + return q$(e, t); + let s = n, r = n.mul(Hr).add(113), a = rm(r.mul(on).add(113)).mul(on), i = [jr.UZERO, jr.UZERO], o = [jr.UZERO, jr.UZERO]; + s = s.mul(on).add(lt(e, 0)); let u = 0, l = (t - 1 >> 6) * 64, c = l + (t - 1 & 63) - 63; do - s = Lt(s.add(r).add(i[0]).add(lt(e, u + 8)), 37).mul(Hr), r = Lt(r.add(i[1]).add(lt(e, u + 48)), 42).mul(Hr), s = s.xor(o[1]), r = r.add(i[0]).add(lt(e, u + 40)), a = Lt(a.add(o[0]), 33).mul(Hr), i = Vc(e, u, i[1].mul(Hr), s.add(o[0])), o = Vc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], u += 64; + s = Bt(s.add(r).add(i[0]).add(lt(e, u + 8)), 37).mul(Hr), r = Bt(r.add(i[1]).add(lt(e, u + 48)), 42).mul(Hr), s = s.xor(o[1]), r = r.add(i[0]).add(lt(e, u + 40)), a = Bt(a.add(o[0]), 33).mul(Hr), i = Wc(e, u, i[1].mul(Hr), s.add(o[0])), o = Wc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], u += 64; while (u !== l); let p = Hr.add(a.and(255).shl(1)); - return u = c, o[0] = o[0].add(t - 1 & 63), i[0] = i[0].add(o[0]), o[0] = o[0].add(i[0]), s = Lt(s.add(r).add(i[0]).add(lt(e, u + 8)), 37).mul(p), r = Lt(r.add(i[1]).add(lt(e, u + 48)), 42).mul(p), s = s.xor(o[1].mul(9)), r = r.add(i[0].mul(9).add(lt(e, u + 40))), a = Lt(a.add(o[0]), 33).mul(p), i = Vc(e, u, i[1].mul(p), s.add(o[0])), o = Vc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], lr(lr(i[0], o[0], p).add(tm(r).mul(ik)).add(a), lr(i[1], o[1], p).add(s), p); + return u = c, o[0] = o[0].add(t - 1 & 63), i[0] = i[0].add(o[0]), o[0] = o[0].add(i[0]), s = Bt(s.add(r).add(i[0]).add(lt(e, u + 8)), 37).mul(p), r = Bt(r.add(i[1]).add(lt(e, u + 48)), 42).mul(p), s = s.xor(o[1].mul(9)), r = r.add(i[0].mul(9).add(lt(e, u + 40))), a = Bt(a.add(o[0]), 33).mul(p), i = Wc(e, u, i[1].mul(p), s.add(o[0])), o = Wc(e, u + 32, a.add(o[1]), r.add(lt(e, u + 16))), [a, s] = [s, a], or(or(i[0], o[0], p).add(rm(r).mul(lk)).add(a), or(i[1], o[1], p).add(s), p); } -function G$(e, t) { - return t === "string" ? Dl(e) : dp([e], t); +function K$(e, t) { + return t === "string" ? Fl(e) : fp([e], t); } -function H$(e, t) { +function X$(e, t) { return e instanceof Float32Array && t === "float32" || e instanceof Int32Array && t === "int32" || e instanceof Uint8Array && t === "bool"; } -function dp(e, t) { +function fp(e, t) { if (t === "string") throw new Error("Cannot convert a string[] to a TypedArray"); - if (Array.isArray(e) && (e = ra(e)), X().getBool("DEBUG") && Zw(e, t), H$(e, t)) + if (Array.isArray(e) && (e = ra(e)), K().getBool("DEBUG") && tk(e, t), X$(e, t)) return e; if (t == null || t === "float32" || t === "complex64") return new Float32Array(e); @@ -4121,39 +4130,39 @@ function dp(e, t) { } else throw new Error(`Unknown data type ${t}`); } -function Gu() { - return X().platform.now(); +function Hu() { + return K().platform.now(); } -function q$(e, t) { - return X().platform.fetch(e, t); +function Y$(e, t) { + return K().platform.fetch(e, t); } -function Dl(e, t = "utf-8") { - return t = t || "utf-8", X().platform.encode(e, t); +function Fl(e, t = "utf-8") { + return t = t || "utf-8", K().platform.encode(e, t); } -function md(e, t = "utf-8") { - return t = t || "utf-8", X().platform.decode(e, t); +function yd(e, t = "utf-8") { + return t = t || "utf-8", K().platform.decode(e, t); } -var j$ = class { +var Q$ = class { constructor(e, t) { - this.backendTimer = e, this.logger = t, t == null && (this.logger = new X$()); + this.backendTimer = e, this.logger = t, t == null && (this.logger = new J$()); } profileKernel(e, t, n) { let s, r = () => { s = n(); - }, a, i = Gu(); + }, a, i = Hu(); if (this.backendTimer.timerAvailable()) a = this.backendTimer.time(r); else { r(); for (let u of s) u.dataSync(); - a = Promise.resolve({ kernelMs: Gu() - i }); + a = Promise.resolve({ kernelMs: Hu() - i }); } - if (X().getBool("CHECK_COMPUTATION_FOR_ERRORS")) + if (K().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let u = 0; u < s.length; u++) { let l = s[u]; l.data().then((c) => { - K$(c, l.dtype, e); + Z$(c, l.dtype, e); }); } return { kernelName: e, outputs: s, inputs: t, timeMs: a.then((u) => u.kernelMs), extraInfo: a.then((u) => u.getExtraProfileInfo != null ? u.getExtraProfileInfo() : "") }; @@ -4167,7 +4176,7 @@ var j$ = class { }); } }; -function K$(e, t, n) { +function Z$(e, t, n) { if (t !== "float32") return false; for (let s = 0; s < e.length; s++) { @@ -4177,9 +4186,9 @@ function K$(e, t, n) { } return false; } -var X$ = class { +var J$ = class { logKernelProfile(e, t, n, s, r, a) { - let i = typeof s == "number" ? Mu(`${s}ms`, 9) : s.error, o = Mu(e, 25), u = t.rank, l = t.size, c = Mu(t.shape.toString(), 14), p = ""; + let i = typeof s == "number" ? Lu(`${s}ms`, 9) : s.error, o = Lu(e, 25), u = t.rank, l = t.size, c = Lu(t.shape.toString(), 14), p = ""; for (let d in r) { let h = r[d]; if (h != null) { @@ -4190,7 +4199,7 @@ var X$ = class { console.log(`%c${o} %c${i} %c${u}D ${c} %c${l} %c${p} %c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue"); } }; -function Y$(e, t, n) { +function e_(e, t, n) { let s = {}, r = {}; for (let u = 0; u < t.length; u++) s[t[u].id] = true; @@ -4234,7 +4243,7 @@ function Y$(e, t, n) { } return o; } -function Q$(e, t, n, s) { +function t_(e, t, n, s) { for (let r = t.length - 1; r >= 0; r--) { let a = t[r], i = []; if (a.outputs.forEach((u) => { @@ -4250,7 +4259,7 @@ function Q$(e, t, n, s) { if (l.dtype !== "float32") throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${u} must have 'float32' dtype, but has '${l.dtype}'`); let c = a.inputs[u]; - if (!Ir(l.shape, c.shape)) + if (!kr(l.shape, c.shape)) throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${u}' has shape '${l.shape}', which does not match the shape of the input '${c.shape}'`); if (e[c.id] == null) e[c.id] = l; @@ -4261,64 +4270,64 @@ function Q$(e, t, n, s) { } } } -var ox = 20; -var Cu = 3; -var Pf = 7; -function Z$(e, t, n, s) { - let r = oo(t), a = J$(e, t, n, r), i = t.length, o = ed(e, t, n, r, a), u = ["Tensor"]; +var cx = 20; +var Nu = 3; +var Lf = 7; +function n_(e, t, n, s) { + let r = lo(t), a = s_(e, t, n, r), i = t.length, o = nd(e, t, n, r, a), u = ["Tensor"]; return s && (u.push(` dtype: ${n}`), u.push(` rank: ${i}`), u.push(` shape: [${t}]`), u.push(" values:")), u.push(o.map((l) => " " + l).join(` `)), u.join(` `); } -function J$(e, t, n, s) { - let r = pt(t), a = s[s.length - 1], i = new Array(a).fill(0), o = t.length, u = n === "complex64" ? Au(e) : e; +function s_(e, t, n, s) { + let r = dt(t), a = s[s.length - 1], i = new Array(a).fill(0), o = t.length, u = n === "complex64" ? Eu(e) : e; if (o > 1) for (let l = 0; l < r / a; l++) { let c = l * a; for (let p = 0; p < a; p++) - i[p] = Math.max(i[p], _u(u[c + p], 0, n).length); + i[p] = Math.max(i[p], Au(u[c + p], 0, n).length); } return i; } -function _u(e, t, n) { +function Au(e, t, n) { let s; - return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(Pf))} + ${parseFloat(e[1].toFixed(Pf))}j` : or(e) ? s = `'${e}'` : n === "bool" ? s = uk(e) : s = parseFloat(e.toFixed(Pf)).toString(), Mu(s, t); + return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(Lf))} + ${parseFloat(e[1].toFixed(Lf))}j` : ar(e) ? s = `'${e}'` : n === "bool" ? s = dk(e) : s = parseFloat(e.toFixed(Lf)).toString(), Lu(s, t); } -function uk(e) { +function dk(e) { return e === 0 ? "false" : "true"; } -function ed(e, t, n, s, r, a = true) { +function nd(e, t, n, s, r, a = true) { let i = n === "complex64" ? 2 : 1, o = t[0], u = t.length; if (u === 0) { if (n === "complex64") { - let m = Au(e); - return [_u(m[0], 0, n)]; + let m = Eu(e); + return [Au(m[0], 0, n)]; } - return n === "bool" ? [uk(e[0])] : [e[0].toString()]; + return n === "bool" ? [dk(e[0])] : [e[0].toString()]; } if (u === 1) { - if (o > ox) { - let g = Cu * i, b = Array.from(e.slice(0, g)), y = Array.from(e.slice((o - Cu) * i, o * i)); - return n === "complex64" && (b = Au(b), y = Au(y)), ["[" + b.map((v, x) => _u(v, r[x], n)).join(", ") + ", ..., " + y.map((v, x) => _u(v, r[o - Cu + x], n)).join(", ") + "]"]; + if (o > cx) { + let g = Nu * i, b = Array.from(e.slice(0, g)), y = Array.from(e.slice((o - Nu) * i, o * i)); + return n === "complex64" && (b = Eu(b), y = Eu(y)), ["[" + b.map((v, x) => Au(v, r[x], n)).join(", ") + ", ..., " + y.map((v, x) => Au(v, r[o - Nu + x], n)).join(", ") + "]"]; } - let m = n === "complex64" ? Au(e) : Array.from(e); - return ["[" + m.map((g, b) => _u(g, r[b], n)).join(", ") + "]"]; + let m = n === "complex64" ? Eu(e) : Array.from(e); + return ["[" + m.map((g, b) => Au(g, r[b], n)).join(", ") + "]"]; } let l = t.slice(1), c = s.slice(1), p = s[0] * i, d = []; - if (o > ox) { - for (let m = 0; m < Cu; m++) { + if (o > cx) { + for (let m = 0; m < Nu; m++) { let g = m * p, b = g + p; - d.push(...ed(e.slice(g, b), l, n, c, r, false)); + d.push(...nd(e.slice(g, b), l, n, c, r, false)); } d.push("..."); - for (let m = o - Cu; m < o; m++) { + for (let m = o - Nu; m < o; m++) { let g = m * p, b = g + p; - d.push(...ed(e.slice(g, b), l, n, c, r, m === o - 1)); + d.push(...nd(e.slice(g, b), l, n, c, r, m === o - 1)); } } else for (let m = 0; m < o; m++) { let g = m * p, b = g + p; - d.push(...ed(e.slice(g, b), l, n, c, r, m === o - 1)); + d.push(...nd(e.slice(g, b), l, n, c, r, m === o - 1)); } let h = u === 2 ? "," : ""; d[0] = "[" + d[0] + h; @@ -4331,21 +4340,21 @@ function ed(e, t, n, s, r, a = true) { `; return d[d.length - 1] = " " + d[d.length - 1] + "]" + (a ? "" : f), d; } -function Au(e) { +function Eu(e) { let t = []; for (let n = 0; n < e.length; n += 2) t.push([e[n], e[n + 1]]); return t; } -var Vt = class { +var Wt = class { constructor(e, t, n) { - if (this.dtype = t, this.shape = e.slice(), this.size = pt(e), n != null) { + if (this.dtype = t, this.shape = e.slice(), this.size = dt(e), n != null) { let s = n.length; O(s === this.size, () => `Length of values '${s}' does not match the size inferred by the shape '${this.size}'.`); } if (t === "complex64") throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag)."); - this.values = n || Qw(t, this.size), this.strides = oo(e); + this.values = n || ek(t, this.size), this.strides = lo(e); } set(e, ...t) { t.length === 0 && (t = [0]), O(t.length === this.rank, () => `The number of provided coordinates (${t.length}) must match the rank (${this.rank})`); @@ -4395,37 +4404,37 @@ var Vt = class { } }; var cs = null; -var Gi = null; -var e_ = null; -function t_(e) { +var qi = null; +var r_ = null; +function a_(e) { cs = e; } -function n_(e) { - Gi = e; +function i_(e) { + qi = e; } -function s_(e) { - e_ = e; +function o_(e) { + r_ = e; } var et = class { constructor(e, t, n, s) { - this.kept = false, this.isDisposedInternal = false, this.shape = e.slice(), this.dtype = t || "float32", this.size = pt(e), this.strides = oo(e), this.dataId = n, this.id = s, this.rankType = this.rank < 5 ? this.rank.toString() : "higher"; + this.kept = false, this.isDisposedInternal = false, this.shape = e.slice(), this.dtype = t || "float32", this.size = dt(e), this.strides = lo(e), this.dataId = n, this.id = s, this.rankType = this.rank < 5 ? this.rank.toString() : "higher"; } get rank() { return this.shape.length; } async buffer() { let e = await this.data(); - return Gi.buffer(this.shape, this.dtype, e); + return qi.buffer(this.shape, this.dtype, e); } bufferSync() { - return Gi.buffer(this.shape, this.dtype, this.dataSync()); + return qi.buffer(this.shape, this.dtype, this.dataSync()); } async array() { let e = await this.data(); - return ji(this.shape, e, this.dtype === "complex64"); + return Xi(this.shape, e, this.dtype === "complex64"); } arraySync() { - return ji(this.shape, this.dataSync(), this.dtype === "complex64"); + return Xi(this.shape, this.dataSync(), this.dtype === "complex64"); } async data() { this.throwIfDisposed(); @@ -4433,7 +4442,7 @@ var et = class { if (this.dtype === "string") { let t = await e; try { - return t.map((n) => md(n)); + return t.map((n) => yd(n)); } catch (n) { throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes()."); } @@ -4448,7 +4457,7 @@ var et = class { let e = cs().readSync(this.dataId); if (this.dtype === "string") try { - return e.map((t) => md(t)); + return e.map((t) => yd(t)); } catch (t) { throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes()."); } @@ -4470,35 +4479,35 @@ var et = class { throw new Error("Tensor is disposed."); } print(e = false) { - return Gi.print(this, e); + return qi.print(this, e); } clone() { - return this.throwIfDisposed(), Gi.clone(this); + return this.throwIfDisposed(), qi.clone(this); } toString(e = false) { let t = this.dataSync(); - return Z$(t, this.shape, this.dtype, e); + return n_(t, this.shape, this.dtype, e); } cast(e) { - return this.throwIfDisposed(), Gi.cast(this, e); + return this.throwIfDisposed(), qi.cast(this, e); } variable(e = true, t, n) { return this.throwIfDisposed(), cs().makeVariable(this, e, t, n); } }; Object.defineProperty(et, Symbol.hasInstance, { value: (e) => !!e && e.data != null && e.dataSync != null && e.throwIfDisposed != null }); -function r_() { - return og("Tensor", () => et); +function u_() { + return lg("Tensor", () => et); } -r_(); -var gd = class extends et { +u_(); +var vd = class extends et { constructor(e, t, n, s) { super(e.shape, e.dtype, e.dataId, s), this.trainable = t, this.name = n; } assign(e) { if (e.dtype !== this.dtype) throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`); - if (!Ir(e.shape, this.shape)) + if (!kr(e.shape, this.shape)) throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`); cs().disposeTensor(this), this.dataId = e.dataId, cs().incRef(this, null); } @@ -4506,64 +4515,64 @@ var gd = class extends et { cs().disposeVariable(this), this.isDisposedInternal = true; } }; -Object.defineProperty(gd, Symbol.hasInstance, { value: (e) => e instanceof et && e.assign != null && e.assign instanceof Function }); +Object.defineProperty(vd, Symbol.hasInstance, { value: (e) => e instanceof et && e.assign != null && e.assign instanceof Function }); var _s = {}; -Ae(_s, { assertTypesMatch: () => hk, getTensorsInContainer: () => Fg, isTensorInList: () => o_, makeTypesMatch: () => vt }); -var a_ = ((e) => (e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6", e))(a_ || {}); -var lk = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64", e))(lk || {}); -var ck = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64", e))(ck || {}); -var dk = ((e) => (e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64", e))(dk || {}); -var pk = ((e) => (e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64", e))(pk || {}); -var i_ = { float32: dk, int32: lk, bool: ck, complex64: pk }; -function ln(e, t) { +Ae(_s, { assertTypesMatch: () => gk, getTensorsInContainer: () => zg, isTensorInList: () => d_, makeTypesMatch: () => vt }); +var l_ = ((e) => (e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6", e))(l_ || {}); +var pk = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64", e))(pk || {}); +var hk = ((e) => (e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64", e))(hk || {}); +var fk = ((e) => (e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64", e))(fk || {}); +var mk = ((e) => (e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64", e))(mk || {}); +var c_ = { float32: fk, int32: pk, bool: hk, complex64: mk }; +function cn(e, t) { if (e === "string" || t === "string") { if (e === "string" && t === "string") return "string"; throw new Error(`Can not upcast ${e} with ${t}`); } - return i_[e][t]; + return c_[e][t]; } -function pp(e) { - return ln(e, "int32"); +function mp(e) { + return cn(e, "int32"); } function vt(e, t) { if (e.dtype === t.dtype) return [e, t]; - let n = ln(e.dtype, t.dtype); + let n = cn(e.dtype, t.dtype); return [e.cast(n), t.cast(n)]; } -function hk(e, t) { +function gk(e, t) { O(e.dtype === t.dtype, () => `The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`); } -function o_(e, t) { +function d_(e, t) { return t.some((n) => n.id === e.id); } -function Fg(e) { +function zg(e) { let t = []; - return fk(e, t, /* @__PURE__ */ new Set()), t; + return bk(e, t, /* @__PURE__ */ new Set()), t; } -function fk(e, t, n) { +function bk(e, t, n) { if (e == null) return; if (e instanceof et) { t.push(e); return; } - if (!u_(e)) + if (!p_(e)) return; let s = e; for (let r in s) { let a = s[r]; - n.has(a) || (n.add(a), fk(a, t, n)); + n.has(a) || (n.add(a), bk(a, t, n)); } } -function u_(e) { +function p_(e) { return Array.isArray(e) || typeof e == "object"; } -function zf(e) { +function Bf(e) { return e.kernelName != null; } -var ux = class { +var dx = 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 = /* @__PURE__ */ new WeakMap(), this.profiling = false, this.activeProfile = { newBytes: 0, newTensors: 0, peakBytes: 0, kernels: [], result: null, get kernelNames() { return Array.from(new Set(this.kernels.map((e) => e.name))); @@ -4574,9 +4583,9 @@ var ux = class { this.registeredVariables[e].dispose(); } }; -var nm = class { +var am = class { constructor(e) { - this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new ux(); + this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new dx(); } async ready() { if (this.pendingBackendInit != null) @@ -4622,7 +4631,7 @@ var nm = class { return e in this.registryFactory ? this.registryFactory[e].factory : null; } registerBackend(e, t, n = 1) { - return e in this.registryFactory ? (ir(`${e} backend was already registered. Reusing existing backend factory.`), false) : (this.registryFactory[e] = { factory: t, priority: n }, true); + return e in this.registryFactory ? (rr(`${e} backend was already registered. Reusing existing backend factory.`), false) : (this.registryFactory[e] = { factory: t, priority: n }, true); } async setBackend(e) { if (this.registryFactory[e] == null) @@ -4633,15 +4642,15 @@ var nm = class { if (!(n ? await t : t)) return false; } - return this.backendInstance = this.registry[e], this.setupRegisteredKernels(), this.profiler = new j$(this.backendInstance), true; + return this.backendInstance = this.registry[e], this.setupRegisteredKernels(), this.profiler = new Q$(this.backendInstance), true; } setupRegisteredKernels() { - em(this.backendName).forEach((t) => { + sm(this.backendName).forEach((t) => { t.setupFunc != null && t.setupFunc(this.backendInstance); }); } disposeRegisteredKernels(e) { - em(e).forEach((n) => { + sm(e).forEach((n) => { n.disposeFunc != null && n.disposeFunc(this.registry[e]); }); } @@ -4651,13 +4660,13 @@ var nm = class { throw new Error(`Cannot initialize backend ${e}, no registration found.`); try { let n = t.factory(); - if (n && !(n instanceof sl) && typeof n.then == "function") { - let s = ++this.pendingBackendInitId, r = n.then((a) => s < this.pendingBackendInitId ? false : (this.registry[e] = a, this.pendingBackendInit = null, true)).catch((a) => (s < this.pendingBackendInitId || (this.pendingBackendInit = null, ir(`Initialization of backend ${e} failed`), ir(a.stack || a.message)), false)); + if (n && !(n instanceof rl) && typeof n.then == "function") { + let s = ++this.pendingBackendInitId, r = n.then((a) => s < this.pendingBackendInitId ? false : (this.registry[e] = a, this.pendingBackendInit = null, true)).catch((a) => (s < this.pendingBackendInitId || (this.pendingBackendInit = null, rr(`Initialization of backend ${e} failed`), rr(a.stack || a.message)), false)); return this.pendingBackendInit = r, { success: r, asyncInit: true }; } else return this.registry[e] = n, { success: true, asyncInit: false }; } catch (n) { - return ir(`Initialization of backend ${e} failed`), ir(n.stack || n.message), { success: false, asyncInit: false }; + return rr(`Initialization of backend ${e} failed`), rr(n.stack || n.message), { success: false, asyncInit: false }; } } removeBackend(e) { @@ -4709,10 +4718,10 @@ var nm = class { } } nextTensorId() { - return nm.nextTensorId++; + return am.nextTensorId++; } nextVariableId() { - return nm.nextVariableId++; + return am.nextVariableId++; } clone(e) { let t = M.runKernel(Wa, { x: e }), n = { x: e }, s = (a) => ({ x: () => { @@ -4722,7 +4731,7 @@ var nm = class { return this.addTapeNode(this.state.activeScope.name, n, [t], s, r, {}), t; } runKernel(e, t, n) { - if (this.backendName == null && this.backend, !(Jf(e, this.backendName) != null)) + if (this.backendName == null && this.backend, !(nm(e, this.backendName) != null)) throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`); return this.runKernelFunc({ kernelName: e, inputs: t, attrs: n }); } @@ -4743,22 +4752,17 @@ var nm = class { this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0); let i; this.backendName == null && this.backend; - let o, u = zf(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : ""; - if (zf(e)) { + let o, u = Bf(e) ? e.kernelName : this.state.activeScope != null ? this.state.activeScope.name : ""; + if (Bf(e)) { let { kernelName: h, inputs: f, attrs: m } = e; this.backendName == null && this.backend; - let g = Jf(h, this.backendName); + let g = nm(h, this.backendName); O(g != null, () => `Cannot find registered kernel '${h}' for backend '${this.backendName}'`), i = () => { let b = this.backend.numDataIds(); o = g.kernelFunc({ inputs: f, attrs: m, backend: this.backend }); let y = Array.isArray(o) ? o : [o]; this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(h, b, y); - let v = y.map((x) => { - if (x.rank != null) - return x; - let { dataId: k, shape: S, dtype: $ } = x; - return this.makeTensorFromDataId(k, S, $); - }); + let v = y.map((x) => x.rank != null ? x : this.makeTensorFromTensorInfo(x)); if (s) { let x = this.getTensorsForGradient(h, f, v); n = this.saveTensorsForBackwardMode(x); @@ -4776,7 +4780,7 @@ var nm = class { return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(u, m, g), g; }; } - let { inputs: l, attrs: c } = e, p = zf(e) ? null : e.backwardsFunc, d; + let { inputs: l, attrs: c } = e, p = Bf(e) ? null : e.backwardsFunc, d; return this.scopedRun(() => this.state.kernelDepth++, () => this.state.kernelDepth--, () => { !this.ENV.getBool("DEBUG") && !this.state.profiling ? t = i() : (d = this.profiler.profileKernel(u, l, () => i()), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(d), t = d.outputs); }), s && this.addTapeNode(u, l, t, p, n, c), this.state.profiling && this.state.activeProfile.kernels.push({ name: u, bytesAdded: this.state.numBytes - r, totalBytesSnapshot: this.state.numBytes, tensorsAdded: this.state.numTensors - a, totalTensorsSnapshot: this.state.numTensors, inputShapes: Object.keys(l).map((h) => l[h] != null ? l[h].shape : null), outputShapes: t.map((h) => h.shape), kernelTimeMs: d.timeMs, extraInfo: d.extraInfo }), Array.isArray(o) ? t : t[0]; @@ -4785,7 +4789,7 @@ var nm = class { return e.map((n) => this.keep(this.clone(n))); } getTensorsForGradient(e, t, n) { - let s = rx(e); + let s = ox(e); if (s != null) { let r = s.inputsToSave || [], a = s.outputsToSave || [], i; s.saveAllInputs ? (O(Array.isArray(t), () => "saveAllInputs is true, expected inputs to be an array."), i = Object.keys(t).map((u) => t[u])) : i = r.map((u) => t[u]); @@ -4799,22 +4803,21 @@ var nm = class { throw new Error("Values passed to engine.makeTensor() are null"); n = n || "float32", s = s || this.backend; let r = e; - n === "string" && or(e[0]) && (r = e.map((o) => Dl(o))); + n === "string" && ar(e[0]) && (r = e.map((o) => Fl(o))); let a = s.write(r, t, n), i = new et(t, n, a, this.nextTensorId()); if (this.trackTensor(i, s), n === "string") { - let o = this.state.tensorInfo.get(a), u = ek(r); + let o = this.state.tensorInfo.get(a), u = sk(r); this.state.numBytes += u - o.bytes, o.bytes = u; } return i; } - makeTensorFromDataId(e, t, n, s) { - n = n || "float32"; - let r = new et(t, n, e, this.nextTensorId()); - return this.trackTensor(r, s), r; + makeTensorFromTensorInfo(e, t) { + let { dataId: n, shape: s, dtype: r } = e, a = new et(s, r, n, this.nextTensorId()); + return this.trackTensor(a, t), a; } makeVariable(e, t = true, n, s) { n = n || this.nextVariableId().toString(), s != null && s !== e.dtype && (e = e.cast(s)); - let r = new gd(e, t, n, this.nextTensorId()); + let r = new vd(e, t, n, this.nextTensorId()); if (this.state.registeredVariables[r.name] != null) throw new Error(`Variable with name ${r.name} was already registered`); return this.state.registeredVariables[r.name] = r, this.incRef(r, this.backend), r; @@ -4822,7 +4825,7 @@ var nm = class { trackTensor(e, t) { this.state.numTensors++, e.dtype === "string" && this.state.numStringTensors++; let n = 0; - e.dtype !== "complex64" && e.dtype !== "string" && (n = e.size * Yf(e.dtype)), this.state.numBytes += n, this.state.tensorInfo.has(e.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(e.dataId, { backend: t || this.backend, dtype: e.dtype, shape: e.shape, bytes: n })), e instanceof gd || this.track(e); + e.dtype !== "complex64" && e.dtype !== "string" && (n = e.size * Jf(e.dtype)), this.state.numBytes += n, this.state.tensorInfo.has(e.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(e.dataId, { backend: t || this.backend, dtype: e.dtype, shape: e.shape, bytes: n })), e instanceof vd || this.track(e); } incRef(e, t) { this.trackTensor(e, t), this.backend.incRef(e.dataId); @@ -4835,7 +4838,7 @@ var nm = class { return; let t = this.state.tensorInfo.get(e.dataId); if (this.state.numTensors--, e.dtype === "string" && (this.state.numStringTensors--, this.state.numBytes -= t.bytes), e.dtype !== "complex64" && e.dtype !== "string") { - let n = e.size * Yf(e.dtype); + let n = e.size * Jf(e.dtype); this.state.numBytes -= n; } t.backend.disposeData(e.dataId) && this.removeDataId(e.dataId, t.backend); @@ -4865,10 +4868,10 @@ var nm = class { return this.state.gradientDepth > 0 && this.state.kernelDepth === 0; } addTapeNode(e, t, n, s, r, a) { - let i = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t, outputs: n, saved: r }, o = rx(e); + let i = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t, outputs: n, saved: r }, o = ox(e); o != null && (s = o.gradFunc), s != null && (i.gradient = (u) => (u = u.map((l, c) => { if (l == null) { - let p = n[c], d = jd(p.size, p.dtype); + let p = n[c], d = Yd(p.size, p.dtype); return this.makeTensor(d, p.shape, p.dtype); } return l; @@ -4888,7 +4891,7 @@ var nm = class { e && (t.name = e), this.state.scopeStack.push(t), this.state.activeScope = t; } endScope(e) { - let t = Fg(e), n = new Set(t.map((r) => r.id)); + let t = zg(e), n = new Set(t.map((r) => r.id)); for (let r = 0; r < this.state.activeScope.track.length; r++) { let a = this.state.activeScope.track[r]; !a.kept && !n.has(a.id) && a.dispose(); @@ -4903,12 +4906,12 @@ var nm = class { throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`); let r = this.scopedRun(() => this.startTape(), () => this.endTape(), () => this.tidy("forward", e)); O(r instanceof et, () => "The result y returned by f() must be a tensor."); - let a = Y$(this.state.activeTape, t, r); + let a = e_(this.state.activeTape, t, r); if (!s && a.length === 0 && t.length > 0) throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y."); return this.tidy("backward", () => { let i = {}; - i[r.id] = n == null ? l_(r.shape) : n, Q$(i, a, (u) => this.tidy(u), c_); + i[r.id] = n == null ? h_(r.shape) : n, t_(i, a, (u) => this.tidy(u), f_); let o = t.map((u) => i[u.id]); return this.state.gradientDepth === 0 && (this.state.activeTape.forEach((u) => { for (let l of u.saved) @@ -4917,13 +4920,13 @@ var nm = class { }); } customGrad(e) { - return O(fr(e), () => "The f passed in customGrad(f) must be a function."), (...t) => { + return O(hr(e), () => "The f passed in customGrad(f) must be a function."), (...t) => { O(t.every((i) => i instanceof et), () => "The args passed in customGrad(f)(x1, x2,...) must all be tensors"); let n, s = {}; t.forEach((i, o) => { s[o] = i; }); - let r = (i, o) => (n = e(...t, o), O(n.value instanceof et, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), O(fr(n.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), n.value), a = (i, o) => { + let r = (i, o) => (n = e(...t, o), O(n.value instanceof et, () => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"), O(hr(n.gradFunc), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."), n.value), a = (i, o) => { let u = n.gradFunc(i, o), l = Array.isArray(u) ? u : [u]; O(l.length === t.length, () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."), O(l.every((p) => p instanceof et), () => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."); let c = {}; @@ -4944,8 +4947,8 @@ var nm = class { return this.state.tensorInfo.get(e).backend.readToGPU(e, t); } async time(e) { - let t = Gu(), n = await this.backend.time(e); - return n.wallMs = Gu() - t, n; + let t = Hu(), n = await this.backend.time(e); + return n.wallMs = Hu() - t, n; } track(e) { return this.state.activeScope != null && (e.scopeId = this.state.activeScope.id, this.state.activeScope.track.push(e)), e; @@ -4954,45 +4957,45 @@ var nm = class { return this.state.registeredVariables; } reset() { - this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new ux(); + this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new dx(); for (let e in this.registry) this.disposeRegisteredKernels(e), this.registry[e].dispose(), delete this.registry[e]; this.backendName = null, this.backendInstance = null, this.pendingBackendInit = null; } }; -var Og = nm; -Og.nextTensorId = 0; -Og.nextVariableId = 0; -function l_(e) { - let t = rg(pt(e), "float32"); +var Mg = am; +Mg.nextTensorId = 0; +Mg.nextVariableId = 0; +function h_(e) { + let t = ig(dt(e), "float32"); return M.makeTensor(t, e, "float32"); } -function mk() { - let e = ak(); +function yk() { + let e = uk(); if (e._tfengine == null) { - let t = new _$(e); - e._tfengine = new Og(t); + let t = new D$(e); + e._tfengine = new Mg(t); } - return D$(e._tfengine.ENV), t_(() => e._tfengine), e._tfengine; + return z$(e._tfengine.ENV), a_(() => e._tfengine), e._tfengine; } -var M = mk(); -function c_(e, t) { +var M = yk(); +function f_(e, t) { let n = { a: e, b: t }; return M.runKernel(Sr, n); } -var hp = {}; -Ae(hp, { isBrowser: () => gk, isMobile: () => h_, mockIsMobile: () => p_ }); -function d_() { +var gp = {}; +Ae(gp, { isBrowser: () => vk, isMobile: () => b_, mockIsMobile: () => g_ }); +function m_() { return typeof navigator != "undefined" && navigator != null; } -var sm; -function p_(e) { - sm = e; +var im; +function g_(e) { + im = e; } -function h_(e) { - if (sm !== void 0) - return sm; - if (e || d_()) { +function b_(e) { + if (im !== void 0) + return im; + if (e || m_()) { if (e || (e = navigator), e.product === "ReactNative") return true; let t = e.userAgent || e.vendor || (typeof window != "undefined" ? window.opera : ""); @@ -5004,14 +5007,14 @@ function h_(e) { } return false; } -function gk() { +function vk() { return typeof window != "undefined" && window.document != null || typeof WorkerGlobalScope != "undefined"; } -var Kn = X(); +var Kn = K(); Kn.registerFlag("DEBUG", () => false, (e) => { e && console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance."); }); -Kn.registerFlag("IS_BROWSER", () => gk()); +Kn.registerFlag("IS_BROWSER", () => vk()); Kn.registerFlag("IS_NODE", () => typeof process != "undefined" && typeof process.versions != "undefined" && typeof process.versions.node != "undefined"); Kn.registerFlag("IS_CHROME", () => typeof navigator != "undefined" && navigator != null && navigator.userAgent != null && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor)); Kn.registerFlag("PROD", () => false); @@ -5023,26 +5026,26 @@ Kn.registerFlag("WRAP_TO_IMAGEBITMAP", () => false); Kn.registerFlag("ENGINE_COMPILE_ONLY", () => false); function Rs(e, t) { let n = e; - if (Yt(e)) + if (Qt(e)) return t === "string" ? [] : [e.length]; if (!Array.isArray(e)) return []; let s = []; - for (; Array.isArray(n) || Yt(n) && t !== "string"; ) + for (; Array.isArray(n) || Qt(n) && t !== "string"; ) s.push(n.length), n = n[0]; - return Array.isArray(e) && X().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && bk(e, s, []), s; + return Array.isArray(e) && K().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && xk(e, s, []), s; } -function bk(e, t, n) { - if (n = n || [], !Array.isArray(e) && !Yt(e)) { +function xk(e, t, n) { + if (n = n || [], !Array.isArray(e) && !Qt(e)) { O(t.length === 0, () => `Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`); return; } O(t.length > 0, () => `Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`), O(e.length === t[0], () => `Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`); let s = t.slice(1); for (let r = 0; r < e.length; ++r) - bk(e[r], s, n.concat(r)); + xk(e[r], s, n.concat(r)); } -function lx(e, t, n, s) { +function px(e, t, n, s) { if (e !== "string_or_numeric") { if (e == null) throw new Error("Expected dtype cannot be null."); @@ -5052,70 +5055,70 @@ function lx(e, t, n, s) { } function _(e, t, n, s = "numeric") { if (e instanceof et) - return lx(s, e.dtype, t, n), e; - let r = qd(e); - if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), lx(s, r, t, n), e == null || !Yt(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") { + return px(s, e.dtype, t, n), e; + let r = Xd(e); + if (r !== "string" && ["bool", "int32", "float32"].indexOf(s) >= 0 && (r = s), px(s, r, t, n), e == null || !Qt(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") { let u = e == null ? "null" : e.constructor.name; throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${u}'`); } let a = Rs(e, r); - !Yt(e) && !Array.isArray(e) && (e = [e]); - let o = r !== "string" ? dp(e, r) : ra(e, [], true); + !Qt(e) && !Array.isArray(e) && (e = [e]); + let o = r !== "string" ? fp(e, r) : ra(e, [], true); return M.makeTensor(o, a, r); } -function Hu(e, t, n, s = "numeric") { +function qu(e, t, n, s = "numeric") { if (!Array.isArray(e)) throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``); return e.map((a, i) => _(a, `${t}[${i}]`, n, s)); } -var f_ = "__op"; +var y_ = "__op"; function L(e) { let t = Object.keys(e); if (t.length !== 1) throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`); let n = t[0], s = e[n]; - n.endsWith("_") && (n = n.substring(0, n.length - 1)), n = n + f_; + n.endsWith("_") && (n = n.substring(0, n.length - 1)), n = n + y_; let r = (...a) => { M.startScope(n); try { let i = s(...a); - return ig(i) && console.error("Cannot return a Promise inside of tidy."), M.endScope(i), i; + return ug(i) && console.error("Cannot return a Promise inside of tidy."), M.endScope(i), i; } catch (i) { throw M.endScope(null), i; } }; return Object.defineProperty(r, "name", { value: n, configurable: true }), r; } -function m_(e, t) { +function v_(e, t) { let n = _(e, "real", "complex"), s = _(t, "imag", "complex"); pn(n.shape, s.shape, `real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`); let r = { real: n, imag: s }; - return M.runKernel(Xd, r); + return M.runKernel(Zd, r); } -var ua = L({ complex_: m_ }); -function Tr(e, t, n, s) { - if (s == null && (s = qd(e)), s === "complex64") +var ua = L({ complex_: v_ }); +function Nr(e, t, n, s) { + if (s == null && (s = Xd(e)), s === "complex64") throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag)."); - if (!Yt(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") + if (!Qt(e) && !Array.isArray(e) && typeof e != "number" && typeof e != "boolean" && typeof e != "string") throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray"); if (t != null) { - ag(t); - let r = pt(t), a = pt(n); + og(t); + let r = dt(t), a = dt(n); O(r === a, () => `Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`); for (let i = 0; i < n.length; ++i) { - let o = n[i], u = i === n.length - 1 ? o !== pt(t.slice(i)) : true; + let o = n[i], u = i === n.length - 1 ? o !== dt(t.slice(i)) : true; O(n[i] === t[i] || !u, () => `Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `); } } - return !Yt(e) && !Array.isArray(e) && (e = [e]), t = t || n, e = s !== "string" ? dp(e, s) : ra(e, [], true), M.makeTensor(e, t, s); + return !Qt(e) && !Array.isArray(e) && (e = [e]), t = t || n, e = s !== "string" ? fp(e, s) : ra(e, [], true), M.makeTensor(e, t, s); } -function fs(e, t, n) { +function ms(e, t, n) { let s = Rs(e, n); - return Tr(e, t, s, n); + return Nr(e, t, s, n); } -var rm = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 }; -var bd = 4; -async function g_(e, t) { +var om = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 }; +var xd = 4; +async function x_(e, t) { let n = [], s = [], r = Array.isArray(e) ? e.map((i) => i.name) : Object.keys(e); for (let i = 0; i < r.length; ++i) { let o = r[i], u = Array.isArray(e) ? e[i].tensor : e[o]; @@ -5124,10 +5127,10 @@ async function g_(e, t) { let l = { name: o, shape: u.shape, dtype: u.dtype }; if (u.dtype === "string") { let c = new Promise(async (p) => { - let d = await u.bytes(), h = d.reduce((g, b) => g + b.length, 0) + bd * d.length, f = new Uint8Array(h), m = 0; + let d = await u.bytes(), h = d.reduce((g, b) => g + b.length, 0) + xd * d.length, f = new Uint8Array(h), m = 0; for (let g = 0; g < d.length; g++) { let b = d[g], y = new Uint8Array(new Uint32Array([b.length]).buffer); - f.set(y, m), m += bd, f.set(b, m), m += b.length; + f.set(y, m), m += xd, f.set(b, m), m += b.length; } p(f); }); @@ -5137,12 +5140,12 @@ async function g_(e, t) { t != null && (l.group = t), n.push(l); } let a = await Promise.all(s); - return { data: b_(a), specs: n }; + return { data: w_(a), specs: n }; } -function yk(e, t) { +function wk(e, t) { let n = {}, s, r = 0; for (let a of t) { - let i = a.name, o = a.dtype, u = a.shape, l = pt(u), c; + let i = a.name, o = a.dtype, u = a.shape, l = dt(u), c; if ("quantization" in a) { let p = a.quantization; if (p.dtype === "uint8" || p.dtype === "uint16") { @@ -5153,7 +5156,7 @@ function yk(e, t) { throw new Error(`Weight ${a.name} is quantized with ${p.dtype} which only supports weights of type float32 not ${o}.`); } else throw new Error(`Weight ${a.name} has unknown quantization dtype ${p.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); - let d = rm[p.dtype], h = e.slice(r, r + l * d), f = p.dtype === "uint8" ? new Uint8Array(h) : new Uint16Array(h); + let d = om[p.dtype], h = e.slice(r, r + l * d), f = p.dtype === "uint8" ? new Uint8Array(h) : new Uint16Array(h); if (o === "float32") if (p.dtype === "uint8" || p.dtype === "uint16") { c = new Float32Array(f.length); @@ -5162,7 +5165,7 @@ function yk(e, t) { c[m] = g * p.scale + p.min; } } else if (p.dtype === "float16") - s === void 0 && (s = I_()), c = s(f); + s === void 0 && (s = T_()), c = s(f); else throw new Error(`Unsupported quantization type ${p.dtype} for weight type float32.`); else if (o === "int32") { @@ -5177,16 +5180,16 @@ function yk(e, t) { throw new Error(`Unsupported dtype in weight '${i}': ${o}`); r += l * d; } else if (o === "string") { - let p = pt(a.shape); + let p = dt(a.shape); c = []; for (let d = 0; d < p; d++) { - let h = new Uint32Array(e.slice(r, r + bd))[0]; - r += bd; + let h = new Uint32Array(e.slice(r, r + xd))[0]; + r += xd; let f = new Uint8Array(e.slice(r, r + h)); c.push(f), r += h; } } else { - let p = rm[o], d = e.slice(r, r + l * p); + let p = om[o], d = e.slice(r, r + l * p); if (o === "float32") c = new Float32Array(d); else if (o === "int32") @@ -5198,17 +5201,17 @@ function yk(e, t) { let h = new Float32Array(c.length / 2), f = new Float32Array(c.length / 2); for (let b = 0; b < h.length; b++) h[b] = c[b * 2], f[b] = c[b * 2 + 1]; - let m = fs(h, u, "float32"), g = fs(f, u, "float32"); + let m = ms(h, u, "float32"), g = ms(f, u, "float32"); n[i] = ua(m, g), m.dispose(), g.dispose(); } else throw new Error(`Unsupported dtype in weight '${i}': ${o}`); r += l * p; } - o !== "complex64" && (n[i] = fs(c, u, o)); + o !== "complex64" && (n[i] = ms(c, u, o)); } return n; } -function b_(e) { +function w_(e) { if (e === null) throw new Error(`Invalid input value: ${JSON.stringify(e)}`); let t = 0, n = []; @@ -5221,20 +5224,20 @@ function b_(e) { s.set(new Uint8Array(a.buffer), r), r += a.byteLength; }), s.buffer; } -var Pg = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined"); -function cx(e) { - return Pg ? Buffer.byteLength(e) : new Blob([e]).size; +var Lg = typeof Buffer != "undefined" && (typeof Blob == "undefined" || typeof atob == "undefined" || typeof btoa == "undefined"); +function hx(e) { + return Lg ? Buffer.byteLength(e) : new Blob([e]).size; } -function y_(e) { - if (Pg) +function k_(e) { + if (Lg) return Buffer.from(e).toString("base64"); let t = new Uint8Array(e), n = ""; for (let s = 0, r = t.length; s < r; s++) n += String.fromCharCode(t[s]); return btoa(n); } -function v_(e) { - if (Pg) { +function S_(e) { + if (Lg) { let s = Buffer.from(e, "base64"); return s.buffer.slice(s.byteOffset, s.byteOffset + s.byteLength); } @@ -5243,7 +5246,7 @@ function v_(e) { n.set([t.charCodeAt(s)], s); return n.buffer; } -function zg(e) { +function Bg(e) { if (e.length === 1) return e[0]; let t = 0; @@ -5255,18 +5258,18 @@ function zg(e) { n.set(new Uint8Array(r), s), s += r.byteLength; }), n.buffer; } -function dx(e) { +function fx(e) { let t = "/"; for (e = e.trim(); e.endsWith(t); ) e = e.slice(0, e.length - 1); let n = e.split(t); return n[n.length - 1]; } -function vk(e, t) { +function kk(e, t) { let n = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, weightsManifest: t }; return e.signature != null && (n.signature = e.signature), e.userDefinedMetadata != null && (n.userDefinedMetadata = e.userDefinedMetadata), e.modelInitializer != null && (n.modelInitializer = e.modelInitializer), e.trainingConfig != null && (n.trainingConfig = e.trainingConfig), n; } -async function Mg(e, t) { +async function Vg(e, t) { let n = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy }; if (e.trainingConfig != null && (n.trainingConfig = e.trainingConfig), e.weightsManifest != null) { let [s, r] = await t(e.weightsManifest); @@ -5274,12 +5277,12 @@ async function Mg(e, t) { } return e.signature != null && (n.signature = e.signature), e.userDefinedMetadata != null && (n.userDefinedMetadata = e.userDefinedMetadata), e.modelInitializer != null && (n.modelInitializer = e.modelInitializer), n; } -function Fl(e) { +function Ol(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("Expected JSON model topology, received ArrayBuffer."); - return { dateSaved: new Date(), modelTopologyType: "JSON", modelTopologyBytes: e.modelTopology == null ? 0 : cx(JSON.stringify(e.modelTopology)), weightSpecsBytes: e.weightSpecs == null ? 0 : cx(JSON.stringify(e.weightSpecs)), weightDataBytes: e.weightData == null ? 0 : e.weightData.byteLength }; + return { dateSaved: new Date(), modelTopologyType: "JSON", modelTopologyBytes: e.modelTopology == null ? 0 : hx(JSON.stringify(e.modelTopology)), weightSpecsBytes: e.weightSpecs == null ? 0 : hx(JSON.stringify(e.weightSpecs)), weightDataBytes: e.weightData == null ? 0 : e.weightData.byteLength }; } -function x_() { +function I_() { let e = (n) => { let s = n << 13, r = 0; for (; (s & 8388608) === 0; ) @@ -5293,7 +5296,7 @@ function x_() { t[n] = 939524096 + (n - 1024 << 13); return t; } -function w_() { +function C_() { let e = new Uint32Array(64); e[0] = 0, e[31] = 1199570944, e[32] = 2147483648, e[63] = 3347054592; for (let t = 1; t < 31; t++) @@ -5302,14 +5305,14 @@ function w_() { e[t] = 2147483648 + (t - 32 << 23); return e; } -function k_() { +function N_() { let e = new Uint32Array(64); for (let t = 0; t < 64; t++) e[t] = 1024; return e[0] = e[32] = 0, e; } -function I_() { - let e = x_(), t = w_(), n = k_(); +function T_() { + let e = I_(), t = C_(), n = N_(); return (s) => { let r = new ArrayBuffer(4 * s.length), a = new Uint32Array(r); for (let i = 0; i < s.length; i++) { @@ -5346,29 +5349,29 @@ var xt = class { }), s; } }; -var S_ = (e) => xt.registerSaveRouter(e); -var C_ = (e) => xt.registerLoadRouter(e); -var N_ = (e) => xt.getSaveHandlers(e); -var T_ = (e, t) => xt.getLoadHandlers(e, t); -var am = "tensorflowjs"; -var im = 1; +var $_ = (e) => xt.registerSaveRouter(e); +var __ = (e) => xt.registerLoadRouter(e); +var A_ = (e) => xt.getSaveHandlers(e); +var E_ = (e, t) => xt.getLoadHandlers(e, t); +var um = "tensorflowjs"; +var lm = 1; var Qr = "models_store"; -var ur = "model_info_store"; -function xk() { - if (!X().getBool("IS_BROWSER")) +var ir = "model_info_store"; +function Sk() { + if (!K().getBool("IS_BROWSER")) throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser."); let e = typeof window == "undefined" ? self : window, t = e.indexedDB || e.mozIndexedDB || e.webkitIndexedDB || e.msIndexedDB || e.shimIndexedDB; if (t == null) throw new Error("The current browser does not appear to support IndexedDB."); return t; } -function om(e) { +function cm(e) { let t = e.result; - t.createObjectStore(Qr, { keyPath: "modelPath" }), t.createObjectStore(ur, { keyPath: "modelPath" }); + t.createObjectStore(Qr, { keyPath: "modelPath" }), t.createObjectStore(ir, { keyPath: "modelPath" }); } var la = class { constructor(e) { - if (this.indexedDB = xk(), e == null || !e) + if (this.indexedDB = Sk(), e == null || !e) throw new Error("For IndexedDB, modelPath must not be null, undefined or empty."); this.modelPath = e; } @@ -5382,8 +5385,8 @@ var la = class { } databaseAction(e, t) { return new Promise((n, s) => { - let r = this.indexedDB.open(am, im); - r.onupgradeneeded = () => om(r), r.onsuccess = () => { + let r = this.indexedDB.open(um, lm); + r.onupgradeneeded = () => cm(r), r.onsuccess = () => { let a = r.result; if (t == null) { let i = a.transaction(Qr, "readonly"), u = i.objectStore(Qr).get(this.modelPath); @@ -5393,12 +5396,12 @@ var la = class { n(u.result.modelArtifacts); }, u.onerror = (l) => (a.close(), s(u.error)), i.oncomplete = () => a.close(); } else { - let i = Fl(t), o = a.transaction(ur, "readwrite"), u = o.objectStore(ur), l = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), c; + let i = Ol(t), o = a.transaction(ir, "readwrite"), u = o.objectStore(ir), l = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), c; l.onsuccess = () => { c = a.transaction(Qr, "readwrite"); let d = c.objectStore(Qr).put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: i }); d.onsuccess = () => n({ modelArtifactsInfo: i }), d.onerror = (h) => { - u = o.objectStore(ur); + u = o.objectStore(ir); let f = u.delete(this.modelPath); f.onsuccess = () => (a.close(), s(d.error)), f.onerror = (m) => (a.close(), s(d.error)); }; @@ -5411,24 +5414,24 @@ var la = class { } }; la.URL_SCHEME = "indexeddb://"; -var wk = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(la.URL_SCHEME) ? $_(e.slice(la.URL_SCHEME.length)) : null; -xt.registerSaveRouter(wk); -xt.registerLoadRouter(wk); -function $_(e) { +var Ik = (e) => K().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(la.URL_SCHEME) ? R_(e.slice(la.URL_SCHEME.length)) : null; +xt.registerSaveRouter(Ik); +xt.registerLoadRouter(Ik); +function R_(e) { return new la(e); } -function __(e) { +function D_(e) { return e.startsWith(la.URL_SCHEME) ? e.slice(la.URL_SCHEME.length) : e; } -var A_ = class { +var F_ = class { constructor() { - this.indexedDB = xk(); + this.indexedDB = Sk(); } async listModels() { return new Promise((e, t) => { - let n = this.indexedDB.open(am, im); - n.onupgradeneeded = () => om(n), n.onsuccess = () => { - let s = n.result, r = s.transaction(ur, "readonly"), i = r.objectStore(ur).getAll(); + let n = this.indexedDB.open(um, lm); + n.onupgradeneeded = () => cm(n), n.onsuccess = () => { + let s = n.result, r = s.transaction(ir, "readonly"), i = r.objectStore(ir).getAll(); i.onsuccess = () => { let o = {}; for (let u of i.result) @@ -5439,10 +5442,10 @@ var A_ = class { }); } async removeModel(e) { - return e = __(e), new Promise((t, n) => { - let s = this.indexedDB.open(am, im); - s.onupgradeneeded = () => om(s), s.onsuccess = () => { - let r = s.result, a = r.transaction(ur, "readwrite"), i = a.objectStore(ur), o = i.get(e), u; + return e = D_(e), new Promise((t, n) => { + let s = this.indexedDB.open(um, lm); + s.onupgradeneeded = () => cm(s), s.onsuccess = () => { + let r = s.result, a = r.transaction(ir, "readwrite"), i = a.objectStore(ir), o = i.get(e), u; o.onsuccess = () => { if (o.result == null) return r.close(), n(new Error(`Cannot find model with path '${e}' in IndexedDB.`)); @@ -5461,48 +5464,48 @@ var A_ = class { }); } }; -var Gs = "/"; -var Hi = "tensorflowjs_models"; -var kk = "info"; -var E_ = "model_topology"; -var R_ = "weight_specs"; -var D_ = "weight_data"; -var F_ = "model_metadata"; -function Ik(e) { - return { info: [Hi, e, kk].join(Gs), topology: [Hi, e, E_].join(Gs), weightSpecs: [Hi, e, R_].join(Gs), weightData: [Hi, e, D_].join(Gs), modelMetadata: [Hi, e, F_].join(Gs) }; +var Us = "/"; +var ji = "tensorflowjs_models"; +var Ck = "info"; +var O_ = "model_topology"; +var P_ = "weight_specs"; +var z_ = "weight_data"; +var M_ = "model_metadata"; +function Nk(e) { + return { info: [ji, e, Ck].join(Us), topology: [ji, e, O_].join(Us), weightSpecs: [ji, e, P_].join(Us), weightData: [ji, e, z_].join(Us), modelMetadata: [ji, e, M_].join(Us) }; } -function Sk(e) { +function Tk(e) { for (let t of Object.values(e)) window.localStorage.removeItem(t); } -function O_(e) { - let t = e.split(Gs); +function L_(e) { + let t = e.split(Us); if (t.length < 3) throw new Error(`Invalid key format: ${e}`); - return t.slice(1, t.length - 1).join(Gs); + return t.slice(1, t.length - 1).join(Us); } -function P_(e) { +function B_(e) { return e.startsWith(ca.URL_SCHEME) ? e.slice(ca.URL_SCHEME.length) : e; } var ca = class { constructor(e) { - if (!X().getBool("IS_BROWSER") || typeof window == "undefined" || typeof window.localStorage == "undefined") + if (!K().getBool("IS_BROWSER") || typeof window == "undefined" || typeof window.localStorage == "undefined") throw new Error("The current environment does not support local storage."); if (this.LS = window.localStorage, e == null || !e) throw new Error("For local storage, modelPath must not be null, undefined or empty."); - this.modelPath = e, this.keys = Ik(this.modelPath); + this.modelPath = e, this.keys = Nk(this.modelPath); } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet."); { - let t = JSON.stringify(e.modelTopology), n = JSON.stringify(e.weightSpecs), s = Fl(e); + let t = JSON.stringify(e.modelTopology), n = JSON.stringify(e.weightSpecs), s = Ol(e); try { - this.LS.setItem(this.keys.info, JSON.stringify(s)), this.LS.setItem(this.keys.topology, t), this.LS.setItem(this.keys.weightSpecs, n), this.LS.setItem(this.keys.weightData, y_(e.weightData)); + this.LS.setItem(this.keys.info, JSON.stringify(s)), this.LS.setItem(this.keys.topology, t), this.LS.setItem(this.keys.weightSpecs, n), this.LS.setItem(this.keys.weightData, k_(e.weightData)); let r = { format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, signature: e.signature != null ? e.signature : void 0, userDefinedMetadata: e.userDefinedMetadata != null ? e.userDefinedMetadata : void 0, modelInitializer: e.modelInitializer != null ? e.modelInitializer : void 0, trainingConfig: e.trainingConfig != null ? e.trainingConfig : void 0 }; return this.LS.setItem(this.keys.modelMetadata, JSON.stringify(r)), { modelArtifactsInfo: s }; } catch (r) { - throw Sk(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.weightDataBytes}.`); + throw Tk(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${s.modelTopologyBytes}, weightSpecsBytes=${s.weightSpecsBytes}, weightDataBytes=${s.weightDataBytes}.`); } } } @@ -5528,41 +5531,41 @@ var ca = class { let a = this.LS.getItem(this.keys.weightData); if (a == null) throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`); - return t.weightData = v_(a), t; + return t.weightData = S_(a), t; } }; ca.URL_SCHEME = "localstorage://"; -var Ck = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(ca.URL_SCHEME) ? z_(e.slice(ca.URL_SCHEME.length)) : null; -xt.registerSaveRouter(Ck); -xt.registerLoadRouter(Ck); -function z_(e) { +var $k = (e) => K().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(ca.URL_SCHEME) ? V_(e.slice(ca.URL_SCHEME.length)) : null; +xt.registerSaveRouter($k); +xt.registerLoadRouter($k); +function V_(e) { return new ca(e); } -var M_ = class { +var W_ = class { constructor() { - O(X().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), O(typeof window == "undefined" || typeof window.localStorage != "undefined", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage; + O(K().getBool("IS_BROWSER"), () => "Current environment is not a web browser"), O(typeof window == "undefined" || typeof window.localStorage != "undefined", () => "Current browser does not appear to support localStorage"), this.LS = window.localStorage; } async listModels() { - let e = {}, t = Hi + Gs, n = Gs + kk; + let e = {}, t = ji + Us, n = Us + Ck; for (let s = 0; s < this.LS.length; ++s) { let r = this.LS.key(s); if (r.startsWith(t) && r.endsWith(n)) { - let a = O_(r); + let a = L_(r); e[a] = JSON.parse(this.LS.getItem(r)); } } return e; } async removeModel(e) { - e = P_(e); - let t = Ik(e); + e = B_(e); + let t = Nk(e); if (this.LS.getItem(t.info) == null) throw new Error(`Cannot find model at path '${e}'`); let n = JSON.parse(this.LS.getItem(t.info)); - return Sk(t), n; + return Tk(t), n; } }; -var Ki = "://"; +var Yi = "://"; var zn = class { constructor() { this.managers = {}; @@ -5571,7 +5574,7 @@ var zn = class { return zn.instance == null && (zn.instance = new zn()), zn.instance; } static registerManager(e, t) { - O(e != null, () => "scheme must not be undefined or null."), e.endsWith(Ki) && (e = e.slice(0, e.indexOf(Ki))), O(e.length > 0, () => "scheme must not be an empty string."); + O(e != null, () => "scheme must not be undefined or null."), e.endsWith(Yi) && (e = e.slice(0, e.indexOf(Yi))), O(e.length > 0, () => "scheme must not be an empty string."); let n = zn.getInstance(); O(n.managers[e] == null, () => `A model store manager is already registered for scheme '${e}'.`), n.managers[e] = t; } @@ -5585,44 +5588,44 @@ var zn = class { return Object.keys(this.getInstance().managers); } }; -function td(e) { - if (e.indexOf(Ki) === -1) +function sd(e) { + if (e.indexOf(Yi) === -1) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${zn.getSchemes().join(",")}`); - return { scheme: e.split(Ki)[0], path: e.split(Ki)[1] }; + return { scheme: e.split(Yi)[0], path: e.split(Yi)[1] }; } -async function Nk(e, t, n = false) { +async function _k(e, t, n = false) { O(e !== t, () => `Old path and new path are the same: '${e}'`); let s = xt.getLoadHandlers(e); O(s.length > 0, () => `Copying failed because no load handler is found for source URL ${e}.`), O(s.length < 2, () => `Copying failed because more than one (${s.length}) load handlers for source URL ${e}.`); let r = s[0], a = xt.getSaveHandlers(t); O(a.length > 0, () => `Copying failed because no save handler is found for destination URL ${t}.`), O(a.length < 2, () => `Copying failed because more than one (${s.length}) save handlers for destination URL ${t}.`); - let i = a[0], o = td(e).scheme, u = td(e).path, l = o === td(e).scheme, c = await r.load(); + let i = a[0], o = sd(e).scheme, u = sd(e).path, l = o === sd(e).scheme, c = await r.load(); n && l && await zn.getManager(o).removeModel(u); let p = await i.save(c); return n && !l && await zn.getManager(o).removeModel(u), p.modelArtifactsInfo; } -async function L_() { +async function U_() { let e = zn.getSchemes(), t = {}; for (let n of e) { let s = await zn.getManager(n).listModels(); for (let r in s) { - let a = n + Ki + r; + let a = n + Yi + r; t[a] = s[r]; } } return t; } -async function B_(e) { - let t = td(e); +async function G_(e) { + let t = sd(e); return zn.getManager(t.scheme).removeModel(t.path); } -async function V_(e, t) { - return Nk(e, t, false); +async function H_(e, t) { + return _k(e, t, false); } -async function W_(e, t) { - return Nk(e, t, true); +async function q_(e, t) { + return _k(e, t, true); } -var U_ = class { +var j_ = class { fetch(e, t) { return fetch(e, t); } @@ -5638,25 +5641,25 @@ var U_ = class { return new TextDecoder(t).decode(e); } }; -if (X().get("IS_BROWSER")) { - X().setPlatform("browser", new U_()); +if (K().get("IS_BROWSER")) { + K().setPlatform("browser", new j_()); try { - zn.registerManager(ca.URL_SCHEME, new M_()); + zn.registerManager(ca.URL_SCHEME, new W_()); } catch (e) { } try { - zn.registerManager(la.URL_SCHEME, new A_()); + zn.registerManager(la.URL_SCHEME, new F_()); } catch (e) { } } -var G_ = { importFetch: () => QT() }; -var Mf; -var H_ = class { +var K_ = { importFetch: () => t$() }; +var Vf; +var X_ = class { constructor() { - this.util = ZT(), this.textEncoder = new this.util.TextEncoder(); + this.util = n$(), this.textEncoder = new this.util.TextEncoder(); } fetch(e, t) { - return X().global.fetch != null ? X().global.fetch(e, t) : (Mf == null && (Mf = G_.importFetch()), Mf(e, t)); + return K().global.fetch != null ? K().global.fetch(e, t) : (Vf == null && (Vf = K_.importFetch()), Vf(e, t)); } now() { let e = process.hrtime(); @@ -5671,44 +5674,44 @@ var H_ = class { return e.length === 0 ? "" : new this.util.TextDecoder(t).decode(e); } }; -X().get("IS_NODE") && !X().get("IS_BROWSER") && X().setPlatform("node", new H_()); +K().get("IS_NODE") && !K().get("IS_BROWSER") && K().setPlatform("node", new X_()); function De(e, t = "float32", n) { - return t = t || "float32", ag(e), new Vt(e, t, n); + return t = t || "float32", og(e), new Wt(e, t, n); } -function q_(e, t) { +function Y_(e, t) { let n = _(e, "x", "cast"); - if (!Jw(t)) + if (!nk(t)) throw new Error(`Failed to cast to unknown dtype ${t}`); if (t === "string" && n.dtype !== "string" || t !== "string" && n.dtype === "string") throw new Error("Only strings can be casted to strings"); let s = { x: n }, r = { dtype: t }; return M.runKernel(Ta, s, r); } -var ce = L({ cast_: q_ }); -function j_(e) { +var le = L({ cast_: Y_ }); +function Q_(e) { let n = { x: _(e, "x", "clone", "string_or_numeric") }; return M.runKernel(Wa, n); } -var cr = L({ clone_: j_ }); -function K_(e, t = false) { +var ur = L({ clone_: Q_ }); +function Z_(e, t = false) { console.log(e.toString(t)); } -mk(); -var X_ = { buffer: De, cast: ce, clone: cr, print: K_ }; -n_(X_); +yk(); +var J_ = { buffer: De, cast: le, clone: ur, print: Z_ }; +i_(J_); var An = {}; -Ae(An, { browserFiles: () => nA, browserHTTPRequest: () => oA, concatenateArrayBuffers: () => zg, copyModel: () => V_, decodeWeights: () => yk, encodeWeights: () => g_, fromMemory: () => lA, getLoadHandlers: () => T_, getModelArtifactsForJSON: () => Mg, getModelArtifactsInfoForJSON: () => Fl, getSaveHandlers: () => N_, http: () => Bg, isHTTPScheme: () => lm, listModels: () => L_, loadWeights: () => sA, moveModel: () => W_, registerLoadRouter: () => C_, registerSaveRouter: () => S_, removeModel: () => B_, weightsLoaderFactory: () => $k, withSaveHandler: () => cA }); -var Y_ = "model"; -var Q_ = ".json"; -var Z_ = ".weights.bin"; -function px(e) { +Ae(An, { browserFiles: () => iA, browserHTTPRequest: () => dA, concatenateArrayBuffers: () => Bg, copyModel: () => H_, decodeWeights: () => wk, encodeWeights: () => x_, fromMemory: () => hA, getLoadHandlers: () => E_, getModelArtifactsForJSON: () => Vg, getModelArtifactsInfoForJSON: () => Ol, getSaveHandlers: () => A_, http: () => Ug, isHTTPScheme: () => pm, listModels: () => U_, loadWeights: () => oA, moveModel: () => q_, registerLoadRouter: () => __, registerSaveRouter: () => $_, removeModel: () => G_, weightsLoaderFactory: () => Ek, withSaveHandler: () => fA }); +var eA = "model"; +var tA = ".json"; +var nA = ".weights.bin"; +function mx(e) { return new Promise((t) => setTimeout(t)).then(e); } -var um = class { +var dm = class { constructor(e) { - if (!X().getBool("IS_BROWSER")) + if (!K().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); - e.startsWith(um.URL_SCHEME) && (e = e.slice(um.URL_SCHEME.length)), (e == null || e.length === 0) && (e = Y_), this.modelJsonFileName = e + Q_, this.weightDataFileName = e + Z_; + e.startsWith(dm.URL_SCHEME) && (e = e.slice(dm.URL_SCHEME.length)), (e == null || e.length === 0) && (e = eA), this.modelJsonFileName = e + tA, this.weightDataFileName = e + nA; } async save(e) { if (typeof document == "undefined") @@ -5717,18 +5720,18 @@ var um = class { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet."); { - let n = [{ paths: ["./" + this.weightDataFileName], weights: e.weightSpecs }], s = vk(e, n), r = window.URL.createObjectURL(new Blob([JSON.stringify(s)], { type: "application/json" })), a = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor; - if (a.download = this.modelJsonFileName, a.href = r, await px(() => a.dispatchEvent(new MouseEvent("click"))), e.weightData != null) { + let n = [{ paths: ["./" + this.weightDataFileName], weights: e.weightSpecs }], s = kk(e, n), r = window.URL.createObjectURL(new Blob([JSON.stringify(s)], { type: "application/json" })), a = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor; + if (a.download = this.modelJsonFileName, a.href = r, await mx(() => a.dispatchEvent(new MouseEvent("click"))), e.weightData != null) { let i = this.weightDataAnchor == null ? document.createElement("a") : this.weightDataAnchor; - i.download = this.weightDataFileName, i.href = t, await px(() => i.dispatchEvent(new MouseEvent("click"))); + i.download = this.weightDataFileName, i.href = t, await mx(() => i.dispatchEvent(new MouseEvent("click"))); } - return { modelArtifactsInfo: Fl(e) }; + return { modelArtifactsInfo: Ol(e) }; } } }; -var yd = um; -yd.URL_SCHEME = "downloads://"; -var J_ = class { +var wd = dm; +wd.URL_SCHEME = "downloads://"; +var sA = class { constructor(e) { if (e == null || e.length < 1) throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`); @@ -5751,7 +5754,7 @@ var J_ = class { e({ modelTopology: a }); return; } - let o = Mg(r, (u) => this.loadWeights(u)); + let o = Vg(r, (u) => this.loadWeights(u)); e(o); }, n.onerror = (s) => t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`), n.readAsText(this.jsonFile); }); @@ -5761,7 +5764,7 @@ var J_ = class { for (let a of e) t.push(...a.weights), n.push(...a.paths); let s = this.checkManifestAndWeightFiles(e), r = n.map((a) => this.loadWeightsFile(a, s[a])); - return Promise.all(r).then((a) => [t, zg(a)]); + return Promise.all(r).then((a) => [t, Bg(a)]); } loadWeightsFile(e, t) { return new Promise((n, s) => { @@ -5773,10 +5776,10 @@ var J_ = class { }); } checkManifestAndWeightFiles(e) { - let t = [], n = this.weightsFiles.map((r) => dx(r.name)), s = {}; + let t = [], n = this.weightsFiles.map((r) => fx(r.name)), s = {}; for (let r of e) r.paths.forEach((a) => { - let i = dx(a); + let i = fx(a); if (t.indexOf(i) !== -1) throw new Error(`Duplicate file basename found in weights manifest: '${i}'`); if (t.push(i), n.indexOf(i) === -1) @@ -5788,15 +5791,15 @@ var J_ = class { return s; } }; -var eA = (e) => X().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(yd.URL_SCHEME) ? tA(e.slice(yd.URL_SCHEME.length)) : null; -xt.registerSaveRouter(eA); -function tA(e = "model") { - return new yd(e); +var rA = (e) => K().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(wd.URL_SCHEME) ? aA(e.slice(wd.URL_SCHEME.length)) : null; +xt.registerSaveRouter(rA); +function aA(e = "model") { + return new wd(e); } -function nA(e) { - return new J_(e); +function iA(e) { + return new sA(e); } -function hx(e, t, n, s) { +function gx(e, t, n, s) { i(e), n = n == null ? 0 : n, s = s == null ? 1 : s, o(n, s); let r = 0, a = (u) => (u.then((l) => { let c = n + ++r / e.length * (s - n); @@ -5810,21 +5813,21 @@ function hx(e, t, n, s) { } return Promise.all(e.map(a)); } -async function Tk(e, t) { +async function Ak(e, t) { t == null && (t = {}); - let n = t.fetchFunc == null ? X().platform.fetch : t.fetchFunc, s = e.map((p) => n(p, t.requestInit, { isBinary: true })), r = 0, a = 0.5, o = (t.onProgress == null ? await Promise.all(s) : await hx(s, t.onProgress, r, a)).map((p) => p.arrayBuffer()), u = 0.5, l = 1; - return t.onProgress == null ? await Promise.all(o) : await hx(o, t.onProgress, u, l); + let n = t.fetchFunc == null ? K().platform.fetch : t.fetchFunc, s = e.map((p) => n(p, t.requestInit, { isBinary: true })), r = 0, a = 0.5, o = (t.onProgress == null ? await Promise.all(s) : await gx(s, t.onProgress, r, a)).map((p) => p.arrayBuffer()), u = 0.5, l = 1; + return t.onProgress == null ? await Promise.all(o) : await gx(o, t.onProgress, u, l); } -async function sA(e, t = "", n, s) { - return $k((i) => Tk(i, { requestInit: s }))(e, t, n); +async function oA(e, t = "", n, s) { + return Ek((i) => Ak(i, { requestInit: s }))(e, t, n); } -function $k(e) { +function Ek(e) { return async (t, n = "", s) => { let r = t.map(() => false), a = {}, i = s != null ? s.map(() => false) : [], o = []; if (t.forEach((h, f) => { let m = 0; h.weights.forEach((g) => { - let b = "quantization" in g ? g.quantization.dtype : g.dtype, y = rm[b] * pt(g.shape), v = () => { + let b = "quantization" in g ? g.quantization.dtype : g.dtype, y = om[b] * dt(g.shape), v = () => { r[f] = true, a[f] == null && (a[f] = []), a[f].push({ manifestEntry: g, groupOffset: m, sizeBytes: y }); }; s != null ? s.forEach((x, k) => { @@ -5854,18 +5857,18 @@ Manifest JSON has weights with names: ${o.join(", ")}.`); b.set(k, y), y += k.byteLength; } a[h].forEach((x) => { - let k = g.slice(x.groupOffset, x.groupOffset + x.sizeBytes), S = yk(k, [x.manifestEntry]); - for (let $ in S) - p[$] = S[$]; + let k = g.slice(x.groupOffset, x.groupOffset + x.sizeBytes), I = wk(k, [x.manifestEntry]); + for (let $ in I) + p[$] = I[$]; }), d += f; }), p; }; } -var rA = "application/octet-stream"; -var aA = "application/json"; -var Lg = class { +var uA = "application/octet-stream"; +var lA = "application/json"; +var Wg = class { constructor(e, t) { - if (this.DEFAULT_METHOD = "POST", t == null && (t = {}), this.weightPathPrefix = t.weightPathPrefix, this.onProgress = t.onProgress, this.weightUrlConverter = t.weightUrlConverter, t.fetchFunc != null ? (O(typeof t.fetchFunc == "function", () => "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"), this.fetch = t.fetchFunc) : this.fetch = X().platform.fetch, O(e != null && e.length > 0, () => "URL path for http must not be null, undefined or empty."), Array.isArray(e) && O(e.length === 2, () => `URL paths for http must have a length of 2, (actual length is ${e.length}).`), this.path = e, t.requestInit != null && t.requestInit.body != null) + if (this.DEFAULT_METHOD = "POST", t == null && (t = {}), this.weightPathPrefix = t.weightPathPrefix, this.onProgress = t.onProgress, this.weightUrlConverter = t.weightUrlConverter, t.fetchFunc != null ? (O(typeof t.fetchFunc == "function", () => "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"), this.fetch = t.fetchFunc) : this.fetch = K().platform.fetch, O(e != null && e.length > 0, () => "URL path for http must not be null, undefined or empty."), Array.isArray(e) && O(e.length === 2, () => `URL paths for http must have a length of 2, (actual length is ${e.length}).`), this.path = e, t.requestInit != null && t.requestInit.body != null) throw new Error("requestInit is expected to have no pre-existing body, but has one."); this.requestInit = t.requestInit || {}; } @@ -5874,11 +5877,11 @@ var Lg = class { throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet."); let t = Object.assign({ method: this.DEFAULT_METHOD }, this.requestInit); t.body = new FormData(); - let n = [{ paths: ["./model.weights.bin"], weights: e.weightSpecs }], s = vk(e, n); - t.body.append("model.json", new Blob([JSON.stringify(s)], { type: aA }), "model.json"), e.weightData != null && t.body.append("model.weights.bin", new Blob([e.weightData], { type: rA }), "model.weights.bin"); + let n = [{ paths: ["./model.weights.bin"], weights: e.weightSpecs }], s = kk(e, n); + t.body.append("model.json", new Blob([JSON.stringify(s)], { type: lA }), "model.json"), e.weightData != null && t.body.append("model.weights.bin", new Blob([e.weightData], { type: uA }), "model.weights.bin"); let r = await this.fetch(this.path, t); if (r.ok) - return { modelArtifactsInfo: Fl(e), responses: [r] }; + return { modelArtifactsInfo: Ol(e), responses: [r] }; throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`); } async load() { @@ -5895,10 +5898,10 @@ var Lg = class { let n = t.modelTopology, s = t.weightsManifest; if (n == null && s == null) throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`); - return Mg(t, (r) => this.loadWeights(r)); + return Vg(t, (r) => this.loadWeights(r)); } async loadWeights(e) { - let t = Array.isArray(this.path) ? this.path[1] : this.path, [n, s] = iA(t), r = this.weightPathPrefix || n, a = []; + let t = Array.isArray(this.path) ? this.path[1] : this.path, [n, s] = cA(t), r = this.weightPathPrefix || n, a = []; for (let l of e) a.push(...l.weights); let i = [], o = []; @@ -5906,37 +5909,37 @@ var Lg = class { for (let c of l.paths) this.weightUrlConverter != null ? o.push(this.weightUrlConverter(c)) : i.push(r + c + s); this.weightUrlConverter && i.push(...await Promise.all(o)); - let u = await Tk(i, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress }); - return [a, zg(u)]; + let u = await Ak(i, { requestInit: this.requestInit, fetchFunc: this.fetch, onProgress: this.onProgress }); + return [a, Bg(u)]; } }; -Lg.URL_SCHEME_REGEX = /^https?:\/\//; -function iA(e) { +Wg.URL_SCHEME_REGEX = /^https?:\/\//; +function cA(e) { let t = e.lastIndexOf("/"), n = e.lastIndexOf("?"), s = e.substring(0, t), r = n > t ? e.substring(n) : ""; return [s + "/", r]; } -function lm(e) { - return e.match(Lg.URL_SCHEME_REGEX) != null; +function pm(e) { + return e.match(Wg.URL_SCHEME_REGEX) != null; } -var _k = (e, t) => { +var Rk = (e, t) => { if (typeof fetch == "undefined" && (t == null || t.fetchFunc == null)) return null; { let n = true; - if (Array.isArray(e) ? n = e.every((s) => lm(s)) : n = lm(e), n) - return Bg(e, t); + if (Array.isArray(e) ? n = e.every((s) => pm(s)) : n = pm(e), n) + return Ug(e, t); } return null; }; -xt.registerSaveRouter(_k); -xt.registerLoadRouter(_k); -function Bg(e, t) { - return new Lg(e, t); +xt.registerSaveRouter(Rk); +xt.registerLoadRouter(Rk); +function Ug(e, t) { + return new Wg(e, t); } -function oA(e, t) { - return Bg(e, t); +function dA(e, t) { + return Ug(e, t); } -var Lf = class { +var Wf = class { constructor(e) { this.modelArtifacts = e; } @@ -5944,7 +5947,7 @@ var Lf = class { return this.modelArtifacts; } }; -var uA = class { +var pA = class { constructor(e) { this.saveHandler = e; } @@ -5952,29 +5955,29 @@ var uA = class { return this.saveHandler(e); } }; -function lA(e, t, n, s) { - return arguments.length === 1 ? e.modelTopology != null || e.weightSpecs != null ? new Lf(e) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new Lf({ modelTopology: e })) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new Lf({ modelTopology: e, weightSpecs: t, weightData: n, trainingConfig: s })); +function hA(e, t, n, s) { + return arguments.length === 1 ? e.modelTopology != null || e.weightSpecs != null ? new Wf(e) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new Wf({ modelTopology: e })) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new Wf({ modelTopology: e, weightSpecs: t, weightData: n, trainingConfig: s })); } -function cA(e) { - return new uA(e); +function fA(e) { + return new pA(e); } -var dA = {}; -Ae(dA, { confusionMatrix: () => gA }); -function pA(e, t, n = false, s = false) { +var mA = {}; +Ae(mA, { confusionMatrix: () => xA }); +function gA(e, t, n = false, s = false) { let r = _(e, "a", "matMul"), a = _(t, "b", "matMul"); [r, a] = vt(r, a); let i = { a: r, b: a }, o = { transposeA: n, transposeB: s }; return M.runKernel(Na, i, o); } -var We = L({ matMul_: pA }); -function hA(e, t, n = 1, s = 0) { +var Ve = L({ matMul_: gA }); +function bA(e, t, n = 1, s = 0) { if (t < 2) throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`); let a = { indices: _(e, "indices", "oneHot", "int32") }, i = { depth: t, onValue: n, offValue: s }; - return M.runKernel(Ao, a, i); + return M.runKernel(Ro, a, i); } -var vd = L({ oneHot_: hA }); -function fA(e, t) { +var kd = L({ oneHot_: bA }); +function yA(e, t) { let n = _(e, "x", "transpose"); if (t == null && (t = n.shape.map((a, i) => i).reverse()), O(n.rank === t.length, () => `Error in transpose: rank of input ${n.rank} must match length of perm ${t}.`), t.forEach((a) => { O(a >= 0 && a < n.rank, () => `All entries in 'perm' must be between 0 and ${n.rank - 1} but got ${t}`); @@ -5983,17 +5986,17 @@ function fA(e, t) { let s = { x: n }, r = { perm: t }; return M.runKernel(mi, s, r); } -var Ge = L({ transpose_: fA }); -function mA(e, t, n) { +var Ge = L({ transpose_: yA }); +function vA(e, t, n) { let s = _(e, "labels", "confusionMatrix"), r = _(t, "predictions", "confusionMatrix"); O(n == null || n > 0 && Number.isInteger(n), () => `If provided, numClasses must be a positive integer, but got ${n}`), O(s.rank === 1, () => `Expected the rank of labels to be 1, but got ${s.rank}`), O(r.rank === 1, () => `Expected the rank of predictions to be 1, but got ${r.rank}`), O(s.shape[0] === r.shape[0], () => `Mismatch in the number of examples: ${s.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`), O(n > 0 && Number.isInteger(n), () => `numClasses is required to be a positive integer, but got ${n}`); - let a = vd(ce(s, "int32"), n), i = vd(ce(r, "int32"), n), o = Ge(a), u = We(o, i); - return ce(u, "int32"); + let a = kd(le(s, "int32"), n), i = kd(le(r, "int32"), n), o = Ge(a), u = Ve(o, i); + return le(u, "int32"); } -var gA = L({ confusionMatrix_: mA }); -var Ko = {}; -Ae(Ko, { assertAndGetBroadcastShape: () => it, getBroadcastDims: () => Ak, getReductionAxes: () => _t }); -function Ak(e, t) { +var xA = L({ confusionMatrix_: vA }); +var bi = {}; +Ae(bi, { assertAndGetBroadcastShape: () => it, getBroadcastDims: () => Dk, getReductionAxes: () => _t }); +function Dk(e, t) { let n = e.length, s = []; for (let r = 0; r < n; r++) { let a = n - 1 - r, i = e[a] || 1; @@ -6027,9 +6030,9 @@ function it(e, t) { } return n; } -var Ek = {}; -Ae(Ek, { fromPixels: () => SA, fromPixelsAsync: () => kA, toPixels: () => IA }); -function bA(e, t, n) { +var Fk = {}; +Ae(Fk, { fromPixels: () => $A, fromPixelsAsync: () => NA, toPixels: () => TA }); +function wA(e, t, n) { if (ka(e), t != null && t.length !== 3) throw new Error("tensor3d() requires shape to have three numbers"); let s = Rs(e, n); @@ -6037,10 +6040,10 @@ function bA(e, t, n) { throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray"); if (s.length === 1 && t == null) throw new Error("tensor3d() requires shape to be provided when `values` are a flat array"); - return Tr(e, t, s, n); + return Nr(e, t, s, n); } var Wr; -function Rk(e, t = 3) { +function Ok(e, t = 3) { if (t > 4) throw new Error("Cannot construct Tensor with more than 4 channels from pixels."); if (e == null) @@ -6062,9 +6065,9 @@ function Rk(e, t = 3) { throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`); if (r && r && e.readyState < 2) throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the