diff --git a/dist/human.esm-nobundle.js b/dist/human.esm-nobundle.js index b0df5756..b7ae9287 100644 --- a/dist/human.esm-nobundle.js +++ b/dist/human.esm-nobundle.js @@ -4,7 +4,7 @@ author: ' */ -var It=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var yr=Object.prototype.hasOwnProperty;var xr=(e,t,o)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var Y0=(e,t)=>{for(var o in t)It(e,o,{get:t[o],enumerable:!0})},bo=(e,t,o,A)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of lr(t))!yr.call(e,n)&&n!==o&&It(e,n,{get:()=>t[n],enumerable:!(A=ir(t,n))||A.enumerable});return e},Z=(e,t,o)=>(bo(e,t,"default"),o&&bo(o,t,"default"));var R=(e,t,o)=>(xr(e,typeof t!="symbol"?t+"":t,o),o),go=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var Ee=(e,t,o)=>(go(e,t,"read from private field"),o?o.call(e):t.get(e)),ze=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)},je=(e,t,o,A)=>(go(e,t,"write to private field"),A?A.call(e,o):t.set(e,o),o);function g(...e){let t=new Date,o=`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`;e&&console.log(o,"Human:",...e)}function Mo(e,t){let o=e.endsWith("/")?"":"/",n=t.startsWith(".")||t.startsWith("/")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("file:")?`${t}`:`${e}${o}${t}`;if(!n.toLocaleLowerCase().includes(".json"))throw new Error(`modelpath error: expecting json file: ${n}`);return n}var M=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function Ot(e,t,o="config",A=[]){for(let n of Object.keys(t))if(typeof t[n]=="object")Ot(e[n],t[n],n,A);else{let s=e&&typeof e[n]!="undefined";s||A.push({reason:"unknown property",where:`${o}.${n} = ${t[n]}`});let a=e&&typeof e[n]==typeof t[n];s&&!a&&A.push({reason:"property type mismatch",where:`${o}.${n} = ${t[n]}`,expected:typeof e[n]})}return t.debug&&o==="config"&&A.length>0&&g("invalid configuration",A),A}function o0(...e){let t=o=>o&&typeof o=="object";return e.reduce((o,A)=>(Object.keys(A||{}).forEach(n=>{let s=o[n],a=A[n];Array.isArray(s)&&Array.isArray(a)?o[n]=s.concat(...a):t(s)&&t(a)?o[n]=o0(s,a):o[n]=a}),o),{})}var K0={backend:"",modelBasePath:"",cacheModels:!0,wasmPath:"",wasmPlatformFetch:!1,debug:!0,async:!0,warmup:"full",cacheSensitivity:.7,skipAllowed:!1,deallocate:!1,filter:{enabled:!0,equalization:!1,width:0,height:0,flip:!1,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"blazeface.json",rotation:!0,maxDetected:1,skipFrames:99,skipTime:2500,minConfidence:.2,iouThreshold:.1,mask:!1,return:!1},mesh:{enabled:!0,modelPath:"facemesh.json"},iris:{enabled:!0,modelPath:"iris.json"},emotion:{enabled:!0,minConfidence:.1,skipFrames:99,skipTime:1500,modelPath:"emotion.json"},description:{enabled:!0,modelPath:"faceres.json",skipFrames:99,skipTime:3e3,minConfidence:.1},antispoof:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"antispoof.json"},liveness:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"liveness.json"}},body:{enabled:!0,modelPath:"movenet-lightning.json",maxDetected:-1,minConfidence:.3,skipFrames:1,skipTime:200},hand:{enabled:!0,rotation:!0,skipFrames:99,skipTime:1e3,minConfidence:.5,iouThreshold:.2,maxDetected:-1,landmarks:!0,detector:{modelPath:"handtrack.json"},skeleton:{modelPath:"handlandmark-full.json"}},object:{enabled:!1,modelPath:"mb3-centernet.json",minConfidence:.2,iouThreshold:.4,maxDetected:10,skipFrames:99,skipTime:2e3},segmentation:{enabled:!1,modelPath:"selfie.json",blur:8}};var r={};Y0(r,{GraphModel:()=>Nt,Tensor:()=>ae,version:()=>Se});Z(r,os);Z(r,As);import*as os from"@tensorflow/tfjs/dist/index.js";import*as As from"@tensorflow/tfjs-backend-webgl/dist/index.js";import{Tensor as ae}from"@tensorflow/tfjs/dist/index.js";import{GraphModel as Nt}from"@tensorflow/tfjs-converter/dist/index";var cr="3.15.0",dr="3.15.0",fr="3.15.0",mr="3.15.0",pr="3.15.0",ur="3.15.0",hr="3.15.0",br="3.15.0",Se={tfjs:cr,"tfjs-core":dr,"tfjs-data":fr,"tfjs-layers":mr,"tfjs-converter":pr,"tfjs-backend-cpu":ur,"tfjs-backend-webgl":hr,"tfjs-backend-wasm":br};var Po=` +var Lt=Object.defineProperty;var lr=Object.getOwnPropertyDescriptor;var yr=Object.getOwnPropertyNames;var xr=Object.prototype.hasOwnProperty;var cr=(e,t,o)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var K0=(e,t)=>{for(var o in t)Lt(e,o,{get:t[o],enumerable:!0})},Mo=(e,t,o,A)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of yr(t))!xr.call(e,n)&&n!==o&&Lt(e,n,{get:()=>t[n],enumerable:!(A=lr(t,n))||A.enumerable});return e},Z=(e,t,o)=>(Mo(e,t,"default"),o&&Mo(o,t,"default"));var R=(e,t,o)=>(cr(e,typeof t!="symbol"?t+"":t,o),o),Po=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var Ee=(e,t,o)=>(Po(e,t,"read from private field"),o?o.call(e):t.get(e)),ze=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)},je=(e,t,o,A)=>(Po(e,t,"write to private field"),A?A.call(e,o):t.set(e,o),o);function g(...e){let t=new Date,o=`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`;e&&console.log(o,"Human:",...e)}function vo(e,t){let o=e.endsWith("/")?"":"/",n=t.startsWith(".")||t.startsWith("/")||t.startsWith("http:")||t.startsWith("https:")||t.startsWith("file:")?`${t}`:`${e}${o}${t}`;if(!n.toLocaleLowerCase().includes(".json"))throw new Error(`modelpath error: expecting json file: ${n}`);return n}var M=()=>typeof performance!="undefined"?performance.now():parseInt((Number(process.hrtime.bigint())/1e3/1e3).toString());function Gt(e,t,o="config",A=[]){for(let n of Object.keys(t))if(typeof t[n]=="object")Gt(e[n],t[n],n,A);else{let s=e&&typeof e[n]!="undefined";s||A.push({reason:"unknown property",where:`${o}.${n} = ${t[n]}`});let a=e&&typeof e[n]==typeof t[n];s&&!a&&A.push({reason:"property type mismatch",where:`${o}.${n} = ${t[n]}`,expected:typeof e[n]})}return t.debug&&o==="config"&&A.length>0&&g("invalid configuration",A),A}function o0(...e){let t=o=>o&&typeof o=="object";return e.reduce((o,A)=>(Object.keys(A||{}).forEach(n=>{let s=o[n],a=A[n];Array.isArray(s)&&Array.isArray(a)?o[n]=s.concat(...a):t(s)&&t(a)?o[n]=o0(s,a):o[n]=a}),o),{})}var Q0={backend:"",modelBasePath:"",cacheModels:!0,wasmPath:"",wasmPlatformFetch:!1,debug:!0,async:!0,warmup:"full",cacheSensitivity:.7,skipAllowed:!1,deallocate:!1,filter:{enabled:!0,equalization:!1,width:0,height:0,flip:!1,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},gesture:{enabled:!0},face:{enabled:!0,detector:{modelPath:"blazeface.json",rotation:!0,maxDetected:1,skipFrames:99,skipTime:2500,minConfidence:.2,iouThreshold:.1,mask:!1,return:!1},mesh:{enabled:!0,modelPath:"facemesh.json"},iris:{enabled:!0,modelPath:"iris.json"},emotion:{enabled:!0,minConfidence:.1,skipFrames:99,skipTime:1500,modelPath:"emotion.json"},description:{enabled:!0,modelPath:"faceres.json",skipFrames:99,skipTime:3e3,minConfidence:.1},antispoof:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"antispoof.json"},liveness:{enabled:!1,skipFrames:99,skipTime:4e3,modelPath:"liveness.json"}},body:{enabled:!0,modelPath:"movenet-lightning.json",maxDetected:-1,minConfidence:.3,skipFrames:1,skipTime:200},hand:{enabled:!0,rotation:!0,skipFrames:99,skipTime:1e3,minConfidence:.5,iouThreshold:.2,maxDetected:-1,landmarks:!0,detector:{modelPath:"handtrack.json"},skeleton:{modelPath:"handlandmark-full.json"}},object:{enabled:!1,modelPath:"mb3-centernet.json",minConfidence:.2,iouThreshold:.4,maxDetected:10,skipFrames:99,skipTime:2e3},segmentation:{enabled:!1,modelPath:"selfie.json",blur:8}};var r={};K0(r,{GraphModel:()=>Bt,Tensor:()=>ae,version:()=>Se});Z(r,os);Z(r,As);import*as os from"@tensorflow/tfjs/dist/index.js";import*as As from"@tensorflow/tfjs-backend-webgl/dist/index.js";import{Tensor as ae}from"@tensorflow/tfjs/dist/index.js";import{GraphModel as Bt}from"@tensorflow/tfjs-converter/dist/index";var dr="3.15.0",fr="3.15.0",mr="3.15.0",pr="3.15.0",ur="3.15.0",hr="3.15.0",br="3.15.0",gr="3.15.0",Se={tfjs:dr,"tfjs-core":fr,"tfjs-data":mr,"tfjs-layers":pr,"tfjs-converter":ur,"tfjs-backend-cpu":hr,"tfjs-backend-webgl":br,"tfjs-backend-wasm":gr};var To=` precision highp float; attribute vec2 pos; attribute vec2 uv; @@ -14,7 +14,7 @@ var It=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var lr=Objec vUv = uv; gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.); } -`;var vo=` +`;var wo=` precision highp float; varying vec2 vUv; uniform sampler2D texture; @@ -26,7 +26,7 @@ var It=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var lr=Objec gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14]; gl_FragColor.a = m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19]; } -`,To=` +`,Ro=` precision highp float; varying vec2 vUv; uniform sampler2D texture; @@ -38,7 +38,7 @@ var It=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var lr=Objec gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[14]; gl_FragColor.a = c.a; } -`,wo=` +`,ko=` precision highp float; varying vec2 vUv; uniform vec2 size; @@ -51,7 +51,7 @@ var It=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var lr=Objec vec2 coord = pixelate(vUv, size); gl_FragColor += texture2D(texture, coord); } -`,Ro=` +`,Eo=` precision highp float; varying vec2 vUv; uniform sampler2D texture; @@ -74,7 +74,7 @@ var It=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var lr=Objec gl_FragColor += texture2D(texture, vUv + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794; gl_FragColor += texture2D(texture, vUv + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265; } -`,ko=` +`,zo=` precision highp float; varying vec2 vUv; uniform sampler2D texture; @@ -96,7 +96,7 @@ var It=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var lr=Objec c31 * m[6] + c32 * m[7] + c33 * m[8]; gl_FragColor.a = c22.a; } -`;var Lt=(e,t,o)=>{let A=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(A,(n,s)=>(o[s]=0,n))},Eo=class{constructor(t,o,A){R(this,"uniform",{});R(this,"attribute",{});R(this,"gl");R(this,"id");R(this,"compile",(t,o)=>{let A=this.gl.createShader(o);return A?(this.gl.shaderSource(A,t),this.gl.compileShader(A),this.gl.getShaderParameter(A,this.gl.COMPILE_STATUS)?A:(g(`filter: gl compile failed: ${this.gl.getShaderInfoLog(A)}`),null)):(g("filter: could not create shader"),null)});this.gl=t;let n=this.compile(o,this.gl.VERTEX_SHADER),s=this.compile(A,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!n||!s)){if(!this.id){g("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,n),this.gl.attachShader(this.id,s),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){g(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),Lt(o,"attribute",this.attribute);for(let a in this.attribute)this.attribute[a]=this.gl.getAttribLocation(this.id,a);Lt(o,"uniform",this.uniform),Lt(A,"uniform",this.uniform);for(let a in this.uniform)this.uniform[a]=this.gl.getUniformLocation(this.id,a)}}};function zo(){let e=0,t=null,o=!1,A=-1,n=[null,null],s=[],a=null,i=null,x=s0(100,100),d={},l={INTERMEDIATE:1},y=x.getContext("webgl");if(this.gl=y,!y){g("filter: cannot get webgl context");return}function c(P,p){if(!(P===x.width&&p===x.height)){if(x.width=P,x.height=p,!a){let u=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,u,y.STATIC_DRAW),y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}y.viewport(0,0,x.width,x.height),n=[null,null]}}function f(P,p){let u=y.createFramebuffer();y.bindFramebuffer(y.FRAMEBUFFER,u);let E=y.createRenderbuffer();y.bindRenderbuffer(y.RENDERBUFFER,E);let W=y.createTexture();return y.bindTexture(y.TEXTURE_2D,W),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,P,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,W,0),y.bindTexture(y.TEXTURE_2D,null),y.bindFramebuffer(y.FRAMEBUFFER,null),{fbo:u,texture:W}}function h(P){return n[P]=n[P]||f(x.width,x.height),n[P]}function m(P=0){if(!i)return;let p=null,u=null,E=!1;e===0?p=t:p=h(A).texture||null,e++,o&&!(P&l.INTERMEDIATE)?(u=null,E=e%2===0):(A=(A+1)%2,u=h(A).fbo||null),y.bindTexture(y.TEXTURE_2D,p),y.bindFramebuffer(y.FRAMEBUFFER,u),y.uniform1f(i.uniform.flipY,E?-1:1),y.drawArrays(y.TRIANGLES,0,6)}function v(P){if(d[P])return i=d[P],y.useProgram((i?i.id:null)||null),i;if(i=new Eo(y,Po,P),!i)return g("filter: could not get webgl program"),null;let p=Float32Array.BYTES_PER_ELEMENT,u=4*p;return y.enableVertexAttribArray(i.attribute.pos),y.vertexAttribPointer(i.attribute.pos,2,y.FLOAT,!1,u,0*p),y.enableVertexAttribArray(i.attribute.uv),y.vertexAttribPointer(i.attribute.uv,2,y.FLOAT,!1,u,2*p),d[P]=i,i}let b={colorMatrix:P=>{let p=new Float32Array(P);p[4]/=255,p[9]/=255,p[14]/=255,p[19]/=255;let u=p[18]===1&&p[3]===0&&p[8]===0&&p[13]===0&&p[15]===0&&p[16]===0&&p[17]===0&&p[19]===0?To:vo,E=v(u);!E||(y.uniform1fv(E.uniform.m,p),m())},brightness:P=>{let p=(P||0)+1;b.colorMatrix([p,0,0,0,0,0,p,0,0,0,0,0,p,0,0,0,0,0,1,0])},saturation:P=>{let p=(P||0)*2/3+1,u=(p-1)*-.5;b.colorMatrix([p,u,u,0,0,u,p,u,0,0,u,u,p,0,0,0,0,0,1,0])},desaturate:()=>{b.saturation(-1)},contrast:P=>{let p=(P||0)+1,u=-128*(p-1);b.colorMatrix([p,0,0,0,u,0,p,0,0,u,0,0,p,0,u,0,0,0,1,0])},negative:()=>{b.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let p=Math.cos(P),u=Math.sin(P),E=.213,W=.715,C=.072;b.colorMatrix([E+p*(1-E)+u*-E,W+p*-W+u*-W,C+p*-C+u*(1-C),0,0,E+p*-E+u*.143,W+p*(1-W)+u*.14,C+p*-C+u*-.283,0,0,E+p*-E+u*-(1-E),W+p*-W+u*W,C+p*(1-C)+u*C,0,0,0,0,0,1,0])},desaturateLuminance:()=>{b.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:()=>{b.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{b.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:()=>{b.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:()=>{b.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:()=>{b.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:()=>{b.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:()=>{b.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let p=new Float32Array(P),u=1/x.width,E=1/x.height,W=v(ko);!W||(y.uniform1fv(W.uniform.m,p),y.uniform2f(W.uniform.px,u,E),m())},detectEdges:()=>{b.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{b.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{b.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let p=P||1;b.convolution.call(this,[0,-1*p,0,-1*p,1+4*p,-1*p,0,-1*p,0])},emboss:P=>{let p=P||1;b.convolution.call(this,[-2*p,-1*p,0,-1*p,1,1*p,0,1*p,2*p])},blur:P=>{let p=P/7/x.width,u=P/7/x.height,E=v(Ro);!E||(y.uniform2f(E.uniform.px,0,u),m(l.INTERMEDIATE),y.uniform2f(E.uniform.px,p,0),m())},pixelate:P=>{let p=P/x.width,u=P/x.height,E=v(wo);!E||(y.uniform2f(E.uniform.size,p,u),m())}};this.add=function(P){let p=Array.prototype.slice.call(arguments,1),u=b[P];s.push({func:u,args:p})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(P){c(P.width,P.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,P);for(let p=0;pf.data())),a=.99*Math.max(s[0][0],s[1][0],s[2][0]),i=[r.sub(o[0],A[0]),r.sub(o[1],A[1]),r.sub(o[2],A[2])],x=[r.sub(n[0],A[0]),r.sub(n[1],A[1]),r.sub(n[2],A[2])],d=[r.div(a,x[0]),r.div(a,x[1]),r.div(a,x[2])],l=[r.mul(i[0],d[0]),r.mul(i[1],d[1]),r.mul(i[2],d[2])],y=r.stack([l[0],l[1],l[2]],2),c=r.reshape(y,[1,t.shape[0],t.shape[1],3]);return r.dispose([...o,...A,...n,...i,...x,...d,...l,y,t]),c}var qe=2048,B=null,_=null,ie=null,D,j0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function s0(e,t){let o;if(w.browser)if(w.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 w.Canvas!="undefined"?o=new w.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function Gt(e,t){let o=t||s0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function le(e,t,o=!0){if(!e)return t.debug&&g("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof ae)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof w.Canvas!="undefined"&&e instanceof w.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 ae){let A=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)A=r.expandDims(e,0);else if(e.shape[2]===4){let n=r.slice3d(e,[0,0,0],[-1,-1,3]);A=r.expandDims(n,0),r.dispose(n)}}else e.shape.length===4&&(e.shape[3]===3?A=r.clone(e):e.shape[3]===4&&(A=r.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(A==null||A.shape.length!==4||A.shape[0]!==1||A.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(A.dtype==="int32"){let n=r.cast(A,"float32");r.dispose(A),A=n}return{tensor:A,canvas:t.filter.return?_:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&g("input stream is not ready"),{tensor:null,canvas:B};let A=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,n=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!A||!n)return t.debug&&g("cannot determine input dimensions"),{tensor:null,canvas:B};let s=A,a=n;if(s>qe&&(s=qe,a=Math.trunc(s*n/A)),a>qe&&(a=qe,s=Math.trunc(a*A/n)),(t.filter.width||0)>0?s=t.filter.width:(t.filter.height||0)>0&&(s=A*((t.filter.height||0)/n)),(t.filter.height||0)>0?a=t.filter.height:(t.filter.width||0)>0&&(a=n*((t.filter.width||0)/A)),!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=s0(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(A,0),i.scale(-1,1),i.drawImage(e,0,0,A,n,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,A,n,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))&&(_=s0(B.width,B.height)),t.filter.enabled&&w.webgl.supported){if(D||(D=w.browser?new zo:null),w.filter=!!D,!D||!D.add)return t.debug&&g("input process error: cannot initialize filters"),{tensor:null,canvas:B};D.reset(),t.filter.brightness!==0&&D.add("brightness",t.filter.brightness),t.filter.contrast!==0&&D.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&D.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&D.add("blur",t.filter.blur),t.filter.saturation!==0&&D.add("saturation",t.filter.saturation),t.filter.hue!==0&&D.add("hue",t.filter.hue),t.filter.negative&&D.add("negative"),t.filter.sepia&&D.add("sepia"),t.filter.vintage&&D.add("brownie"),t.filter.sepia&&D.add("sepia"),t.filter.kodachrome&&D.add("kodachrome"),t.filter.technicolor&&D.add("technicolor"),t.filter.polaroid&&D.add("polaroid"),t.filter.pixelate!==0&&D.add("pixelate",t.filter.pixelate),D.get()>0?_=D.apply(B):_=D.draw(B)}else Gt(B,_),D&&(D=null),w.filter=!!D;if(!o)return{tensor:null,canvas:_};if(!_)throw new Error("canvas error: cannot create output");let x,d=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(w.browser&&r.browser)x=r.browser?r.browser.fromPixels(e):null;else{d=e.data.length/e.height/e.width;let c=new Uint8Array(e.data.buffer);x=r.tensor(c,[e.height,e.width,d],"int32")}else if((!ie||_.width!==ie.width||_.height!==ie.height)&&(ie=s0(_.width,_.height)),r.browser&&w.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?x=r.browser.fromPixels(_):(ie=Gt(_),x=r.browser.fromPixels(ie));else{let h=Gt(_).getContext("2d").getImageData(0,0,s,a);d=h.data.length/s/a;let m=new Uint8Array(h.data.buffer);x=r.tensor(m,[s,a,d])}if(d===4){let c=r.slice3d(x,[0,0,0],[-1,-1,3]);r.dispose(x),x=c}if(!x)throw new Error("input error: cannot create tensor");let l=r.cast(x,"float32"),y=t.filter.equalization?await De(l):r.expandDims(l,0);return r.dispose([x,l]),{tensor:y,canvas:t.filter.return?_:null}}}async function jo(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(!j0.inputTensor)j0.inputTensor=r.clone(t);else if(j0.inputTensor.shape[1]!==t.shape[1]||j0.inputTensor.shape[2]!==t.shape[2])r.dispose(j0.inputTensor),j0.inputTensor=r.clone(t);else{let A={};A.diff=r.sub(t,j0.inputTensor),A.squared=r.mul(A.diff,A.diff),A.sum=r.sum(A.squared);let s=(await A.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;r.dispose([j0.inputTensor,A.diff,A.squared,A.sum]),j0.inputTensor=r.clone(t),o=s<=(e.cacheSensitivity||0)}return o}async function So(e,t,o){let A={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||g("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||g("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;A.input1=r.clone(t),A.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?r.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):r.clone(o),A.diff=r.sub(A.input1,A.input2),A.squared=r.mul(A.diff,A.diff),A.sum=r.sum(A.squared);let s=(await A.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return r.dispose([A.input1,A.input2,A.diff,A.squared,A.sum]),s}var Wo=class{constructor(){R(this,"browser");R(this,"node");R(this,"worker");R(this,"platform","");R(this,"agent","");R(this,"backends",[]);R(this,"initial");R(this,"filter");R(this,"tfjs");R(this,"offscreen");R(this,"perfadd",!1);R(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});R(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});R(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});R(this,"cpu",{model:void 0,flags:[]});R(this,"kernels",[]);R(this,"Canvas");R(this,"Image");R(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:Se["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(r.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&r.getBackend()==="wasm"&&(this.wasm.simd=await r.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await r.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=s0(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&&(r.getBackend()==="webgl"||r.getBackend()==="humangl")){let A=r.backend().gpgpu!=="undefined"?await r.backend().getGPGPUContext().gl:null;A&&(this.webgl.version=A.getParameter(A.VERSION),this.webgl.renderer=A.getParameter(A.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(A){this.webgpu.supported=!1}try{this.kernels=r.getKernelsForBackend(r.getBackend()).map(A=>A.kernelName.toLowerCase())}catch(A){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},w=new Wo;var S0={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function vr(e,t){return S0.debug&&g("load model fetch:",e,t),fetch(e,t)}function Co(e){S0.cacheModels=e.cacheModels,S0.verbose=e.debug,S0.modelBasePath=e.modelBasePath}async function N(e){let t=Mo(S0.modelBasePath,e||""),o=t.split("/"),A="indexeddb://"+o[o.length-1].replace(".json",""),n=await r.io.listModels(),s=S0.cacheModels&&Object.keys(n).includes(A),a=typeof fetch=="undefined"?{}:{fetchFunc:(x,d)=>vr(x,d)},i=new Nt(s?A:t,a);try{i.findIOHandler(),S0.debug&&g("model load handler:",i.handler);let x=await i.handler.load();i.loadSync(x),S0.verbose&&g("load model:",i.modelUrl)}catch(x){g("error loading model:",t,x)}if(S0.cacheModels&&!s)try{let x=await i.save(A);g("model saved:",A,x)}catch(x){g("error saving model:",t,x)}return i}var Bt="2.6.5";var Ao={};Y0(Ao,{Models:()=>vt,load:()=>to,reset:()=>Tt,validate:()=>oo});var u0,Ht=[],Rr=["white","black","asian","indian","other"],kr=[15,23,28,35.5,45.5,55.5,65],Io=0,Oo=0,Ft=Number.MAX_SAFE_INTEGER;async function No(e){return w.initial&&(u0=null),u0?e.debug&&g("cached model:",u0.modelUrl):u0=await N(e.face.gear),u0}async function Vt(e,t,o,A){var a,i;if(!u0)return{age:0,gender:"unknown",genderScore:0,race:[]};let n=Ft<(((a=t.face.gear)==null?void 0:a.skipFrames)||0),s=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>M()-Oo;return t.skipAllowed&&s&&n&&Io===A&&Ht[o]?(Ft++,Ht[o]):(Ft=0,new Promise(async x=>{var b,P;if(!(u0!=null&&u0.inputs[0].shape))return;let d={},l=[[0,.1,.9,.9]];d.resize=r.image.cropAndResize(e,l,[0],[u0.inputs[0].shape[2],u0.inputs[0].shape[1]]);let y={age:0,gender:"unknown",genderScore:0,race:[]};(b=t.face.gear)!=null&&b.enabled&&([d.age,d.gender,d.race]=u0.execute(d.resize,["age_output","gender_output","race_output"]));let c=await d.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 d.race.data();for(let p=0;p(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&y.race.push({score:Math.round(100*f[p])/100,race:Rr[p]});y.race.sort((p,u)=>u.score-p.score);let m=Array.from(await d.age.data()).map((p,u)=>[kr[u],p]).sort((p,u)=>u[1]-p[1]),v=m[0][0];for(let p=1;pr.dispose(d[p])),Ht[o]=y,Io=A,Oo=M(),x(y)}))}var L={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Go(){L.tf255=r.scalar(255,"float32"),L.tf1=r.scalar(1,"float32"),L.tf2=r.scalar(2,"float32"),L.tf05=r.scalar(.5,"float32"),L.tf127=r.scalar(127.5,"float32"),L.rgb=r.tensor1d([.2989,.587,.114],"float32")}var l0,Ue=[],Bo=0,Ho=0,Zt=Number.MAX_SAFE_INTEGER;async function Fo(e){return w.initial&&(l0=null),l0?e.debug&&g("cached model:",l0.modelUrl):l0=await N(e.face.ssrnet.modelPathAge),l0}async function Xt(e,t,o,A){var a,i,x,d;if(!l0)return{age:0};let n=Zt<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>M()-Ho;return t.skipAllowed&&n&&s&&Bo===A&&((x=Ue[o])==null?void 0:x.age)&&((d=Ue[o])==null?void 0:d.age)>0?(Zt++,Ue[o]):(Zt=0,new Promise(async l=>{if(!(l0!=null&&l0.inputs)||!l0.inputs[0]||!l0.inputs[0].shape)return;let y={};y.resize=r.image.resizeBilinear(e,[l0.inputs[0].shape[2],l0.inputs[0].shape[1]],!1),y.enhance=r.mul(y.resize,L.tf255);let c={age:0};if(t.face.ssrnet.enabled&&(y.age=l0.execute(y.enhance)),y.age){let f=await y.age.data();c.age=Math.trunc(10*f[0])/10}Object.keys(y).forEach(f=>r.dispose(y[f])),Ue[o]=c,Bo=A,Ho=M(),l(c)}))}var h0,Je=[],Zo=0,Xo=0,Dt=Number.MAX_SAFE_INTEGER,qt=[.2989,.587,.114];async function Do(e){return w.initial&&(h0=null),h0?e.debug&&g("cached model:",h0.modelUrl):h0=await N(e.face.ssrnet.modelPathGender),h0}async function Ut(e,t,o,A){var a,i,x,d;if(!h0)return{gender:"unknown",genderScore:0};let n=Dt<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>M()-Xo;return t.skipAllowed&&n&&s&&Zo===A&&((x=Je[o])==null?void 0:x.gender)&&((d=Je[o])==null?void 0:d.genderScore)>0?(Dt++,Je[o]):(Dt=0,new Promise(async l=>{if(!(h0!=null&&h0.inputs[0].shape))return;let y={};y.resize=r.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),y.enhance=r.tidy(()=>{let[h,m,v]=r.split(y.resize,3,3),b=r.mul(h,qt[0]),P=r.mul(m,qt[1]),p=r.mul(v,qt[2]),u=r.addN([b,P,p]);return r.mul(r.sub(u,L.tf05),2)});let c={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(y.gender=h0.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(h=>r.dispose(y[h])),Je[o]=c,Zo=A,Xo=M(),l(c)}))}var A0,Ye=[],Jt=Number.MAX_SAFE_INTEGER,Uo=0,Jo=0;async function Yo(e){var t;return w.initial&&(A0=null),A0?e.debug&&g("cached model:",A0.modelUrl):A0=await N((t=e.face.antispoof)==null?void 0:t.modelPath),A0}async function Yt(e,t,o,A){var a,i;if(!A0)return 0;let n=(((a=t.face.antispoof)==null?void 0:a.skipTime)||0)>M()-Jo,s=Jt<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&n&&s&&Uo===A&&Ye[o]?(Jt++,Ye[o]):(Jt=0,new Promise(async x=>{let d=r.image.resizeBilinear(e,[A0!=null&&A0.inputs[0].shape?A0.inputs[0].shape[2]:0,A0!=null&&A0.inputs[0].shape?A0.inputs[0].shape[1]:0],!1),l=A0==null?void 0:A0.execute(d),y=(await l.data())[0];Ye[o]=Math.round(100*y)/100,Uo=A,Jo=M(),r.dispose([d,l]),x(Ye[o])}))}var b0={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]},Kt={count:468,mouth:13,symmetryLine:[13,b0.midwayBetweenEyes[0]]},Ce={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},Qt=[{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]}],Ie=[[.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]],Q0=[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 zr=[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],jr=[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],Sr=[33,133,362,263,1,78,308],ws=zr.map(e=>Ie[e]),Rs=jr.map(e=>Ie[e]),ks=Sr.map(e=>Ie[e]);var ye=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],Ke=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],t5=(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],o5=(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],$o=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],A=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:A,landmarks:e.landmarks,confidence:e.confidence}},$t=(e,t,o)=>{let A=t.shape[1],n=t.shape[2],s=[e.startPoint[1]/A,e.startPoint[0]/n,e.endPoint[1]/A,e.endPoint[0]/n],a=r.image.cropAndResize(t,[s],[0],o),i=r.div(a,L.tf255);return r.dispose(a),i},Qe=(e,t)=>{let o=Ke(e),A=ye(e),n=[t*A[0]/2,t*A[1]/2];return{startPoint:[o[0]-n[0],o[1]-n[1]],endPoint:[o[0]+n[0],o[1]+n[1]],landmarks:e.landmarks,confidence:e.confidence}},_e=e=>{let t=Ke(e),o=ye(e),A=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-A),Math.round(t[1]-A)],endPoint:[Math.round(t[0]+A),Math.round(t[1]+A)],landmarks:e.landmarks,confidence:e.confidence}},eA=e=>{let t=e.map(A=>A[0]),o=e.map(A=>A[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},e5=[[1,0,0],[0,1,0],[0,0,1]],Wr=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Cr=(e,t)=>Wr(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Qo=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],_0=(e,t)=>{let o=0;for(let A=0;A{let o=[];for(let A=0;A{let o=[],A=e.length;for(let n=0;n{let o=Math.cos(e),A=Math.sin(e),n=[[o,-A,0],[A,o,0],[0,0,1]],s=Qo(t[0],t[1]),a=_o(s,n),i=Qo(-t[0],-t[1]);return _o(a,i)},Or=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],A=[-_0(t[0],o),-_0(t[1],o)];return[t[0].concat(A[0]),t[1].concat(A[1]),[0,0,1]]},Nr=(e,t)=>[_0(e,t[0]),_0(e,t[1])];function oA(e){let t={strides:[e/16,e/8],anchors:[2,6]},o=[];for(let A=0;A[s[0]/n*(f[0]-n/2),s[1]/n*(f[1]-n/2),f[2]||0]),i=o&&o!==0&&Math.abs(o)>.2,x=i?tA(o,[0,0]):e5,d=i?a.map(f=>[...Nr(f,x),f[2]]):a,l=i?Or(A):e5,y=Ke(t),c=[_0(y,l[0]),_0(y,l[1])];return d.map(f=>[Math.trunc(f[0]+c[0]),Math.trunc(f[1]+c[1]),Math.trunc(f[2]||0)])}function nA(e,t,o,A){let n=t.landmarks.length>=Kt.count?Kt.symmetryLine:Ce.symmetryLine,s=0,a=e5,i;if(e&&w.kernels.includes("rotatewithoffset"))if(s=Cr(t.landmarks[n[0]],t.landmarks[n[1]]),s&&s!==0&&Math.abs(s)>.2){let d=Ke(t),l=[d[0]/o.shape[2],d[1]/o.shape[1]],y=r.image.rotateWithOffset(o,s,0,l);a=tA(-s,d),i=$t(t,y,[A,A]),r.dispose(y)}else i=$t(t,o,[A,A]);else i=$t(t,o,[A,A]);return[s,a,i]}var Lr=e=>{let t=e.map(A=>A[0]),o=e.map(A=>A[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},rA=(e,t)=>{let o=Lr(e),A=ye(t);return{startPoint:[o[0]-A[0]/2,o[1]-A[1]/2],endPoint:[o[0]+A[0]/2,o[1]+A[1]/2]}};var sA=6,Gr=1.2,T0,aA=null,H0=0,Oe=null,$e=()=>H0;async function iA(e){var t;return w.initial&&(T0=null),T0?e.debug&&g("cached model:",T0.modelUrl):T0=await N((t=e.face.detector)==null?void 0:t.modelPath),H0=T0.inputs[0].shape?T0.inputs[0].shape[2]:0,Oe=r.scalar(H0,"int32"),aA=r.tensor2d(oA(H0)),T0}function Br(e){let t={};t.boxStarts=r.slice(e,[0,1],[-1,2]),t.centers=r.add(t.boxStarts,aA),t.boxSizes=r.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=r.div(t.boxSizes,Oe),t.centersNormalized=r.div(t.centers,Oe),t.halfBoxSize=r.div(t.boxSizesNormalized,L.tf2),t.starts=r.sub(t.centersNormalized,t.halfBoxSize),t.ends=r.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=r.mul(t.starts,Oe),t.endNormalized=r.mul(t.ends,Oe);let o=r.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(A=>r.dispose(t[A])),o}async function lA(e,t){var i,x,d,l;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=r.image.resizeBilinear(e,[H0,H0]),o.div=r.div(o.resized,L.tf127),o.normalized=r.sub(o.div,L.tf05);let A=T0==null?void 0:T0.execute(o.normalized);if(Array.isArray(A)){let y=A.sort((c,f)=>c.size-f.size);o.concat384=r.concat([y[0],y[2]],2),o.concat512=r.concat([y[1],y[3]],2),o.concat=r.concat([o.concat512,o.concat384],1),o.batch=r.squeeze(o.concat,0)}else o.batch=r.squeeze(A);r.dispose(A),o.boxes=Br(o.batch),o.logits=r.slice(o.batch,[0,0],[-1,1]),o.sigmoid=r.sigmoid(o.logits),o.scores=r.squeeze(o.sigmoid),o.nms=await r.image.nonMaxSuppressionAsync(o.boxes,o.scores,((i=t.face.detector)==null?void 0:i.maxDetected)||0,((x=t.face.detector)==null?void 0:x.iouThreshold)||0,((d=t.face.detector)==null?void 0:d.minConfidence)||0);let n=await o.nms.array(),s=[],a=await o.scores.data();for(let y=0;y(((l=t.face.detector)==null?void 0:l.minConfidence)||0)){let f={};f.bbox=r.slice(o.boxes,[n[y],0],[1,-1]),f.slice=r.slice(o.batch,[n[y],sA-1],[1,-1]),f.squeeze=r.squeeze(f.slice),f.landmarks=r.reshape(f.squeeze,[sA,-1]);let h=await f.bbox.data(),m={startPoint:[h[0],h[1]],endPoint:[h[2],h[3]],landmarks:await f.landmarks.array(),confidence:c},v=$o(m,[(e.shape[2]||0)/H0,(e.shape[1]||0)/H0]),b=Qe(v,t.face.scale||Gr),P=_e(b);s.push(P),Object.keys(f).forEach(p=>r.dispose(f[p]))}}return Object.keys(o).forEach(y=>r.dispose(o[y])),s}var et={};Y0(et,{connected:()=>r5,kpt:()=>n5});var n5=["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"],r5={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 xA=224,Hr,Fr=5,tt=[8,16,32,32,32];async function cA(){let e=[],t=0;for(;to.x)),y:r.tensor1d(e.map(o=>o.y))}}function W0(e,t=[1,1]){let o=[e.map(i=>i[0]),e.map(i=>i[1])],A=[Math.min(...o[0]),Math.min(...o[1])],n=[Math.max(...o[0]),Math.max(...o[1])],s=[A[0],A[1],n[0]-A[0],n[1]-A[1]],a=[s[0]/t[0],s[1]/t[1],s[2]/t[0],s[3]/t[1]];return{box:s,boxRaw:a}}function dA(e,t=[1,1]){let o=[e.map(d=>d[0]),e.map(d=>d[1])],A=[Math.min(...o[0]),Math.min(...o[1])],n=[Math.max(...o[0]),Math.max(...o[1])],s=[(A[0]+n[0])/2,(A[1]+n[1])/2],a=Math.max(s[0]-A[0],s[1]-A[1],-s[0]+n[0],-s[1]+n[1]),i=[Math.trunc(s[0]-a),Math.trunc(s[1]-a),Math.trunc(2*a),Math.trunc(2*a)],x=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:x}}function ot(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 pA={initial:!0},y0={detector:null,landmarks:null},xe={detector:[224,224],landmarks:[256,256]},s5=Number.MAX_SAFE_INTEGER,Zr={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},nt=null,Ne,F0=[[0,0],[0,0],[0,0],[0,0]],fA=0,mA=e=>1-1/(1+Math.exp(e));async function uA(e){if(pA.initial&&(y0.detector=null),!y0.detector&&e.body.detector&&e.body.detector.modelPath){y0.detector=await N(e.body.detector.modelPath);let t=Object.values(y0.detector.modelSignature.inputs);xe.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,xe.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&y0.detector&&g("cached model:",y0.detector.modelUrl);return await cA(),y0.detector}async function hA(e){if(pA.initial&&(y0.landmarks=null),y0.landmarks)e.debug&&g("cached model:",y0.landmarks.modelUrl);else{y0.landmarks=await N(e.body.modelPath);let t=Object.values(y0.landmarks.modelSignature.inputs);xe.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,xe.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return y0.landmarks}async function Xr(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let A;if(Ne&&(o.cropped=r.image.cropAndResize(e,[Ne],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let n=[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];F0=[[0,0],n,s,[0,0]],o.pad=r.pad(o.cropped||e,F0),o.resize=r.image.resizeBilinear(o.pad,[t,t]),A=r.div(o.resize,L.tf255)}else e.shape[1]!==t?(o.resize=r.image.resizeBilinear(o.cropped||e,[t,t]),A=r.div(o.resize,L.tf255)):A=r.div(o.cropped||e,L.tf255);return Object.keys(o).forEach(n=>r.dispose(o[n])),A}function Dr(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+F0[2][0]+F0[2][1])/t[0]-F0[2][0]),Math.trunc(o.position[1]*(t[1]+F0[1][0]+F0[1][1])/t[1]-F0[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(Ne)for(let o of e)o.positionRaw=[o.positionRaw[0]+Ne[1],o.positionRaw[1]+Ne[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 qr(e){let t=e.find(i=>i.part==="leftPalm"),o=e.find(i=>i.part==="leftWrist"),A=e.find(i=>i.part==="leftIndex");t.position[2]=((o.position[2]||0)+(A.position[2]||0))/2;let n=e.find(i=>i.part==="rightPalm"),s=e.find(i=>i.part==="rightWrist"),a=e.find(i=>i.part==="rightIndex");n.position[2]=((s.position[2]||0)+(a.position[2]||0))/2}async function Ur(e,t,o){var h;let A={};[A.ld,A.segmentation,A.heatmap,A.world,A.poseflag]=(h=y0.landmarks)==null?void 0:h.execute(e,Zr.landmarks);let n=(await A.poseflag.data())[0],s=await A.ld.data(),a=await A.world.data();Object.keys(A).forEach(m=>r.dispose(A[m]));let i=[],x=5;for(let m=0;mm.position),y=W0(l,[o[0],o[1]]),c={};for(let[m,v]of Object.entries(r5)){let b=[];for(let P=0;PE.part===v[P]),u=d.find(E=>E.part===v[P+1]);p&&u&&b.push([p.position,u.position])}c[m]=b}return{id:0,score:Math.trunc(100*n)/100,box:y.box,boxRaw:y.boxRaw,keypoints:d,annotations:c}}async function a5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],A=(t.body.skipTime||0)>M()-fA,n=s5<(t.body.skipFrames||0);if(t.skipAllowed&&A&&n&&nt!==null)s5++;else{let s={};s.landmarks=await Xr(e,256),nt=await Ur(s.landmarks,t,o),Object.keys(s).forEach(a=>r.dispose(s[a])),fA=M(),s5=0}return nt?[nt]:[]}var ce=[{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 C0,$0=0,i5=[],gA=0,l5=Number.MAX_SAFE_INTEGER;async function MA(e){if(w.initial&&(C0=null),C0)e.debug&&g("cached model:",C0.modelUrl);else{C0=await N(e.object.modelPath);let t=Object.values(C0.modelSignature.inputs);$0=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return C0}async function Jr(e,t,o){if(!e)return[];let A={},n=[],s=await e.array();A.squeeze=r.squeeze(e);let a=r.split(A.squeeze,6,1);A.stack=r.stack([a[1],a[0],a[3],a[2]],1),A.boxes=r.squeeze(A.stack),A.scores=r.squeeze(a[4]),A.classes=r.squeeze(a[5]),r.dispose([e,...a]),A.nms=await r.image.nonMaxSuppressionAsync(A.boxes,A.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let i=await A.nms.data(),x=0;for(let d of Array.from(i)){let l=Math.trunc(100*s[0][d][4])/100,y=s[0][d][5],c=ce[y].label,[f,h]=[s[0][d][0]/$0,s[0][d][1]/$0],m=[f,h,s[0][d][2]/$0-f,s[0][d][3]/$0-h],v=[Math.trunc(m[0]*t[0]),Math.trunc(m[1]*t[1]),Math.trunc(m[2]*t[0]),Math.trunc(m[3]*t[1])];n.push({id:x++,score:l,class:y,label:c,box:v,boxRaw:m})}return Object.keys(A).forEach(d=>r.dispose(A[d])),n}async function y5(e,t){let o=(t.object.skipTime||0)>M()-gA,A=l5<(t.object.skipFrames||0);return t.skipAllowed&&o&&A&&i5.length>0?(l5++,i5):(l5=0,new Promise(async n=>{let s=[e.shape[2]||0,e.shape[1]||0],a=r.image.resizeBilinear(e,[$0,$0]),i=t.object.enabled?C0==null?void 0:C0.execute(a,["tower_0/detections"]):null;gA=M(),r.dispose(a);let x=await Jr(i,s,t);i5=x,n(x)}))}var rt={};Y0(rt,{connected:()=>c5,kpt:()=>x5});var x5=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],c5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var n0,vA=0,a0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},d5=Number.MAX_SAFE_INTEGER;async function TA(e){return w.initial&&(n0=null),n0?e.debug&&g("cached model:",n0.modelUrl):n0=await N(e.body.modelPath),n0}async function Yr(e,t){let[o,A]=e.shape,n=r.reshape(e,[A*o]),s=r.max(n,0),a=(await s.data())[0];if(r.dispose([n,s]),a>t){let i=r.argMax(n,0),x=r.mod(i,o),d=(await x.data())[0],l=r.div(i,r.scalar(o,"int32")),y=(await l.data())[0];return r.dispose([x,l]),[d,y,a]}return[0,0,a]}async function f5(e,t){let o=(t.body.skipTime||0)>M()-vA,A=d5<(t.body.skipFrames||0);return t.skipAllowed&&o&&A&&Object.keys(a0.keypoints).length>0?(d5++,[a0]):(d5=0,new Promise(async n=>{var y;let s=r.tidy(()=>{if(!(n0!=null&&n0.inputs[0].shape))return null;let c=r.image.resizeBilinear(e,[n0.inputs[0].shape[2],n0.inputs[0].shape[1]],!1),f=r.mul(c,L.tf2);return r.sub(f,L.tf1)}),a;if(t.body.enabled&&(a=n0==null?void 0:n0.execute(s)),vA=M(),r.dispose(s),a){a0.keypoints.length=0;let c=a.squeeze();r.dispose(a);let f=c.unstack(2);r.dispose(c);for(let h=0;h(((y=t.body)==null?void 0:y.minConfidence)||0)&&a0.keypoints.push({score:Math.round(100*b)/100,part:x5[h],positionRaw:[m/n0.inputs[0].shape[2],v/n0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/n0.inputs[0].shape[2]),Math.round(e.shape[1]*v/n0.inputs[0].shape[1])]})}f.forEach(h=>r.dispose(h))}a0.score=a0.keypoints.reduce((c,f)=>f.score>c?f.score:c,0);let i=a0.keypoints.map(c=>c.position[0]),x=a0.keypoints.map(c=>c.position[1]);a0.box=[Math.min(...i),Math.min(...x),Math.max(...i)-Math.min(...i),Math.max(...x)-Math.min(...x)];let d=a0.keypoints.map(c=>c.positionRaw[0]),l=a0.keypoints.map(c=>c.positionRaw[1]);a0.boxRaw=[Math.min(...d),Math.min(...l),Math.max(...d)-Math.min(...d),Math.max(...l)-Math.min(...l)];for(let[c,f]of Object.entries(c5)){let h=[];for(let m=0;mP.part===f[m]),b=a0.keypoints.find(P=>P.part===f[m+1]);v&&b&&v.score>(t.body.minConfidence||0)&&b.score>(t.body.minConfidence||0)&&h.push([v.position,b.position])}a0.annotations[c]=h}n([a0])}))}var Kr=["angry","disgust","fear","happy","sad","surprise","neutral"],p0,st=[],RA=0,kA=0,m5=Number.MAX_SAFE_INTEGER;async function EA(e){var t;return w.initial&&(p0=null),p0?e.debug&&g("cached model:",p0.modelUrl):p0=await N((t=e.face.emotion)==null?void 0:t.modelPath),p0}async function p5(e,t,o,A){var a,i;if(!p0)return[];let n=m5<(((a=t.face.emotion)==null?void 0:a.skipFrames)||0),s=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>M()-kA;return t.skipAllowed&&s&&n&&RA===A&&st[o]&&st[o].length>0?(m5++,st[o]):(m5=0,new Promise(async x=>{var l,y;let d=[];if((l=t.face.emotion)!=null&&l.enabled){let c={},f=p0!=null&&p0.inputs[0].shape?p0.inputs[0].shape[2]:0;c.resize=r.image.resizeBilinear(e,[f,f],!1),c.channels=r.mul(c.resize,L.rgb),c.grayscale=r.sum(c.channels,3,!0),c.grayscaleSub=r.sub(c.grayscale,L.tf05),c.grayscaleMul=r.mul(c.grayscaleSub,L.tf2),c.emotion=p0==null?void 0:p0.execute(c.grayscaleMul),kA=M();let h=await c.emotion.data();for(let m=0;m(((y=t.face.emotion)==null?void 0:y.minConfidence)||0)&&d.push({score:Math.min(.99,Math.trunc(100*h[m])/100),emotion:Kr[m]});d.sort((m,v)=>v.score-m.score),Object.keys(c).forEach(m=>r.dispose(c[m]))}st[o]=d,RA=A,x(d)}))}var x0,u5=[],jA=0,SA=0,WA=Number.MAX_SAFE_INTEGER;async function CA(e){return w.initial&&(x0=null),x0?e.debug&&g("cached model:",x0.modelUrl):x0=await N(e.face.mobilefacenet.modelPath),x0}async function h5(e,t,o,A){var a,i;if(!x0)return[];let n=WA<(((a=t.face.embedding)==null?void 0:a.skipFrames)||0),s=(((i=t.face.embedding)==null?void 0:i.skipTime)||0)>M()-SA;return t.skipAllowed&&s&&n&&jA===A&&u5[o]?(WA++,u5[o]):new Promise(async x=>{var l;let d=[];if(((l=t.face.embedding)==null?void 0:l.enabled)&&(x0==null?void 0:x0.inputs[0].shape)){let y={};y.crop=r.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),y.data=x0==null?void 0:x0.execute(y.crop);let c=await y.data.data();d=Array.from(c)}u5[o]=d,jA=A,SA=M(),x(d)})}var I0,V0=0,Qr=2.3,b5=b0.leftEyeLower0,g5=b0.rightEyeLower0,de={leftBounds:[b5[0],b5[b5.length-1]],rightBounds:[g5[0],g5[g5.length-1]]},fe={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function GA(e){var t;return w.initial&&(I0=null),I0?e.debug&&g("cached model:",I0.modelUrl):I0=await N((t=e.face.iris)==null?void 0:t.modelPath),V0=I0.inputs[0].shape?I0.inputs[0].shape[2]:0,V0===-1&&(V0=64),I0}function at(e,t,o,A){for(let n=0;n{let t=e[de.leftBounds[0]][2],o=e[de.rightBounds[0]][2];return t-o},OA=(e,t,o,A,n,s=!1)=>{let a=_e(Qe(eA([e[o],e[A]]),Qr)),i=ye(a),x=r.image.cropAndResize(t,[[a.startPoint[1]/n,a.startPoint[0]/n,a.endPoint[1]/n,a.endPoint[0]/n]],[0],[V0,V0]);if(s&&w.kernels.includes("flipleftright")){let d=r.image.flipLeftRight(x);r.dispose(x),x=d}return{box:a,boxSize:i,crop:x}},NA=(e,t,o,A=!1)=>{let n=[];for(let s=0;s{let A=e[b0[`${o}EyeUpper0`][fe.upperCenter]][2],n=e[b0[`${o}EyeLower0`][fe.lowerCenter]][2],s=(A+n)/2;return t.map((a,i)=>{let x=s;return i===2?x=A:i===4&&(x=n),[a[0],a[1],x]})};async function BA(e,t,o,A){if(!I0)return o.debug&&g("face mesh iris detection requested, but model is not loaded"),e;let{box:n,boxSize:s,crop:a}=OA(e,t,de.leftBounds[0],de.leftBounds[1],A,!0),{box:i,boxSize:x,crop:d}=OA(e,t,de.rightBounds[0],de.rightBounds[1],A,!0),l=r.concat([a,d]);r.dispose(a),r.dispose(d);let y=I0.execute(l);r.dispose(l);let c=await y.data();r.dispose(y);let f=c.slice(0,fe.numCoordinates*3),{rawCoords:h,iris:m}=NA(f,n,s,!0),v=c.slice(fe.numCoordinates*3),{rawCoords:b,iris:P}=NA(v,i,x),p=_r(e);Math.abs(p)<30?(at(e,h,"left",null),at(e,b,"right",null)):p<1?at(e,h,"left",["EyeUpper0","EyeLower0"]):at(e,b,"right",["EyeUpper0","EyeLower0"]);let u=LA(e,m,"left"),E=LA(e,P,"right");return e.concat(u).concat(E)}var w0={boxes:[],skipped:Number.MAX_SAFE_INTEGER,timestamp:0},O0=null,me=0;async function FA(e,t){var i,x,d,l,y,c,f,h,m;let o=(((i=t.face.detector)==null?void 0:i.skipTime)||0)>M()-w0.timestamp,A=w0.skipped<(((x=t.face.detector)==null?void 0:x.skipFrames)||0);!t.skipAllowed||!o||!A||w0.boxes.length===0?(w0.boxes=await lA(e,t),w0.timestamp=M(),w0.skipped=0):w0.skipped++;let n=[],s=[],a=0;for(let v=0;v[H[0]/(e.shape[2]||0),H[1]/(e.shape[1]||0),(H[2]||0)/me]);for(let H of Object.keys(b0))u.annotations[H]=b0[H].map(t0=>u.mesh[t0]);u.score=u.faceScore;let G={...rA(u.mesh,b),confidence:b.confidence,landmarks:b.landmarks};u.box=t5(G,e),u.boxRaw=o5(G,e),s.push(G)}}else{u.box=t5(b,e),u.boxRaw=o5(b,e),u.score=u.boxScore,u.mesh=b.landmarks.map(E=>[(b.startPoint[0]+b.endPoint[0])/2+(b.endPoint[0]+b.startPoint[0])*E[0]/$e(),(b.startPoint[1]+b.endPoint[1])/2+(b.endPoint[1]+b.startPoint[1])*E[1]/$e()]),u.meshRaw=u.mesh.map(E=>[E[0]/(e.shape[2]||0),E[1]/(e.shape[1]||0),(E[2]||0)/me]);for(let E of Object.keys(Ce))u.annotations[E]=[u.mesh[Ce[E]]]}u.score>(((m=t.face.detector)==null?void 0:m.minConfidence)||1)?n.push(u):r.dispose(u.tensor)}return w0.boxes=s,n}async function VA(e){var t;return w.initial&&(O0=null),O0?e.debug&&g("cached model:",O0.modelUrl):O0=await N((t=e.face.mesh)==null?void 0:t.modelPath),me=O0.inputs[0].shape?O0.inputs[0].shape[2]:0,O0}var ZA=Q0,XA=Ie;var c0,it=[],DA=0,qA=0,P5=Number.MAX_SAFE_INTEGER;async function UA(e){var t;return w.initial&&(c0=null),c0?e.debug&&g("cached model:",c0.modelUrl):c0=await N((t=e.face.description)==null?void 0:t.modelPath),c0}function v5(e){let t=e.image||e.tensor||e;if(!(c0!=null&&c0.inputs[0].shape))return t;let o=r.image.resizeBilinear(t,[c0.inputs[0].shape[2],c0.inputs[0].shape[1]],!1),A=r.mul(o,L.tf255);return r.dispose(o),A}async function T5(e,t,o,A){var a,i,x,d;if(!c0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let n=P5<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((i=t.face.description)==null?void 0:i.skipTime)||0)>M()-DA;return t.skipAllowed&&n&&s&&qA===A&&((x=it[o])==null?void 0:x.age)&&((d=it[o])==null?void 0:d.age)>0?(P5++,it[o]):(P5=0,new Promise(async l=>{var c,f;let y={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((c=t.face.description)!=null&&c.enabled){let h=v5(e),m=c0==null?void 0:c0.execute(h);DA=M(),r.dispose(h);let b=await(await m.find(O=>O.shape[1]===1)).data(),P=Math.trunc(200*Math.abs(b[0]-.5))/100;P>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(y.gender=b[0]<=.5?"female":"male",y.genderScore=Math.min(.99,P));let p=r.argMax(m.find(O=>O.shape[1]===100),1),u=(await p.data())[0];r.dispose(p);let W=await m.find(O=>O.shape[1]===100).data();y.age=Math.round(W[u-1]>W[u+1]?10*u-100*W[u-1]:10*u+100*W[u+1])/10;let C=m.find(O=>O.shape[1]===1024),S=C?await C.data():[];y.descriptor=Array.from(S),m.forEach(O=>r.dispose(O))}it[o]=y,qA=A,l(y)}))}function lt(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function Le(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function KA(e,t,o){let A=t.shape[1],n=t.shape[2],s=[[e.startPoint[1]/A,e.startPoint[0]/n,e.endPoint[1]/A,e.endPoint[0]/n]];return r.image.cropAndResize(t,s,[0],o)}function QA(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],A=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],n=e.palmLandmarks.map(s=>[s[0]*t[0],s[1]*t[1]]);return{startPoint:o,endPoint:A,palmLandmarks:n,confidence:e.confidence}}function yt(e,t=1.5){let o=Le(e),A=lt(e),n=[t*A[0]/2,t*A[1]/2],s=[o[0]-n[0],o[1]-n[1]],a=[o[0]+n[0],o[1]+n[1]];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function xt(e){let t=Le(e),o=lt(e),n=Math.max(...o)/2,s=[t[0]-n,t[1]-n],a=[t[0]+n,t[1]+n];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function $r(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function _A(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return $r(o)}var JA=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Z0(e,t){let o=0;for(let A=0;A[o.x,o.y]),this.anchorsTensor=r.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=r.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=r.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=r.slice(t,[0,0],[-1,2]),o.boxSizes=r.slice(t,[0,2],[-1,2]),o.div=r.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=r.add(o.div,this.anchorsTensor),o.halfBoxSizes=r.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=r.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=r.mul(o.sub,this.inputSizeTensor),o.add=r.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=r.mul(o.add,this.inputSizeTensor);let A=r.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(n=>r.dispose(o[n])),A}normalizeLandmarks(t,o){let A={};A.reshape=r.reshape(t,[-1,7,2]),A.div=r.div(A.reshape,this.inputSizeTensor),A.landmarks=r.add(A.div,this.anchors[o]);let n=r.mul(A.landmarks,this.inputSizeTensor);return Object.keys(A).forEach(s=>r.dispose(A[s])),n}async predict(t,o){let A={};A.resize=r.image.resizeBilinear(t,[this.inputSize,this.inputSize]),A.div=r.div(A.resize,L.tf127),A.image=r.sub(A.div,L.tf1),A.batched=this.model.execute(A.image),A.predictions=r.squeeze(A.batched),A.slice=r.slice(A.predictions,[0,0],[-1,1]),A.sigmoid=r.sigmoid(A.slice),A.scores=r.squeeze(A.sigmoid);let n=await A.scores.data();A.boxes=r.slice(A.predictions,[0,1],[-1,4]),A.norm=this.normalizeBoxes(A.boxes),A.nms=await r.image.nonMaxSuppressionAsync(A.norm,A.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let s=await A.nms.array(),a=[];for(let i of s){let x={};x.box=r.slice(A.norm,[i,0],[1,-1]),x.slice=r.slice(A.predictions,[i,5],[1,14]),x.norm=this.normalizeLandmarks(x.slice,i),x.palmLandmarks=r.reshape(x.norm,[-1,2]);let d=await x.box.data(),l=d.slice(0,2),y=d.slice(2,4),c=await x.palmLandmarks.array(),f={startPoint:l,endPoint:y,palmLandmarks:c,confidence:n[i]},h=QA(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);a.push(h),Object.keys(x).forEach(m=>r.dispose(x[m]))}return Object.keys(A).forEach(i=>r.dispose(A[i])),a}};var A2=5,on=1.65,An=[0,5,9,13,17,1,2],n2=0,r2=2,nn=0,z5=class{constructor(t,o){R(this,"handDetector");R(this,"handPoseModel");R(this,"inputSize");R(this,"storedBoxes");R(this,"skipped");R(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]),A=t.map(a=>a[1]),n=[Math.min(...o),Math.min(...A)],s=[Math.max(...o),Math.max(...A)];return{startPoint:n,endPoint:s}}getBoxForPalmLandmarks(t,o){let A=t.map(s=>k5([...s,1],o)),n=this.calculateLandmarksBoundingBox(A);return yt(xt(n),A2)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),A=yt(xt(o),on);A.palmLandmarks=[];for(let n=0;n[a[0]*(f[0]-this.inputSize/2),a[1]*(f[1]-this.inputSize/2),a[2]*f[2]]),x=R5(A,[0,0]),d=i.map(f=>[...k5(f,x),f[2]]),l=$A(n),y=[...Le(o),1],c=[Z0(y,l[0]),Z0(y,l[1])];return d.map(f=>[Math.trunc(f[0]+c[0]),Math.trunc(f[1]+c[1]),Math.trunc(f[2])])}async estimateHands(t,o){let A=!1,n,s=(o.hand.skipTime||0)>M()-nn,a=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&s&&a&&(n=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,n&&n.length>0&&(n.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...n],this.storedBoxes.length>0&&(A=!0));let i=[];for(let x=0;x=o.hand.minConfidence/4){let E=r.reshape(p,[-1,3]),W=await E.array();r.dispose(p),r.dispose(E);let C=this.transformRawCoords(W,m,l,h),S=this.getBoxForHandLandmarks(C);this.storedBoxes[x]={...S,confidence:u};let O={landmarks:C,confidence:u,boxConfidence:d.confidence,fingerConfidence:u,box:{topLeft:S.startPoint,bottomRight:S.endPoint}};i.push(O)}else this.storedBoxes[x]=null;r.dispose(p)}else{let l=yt(xt(d),on),y={confidence:d.confidence,boxConfidence:d.confidence,fingerConfidence:0,box:{topLeft:l.startPoint,bottomRight:l.endPoint},landmarks:[]};i.push(y)}}return this.storedBoxes=this.storedBoxes.filter(x=>x!==null),this.detectedHands=i.length,i.length>o.hand.maxDetected&&(i.length=o.hand.maxDetected),i}};var i0={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=>i0.nameMapping[e],getPoints:e=>i0.pointsMapping[e]},X0={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>X0.nameMapping[e]},U={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=>U.nameMapping[e]},ee=class{constructor(t){R(this,"name");R(this,"curls");R(this,"directions");R(this,"weights");R(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,A){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,A])}direction(t,o,A){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,A])}weight(t,o){this.weights[t]=o;let A=this.weights.reduce((n,s)=>n+s,0);this.weightsRelative=this.weights.map(n=>n*5/A)}matchAgainst(t,o){let A=0;for(let n in t){let s=t[n],a=this.curls[n];if(typeof a=="undefined"){A+=this.weightsRelative[n];continue}for(let[i,x]of a)if(s===i){A+=x*this.weightsRelative[n];break}}for(let n in o){let s=o[n],a=this.directions[n];if(typeof a=="undefined"){A+=this.weightsRelative[n];continue}for(let[i,x]of a)if(s===i){A+=x*this.weightsRelative[n];break}}return A/10}};var{thumb:g0,index:N0,middle:L0,ring:te,pinky:oe}=i0,{none:M0,half:a2,full:P0}=X0,{verticalUp:pe,verticalDown:pa,horizontalLeft:j5,horizontalRight:i2,diagonalUpRight:l2,diagonalUpLeft:ue,diagonalDownRight:ua,diagonalDownLeft:ha}=U,D0=new ee("thumbs up");D0.curl(g0,M0,1);D0.direction(g0,pe,1);D0.direction(g0,ue,.25);D0.direction(g0,l2,.25);for(let e of[i0.index,i0.middle,i0.ring,i0.pinky])D0.curl(e,P0,1),D0.direction(e,j5,1),D0.direction(e,i2,1);var K=new ee("victory");K.curl(g0,a2,.5);K.curl(g0,M0,.5);K.direction(g0,pe,1);K.direction(g0,ue,1);K.curl(N0,M0,1);K.direction(N0,pe,.75);K.direction(N0,ue,1);K.curl(L0,M0,1);K.direction(L0,pe,1);K.direction(L0,ue,.75);K.curl(te,P0,1);K.direction(te,pe,.2);K.direction(te,ue,1);K.direction(te,j5,.2);K.curl(oe,P0,1);K.direction(oe,pe,.2);K.direction(oe,ue,1);K.direction(oe,j5,.2);K.weight(N0,2);K.weight(L0,2);var q0=new ee("point");q0.curl(g0,P0,1);q0.curl(N0,M0,.5);q0.curl(L0,P0,.5);q0.curl(te,P0,.5);q0.curl(oe,P0,.5);q0.weight(N0,2);q0.weight(L0,2);var U0=new ee("middle finger");U0.curl(g0,M0,1);U0.curl(N0,P0,.5);U0.curl(L0,P0,.5);U0.curl(te,P0,.5);U0.curl(oe,P0,.5);U0.weight(N0,2);U0.weight(L0,2);var he=new ee("open palm");he.curl(g0,M0,.75);he.curl(N0,M0,.75);he.curl(L0,M0,.75);he.curl(te,M0,.75);he.curl(oe,M0,.75);var rn=[D0,K,q0,U0,he];var y2=.7,Ae={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 sn(e,t,o,A){let n=(t-A)/(e-o),s=Math.atan(n)*180/Math.PI;return s<=0?s=-s:s>0&&(s=180-s),s}function ln(e,t){if(!e||!t)return[0,0];let o=sn(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let A=sn(e[1],e[2],t[1],t[2]);return[o,A]}function an(e,t=1){let o=0,A=0,n=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?A=1*t:n=1*t,[o,A,n]}function x2(e,t,o){let A=e[0]-t[0],n=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],i=e[1]-o[1],x=t[1]-o[1],d=e[2]-t[2],l=e[2]-o[2],y=t[2]-o[2],c=Math.sqrt(A*A+a*a+d*d),f=Math.sqrt(n*n+i*i+l*l),h=Math.sqrt(s*s+x*x+y*y),m=(h*h+c*c-f*f)/(2*h*c);m>1?m=1:m<-1&&(m=-1);let v=Math.acos(m);v=57.2958*v%180;let b;return v>Ae.NO_CURL_START_LIMIT?b=X0.none:v>Ae.HALF_CURL_START_LIMIT?b=X0.half:b=X0.full,b}function yn(e,t,o,A){let n;return A===Math.abs(e)?e>0?n=U.horizontalLeft:n=U.horizontalRight:A===Math.abs(t)?t>0?n=U.horizontalLeft:n=U.horizontalRight:o>0?n=U.horizontalLeft:n=U.horizontalRight,n}function xn(e,t,o,A){let n;return A===Math.abs(e)?e<0?n=U.verticalDown:n=U.verticalUp:A===Math.abs(t)?t<0?n=U.verticalDown:n=U.verticalUp:o<0?n=U.verticalDown:n=U.verticalUp,n}function c2(e,t,o,A,n,s,a,i){let x,d=xn(e,t,o,A),l=yn(n,s,a,i);return d===U.verticalUp?l===U.horizontalLeft?x=U.diagonalUpLeft:x=U.diagonalUpRight:l===U.horizontalLeft?x=U.diagonalDownLeft:x=U.diagonalDownRight,x}function d2(e,t,o,A){let n=e[0]-t[0],s=e[0]-o[0],a=t[0]-o[0],i=e[1]-t[1],x=e[1]-o[1],d=t[1]-o[1],l=Math.max(Math.abs(n),Math.abs(s),Math.abs(a)),y=Math.max(Math.abs(i),Math.abs(x),Math.abs(d)),c=0,f=0,h=0,m=y/(l+1e-5);m>1.5?c+=Ae.DISTANCE_VOTE_POWER:m>.66?f+=Ae.DISTANCE_VOTE_POWER:h+=Ae.DISTANCE_VOTE_POWER;let v=Math.sqrt(n*n+i*i),b=Math.sqrt(s*s+x*x),P=Math.sqrt(a*a+d*d),p=Math.max(v,b,P),u=e[0],E=e[1],W=o[0],C=o[1];p===v?(W=o[0],C=o[1]):p===P&&(u=t[0],E=t[1]);let V=ln([u,E],[W,C]),G=an(V,Ae.TOTAL_ANGLE_VOTE_POWER);c+=G[0],f+=G[1],h+=G[2];for(let t0 of A){let z=an(t0,Ae.SINGLE_ANGLE_VOTE_POWER);c+=z[0],f+=z[1],h+=z[2]}let H;return c===Math.max(c,f,h)?H=xn(x,i,d,y):h===Math.max(f,h)?H=yn(s,n,a,l):H=c2(x,i,d,y,s,n,a,l),H}function cn(e){let t=[],o=[],A=[],n=[];if(!e)return{curls:A,directions:n};for(let s of i0.all){let a=i0.getPoints(s),i=[],x=[];for(let d of a){let l=e[d[0]],y=e[d[1]],c=ln(l,y),f=c[0],h=c[1];i.push(f),x.push(h)}t.push(i),o.push(x)}for(let s of i0.all){let a=s===i0.thumb?1:0,i=i0.getPoints(s),x=e[i[a][0]],d=e[i[a+1][1]],l=e[i[3][1]],y=x2(x,d,l),c=d2(x,d,l,t[s].slice(a));A[s]=y,n[s]=c}return{curls:A,directions:n}}function ct(e){if(!e||e.length===0)return null;let t=cn(e),o={};for(let A of i0.all)o[i0.getName(A)]={curl:X0.getName(t.curls[A]),direction:U.getName(t.directions[A])};return o}function dn(e){let t=[];if(!e||e.length===0)return t;let o=cn(e);for(let A of rn){let n=A.matchAgainst(o.curls,o.directions);n>=y2&&t.push({name:A.name,confidence:n})}return t}var fn={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]},be,ge,mn;async function W5(e,t){let o=await mn.estimateHands(e,t);if(!o)return[];let A=[];for(let n=0;no[n].landmarks[y]);let a=o[n].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],x=[0,0,0,0];if(a&&a.length>0){for(let l of a)l[0]i[2]&&(i[2]=l[0]),l[1]>i[3]&&(i[3]=l[1]);i[2]-=i[0],i[3]-=i[1],x=[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[n].box?[Math.trunc(Math.max(0,o[n].box.topLeft[0])),Math.trunc(Math.max(0,o[n].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[n].box.bottomRight[0])-Math.max(0,o[n].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[n].box.bottomRight[1])-Math.max(0,o[n].box.topLeft[1]))]:[0,0,0,0],x=[o[n].box.topLeft[0]/(e.shape[2]||0),o[n].box.topLeft[1]/(e.shape[1]||0),(o[n].box.bottomRight[0]-o[n].box.topLeft[0])/(e.shape[2]||0),(o[n].box.bottomRight[1]-o[n].box.topLeft[1])/(e.shape[1]||0)];let d=ct(a);A.push({id:n,score:Math.round(100*o[n].confidence)/100,boxScore:Math.round(100*o[n].boxConfidence)/100,fingerScore:Math.round(100*o[n].fingerConfidence)/100,label:"hand",box:i,boxRaw:x,keypoints:a,annotations:s,landmarks:d})}return A}async function C5(e){var o,A;w.initial&&(be=null,ge=null),!be||!ge?[be,ge]=await Promise.all([e.hand.enabled?N((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?N((A=e.hand.skeleton)==null?void 0:A.modelPath):null]):(e.debug&&g("cached model:",be.modelUrl),e.debug&&g("cached model:",ge.modelUrl));let t=new E5(be);return mn=new z5(t,ge),[be,ge]}var $=[null,null],f2=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],J0=[[0,0],[0,0]],m2=["hand","fist","pinch","point","face","tip","pinchtip"],un=4,hn=1.6,p2=512,u2=1.4,dt=Number.MAX_SAFE_INTEGER,I5=0,G0=[0,0],J={boxes:[],hands:[]},bn={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 gn(e){var t;if(w.initial&&($[0]=null),$[0])e.debug&&g("cached model:",$[0].modelUrl);else{ft(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),$[0]=await N((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values($[0].modelSignature.inputs);J0[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,J0[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return $[0]}async function Mn(e){var t;if(w.initial&&($[1]=null),$[1])e.debug&&g("cached model:",$[1].modelUrl);else{$[1]=await N((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values($[1].modelSignature.inputs);J0[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,J0[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return $[1]}async function h2(e,t){let o=[];if(!e||!$[0])return o;let A={},n=(e.shape[2]||1)/(e.shape[1]||1),s=Math.min(Math.round((e.shape[1]||0)/8)*8,p2),a=Math.round(s*n/8)*8;A.resize=r.image.resizeBilinear(e,[s,a]),A.cast=r.cast(A.resize,"int32"),[A.rawScores,A.rawBoxes]=await $[0].executeAsync(A.cast,f2),A.boxes=r.squeeze(A.rawBoxes,[0,2]),A.scores=r.squeeze(A.rawScores,[0]);let i=r.unstack(A.scores,1);r.dispose(i[un]),i.splice(un,1),A.filtered=r.stack(i,1),r.dispose(i),A.max=r.max(A.filtered,1),A.argmax=r.argMax(A.filtered,1);let x=0;A.nms=await r.image.nonMaxSuppressionAsync(A.boxes,A.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let d=await A.nms.data(),l=await A.max.data(),y=await A.argmax.data();for(let c of Array.from(d)){let f=r.slice(A.boxes,c,1),h=await f.data();r.dispose(f);let m=[h[1],h[0],h[3]-h[1],h[2]-h[0]],v=ot(m,u2),b=[Math.trunc(m[0]*G0[0]),Math.trunc(m[1]*G0[1]),Math.trunc(m[2]*G0[0]),Math.trunc(m[3]*G0[1])],P=l[c],p=m2[y[c]],u={id:x++,score:P,box:b,boxRaw:v,label:p};o.push(u)}return Object.keys(A).forEach(c=>r.dispose(A[c])),o.sort((c,f)=>f.score-c.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function O5(e,t,o){let A={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&&$[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let n={},s=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];n.crop=r.image.cropAndResize(e,[s],[0],[J0[1][0],J0[1][1]],"bilinear"),n.div=r.div(n.crop,L.tf255),[n.score,n.keypoints]=$[1].execute(n.div,["Identity_1","Identity"]);let a=(await n.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(a))))/100;if(i>=(o.hand.minConfidence||0)){A.fingerScore=i,n.reshaped=r.reshape(n.keypoints,[-1,3]);let l=(await n.reshaped.array()).map(y=>[y[0]/J0[1][1],y[1]/J0[1][0],y[2]||0]).map(y=>[y[0]*t.boxRaw[2],y[1]*t.boxRaw[3],y[2]||0]);A.keypoints=l.map(y=>[G0[0]*(y[0]+t.boxRaw[0]),G0[1]*(y[1]+t.boxRaw[1]),y[2]||0]),A.landmarks=ct(A.keypoints);for(let y of Object.keys(bn))A.annotations[y]=bn[y].map(c=>A.landmarks&&A.keypoints[c]?A.keypoints[c]:null)}Object.keys(n).forEach(x=>r.dispose(n[x]))}return A}async function N5(e,t){var n,s;if(!$[0]||!$[1]||!((n=$[0])!=null&&n.inputs[0].shape)||!((s=$[1])!=null&&s.inputs[0].shape))return[];G0=[e.shape[2]||0,e.shape[1]||0],dt++;let o=(t.hand.skipTime||0)>M()-I5,A=dt<(t.hand.skipFrames||0);return t.skipAllowed&&o&&A?J.hands:new Promise(async a=>{let i=3*(t.hand.skipTime||0)>M()-I5,x=dt<3*(t.hand.skipFrames||0);t.skipAllowed&&J.hands.length===t.hand.maxDetected?J.hands=await Promise.all(J.boxes.map(l=>O5(e,l,t))):t.skipAllowed&&i&&x&&J.hands.length>0?J.hands=await Promise.all(J.boxes.map(l=>O5(e,l,t))):(J.boxes=await h2(e,t),I5=M(),J.hands=await Promise.all(J.boxes.map(l=>O5(e,l,t))),dt=0);let d=[...J.boxes];if(J.boxes.length=0,t.cacheSensitivity>0)for(let l=0;l.05&&y.box[3]/(e.shape[1]||1)>.05&&J.hands[l].fingerScore&&J.hands[l].fingerScore>(t.hand.minConfidence||0)){let c=ot(y.box,hn),f=ot(y.boxRaw,hn);J.boxes.push({...d[l],box:c,boxRaw:f})}}for(let l=0;lM()-Tn,s=L5<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&n&&s&&vn===A&&mt[o]?(L5++,mt[o]):(L5=0,new Promise(async x=>{let d=r.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),l=r0==null?void 0:r0.execute(d),y=(await l.data())[0];mt[o]=Math.round(100*y)/100,vn=A,Tn=M(),r.dispose([d,l]),x(mt[o])}))}var Ge={};Y0(Ge,{connected:()=>ut,horizontal:()=>B5,kpt:()=>pt,relative:()=>F5,vertical:()=>H5});var pt=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],B5=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],H5=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],F5=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],ut={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var kn=.005,d0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function V5(e){for(let t of B5){let o=e.keypoints.findIndex(n=>n.part===t[0]),A=e.keypoints.findIndex(n=>n.part===t[1]);if(e.keypoints[o]&&e.keypoints[A]&&e.keypoints[o].position[0]n&&n.part===t[0]),A=e.keypoints.findIndex(n=>n&&n.part===t[1]);e.keypoints[o]&&e.keypoints[A]&&e.keypoints[o].position[1]d&&d.part===t[0]),n=e.keypoints.findIndex(d=>d&&d.part===t[1]),s=e.keypoints.findIndex(d=>d&&d.part===o[0]),a=e.keypoints.findIndex(d=>d&&d.part===o[1]);if(!e.keypoints[s]||!e.keypoints[a])continue;let i=e.keypoints[A]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[A].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[A].position[0])]:[0,0],x=e.keypoints[n]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0])]:[0,0];if(i[0]>i[1]||x[0]>x[1]){let d=e.keypoints[A];e.keypoints[A]=e.keypoints[n],e.keypoints[n]=d}}}function En(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=r.pad(e,d0.padding),o.resize=r.image.resizeBilinear(o.pad,[t,t]);let A=r.cast(o.resize,"int32");return Object.keys(o).forEach(n=>r.dispose(o[n])),A}function jn(e,t){e.keypoints=e.keypoints.filter(A=>A&&A.position);for(let A of e.keypoints)A.position=[A.position[0]*(t[0]+d0.padding[2][0]+d0.padding[2][1])/t[0]-d0.padding[2][0],A.position[1]*(t[1]+d0.padding[1][0]+d0.padding[1][1])/t[1]-d0.padding[1][0]],A.positionRaw=[A.position[0]/t[0],A.position[1]/t[1]];let o=W0(e.keypoints.map(A=>A.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var f0,ht=0,Z5=Number.MAX_SAFE_INTEGER,ne={boxes:[],bodies:[],last:0};async function Sn(e){return w.initial&&(f0=null),f0?e.debug&&g("cached model:",f0.modelUrl):(ft(["size"],e),f0=await N(e.body.modelPath)),ht=f0.inputs[0].shape?f0.inputs[0].shape[2]:0,ht<64&&(ht=256),f0}async function g2(e,t,o){let A=e[0][0],n=[],s=0;for(let l=0;lt.body.minConfidence){let y=[A[l][1],A[l][0]];n.push({score:Math.round(100*s)/100,part:pt[l],positionRaw:y,position:[Math.round((o.shape[2]||0)*y[0]),Math.round((o.shape[1]||0)*y[1])]})}s=n.reduce((l,y)=>y.score>l?y.score:l,0);let a=[],i=W0(n.map(l=>l.position),[o.shape[2],o.shape[1]]),x={};for(let[l,y]of Object.entries(ut)){let c=[];for(let f=0;fv.part===y[f]),m=n.find(v=>v.part===y[f+1]);h&&m&&h.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&c.push([h.position,m.position])}x[l]=c}let d={id:0,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:n,annotations:x};return V5(d),a.push(d),a}async function M2(e,t,o){let A=[];for(let n=0;nt.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:pt[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 x=W0(i.map(y=>y.position),[o.shape[2],o.shape[1]]),d={};for(let[y,c]of Object.entries(ut)){let f=[];for(let h=0;hb.part===c[h]),v=i.find(b=>b.part===c[h+1]);m&&v&&m.score>(t.body.minConfidence||0)&&v.score>(t.body.minConfidence||0)&&f.push([m.position,v.position])}d[y]=f}let l={id:n,score:a,box:x.box,boxRaw:x.boxRaw,keypoints:[...i],annotations:d};V5(l),A.push(l)}}return A.sort((n,s)=>s.score-n.score),A.length>t.body.maxDetected&&(A.length=t.body.maxDetected),A}async function X5(e,t){if(!f0||!(f0!=null&&f0.inputs[0].shape))return[];t.skipAllowed||(ne.boxes.length=0),Z5++;let o=(t.body.skipTime||0)>M()-ne.last,A=Z5<(t.body.skipFrames||0);return t.skipAllowed&&o&&A?ne.bodies:new Promise(async n=>{let s={};Z5=0,s.input=zn(e,ht),s.res=f0==null?void 0:f0.execute(s.input),ne.last=M();let a=await s.res.array();ne.bodies=s.res.shape[2]===17?await g2(a,t,e):await M2(a,t,e);for(let i of ne.bodies)jn(i,[e.shape[2]||1,e.shape[1]||1]),En(i.keypoints);Object.keys(s).forEach(i=>r.dispose(s[i])),n(ne.bodies)})}var Me,bt=[],Cn=0,D5=Number.MAX_SAFE_INTEGER,Mt=0,gt=2.5;async function In(e){if(!Me||w.initial){Me=await N(e.object.modelPath);let t=Object.values(Me.modelSignature.inputs);Mt=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&g("cached model:",Me.modelUrl);return Me}async function P2(e,t,o){let A=0,n=[];for(let x of[1,2,4])r.tidy(async()=>{let d=x*13,l=r.squeeze(e.find(m=>m.shape[1]===d**2&&(m.shape[2]||0)===ce.length)),y=r.squeeze(e.find(m=>m.shape[1]===d**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&v!==61){let P=(.5+Math.trunc(m%d))/d,p=(.5+Math.trunc(m/d))/d,u=f[m].map(H=>H*(d/x/Mt)),[E,W]=[P-gt/x*u[0],p-gt/x*u[1]],[C,S]=[P+gt/x*u[2]-E,p+gt/x*u[3]-W],O=[E,W,C,S];O=O.map(H=>Math.max(0,Math.min(H,1)));let V=[O[0]*t[0],O[1]*t[1],O[2]*t[0],O[3]*t[1]],G={id:A++,score:Math.round(100*b)/100,class:v+1,label:ce[v].label,box:V.map(H=>Math.trunc(H)),boxRaw:O};n.push(G)}}});e.forEach(x=>r.dispose(x));let s=n.map(x=>[x.boxRaw[1],x.boxRaw[0],x.boxRaw[3],x.boxRaw[2]]),a=n.map(x=>x.score),i=[];if(s&&s.length>0){let x=await r.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);i=await x.data(),r.dispose(x)}return n=n.filter((x,d)=>i.includes(d)).sort((x,d)=>d.score-x.score),n}async function q5(e,t){let o=(t.object.skipTime||0)>M()-Cn,A=D5<(t.object.skipFrames||0);return t.skipAllowed&&o&&A&&bt.length>0?(D5++,bt):(D5=0,!w.kernels.includes("mod")||!w.kernels.includes("sparsetodense")?bt:new Promise(async n=>{let s=[e.shape[2]||0,e.shape[1]||0],a=r.image.resizeBilinear(e,[Mt,Mt],!1),i=r.div(a,L.tf255),x=i.transpose([0,3,1,2]);r.dispose(i),r.dispose(a);let d;t.object.enabled&&(d=Me.execute(x)),Cn=M(),r.dispose(x);let l=await P2(d,s,t);bt=l,n(l)}))}var He=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],v2=He.length,Be=He.reduce((e,t,o)=>(e[t]=o,e),{}),T2=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],Va=T2.map(([e,t])=>[Be[e],Be[t]]),Nn=[["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 Ln(e){let t=e.reduce(({maxX:o,maxY:A,minX:n,minY:s},{position:{x:a,y:i}})=>({maxX:Math.max(o,a),maxY:Math.max(A,i),minX:Math.min(n,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 Gn(e,[t,o],[A,n]){let s=t/A,a=o/n,i=(d,l)=>({id:l,score:d.score,boxRaw:[d.box[0]/n,d.box[1]/A,d.box[2]/n,d.box[3]/A],box:[Math.trunc(d.box[0]*a),Math.trunc(d.box[1]*s),Math.trunc(d.box[2]*a),Math.trunc(d.box[3]*s)],keypoints:d.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/A,f.y/A]})),annotations:{}});return e.map((d,l)=>i(d,l))}var U5=class{constructor(t,o){R(this,"priorityQueue");R(this,"numberOfElements");R(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 Bn(e,t,o,A){let n=o-e,s=A-t;return n*n+s*s}function Q5(e,t){return{x:e.x+t.x,y:e.y+t.y}}var v0,R2=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],Pt=1,Pe=16,k2=50**2;function Hn(e,t,o,A,n,s,a=2){let i=b=>({y:s.get(b.y,b.x,e),x:s.get(b.y,b.x,s.shape[2]/2+e)}),x=(b,P,p)=>({y:K5(Math.round(b.y/Pe),0,P-1),x:K5(Math.round(b.x/Pe),0,p-1)}),[d,l]=A.shape,y=x(t.position,d,l),c=i(y),h=Q5(t.position,c);for(let b=0;b[Be[c],Be[f]]),a=s.map(([,c])=>c),i=s.map(([c])=>c),x=t.shape[2],d=a.length,l=new Array(x),y=Y5(e.part,Pe,o);l[e.part.id]={score:e.score,part:He[e.part.id],position:y};for(let c=d-1;c>=0;--c){let f=a[c],h=i[c];l[f]&&!l[h]&&(l[h]=Hn(c,l[f],h,t,o,n))}for(let c=0;ct){i=!1;break}if(!i)break}return i}function j2(e,t){let[o,A,n]=t.shape,s=new U5(o*A*n,({score:a})=>a);for(let a=0;a{var a;let s=(a=n[A])==null?void 0:a.position;return s?Bn(o,t,s.y,s.x)<=k2:!1})}function S2(e,t){return t.reduce((A,{position:n,score:s},a)=>(Fn(e,n,a)||(A+=s),A),0)/t.length}function W2(e,t,o,A,n,s){let a=[],i=j2(s,t);for(;a.lengthf.score>s);let y=S2(a,l),c=Ln(l);y>s&&a.push({keypoints:l,box:c,score:Math.round(100*y)/100})}return a}async function _5(e,t){let o=r.tidy(()=>{if(!v0.inputs[0].shape)return[];let a=r.image.resizeBilinear(e,[v0.inputs[0].shape[2],v0.inputs[0].shape[1]]),i=r.sub(r.div(r.cast(a,"float32"),127.5),1),d=v0.execute(i,R2).map(l=>r.squeeze(l,[0]));return d[1]=r.sigmoid(d[1]),d}),A=await Promise.all(o.map(a=>a.buffer()));for(let a of o)r.dispose(a);let n=await W2(A[0],A[1],A[2],A[3],t.body.maxDetected,t.body.minConfidence);return v0.inputs[0].shape?Gn(n,[e.shape[1],e.shape[2]],[v0.inputs[0].shape[2],v0.inputs[0].shape[1]]):[]}async function Vn(e){return!v0||w.initial?v0=await N(e.body.modelPath):e.debug&&g("cached model:",v0.modelUrl),v0}var R0,$5=!1;async function eo(e){return!R0||w.initial?R0=await N(e.segmentation.modelPath):e.debug&&g("cached model:",R0.modelUrl),R0}async function Xn(e,t,o){var m,v;if($5)return{data:[],canvas:null,alpha:null};$5=!0,R0||await eo(o);let A=await le(e,o),n=((m=A.tensor)==null?void 0:m.shape[2])||0,s=((v=A.tensor)==null?void 0:v.shape[1])||0;if(!A.tensor)return{data:[],canvas:null,alpha:null};let a={};a.resize=r.image.resizeBilinear(A.tensor,[R0.inputs[0].shape?R0.inputs[0].shape[1]:0,R0.inputs[0].shape?R0.inputs[0].shape[2]:0],!1),r.dispose(A.tensor),a.norm=r.div(a.resize,L.tf255),a.res=R0.execute(a.norm),a.squeeze=r.squeeze(a.res,0),a.squeeze.shape[2]===2?(a.softmax=r.softmax(a.squeeze),[a.bg,a.fg]=r.unstack(a.softmax,2),a.expand=r.expandDims(a.fg,2),a.pad=r.expandDims(a.expand,0),a.crop=r.image.cropAndResize(a.pad,[[0,0,.5,.5]],[0],[n,s]),a.data=r.squeeze(a.crop,0)):a.data=r.image.resizeBilinear(a.squeeze,[s,n]);let i=Array.from(await a.data.data());if(w.node&&!w.Canvas&&typeof ImageData=="undefined")return o.debug&&g("canvas support missing"),Object.keys(a).forEach(b=>r.dispose(a[b])),{data:i,canvas:null,alpha:null};let x=s0(n,s);r.browser&&await r.browser.toPixels(a.data,x);let d=x.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(d.filter=`blur(${o.segmentation.blur}px)`);let l=d.getImageData(0,0,n,s),y=s0(n,s),c=y.getContext("2d");A.canvas&&c.drawImage(A.canvas,0,0),c.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`),c.drawImage(x,0,0),c.globalCompositeOperation="source-over",c.filter="none";let f=c.getImageData(0,0,n,s);for(let b=0;br.dispose(a[b])),$5=!1,{data:i,canvas:y,alpha:x}}var vt=class{constructor(){R(this,"ssrnetage",null);R(this,"gear",null);R(this,"blazeposedetect",null);R(this,"blazepose",null);R(this,"centernet",null);R(this,"efficientpose",null);R(this,"mobilefacenet",null);R(this,"emotion",null);R(this,"facedetect",null);R(this,"faceiris",null);R(this,"facemesh",null);R(this,"faceres",null);R(this,"ssrnetgender",null);R(this,"handpose",null);R(this,"handskeleton",null);R(this,"handtrack",null);R(this,"liveness",null);R(this,"movenet",null);R(this,"nanodet",null);R(this,"posenet",null);R(this,"segmentation",null);R(this,"antispoof",null)}};function Tt(e){for(let t of Object.keys(e.models))e.models[t]=null}async function to(e){var t,o,A,n,s,a,i,x,d,l,y,c,f,h,m,v,b,P,p,u,E,W,C,S,O,V,G,H,t0,z;w.initial&&Tt(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 C5(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((n=(A=e.config.hand.detector)==null?void 0:A.modelPath)==null?void 0:n.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await C5(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=hA(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=uA(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((x=(i=e.config.body)==null?void 0:i.modelPath)==null?void 0:x.includes("efficientpose"))&&(e.models.efficientpose=TA(e.config)),e.config.body.enabled&&!e.models.movenet&&((l=(d=e.config.body)==null?void 0:d.modelPath)==null?void 0:l.includes("movenet"))&&(e.models.movenet=Sn(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=Vn(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=iA(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=Yo(e.config)),e.config.face.enabled&&((h=e.config.face.liveness)==null?void 0:h.enabled)&&!e.models.liveness&&(e.models.liveness=wn(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=UA(e.config)),e.config.face.enabled&&((v=e.config.face.emotion)==null?void 0:v.enabled)&&!e.models.emotion&&(e.models.emotion=EA(e.config)),e.config.face.enabled&&((b=e.config.face.iris)==null?void 0:b.enabled)&&!e.models.faceiris&&(e.models.faceiris=GA(e.config)),e.config.face.enabled&&((P=e.config.face.mesh)==null?void 0:P.enabled)&&!e.models.facemesh&&(e.models.facemesh=VA(e.config)),e.config.face.enabled&&((p=e.config.face.gear)==null?void 0:p.enabled)&&!e.models.gear&&(e.models.gear=No(e.config)),e.config.face.enabled&&((u=e.config.face.ssrnet)==null?void 0:u.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Fo(e.config)),e.config.face.enabled&&((E=e.config.face.ssrnet)==null?void 0:E.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Do(e.config)),e.config.face.enabled&&((W=e.config.face.mobilefacenet)==null?void 0:W.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=CA(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((S=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:S.includes("handtrack"))&&(e.models.handtrack=gn(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((V=(O=e.config.hand.detector)==null?void 0:O.modelPath)==null?void 0:V.includes("handtrack"))&&(e.models.handskeleton=Mn(e.config)),e.config.object.enabled&&!e.models.centernet&&((H=(G=e.config.object)==null?void 0:G.modelPath)==null?void 0:H.includes("centernet"))&&(e.models.centernet=MA(e.config)),e.config.object.enabled&&!e.models.nanodet&&((z=(t0=e.config.object)==null?void 0:t0.modelPath)==null?void 0:z.includes("nanodet"))&&(e.models.nanodet=In(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=eo(e.config));for await(let m0 of Object.keys(e.models))e.models[m0]&&typeof e.models[m0]!="undefined"&&(e.models[m0]=await e.models[m0])}async function oo(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let A=e.models[o];if(!A)continue;let n=[],s=A==null?void 0:A.executor;if(s&&s.graph.nodes)for(let i of Object.values(s.graph.nodes)){let x=i.op.toLowerCase();n.includes(x)||n.push(x)}else!s&&e.config.debug&&g("model signature not determined:",o);let a=[];for(let i of n)!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&&g("model validation failed:",o,a)}}var q={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 C2(){let e=q.gl;!e||(q.extensions=e.getSupportedExtensions())}async function qn(e){var t;if(e.config.backend==="humangl"&&(q.name in r.engine().registry&&(!q.gl||!q.gl.getParameter(q.gl.VERSION))&&(g("error: humangl backend invalid context"),Tt(e)),!r.findBackend(q.name))){try{q.canvas=await s0(100,100)}catch(A){g("error: cannot create canvas:",A);return}try{if(q.gl=(t=q.canvas)==null?void 0:t.getContext("webgl2",q.webGLattr),!q.gl.getParameter(q.gl.VERSION).includes("2.0")){g("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}q.canvas&&(q.canvas.addEventListener("webglcontextlost",async n=>{throw g("error: humangl:",n.type),g("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),q.canvas.addEventListener("webglcontextrestored",n=>{g("error: humangl context restored:",n)}),q.canvas.addEventListener("webglcontextcreationerror",n=>{g("error: humangl context create:",n)}))}catch(A){g("error: cannot get WebGL context:",A);return}try{r.setWebGLContext(2,q.gl)}catch(A){g("error: cannot set WebGL context:",A);return}try{let A=new r.GPGPUContext(q.gl);r.registerBackend(q.name,()=>new r.MathBackendWebGL(A),q.priority)}catch(A){g("error: cannot register WebGL backend:",A);return}try{r.getKernelsForBackend("webgl").forEach(n=>{let s={...n,backendName:q.name};r.registerKernel(s)})}catch(A){g("error: cannot update WebGL backend registration:",A);return}let o=r.backend().getGPGPUContext?r.backend().getGPGPUContext().gl:null;if(o)g(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{g("error: no current gl context:",o,q.gl);return}try{r.ENV.set("WEBGL_VERSION",2)}catch(A){g("error: cannot set WebGL backend flags:",A);return}C2(),g("backend registered:",q.name)}}function I2(){if(!w.kernels.includes("mod")){let e={kernelName:"Mod",backendName:r.getBackend(),kernelFunc:t=>r.tidy(()=>r.sub(t.inputs.a,r.mul(r.div(t.inputs.a,t.inputs.b),t.inputs.b)))};r.registerKernel(e),w.kernels.push("mod")}if(!w.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:r.getBackend(),kernelFunc:t=>r.tidy(()=>r.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+r.mod(t.inputs.a,t.inputs.b))};r.registerKernel(e),w.kernels.push("floormod")}}async function wt(e,t=!1){if(e.state="backend",t||w.initial||e.config.backend&&e.config.backend.length>0&&r.getBackend()!==e.config.backend){let o=M();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&g("running inside web worker"),w.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&g("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),w.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&g(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),w.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")g("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let n=await navigator.gpu.requestAdapter();e.config.debug&&g("enumerated webgpu adapter:",n)}e.config.backend==="humangl"&&await qn(e);let A=Object.keys(r.engine().registryFactory);if(e.config.debug&&g("available backends:",A),A.includes(e.config.backend)||(g(`error: backend ${e.config.backend} not found in registry`),e.config.backend=w.node?"tensorflow":"webgl",e.config.debug&&g(`override: setting backend ${e.config.backend}`)),e.config.debug&&g("setting backend:",e.config.backend),e.config.backend==="wasm"){if(e.config.debug&&g("wasm path:",e.config.wasmPath),typeof(r==null?void 0:r.setWasmPaths)!="undefined")await r.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 n=await r.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await r.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&g(`wasm execution: ${n?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),e.config.debug&&!n&&g("warning: wasm simd support is not enabled")}try{await r.setBackend(e.config.backend),await r.ready(),Go()}catch(n){return g("error: cannot set backend:",e.config.backend,n),!1}}if(r.getBackend()==="humangl"&&(r.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),r.ENV.set("WEBGL_CPU_FORWARD",!0),r.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),r.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(g("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),r.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),r.backend().getGPGPUContext)){let A=await r.backend().getGPGPUContext().gl;e.config.debug&&g(`gl version:${A.getParameter(A.VERSION)} renderer:${A.getParameter(A.RENDERER)}`)}r.getBackend(),r.enableProdMode(),await r.ready(),e.performance.initBackend=Math.trunc(M()-o),e.config.backend=r.getBackend(),await w.updateBackend(),I2()}return!0}function ft(e,t){for(let o of e){let A={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&g("kernelFunc",o,t.backend)}};r.registerKernel(A)}w.kernels=r.getKernelsForBackend(r.getBackend()).map(o=>o.kernelName.toLowerCase())}var Kn={};Y0(Kn,{all:()=>io,body:()=>Et,canvas:()=>ao,face:()=>kt,gesture:()=>Rt,hand:()=>zt,object:()=>jt,options:()=>k0,person:()=>so});var k0={color:"rgba(173, 216, 230, 0.6)",labelColor:"rgba(173, 216, 230, 1)",shadowColor:"black",font:'small-caps 16px "Segoe UI"',lineHeight:18,lineWidth:4,pointSize:2,roundRect:8,drawPoints:!1,drawLabels:!0,drawBoxes:!0,drawGestures:!0,drawPolygons:!0,drawGaze:!0,fillPolygons:!1,useDepth:!0,useCurves:!1},no=0,re=e=>{if(!e)g("draw error: invalid canvas");else if(!e.getContext)g("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)g("draw error: cannot get canvas context");else return t}return null},ve=e=>Math.round(e*180/Math.PI);function ro(e,t,o,A,n){A=A||0,e.fillStyle=n.useDepth&&A?`rgba(${127.5+2*A}, ${127.5-2*A}, 255, 0.3)`:n.color,e.beginPath(),e.arc(t,o,n.pointSize,0,2*Math.PI),e.fill()}function Fe(e,t,o,A,n,s){if(e.beginPath(),e.lineWidth=s.lineWidth,s.useCurves){let a=(t+t+A)/2,i=(o+o+n)/2;e.ellipse(a,i,A/2,n/2,0,0,2*Math.PI)}else e.moveTo(t+s.roundRect,o),e.lineTo(t+A-s.roundRect,o),e.quadraticCurveTo(t+A,o,t+A,o+s.roundRect),e.lineTo(t+A,o+n-s.roundRect),e.quadraticCurveTo(t+A,o+n,t+A-s.roundRect,o+n),e.lineTo(t+s.roundRect,o+n),e.quadraticCurveTo(t,o+n,t,o+n-s.roundRect),e.lineTo(t,o+s.roundRect),e.quadraticCurveTo(t,o,t+s.roundRect,o),e.closePath();e.stroke()}function Yn(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let A of t){let n=A[2]||0;e.strokeStyle=o.useDepth&&n!==0?`rgba(${127.5+2*n}, ${127.5-2*n}, 255, 0.3)`:o.color,e.fillStyle=o.useDepth&&n!==0?`rgba(${127.5+2*n}, ${127.5-2*n}, 255, 0.3)`:o.color,e.lineTo(A[0],Math.round(A[1]))}e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function N2(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){Yn(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let A=0;A1&&x[1].length>0){let d=i[1]>0?`#${i[1]}`:"",l=`${i[0]} ${d}: ${x[1]}`;A.shadowColor&&A.shadowColor!==""&&(n.fillStyle=A.shadowColor,n.fillText(l,8,2+s*A.lineHeight)),n.fillStyle=A.labelColor,n.fillText(l,6,0+s*A.lineHeight),s+=1}}}}async function kt(e,t,o){var s,a,i,x,d;let A=o0(k0,o);if(!t||!e)return;let n=re(e);if(!!n)for(let l of t){if(n.font=A.font,n.strokeStyle=A.color,n.fillStyle=A.color,A.drawBoxes&&Fe(n,l.box[0],l.box[1],l.box[2],l.box[3],A),A.drawLabels){let y=[];if(y.push(`face: ${Math.trunc(100*l.score)}%`),l.genderScore&&y.push(`${l.gender||""} ${Math.trunc(100*l.genderScore)}%`),l.age&&y.push(`age: ${l.age||""}`),l.iris&&y.push(`distance: ${l.iris}`),l.real&&y.push(`real: ${Math.trunc(100*l.real)}%`),l.live&&y.push(`live: ${Math.trunc(100*l.live)}%`),l.emotion&&l.emotion.length>0){let c=l.emotion.map(f=>`${Math.trunc(100*f.score)}% ${f.emotion}`);c.length>3&&(c.length=3),y.push(c.join(" "))}l.rotation&&l.rotation.angle&&l.rotation.gaze&&(l.rotation.angle.roll&&y.push(`roll: ${ve(l.rotation.angle.roll)}\xB0 yaw:${ve(l.rotation.angle.yaw)}\xB0 pitch:${ve(l.rotation.angle.pitch)}\xB0`),l.rotation.gaze.bearing&&y.push(`gaze: ${ve(l.rotation.gaze.bearing)}\xB0`)),y.length===0&&y.push("face"),n.fillStyle=A.color;for(let c=y.length-1;c>=0;c--){let f=Math.max(l.box[0],0),h=c*A.lineHeight+l.box[1];A.shadowColor&&A.shadowColor!==""&&(n.fillStyle=A.shadowColor,n.fillText(y[c],f+5,h+16)),n.fillStyle=A.labelColor,n.fillText(y[c],f+4,h+15)}}if(n.lineWidth=2,l.mesh&&l.mesh.length>0){if(A.drawPoints)for(let y of l.mesh)ro(n,y[0],y[1],y[2],A);if(A.drawPolygons){if(l.mesh.length>450)for(let y=0;yl.mesh[f]);Yn(n,c,A)}if(l.annotations&&l.annotations.leftEyeIris&&l.annotations.leftEyeIris[0]){n.strokeStyle=A.useDepth?"rgba(255, 200, 255, 0.3)":A.color,n.beginPath();let y=Math.abs(l.annotations.leftEyeIris[3][0]-l.annotations.leftEyeIris[1][0])/2,c=Math.abs(l.annotations.leftEyeIris[4][1]-l.annotations.leftEyeIris[2][1])/2;n.ellipse(l.annotations.leftEyeIris[0][0],l.annotations.leftEyeIris[0][1],y,c,0,0,2*Math.PI),n.stroke(),A.fillPolygons&&(n.fillStyle=A.useDepth?"rgba(255, 255, 200, 0.3)":A.color,n.fill())}if(l.annotations&&l.annotations.rightEyeIris&&l.annotations.rightEyeIris[0]){n.strokeStyle=A.useDepth?"rgba(255, 200, 255, 0.3)":A.color,n.beginPath();let y=Math.abs(l.annotations.rightEyeIris[3][0]-l.annotations.rightEyeIris[1][0])/2,c=Math.abs(l.annotations.rightEyeIris[4][1]-l.annotations.rightEyeIris[2][1])/2;n.ellipse(l.annotations.rightEyeIris[0][0],l.annotations.rightEyeIris[0][1],y,c,0,0,2*Math.PI),n.stroke(),A.fillPolygons&&(n.fillStyle=A.useDepth?"rgba(255, 255, 200, 0.3)":A.color,n.fill())}if(A.drawGaze&&((s=l.rotation)==null?void 0:s.angle)&&typeof Path2D!="undefined"){n.strokeStyle="pink";let y=l.box[0]+l.box[2]/2-l.box[3]*ve(l.rotation.angle.yaw)/90,c=l.box[1]+l.box[3]/2+l.box[2]*ve(l.rotation.angle.pitch)/90,f=new Path2D(` +`;var Ht=(e,t,o)=>{let A=new RegExp("\\b"+t+" \\w+ (\\w+)","ig");e.replace(A,(n,s)=>(o[s]=0,n))},Ft=class{constructor(t,o,A){R(this,"uniform",{});R(this,"attribute",{});R(this,"gl");R(this,"id");R(this,"compile",(t,o)=>{let A=this.gl.createShader(o);return A?(this.gl.shaderSource(A,t),this.gl.compileShader(A),this.gl.getShaderParameter(A,this.gl.COMPILE_STATUS)?A:(g(`filter: gl compile failed: ${this.gl.getShaderInfoLog(A)}`),null)):(g("filter: could not create shader"),null)});this.gl=t;let n=this.compile(o,this.gl.VERTEX_SHADER),s=this.compile(A,this.gl.FRAGMENT_SHADER);if(this.id=this.gl.createProgram(),!(!n||!s)){if(!this.id){g("filter: could not create webgl program");return}if(this.gl.attachShader(this.id,n),this.gl.attachShader(this.id,s),this.gl.linkProgram(this.id),!this.gl.getProgramParameter(this.id,this.gl.LINK_STATUS)){g(`filter: gl link failed: ${this.gl.getProgramInfoLog(this.id)}`);return}this.gl.useProgram(this.id),Ht(o,"attribute",this.attribute);for(let a in this.attribute)this.attribute[a]=this.gl.getAttribLocation(this.id,a);Ht(o,"uniform",this.uniform),Ht(A,"uniform",this.uniform);for(let a in this.uniform)this.uniform[a]=this.gl.getUniformLocation(this.id,a)}}};function jo(){let e=0,t=null,o=!1,A=-1,n=[null,null],s=[],a=null,i=null,x=s0(100,100),d={},l={INTERMEDIATE:1},y=x.getContext("webgl");if(this.gl=y,!y){g("filter: cannot get webgl context");return}function c(P,p){if(!(P===x.width&&p===x.height)){if(x.width=P,x.height=p,!a){let u=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,u,y.STATIC_DRAW),y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}y.viewport(0,0,x.width,x.height),n=[null,null]}}function f(P,p){let u=y.createFramebuffer();y.bindFramebuffer(y.FRAMEBUFFER,u);let E=y.createRenderbuffer();y.bindRenderbuffer(y.RENDERBUFFER,E);let W=y.createTexture();return y.bindTexture(y.TEXTURE_2D,W),y.texImage2D(y.TEXTURE_2D,0,y.RGBA,P,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,W,0),y.bindTexture(y.TEXTURE_2D,null),y.bindFramebuffer(y.FRAMEBUFFER,null),{fbo:u,texture:W}}function h(P){return n[P]=n[P]||f(x.width,x.height),n[P]}function m(P=0){if(!i)return;let p=null,u=null,E=!1;e===0?p=t:p=h(A).texture||null,e++,o&&!(P&l.INTERMEDIATE)?(u=null,E=e%2===0):(A=(A+1)%2,u=h(A).fbo||null),y.bindTexture(y.TEXTURE_2D,p),y.bindFramebuffer(y.FRAMEBUFFER,u),y.uniform1f(i.uniform.flipY,E?-1:1),y.drawArrays(y.TRIANGLES,0,6)}function v(P){if(d[P])return i=d[P],y.useProgram((i?i.id:null)||null),i;if(i=new Ft(y,To,P),!i)return g("filter: could not get webgl program"),null;let p=Float32Array.BYTES_PER_ELEMENT,u=4*p;return y.enableVertexAttribArray(i.attribute.pos),y.vertexAttribPointer(i.attribute.pos,2,y.FLOAT,!1,u,0*p),y.enableVertexAttribArray(i.attribute.uv),y.vertexAttribPointer(i.attribute.uv,2,y.FLOAT,!1,u,2*p),d[P]=i,i}let b={colorMatrix:P=>{let p=new Float32Array(P);p[4]/=255,p[9]/=255,p[14]/=255,p[19]/=255;let u=p[18]===1&&p[3]===0&&p[8]===0&&p[13]===0&&p[15]===0&&p[16]===0&&p[17]===0&&p[19]===0?Ro:wo,E=v(u);!E||(y.uniform1fv(E.uniform.m,p),m())},brightness:P=>{let p=(P||0)+1;b.colorMatrix([p,0,0,0,0,0,p,0,0,0,0,0,p,0,0,0,0,0,1,0])},saturation:P=>{let p=(P||0)*2/3+1,u=(p-1)*-.5;b.colorMatrix([p,u,u,0,0,u,p,u,0,0,u,u,p,0,0,0,0,0,1,0])},desaturate:()=>{b.saturation(-1)},contrast:P=>{let p=(P||0)+1,u=-128*(p-1);b.colorMatrix([p,0,0,0,u,0,p,0,0,u,0,0,p,0,u,0,0,0,1,0])},negative:()=>{b.contrast(-2)},hue:P=>{P=(P||0)/180*Math.PI;let p=Math.cos(P),u=Math.sin(P),E=.213,W=.715,C=.072;b.colorMatrix([E+p*(1-E)+u*-E,W+p*-W+u*-W,C+p*-C+u*(1-C),0,0,E+p*-E+u*.143,W+p*(1-W)+u*.14,C+p*-C+u*-.283,0,0,E+p*-E+u*-(1-E),W+p*-W+u*W,C+p*(1-C)+u*C,0,0,0,0,0,1,0])},desaturateLuminance:()=>{b.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:()=>{b.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},brownie:()=>{b.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:()=>{b.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:()=>{b.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:()=>{b.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:()=>{b.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:()=>{b.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},convolution:P=>{let p=new Float32Array(P),u=1/x.width,E=1/x.height,W=v(zo);!W||(y.uniform1fv(W.uniform.m,p),y.uniform2f(W.uniform.px,u,E),m())},detectEdges:()=>{b.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},sobelX:()=>{b.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},sobelY:()=>{b.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},sharpen:P=>{let p=P||1;b.convolution.call(this,[0,-1*p,0,-1*p,1+4*p,-1*p,0,-1*p,0])},emboss:P=>{let p=P||1;b.convolution.call(this,[-2*p,-1*p,0,-1*p,1,1*p,0,1*p,2*p])},blur:P=>{let p=P/7/x.width,u=P/7/x.height,E=v(Eo);!E||(y.uniform2f(E.uniform.px,0,u),m(l.INTERMEDIATE),y.uniform2f(E.uniform.px,p,0),m())},pixelate:P=>{let p=P/x.width,u=P/x.height,E=v(ko);!E||(y.uniform2f(E.uniform.size,p,u),m())}};this.add=function(P){let p=Array.prototype.slice.call(arguments,1),u=b[P];s.push({func:u,args:p})},this.reset=function(){s=[]},this.get=function(){return s},this.apply=function(P){c(P.width,P.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,P);for(let p=0;pf.data())),a=.99*Math.max(s[0][0],s[1][0],s[2][0]),i=[r.sub(o[0],A[0]),r.sub(o[1],A[1]),r.sub(o[2],A[2])],x=[r.sub(n[0],A[0]),r.sub(n[1],A[1]),r.sub(n[2],A[2])],d=[r.div(a,x[0]),r.div(a,x[1]),r.div(a,x[2])],l=[r.mul(i[0],d[0]),r.mul(i[1],d[1]),r.mul(i[2],d[2])],y=r.stack([l[0],l[1],l[2]],2),c=r.reshape(y,[1,t.shape[0],t.shape[1],3]);return r.dispose([...o,...A,...n,...i,...x,...d,...l,y,t]),c}var Ue=2048,B=null,_=null,ie=null,D,j0={inputSum:0,cacheDiff:1,sumMethod:0,inputTensor:void 0};function s0(e,t){let o;if(w.browser)if(w.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 w.Canvas!="undefined"?o=new w.Canvas(e,t):typeof globalThis.Canvas!="undefined"&&(o=new globalThis.Canvas(e,t));return o}function Vt(e,t){let o=t||s0(e.width,e.height);return o.getContext("2d").drawImage(e,0,0),o}async function le(e,t,o=!0){if(!e)return t.debug&&g("input error: input is missing"),{tensor:null,canvas:null};if(!(e instanceof ae)&&!(typeof Image!="undefined"&&e instanceof Image)&&!(typeof w.Canvas!="undefined"&&e instanceof w.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 ae){let A=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)A=r.expandDims(e,0);else if(e.shape[2]===4){let n=r.slice3d(e,[0,0,0],[-1,-1,3]);A=r.expandDims(n,0),r.dispose(n)}}else e.shape.length===4&&(e.shape[3]===3?A=r.clone(e):e.shape[3]===4&&(A=r.slice4d(e,[0,0,0,0],[-1,-1,-1,3])));if(A==null||A.shape.length!==4||A.shape[0]!==1||A.shape[3]!==3)throw new Error(`input error: attempted to use tensor with unrecognized shape: ${e.shape}`);if(A.dtype==="int32"){let n=r.cast(A,"float32");r.dispose(A),A=n}return{tensor:A,canvas:t.filter.return?_:null}}else{if(typeof e.readyState!="undefined"&&e.readyState<=2)return t.debug&&g("input stream is not ready"),{tensor:null,canvas:B};let A=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,n=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;if(!A||!n)return t.debug&&g("cannot determine input dimensions"),{tensor:null,canvas:B};let s=A,a=n;if(s>Ue&&(s=Ue,a=Math.trunc(s*n/A)),a>Ue&&(a=Ue,s=Math.trunc(a*A/n)),(t.filter.width||0)>0?s=t.filter.width:(t.filter.height||0)>0&&(s=A*((t.filter.height||0)/n)),(t.filter.height||0)>0?a=t.filter.height:(t.filter.width||0)>0&&(a=n*((t.filter.width||0)/A)),!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=s0(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(A,0),i.scale(-1,1),i.drawImage(e,0,0,A,n,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,A,n,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))&&(_=s0(B.width,B.height)),t.filter.enabled&&w.webgl.supported){if(D||(D=w.browser?new jo:null),w.filter=!!D,!D||!D.add)return t.debug&&g("input process error: cannot initialize filters"),{tensor:null,canvas:B};D.reset(),t.filter.brightness!==0&&D.add("brightness",t.filter.brightness),t.filter.contrast!==0&&D.add("contrast",t.filter.contrast),t.filter.sharpness!==0&&D.add("sharpen",t.filter.sharpness),t.filter.blur!==0&&D.add("blur",t.filter.blur),t.filter.saturation!==0&&D.add("saturation",t.filter.saturation),t.filter.hue!==0&&D.add("hue",t.filter.hue),t.filter.negative&&D.add("negative"),t.filter.sepia&&D.add("sepia"),t.filter.vintage&&D.add("brownie"),t.filter.sepia&&D.add("sepia"),t.filter.kodachrome&&D.add("kodachrome"),t.filter.technicolor&&D.add("technicolor"),t.filter.polaroid&&D.add("polaroid"),t.filter.pixelate!==0&&D.add("pixelate",t.filter.pixelate),D.get()>0?_=D.apply(B):_=D.draw(B)}else Vt(B,_),D&&(D=null),w.filter=!!D;if(!o)return{tensor:null,canvas:_};if(!_)throw new Error("canvas error: cannot create output");let x,d=3;if(typeof ImageData!="undefined"&&e instanceof ImageData||e.data&&e.width&&e.height)if(w.browser&&r.browser)x=r.browser?r.browser.fromPixels(e):null;else{d=e.data.length/e.height/e.width;let c=new Uint8Array(e.data.buffer);x=r.tensor(c,[e.height,e.width,d],"int32")}else if((!ie||_.width!==ie.width||_.height!==ie.height)&&(ie=s0(_.width,_.height)),r.browser&&w.browser)t.backend==="webgl"||t.backend==="humangl"||t.backend==="webgpu"?x=r.browser.fromPixels(_):(ie=Vt(_),x=r.browser.fromPixels(ie));else{let h=Vt(_).getContext("2d").getImageData(0,0,s,a);d=h.data.length/s/a;let m=new Uint8Array(h.data.buffer);x=r.tensor(m,[s,a,d])}if(d===4){let c=r.slice3d(x,[0,0,0],[-1,-1,3]);r.dispose(x),x=c}if(!x)throw new Error("input error: cannot create tensor");let l=r.cast(x,"float32"),y=t.filter.equalization?await qe(l):r.expandDims(l,0);return r.dispose([x,l]),{tensor:y,canvas:t.filter.return?_:null}}}async function So(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(!j0.inputTensor)j0.inputTensor=r.clone(t);else if(j0.inputTensor.shape[1]!==t.shape[1]||j0.inputTensor.shape[2]!==t.shape[2])r.dispose(j0.inputTensor),j0.inputTensor=r.clone(t);else{let A={};A.diff=r.sub(t,j0.inputTensor),A.squared=r.mul(A.diff,A.diff),A.sum=r.sum(A.squared);let s=(await A.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;r.dispose([j0.inputTensor,A.diff,A.squared,A.sum]),j0.inputTensor=r.clone(t),o=s<=(e.cacheSensitivity||0)}return o}async function Wo(e,t,o){let A={};if(!t||!o||t.shape.length!==4||t.shape.length!==o.shape.length)return e.debug||g("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||g("input tensors must be of shape [1, height, width, 3]:",t.shape,o.shape),0;A.input1=r.clone(t),A.input2=t.shape[1]!==o.shape[1]||t.shape[2]!==o.shape[2]?r.image.resizeBilinear(o,[t.shape[1],t.shape[2]]):r.clone(o),A.diff=r.sub(A.input1,A.input2),A.squared=r.mul(A.diff,A.diff),A.sum=r.sum(A.squared);let s=(await A.sum.data())[0]/(t.shape[1]||1)/(t.shape[2]||1)/255/3;return r.dispose([A.input1,A.input2,A.diff,A.squared,A.sum]),s}var Zt=class{constructor(){R(this,"browser");R(this,"node");R(this,"worker");R(this,"platform","");R(this,"agent","");R(this,"backends",[]);R(this,"initial");R(this,"filter");R(this,"tfjs");R(this,"offscreen");R(this,"perfadd",!1);R(this,"wasm",{supported:void 0,backend:void 0,simd:void 0,multithread:void 0});R(this,"webgl",{supported:void 0,backend:void 0,version:void 0,renderer:void 0});R(this,"webgpu",{supported:void 0,backend:void 0,adapter:void 0});R(this,"cpu",{model:void 0,flags:[]});R(this,"kernels",[]);R(this,"Canvas");R(this,"Image");R(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:Se["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(r.engine().registryFactory),this.wasm.supported=typeof WebAssembly!="undefined",this.wasm.backend=this.backends.includes("wasm"),this.wasm.supported&&this.wasm.backend&&r.getBackend()==="wasm"&&(this.wasm.simd=await r.env().getAsync("WASM_HAS_SIMD_SUPPORT"),this.wasm.multithread=await r.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"));let t=s0(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&&(r.getBackend()==="webgl"||r.getBackend()==="humangl")){let A=r.backend().gpgpu!=="undefined"?await r.backend().getGPGPUContext().gl:null;A&&(this.webgl.version=A.getParameter(A.VERSION),this.webgl.renderer=A.getParameter(A.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(A){this.webgpu.supported=!1}try{this.kernels=r.getKernelsForBackend(r.getBackend()).map(A=>A.kernelName.toLowerCase())}catch(A){}}async updateCPU(){let t={model:"",flags:[]};this.node&&this.platform.startsWith("linux"),this.cpu?this.cpu=t:Object.defineProperty(this,"cpu",{value:t})}},w=new Zt;var S0={cacheModels:!1,verbose:!0,debug:!1,modelBasePath:""};async function Tr(e,t){return S0.debug&&g("load model fetch:",e,t),fetch(e,t)}function Co(e){S0.cacheModels=e.cacheModels,S0.verbose=e.debug,S0.modelBasePath=e.modelBasePath}async function N(e){let t=vo(S0.modelBasePath,e||""),o=t.split("/"),A="indexeddb://"+o[o.length-1].replace(".json",""),n=await r.io.listModels(),s=S0.cacheModels&&Object.keys(n).includes(A),a=typeof fetch=="undefined"?{}:{fetchFunc:(x,d)=>Tr(x,d)},i=new Bt(s?A:t,a);try{i.findIOHandler(),S0.debug&&g("model load handler:",i.handler);let x=await i.handler.load();i.loadSync(x),S0.verbose&&g("load model:",i.modelUrl)}catch(x){g("error loading model:",t,x)}if(S0.cacheModels&&!s)try{let x=await i.save(A);g("model saved:",A,x)}catch(x){g("error saving model:",t,x)}return i}var Xt="2.6.5";var ro={};K0(ro,{Models:()=>Fe,load:()=>Ao,reset:()=>kt,validate:()=>no});var u0,Dt=[],kr=["white","black","asian","indian","other"],Er=[15,23,28,35.5,45.5,55.5,65],Io=0,Oo=0,qt=Number.MAX_SAFE_INTEGER;async function No(e){return w.initial&&(u0=null),u0?e.debug&&g("cached model:",u0.modelUrl):u0=await N(e.face.gear),u0}async function Ut(e,t,o,A){var a,i;if(!u0)return{age:0,gender:"unknown",genderScore:0,race:[]};let n=qt<(((a=t.face.gear)==null?void 0:a.skipFrames)||0),s=(((i=t.face.gear)==null?void 0:i.skipTime)||0)>M()-Oo;return t.skipAllowed&&s&&n&&Io===A&&Dt[o]?(qt++,Dt[o]):(qt=0,new Promise(async x=>{var b,P;if(!(u0!=null&&u0.inputs[0].shape))return;let d={},l=[[0,.1,.9,.9]];d.resize=r.image.cropAndResize(e,l,[0],[u0.inputs[0].shape[2],u0.inputs[0].shape[1]]);let y={age:0,gender:"unknown",genderScore:0,race:[]};(b=t.face.gear)!=null&&b.enabled&&([d.age,d.gender,d.race]=u0.execute(d.resize,["age_output","gender_output","race_output"]));let c=await d.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 d.race.data();for(let p=0;p(((P=t.face.gear)==null?void 0:P.minConfidence)||.2)&&y.race.push({score:Math.round(100*f[p])/100,race:kr[p]});y.race.sort((p,u)=>u.score-p.score);let m=Array.from(await d.age.data()).map((p,u)=>[Er[u],p]).sort((p,u)=>u[1]-p[1]),v=m[0][0];for(let p=1;pr.dispose(d[p])),Dt[o]=y,Io=A,Oo=M(),x(y)}))}var L={tf255:255,tf1:1,tf2:2,tf05:.5,tf127:127.5,rgb:[.2989,.587,.114]};function Go(){L.tf255=r.scalar(255,"float32"),L.tf1=r.scalar(1,"float32"),L.tf2=r.scalar(2,"float32"),L.tf05=r.scalar(.5,"float32"),L.tf127=r.scalar(127.5,"float32"),L.rgb=r.tensor1d([.2989,.587,.114],"float32")}var l0,Je=[],Bo=0,Ho=0,Jt=Number.MAX_SAFE_INTEGER;async function Fo(e){return w.initial&&(l0=null),l0?e.debug&&g("cached model:",l0.modelUrl):l0=await N(e.face.ssrnet.modelPathAge),l0}async function Yt(e,t,o,A){var a,i,x,d;if(!l0)return{age:0};let n=Jt<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>M()-Ho;return t.skipAllowed&&n&&s&&Bo===A&&((x=Je[o])==null?void 0:x.age)&&((d=Je[o])==null?void 0:d.age)>0?(Jt++,Je[o]):(Jt=0,new Promise(async l=>{if(!(l0!=null&&l0.inputs)||!l0.inputs[0]||!l0.inputs[0].shape)return;let y={};y.resize=r.image.resizeBilinear(e,[l0.inputs[0].shape[2],l0.inputs[0].shape[1]],!1),y.enhance=r.mul(y.resize,L.tf255);let c={age:0};if(t.face.ssrnet.enabled&&(y.age=l0.execute(y.enhance)),y.age){let f=await y.age.data();c.age=Math.trunc(10*f[0])/10}Object.keys(y).forEach(f=>r.dispose(y[f])),Je[o]=c,Bo=A,Ho=M(),l(c)}))}var h0,Ye=[],Zo=0,Xo=0,Kt=Number.MAX_SAFE_INTEGER,Qt=[.2989,.587,.114];async function Do(e){return w.initial&&(h0=null),h0?e.debug&&g("cached model:",h0.modelUrl):h0=await N(e.face.ssrnet.modelPathGender),h0}async function _t(e,t,o,A){var a,i,x,d;if(!h0)return{gender:"unknown",genderScore:0};let n=Kt<(((a=t.face.ssrnet)==null?void 0:a.skipFrames)||0),s=(((i=t.face.ssrnet)==null?void 0:i.skipTime)||0)>M()-Xo;return t.skipAllowed&&n&&s&&Zo===A&&((x=Ye[o])==null?void 0:x.gender)&&((d=Ye[o])==null?void 0:d.genderScore)>0?(Kt++,Ye[o]):(Kt=0,new Promise(async l=>{if(!(h0!=null&&h0.inputs[0].shape))return;let y={};y.resize=r.image.resizeBilinear(e,[h0.inputs[0].shape[2],h0.inputs[0].shape[1]],!1),y.enhance=r.tidy(()=>{let[h,m,v]=r.split(y.resize,3,3),b=r.mul(h,Qt[0]),P=r.mul(m,Qt[1]),p=r.mul(v,Qt[2]),u=r.addN([b,P,p]);return r.mul(r.sub(u,L.tf05),2)});let c={gender:"unknown",genderScore:0};t.face.ssrnet.enabled&&(y.gender=h0.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(h=>r.dispose(y[h])),Ye[o]=c,Zo=A,Xo=M(),l(c)}))}var A0,Ke=[],$t=Number.MAX_SAFE_INTEGER,Uo=0,Jo=0;async function Yo(e){var t;return w.initial&&(A0=null),A0?e.debug&&g("cached model:",A0.modelUrl):A0=await N((t=e.face.antispoof)==null?void 0:t.modelPath),A0}async function e5(e,t,o,A){var a,i;if(!A0)return 0;let n=(((a=t.face.antispoof)==null?void 0:a.skipTime)||0)>M()-Jo,s=$t<(((i=t.face.antispoof)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&n&&s&&Uo===A&&Ke[o]?($t++,Ke[o]):($t=0,new Promise(async x=>{let d=r.image.resizeBilinear(e,[A0!=null&&A0.inputs[0].shape?A0.inputs[0].shape[2]:0,A0!=null&&A0.inputs[0].shape?A0.inputs[0].shape[1]:0],!1),l=A0==null?void 0:A0.execute(d),y=(await l.data())[0];Ke[o]=Math.round(100*y)/100,Uo=A,Jo=M(),r.dispose([d,l]),x(Ke[o])}))}var b0={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]},t5={count:468,mouth:13,symmetryLine:[13,b0.midwayBetweenEyes[0]]},Ce={leftEye:0,rightEye:1,nose:2,mouth:3,leftEar:4,rightEar:5,symmetryLine:[3,2]},o5=[{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]}],Ie=[[.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]],_0=[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 jr=[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],Sr=[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],Wr=[33,133,362,263,1,78,308],ws=jr.map(e=>Ie[e]),Rs=Sr.map(e=>Ie[e]),ks=Wr.map(e=>Ie[e]);var ye=e=>[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])],Qe=e=>[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2,1],s5=(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],a5=(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],$o=(e,t)=>{let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],A=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:A,landmarks:e.landmarks,confidence:e.confidence}},n5=(e,t,o)=>{let A=t.shape[1],n=t.shape[2],s=[e.startPoint[1]/A,e.startPoint[0]/n,e.endPoint[1]/A,e.endPoint[0]/n],a=r.image.cropAndResize(t,[s],[0],o),i=r.div(a,L.tf255);return r.dispose(a),i},_e=(e,t)=>{let o=Qe(e),A=ye(e),n=[t*A[0]/2,t*A[1]/2];return{startPoint:[o[0]-n[0],o[1]-n[1]],endPoint:[o[0]+n[0],o[1]+n[1]],landmarks:e.landmarks,confidence:e.confidence}},$e=e=>{let t=Qe(e),o=ye(e),A=Math.max(...o)/2;return{startPoint:[Math.round(t[0]-A),Math.round(t[1]-A)],endPoint:[Math.round(t[0]+A),Math.round(t[1]+A)],landmarks:e.landmarks,confidence:e.confidence}},eA=e=>{let t=e.map(A=>A[0]),o=e.map(A=>A[1]);return{startPoint:[Math.min(...t),Math.min(...o)],endPoint:[Math.max(...t),Math.max(...o)],landmarks:e}},r5=[[1,0,0],[0,1,0],[0,0,1]],Cr=e=>e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI)),Ir=(e,t)=>Cr(Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]));var Qo=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]],$0=(e,t)=>{let o=0;for(let A=0;A{let o=[];for(let A=0;A{let o=[],A=e.length;for(let n=0;n{let o=Math.cos(e),A=Math.sin(e),n=[[o,-A,0],[A,o,0],[0,0,1]],s=Qo(t[0],t[1]),a=_o(s,n),i=Qo(-t[0],-t[1]);return _o(a,i)},Nr=e=>{let t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],A=[-$0(t[0],o),-$0(t[1],o)];return[t[0].concat(A[0]),t[1].concat(A[1]),[0,0,1]]},Lr=(e,t)=>[$0(e,t[0]),$0(e,t[1])];function oA(e){let t={strides:[e/16,e/8],anchors:[2,6]},o=[];for(let A=0;A[s[0]/n*(f[0]-n/2),s[1]/n*(f[1]-n/2),f[2]||0]),i=o&&o!==0&&Math.abs(o)>.2,x=i?tA(o,[0,0]):r5,d=i?a.map(f=>[...Lr(f,x),f[2]]):a,l=i?Nr(A):r5,y=Qe(t),c=[$0(y,l[0]),$0(y,l[1])];return d.map(f=>[Math.trunc(f[0]+c[0]),Math.trunc(f[1]+c[1]),Math.trunc(f[2]||0)])}function nA(e,t,o,A){let n=t.landmarks.length>=t5.count?t5.symmetryLine:Ce.symmetryLine,s=0,a=r5,i;if(e&&w.kernels.includes("rotatewithoffset"))if(s=Ir(t.landmarks[n[0]],t.landmarks[n[1]]),s&&s!==0&&Math.abs(s)>.2){let d=Qe(t),l=[d[0]/o.shape[2],d[1]/o.shape[1]],y=r.image.rotateWithOffset(o,s,0,l);a=tA(-s,d),i=n5(t,y,[A,A]),r.dispose(y)}else i=n5(t,o,[A,A]);else i=n5(t,o,[A,A]);return[s,a,i]}var Gr=e=>{let t=e.map(A=>A[0]),o=e.map(A=>A[1]);return[Math.min(...t)+(Math.max(...t)-Math.min(...t))/2,Math.min(...o)+(Math.max(...o)-Math.min(...o))/2]},rA=(e,t)=>{let o=Gr(e),A=ye(t);return{startPoint:[o[0]-A[0]/2,o[1]-A[1]/2],endPoint:[o[0]+A[0]/2,o[1]+A[1]/2]}};var sA=6,Br=1.2,T0,aA=null,H0=0,Oe=null,et=()=>H0;async function iA(e){var t;return w.initial&&(T0=null),T0?e.debug&&g("cached model:",T0.modelUrl):T0=await N((t=e.face.detector)==null?void 0:t.modelPath),H0=T0.inputs[0].shape?T0.inputs[0].shape[2]:0,Oe=r.scalar(H0,"int32"),aA=r.tensor2d(oA(H0)),T0}function Hr(e){let t={};t.boxStarts=r.slice(e,[0,1],[-1,2]),t.centers=r.add(t.boxStarts,aA),t.boxSizes=r.slice(e,[0,3],[-1,2]),t.boxSizesNormalized=r.div(t.boxSizes,Oe),t.centersNormalized=r.div(t.centers,Oe),t.halfBoxSize=r.div(t.boxSizesNormalized,L.tf2),t.starts=r.sub(t.centersNormalized,t.halfBoxSize),t.ends=r.add(t.centersNormalized,t.halfBoxSize),t.startNormalized=r.mul(t.starts,Oe),t.endNormalized=r.mul(t.ends,Oe);let o=r.concat2d([t.startNormalized,t.endNormalized],1);return Object.keys(t).forEach(A=>r.dispose(t[A])),o}async function lA(e,t){var i,x,d,l;if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return[];let o={};o.resized=r.image.resizeBilinear(e,[H0,H0]),o.div=r.div(o.resized,L.tf127),o.normalized=r.sub(o.div,L.tf05);let A=T0==null?void 0:T0.execute(o.normalized);if(Array.isArray(A)){let y=A.sort((c,f)=>c.size-f.size);o.concat384=r.concat([y[0],y[2]],2),o.concat512=r.concat([y[1],y[3]],2),o.concat=r.concat([o.concat512,o.concat384],1),o.batch=r.squeeze(o.concat,0)}else o.batch=r.squeeze(A);r.dispose(A),o.boxes=Hr(o.batch),o.logits=r.slice(o.batch,[0,0],[-1,1]),o.sigmoid=r.sigmoid(o.logits),o.scores=r.squeeze(o.sigmoid),o.nms=await r.image.nonMaxSuppressionAsync(o.boxes,o.scores,((i=t.face.detector)==null?void 0:i.maxDetected)||0,((x=t.face.detector)==null?void 0:x.iouThreshold)||0,((d=t.face.detector)==null?void 0:d.minConfidence)||0);let n=await o.nms.array(),s=[],a=await o.scores.data();for(let y=0;y(((l=t.face.detector)==null?void 0:l.minConfidence)||0)){let f={};f.bbox=r.slice(o.boxes,[n[y],0],[1,-1]),f.slice=r.slice(o.batch,[n[y],sA-1],[1,-1]),f.squeeze=r.squeeze(f.slice),f.landmarks=r.reshape(f.squeeze,[sA,-1]);let h=await f.bbox.data(),m={startPoint:[h[0],h[1]],endPoint:[h[2],h[3]],landmarks:await f.landmarks.array(),confidence:c},v=$o(m,[(e.shape[2]||0)/H0,(e.shape[1]||0)/H0]),b=_e(v,t.face.scale||Br),P=$e(b);s.push(P),Object.keys(f).forEach(p=>r.dispose(f[p]))}}return Object.keys(o).forEach(y=>r.dispose(o[y])),s}var tt={};K0(tt,{connected:()=>y5,kpt:()=>l5});var l5=["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"],y5={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 xA=224,Fr,Vr=5,ot=[8,16,32,32,32];async function cA(){let e=[],t=0;for(;to.x)),y:r.tensor1d(e.map(o=>o.y))}}function W0(e,t=[1,1]){let o=[e.map(i=>i[0]),e.map(i=>i[1])],A=[Math.min(...o[0]),Math.min(...o[1])],n=[Math.max(...o[0]),Math.max(...o[1])],s=[A[0],A[1],n[0]-A[0],n[1]-A[1]],a=[s[0]/t[0],s[1]/t[1],s[2]/t[0],s[3]/t[1]];return{box:s,boxRaw:a}}function dA(e,t=[1,1]){let o=[e.map(d=>d[0]),e.map(d=>d[1])],A=[Math.min(...o[0]),Math.min(...o[1])],n=[Math.max(...o[0]),Math.max(...o[1])],s=[(A[0]+n[0])/2,(A[1]+n[1])/2],a=Math.max(s[0]-A[0],s[1]-A[1],-s[0]+n[0],-s[1]+n[1]),i=[Math.trunc(s[0]-a),Math.trunc(s[1]-a),Math.trunc(2*a),Math.trunc(2*a)],x=[i[0]/t[0],i[1]/t[1],i[2]/t[0],i[3]/t[1]];return{box:i,boxRaw:x}}function At(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 pA={initial:!0},y0={detector:null,landmarks:null},xe={detector:[224,224],landmarks:[256,256]},x5=Number.MAX_SAFE_INTEGER,Xr={landmarks:["ld_3d","activation_segmentation","activation_heatmap","world_3d","output_poseflag"],detector:[]},rt=null,Ne,F0=[[0,0],[0,0],[0,0],[0,0]],fA=0,mA=e=>1-1/(1+Math.exp(e));async function uA(e){if(pA.initial&&(y0.detector=null),!y0.detector&&e.body.detector&&e.body.detector.modelPath){y0.detector=await N(e.body.detector.modelPath);let t=Object.values(y0.detector.modelSignature.inputs);xe.detector[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,xe.detector[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&y0.detector&&g("cached model:",y0.detector.modelUrl);return await cA(),y0.detector}async function hA(e){if(pA.initial&&(y0.landmarks=null),y0.landmarks)e.debug&&g("cached model:",y0.landmarks.modelUrl);else{y0.landmarks=await N(e.body.modelPath);let t=Object.values(y0.landmarks.modelSignature.inputs);xe.landmarks[0]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[1].size):0,xe.landmarks[1]=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return y0.landmarks}async function Dr(e,t){let o={};if(!e.shape||!e.shape[1]||!e.shape[2])return e;let A;if(Ne&&(o.cropped=r.image.cropAndResize(e,[Ne],[0],[e.shape[1],e.shape[2]])),e.shape[1]!==e.shape[2]){let n=[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];F0=[[0,0],n,s,[0,0]],o.pad=r.pad(o.cropped||e,F0),o.resize=r.image.resizeBilinear(o.pad,[t,t]),A=r.div(o.resize,L.tf255)}else e.shape[1]!==t?(o.resize=r.image.resizeBilinear(o.cropped||e,[t,t]),A=r.div(o.resize,L.tf255)):A=r.div(o.cropped||e,L.tf255);return Object.keys(o).forEach(n=>r.dispose(o[n])),A}function qr(e,t){for(let o of e)o.position=[Math.trunc(o.position[0]*(t[0]+F0[2][0]+F0[2][1])/t[0]-F0[2][0]),Math.trunc(o.position[1]*(t[1]+F0[1][0]+F0[1][1])/t[1]-F0[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(Ne)for(let o of e)o.positionRaw=[o.positionRaw[0]+Ne[1],o.positionRaw[1]+Ne[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 Ur(e){let t=e.find(i=>i.part==="leftPalm"),o=e.find(i=>i.part==="leftWrist"),A=e.find(i=>i.part==="leftIndex");t.position[2]=((o.position[2]||0)+(A.position[2]||0))/2;let n=e.find(i=>i.part==="rightPalm"),s=e.find(i=>i.part==="rightWrist"),a=e.find(i=>i.part==="rightIndex");n.position[2]=((s.position[2]||0)+(a.position[2]||0))/2}async function Jr(e,t,o){var h;let A={};[A.ld,A.segmentation,A.heatmap,A.world,A.poseflag]=(h=y0.landmarks)==null?void 0:h.execute(e,Xr.landmarks);let n=(await A.poseflag.data())[0],s=await A.ld.data(),a=await A.world.data();Object.keys(A).forEach(m=>r.dispose(A[m]));let i=[],x=5;for(let m=0;mm.position),y=W0(l,[o[0],o[1]]),c={};for(let[m,v]of Object.entries(y5)){let b=[];for(let P=0;PE.part===v[P]),u=d.find(E=>E.part===v[P+1]);p&&u&&b.push([p.position,u.position])}c[m]=b}return{id:0,score:Math.trunc(100*n)/100,box:y.box,boxRaw:y.boxRaw,keypoints:d,annotations:c}}async function c5(e,t){let o=[e.shape[2]||0,e.shape[1]||0],A=(t.body.skipTime||0)>M()-fA,n=x5<(t.body.skipFrames||0);if(t.skipAllowed&&A&&n&&rt!==null)x5++;else{let s={};s.landmarks=await Dr(e,256),rt=await Jr(s.landmarks,t,o),Object.keys(s).forEach(a=>r.dispose(s[a])),fA=M(),x5=0}return rt?[rt]:[]}var ce=[{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 C0,ee=0,d5=[],gA=0,f5=Number.MAX_SAFE_INTEGER;async function MA(e){if(w.initial&&(C0=null),C0)e.debug&&g("cached model:",C0.modelUrl);else{C0=await N(e.object.modelPath);let t=Object.values(C0.modelSignature.inputs);ee=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}return C0}async function Yr(e,t,o){if(!e)return[];let A={},n=[],s=await e.array();A.squeeze=r.squeeze(e);let a=r.split(A.squeeze,6,1);A.stack=r.stack([a[1],a[0],a[3],a[2]],1),A.boxes=r.squeeze(A.stack),A.scores=r.squeeze(a[4]),A.classes=r.squeeze(a[5]),r.dispose([e,...a]),A.nms=await r.image.nonMaxSuppressionAsync(A.boxes,A.scores,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence||0);let i=await A.nms.data(),x=0;for(let d of Array.from(i)){let l=Math.trunc(100*s[0][d][4])/100,y=s[0][d][5],c=ce[y].label,[f,h]=[s[0][d][0]/ee,s[0][d][1]/ee],m=[f,h,s[0][d][2]/ee-f,s[0][d][3]/ee-h],v=[Math.trunc(m[0]*t[0]),Math.trunc(m[1]*t[1]),Math.trunc(m[2]*t[0]),Math.trunc(m[3]*t[1])];n.push({id:x++,score:l,class:y,label:c,box:v,boxRaw:m})}return Object.keys(A).forEach(d=>r.dispose(A[d])),n}async function m5(e,t){let o=(t.object.skipTime||0)>M()-gA,A=f5<(t.object.skipFrames||0);return t.skipAllowed&&o&&A&&d5.length>0?(f5++,d5):(f5=0,new Promise(async n=>{let s=[e.shape[2]||0,e.shape[1]||0],a=r.image.resizeBilinear(e,[ee,ee]),i=t.object.enabled?C0==null?void 0:C0.execute(a,["tower_0/detections"]):null;gA=M(),r.dispose(a);let x=await Yr(i,s,t);d5=x,n(x)}))}var st={};K0(st,{connected:()=>u5,kpt:()=>p5});var p5=["head","neck","rightShoulder","rightElbow","rightWrist","chest","leftShoulder","leftElbow","leftWrist","bodyCenter","rightHip","rightKnee","rightAnkle","leftHip","leftKnee","leftAnkle"],u5={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var n0,vA=0,a0={id:0,keypoints:[],box:[0,0,0,0],boxRaw:[0,0,0,0],score:0,annotations:{}},h5=Number.MAX_SAFE_INTEGER;async function TA(e){return w.initial&&(n0=null),n0?e.debug&&g("cached model:",n0.modelUrl):n0=await N(e.body.modelPath),n0}async function Kr(e,t){let[o,A]=e.shape,n=r.reshape(e,[A*o]),s=r.max(n,0),a=(await s.data())[0];if(r.dispose([n,s]),a>t){let i=r.argMax(n,0),x=r.mod(i,o),d=(await x.data())[0],l=r.div(i,r.scalar(o,"int32")),y=(await l.data())[0];return r.dispose([x,l]),[d,y,a]}return[0,0,a]}async function b5(e,t){let o=(t.body.skipTime||0)>M()-vA,A=h5<(t.body.skipFrames||0);return t.skipAllowed&&o&&A&&Object.keys(a0.keypoints).length>0?(h5++,[a0]):(h5=0,new Promise(async n=>{var y;let s=r.tidy(()=>{if(!(n0!=null&&n0.inputs[0].shape))return null;let c=r.image.resizeBilinear(e,[n0.inputs[0].shape[2],n0.inputs[0].shape[1]],!1),f=r.mul(c,L.tf2);return r.sub(f,L.tf1)}),a;if(t.body.enabled&&(a=n0==null?void 0:n0.execute(s)),vA=M(),r.dispose(s),a){a0.keypoints.length=0;let c=a.squeeze();r.dispose(a);let f=c.unstack(2);r.dispose(c);for(let h=0;h(((y=t.body)==null?void 0:y.minConfidence)||0)&&a0.keypoints.push({score:Math.round(100*b)/100,part:p5[h],positionRaw:[m/n0.inputs[0].shape[2],v/n0.inputs[0].shape[1]],position:[Math.round(e.shape[2]*m/n0.inputs[0].shape[2]),Math.round(e.shape[1]*v/n0.inputs[0].shape[1])]})}f.forEach(h=>r.dispose(h))}a0.score=a0.keypoints.reduce((c,f)=>f.score>c?f.score:c,0);let i=a0.keypoints.map(c=>c.position[0]),x=a0.keypoints.map(c=>c.position[1]);a0.box=[Math.min(...i),Math.min(...x),Math.max(...i)-Math.min(...i),Math.max(...x)-Math.min(...x)];let d=a0.keypoints.map(c=>c.positionRaw[0]),l=a0.keypoints.map(c=>c.positionRaw[1]);a0.boxRaw=[Math.min(...d),Math.min(...l),Math.max(...d)-Math.min(...d),Math.max(...l)-Math.min(...l)];for(let[c,f]of Object.entries(u5)){let h=[];for(let m=0;mP.part===f[m]),b=a0.keypoints.find(P=>P.part===f[m+1]);v&&b&&v.score>(t.body.minConfidence||0)&&b.score>(t.body.minConfidence||0)&&h.push([v.position,b.position])}a0.annotations[c]=h}n([a0])}))}var Qr=["angry","disgust","fear","happy","sad","surprise","neutral"],p0,at=[],RA=0,kA=0,g5=Number.MAX_SAFE_INTEGER;async function EA(e){var t;return w.initial&&(p0=null),p0?e.debug&&g("cached model:",p0.modelUrl):p0=await N((t=e.face.emotion)==null?void 0:t.modelPath),p0}async function M5(e,t,o,A){var a,i;if(!p0)return[];let n=g5<(((a=t.face.emotion)==null?void 0:a.skipFrames)||0),s=(((i=t.face.emotion)==null?void 0:i.skipTime)||0)>M()-kA;return t.skipAllowed&&s&&n&&RA===A&&at[o]&&at[o].length>0?(g5++,at[o]):(g5=0,new Promise(async x=>{var l,y;let d=[];if((l=t.face.emotion)!=null&&l.enabled){let c={},f=p0!=null&&p0.inputs[0].shape?p0.inputs[0].shape[2]:0;c.resize=r.image.resizeBilinear(e,[f,f],!1),c.channels=r.mul(c.resize,L.rgb),c.grayscale=r.sum(c.channels,3,!0),c.grayscaleSub=r.sub(c.grayscale,L.tf05),c.grayscaleMul=r.mul(c.grayscaleSub,L.tf2),c.emotion=p0==null?void 0:p0.execute(c.grayscaleMul),kA=M();let h=await c.emotion.data();for(let m=0;m(((y=t.face.emotion)==null?void 0:y.minConfidence)||0)&&d.push({score:Math.min(.99,Math.trunc(100*h[m])/100),emotion:Qr[m]});d.sort((m,v)=>v.score-m.score),Object.keys(c).forEach(m=>r.dispose(c[m]))}at[o]=d,RA=A,x(d)}))}var x0,P5=[],jA=0,SA=0,WA=Number.MAX_SAFE_INTEGER;async function CA(e){return w.initial&&(x0=null),x0?e.debug&&g("cached model:",x0.modelUrl):x0=await N(e.face.mobilefacenet.modelPath),x0}async function v5(e,t,o,A){var a,i;if(!x0)return[];let n=WA<(((a=t.face.embedding)==null?void 0:a.skipFrames)||0),s=(((i=t.face.embedding)==null?void 0:i.skipTime)||0)>M()-SA;return t.skipAllowed&&s&&n&&jA===A&&P5[o]?(WA++,P5[o]):new Promise(async x=>{var l;let d=[];if(((l=t.face.embedding)==null?void 0:l.enabled)&&(x0==null?void 0:x0.inputs[0].shape)){let y={};y.crop=r.image.resizeBilinear(e,[x0.inputs[0].shape[2],x0.inputs[0].shape[1]],!1),y.data=x0==null?void 0:x0.execute(y.crop);let c=await y.data.data();d=Array.from(c)}P5[o]=d,jA=A,SA=M(),x(d)})}var I0,V0=0,_r=2.3,T5=b0.leftEyeLower0,w5=b0.rightEyeLower0,de={leftBounds:[T5[0],T5[T5.length-1]],rightBounds:[w5[0],w5[w5.length-1]]},fe={upperCenter:3,lowerCenter:4,index:71,numCoordinates:76};async function GA(e){var t;return w.initial&&(I0=null),I0?e.debug&&g("cached model:",I0.modelUrl):I0=await N((t=e.face.iris)==null?void 0:t.modelPath),V0=I0.inputs[0].shape?I0.inputs[0].shape[2]:0,V0===-1&&(V0=64),I0}function it(e,t,o,A){for(let n=0;n{let t=e[de.leftBounds[0]][2],o=e[de.rightBounds[0]][2];return t-o},OA=(e,t,o,A,n,s=!1)=>{let a=$e(_e(eA([e[o],e[A]]),_r)),i=ye(a),x=r.image.cropAndResize(t,[[a.startPoint[1]/n,a.startPoint[0]/n,a.endPoint[1]/n,a.endPoint[0]/n]],[0],[V0,V0]);if(s&&w.kernels.includes("flipleftright")){let d=r.image.flipLeftRight(x);r.dispose(x),x=d}return{box:a,boxSize:i,crop:x}},NA=(e,t,o,A=!1)=>{let n=[];for(let s=0;s{let A=e[b0[`${o}EyeUpper0`][fe.upperCenter]][2],n=e[b0[`${o}EyeLower0`][fe.lowerCenter]][2],s=(A+n)/2;return t.map((a,i)=>{let x=s;return i===2?x=A:i===4&&(x=n),[a[0],a[1],x]})};async function BA(e,t,o,A){if(!I0)return o.debug&&g("face mesh iris detection requested, but model is not loaded"),e;let{box:n,boxSize:s,crop:a}=OA(e,t,de.leftBounds[0],de.leftBounds[1],A,!0),{box:i,boxSize:x,crop:d}=OA(e,t,de.rightBounds[0],de.rightBounds[1],A,!0),l=r.concat([a,d]);r.dispose(a),r.dispose(d);let y=I0.execute(l);r.dispose(l);let c=await y.data();r.dispose(y);let f=c.slice(0,fe.numCoordinates*3),{rawCoords:h,iris:m}=NA(f,n,s,!0),v=c.slice(fe.numCoordinates*3),{rawCoords:b,iris:P}=NA(v,i,x),p=$r(e);Math.abs(p)<30?(it(e,h,"left",null),it(e,b,"right",null)):p<1?it(e,h,"left",["EyeUpper0","EyeLower0"]):it(e,b,"right",["EyeUpper0","EyeLower0"]);let u=LA(e,m,"left"),E=LA(e,P,"right");return e.concat(u).concat(E)}var w0={boxes:[],skipped:Number.MAX_SAFE_INTEGER,timestamp:0},O0=null,me=0;async function FA(e,t){var i,x,d,l,y,c,f,h,m;let o=(((i=t.face.detector)==null?void 0:i.skipTime)||0)>M()-w0.timestamp,A=w0.skipped<(((x=t.face.detector)==null?void 0:x.skipFrames)||0);!t.skipAllowed||!o||!A||w0.boxes.length===0?(w0.boxes=await lA(e,t),w0.timestamp=M(),w0.skipped=0):w0.skipped++;let n=[],s=[],a=0;for(let v=0;v[H[0]/(e.shape[2]||0),H[1]/(e.shape[1]||0),(H[2]||0)/me]);for(let H of Object.keys(b0))u.annotations[H]=b0[H].map(t0=>u.mesh[t0]);u.score=u.faceScore;let G={...rA(u.mesh,b),confidence:b.confidence,landmarks:b.landmarks};u.box=s5(G,e),u.boxRaw=a5(G,e),s.push(G)}}else{u.box=s5(b,e),u.boxRaw=a5(b,e),u.score=u.boxScore,u.mesh=b.landmarks.map(E=>[(b.startPoint[0]+b.endPoint[0])/2+(b.endPoint[0]+b.startPoint[0])*E[0]/et(),(b.startPoint[1]+b.endPoint[1])/2+(b.endPoint[1]+b.startPoint[1])*E[1]/et()]),u.meshRaw=u.mesh.map(E=>[E[0]/(e.shape[2]||0),E[1]/(e.shape[1]||0),(E[2]||0)/me]);for(let E of Object.keys(Ce))u.annotations[E]=[u.mesh[Ce[E]]]}u.score>(((m=t.face.detector)==null?void 0:m.minConfidence)||1)?n.push(u):r.dispose(u.tensor)}return w0.boxes=s,n}async function VA(e){var t;return w.initial&&(O0=null),O0?e.debug&&g("cached model:",O0.modelUrl):O0=await N((t=e.face.mesh)==null?void 0:t.modelPath),me=O0.inputs[0].shape?O0.inputs[0].shape[2]:0,O0}var ZA=_0,XA=Ie;var c0,lt=[],DA=0,qA=0,k5=Number.MAX_SAFE_INTEGER;async function UA(e){var t;return w.initial&&(c0=null),c0?e.debug&&g("cached model:",c0.modelUrl):c0=await N((t=e.face.description)==null?void 0:t.modelPath),c0}function E5(e){let t=e.image||e.tensor||e;if(!(c0!=null&&c0.inputs[0].shape))return t;let o=r.image.resizeBilinear(t,[c0.inputs[0].shape[2],c0.inputs[0].shape[1]],!1),A=r.mul(o,L.tf255);return r.dispose(o),A}async function z5(e,t,o,A){var a,i,x,d;if(!c0)return{age:0,gender:"unknown",genderScore:0,descriptor:[]};let n=k5<(((a=t.face.description)==null?void 0:a.skipFrames)||0),s=(((i=t.face.description)==null?void 0:i.skipTime)||0)>M()-DA;return t.skipAllowed&&n&&s&&qA===A&&((x=lt[o])==null?void 0:x.age)&&((d=lt[o])==null?void 0:d.age)>0?(k5++,lt[o]):(k5=0,new Promise(async l=>{var c,f;let y={age:0,gender:"unknown",genderScore:0,descriptor:[]};if((c=t.face.description)!=null&&c.enabled){let h=E5(e),m=c0==null?void 0:c0.execute(h);DA=M(),r.dispose(h);let b=await(await m.find(O=>O.shape[1]===1)).data(),P=Math.trunc(200*Math.abs(b[0]-.5))/100;P>(((f=t.face.description)==null?void 0:f.minConfidence)||0)&&(y.gender=b[0]<=.5?"female":"male",y.genderScore=Math.min(.99,P));let p=r.argMax(m.find(O=>O.shape[1]===100),1),u=(await p.data())[0];r.dispose(p);let W=await m.find(O=>O.shape[1]===100).data();y.age=Math.round(W[u-1]>W[u+1]?10*u-100*W[u-1]:10*u+100*W[u+1])/10;let C=m.find(O=>O.shape[1]===1024),S=C?await C.data():[];y.descriptor=Array.from(S),m.forEach(O=>r.dispose(O))}lt[o]=y,qA=A,l(y)}))}function yt(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}function Le(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}function KA(e,t,o){let A=t.shape[1],n=t.shape[2],s=[[e.startPoint[1]/A,e.startPoint[0]/n,e.endPoint[1]/A,e.endPoint[0]/n]];return r.image.cropAndResize(t,s,[0],o)}function QA(e,t){let o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],A=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],n=e.palmLandmarks.map(s=>[s[0]*t[0],s[1]*t[1]]);return{startPoint:o,endPoint:A,palmLandmarks:n,confidence:e.confidence}}function xt(e,t=1.5){let o=Le(e),A=yt(e),n=[t*A[0]/2,t*A[1]/2],s=[o[0]-n[0],o[1]-n[1]],a=[o[0]+n[0],o[1]+n[1]];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function ct(e){let t=Le(e),o=yt(e),n=Math.max(...o)/2,s=[t[0]-n,t[1]-n],a=[t[0]+n,t[1]+n];return{startPoint:s,endPoint:a,palmLandmarks:e.palmLandmarks}}function e2(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function _A(e,t){let o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return e2(o)}var JA=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function Z0(e,t){let o=0;for(let A=0;A[o.x,o.y]),this.anchorsTensor=r.tensor2d(this.anchors),this.inputSize=this.model&&this.model.inputs&&this.model.inputs[0].shape?this.model.inputs[0].shape[2]:0,this.inputSizeTensor=r.tensor1d([this.inputSize,this.inputSize]),this.doubleInputSizeTensor=r.tensor1d([this.inputSize*2,this.inputSize*2])}normalizeBoxes(t){let o={};o.boxOffsets=r.slice(t,[0,0],[-1,2]),o.boxSizes=r.slice(t,[0,2],[-1,2]),o.div=r.div(o.boxOffsets,this.inputSizeTensor),o.boxCenterPoints=r.add(o.div,this.anchorsTensor),o.halfBoxSizes=r.div(o.boxSizes,this.doubleInputSizeTensor),o.sub=r.sub(o.boxCenterPoints,o.halfBoxSizes),o.startPoints=r.mul(o.sub,this.inputSizeTensor),o.add=r.add(o.boxCenterPoints,o.halfBoxSizes),o.endPoints=r.mul(o.add,this.inputSizeTensor);let A=r.concat2d([o.startPoints,o.endPoints],1);return Object.keys(o).forEach(n=>r.dispose(o[n])),A}normalizeLandmarks(t,o){let A={};A.reshape=r.reshape(t,[-1,7,2]),A.div=r.div(A.reshape,this.inputSizeTensor),A.landmarks=r.add(A.div,this.anchors[o]);let n=r.mul(A.landmarks,this.inputSizeTensor);return Object.keys(A).forEach(s=>r.dispose(A[s])),n}async predict(t,o){let A={};A.resize=r.image.resizeBilinear(t,[this.inputSize,this.inputSize]),A.div=r.div(A.resize,L.tf127),A.image=r.sub(A.div,L.tf1),A.batched=this.model.execute(A.image),A.predictions=r.squeeze(A.batched),A.slice=r.slice(A.predictions,[0,0],[-1,1]),A.sigmoid=r.sigmoid(A.slice),A.scores=r.squeeze(A.sigmoid);let n=await A.scores.data();A.boxes=r.slice(A.predictions,[0,1],[-1,4]),A.norm=this.normalizeBoxes(A.boxes),A.nms=await r.image.nonMaxSuppressionAsync(A.norm,A.scores,3*o.hand.maxDetected,o.hand.iouThreshold,o.hand.minConfidence);let s=await A.nms.array(),a=[];for(let i of s){let x={};x.box=r.slice(A.norm,[i,0],[1,-1]),x.slice=r.slice(A.predictions,[i,5],[1,14]),x.norm=this.normalizeLandmarks(x.slice,i),x.palmLandmarks=r.reshape(x.norm,[-1,2]);let d=await x.box.data(),l=d.slice(0,2),y=d.slice(2,4),c=await x.palmLandmarks.array(),f={startPoint:l,endPoint:y,palmLandmarks:c,confidence:n[i]},h=QA(f,[t.shape[2]/this.inputSize,t.shape[1]/this.inputSize]);a.push(h),Object.keys(x).forEach(m=>r.dispose(x[m]))}return Object.keys(A).forEach(i=>r.dispose(A[i])),a}};var n2=5,on=1.65,An=[0,5,9,13,17,1,2],r2=0,s2=2,nn=0,ft=class{constructor(t,o){R(this,"handDetector");R(this,"handPoseModel");R(this,"inputSize");R(this,"storedBoxes");R(this,"skipped");R(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]),A=t.map(a=>a[1]),n=[Math.min(...o),Math.min(...A)],s=[Math.max(...o),Math.max(...A)];return{startPoint:n,endPoint:s}}getBoxForPalmLandmarks(t,o){let A=t.map(s=>W5([...s,1],o)),n=this.calculateLandmarksBoundingBox(A);return xt(ct(n),n2)}getBoxForHandLandmarks(t){let o=this.calculateLandmarksBoundingBox(t),A=xt(ct(o),on);A.palmLandmarks=[];for(let n=0;n[a[0]*(f[0]-this.inputSize/2),a[1]*(f[1]-this.inputSize/2),a[2]*f[2]]),x=S5(A,[0,0]),d=i.map(f=>[...W5(f,x),f[2]]),l=$A(n),y=[...Le(o),1],c=[Z0(y,l[0]),Z0(y,l[1])];return d.map(f=>[Math.trunc(f[0]+c[0]),Math.trunc(f[1]+c[1]),Math.trunc(f[2])])}async estimateHands(t,o){let A=!1,n,s=(o.hand.skipTime||0)>M()-nn,a=this.skipped<(o.hand.skipFrames||0);o.skipAllowed&&s&&a&&(n=await this.handDetector.predict(t,o),this.skipped=0),o.skipAllowed&&this.skipped++,n&&n.length>0&&(n.length!==this.detectedHands&&this.detectedHands!==o.hand.maxDetected||!o.hand.landmarks)&&(this.detectedHands=0,this.storedBoxes=[...n],this.storedBoxes.length>0&&(A=!0));let i=[];for(let x=0;x=o.hand.minConfidence/4){let E=r.reshape(p,[-1,3]),W=await E.array();r.dispose(p),r.dispose(E);let C=this.transformRawCoords(W,m,l,h),S=this.getBoxForHandLandmarks(C);this.storedBoxes[x]={...S,confidence:u};let O={landmarks:C,confidence:u,boxConfidence:d.confidence,fingerConfidence:u,box:{topLeft:S.startPoint,bottomRight:S.endPoint}};i.push(O)}else this.storedBoxes[x]=null;r.dispose(p)}else{let l=xt(ct(d),on),y={confidence:d.confidence,boxConfidence:d.confidence,fingerConfidence:0,box:{topLeft:l.startPoint,bottomRight:l.endPoint},landmarks:[]};i.push(y)}}return this.storedBoxes=this.storedBoxes.filter(x=>x!==null),this.detectedHands=i.length,i.length>o.hand.maxDetected&&(i.length=o.hand.maxDetected),i}};var i0={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=>i0.nameMapping[e],getPoints:e=>i0.pointsMapping[e]},D0={none:0,half:1,full:2,nameMapping:{0:"none",1:"half",2:"full"},getName:e=>D0.nameMapping[e]},U={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=>U.nameMapping[e]},X0=class{constructor(t){R(this,"name");R(this,"curls");R(this,"directions");R(this,"weights");R(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,A){typeof this.curls[t]=="undefined"&&(this.curls[t]=[]),this.curls[t].push([o,A])}direction(t,o,A){this.directions[t]||(this.directions[t]=[]),this.directions[t].push([o,A])}weight(t,o){this.weights[t]=o;let A=this.weights.reduce((n,s)=>n+s,0);this.weightsRelative=this.weights.map(n=>n*5/A)}matchAgainst(t,o){let A=0;for(let n in t){let s=t[n],a=this.curls[n];if(typeof a=="undefined"){A+=this.weightsRelative[n];continue}for(let[i,x]of a)if(s===i){A+=x*this.weightsRelative[n];break}}for(let n in o){let s=o[n],a=this.directions[n];if(typeof a=="undefined"){A+=this.weightsRelative[n];continue}for(let[i,x]of a)if(s===i){A+=x*this.weightsRelative[n];break}}return A/10}};var{thumb:g0,index:N0,middle:L0,ring:te,pinky:oe}=i0,{none:M0,half:i2,full:P0}=D0,{verticalUp:pe,verticalDown:pa,horizontalLeft:C5,horizontalRight:l2,diagonalUpRight:y2,diagonalUpLeft:ue,diagonalDownRight:ua,diagonalDownLeft:ha}=U,q0=new X0("thumbs up");q0.curl(g0,M0,1);q0.direction(g0,pe,1);q0.direction(g0,ue,.25);q0.direction(g0,y2,.25);for(let e of[i0.index,i0.middle,i0.ring,i0.pinky])q0.curl(e,P0,1),q0.direction(e,C5,1),q0.direction(e,l2,1);var K=new X0("victory");K.curl(g0,i2,.5);K.curl(g0,M0,.5);K.direction(g0,pe,1);K.direction(g0,ue,1);K.curl(N0,M0,1);K.direction(N0,pe,.75);K.direction(N0,ue,1);K.curl(L0,M0,1);K.direction(L0,pe,1);K.direction(L0,ue,.75);K.curl(te,P0,1);K.direction(te,pe,.2);K.direction(te,ue,1);K.direction(te,C5,.2);K.curl(oe,P0,1);K.direction(oe,pe,.2);K.direction(oe,ue,1);K.direction(oe,C5,.2);K.weight(N0,2);K.weight(L0,2);var U0=new X0("point");U0.curl(g0,P0,1);U0.curl(N0,M0,.5);U0.curl(L0,P0,.5);U0.curl(te,P0,.5);U0.curl(oe,P0,.5);U0.weight(N0,2);U0.weight(L0,2);var J0=new X0("middle finger");J0.curl(g0,M0,1);J0.curl(N0,P0,.5);J0.curl(L0,P0,.5);J0.curl(te,P0,.5);J0.curl(oe,P0,.5);J0.weight(N0,2);J0.weight(L0,2);var he=new X0("open palm");he.curl(g0,M0,.75);he.curl(N0,M0,.75);he.curl(L0,M0,.75);he.curl(te,M0,.75);he.curl(oe,M0,.75);var rn=[q0,K,U0,J0,he];var x2=.7,Ae={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 sn(e,t,o,A){let n=(t-A)/(e-o),s=Math.atan(n)*180/Math.PI;return s<=0?s=-s:s>0&&(s=180-s),s}function ln(e,t){if(!e||!t)return[0,0];let o=sn(e[0],e[1],t[0],t[1]);if(e.length===2)return o;let A=sn(e[1],e[2],t[1],t[2]);return[o,A]}function an(e,t=1){let o=0,A=0,n=0;return e>=75&&e<=105?o=1*t:e>=25&&e<=155?A=1*t:n=1*t,[o,A,n]}function c2(e,t,o){let A=e[0]-t[0],n=e[0]-o[0],s=t[0]-o[0],a=e[1]-t[1],i=e[1]-o[1],x=t[1]-o[1],d=e[2]-t[2],l=e[2]-o[2],y=t[2]-o[2],c=Math.sqrt(A*A+a*a+d*d),f=Math.sqrt(n*n+i*i+l*l),h=Math.sqrt(s*s+x*x+y*y),m=(h*h+c*c-f*f)/(2*h*c);m>1?m=1:m<-1&&(m=-1);let v=Math.acos(m);v=57.2958*v%180;let b;return v>Ae.NO_CURL_START_LIMIT?b=D0.none:v>Ae.HALF_CURL_START_LIMIT?b=D0.half:b=D0.full,b}function yn(e,t,o,A){let n;return A===Math.abs(e)?e>0?n=U.horizontalLeft:n=U.horizontalRight:A===Math.abs(t)?t>0?n=U.horizontalLeft:n=U.horizontalRight:o>0?n=U.horizontalLeft:n=U.horizontalRight,n}function xn(e,t,o,A){let n;return A===Math.abs(e)?e<0?n=U.verticalDown:n=U.verticalUp:A===Math.abs(t)?t<0?n=U.verticalDown:n=U.verticalUp:o<0?n=U.verticalDown:n=U.verticalUp,n}function d2(e,t,o,A,n,s,a,i){let x,d=xn(e,t,o,A),l=yn(n,s,a,i);return d===U.verticalUp?l===U.horizontalLeft?x=U.diagonalUpLeft:x=U.diagonalUpRight:l===U.horizontalLeft?x=U.diagonalDownLeft:x=U.diagonalDownRight,x}function f2(e,t,o,A){let n=e[0]-t[0],s=e[0]-o[0],a=t[0]-o[0],i=e[1]-t[1],x=e[1]-o[1],d=t[1]-o[1],l=Math.max(Math.abs(n),Math.abs(s),Math.abs(a)),y=Math.max(Math.abs(i),Math.abs(x),Math.abs(d)),c=0,f=0,h=0,m=y/(l+1e-5);m>1.5?c+=Ae.DISTANCE_VOTE_POWER:m>.66?f+=Ae.DISTANCE_VOTE_POWER:h+=Ae.DISTANCE_VOTE_POWER;let v=Math.sqrt(n*n+i*i),b=Math.sqrt(s*s+x*x),P=Math.sqrt(a*a+d*d),p=Math.max(v,b,P),u=e[0],E=e[1],W=o[0],C=o[1];p===v?(W=o[0],C=o[1]):p===P&&(u=t[0],E=t[1]);let V=ln([u,E],[W,C]),G=an(V,Ae.TOTAL_ANGLE_VOTE_POWER);c+=G[0],f+=G[1],h+=G[2];for(let t0 of A){let z=an(t0,Ae.SINGLE_ANGLE_VOTE_POWER);c+=z[0],f+=z[1],h+=z[2]}let H;return c===Math.max(c,f,h)?H=xn(x,i,d,y):h===Math.max(f,h)?H=yn(s,n,a,l):H=d2(x,i,d,y,s,n,a,l),H}function cn(e){let t=[],o=[],A=[],n=[];if(!e)return{curls:A,directions:n};for(let s of i0.all){let a=i0.getPoints(s),i=[],x=[];for(let d of a){let l=e[d[0]],y=e[d[1]],c=ln(l,y),f=c[0],h=c[1];i.push(f),x.push(h)}t.push(i),o.push(x)}for(let s of i0.all){let a=s===i0.thumb?1:0,i=i0.getPoints(s),x=e[i[a][0]],d=e[i[a+1][1]],l=e[i[3][1]],y=c2(x,d,l),c=f2(x,d,l,t[s].slice(a));A[s]=y,n[s]=c}return{curls:A,directions:n}}function mt(e){if(!e||e.length===0)return null;let t=cn(e),o={};for(let A of i0.all)o[i0.getName(A)]={curl:D0.getName(t.curls[A]),direction:U.getName(t.directions[A])};return o}function dn(e){let t=[];if(!e||e.length===0)return t;let o=cn(e);for(let A of rn){let n=A.matchAgainst(o.curls,o.directions);n>=x2&&t.push({name:A.name,confidence:n})}return t}var fn={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]},be,ge,mn;async function O5(e,t){let o=await mn.estimateHands(e,t);if(!o)return[];let A=[];for(let n=0;no[n].landmarks[y]);let a=o[n].landmarks,i=[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,0,0],x=[0,0,0,0];if(a&&a.length>0){for(let l of a)l[0]i[2]&&(i[2]=l[0]),l[1]>i[3]&&(i[3]=l[1]);i[2]-=i[0],i[3]-=i[1],x=[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[n].box?[Math.trunc(Math.max(0,o[n].box.topLeft[0])),Math.trunc(Math.max(0,o[n].box.topLeft[1])),Math.trunc(Math.min(e.shape[2]||0,o[n].box.bottomRight[0])-Math.max(0,o[n].box.topLeft[0])),Math.trunc(Math.min(e.shape[1]||0,o[n].box.bottomRight[1])-Math.max(0,o[n].box.topLeft[1]))]:[0,0,0,0],x=[o[n].box.topLeft[0]/(e.shape[2]||0),o[n].box.topLeft[1]/(e.shape[1]||0),(o[n].box.bottomRight[0]-o[n].box.topLeft[0])/(e.shape[2]||0),(o[n].box.bottomRight[1]-o[n].box.topLeft[1])/(e.shape[1]||0)];let d=mt(a);A.push({id:n,score:Math.round(100*o[n].confidence)/100,boxScore:Math.round(100*o[n].boxConfidence)/100,fingerScore:Math.round(100*o[n].fingerConfidence)/100,label:"hand",box:i,boxRaw:x,keypoints:a,annotations:s,landmarks:d})}return A}async function N5(e){var o,A;w.initial&&(be=null,ge=null),!be||!ge?[be,ge]=await Promise.all([e.hand.enabled?N((o=e.hand.detector)==null?void 0:o.modelPath):null,e.hand.landmarks?N((A=e.hand.skeleton)==null?void 0:A.modelPath):null]):(e.debug&&g("cached model:",be.modelUrl),e.debug&&g("cached model:",ge.modelUrl));let t=new dt(be);return mn=new ft(t,ge),[be,ge]}var $=[null,null],m2=["StatefulPartitionedCall/Postprocessor/Slice","StatefulPartitionedCall/Postprocessor/ExpandDims_1"],Y0=[[0,0],[0,0]],p2=["hand","fist","pinch","point","face","tip","pinchtip"],un=4,hn=1.6,u2=512,h2=1.4,pt=Number.MAX_SAFE_INTEGER,L5=0,G0=[0,0],J={boxes:[],hands:[]},bn={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 gn(e){var t;if(w.initial&&($[0]=null),$[0])e.debug&&g("cached model:",$[0].modelUrl);else{ut(["tensorlistreserve","enter","tensorlistfromtensor","merge","loopcond","switch","exit","tensorliststack","nextiteration","tensorlistsetitem","tensorlistgetitem","reciprocal","shape","split","where"],e),$[0]=await N((t=e.hand.detector)==null?void 0:t.modelPath);let o=Object.values($[0].modelSignature.inputs);Y0[0][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Y0[0][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return $[0]}async function Mn(e){var t;if(w.initial&&($[1]=null),$[1])e.debug&&g("cached model:",$[1].modelUrl);else{$[1]=await N((t=e.hand.skeleton)==null?void 0:t.modelPath);let o=Object.values($[1].modelSignature.inputs);Y0[1][0]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[1].size):0,Y0[1][1]=Array.isArray(o)?parseInt(o[0].tensorShape.dim[2].size):0}return $[1]}async function b2(e,t){let o=[];if(!e||!$[0])return o;let A={},n=(e.shape[2]||1)/(e.shape[1]||1),s=Math.min(Math.round((e.shape[1]||0)/8)*8,u2),a=Math.round(s*n/8)*8;A.resize=r.image.resizeBilinear(e,[s,a]),A.cast=r.cast(A.resize,"int32"),[A.rawScores,A.rawBoxes]=await $[0].executeAsync(A.cast,m2),A.boxes=r.squeeze(A.rawBoxes,[0,2]),A.scores=r.squeeze(A.rawScores,[0]);let i=r.unstack(A.scores,1);r.dispose(i[un]),i.splice(un,1),A.filtered=r.stack(i,1),r.dispose(i),A.max=r.max(A.filtered,1),A.argmax=r.argMax(A.filtered,1);let x=0;A.nms=await r.image.nonMaxSuppressionAsync(A.boxes,A.max,(t.hand.maxDetected||0)+1,t.hand.iouThreshold||0,t.hand.minConfidence||1);let d=await A.nms.data(),l=await A.max.data(),y=await A.argmax.data();for(let c of Array.from(d)){let f=r.slice(A.boxes,c,1),h=await f.data();r.dispose(f);let m=[h[1],h[0],h[3]-h[1],h[2]-h[0]],v=At(m,h2),b=[Math.trunc(m[0]*G0[0]),Math.trunc(m[1]*G0[1]),Math.trunc(m[2]*G0[0]),Math.trunc(m[3]*G0[1])],P=l[c],p=p2[y[c]],u={id:x++,score:P,box:b,boxRaw:v,label:p};o.push(u)}return Object.keys(A).forEach(c=>r.dispose(A[c])),o.sort((c,f)=>f.score-c.score),o.length>(t.hand.maxDetected||1)&&(o.length=t.hand.maxDetected||1),o}async function G5(e,t,o){let A={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&&$[1]&&o.hand.landmarks&&t.score>(o.hand.minConfidence||0)){let n={},s=[t.boxRaw[1],t.boxRaw[0],t.boxRaw[3]+t.boxRaw[1],t.boxRaw[2]+t.boxRaw[0]];n.crop=r.image.cropAndResize(e,[s],[0],[Y0[1][0],Y0[1][1]],"bilinear"),n.div=r.div(n.crop,L.tf255),[n.score,n.keypoints]=$[1].execute(n.div,["Identity_1","Identity"]);let a=(await n.score.data())[0],i=(100-Math.trunc(100/(1+Math.exp(a))))/100;if(i>=(o.hand.minConfidence||0)){A.fingerScore=i,n.reshaped=r.reshape(n.keypoints,[-1,3]);let l=(await n.reshaped.array()).map(y=>[y[0]/Y0[1][1],y[1]/Y0[1][0],y[2]||0]).map(y=>[y[0]*t.boxRaw[2],y[1]*t.boxRaw[3],y[2]||0]);A.keypoints=l.map(y=>[G0[0]*(y[0]+t.boxRaw[0]),G0[1]*(y[1]+t.boxRaw[1]),y[2]||0]),A.landmarks=mt(A.keypoints);for(let y of Object.keys(bn))A.annotations[y]=bn[y].map(c=>A.landmarks&&A.keypoints[c]?A.keypoints[c]:null)}Object.keys(n).forEach(x=>r.dispose(n[x]))}return A}async function B5(e,t){var n,s;if(!$[0]||!$[1]||!((n=$[0])!=null&&n.inputs[0].shape)||!((s=$[1])!=null&&s.inputs[0].shape))return[];G0=[e.shape[2]||0,e.shape[1]||0],pt++;let o=(t.hand.skipTime||0)>M()-L5,A=pt<(t.hand.skipFrames||0);return t.skipAllowed&&o&&A?J.hands:new Promise(async a=>{let i=3*(t.hand.skipTime||0)>M()-L5,x=pt<3*(t.hand.skipFrames||0);t.skipAllowed&&J.hands.length===t.hand.maxDetected?J.hands=await Promise.all(J.boxes.map(l=>G5(e,l,t))):t.skipAllowed&&i&&x&&J.hands.length>0?J.hands=await Promise.all(J.boxes.map(l=>G5(e,l,t))):(J.boxes=await b2(e,t),L5=M(),J.hands=await Promise.all(J.boxes.map(l=>G5(e,l,t))),pt=0);let d=[...J.boxes];if(J.boxes.length=0,t.cacheSensitivity>0)for(let l=0;l.05&&y.box[3]/(e.shape[1]||1)>.05&&J.hands[l].fingerScore&&J.hands[l].fingerScore>(t.hand.minConfidence||0)){let c=At(y.box,hn),f=At(y.boxRaw,hn);J.boxes.push({...d[l],box:c,boxRaw:f})}}for(let l=0;lM()-Tn,s=H5<(((i=t.face.liveness)==null?void 0:i.skipFrames)||0);return t.skipAllowed&&n&&s&&vn===A&&ht[o]?(H5++,ht[o]):(H5=0,new Promise(async x=>{let d=r.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),l=r0==null?void 0:r0.execute(d),y=(await l.data())[0];ht[o]=Math.round(100*y)/100,vn=A,Tn=M(),r.dispose([d,l]),x(ht[o])}))}var Ge={};K0(Ge,{connected:()=>gt,horizontal:()=>V5,kpt:()=>bt,relative:()=>X5,vertical:()=>Z5});var bt=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],V5=[["leftEye","rightEye"],["leftEar","rightEar"],["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"]],Z5=[["leftKnee","leftShoulder"],["rightKnee","rightShoulder"],["leftAnkle","leftKnee"],["rightAnkle","rightKnee"]],X5=[[["leftHip","rightHip"],["leftShoulder","rightShoulder"]],[["leftElbow","rightElbow"],["leftShoulder","rightShoulder"]]],gt={leftLeg:["leftHip","leftKnee","leftAnkle"],rightLeg:["rightHip","rightKnee","rightAnkle"],torso:["leftShoulder","rightShoulder","rightHip","leftHip","leftShoulder"],leftArm:["leftShoulder","leftElbow","leftWrist"],rightArm:["rightShoulder","rightElbow","rightWrist"],head:[]};var kn=.005,d0={keypoints:[],padding:[[0,0],[0,0],[0,0],[0,0]]};function D5(e){for(let t of V5){let o=e.keypoints.findIndex(n=>n.part===t[0]),A=e.keypoints.findIndex(n=>n.part===t[1]);if(e.keypoints[o]&&e.keypoints[A]&&e.keypoints[o].position[0]n&&n.part===t[0]),A=e.keypoints.findIndex(n=>n&&n.part===t[1]);e.keypoints[o]&&e.keypoints[A]&&e.keypoints[o].position[1]d&&d.part===t[0]),n=e.keypoints.findIndex(d=>d&&d.part===t[1]),s=e.keypoints.findIndex(d=>d&&d.part===o[0]),a=e.keypoints.findIndex(d=>d&&d.part===o[1]);if(!e.keypoints[s]||!e.keypoints[a])continue;let i=e.keypoints[A]?[Math.abs(e.keypoints[s].position[0]-e.keypoints[A].position[0]),Math.abs(e.keypoints[a].position[0]-e.keypoints[A].position[0])]:[0,0],x=e.keypoints[n]?[Math.abs(e.keypoints[a].position[0]-e.keypoints[n].position[0]),Math.abs(e.keypoints[s].position[0]-e.keypoints[n].position[0])]:[0,0];if(i[0]>i[1]||x[0]>x[1]){let d=e.keypoints[A];e.keypoints[A]=e.keypoints[n],e.keypoints[n]=d}}}function En(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=r.pad(e,d0.padding),o.resize=r.image.resizeBilinear(o.pad,[t,t]);let A=r.cast(o.resize,"int32");return Object.keys(o).forEach(n=>r.dispose(o[n])),A}function jn(e,t){e.keypoints=e.keypoints.filter(A=>A&&A.position);for(let A of e.keypoints)A.position=[A.position[0]*(t[0]+d0.padding[2][0]+d0.padding[2][1])/t[0]-d0.padding[2][0],A.position[1]*(t[1]+d0.padding[1][0]+d0.padding[1][1])/t[1]-d0.padding[1][0]],A.positionRaw=[A.position[0]/t[0],A.position[1]/t[1]];let o=W0(e.keypoints.map(A=>A.position),t);return e.box=o.box,e.boxRaw=o.boxRaw,e}var f0,Mt=0,q5=Number.MAX_SAFE_INTEGER,ne={boxes:[],bodies:[],last:0};async function Sn(e){return w.initial&&(f0=null),f0?e.debug&&g("cached model:",f0.modelUrl):(ut(["size"],e),f0=await N(e.body.modelPath)),Mt=f0.inputs[0].shape?f0.inputs[0].shape[2]:0,Mt<64&&(Mt=256),f0}async function M2(e,t,o){let A=e[0][0],n=[],s=0;for(let l=0;lt.body.minConfidence){let y=[A[l][1],A[l][0]];n.push({score:Math.round(100*s)/100,part:bt[l],positionRaw:y,position:[Math.round((o.shape[2]||0)*y[0]),Math.round((o.shape[1]||0)*y[1])]})}s=n.reduce((l,y)=>y.score>l?y.score:l,0);let a=[],i=W0(n.map(l=>l.position),[o.shape[2],o.shape[1]]),x={};for(let[l,y]of Object.entries(gt)){let c=[];for(let f=0;fv.part===y[f]),m=n.find(v=>v.part===y[f+1]);h&&m&&h.score>(t.body.minConfidence||0)&&m.score>(t.body.minConfidence||0)&&c.push([h.position,m.position])}x[l]=c}let d={id:0,score:s,box:i.box,boxRaw:i.boxRaw,keypoints:n,annotations:x};return D5(d),a.push(d),a}async function P2(e,t,o){let A=[];for(let n=0;nt.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:bt[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 x=W0(i.map(y=>y.position),[o.shape[2],o.shape[1]]),d={};for(let[y,c]of Object.entries(gt)){let f=[];for(let h=0;hb.part===c[h]),v=i.find(b=>b.part===c[h+1]);m&&v&&m.score>(t.body.minConfidence||0)&&v.score>(t.body.minConfidence||0)&&f.push([m.position,v.position])}d[y]=f}let l={id:n,score:a,box:x.box,boxRaw:x.boxRaw,keypoints:[...i],annotations:d};D5(l),A.push(l)}}return A.sort((n,s)=>s.score-n.score),A.length>t.body.maxDetected&&(A.length=t.body.maxDetected),A}async function U5(e,t){if(!f0||!(f0!=null&&f0.inputs[0].shape))return[];t.skipAllowed||(ne.boxes.length=0),q5++;let o=(t.body.skipTime||0)>M()-ne.last,A=q5<(t.body.skipFrames||0);return t.skipAllowed&&o&&A?ne.bodies:new Promise(async n=>{let s={};q5=0,s.input=zn(e,Mt),s.res=f0==null?void 0:f0.execute(s.input),ne.last=M();let a=await s.res.array();ne.bodies=s.res.shape[2]===17?await M2(a,t,e):await P2(a,t,e);for(let i of ne.bodies)jn(i,[e.shape[2]||1,e.shape[1]||1]),En(i.keypoints);Object.keys(s).forEach(i=>r.dispose(s[i])),n(ne.bodies)})}var Me,Pt=[],Cn=0,J5=Number.MAX_SAFE_INTEGER,Tt=0,vt=2.5;async function In(e){if(!Me||w.initial){Me=await N(e.object.modelPath);let t=Object.values(Me.modelSignature.inputs);Tt=Array.isArray(t)?parseInt(t[0].tensorShape.dim[2].size):0}else e.debug&&g("cached model:",Me.modelUrl);return Me}async function v2(e,t,o){let A=0,n=[];for(let x of[1,2,4])r.tidy(async()=>{let d=x*13,l=r.squeeze(e.find(m=>m.shape[1]===d**2&&(m.shape[2]||0)===ce.length)),y=r.squeeze(e.find(m=>m.shape[1]===d**2&&(m.shape[2]||0)(o.object.minConfidence||0)&&v!==61){let P=(.5+Math.trunc(m%d))/d,p=(.5+Math.trunc(m/d))/d,u=f[m].map(H=>H*(d/x/Tt)),[E,W]=[P-vt/x*u[0],p-vt/x*u[1]],[C,S]=[P+vt/x*u[2]-E,p+vt/x*u[3]-W],O=[E,W,C,S];O=O.map(H=>Math.max(0,Math.min(H,1)));let V=[O[0]*t[0],O[1]*t[1],O[2]*t[0],O[3]*t[1]],G={id:A++,score:Math.round(100*b)/100,class:v+1,label:ce[v].label,box:V.map(H=>Math.trunc(H)),boxRaw:O};n.push(G)}}});e.forEach(x=>r.dispose(x));let s=n.map(x=>[x.boxRaw[1],x.boxRaw[0],x.boxRaw[3],x.boxRaw[2]]),a=n.map(x=>x.score),i=[];if(s&&s.length>0){let x=await r.image.nonMaxSuppressionAsync(s,a,o.object.maxDetected,o.object.iouThreshold,o.object.minConfidence);i=await x.data(),r.dispose(x)}return n=n.filter((x,d)=>i.includes(d)).sort((x,d)=>d.score-x.score),n}async function Y5(e,t){let o=(t.object.skipTime||0)>M()-Cn,A=J5<(t.object.skipFrames||0);return t.skipAllowed&&o&&A&&Pt.length>0?(J5++,Pt):(J5=0,!w.kernels.includes("mod")||!w.kernels.includes("sparsetodense")?Pt:new Promise(async n=>{let s=[e.shape[2]||0,e.shape[1]||0],a=r.image.resizeBilinear(e,[Tt,Tt],!1),i=r.div(a,L.tf255),x=i.transpose([0,3,1,2]);r.dispose(i),r.dispose(a);let d;t.object.enabled&&(d=Me.execute(x)),Cn=M(),r.dispose(x);let l=await v2(d,s,t);Pt=l,n(l)}))}var He=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],T2=He.length,Be=He.reduce((e,t,o)=>(e[t]=o,e),{}),w2=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]],Va=w2.map(([e,t])=>[Be[e],Be[t]]),Nn=[["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 Ln(e){let t=e.reduce(({maxX:o,maxY:A,minX:n,minY:s},{position:{x:a,y:i}})=>({maxX:Math.max(o,a),maxY:Math.max(A,i),minX:Math.min(n,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 Gn(e,[t,o],[A,n]){let s=t/A,a=o/n,i=(d,l)=>({id:l,score:d.score,boxRaw:[d.box[0]/n,d.box[1]/A,d.box[2]/n,d.box[3]/A],box:[Math.trunc(d.box[0]*a),Math.trunc(d.box[1]*s),Math.trunc(d.box[2]*a),Math.trunc(d.box[3]*s)],keypoints:d.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/A,f.y/A]})),annotations:{}});return e.map((d,l)=>i(d,l))}var wt=class{constructor(t,o){R(this,"priorityQueue");R(this,"numberOfElements");R(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 Bn(e,t,o,A){let n=o-e,s=A-t;return n*n+s*s}function $5(e,t){return{x:e.x+t.x,y:e.y+t.y}}var v0,k2=["MobilenetV1/offset_2/BiasAdd","MobilenetV1/heatmap_2/BiasAdd","MobilenetV1/displacement_fwd_2/BiasAdd","MobilenetV1/displacement_bwd_2/BiasAdd"],Rt=1,Pe=16,E2=50**2;function Hn(e,t,o,A,n,s,a=2){let i=b=>({y:s.get(b.y,b.x,e),x:s.get(b.y,b.x,s.shape[2]/2+e)}),x=(b,P,p)=>({y:_5(Math.round(b.y/Pe),0,P-1),x:_5(Math.round(b.x/Pe),0,p-1)}),[d,l]=A.shape,y=x(t.position,d,l),c=i(y),h=$5(t.position,c);for(let b=0;b[Be[c],Be[f]]),a=s.map(([,c])=>c),i=s.map(([c])=>c),x=t.shape[2],d=a.length,l=new Array(x),y=Q5(e.part,Pe,o);l[e.part.id]={score:e.score,part:He[e.part.id],position:y};for(let c=d-1;c>=0;--c){let f=a[c],h=i[c];l[f]&&!l[h]&&(l[h]=Hn(c,l[f],h,t,o,n))}for(let c=0;ct){i=!1;break}if(!i)break}return i}function S2(e,t){let[o,A,n]=t.shape,s=new wt(o*A*n,({score:a})=>a);for(let a=0;a{var a;let s=(a=n[A])==null?void 0:a.position;return s?Bn(o,t,s.y,s.x)<=E2:!1})}function W2(e,t){return t.reduce((A,{position:n,score:s},a)=>(Fn(e,n,a)||(A+=s),A),0)/t.length}function C2(e,t,o,A,n,s){let a=[],i=S2(s,t);for(;a.lengthf.score>s);let y=W2(a,l),c=Ln(l);y>s&&a.push({keypoints:l,box:c,score:Math.round(100*y)/100})}return a}async function eo(e,t){let o=r.tidy(()=>{if(!v0.inputs[0].shape)return[];let a=r.image.resizeBilinear(e,[v0.inputs[0].shape[2],v0.inputs[0].shape[1]]),i=r.sub(r.div(r.cast(a,"float32"),127.5),1),d=v0.execute(i,k2).map(l=>r.squeeze(l,[0]));return d[1]=r.sigmoid(d[1]),d}),A=await Promise.all(o.map(a=>a.buffer()));for(let a of o)r.dispose(a);let n=await C2(A[0],A[1],A[2],A[3],t.body.maxDetected,t.body.minConfidence);return v0.inputs[0].shape?Gn(n,[e.shape[1],e.shape[2]],[v0.inputs[0].shape[2],v0.inputs[0].shape[1]]):[]}async function Vn(e){return!v0||w.initial?v0=await N(e.body.modelPath):e.debug&&g("cached model:",v0.modelUrl),v0}var R0,to=!1;async function oo(e){return!R0||w.initial?R0=await N(e.segmentation.modelPath):e.debug&&g("cached model:",R0.modelUrl),R0}async function Xn(e,t,o){var m,v;if(to)return{data:[],canvas:null,alpha:null};to=!0,R0||await oo(o);let A=await le(e,o),n=((m=A.tensor)==null?void 0:m.shape[2])||0,s=((v=A.tensor)==null?void 0:v.shape[1])||0;if(!A.tensor)return{data:[],canvas:null,alpha:null};let a={};a.resize=r.image.resizeBilinear(A.tensor,[R0.inputs[0].shape?R0.inputs[0].shape[1]:0,R0.inputs[0].shape?R0.inputs[0].shape[2]:0],!1),r.dispose(A.tensor),a.norm=r.div(a.resize,L.tf255),a.res=R0.execute(a.norm),a.squeeze=r.squeeze(a.res,0),a.squeeze.shape[2]===2?(a.softmax=r.softmax(a.squeeze),[a.bg,a.fg]=r.unstack(a.softmax,2),a.expand=r.expandDims(a.fg,2),a.pad=r.expandDims(a.expand,0),a.crop=r.image.cropAndResize(a.pad,[[0,0,.5,.5]],[0],[n,s]),a.data=r.squeeze(a.crop,0)):a.data=r.image.resizeBilinear(a.squeeze,[s,n]);let i=Array.from(await a.data.data());if(w.node&&!w.Canvas&&typeof ImageData=="undefined")return o.debug&&g("canvas support missing"),Object.keys(a).forEach(b=>r.dispose(a[b])),{data:i,canvas:null,alpha:null};let x=s0(n,s);r.browser&&await r.browser.toPixels(a.data,x);let d=x.getContext("2d");o.segmentation.blur&&o.segmentation.blur>0&&(d.filter=`blur(${o.segmentation.blur}px)`);let l=d.getImageData(0,0,n,s),y=s0(n,s),c=y.getContext("2d");A.canvas&&c.drawImage(A.canvas,0,0),c.globalCompositeOperation="darken",o.segmentation.blur&&o.segmentation.blur>0&&(c.filter=`blur(${o.segmentation.blur}px)`),c.drawImage(x,0,0),c.globalCompositeOperation="source-over",c.filter="none";let f=c.getImageData(0,0,n,s);for(let b=0;br.dispose(a[b])),to=!1,{data:i,canvas:y,alpha:x}}var Fe=class{constructor(){R(this,"ssrnetage",null);R(this,"gear",null);R(this,"blazeposedetect",null);R(this,"blazepose",null);R(this,"centernet",null);R(this,"efficientpose",null);R(this,"mobilefacenet",null);R(this,"emotion",null);R(this,"facedetect",null);R(this,"faceiris",null);R(this,"facemesh",null);R(this,"faceres",null);R(this,"ssrnetgender",null);R(this,"handpose",null);R(this,"handskeleton",null);R(this,"handtrack",null);R(this,"liveness",null);R(this,"movenet",null);R(this,"nanodet",null);R(this,"posenet",null);R(this,"segmentation",null);R(this,"antispoof",null)}};function kt(e){for(let t of Object.keys(e.models))e.models[t]=null}async function Ao(e){var t,o,A,n,s,a,i,x,d,l,y,c,f,h,m,v,b,P,p,u,E,W,C,S,O,V,G,H,t0,z;w.initial&&kt(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 N5(e.config)),!e.models.handskeleton&&e.config.hand.landmarks&&((n=(A=e.config.hand.detector)==null?void 0:A.modelPath)==null?void 0:n.includes("handdetect"))&&([e.models.handpose,e.models.handskeleton]=await N5(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=hA(e.config)),e.config.body.enabled&&!e.models.blazeposedetect&&e.config.body.detector&&e.config.body.detector.modelPath&&(e.models.blazeposedetect=uA(e.config)),e.config.body.enabled&&!e.models.efficientpose&&((x=(i=e.config.body)==null?void 0:i.modelPath)==null?void 0:x.includes("efficientpose"))&&(e.models.efficientpose=TA(e.config)),e.config.body.enabled&&!e.models.movenet&&((l=(d=e.config.body)==null?void 0:d.modelPath)==null?void 0:l.includes("movenet"))&&(e.models.movenet=Sn(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=Vn(e.config)),e.config.face.enabled&&!e.models.facedetect&&(e.models.facedetect=iA(e.config)),e.config.face.enabled&&((f=e.config.face.antispoof)==null?void 0:f.enabled)&&!e.models.antispoof&&(e.models.antispoof=Yo(e.config)),e.config.face.enabled&&((h=e.config.face.liveness)==null?void 0:h.enabled)&&!e.models.liveness&&(e.models.liveness=wn(e.config)),e.config.face.enabled&&((m=e.config.face.description)==null?void 0:m.enabled)&&!e.models.faceres&&(e.models.faceres=UA(e.config)),e.config.face.enabled&&((v=e.config.face.emotion)==null?void 0:v.enabled)&&!e.models.emotion&&(e.models.emotion=EA(e.config)),e.config.face.enabled&&((b=e.config.face.iris)==null?void 0:b.enabled)&&!e.models.faceiris&&(e.models.faceiris=GA(e.config)),e.config.face.enabled&&((P=e.config.face.mesh)==null?void 0:P.enabled)&&!e.models.facemesh&&(e.models.facemesh=VA(e.config)),e.config.face.enabled&&((p=e.config.face.gear)==null?void 0:p.enabled)&&!e.models.gear&&(e.models.gear=No(e.config)),e.config.face.enabled&&((u=e.config.face.ssrnet)==null?void 0:u.enabled)&&!e.models.ssrnetage&&(e.models.ssrnetage=Fo(e.config)),e.config.face.enabled&&((E=e.config.face.ssrnet)==null?void 0:E.enabled)&&!e.models.ssrnetgender&&(e.models.ssrnetgender=Do(e.config)),e.config.face.enabled&&((W=e.config.face.mobilefacenet)==null?void 0:W.enabled)&&!e.models.mobilefacenet&&(e.models.mobilefacenet=CA(e.config)),e.config.hand.enabled&&!e.models.handtrack&&((S=(C=e.config.hand.detector)==null?void 0:C.modelPath)==null?void 0:S.includes("handtrack"))&&(e.models.handtrack=gn(e.config)),e.config.hand.enabled&&e.config.hand.landmarks&&!e.models.handskeleton&&((V=(O=e.config.hand.detector)==null?void 0:O.modelPath)==null?void 0:V.includes("handtrack"))&&(e.models.handskeleton=Mn(e.config)),e.config.object.enabled&&!e.models.centernet&&((H=(G=e.config.object)==null?void 0:G.modelPath)==null?void 0:H.includes("centernet"))&&(e.models.centernet=MA(e.config)),e.config.object.enabled&&!e.models.nanodet&&((z=(t0=e.config.object)==null?void 0:t0.modelPath)==null?void 0:z.includes("nanodet"))&&(e.models.nanodet=In(e.config)),e.config.segmentation.enabled&&!e.models.segmentation&&(e.models.segmentation=oo(e.config));for await(let m0 of Object.keys(e.models))e.models[m0]&&typeof e.models[m0]!="undefined"&&(e.models[m0]=await e.models[m0])}async function no(e){let t=["const","placeholder","noop","pad","squeeze","add","sub","mul","div"];for(let o of Object.keys(e.models)){let A=e.models[o];if(!A)continue;let n=[],s=A==null?void 0:A.executor;if(s&&s.graph.nodes)for(let i of Object.values(s.graph.nodes)){let x=i.op.toLowerCase();n.includes(x)||n.push(x)}else!s&&e.config.debug&&g("model signature not determined:",o);let a=[];for(let i of n)!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&&g("model validation failed:",o,a)}}var q={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 I2(){let e=q.gl;!e||(q.extensions=e.getSupportedExtensions())}async function qn(e){var t;if(e.config.backend==="humangl"&&(q.name in r.engine().registry&&(!q.gl||!q.gl.getParameter(q.gl.VERSION))&&(g("error: humangl backend invalid context"),kt(e)),!r.findBackend(q.name))){try{q.canvas=await s0(100,100)}catch(A){g("error: cannot create canvas:",A);return}try{if(q.gl=(t=q.canvas)==null?void 0:t.getContext("webgl2",q.webGLattr),!q.gl.getParameter(q.gl.VERSION).includes("2.0")){g("override: using fallback webgl backend as webgl 2.0 is not detected"),e.config.backend="webgl";return}q.canvas&&(q.canvas.addEventListener("webglcontextlost",async n=>{throw g("error: humangl:",n.type),g("possible browser memory leak using webgl or conflict with multiple backend registrations"),e.emit("error"),new Error("backend error: webgl context lost")}),q.canvas.addEventListener("webglcontextrestored",n=>{g("error: humangl context restored:",n)}),q.canvas.addEventListener("webglcontextcreationerror",n=>{g("error: humangl context create:",n)}))}catch(A){g("error: cannot get WebGL context:",A);return}try{r.setWebGLContext(2,q.gl)}catch(A){g("error: cannot set WebGL context:",A);return}try{let A=new r.GPGPUContext(q.gl);r.registerBackend(q.name,()=>new r.MathBackendWebGL(A),q.priority)}catch(A){g("error: cannot register WebGL backend:",A);return}try{r.getKernelsForBackend("webgl").forEach(n=>{let s={...n,backendName:q.name};r.registerKernel(s)})}catch(A){g("error: cannot update WebGL backend registration:",A);return}let o=r.backend().getGPGPUContext?r.backend().getGPGPUContext().gl:null;if(o)g(`humangl webgl version:${o.getParameter(o.VERSION)} renderer:${o.getParameter(o.RENDERER)}`);else{g("error: no current gl context:",o,q.gl);return}try{r.ENV.set("WEBGL_VERSION",2)}catch(A){g("error: cannot set WebGL backend flags:",A);return}I2(),g("backend registered:",q.name)}}function O2(){if(!w.kernels.includes("mod")){let e={kernelName:"Mod",backendName:r.getBackend(),kernelFunc:t=>r.tidy(()=>r.sub(t.inputs.a,r.mul(r.div(t.inputs.a,t.inputs.b),t.inputs.b)))};r.registerKernel(e),w.kernels.push("mod")}if(!w.kernels.includes("floormod")){let e={kernelName:"FloorMod",backendName:r.getBackend(),kernelFunc:t=>r.tidy(()=>r.floorDiv(t.inputs.a/t.inputs.b)*t.inputs.b+r.mod(t.inputs.a,t.inputs.b))};r.registerKernel(e),w.kernels.push("floormod")}}async function Et(e,t=!1){if(e.state="backend",t||w.initial||e.config.backend&&e.config.backend.length>0&&r.getBackend()!==e.config.backend){let o=M();if(e.config.backend&&e.config.backend.length>0){if(typeof window=="undefined"&&typeof WorkerGlobalScope!="undefined"&&e.config.debug&&e.config.debug&&g("running inside web worker"),w.browser&&e.config.backend==="tensorflow"&&(e.config.debug&&g("override: backend set to tensorflow while running in browser"),e.config.backend="humangl"),w.node&&(e.config.backend==="webgl"||e.config.backend==="humangl")&&(e.config.debug&&g(`override: backend set to ${e.config.backend} while running in nodejs`),e.config.backend="tensorflow"),w.browser&&e.config.backend==="webgpu")if(typeof navigator=="undefined"||typeof navigator.gpu=="undefined")g("override: backend set to webgpu but browser does not support webgpu"),e.config.backend="humangl";else{let n=await navigator.gpu.requestAdapter();e.config.debug&&g("enumerated webgpu adapter:",n)}e.config.backend==="humangl"&&await qn(e);let A=Object.keys(r.engine().registryFactory);if(e.config.debug&&g("available backends:",A),A.includes(e.config.backend)||(g(`error: backend ${e.config.backend} not found in registry`),e.config.backend=w.node?"tensorflow":"webgl",e.config.debug&&g(`override: setting backend ${e.config.backend}`)),e.config.debug&&g("setting backend:",e.config.backend),e.config.backend==="wasm"){if(e.config.debug&&g("wasm path:",e.config.wasmPath),typeof(r==null?void 0:r.setWasmPaths)!="undefined")await r.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 n=await r.env().getAsync("WASM_HAS_SIMD_SUPPORT"),s=await r.env().getAsync("WASM_HAS_MULTITHREAD_SUPPORT");e.config.debug&&g(`wasm execution: ${n?"SIMD":"no SIMD"} ${s?"multithreaded":"singlethreaded"}`),e.config.debug&&!n&&g("warning: wasm simd support is not enabled")}try{await r.setBackend(e.config.backend),await r.ready(),Go()}catch(n){return g("error: cannot set backend:",e.config.backend,n),!1}}if(r.getBackend()==="humangl"&&(r.ENV.set("CHECK_COMPUTATION_FOR_ERRORS",!1),r.ENV.set("WEBGL_CPU_FORWARD",!0),r.ENV.set("WEBGL_USE_SHAPES_UNIFORMS",!0),r.ENV.set("CPU_HANDOFF_SIZE_THRESHOLD",256),typeof e.config.deallocate!="undefined"&&e.config.deallocate&&(g("changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:",!0),r.ENV.set("WEBGL_DELETE_TEXTURE_THRESHOLD",0)),r.backend().getGPGPUContext)){let A=await r.backend().getGPGPUContext().gl;e.config.debug&&g(`gl version:${A.getParameter(A.VERSION)} renderer:${A.getParameter(A.RENDERER)}`)}r.getBackend(),r.enableProdMode(),await r.ready(),e.performance.initBackend=Math.trunc(M()-o),e.config.backend=r.getBackend(),await w.updateBackend(),O2()}return!0}function ut(e,t){for(let o of e){let A={kernelName:o,backendName:t.backend,kernelFunc:()=>{t.debug&&g("kernelFunc",o,t.backend)}};r.registerKernel(A)}w.kernels=r.getKernelsForBackend(r.getBackend()).map(o=>o.kernelName.toLowerCase())}var Kn={};K0(Kn,{all:()=>yo,body:()=>St,canvas:()=>lo,face:()=>jt,gesture:()=>zt,hand:()=>Wt,object:()=>Ct,options:()=>k0,person:()=>io});var k0={color:"rgba(173, 216, 230, 0.6)",labelColor:"rgba(173, 216, 230, 1)",shadowColor:"black",font:'small-caps 16px "Segoe UI"',lineHeight:18,lineWidth:4,pointSize:2,roundRect:8,drawPoints:!1,drawLabels:!0,drawBoxes:!0,drawGestures:!0,drawPolygons:!0,drawGaze:!0,fillPolygons:!1,useDepth:!0,useCurves:!1},so=0,re=e=>{if(!e)g("draw error: invalid canvas");else if(!e.getContext)g("draw error: canvas context not defined");else{let t=e.getContext("2d");if(!t)g("draw error: cannot get canvas context");else return t}return null},ve=e=>Math.round(e*180/Math.PI);function ao(e,t,o,A,n){A=A||0,e.fillStyle=n.useDepth&&A?`rgba(${127.5+2*A}, ${127.5-2*A}, 255, 0.3)`:n.color,e.beginPath(),e.arc(t,o,n.pointSize,0,2*Math.PI),e.fill()}function Ve(e,t,o,A,n,s){if(e.beginPath(),e.lineWidth=s.lineWidth,s.useCurves){let a=(t+t+A)/2,i=(o+o+n)/2;e.ellipse(a,i,A/2,n/2,0,0,2*Math.PI)}else e.moveTo(t+s.roundRect,o),e.lineTo(t+A-s.roundRect,o),e.quadraticCurveTo(t+A,o,t+A,o+s.roundRect),e.lineTo(t+A,o+n-s.roundRect),e.quadraticCurveTo(t+A,o+n,t+A-s.roundRect,o+n),e.lineTo(t+s.roundRect,o+n),e.quadraticCurveTo(t,o+n,t,o+n-s.roundRect),e.lineTo(t,o+s.roundRect),e.quadraticCurveTo(t,o,t+s.roundRect,o),e.closePath();e.stroke()}function Yn(e,t,o){if(!(t.length<2)){e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let A of t){let n=A[2]||0;e.strokeStyle=o.useDepth&&n!==0?`rgba(${127.5+2*n}, ${127.5-2*n}, 255, 0.3)`:o.color,e.fillStyle=o.useDepth&&n!==0?`rgba(${127.5+2*n}, ${127.5-2*n}, 255, 0.3)`:o.color,e.lineTo(A[0],Math.round(A[1]))}e.stroke(),o.fillPolygons&&(e.closePath(),e.fill())}}function L2(e,t,o){if(!(t.length<2)){if(e.lineWidth=o.lineWidth,!o.useCurves||t.length<=2){Yn(e,t,o);return}e.moveTo(t[0][0],t[0][1]);for(let A=0;A1&&x[1].length>0){let d=i[1]>0?`#${i[1]}`:"",l=`${i[0]} ${d}: ${x[1]}`;A.shadowColor&&A.shadowColor!==""&&(n.fillStyle=A.shadowColor,n.fillText(l,8,2+s*A.lineHeight)),n.fillStyle=A.labelColor,n.fillText(l,6,0+s*A.lineHeight),s+=1}}}}async function jt(e,t,o){var s,a,i,x,d;let A=o0(k0,o);if(!t||!e)return;let n=re(e);if(!!n)for(let l of t){if(n.font=A.font,n.strokeStyle=A.color,n.fillStyle=A.color,A.drawBoxes&&Ve(n,l.box[0],l.box[1],l.box[2],l.box[3],A),A.drawLabels){let y=[];if(y.push(`face: ${Math.trunc(100*l.score)}%`),l.genderScore&&y.push(`${l.gender||""} ${Math.trunc(100*l.genderScore)}%`),l.age&&y.push(`age: ${l.age||""}`),l.iris&&y.push(`distance: ${l.iris}`),l.real&&y.push(`real: ${Math.trunc(100*l.real)}%`),l.live&&y.push(`live: ${Math.trunc(100*l.live)}%`),l.emotion&&l.emotion.length>0){let c=l.emotion.map(f=>`${Math.trunc(100*f.score)}% ${f.emotion}`);c.length>3&&(c.length=3),y.push(c.join(" "))}l.rotation&&l.rotation.angle&&l.rotation.gaze&&(l.rotation.angle.roll&&y.push(`roll: ${ve(l.rotation.angle.roll)}\xB0 yaw:${ve(l.rotation.angle.yaw)}\xB0 pitch:${ve(l.rotation.angle.pitch)}\xB0`),l.rotation.gaze.bearing&&y.push(`gaze: ${ve(l.rotation.gaze.bearing)}\xB0`)),y.length===0&&y.push("face"),n.fillStyle=A.color;for(let c=y.length-1;c>=0;c--){let f=Math.max(l.box[0],0),h=c*A.lineHeight+l.box[1];A.shadowColor&&A.shadowColor!==""&&(n.fillStyle=A.shadowColor,n.fillText(y[c],f+5,h+16)),n.fillStyle=A.labelColor,n.fillText(y[c],f+4,h+15)}}if(n.lineWidth=2,l.mesh&&l.mesh.length>0){if(A.drawPoints)for(let y of l.mesh)ao(n,y[0],y[1],y[2],A);if(A.drawPolygons){if(l.mesh.length>450)for(let y=0;y<_0.length/3;y++){let c=[_0[y*3+0],_0[y*3+1],_0[y*3+2]].map(f=>l.mesh[f]);Yn(n,c,A)}if(l.annotations&&l.annotations.leftEyeIris&&l.annotations.leftEyeIris[0]){n.strokeStyle=A.useDepth?"rgba(255, 200, 255, 0.3)":A.color,n.beginPath();let y=Math.abs(l.annotations.leftEyeIris[3][0]-l.annotations.leftEyeIris[1][0])/2,c=Math.abs(l.annotations.leftEyeIris[4][1]-l.annotations.leftEyeIris[2][1])/2;n.ellipse(l.annotations.leftEyeIris[0][0],l.annotations.leftEyeIris[0][1],y,c,0,0,2*Math.PI),n.stroke(),A.fillPolygons&&(n.fillStyle=A.useDepth?"rgba(255, 255, 200, 0.3)":A.color,n.fill())}if(l.annotations&&l.annotations.rightEyeIris&&l.annotations.rightEyeIris[0]){n.strokeStyle=A.useDepth?"rgba(255, 200, 255, 0.3)":A.color,n.beginPath();let y=Math.abs(l.annotations.rightEyeIris[3][0]-l.annotations.rightEyeIris[1][0])/2,c=Math.abs(l.annotations.rightEyeIris[4][1]-l.annotations.rightEyeIris[2][1])/2;n.ellipse(l.annotations.rightEyeIris[0][0],l.annotations.rightEyeIris[0][1],y,c,0,0,2*Math.PI),n.stroke(),A.fillPolygons&&(n.fillStyle=A.useDepth?"rgba(255, 255, 200, 0.3)":A.color,n.fill())}if(A.drawGaze&&((s=l.rotation)==null?void 0:s.angle)&&typeof Path2D!="undefined"){n.strokeStyle="pink";let y=l.box[0]+l.box[2]/2-l.box[3]*ve(l.rotation.angle.yaw)/90,c=l.box[1]+l.box[3]/2+l.box[2]*ve(l.rotation.angle.pitch)/90,f=new Path2D(` M ${l.box[0]+l.box[2]/2} ${l.box[1]} C ${y} ${l.box[1]}, @@ -108,7 +108,7 @@ var It=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var lr=Objec ${l.box[0]} ${c}, ${l.box[0]+l.box[2]} ${c}, ${l.box[0]+l.box[2]} ${l.box[1]+l.box[3]/2} - `);n.stroke(h),n.stroke(f)}if(A.drawGaze&&((i=(a=l.rotation)==null?void 0:a.gaze)==null?void 0:i.strength)&&((d=(x=l.rotation)==null?void 0:x.gaze)==null?void 0:d.bearing)&&l.annotations.leftEyeIris&&l.annotations.rightEyeIris&&l.annotations.leftEyeIris[0]&&l.annotations.rightEyeIris[0]){n.strokeStyle="pink",n.fillStyle="pink";let y=[l.annotations.leftEyeIris[0][0]+Math.sin(l.rotation.gaze.bearing)*l.rotation.gaze.strength*l.box[3],l.annotations.leftEyeIris[0][1]+Math.cos(l.rotation.gaze.bearing)*l.rotation.gaze.strength*l.box[2]];Jn(n,[l.annotations.leftEyeIris[0][0],l.annotations.leftEyeIris[0][1]],[y[0],y[1]],4);let c=[l.annotations.rightEyeIris[0][0]+Math.sin(l.rotation.gaze.bearing)*l.rotation.gaze.strength*l.box[3],l.annotations.rightEyeIris[0][1]+Math.cos(l.rotation.gaze.bearing)*l.rotation.gaze.strength*l.box[2]];Jn(n,[l.annotations.rightEyeIris[0][0],l.annotations.rightEyeIris[0][1]],[c[0],c[1]],4)}}}}}async function Et(e,t,o){var s;let A=o0(k0,o);if(!t||!e)return;let n=re(e);if(!!n){n.lineJoin="round";for(let a=0;a0)for(let a of s.keypoints)n.fillStyle=A.useDepth?`rgba(${127.5+2*(a[2]||0)}, ${127.5-2*(a[2]||0)}, 255, 0.5)`:A.color,ro(n,a[0],a[1],0,A);if(A.drawLabels&&s.annotations){let a=(i,x)=>{if(!i||i.length===0||!i[0])return;let d=i[i.length-1][2]||0;n.fillStyle=A.useDepth?`rgba(${127.5+2*d}, ${127.5-2*d}, 255, 0.5)`:A.color,n.fillText(x,i[i.length-1][0]+4,i[i.length-1][1]+4)};n.font=A.font,a(s.annotations.index,"index"),a(s.annotations.middle,"middle"),a(s.annotations.ring,"ring"),a(s.annotations.pinky,"pinky"),a(s.annotations.thumb,"thumb"),a(s.annotations.palm,"palm")}if(A.drawPolygons&&s.annotations){let a=i=>{if(!(!i||i.length===0||!i[0]))for(let x=0;x0?x-1:0][0],i[x>0?x-1:0][1]),n.lineTo(i[x][0],i[x][1]),n.stroke()}};n.lineWidth=A.lineWidth,a(s.annotations.index),a(s.annotations.middle),a(s.annotations.ring),a(s.annotations.pinky),a(s.annotations.thumb)}}}}async function jt(e,t,o){let A=o0(k0,o);if(!t||!e)return;let n=re(e);if(!!n){n.lineJoin="round",n.font=A.font;for(let s of t)if(A.drawBoxes){if(n.strokeStyle=A.color,n.fillStyle=A.color,Fe(n,s.box[0],s.box[1],s.box[2],s.box[3],A),A.drawLabels){let a=`${s.label} ${Math.round(100*s.score)}%`;A.shadowColor&&A.shadowColor!==""&&(n.fillStyle=A.shadowColor,n.fillText(a,s.box[0]+3,1+s.box[1]+A.lineHeight,s.box[2])),n.fillStyle=A.labelColor,n.fillText(a,s.box[0]+2,0+s.box[1]+A.lineHeight,s.box[2])}n.stroke()}}}async function so(e,t,o){let A=o0(k0,o);if(!t||!e)return;let n=re(e);if(!!n){n.lineJoin="round",n.font=A.font;for(let s=0;st!=o[n].y>t&&e<(o[n].x-o[s].x)*(t-o[s].y)/(o[n].y-o[s].y)+o[s].x&&(A=!A);return A}async function Qn(e){if(!e.tensor||!e.mesh||e.mesh.length<100)return e.tensor;let t=e.tensor.shape[2]||0,o=e.tensor.shape[1]||0,A=await e.tensor.buffer(),n=[];for(let a of b0.silhouette)n.push({x:(e.mesh[a][0]-e.box[0])/e.box[2],y:(e.mesh[a][1]-e.box[1])/e.box[3]});Te&&Te>0&&(n=n.map(a=>({x:a.x>.5?a.x+Te:a.x-Te,y:a.y>.5?a.y+Te:a.y-Te})));for(let a=0;a{let t=(y,c)=>Math.atan2(y[1]-c[1],y[0]-c[0]);if(!e.annotations.rightEyeIris||!e.annotations.leftEyeIris)return{bearing:0,strength:0};let o=[0,-.1],A=1,n=(e.mesh[33][2]||0)>(e.mesh[263][2]||0),s=n?e.mesh[473]:e.mesh[468],a=n?[(e.mesh[133][0]+e.mesh[33][0])/2,(e.mesh[133][1]+e.mesh[33][1])/2]:[(e.mesh[263][0]+e.mesh[362][0])/2,(e.mesh[263][1]+e.mesh[362][1])/2],i=n?[e.mesh[133][0]-e.mesh[33][0],e.mesh[23][1]-e.mesh[27][1]]:[e.mesh[263][0]-e.mesh[362][0],e.mesh[253][1]-e.mesh[257][1]],x=[(a[0]-s[0])/i[0]-o[0],A*(s[1]-a[1])/i[1]-o[1]],d=Math.sqrt(x[0]*x[0]+x[1]*x[1]);return d=Math.min(d,e.boxRaw[2]/2,e.boxRaw[3]/2),{bearing:(t([0,0],x)+Math.PI/2)%Math.PI,strength:d}},_n=(e,t)=>{let o=m=>{let v=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);return m[0]/=v,m[1]/=v,m[2]/=v,m},A=(m,v)=>{let b=m[0]-v[0],P=m[1]-v[1],p=m[2]-v[2];return[b,P,p]},n=(m,v)=>{let b=m[1]*v[2]-m[2]*v[1],P=m[2]*v[0]-m[0]*v[2],p=m[0]*v[1]-m[1]*v[0];return[b,P,p]},s=m=>{let[v,b,P,p,u,E,W,C,S]=m,O,V,G;return p<1?p>-1?(G=Math.asin(p),V=Math.atan2(-W,v),O=Math.atan2(-E,u)):(G=-Math.PI/2,V=-Math.atan2(C,S),O=0):(G=Math.PI/2,V=Math.atan2(C,S),O=0),isNaN(O)&&(O=0),isNaN(V)&&(V=0),isNaN(G)&&(G=0),{pitch:2*-O,yaw:2*-V,roll:2*-G}},a=e.meshRaw;if(!a||a.length<300)return{angle:{pitch:0,yaw:0,roll:0},matrix:[1,0,0,0,1,0,0,0,1],gaze:{bearing:0,strength:0}};let i=Math.max(e.boxRaw[2]*t[0],e.boxRaw[3]*t[1])/1.5,x=[a[10],a[152],a[234],a[454]].map(m=>[m[0]*t[0]/i,m[1]*t[1]/i,m[2]]),d=o(A(x[1],x[0])),l=o(A(x[3],x[2])),y=o(n(l,d));l=n(d,y);let c=[l[0],l[1],l[2],d[0],d[1],d[2],y[0],y[1],y[2]],f=s(c),h=a.length===478?B2(e):{bearing:0,strength:0};return{angle:f,matrix:c,gaze:h}};var yo=async(e,t)=>{var f,h,m,v,b,P,p,u,E,W,C,S,O,V,G,H,t0,z,m0,B0,T,Q;let o=M(),A,n,s,a,i,x,d,l,y=[];e.state="run:face";let c=await FA(t,e.config);if(e.performance.face=w.perfadd?(e.performance.face||0)+Math.trunc(M()-o):Math.trunc(M()-o),!t.shape||t.shape.length!==4)return[];if(!c)return[];for(let k=0;k200?_n(c[k],[t.shape[2],t.shape[1]]):null;e.analyze("Start Emotion:"),e.config.async?a=(h=e.config.face.emotion)!=null&&h.enabled?p5(c[k].tensor||r.tensor([]),e.config,k,c.length):[]:(e.state="run:emotion",o=M(),a=(m=e.config.face.emotion)!=null&&m.enabled?await p5(c[k].tensor||r.tensor([]),e.config,k,c.length):[],e.performance.emotion=w.perfadd?(e.performance.emotion||0)+Math.trunc(M()-o):Math.trunc(M()-o)),e.analyze("End Emotion:"),e.analyze("Start AntiSpoof:"),e.config.async?x=(v=e.config.face.antispoof)!=null&&v.enabled?Yt(c[k].tensor||r.tensor([]),e.config,k,c.length):0:(e.state="run:antispoof",o=M(),x=(b=e.config.face.antispoof)!=null&&b.enabled?await Yt(c[k].tensor||r.tensor([]),e.config,k,c.length):0,e.performance.antispoof=w.perfadd?(e.performance.antispoof||0)+Math.trunc(M()-o):Math.trunc(M()-o)),e.analyze("End AntiSpoof:"),e.analyze("Start Liveness:"),e.config.async?d=(P=e.config.face.liveness)!=null&&P.enabled?G5(c[k].tensor||r.tensor([]),e.config,k,c.length):0:(e.state="run:liveness",o=M(),d=(p=e.config.face.liveness)!=null&&p.enabled?await G5(c[k].tensor||r.tensor([]),e.config,k,c.length):0,e.performance.liveness=w.perfadd?(e.performance.antispoof||0)+Math.trunc(M()-o):Math.trunc(M()-o)),e.analyze("End Liveness:"),e.analyze("Start GEAR:"),e.config.async?n=(u=e.config.face.gear)!=null&&u.enabled?Vt(c[k].tensor||r.tensor([]),e.config,k,c.length):null:(e.state="run:gear",o=M(),n=(E=e.config.face.gear)!=null&&E.enabled?await Vt(c[k].tensor||r.tensor([]),e.config,k,c.length):null,e.performance.gear=Math.trunc(M()-o)),e.analyze("End GEAR:"),e.analyze("Start SSRNet:"),e.config.async?(A=(W=e.config.face.ssrnet)!=null&&W.enabled?Xt(c[k].tensor||r.tensor([]),e.config,k,c.length):null,s=(C=e.config.face.ssrnet)!=null&&C.enabled?Ut(c[k].tensor||r.tensor([]),e.config,k,c.length):null):(e.state="run:ssrnet",o=M(),A=(S=e.config.face.ssrnet)!=null&&S.enabled?await Xt(c[k].tensor||r.tensor([]),e.config,k,c.length):null,s=(O=e.config.face.ssrnet)!=null&&O.enabled?await Ut(c[k].tensor||r.tensor([]),e.config,k,c.length):null,e.performance.ssrnet=Math.trunc(M()-o)),e.analyze("End SSRNet:"),e.analyze("Start MobileFaceNet:"),e.config.async?i=(V=e.config.face.mobilefacenet)!=null&&V.enabled?h5(c[k].tensor||r.tensor([]),e.config,k,c.length):null:(e.state="run:mobilefacenet",o=M(),i=(G=e.config.face.mobilefacenet)!=null&&G.enabled?await h5(c[k].tensor||r.tensor([]),e.config,k,c.length):null,e.performance.mobilefacenet=Math.trunc(M()-o)),e.analyze("End MobileFaceNet:"),e.analyze("Start Description:"),e.config.async?l=(H=e.config.face.description)!=null&&H.enabled?T5(c[k].tensor||r.tensor([]),e.config,k,c.length):null:(e.state="run:description",o=M(),l=(t0=e.config.face.description)!=null&&t0.enabled?await T5(c[k].tensor||r.tensor([]),e.config,k,c.length):null,e.performance.description=w.perfadd?(e.performance.description||0)+Math.trunc(M()-o):Math.trunc(M()-o)),e.analyze("End Description:"),e.config.async&&([A,s,a,i,l,n,x,d]=await Promise.all([A,s,a,i,l,n,x,d])),e.analyze("Finish Face:"),((z=e.config.face.ssrnet)==null?void 0:z.enabled)&&A&&s&&(l={...l,age:A.age,gender:s.gender,genderScore:s.genderScore}),((m0=e.config.face.gear)==null?void 0:m0.enabled)&&n&&(l={...l,age:n.age,gender:n.gender,genderScore:n.genderScore,race:n.race}),((B0=e.config.face.mobilefacenet)==null?void 0:B0.enabled)&&i&&(l.descriptor=i),(T=e.config.face.iris)!=null&&T.enabled;let Y=c[k].annotations&&c[k].annotations.leftEyeIris&&c[k].annotations.leftEyeIris[0]&&c[k].annotations.rightEyeIris&&c[k].annotations.rightEyeIris[0]&&c[k].annotations.leftEyeIris.length>0&&c[k].annotations.rightEyeIris.length>0&&c[k].annotations.leftEyeIris[0]!==null&&c[k].annotations.rightEyeIris[0]!==null?Math.max(Math.abs(c[k].annotations.leftEyeIris[3][0]-c[k].annotations.leftEyeIris[1][0]),Math.abs(c[k].annotations.rightEyeIris[4][1]-c[k].annotations.rightEyeIris[2][1]))/t.shape[2]:0,e0=(Q=e.config.face.detector)!=null&&Q.return?r.squeeze(c[k].tensor):null;r.dispose(c[k].tensor),c[k].tensor&&delete c[k].tensor;let I={...c[k],id:k};l!=null&&l.age&&(I.age=l.age),l!=null&&l.gender&&(I.gender=l.gender),l!=null&&l.genderScore&&(I.genderScore=l==null?void 0:l.genderScore),l!=null&&l.descriptor&&(I.embedding=l==null?void 0:l.descriptor),l!=null&&l.race&&(I.race=l==null?void 0:l.race),a&&(I.emotion=a),x&&(I.real=x),d&&(I.live=d),Y&&Y!==0&&(I.iris=Math.trunc(500/Y/11.7)/100),X&&(I.rotation=X),e0&&(I.tensor=e0),y.push(I),e.analyze("End Face")}return e.analyze("End FaceMesh:"),e.config.async&&(e.performance.face&&delete e.performance.face,e.performance.age&&delete e.performance.age,e.performance.gender&&delete e.performance.gender,e.performance.emotion&&delete e.performance.emotion),y};var $n=e=>{if(!e)return[];let t=[];for(let o=0;ox.part==="leftWrist"),n=e[o].keypoints.find(x=>x.part==="rightWrist"),s=e[o].keypoints.find(x=>x.part==="nose");s&&A&&n&&A.position[1]x.part==="leftShoulder"),i=e[o].keypoints.find(x=>x.part==="rightShoulder");a&&i&&Math.abs(a.positionRaw[1]-i.positionRaw[1])>.1&&t.push({body:o,gesture:`leaning ${a.position[1]>i.position[1]?"left":"right"}`})}return t},er=e=>{if(!e)return[];let t=[];for(let o=0;o450){let A=(e[o].mesh[33][2]||0)-(e[o].mesh[263][2]||0),n=e[o].mesh[33][0]-e[o].mesh[263][0];Math.abs(A/n)<=.15?t.push({face:o,gesture:"facing center"}):t.push({face:o,gesture:`facing ${A<0?"left":"right"}`}),Math.abs(e[o].mesh[374][1]-e[o].mesh[386][1])/Math.abs(e[o].mesh[443][1]-e[o].mesh[450][1])<.2&&t.push({face:o,gesture:"blink left eye"}),Math.abs(e[o].mesh[145][1]-e[o].mesh[159][1])/Math.abs(e[o].mesh[223][1]-e[o].mesh[230][1])<.2&&t.push({face:o,gesture:"blink right eye"});let i=Math.min(100,500*Math.abs(e[o].mesh[13][1]-e[o].mesh[14][1])/Math.abs(e[o].mesh[10][1]-e[o].mesh[152][1]));i>10&&t.push({face:o,gesture:`mouth ${Math.trunc(i)}% open`});let x=e[o].mesh[152][2]||0;Math.abs(x)>10&&t.push({face:o,gesture:`head ${x<0?"up":"down"}`})}return t},tr=e=>{if(!e)return[];let t=[];for(let o=0;o.06||c>.06)&&(d=!1),y>c?y>.05&&t.push({iris:o,gesture:"looking right"}):c>.05&&t.push({iris:o,gesture:"looking left"});let f=Math.abs(e[o].mesh[145][1]-e[o].annotations.rightEyeIris[0][1])/e[o].box[3],h=Math.abs(e[o].mesh[374][1]-e[o].annotations.leftEyeIris[0][1])/e[o].box[3];(h<.01||f<.01||h>.022||f>.022)&&(d=!1),(h<.01||f<.01)&&t.push({iris:o,gesture:"looking down"}),(h>.022||f>.022)&&t.push({iris:o,gesture:"looking up"}),d&&t.push({iris:o,gesture:"looking center"})}return t},or=e=>{if(!e)return[];let t=[];for(let o=0;o0){let n=A.reduce((a,i)=>(a.position[2]||0)<(i.position[2]||0)?a:i);t.push({hand:o,gesture:`${n.name} forward`});let s=A.reduce((a,i)=>a.position[1]((n-1)*j.body[T].box[F]+I)/n),k=e.body[T].boxRaw.map((I,F)=>((n-1)*j.body[T].boxRaw[F]+I)/n),X=e.body[T].keypoints.map((I,F)=>{var E0,z0,Re,ke,se,mo,po,uo,ho;return{score:I.score,part:I.part,position:[j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].position[0]||0)+(I.position[0]||0))/n:I.position[0],j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].position[1]||0)+(I.position[1]||0))/n:I.position[1],j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].position[2]||0)+(I.position[2]||0))/n:I.position[2]],positionRaw:[j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].positionRaw[0]||0)+(I.positionRaw[0]||0))/n:I.positionRaw[0],j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].positionRaw[1]||0)+(I.positionRaw[1]||0))/n:I.positionRaw[1],j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].positionRaw[2]||0)+(I.positionRaw[2]||0))/n:I.positionRaw[2]],distance:[j.body[T].keypoints[F]?((n-1)*(((E0=j.body[T].keypoints[F].distance)==null?void 0:E0[0])||0)+(((z0=I.distance)==null?void 0:z0[0])||0))/n:(Re=I.distance)==null?void 0:Re[0],j.body[T].keypoints[F]?((n-1)*(((ke=j.body[T].keypoints[F].distance)==null?void 0:ke[1])||0)+(((se=I.distance)==null?void 0:se[1])||0))/n:(mo=I.distance)==null?void 0:mo[1],j.body[T].keypoints[F]?((n-1)*(((po=j.body[T].keypoints[F].distance)==null?void 0:po[2])||0)+(((uo=I.distance)==null?void 0:uo[2])||0))/n:(ho=I.distance)==null?void 0:ho[2]]}}),Y={},e0={connected:{}};(i=(a=t.body)==null?void 0:a.modelPath)!=null&&i.includes("efficientpose")?e0=rt:(d=(x=t.body)==null?void 0:x.modelPath)!=null&&d.includes("blazepose")?e0=et:(y=(l=t.body)==null?void 0:l.modelPath)!=null&&y.includes("movenet")&&(e0=Ge);for(let[I,F]of Object.entries(e0.connected)){let E0=[];for(let z0=0;z0se.part===F[z0]),ke=X.find(se=>se.part===F[z0+1]);Re&&ke&&E0.push([Re.position,ke.position])}Y[I]=E0}j.body[T]={...e.body[T],box:Q,boxRaw:k,keypoints:X,annotations:Y}}if(!j.hand||e.hand.length!==j.hand.length)j.hand=JSON.parse(JSON.stringify(e.hand));else for(let T=0;T((n-1)*j.hand[T].box[I]+e0)/n),k=e.hand[T].boxRaw.map((e0,I)=>((n-1)*j.hand[T].boxRaw[I]+e0)/n);j.hand[T].keypoints.length!==e.hand[T].keypoints.length&&(j.hand[T].keypoints=e.hand[T].keypoints);let X=e.hand[T].keypoints&&e.hand[T].keypoints.length>0?e.hand[T].keypoints.map((e0,I)=>e0.map((F,E0)=>((n-1)*(j.hand[T].keypoints[I][E0]||1)+(F||0))/n)):[],Y={};if(Object.keys(j.hand[T].annotations).length!==Object.keys(e.hand[T].annotations).length)j.hand[T].annotations=e.hand[T].annotations,Y=j.hand[T].annotations;else if(e.hand[T].annotations)for(let e0 of Object.keys(e.hand[T].annotations))Y[e0]=e.hand[T].annotations[e0]&&e.hand[T].annotations[e0][0]?e.hand[T].annotations[e0].map((I,F)=>I.map((E0,z0)=>((n-1)*j.hand[T].annotations[e0][F][z0]+E0)/n)):null;j.hand[T]={...e.hand[T],box:Q,boxRaw:k,keypoints:X,annotations:Y}}if(!j.face||e.face.length!==j.face.length)j.face=JSON.parse(JSON.stringify(e.face));else for(let T=0;T((n-1)*j.face[T].box[Y]+X)/n),k=e.face[T].boxRaw.map((X,Y)=>((n-1)*j.face[T].boxRaw[Y]+X)/n);if(e.face[T].rotation){let X={matrix:[0,0,0,0,0,0,0,0,0],angle:{roll:0,yaw:0,pitch:0},gaze:{bearing:0,strength:0}};X.matrix=(c=e.face[T].rotation)==null?void 0:c.matrix,X.angle={roll:((n-1)*(((h=(f=j.face[T].rotation)==null?void 0:f.angle)==null?void 0:h.roll)||0)+(((v=(m=e.face[T].rotation)==null?void 0:m.angle)==null?void 0:v.roll)||0))/n,yaw:((n-1)*(((P=(b=j.face[T].rotation)==null?void 0:b.angle)==null?void 0:P.yaw)||0)+(((u=(p=e.face[T].rotation)==null?void 0:p.angle)==null?void 0:u.yaw)||0))/n,pitch:((n-1)*(((W=(E=j.face[T].rotation)==null?void 0:E.angle)==null?void 0:W.pitch)||0)+(((S=(C=e.face[T].rotation)==null?void 0:C.angle)==null?void 0:S.pitch)||0))/n},X.gaze={bearing:((n-1)*(((V=(O=j.face[T].rotation)==null?void 0:O.gaze)==null?void 0:V.bearing)||0)+(((H=(G=e.face[T].rotation)==null?void 0:G.gaze)==null?void 0:H.bearing)||0))/n,strength:((n-1)*(((z=(t0=j.face[T].rotation)==null?void 0:t0.gaze)==null?void 0:z.strength)||0)+(((B0=(m0=e.face[T].rotation)==null?void 0:m0.gaze)==null?void 0:B0.strength)||0))/n},j.face[T]={...e.face[T],rotation:X,box:Q,boxRaw:k}}j.face[T]={...e.face[T],box:Q,boxRaw:k}}if(!j.object||e.object.length!==j.object.length)j.object=JSON.parse(JSON.stringify(e.object));else for(let T=0;T((n-1)*j.object[T].box[Y]+X)/n),k=e.object[T].boxRaw.map((X,Y)=>((n-1)*j.object[T].boxRaw[Y]+X)/n);j.object[T]={...e.object[T],box:Q,boxRaw:k}}if(e.persons){let T=e.persons;if(!j.persons||T.length!==j.persons.length)j.persons=JSON.parse(JSON.stringify(T));else for(let Q=0;Q((n-1)*j.persons[Q].box[X]+k)/n)}e.gesture&&(j.gesture=e.gesture);let s=M();return xo=w.perfadd?xo+Math.round(s-o):Math.round(s-o),e.performance&&(j.performance={...e.performance,interpolate:xo}),j}var rr={};Y0(rr,{distance:()=>Ve,match:()=>fo,similarity:()=>co});function Ve(e,t,o={order:2,multiplier:25}){let A=0;for(let n=0;n{if(e===0)return 1;let n=t===2?Math.sqrt(e):e**(1/t),s=(1-n/100-o)/(A-o);return Math.max(Math.min(s,1),0)};function co(e,t,o={order:2,multiplier:25,min:.2,max:.8}){let A=Ve(e,t,o);return nr(A,o.order||2,o.min||0,o.max||1)}function fo(e,t,o={order:2,multiplier:25,threshold:0,min:.2,max:.8}){if(!Array.isArray(e)||!Array.isArray(t)||e.length<64||t.length===0||e.length!==t[0].length)return{index:-1,distance:Number.POSITIVE_INFINITY,similarity:0};let A=Number.MAX_SAFE_INTEGER,n=-1;for(let a=0;az.box[0]&&C.box[0]z.box[1]&&C.box[1]+C.box[3]S.body.box[0]&&z.box[0]+z.box[2]S.body.box[1]&&z.box[1]+z.box[3]S.body.box[0]&&z.box[1]+z.box[3]>S.body.box[1]&&z.box[1]+z.box[3]{z&&z.length===4&&(O.push(z[0],z[0]+z[2]),V.push(z[1],z[1]+z[3]))};G((b=S.face)==null?void 0:b.box),G((P=S.body)==null?void 0:P.box),G((u=(p=S.hands)==null?void 0:p.left)==null?void 0:u.box),G((W=(E=S.hands)==null?void 0:E.right)==null?void 0:W.box);let H=Math.min(...O),t0=Math.min(...V);S.box=[H,t0,Math.max(...O)-H,Math.max(...V)-t0],n&&n[1]&&n[2]&&(S.boxRaw=[S.box[0]/n[2],S.box[1]/n[1],S.box[2]/n[2],S.box[3]/n[1]]),a.push(S)}return a}var St=` + `);n.stroke(h),n.stroke(f)}if(A.drawGaze&&((i=(a=l.rotation)==null?void 0:a.gaze)==null?void 0:i.strength)&&((d=(x=l.rotation)==null?void 0:x.gaze)==null?void 0:d.bearing)&&l.annotations.leftEyeIris&&l.annotations.rightEyeIris&&l.annotations.leftEyeIris[0]&&l.annotations.rightEyeIris[0]){n.strokeStyle="pink",n.fillStyle="pink";let y=[l.annotations.leftEyeIris[0][0]+Math.sin(l.rotation.gaze.bearing)*l.rotation.gaze.strength*l.box[3],l.annotations.leftEyeIris[0][1]+Math.cos(l.rotation.gaze.bearing)*l.rotation.gaze.strength*l.box[2]];Jn(n,[l.annotations.leftEyeIris[0][0],l.annotations.leftEyeIris[0][1]],[y[0],y[1]],4);let c=[l.annotations.rightEyeIris[0][0]+Math.sin(l.rotation.gaze.bearing)*l.rotation.gaze.strength*l.box[3],l.annotations.rightEyeIris[0][1]+Math.cos(l.rotation.gaze.bearing)*l.rotation.gaze.strength*l.box[2]];Jn(n,[l.annotations.rightEyeIris[0][0],l.annotations.rightEyeIris[0][1]],[c[0],c[1]],4)}}}}}async function St(e,t,o){var s;let A=o0(k0,o);if(!t||!e)return;let n=re(e);if(!!n){n.lineJoin="round";for(let a=0;a0)for(let a of s.keypoints)n.fillStyle=A.useDepth?`rgba(${127.5+2*(a[2]||0)}, ${127.5-2*(a[2]||0)}, 255, 0.5)`:A.color,ao(n,a[0],a[1],0,A);if(A.drawLabels&&s.annotations){let a=(i,x)=>{if(!i||i.length===0||!i[0])return;let d=i[i.length-1][2]||0;n.fillStyle=A.useDepth?`rgba(${127.5+2*d}, ${127.5-2*d}, 255, 0.5)`:A.color,n.fillText(x,i[i.length-1][0]+4,i[i.length-1][1]+4)};n.font=A.font,a(s.annotations.index,"index"),a(s.annotations.middle,"middle"),a(s.annotations.ring,"ring"),a(s.annotations.pinky,"pinky"),a(s.annotations.thumb,"thumb"),a(s.annotations.palm,"palm")}if(A.drawPolygons&&s.annotations){let a=i=>{if(!(!i||i.length===0||!i[0]))for(let x=0;x0?x-1:0][0],i[x>0?x-1:0][1]),n.lineTo(i[x][0],i[x][1]),n.stroke()}};n.lineWidth=A.lineWidth,a(s.annotations.index),a(s.annotations.middle),a(s.annotations.ring),a(s.annotations.pinky),a(s.annotations.thumb)}}}}async function Ct(e,t,o){let A=o0(k0,o);if(!t||!e)return;let n=re(e);if(!!n){n.lineJoin="round",n.font=A.font;for(let s of t)if(A.drawBoxes){if(n.strokeStyle=A.color,n.fillStyle=A.color,Ve(n,s.box[0],s.box[1],s.box[2],s.box[3],A),A.drawLabels){let a=`${s.label} ${Math.round(100*s.score)}%`;A.shadowColor&&A.shadowColor!==""&&(n.fillStyle=A.shadowColor,n.fillText(a,s.box[0]+3,1+s.box[1]+A.lineHeight,s.box[2])),n.fillStyle=A.labelColor,n.fillText(a,s.box[0]+2,0+s.box[1]+A.lineHeight,s.box[2])}n.stroke()}}}async function io(e,t,o){let A=o0(k0,o);if(!t||!e)return;let n=re(e);if(!!n){n.lineJoin="round",n.font=A.font;for(let s=0;st!=o[n].y>t&&e<(o[n].x-o[s].x)*(t-o[s].y)/(o[n].y-o[s].y)+o[s].x&&(A=!A);return A}async function Qn(e){if(!e.tensor||!e.mesh||e.mesh.length<100)return e.tensor;let t=e.tensor.shape[2]||0,o=e.tensor.shape[1]||0,A=await e.tensor.buffer(),n=[];for(let a of b0.silhouette)n.push({x:(e.mesh[a][0]-e.box[0])/e.box[2],y:(e.mesh[a][1]-e.box[1])/e.box[3]});Te&&Te>0&&(n=n.map(a=>({x:a.x>.5?a.x+Te:a.x-Te,y:a.y>.5?a.y+Te:a.y-Te})));for(let a=0;a{let t=(y,c)=>Math.atan2(y[1]-c[1],y[0]-c[0]);if(!e.annotations.rightEyeIris||!e.annotations.leftEyeIris)return{bearing:0,strength:0};let o=[0,-.1],A=1,n=(e.mesh[33][2]||0)>(e.mesh[263][2]||0),s=n?e.mesh[473]:e.mesh[468],a=n?[(e.mesh[133][0]+e.mesh[33][0])/2,(e.mesh[133][1]+e.mesh[33][1])/2]:[(e.mesh[263][0]+e.mesh[362][0])/2,(e.mesh[263][1]+e.mesh[362][1])/2],i=n?[e.mesh[133][0]-e.mesh[33][0],e.mesh[23][1]-e.mesh[27][1]]:[e.mesh[263][0]-e.mesh[362][0],e.mesh[253][1]-e.mesh[257][1]],x=[(a[0]-s[0])/i[0]-o[0],A*(s[1]-a[1])/i[1]-o[1]],d=Math.sqrt(x[0]*x[0]+x[1]*x[1]);return d=Math.min(d,e.boxRaw[2]/2,e.boxRaw[3]/2),{bearing:(t([0,0],x)+Math.PI/2)%Math.PI,strength:d}},_n=(e,t)=>{let o=m=>{let v=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);return m[0]/=v,m[1]/=v,m[2]/=v,m},A=(m,v)=>{let b=m[0]-v[0],P=m[1]-v[1],p=m[2]-v[2];return[b,P,p]},n=(m,v)=>{let b=m[1]*v[2]-m[2]*v[1],P=m[2]*v[0]-m[0]*v[2],p=m[0]*v[1]-m[1]*v[0];return[b,P,p]},s=m=>{let[v,b,P,p,u,E,W,C,S]=m,O,V,G;return p<1?p>-1?(G=Math.asin(p),V=Math.atan2(-W,v),O=Math.atan2(-E,u)):(G=-Math.PI/2,V=-Math.atan2(C,S),O=0):(G=Math.PI/2,V=Math.atan2(C,S),O=0),isNaN(O)&&(O=0),isNaN(V)&&(V=0),isNaN(G)&&(G=0),{pitch:2*-O,yaw:2*-V,roll:2*-G}},a=e.meshRaw;if(!a||a.length<300)return{angle:{pitch:0,yaw:0,roll:0},matrix:[1,0,0,0,1,0,0,0,1],gaze:{bearing:0,strength:0}};let i=Math.max(e.boxRaw[2]*t[0],e.boxRaw[3]*t[1])/1.5,x=[a[10],a[152],a[234],a[454]].map(m=>[m[0]*t[0]/i,m[1]*t[1]/i,m[2]]),d=o(A(x[1],x[0])),l=o(A(x[3],x[2])),y=o(n(l,d));l=n(d,y);let c=[l[0],l[1],l[2],d[0],d[1],d[2],y[0],y[1],y[2]],f=s(c),h=a.length===478?H2(e):{bearing:0,strength:0};return{angle:f,matrix:c,gaze:h}};var co=async(e,t)=>{var f,h,m,v,b,P,p,u,E,W,C,S,O,V,G,H,t0,z,m0,B0,T,Q;let o=M(),A,n,s,a,i,x,d,l,y=[];e.state="run:face";let c=await FA(t,e.config);if(e.performance.face=w.perfadd?(e.performance.face||0)+Math.trunc(M()-o):Math.trunc(M()-o),!t.shape||t.shape.length!==4)return[];if(!c)return[];for(let k=0;k200?_n(c[k],[t.shape[2],t.shape[1]]):null;e.analyze("Start Emotion:"),e.config.async?a=(h=e.config.face.emotion)!=null&&h.enabled?M5(c[k].tensor||r.tensor([]),e.config,k,c.length):[]:(e.state="run:emotion",o=M(),a=(m=e.config.face.emotion)!=null&&m.enabled?await M5(c[k].tensor||r.tensor([]),e.config,k,c.length):[],e.performance.emotion=w.perfadd?(e.performance.emotion||0)+Math.trunc(M()-o):Math.trunc(M()-o)),e.analyze("End Emotion:"),e.analyze("Start AntiSpoof:"),e.config.async?x=(v=e.config.face.antispoof)!=null&&v.enabled?e5(c[k].tensor||r.tensor([]),e.config,k,c.length):0:(e.state="run:antispoof",o=M(),x=(b=e.config.face.antispoof)!=null&&b.enabled?await e5(c[k].tensor||r.tensor([]),e.config,k,c.length):0,e.performance.antispoof=w.perfadd?(e.performance.antispoof||0)+Math.trunc(M()-o):Math.trunc(M()-o)),e.analyze("End AntiSpoof:"),e.analyze("Start Liveness:"),e.config.async?d=(P=e.config.face.liveness)!=null&&P.enabled?F5(c[k].tensor||r.tensor([]),e.config,k,c.length):0:(e.state="run:liveness",o=M(),d=(p=e.config.face.liveness)!=null&&p.enabled?await F5(c[k].tensor||r.tensor([]),e.config,k,c.length):0,e.performance.liveness=w.perfadd?(e.performance.antispoof||0)+Math.trunc(M()-o):Math.trunc(M()-o)),e.analyze("End Liveness:"),e.analyze("Start GEAR:"),e.config.async?n=(u=e.config.face.gear)!=null&&u.enabled?Ut(c[k].tensor||r.tensor([]),e.config,k,c.length):null:(e.state="run:gear",o=M(),n=(E=e.config.face.gear)!=null&&E.enabled?await Ut(c[k].tensor||r.tensor([]),e.config,k,c.length):null,e.performance.gear=Math.trunc(M()-o)),e.analyze("End GEAR:"),e.analyze("Start SSRNet:"),e.config.async?(A=(W=e.config.face.ssrnet)!=null&&W.enabled?Yt(c[k].tensor||r.tensor([]),e.config,k,c.length):null,s=(C=e.config.face.ssrnet)!=null&&C.enabled?_t(c[k].tensor||r.tensor([]),e.config,k,c.length):null):(e.state="run:ssrnet",o=M(),A=(S=e.config.face.ssrnet)!=null&&S.enabled?await Yt(c[k].tensor||r.tensor([]),e.config,k,c.length):null,s=(O=e.config.face.ssrnet)!=null&&O.enabled?await _t(c[k].tensor||r.tensor([]),e.config,k,c.length):null,e.performance.ssrnet=Math.trunc(M()-o)),e.analyze("End SSRNet:"),e.analyze("Start MobileFaceNet:"),e.config.async?i=(V=e.config.face.mobilefacenet)!=null&&V.enabled?v5(c[k].tensor||r.tensor([]),e.config,k,c.length):null:(e.state="run:mobilefacenet",o=M(),i=(G=e.config.face.mobilefacenet)!=null&&G.enabled?await v5(c[k].tensor||r.tensor([]),e.config,k,c.length):null,e.performance.mobilefacenet=Math.trunc(M()-o)),e.analyze("End MobileFaceNet:"),e.analyze("Start Description:"),e.config.async?l=(H=e.config.face.description)!=null&&H.enabled?z5(c[k].tensor||r.tensor([]),e.config,k,c.length):null:(e.state="run:description",o=M(),l=(t0=e.config.face.description)!=null&&t0.enabled?await z5(c[k].tensor||r.tensor([]),e.config,k,c.length):null,e.performance.description=w.perfadd?(e.performance.description||0)+Math.trunc(M()-o):Math.trunc(M()-o)),e.analyze("End Description:"),e.config.async&&([A,s,a,i,l,n,x,d]=await Promise.all([A,s,a,i,l,n,x,d])),e.analyze("Finish Face:"),((z=e.config.face.ssrnet)==null?void 0:z.enabled)&&A&&s&&(l={...l,age:A.age,gender:s.gender,genderScore:s.genderScore}),((m0=e.config.face.gear)==null?void 0:m0.enabled)&&n&&(l={...l,age:n.age,gender:n.gender,genderScore:n.genderScore,race:n.race}),((B0=e.config.face.mobilefacenet)==null?void 0:B0.enabled)&&i&&(l.descriptor=i),(T=e.config.face.iris)!=null&&T.enabled;let Y=c[k].annotations&&c[k].annotations.leftEyeIris&&c[k].annotations.leftEyeIris[0]&&c[k].annotations.rightEyeIris&&c[k].annotations.rightEyeIris[0]&&c[k].annotations.leftEyeIris.length>0&&c[k].annotations.rightEyeIris.length>0&&c[k].annotations.leftEyeIris[0]!==null&&c[k].annotations.rightEyeIris[0]!==null?Math.max(Math.abs(c[k].annotations.leftEyeIris[3][0]-c[k].annotations.leftEyeIris[1][0]),Math.abs(c[k].annotations.rightEyeIris[4][1]-c[k].annotations.rightEyeIris[2][1]))/t.shape[2]:0,e0=(Q=e.config.face.detector)!=null&&Q.return?r.squeeze(c[k].tensor):null;r.dispose(c[k].tensor),c[k].tensor&&delete c[k].tensor;let I={...c[k],id:k};l!=null&&l.age&&(I.age=l.age),l!=null&&l.gender&&(I.gender=l.gender),l!=null&&l.genderScore&&(I.genderScore=l==null?void 0:l.genderScore),l!=null&&l.descriptor&&(I.embedding=l==null?void 0:l.descriptor),l!=null&&l.race&&(I.race=l==null?void 0:l.race),a&&(I.emotion=a),x&&(I.real=x),d&&(I.live=d),Y&&Y!==0&&(I.iris=Math.trunc(500/Y/11.7)/100),X&&(I.rotation=X),e0&&(I.tensor=e0),y.push(I),e.analyze("End Face")}return e.analyze("End FaceMesh:"),e.config.async&&(e.performance.face&&delete e.performance.face,e.performance.age&&delete e.performance.age,e.performance.gender&&delete e.performance.gender,e.performance.emotion&&delete e.performance.emotion),y};var $n=e=>{if(!e)return[];let t=[];for(let o=0;ox.part==="leftWrist"),n=e[o].keypoints.find(x=>x.part==="rightWrist"),s=e[o].keypoints.find(x=>x.part==="nose");s&&A&&n&&A.position[1]x.part==="leftShoulder"),i=e[o].keypoints.find(x=>x.part==="rightShoulder");a&&i&&Math.abs(a.positionRaw[1]-i.positionRaw[1])>.1&&t.push({body:o,gesture:`leaning ${a.position[1]>i.position[1]?"left":"right"}`})}return t},er=e=>{if(!e)return[];let t=[];for(let o=0;o450){let A=(e[o].mesh[33][2]||0)-(e[o].mesh[263][2]||0),n=e[o].mesh[33][0]-e[o].mesh[263][0];Math.abs(A/n)<=.15?t.push({face:o,gesture:"facing center"}):t.push({face:o,gesture:`facing ${A<0?"left":"right"}`}),Math.abs(e[o].mesh[374][1]-e[o].mesh[386][1])/Math.abs(e[o].mesh[443][1]-e[o].mesh[450][1])<.2&&t.push({face:o,gesture:"blink left eye"}),Math.abs(e[o].mesh[145][1]-e[o].mesh[159][1])/Math.abs(e[o].mesh[223][1]-e[o].mesh[230][1])<.2&&t.push({face:o,gesture:"blink right eye"});let i=Math.min(100,500*Math.abs(e[o].mesh[13][1]-e[o].mesh[14][1])/Math.abs(e[o].mesh[10][1]-e[o].mesh[152][1]));i>10&&t.push({face:o,gesture:`mouth ${Math.trunc(i)}% open`});let x=e[o].mesh[152][2]||0;Math.abs(x)>10&&t.push({face:o,gesture:`head ${x<0?"up":"down"}`})}return t},tr=e=>{if(!e)return[];let t=[];for(let o=0;o.06||c>.06)&&(d=!1),y>c?y>.05&&t.push({iris:o,gesture:"looking right"}):c>.05&&t.push({iris:o,gesture:"looking left"});let f=Math.abs(e[o].mesh[145][1]-e[o].annotations.rightEyeIris[0][1])/e[o].box[3],h=Math.abs(e[o].mesh[374][1]-e[o].annotations.leftEyeIris[0][1])/e[o].box[3];(h<.01||f<.01||h>.022||f>.022)&&(d=!1),(h<.01||f<.01)&&t.push({iris:o,gesture:"looking down"}),(h>.022||f>.022)&&t.push({iris:o,gesture:"looking up"}),d&&t.push({iris:o,gesture:"looking center"})}return t},or=e=>{if(!e)return[];let t=[];for(let o=0;o0){let n=A.reduce((a,i)=>(a.position[2]||0)<(i.position[2]||0)?a:i);t.push({hand:o,gesture:`${n.name} forward`});let s=A.reduce((a,i)=>a.position[1]((n-1)*j.body[T].box[F]+I)/n),k=e.body[T].boxRaw.map((I,F)=>((n-1)*j.body[T].boxRaw[F]+I)/n),X=e.body[T].keypoints.map((I,F)=>{var E0,z0,Re,ke,se,uo,ho,bo,go;return{score:I.score,part:I.part,position:[j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].position[0]||0)+(I.position[0]||0))/n:I.position[0],j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].position[1]||0)+(I.position[1]||0))/n:I.position[1],j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].position[2]||0)+(I.position[2]||0))/n:I.position[2]],positionRaw:[j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].positionRaw[0]||0)+(I.positionRaw[0]||0))/n:I.positionRaw[0],j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].positionRaw[1]||0)+(I.positionRaw[1]||0))/n:I.positionRaw[1],j.body[T].keypoints[F]?((n-1)*(j.body[T].keypoints[F].positionRaw[2]||0)+(I.positionRaw[2]||0))/n:I.positionRaw[2]],distance:[j.body[T].keypoints[F]?((n-1)*(((E0=j.body[T].keypoints[F].distance)==null?void 0:E0[0])||0)+(((z0=I.distance)==null?void 0:z0[0])||0))/n:(Re=I.distance)==null?void 0:Re[0],j.body[T].keypoints[F]?((n-1)*(((ke=j.body[T].keypoints[F].distance)==null?void 0:ke[1])||0)+(((se=I.distance)==null?void 0:se[1])||0))/n:(uo=I.distance)==null?void 0:uo[1],j.body[T].keypoints[F]?((n-1)*(((ho=j.body[T].keypoints[F].distance)==null?void 0:ho[2])||0)+(((bo=I.distance)==null?void 0:bo[2])||0))/n:(go=I.distance)==null?void 0:go[2]]}}),Y={},e0={connected:{}};(i=(a=t.body)==null?void 0:a.modelPath)!=null&&i.includes("efficientpose")?e0=st:(d=(x=t.body)==null?void 0:x.modelPath)!=null&&d.includes("blazepose")?e0=tt:(y=(l=t.body)==null?void 0:l.modelPath)!=null&&y.includes("movenet")&&(e0=Ge);for(let[I,F]of Object.entries(e0.connected)){let E0=[];for(let z0=0;z0se.part===F[z0]),ke=X.find(se=>se.part===F[z0+1]);Re&&ke&&E0.push([Re.position,ke.position])}Y[I]=E0}j.body[T]={...e.body[T],box:Q,boxRaw:k,keypoints:X,annotations:Y}}if(!j.hand||e.hand.length!==j.hand.length)j.hand=JSON.parse(JSON.stringify(e.hand));else for(let T=0;T((n-1)*j.hand[T].box[I]+e0)/n),k=e.hand[T].boxRaw.map((e0,I)=>((n-1)*j.hand[T].boxRaw[I]+e0)/n);j.hand[T].keypoints.length!==e.hand[T].keypoints.length&&(j.hand[T].keypoints=e.hand[T].keypoints);let X=e.hand[T].keypoints&&e.hand[T].keypoints.length>0?e.hand[T].keypoints.map((e0,I)=>e0.map((F,E0)=>((n-1)*(j.hand[T].keypoints[I][E0]||1)+(F||0))/n)):[],Y={};if(Object.keys(j.hand[T].annotations).length!==Object.keys(e.hand[T].annotations).length)j.hand[T].annotations=e.hand[T].annotations,Y=j.hand[T].annotations;else if(e.hand[T].annotations)for(let e0 of Object.keys(e.hand[T].annotations))Y[e0]=e.hand[T].annotations[e0]&&e.hand[T].annotations[e0][0]?e.hand[T].annotations[e0].map((I,F)=>I.map((E0,z0)=>((n-1)*j.hand[T].annotations[e0][F][z0]+E0)/n)):null;j.hand[T]={...e.hand[T],box:Q,boxRaw:k,keypoints:X,annotations:Y}}if(!j.face||e.face.length!==j.face.length)j.face=JSON.parse(JSON.stringify(e.face));else for(let T=0;T((n-1)*j.face[T].box[Y]+X)/n),k=e.face[T].boxRaw.map((X,Y)=>((n-1)*j.face[T].boxRaw[Y]+X)/n);if(e.face[T].rotation){let X={matrix:[0,0,0,0,0,0,0,0,0],angle:{roll:0,yaw:0,pitch:0},gaze:{bearing:0,strength:0}};X.matrix=(c=e.face[T].rotation)==null?void 0:c.matrix,X.angle={roll:((n-1)*(((h=(f=j.face[T].rotation)==null?void 0:f.angle)==null?void 0:h.roll)||0)+(((v=(m=e.face[T].rotation)==null?void 0:m.angle)==null?void 0:v.roll)||0))/n,yaw:((n-1)*(((P=(b=j.face[T].rotation)==null?void 0:b.angle)==null?void 0:P.yaw)||0)+(((u=(p=e.face[T].rotation)==null?void 0:p.angle)==null?void 0:u.yaw)||0))/n,pitch:((n-1)*(((W=(E=j.face[T].rotation)==null?void 0:E.angle)==null?void 0:W.pitch)||0)+(((S=(C=e.face[T].rotation)==null?void 0:C.angle)==null?void 0:S.pitch)||0))/n},X.gaze={bearing:((n-1)*(((V=(O=j.face[T].rotation)==null?void 0:O.gaze)==null?void 0:V.bearing)||0)+(((H=(G=e.face[T].rotation)==null?void 0:G.gaze)==null?void 0:H.bearing)||0))/n,strength:((n-1)*(((z=(t0=j.face[T].rotation)==null?void 0:t0.gaze)==null?void 0:z.strength)||0)+(((B0=(m0=e.face[T].rotation)==null?void 0:m0.gaze)==null?void 0:B0.strength)||0))/n},j.face[T]={...e.face[T],rotation:X,box:Q,boxRaw:k}}j.face[T]={...e.face[T],box:Q,boxRaw:k}}if(!j.object||e.object.length!==j.object.length)j.object=JSON.parse(JSON.stringify(e.object));else for(let T=0;T((n-1)*j.object[T].box[Y]+X)/n),k=e.object[T].boxRaw.map((X,Y)=>((n-1)*j.object[T].boxRaw[Y]+X)/n);j.object[T]={...e.object[T],box:Q,boxRaw:k}}if(e.persons){let T=e.persons;if(!j.persons||T.length!==j.persons.length)j.persons=JSON.parse(JSON.stringify(T));else for(let Q=0;Q((n-1)*j.persons[Q].box[X]+k)/n)}e.gesture&&(j.gesture=e.gesture);let s=M();return fo=w.perfadd?fo+Math.round(s-o):Math.round(s-o),e.performance&&(j.performance={...e.performance,interpolate:fo}),j}var rr={};K0(rr,{distance:()=>Ze,match:()=>po,similarity:()=>mo});function Ze(e,t,o={order:2,multiplier:25}){let A=0;for(let n=0;n{if(e===0)return 1;let n=t===2?Math.sqrt(e):e**(1/t),s=(1-n/100-o)/(A-o);return Math.max(Math.min(s,1),0)};function mo(e,t,o={order:2,multiplier:25,min:.2,max:.8}){let A=Ze(e,t,o);return nr(A,o.order||2,o.min||0,o.max||1)}function po(e,t,o={order:2,multiplier:25,threshold:0,min:.2,max:.8}){if(!Array.isArray(e)||!Array.isArray(t)||e.length<64||t.length===0||e.length!==t[0].length)return{index:-1,distance:Number.POSITIVE_INFINITY,similarity:0};let A=Number.MAX_SAFE_INTEGER,n=-1;for(let a=0;az.box[0]&&C.box[0]z.box[1]&&C.box[1]+C.box[3]S.body.box[0]&&z.box[0]+z.box[2]S.body.box[1]&&z.box[1]+z.box[3]S.body.box[0]&&z.box[1]+z.box[3]>S.body.box[1]&&z.box[1]+z.box[3]{z&&z.length===4&&(O.push(z[0],z[0]+z[2]),V.push(z[1],z[1]+z[3]))};G((b=S.face)==null?void 0:b.box),G((P=S.body)==null?void 0:P.box),G((u=(p=S.hands)==null?void 0:p.left)==null?void 0:u.box),G((W=(E=S.hands)==null?void 0:E.right)==null?void 0:W.box);let H=Math.min(...O),t0=Math.min(...V);S.box=[H,t0,Math.max(...O)-H,Math.max(...V)-t0],n&&n[1]&&n[2]&&(S.boxRaw=[S.box[0]/n[2],S.box[1]/n[1],S.box[2]/n[2],S.box[3]/n[1]]),a.push(S)}return a}var It=` /9j/4AAQSkZJRgABAQEAYABgAAD/4QBoRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUA AAABAAAARgEoAAMAAAABAAIAAAExAAIAAAARAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQu bmV0IDQuMi4xMwAA/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBgXFBYWGh0lHxob @@ -259,7 +259,7 @@ PQ4GJ+ashuK0MhWaoWcA0AaOmASMK7jRNPWYBmHyiuepO2x10qfcv6vYxCzYqoGK4HVYVTJrmb5l c6oaM5TUJ8EgGsG4kLNUHT0M64OaqMMikSRsuKbnFMRLG3zVehOaGNE445NNlnVFpDMu6uie9Vo1 8z5mOAOST2pDK91cNN+5tsrH3PrW54a06KxT7fdrlh/q1Pc+tJ6IUdZGvHPLezMcnBOWbsPap5r3 ylFtbdT1xUWNWzU0/Zbwlgfmx8zGsHWtRHmMqE59aAMyNifvHPc1f0gtPdqkY5JosJHeNci2tktY -euPnNY+oXWZEVJNrZ9aun8SIq/CzodHuriIokhDIR1ronbKZr0o6o8ipoz//2Q==`,Wt=` +euPnNY+oXWZEVJNrZ9aun8SIq/CzodHuriIokhDIR1ronbKZr0o6o8ipoz//2Q==`,Ot=` /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAsICAoIBwsKCQoNDAsNERwSEQ8PESIZGhQcKSQrKigk JyctMkA3LTA9MCcnOEw5PUNFSElIKzZPVU5GVEBHSEX/2wBDAQwNDREPESESEiFFLicuRUVFRUVF RUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUX/wAARCASwBLADASIA @@ -827,7 +827,7 @@ AAAAAAJAAAAAAAAAAAAAABAJEAAAAAAAAAAAAAAAIEoBKAAAAAAAAAAAAAAABAlAAAAAAAIAAAAA BAkBAkBAkBAlACEgMZjdjbFW8bWrEx8YWANb6Fp+bfwab+vLDKMFK9qxH5L0bAr8OPRPKz2AY7J2 SbAjYZAI2E7AIEgIEgIEgMdkSy2NgY7MdlmyNoBXsxmFuyNgVTVjNV3KjlBRNTlXTVHKCrlIqt5T lBhEMohlFerLlBjEMohMVTEARDKCITsAk2AEgAAAkAAAAAAAAAAAAAAAAAAAAAAAASAAAAAAAAD/ -2Q==`;async function D2(e){let t=(n,s="application/octet-stream")=>fetch(`data:${s};base64,${n}`).then(a=>a.blob()),o,A;switch(e.config.warmup){case"face":o=await t(St);break;case"body":case"full":o=await t(Wt);break;default:o=null}if(o){let n=await createImageBitmap(o);A=await e.detect(n,e.config),n.close()}return A}async function q2(e){return new Promise(t=>{let o;switch(e.config.warmup){case"face":o="data:image/jpeg;base64,"+St;break;case"full":case"body":o="data:image/jpeg;base64,"+Wt;break;default:o=null}let A;if(typeof Image!="undefined")A=new Image;else if(w.Image)A=new w.Image;else return;A.onload=async()=>{let n=s0(A.naturalWidth,A.naturalHeight);if(!n)g("Warmup: Canvas not found"),t(void 0);else{let s=n.getContext("2d");s&&s.drawImage(A,0,0);let a=await e.image(n),i=await e.detect(a.tensor,e.config);t(i)}},o?A.src=o:t(void 0)})}async function U2(e){let t=n=>Buffer.from(n,"base64"),o;e.config.warmup==="face"?o=t(St):o=t(Wt);let A;if("node"in r){let n=r.node.decodeJpeg(o),s=n.expandDims(0);e.tf.dispose(n),A=await e.detect(s,e.config),e.tf.dispose(s)}else e.config.debug&&g("Warmup tfjs-node not loaded");return A}async function J2(e){let t;return typeof createImageBitmap=="function"?t=await D2(e):typeof Image!="undefined"||w.Canvas!==void 0?t=await q2(e):t=await U2(e),t}async function ar(e,t){let o=M();return e.state="warmup",t&&(e.config=o0(e.config,t)),!e.config.warmup||e.config.warmup.length===0||e.config.warmup==="none"?{face:[],body:[],hand:[],gesture:[],object:[],performance:e.performance,timestamp:M(),persons:[],error:null}:new Promise(async A=>{let n=await J2(e),s=M();e.config.debug&&g("warmup",e.config.warmup,Math.round(s-o),"ms"),e.emit("warmup"),A(n)})}var we,Ze,Xe,Ct,K2=class{constructor(t){R(this,"version");R(this,"config");R(this,"result");R(this,"state");R(this,"process");R(this,"tf");R(this,"env");R(this,"draw");R(this,"models");R(this,"events");R(this,"faceTriangulation");R(this,"faceUVMap");R(this,"performance");ze(this,we,void 0);ze(this,Ze,void 0);ze(this,Xe,void 0);R(this,"gl");R(this,"analyze",(...t)=>{if(!Ee(this,Ze))return;let o=this.tf.engine().state.numTensors,A=Ee(this,we);je(this,we,o);let n=o-A;n!==0&&g(...t,n)});ze(this,Ct,t=>{if(!Ee(this,Xe))return null;if(!t)return"input is not defined";if(this.env.node&&!(t instanceof ae))return"input must be a tensor";try{this.tf.getBackend()}catch(o){return"backend not loaded"}return null});R(this,"similarity",co);R(this,"distance",Ve);R(this,"match",fo);R(this,"emit",t=>{var o;this.events&&this.events.dispatchEvent&&((o=this.events)==null||o.dispatchEvent(new Event(t)))});this.env=w,K0.wasmPath=Se["tfjs-core"].includes("-")?"https://vladmandic.github.io/tfjs/dist/":`https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${r.version_core}/dist/`,K0.modelBasePath=w.browser?"../models/":"file://models/",K0.backend=w.browser?"humangl":"tensorflow",this.version=Bt,Object.defineProperty(this,"version",{value:Bt}),this.config=JSON.parse(JSON.stringify(K0)),Object.seal(this.config),this.config.cacheModels=typeof indexedDB!="undefined",t&&(this.config=o0(this.config,t)),Co(this.config),this.tf=r,this.state="idle",je(this,we,0),je(this,Ze,!1),je(this,Xe,!1),this.performance={},this.events=typeof EventTarget!="undefined"?new EventTarget:void 0,this.models=new vt,this.draw={options:k0,canvas:(o,A)=>ao(o,A),face:(o,A,n)=>kt(o,A,n),body:(o,A,n)=>Et(o,A,n),hand:(o,A,n)=>zt(o,A,n),gesture:(o,A,n)=>Rt(o,A,n),object:(o,A,n)=>jt(o,A,n),person:(o,A,n)=>so(o,A,n),all:(o,A,n)=>io(o,A,n)},this.result={face:[],body:[],hand:[],gesture:[],object:[],performance:{},timestamp:0,persons:[],error:null},this.process={tensor:null,canvas:null},this.faceTriangulation=ZA,this.faceUVMap=XA,this.gl=q,this.emit("create")}reset(){let t=this.config.backend;this.config=JSON.parse(JSON.stringify(K0)),this.config.backend=t}validate(t){return Ot(K0,t||this.config)}now(){return M()}image(t,o=!0){return le(t,this.config,o)}async segmentation(t,o){return Xn(t,o,this.config)}enhance(t){return v5(t)}compare(t,o){return So(this.config,t,o)}async init(){await wt(this,!0),await this.tf.ready()}async load(t){this.state="load";let o=M(),A=Object.values(this.models).filter(a=>a).length;t&&(this.config=o0(this.config,t)),this.env.initial&&(this.config.debug&&g(`version: ${this.version}`),this.config.debug&&g(`tfjs version: ${this.tf.version["tfjs-core"]}`),await wt(this)||g("error: backend check failed"),await r.ready(),this.env.browser&&(this.config.debug&&g("configuration:",this.config),this.config.debug&&g("environment:",this.env),this.config.debug&&g("tf flags:",this.tf.ENV.flags))),await to(this),this.env.initial&&this.config.debug&&g("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),this.env.initial=!1,Object.values(this.models).filter(a=>a).length!==A&&(await oo(this),this.emit("load"));let s=Math.trunc(M()-o);s>(this.performance.loadModels||0)&&(this.performance.loadModels=this.env.perfadd?(this.performance.loadModels||0)+s:s)}next(t=this.result){return Ar(t,this.config)}async warmup(t){let o=M(),A=await ar(this,t),n=M();return this.performance.warmup=Math.trunc(n-o),A}async profile(t,o){let A=await this.tf.profile(()=>this.detect(t,o)),n={};for(let i of A.kernels)n[i.name]?n[i.name]+=i.kernelTimeMs:n[i.name]=i.kernelTimeMs;let s=[];Object.entries(n).forEach(i=>s.push({name:i[0],ms:i[1]})),s.sort((i,x)=>x.ms-i.ms),s.length=20;let a={};for(let i of s)a[i.name]=i.ms;return a}async detect(t,o){return this.state="detect",new Promise(async A=>{var v,b,P,p,u,E,W,C,S,O,V,G,H,t0,z,m0,B0,T,Q,k,X,Y;this.state="config";let n;this.config=o0(this.config,o),this.state="check";let s=Ee(this,Ct).call(this,t);s&&(g(s,t),this.emit("error"),A({face:[],body:[],hand:[],gesture:[],object:[],performance:this.performance,timestamp:M(),persons:[],error:s}));let a=M();await wt(this),await this.load(),n=M(),this.state="image";let i=await le(t,this.config);if(this.process=i,this.performance.inputProcess=this.env.perfadd?(this.performance.inputProcess||0)+Math.trunc(M()-n):Math.trunc(M()-n),this.analyze("Get Image:"),!i.tensor){this.config.debug&&g("could not convert input to tensor"),this.emit("error"),A({face:[],body:[],hand:[],gesture:[],object:[],performance:this.performance,timestamp:M(),persons:[],error:"could not convert input to tensor"});return}this.emit("image"),n=M(),this.config.skipAllowed=await jo(this.config,i.tensor),this.performance.totalFrames||(this.performance.totalFrames=0),this.performance.cachedFrames||(this.performance.cachedFrames=0),this.performance.totalFrames++,this.config.skipAllowed&&this.performance.cachedFrames++,this.performance.cacheCheck=this.env.perfadd?(this.performance.cacheCheck||0)+Math.trunc(M()-n):Math.trunc(M()-n),this.analyze("Check Changed:");let x=[],d=[],l=[],y=[];this.state="detect:face",this.config.async?(x=this.config.face.enabled?yo(this,i.tensor):[],this.performance.face&&delete this.performance.face):(n=M(),x=this.config.face.enabled?await yo(this,i.tensor):[],this.performance.face=this.env.perfadd?(this.performance.face||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.config.async&&(this.config.body.maxDetected===-1||this.config.hand.maxDetected===-1)&&(x=await x),this.analyze("Start Body:"),this.state="detect:body";let c=this.config.body.maxDetected===-1?o0(this.config,{body:{maxDetected:this.config.face.enabled?1*x.length:1}}):this.config;this.config.async?((v=this.config.body.modelPath)!=null&&v.includes("posenet")?d=this.config.body.enabled?_5(i.tensor,c):[]:(b=this.config.body.modelPath)!=null&&b.includes("blazepose")?d=this.config.body.enabled?a5(i.tensor,c):[]:(P=this.config.body.modelPath)!=null&&P.includes("efficientpose")?d=this.config.body.enabled?f5(i.tensor,c):[]:(p=this.config.body.modelPath)!=null&&p.includes("movenet")&&(d=this.config.body.enabled?X5(i.tensor,c):[]),this.performance.body&&delete this.performance.body):(n=M(),(u=this.config.body.modelPath)!=null&&u.includes("posenet")?d=this.config.body.enabled?await _5(i.tensor,c):[]:(E=this.config.body.modelPath)!=null&&E.includes("blazepose")?d=this.config.body.enabled?await a5(i.tensor,c):[]:(W=this.config.body.modelPath)!=null&&W.includes("efficientpose")?d=this.config.body.enabled?await f5(i.tensor,c):[]:(C=this.config.body.modelPath)!=null&&C.includes("movenet")&&(d=this.config.body.enabled?await X5(i.tensor,c):[]),this.performance.body=this.env.perfadd?(this.performance.body||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.state="detect:hand";let f=this.config.hand.maxDetected===-1?o0(this.config,{hand:{maxDetected:this.config.face.enabled?2*x.length:1}}):this.config;this.config.async?((O=(S=this.config.hand.detector)==null?void 0:S.modelPath)!=null&&O.includes("handdetect")?l=this.config.hand.enabled?W5(i.tensor,f):[]:(G=(V=this.config.hand.detector)==null?void 0:V.modelPath)!=null&&G.includes("handtrack")&&(l=this.config.hand.enabled?N5(i.tensor,f):[]),this.performance.hand&&delete this.performance.hand):(n=M(),(t0=(H=this.config.hand.detector)==null?void 0:H.modelPath)!=null&&t0.includes("handdetect")?l=this.config.hand.enabled?await W5(i.tensor,f):[]:(m0=(z=this.config.hand.detector)==null?void 0:z.modelPath)!=null&&m0.includes("handtrack")&&(l=this.config.hand.enabled?await N5(i.tensor,f):[]),this.performance.hand=this.env.perfadd?(this.performance.hand||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.state="detect:object",this.config.async?((B0=this.config.object.modelPath)!=null&&B0.includes("nanodet")?y=this.config.object.enabled?q5(i.tensor,this.config):[]:(T=this.config.object.modelPath)!=null&&T.includes("centernet")&&(y=this.config.object.enabled?y5(i.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(n=M(),(Q=this.config.object.modelPath)!=null&&Q.includes("nanodet")?y=this.config.object.enabled?await q5(i.tensor,this.config):[]:(k=this.config.object.modelPath)!=null&&k.includes("centernet")&&(y=this.config.object.enabled?await y5(i.tensor,this.config):[]),this.performance.object=this.env.perfadd?(this.performance.object||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.analyze("End Object:"),this.state="detect:await",this.config.async&&([x,d,l,y]=await Promise.all([x,d,l,y])),this.state="detect:gesture";let h=[];this.config.gesture.enabled&&(n=M(),h=[...er(x),...$n(d),...or(l),...tr(x)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=this.env.perfadd?(this.performance.gesture||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.performance.total=this.env.perfadd?(this.performance.total||0)+Math.trunc(M()-a):Math.trunc(M()-a);let m=((Y=(X=this.process)==null?void 0:X.tensor)==null?void 0:Y.shape)||[];this.result={face:x,body:d,hand:l,gesture:h,object:y,performance:this.performance,canvas:this.process.canvas,timestamp:Date.now(),error:null,get persons(){return sr(x,d,l,h,m)}},r.dispose(i.tensor),this.emit("detect"),this.state="idle",A(this.result)})}};we=new WeakMap,Ze=new WeakMap,Xe=new WeakMap,Ct=new WeakMap;export{K2 as Human,K2 as default,K0 as defaults,Kn as draw,w as env,rr as match,Ao as models}; +2Q==`;async function q2(e){let t=(n,s="application/octet-stream")=>fetch(`data:${s};base64,${n}`).then(a=>a.blob()),o,A;switch(e.config.warmup){case"face":o=await t(It);break;case"body":case"full":o=await t(Ot);break;default:o=null}if(o){let n=await createImageBitmap(o);A=await e.detect(n,e.config),n.close()}return A}async function U2(e){return new Promise(t=>{let o;switch(e.config.warmup){case"face":o="data:image/jpeg;base64,"+It;break;case"full":case"body":o="data:image/jpeg;base64,"+Ot;break;default:o=null}let A;if(typeof Image!="undefined")A=new Image;else if(w.Image)A=new w.Image;else return;A.onload=async()=>{let n=s0(A.naturalWidth,A.naturalHeight);if(!n)g("Warmup: Canvas not found"),t(void 0);else{let s=n.getContext("2d");s&&s.drawImage(A,0,0);let a=await e.image(n),i=await e.detect(a.tensor,e.config);t(i)}},o?A.src=o:t(void 0)})}async function J2(e){let t=n=>Buffer.from(n,"base64"),o;e.config.warmup==="face"?o=t(It):o=t(Ot);let A;if("node"in r){let n=r.node.decodeJpeg(o),s=n.expandDims(0);e.tf.dispose(n),A=await e.detect(s,e.config),e.tf.dispose(s)}else e.config.debug&&g("Warmup tfjs-node not loaded");return A}async function Y2(e){let t;return typeof createImageBitmap=="function"?t=await q2(e):typeof Image!="undefined"||w.Canvas!==void 0?t=await U2(e):t=await J2(e),t}async function ar(e,t){let o=M();return e.state="warmup",t&&(e.config=o0(e.config,t)),!e.config.warmup||e.config.warmup.length===0||e.config.warmup==="none"?{face:[],body:[],hand:[],gesture:[],object:[],performance:e.performance,timestamp:M(),persons:[],error:null}:new Promise(async A=>{let n=await Y2(e),s=M();e.config.debug&&g("warmup",e.config.warmup,Math.round(s-o),"ms"),e.emit("warmup"),A(n)})}var we,Xe,De,Nt,ir=class{constructor(t){R(this,"version");R(this,"config");R(this,"result");R(this,"state");R(this,"process");R(this,"tf");R(this,"env");R(this,"draw");R(this,"models");R(this,"events");R(this,"faceTriangulation");R(this,"faceUVMap");R(this,"performance");ze(this,we,void 0);ze(this,Xe,void 0);ze(this,De,void 0);R(this,"gl");R(this,"analyze",(...t)=>{if(!Ee(this,Xe))return;let o=this.tf.engine().state.numTensors,A=Ee(this,we);je(this,we,o);let n=o-A;n!==0&&g(...t,n)});ze(this,Nt,t=>{if(!Ee(this,De))return null;if(!t)return"input is not defined";if(this.env.node&&!(t instanceof ae))return"input must be a tensor";try{this.tf.getBackend()}catch(o){return"backend not loaded"}return null});R(this,"similarity",mo);R(this,"distance",Ze);R(this,"match",po);R(this,"emit",t=>{var o;this.events&&this.events.dispatchEvent&&((o=this.events)==null||o.dispatchEvent(new Event(t)))});this.env=w,Q0.wasmPath=Se["tfjs-core"].includes("-")?"https://vladmandic.github.io/tfjs/dist/":`https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${r.version_core}/dist/`,Q0.modelBasePath=w.browser?"../models/":"file://models/",Q0.backend=w.browser?"humangl":"tensorflow",this.version=Xt,Object.defineProperty(this,"version",{value:Xt}),this.config=JSON.parse(JSON.stringify(Q0)),Object.seal(this.config),this.config.cacheModels=typeof indexedDB!="undefined",t&&(this.config=o0(this.config,t)),Co(this.config),this.tf=r,this.state="idle",je(this,we,0),je(this,Xe,!1),je(this,De,!1),this.performance={},this.events=typeof EventTarget!="undefined"?new EventTarget:void 0,this.models=new Fe,this.draw={options:k0,canvas:(o,A)=>lo(o,A),face:(o,A,n)=>jt(o,A,n),body:(o,A,n)=>St(o,A,n),hand:(o,A,n)=>Wt(o,A,n),gesture:(o,A,n)=>zt(o,A,n),object:(o,A,n)=>Ct(o,A,n),person:(o,A,n)=>io(o,A,n),all:(o,A,n)=>yo(o,A,n)},this.result={face:[],body:[],hand:[],gesture:[],object:[],performance:{},timestamp:0,persons:[],error:null},this.process={tensor:null,canvas:null},this.faceTriangulation=ZA,this.faceUVMap=XA,this.gl=q,this.emit("create")}reset(){let t=this.config.backend;this.config=JSON.parse(JSON.stringify(Q0)),this.config.backend=t}validate(t){return Gt(Q0,t||this.config)}now(){return M()}image(t,o=!0){return le(t,this.config,o)}async segmentation(t,o){return Xn(t,o,this.config)}enhance(t){return E5(t)}compare(t,o){return Wo(this.config,t,o)}async init(){await Et(this,!0),await this.tf.ready()}async load(t){this.state="load";let o=M(),A=Object.values(this.models).filter(a=>a).length;t&&(this.config=o0(this.config,t)),this.env.initial&&(this.config.debug&&g(`version: ${this.version}`),this.config.debug&&g(`tfjs version: ${this.tf.version["tfjs-core"]}`),await Et(this)||g("error: backend check failed"),await r.ready(),this.env.browser&&(this.config.debug&&g("configuration:",this.config),this.config.debug&&g("environment:",this.env),this.config.debug&&g("tf flags:",this.tf.ENV.flags))),await Ao(this),this.env.initial&&this.config.debug&&g("tf engine state:",this.tf.engine().state.numBytes,"bytes",this.tf.engine().state.numTensors,"tensors"),this.env.initial=!1,Object.values(this.models).filter(a=>a).length!==A&&(await no(this),this.emit("load"));let s=Math.trunc(M()-o);s>(this.performance.loadModels||0)&&(this.performance.loadModels=this.env.perfadd?(this.performance.loadModels||0)+s:s)}next(t=this.result){return Ar(t,this.config)}async warmup(t){let o=M(),A=await ar(this,t),n=M();return this.performance.warmup=Math.trunc(n-o),A}async profile(t,o){let A=await this.tf.profile(()=>this.detect(t,o)),n={};for(let i of A.kernels)n[i.name]?n[i.name]+=i.kernelTimeMs:n[i.name]=i.kernelTimeMs;let s=[];Object.entries(n).forEach(i=>s.push({name:i[0],ms:i[1]})),s.sort((i,x)=>x.ms-i.ms),s.length=20;let a={};for(let i of s)a[i.name]=i.ms;return a}async detect(t,o){return this.state="detect",new Promise(async A=>{var v,b,P,p,u,E,W,C,S,O,V,G,H,t0,z,m0,B0,T,Q,k,X,Y;this.state="config";let n;this.config=o0(this.config,o),this.state="check";let s=Ee(this,Nt).call(this,t);s&&(g(s,t),this.emit("error"),A({face:[],body:[],hand:[],gesture:[],object:[],performance:this.performance,timestamp:M(),persons:[],error:s}));let a=M();await Et(this),await this.load(),n=M(),this.state="image";let i=await le(t,this.config);if(this.process=i,this.performance.inputProcess=this.env.perfadd?(this.performance.inputProcess||0)+Math.trunc(M()-n):Math.trunc(M()-n),this.analyze("Get Image:"),!i.tensor){this.config.debug&&g("could not convert input to tensor"),this.emit("error"),A({face:[],body:[],hand:[],gesture:[],object:[],performance:this.performance,timestamp:M(),persons:[],error:"could not convert input to tensor"});return}this.emit("image"),n=M(),this.config.skipAllowed=await So(this.config,i.tensor),this.performance.totalFrames||(this.performance.totalFrames=0),this.performance.cachedFrames||(this.performance.cachedFrames=0),this.performance.totalFrames++,this.config.skipAllowed&&this.performance.cachedFrames++,this.performance.cacheCheck=this.env.perfadd?(this.performance.cacheCheck||0)+Math.trunc(M()-n):Math.trunc(M()-n),this.analyze("Check Changed:");let x=[],d=[],l=[],y=[];this.state="detect:face",this.config.async?(x=this.config.face.enabled?co(this,i.tensor):[],this.performance.face&&delete this.performance.face):(n=M(),x=this.config.face.enabled?await co(this,i.tensor):[],this.performance.face=this.env.perfadd?(this.performance.face||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.config.async&&(this.config.body.maxDetected===-1||this.config.hand.maxDetected===-1)&&(x=await x),this.analyze("Start Body:"),this.state="detect:body";let c=this.config.body.maxDetected===-1?o0(this.config,{body:{maxDetected:this.config.face.enabled?1*x.length:1}}):this.config;this.config.async?((v=this.config.body.modelPath)!=null&&v.includes("posenet")?d=this.config.body.enabled?eo(i.tensor,c):[]:(b=this.config.body.modelPath)!=null&&b.includes("blazepose")?d=this.config.body.enabled?c5(i.tensor,c):[]:(P=this.config.body.modelPath)!=null&&P.includes("efficientpose")?d=this.config.body.enabled?b5(i.tensor,c):[]:(p=this.config.body.modelPath)!=null&&p.includes("movenet")&&(d=this.config.body.enabled?U5(i.tensor,c):[]),this.performance.body&&delete this.performance.body):(n=M(),(u=this.config.body.modelPath)!=null&&u.includes("posenet")?d=this.config.body.enabled?await eo(i.tensor,c):[]:(E=this.config.body.modelPath)!=null&&E.includes("blazepose")?d=this.config.body.enabled?await c5(i.tensor,c):[]:(W=this.config.body.modelPath)!=null&&W.includes("efficientpose")?d=this.config.body.enabled?await b5(i.tensor,c):[]:(C=this.config.body.modelPath)!=null&&C.includes("movenet")&&(d=this.config.body.enabled?await U5(i.tensor,c):[]),this.performance.body=this.env.perfadd?(this.performance.body||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.analyze("End Body:"),this.analyze("Start Hand:"),this.state="detect:hand";let f=this.config.hand.maxDetected===-1?o0(this.config,{hand:{maxDetected:this.config.face.enabled?2*x.length:1}}):this.config;this.config.async?((O=(S=this.config.hand.detector)==null?void 0:S.modelPath)!=null&&O.includes("handdetect")?l=this.config.hand.enabled?O5(i.tensor,f):[]:(G=(V=this.config.hand.detector)==null?void 0:V.modelPath)!=null&&G.includes("handtrack")&&(l=this.config.hand.enabled?B5(i.tensor,f):[]),this.performance.hand&&delete this.performance.hand):(n=M(),(t0=(H=this.config.hand.detector)==null?void 0:H.modelPath)!=null&&t0.includes("handdetect")?l=this.config.hand.enabled?await O5(i.tensor,f):[]:(m0=(z=this.config.hand.detector)==null?void 0:z.modelPath)!=null&&m0.includes("handtrack")&&(l=this.config.hand.enabled?await B5(i.tensor,f):[]),this.performance.hand=this.env.perfadd?(this.performance.hand||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.analyze("End Hand:"),this.analyze("Start Object:"),this.state="detect:object",this.config.async?((B0=this.config.object.modelPath)!=null&&B0.includes("nanodet")?y=this.config.object.enabled?Y5(i.tensor,this.config):[]:(T=this.config.object.modelPath)!=null&&T.includes("centernet")&&(y=this.config.object.enabled?m5(i.tensor,this.config):[]),this.performance.object&&delete this.performance.object):(n=M(),(Q=this.config.object.modelPath)!=null&&Q.includes("nanodet")?y=this.config.object.enabled?await Y5(i.tensor,this.config):[]:(k=this.config.object.modelPath)!=null&&k.includes("centernet")&&(y=this.config.object.enabled?await m5(i.tensor,this.config):[]),this.performance.object=this.env.perfadd?(this.performance.object||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.analyze("End Object:"),this.state="detect:await",this.config.async&&([x,d,l,y]=await Promise.all([x,d,l,y])),this.state="detect:gesture";let h=[];this.config.gesture.enabled&&(n=M(),h=[...er(x),...$n(d),...or(l),...tr(x)],this.config.async?this.performance.gesture&&delete this.performance.gesture:this.performance.gesture=this.env.perfadd?(this.performance.gesture||0)+Math.trunc(M()-n):Math.trunc(M()-n)),this.performance.total=this.env.perfadd?(this.performance.total||0)+Math.trunc(M()-a):Math.trunc(M()-a);let m=((Y=(X=this.process)==null?void 0:X.tensor)==null?void 0:Y.shape)||[];this.result={face:x,body:d,hand:l,gesture:h,object:y,performance:this.performance,canvas:this.process.canvas,timestamp:Date.now(),error:null,get persons(){return sr(x,d,l,h,m)}},r.dispose(i.tensor),this.emit("detect"),this.state="idle",A(this.result)})}};we=new WeakMap,Xe=new WeakMap,De=new WeakMap,Nt=new WeakMap;export{ir as Human,ir as default,Q0 as defaults,Kn as draw,w as env,rr as match,ro as models}; /** * Human main module * @default Human Library diff --git a/dist/human.esm.js b/dist/human.esm.js index 1759ca73..9e01ca90 100644 --- a/dist/human.esm.js +++ b/dist/human.esm.js @@ -215,31 +215,31 @@ var config = { // dist/tfjs.esm.js var tfjs_esm_exports = {}; __export(tfjs_esm_exports, { - Abs: () => ao, - Acos: () => nl, - Acosh: () => sl, + Abs: () => io, + Acos: () => sl, + Acosh: () => rl, AdadeltaOptimizer: () => fb, AdagradOptimizer: () => mb, AdamOptimizer: () => gb, AdamaxOptimizer: () => bb, Add: () => Ir, AddN: () => ka, - All: () => rl, - Any: () => al, + All: () => al, + Any: () => il, ArgMax: () => Ia, - ArgMin: () => il, - Asin: () => ol, - Asinh: () => ul, - Atan: () => ll, - Atan2: () => dl, - Atanh: () => cl, + ArgMin: () => ol, + Asin: () => ul, + Asinh: () => ll, + Atan: () => cl, + Atan2: () => pl, + Atanh: () => dl, AvgPool: () => Sa, AvgPool3D: () => qd, AvgPool3DGrad: () => og, AvgPoolGrad: () => ig, - BackendWasm: () => wde, + BackendWasm: () => kde, BatchMatMul: () => Ca, - BatchToSpaceND: () => io, + BatchToSpaceND: () => oo, Bincount: () => ug, BroadcastArgs: () => lg, BroadcastTo: () => A$, @@ -250,7 +250,7 @@ __export(tfjs_esm_exports, { ClipByValue: () => Sr, Complex: () => jd, ComplexAbs: () => Kd, - Concat: () => oo, + Concat: () => uo, Conv2D: () => $a, Conv2DBackpropFilter: () => cg, Conv2DBackpropInput: () => _a, @@ -259,13 +259,13 @@ __export(tfjs_esm_exports, { Conv3DBackpropInputV2: () => pg, Cos: () => Aa, Cosh: () => Ea, - CropAndResize: () => lo, - Cumprod: () => pl, - Cumsum: () => uo, + CropAndResize: () => co, + Cumprod: () => hl, + Cumsum: () => lo, CustomCallback: () => BL, DataStorage: () => Ud, DenseBincount: () => hg, - DepthToSpace: () => co, + DepthToSpace: () => po, DepthwiseConv2dNative: () => Ra, DepthwiseConv2dNativeBackpropFilter: () => fg, DepthwiseConv2dNativeBackpropInput: () => mg, @@ -279,14 +279,14 @@ __export(tfjs_esm_exports, { Elu: () => Fa, EluGrad: () => bg, Environment: () => S$, - Equal: () => po, - Erf: () => hl, + Equal: () => ho, + Erf: () => fl, Exp: () => Oa, - ExpandDims: () => ho, - Expm1: () => fo, + ExpandDims: () => fo, + Expm1: () => mo, FFT: () => yg, - Fill: () => fl, - FlipLeftRight: () => mo, + Fill: () => ml, + FlipLeftRight: () => go, Floor: () => Pa, FloorDiv: () => za, FromPixels: () => fd, @@ -294,33 +294,33 @@ __export(tfjs_esm_exports, { FusedConv2D: () => aa, FusedDepthwiseConv2D: () => ia, GPGPUContext: () => Kf, - GatherNd: () => bo, - GatherV2: () => go, + GatherNd: () => yo, + GatherV2: () => bo, GraphModel: () => E4, - Greater: () => yo, + Greater: () => vo, GreaterEqual: () => La, History: () => LL, IFFT: () => vg, Identity: () => Ba, Imag: () => Zd, InputSpec: () => Dt, - IsFinite: () => ml, - IsInf: () => gl, - IsNan: () => bl, - KernelBackend: () => tl, + IsFinite: () => gl, + IsInf: () => bl, + IsNan: () => yl, + KernelBackend: () => nl, LRN: () => ep, LRNGrad: () => wg, LayerVariable: () => AL, LayersModel: () => pr, LeakyRelu: () => Va, - Less: () => vo, - LessEqual: () => xo, + Less: () => xo, + LessEqual: () => wo, LinSpace: () => xg, Log: () => Wa, - Log1p: () => yl, + Log1p: () => vl, LogSoftmax: () => E$, - LogicalAnd: () => wo, - LogicalNot: () => vl, + LogicalAnd: () => ko, + LogicalNot: () => xl, LogicalOr: () => Jd, MathBackendCPU: () => L0, MathBackendWebGL: () => M1, @@ -335,88 +335,88 @@ __export(tfjs_esm_exports, { Min: () => ja, Minimum: () => Ka, MirrorPad: () => Xa, - Mod: () => xl, + Mod: () => wl, MomentumOptimizer: () => yb, Multinomial: () => Cg, Multiply: () => Ya, - Neg: () => ko, - NonMaxSuppressionV3: () => So, - NonMaxSuppressionV4: () => wl, - NonMaxSuppressionV5: () => Co, - NotEqual: () => Io, + Neg: () => Io, + NonMaxSuppressionV3: () => Co, + NonMaxSuppressionV4: () => kl, + NonMaxSuppressionV5: () => No, + NotEqual: () => So, OP_SCOPE_SUFFIX: () => l_, - OneHot: () => To, - OnesLike: () => No, + OneHot: () => $o, + OnesLike: () => To, Optimizer: () => _r, OptimizerConstructors: () => Wr, - Pack: () => $o, + Pack: () => _o, PadV2: () => Qa, - Pool: () => Tde, + Pool: () => $de, Pow: () => Za, Prelu: () => Ja, - Prod: () => _o, + Prod: () => Ao, RMSPropOptimizer: () => vb, RNN: () => Ar, - Range: () => kl, + Range: () => Il, Rank: () => e_, Real: () => np, RealDiv: () => Da, - Reciprocal: () => Il, + Reciprocal: () => Sl, Reduction: () => oO, Relu: () => ei, Relu6: () => ni, - Reshape: () => Ao, + Reshape: () => Eo, ResizeBilinear: () => ti, ResizeBilinearGrad: () => Tg, - ResizeNearestNeighbor: () => Sl, + ResizeNearestNeighbor: () => Cl, ResizeNearestNeighborGrad: () => Ng, - Reverse: () => Eo, - RotateWithOffset: () => Ho, - Round: () => Ro, + Reverse: () => Ro, + RotateWithOffset: () => qo, + Round: () => Do, Rsqrt: () => si, SGDOptimizer: () => Ip, - ScatterNd: () => Do, - Select: () => Fo, - Selu: () => Cl, + ScatterNd: () => Fo, + Select: () => Oo, + Selu: () => Nl, Sequential: () => Ub, Sigmoid: () => ai, - Sign: () => Nl, + Sign: () => Tl, Sin: () => ri, - Sinh: () => Po, - Slice: () => Oo, + Sinh: () => zo, + Slice: () => Po, Softmax: () => ui, - Softplus: () => Tl, - SpaceToBatchND: () => zo, + Softplus: () => $l, + SpaceToBatchND: () => Mo, SparseFillEmptyRows: () => sp, - SparseReshape: () => $l, + SparseReshape: () => _l, SparseSegmentMean: () => rp, SparseSegmentSum: () => ap, SparseToDense: () => ip, - SplitV: () => Mo, + SplitV: () => Lo, Sqrt: () => ii, - Square: () => _l, + Square: () => Al, SquaredDifference: () => li, Step: () => hi, - StridedSlice: () => Lo, + StridedSlice: () => Bo, StringNGrams: () => op, StringSplit: () => $g, StringToHashBucketFast: () => _g, Sub: () => ci, Sum: () => oi, SymbolicTensor: () => $s, - Tan: () => Bo, + Tan: () => Vo, Tanh: () => di, Tensor: () => et, TensorBuffer: () => Vt, Tile: () => Cr, - TopK: () => Vo, - Transform: () => Wo, + TopK: () => Wo, + Transform: () => Uo, Transpose: () => pi, Unique: () => Ag, - Unpack: () => Uo, + Unpack: () => Go, UnsortedSegmentSum: () => up, Variable: () => gd, - ZerosLike: () => Go, + ZerosLike: () => Ho, _FusedMatMul: () => ra, abs: () => Mt, acos: () => GA, @@ -425,7 +425,7 @@ __export(tfjs_esm_exports, { addN: () => KA, all: () => qk, any: () => pm, - argMax: () => Gu, + argMax: () => Hu, argMin: () => JA, asin: () => tE, asinh: () => sE, @@ -436,20 +436,20 @@ __export(tfjs_esm_exports, { avgPool3d: () => Yk, backend: () => zA, backend_util: () => S, - basicLSTMCell: () => Hde, - batchNorm: () => qu, + basicLSTMCell: () => qde, + batchNorm: () => ju, batchNorm2d: () => $E, batchNorm3d: () => AE, batchNorm4d: () => RE, batchToSpaceND: () => Hg, bincount: () => Qk, - booleanMaskAsync: () => vpe, + booleanMaskAsync: () => xpe, broadcastArgs: () => OE, broadcastTo: () => nd, - broadcast_util: () => qo, + broadcast_util: () => jo, browser: () => Nk, buffer: () => De, - callbacks: () => _pe, + callbacks: () => Ape, cast: () => ce, ceil: () => ME, clipByValue: () => Vn, @@ -466,7 +466,7 @@ __export(tfjs_esm_exports, { conv2dTranspose: () => Jk, conv3d: () => eI, conv3dTranspose: () => tR, - copyRegisteredKernels: () => Ade, + copyRegisteredKernels: () => Ede, cos: () => jg, cosh: () => nI, cosineWindow: () => TI, @@ -478,21 +478,21 @@ __export(tfjs_esm_exports, { deprecationWarn: () => Gk, depthToSpace: () => cR, depthwiseConv2d: () => hp, - deregisterOp: () => Epe, + deregisterOp: () => Rpe, device_util: () => dp, - diag: () => qde, + diag: () => jde, dilation2d: () => fR, - disableDeprecationWarnings: () => Fde, + disableDeprecationWarnings: () => Ode, dispose: () => Re, - disposeVariables: () => Ode, + disposeVariables: () => Pde, div: () => xe, divNoNan: () => vR, - dot: () => jde, + dot: () => Kde, dropout: () => nF, einsum: () => kR, elu: () => fp, - enableDebugMode: () => Dde, - enableProdMode: () => Rde, + enableDebugMode: () => Fde, + enableProdMode: () => Dde, enclosingPowerOfTwo: () => sF, engine: () => Ss, env: () => X, @@ -503,58 +503,58 @@ __export(tfjs_esm_exports, { expm1: () => _R, eye: () => rI, fft: () => lb, - fill: () => Ol, - findBackend: () => Wde, - findBackendFactory: () => Ude, + fill: () => Pl, + findBackend: () => Ude, + findBackendFactory: () => Gde, floor: () => mp, floorDiv: () => Hk, forceHalfFloat: () => GX, fused: () => ha, - gather: () => ju, + gather: () => Ku, gatherND: () => J3, gather_util: () => $k, - getBackend: () => Bde, + getBackend: () => Vde, getGradient: () => nx, getKernel: () => Zf, getKernelsForBackend: () => Jf, - getThreadsCount: () => Vpe, + getThreadsCount: () => Wpe, gpgpu_util: () => RK, - grad: () => Yde, - grads: () => Qde, + grad: () => Qde, + grads: () => Zde, greater: () => Wn, - greaterEqual: () => jo, + greaterEqual: () => Ko, ifft: () => Id, imag: () => Kg, image: () => qn, - inTopKAsync: () => wpe, + inTopKAsync: () => kpe, initializers: () => qM, input: () => OB, io: () => En, irfft: () => xI, - isFinite: () => Kde, - isInf: () => Xde, + isFinite: () => Xde, + isInf: () => Yde, isNaN: () => BR, keep: () => Ht, kernel_impls: () => xs, layers: () => $L, leakyRelu: () => Xg, less: () => aI, - lessEqual: () => Ko, + lessEqual: () => Xo, linalg: () => VO, linspace: () => GR, - loadGraphModel: () => Rpe, - loadLayersModel: () => Tpe, + loadGraphModel: () => Dpe, + loadLayersModel: () => $pe, localResponseNormalization: () => qR, log: () => Yn, log1p: () => Yg, - logSigmoid: () => epe, + logSigmoid: () => tpe, logSoftmax: () => iI, logSumExp: () => iD, logicalAnd: () => Ds, logicalNot: () => Jg, logicalOr: () => cI, - logicalXor: () => tpe, - losses: () => Spe, + logicalXor: () => npe, + losses: () => Cpe, matMul: () => We, math: () => iA, max: () => As, @@ -564,62 +564,62 @@ __export(tfjs_esm_exports, { maximum: () => $r, mean: () => St, memory: () => dm, - meshgrid: () => npe, + meshgrid: () => spe, metrics: () => rW, min: () => fm, minimum: () => bp, mirrorPad: () => xD, mod: () => kD, - model: () => Cpe, + model: () => Npe, models: () => xW, moments: () => tb, - movingAverage: () => xpe, + movingAverage: () => wpe, mul: () => V, - multiRNNCell: () => spe, + multiRNNCell: () => rpe, multinomial: () => TD, neg: () => kt, nextFrame: () => OI, norm: () => CI, - notEqual: () => Ku, + notEqual: () => Xu, oneHot: () => vd, ones: () => Mn, onesLike: () => Qn, op: () => L, - outerProduct: () => rpe, + outerProduct: () => ape, pad: () => fi, - pad1d: () => ape, - pad2d: () => ipe, - pad3d: () => ope, - pad4d: () => upe, - pool: () => lpe, + pad1d: () => ipe, + pad2d: () => ope, + pad3d: () => upe, + pad4d: () => lpe, + pool: () => cpe, pow: () => pa, prelu: () => sb, print: () => U_, prod: () => pI, - profile: () => Pde, - rand: () => cpe, - randomGamma: () => dpe, + profile: () => zde, + rand: () => dpe, + randomGamma: () => ppe, randomNormal: () => KD, - randomUniform: () => zl, - range: () => Xu, - ready: () => Lde, + randomUniform: () => Ml, + range: () => Yu, + ready: () => Bde, real: () => wd, reciprocal: () => ZD, registerBackend: () => pp, - registerCallbackConstructor: () => $pe, + registerCallbackConstructor: () => _pe, registerGradient: () => D$, - registerKernel: () => Al, - registerOp: () => Ape, + registerKernel: () => El, + registerOp: () => Epe, regularizers: () => wW, relu: () => Xs, relu6: () => hI, - removeBackend: () => Vde, + removeBackend: () => Wde, reshape: () => G, reverse: () => Zn, - reverse1d: () => ppe, - reverse2d: () => hpe, - reverse3d: () => fpe, - reverse4d: () => mpe, + reverse1d: () => hpe, + reverse2d: () => fpe, + reverse3d: () => mpe, + reverse4d: () => gpe, rfft: () => cb, round: () => fI, rsqrt: () => mI, @@ -628,19 +628,19 @@ __export(tfjs_esm_exports, { scatter_util: () => Ak, selu: () => gI, separableConv2d: () => c3, - sequential: () => Npe, + sequential: () => Tpe, serialization: () => ae, - setBackend: () => Mde, - setPlatform: () => Gde, - setThreadsCount: () => Bpe, - setWasmPath: () => Mpe, - setWasmPaths: () => Lpe, + setBackend: () => Lde, + setPlatform: () => Hde, + setThreadsCount: () => Vpe, + setWasmPath: () => Lpe, + setWasmPaths: () => Bpe, setWebGLContext: () => S5, setdiff1dAsync: () => p3, shared: () => Zy, sigmoid: () => qs, sign: () => f3, - signal: () => Ipe, + signal: () => Spe, sin: () => bI, sinh: () => yI, slice: () => He, @@ -650,11 +650,11 @@ __export(tfjs_esm_exports, { slice4d: () => kd, slice_util: () => wt, softmax: () => ub, - softplus: () => Pl, + softplus: () => zl, spaceToBatchND: () => nb, sparse: () => Wc, sparseToDense: () => NI, - spectral: () => kpe, + spectral: () => Ipe, split: () => Bn, sqrt: () => dn, square: () => ct, @@ -668,44 +668,44 @@ __export(tfjs_esm_exports, { sum: () => ve, sumOutType: () => cp, tan: () => O3, - tanh: () => Hu, + tanh: () => qu, tensor: () => fs, tensor1d: () => Zt, tensor2d: () => Ki, tensor3d: () => pA, - tensor4d: () => gpe, - tensor5d: () => bpe, - tensor6d: () => ype, + tensor4d: () => bpe, + tensor5d: () => ype, + tensor6d: () => vpe, tensor_util: () => _s, test_util: () => _A, tidy: () => j, tile: () => ps, - time: () => zde, + time: () => Mde, topk: () => z3, train: () => Pi, transpose: () => qe, truncatedNormal: () => db, unique: () => hx, - unregisterGradient: () => _de, - unregisterKernel: () => $de, + unregisterGradient: () => Ade, + unregisterKernel: () => _de, unsortedSegmentSum: () => V3, unstack: () => Fs, upcastType: () => cn, util: () => w, - valueAndGrad: () => Zde, - valueAndGrads: () => Jde, + valueAndGrad: () => Jde, + valueAndGrads: () => epe, variable: () => U3, variableGrads: () => XR, - version: () => Upe, - version_converter: () => Dpe, - version_core: () => Ede, - version_cpu: () => Fpe, + version: () => Gpe, + version_converter: () => Fpe, + version_core: () => Rde, + version_cpu: () => Ope, version_layers: () => uS, - version_wasm: () => Wpe, - version_webgl: () => Ope, - webgl: () => Ppe, + version_wasm: () => Upe, + version_webgl: () => Ppe, + webgl: () => zpe, webgl_util: () => I5, - webgpu: () => soe, + webgpu: () => roe, where: () => vn, whereAsync: () => II, zeros: () => $t, @@ -1332,7 +1332,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js return Ce.buffer != nn && rs(Ce.buffer), oc; } function o() { - return Ce.buffer != nn && rs(Ce.buffer), pu; + return Ce.buffer != nn && rs(Ce.buffer), hu; } function u() { return Ce.buffer != nn && rs(Ce.buffer), uc; @@ -1360,7 +1360,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js } var P, R, F, $; function z(C) { - if (C instanceof wu) + if (C instanceof ku) return; ee("exiting due to exception: " + C); } @@ -1378,7 +1378,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js 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) { - if (!(D instanceof wu)) + if (!(D instanceof ku)) throw D; }), process.on("unhandledRejection", function(D) { throw D; @@ -1435,8 +1435,8 @@ var a$ = 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: C } }), ku = Bc.exports.f; - return ku; + 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: C } }), Iu = Bc.exports.f; + return Iu; } var re = [], le; function me() { @@ -1490,11 +1490,11 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js var Bc = pe[B[ls]]; Bc ? (us === 0 && (us = Ef()), bt[ls] = Bc(Q[ls])) : bt[ls] = Q[ls]; } - var ku = Te.apply(null, bt); + var Iu = Te.apply(null, bt); function MT($n) { return us !== 0 && Pc(us), ye($n); } - return ku = MT(ku), ku; + return Iu = MT(Iu), Iu; } function en(C, D, B, Q) { B = B || []; @@ -1583,7 +1583,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js function Bs(C, D) { a().set(C, D); } - function du(C, D, B) { + function pu(C, D, B) { for (var Q = 0; Q < C.length; ++Q) a()[D++ >> 0] = C.charCodeAt(Q); B || (a()[D >> 0] = 0); @@ -1591,10 +1591,10 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js function Ii(C, D) { return C % D > 0 && (C += D - C % D), C; } - var nn, ic, oc, pu, uc, lc, Fv, cc, dc; + var nn, ic, oc, hu, uc, lc, Fv, cc, dc; N && (nn = d.buffer); function rs(C) { - nn = C, d.HEAP8 = ic = new Int8Array(C), d.HEAP16 = pu = new Int16Array(C), d.HEAP32 = lc = new Int32Array(C), d.HEAPU8 = oc = new Uint8Array(C), d.HEAPU16 = uc = new Uint16Array(C), d.HEAPU32 = Fv = new Uint32Array(C), d.HEAPF32 = cc = new Float32Array(C), d.HEAPF64 = dc = new Float64Array(C); + nn = C, d.HEAP8 = ic = new Int8Array(C), d.HEAP16 = hu = new Int16Array(C), d.HEAP32 = lc = new Int32Array(C), d.HEAPU8 = oc = new Uint8Array(C), d.HEAPU16 = uc = new Uint16Array(C), d.HEAPU32 = Fv = new Uint32Array(C), d.HEAPF32 = cc = new Float32Array(C), d.HEAPF64 = dc = new Float64Array(C); } var pc = d.INITIAL_MEMORY || 16777216; if (N) @@ -1614,7 +1614,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js Ov(d.preRun.shift()); vc(Si); } - function hu() { + function fu() { Or = true, !N && vc(er); } function sh() { @@ -1624,7 +1624,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js if (!N) { if (d.postRun) for (typeof d.postRun == "function" && (d.postRun = [d.postRun]); d.postRun.length; ) - fu(d.postRun.shift()); + mu(d.postRun.shift()); vc(hc); } } @@ -1634,11 +1634,11 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js function Pv(C) { er.unshift(C); } - function fu(C) { + function mu(C) { hc.unshift(C); } var tr = 0, mc = null, as = null; - function mu(C) { + function gu(C) { tr++, d.monitorRunDependencies && d.monitorRunDependencies(tr); } function zv(C) { @@ -1707,7 +1707,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js }); } } - N || mu("wasm-instantiate"); + N || gu("wasm-instantiate"); function B(ye) { D(ye.instance, ye.module); } @@ -1784,7 +1784,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js OT(C); } function ch(C) { - if (C instanceof wu || C == "unwind") + if (C instanceof ku || C == "unwind") return Jt; v(1, C); } @@ -1980,13 +1980,13 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js return Qv(C, ue, pe, D); }); } - var gu = []; + var bu = []; function Th(C, D, B) { - gu.length = D; + bu.length = D; for (var Q = B >> 3, ue = 0; ue < D; ue++) - gu[ue] = p()[Q + ue]; + bu[ue] = p()[Q + ue]; var pe = C < 0, ye = pe ? oh[-C - 1] : qh[C]; - return ye.apply(null, gu); + return ye.apply(null, bu); } function $h(C) { try { @@ -2100,11 +2100,11 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js var D = Fh[C] || (typeof document != "undefined" ? document.querySelector(C) : void 0); return D; } - function bu(C) { + function yu(C) { return Oh(C); } function Cc(C, D, B) { - var Q = bu(C); + var Q = yu(C); if (!Q) return -4; if (Q.canvasSharedPtr && (l()[Q.canvasSharedPtr >> 2] = D, l()[Q.canvasSharedPtr + 4 >> 2] = B), Q.offscreenCanvas || !Q.controlTransferredOffscreen) { @@ -2126,7 +2126,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js return N ? Lr(2, 1, C, D, B) : Cc(C, D, B); } function Ph(C, D, B) { - var Q = bu(C); + var Q = yu(C); return Q ? Cc(C, D, B) : Nc(C, D, B); } function zh() { @@ -2211,7 +2211,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js } } }, Wh = ["default", "low-power", "high-performance"]; function Uh(C, 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: Wh[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 = bu(C); + 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: Wh[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 = yu(C); if (!pe || ue.explicitSwapControl) return 0; var ye = gt.createContext(pe, ue); @@ -2320,18 +2320,18 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js return (Rc = d._Floor = d.asm.Floor).apply(null, arguments); }, Dc = d._FloorDiv = function() { return (Dc = d._FloorDiv = d.asm.FloorDiv).apply(null, arguments); - }, yu = d._FusedBatchNorm = function() { - return (yu = d._FusedBatchNorm = d.asm.FusedBatchNorm).apply(null, arguments); + }, vu = d._FusedBatchNorm = function() { + return (vu = d._FusedBatchNorm = d.asm.FusedBatchNorm).apply(null, arguments); }, Sf = d._FusedConv2D = function() { return (Sf = d._FusedConv2D = d.asm.FusedConv2D).apply(null, arguments); }, Cf = d._FusedDepthwiseConv2D = function() { return (Cf = d._FusedDepthwiseConv2D = d.asm.FusedDepthwiseConv2D).apply(null, arguments); }, Ai = d._Gather = function() { return (Ai = d._Gather = d.asm.Gather).apply(null, arguments); - }, vu = d._GatherNd = function() { - return (vu = d._GatherNd = d.asm.GatherNd).apply(null, arguments); - }, xu = d._Greater = function() { - return (xu = d._Greater = d.asm.Greater).apply(null, arguments); + }, xu = d._GatherNd = function() { + return (xu = d._GatherNd = d.asm.GatherNd).apply(null, arguments); + }, wu = d._Greater = function() { + return (wu = d._Greater = d.asm.Greater).apply(null, arguments); }, Hv = d._GreaterEqual = function() { return (Hv = d._GreaterEqual = d.asm.GreaterEqual).apply(null, arguments); }, Ei = d._LeakyRelu = function() { @@ -2487,9 +2487,9 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js }, FT = d.dynCall_jiji = function() { return (FT = d.dynCall_jiji = d.asm.dynCall_jiji).apply(null, arguments); }, Jv = d.__emscripten_allow_main_runtime_queued_calls = 21456; - d.cwrap = en, d.keepRuntimeAlive = Pr, d.PThread = $e, d.PThread = $e, d.wasmMemory = Ce, d.ExitStatus = wu; + d.cwrap = en, d.keepRuntimeAlive = Pr, d.PThread = $e, d.PThread = $e, d.wasmMemory = Ce, d.ExitStatus = ku; var zc; - function wu(C) { + function ku(C) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + C + ")", this.status = C; } as = function C() { @@ -2499,13 +2499,13 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js if (C = C || b, tr > 0) return; if (N) { - h(d), hu(), postMessage({ cmd: "loaded" }); + h(d), fu(), postMessage({ cmd: "loaded" }); return; } if (sn(), tr > 0) return; function D() { - zc || (zc = true, d.calledRun = true, !at && (hu(), h(d), d.onRuntimeInitialized && d.onRuntimeInitialized(), rh())); + zc || (zc = true, d.calledRun = true, !at && (fu(), h(d), d.onRuntimeInitialized && d.onRuntimeInitialized(), rh())); } d.setStatus ? (d.setStatus("Running..."), setTimeout(function() { setTimeout(function() { @@ -2520,7 +2520,7 @@ var a$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.js Pr() || sh(), PT(C); } function PT(C) { - Jt = C, Pr() || ($e.terminateAllThreads(), d.onExit && d.onExit(C), at = true), v(C, new wu(C)); + Jt = C, Pr() || ($e.terminateAllThreads(), d.onExit && d.onExit(C), at = true), v(C, new ku(C)); } if (d.preInit) for (typeof d.preInit == "function" && (d.preInit = [d.preInit]); d.preInit.length > 0; ) @@ -2575,7 +2575,7 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { } var y, v, x, k; function T(H) { - if (H instanceof vu) + if (H instanceof xu) return; R("exiting due to exception: " + H); } @@ -2592,12 +2592,12 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { Ie ? de(Ie) : J(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 vu)) + if (!(H instanceof xu)) throw H; }), process.on("unhandledRejection", function(H) { throw H; }), d = (H, J) => { - if (pu()) + if (hu()) throw process.exitCode = H, J; T(J), process.exit(H); }, a.inspect = function() { @@ -2651,7 +2651,7 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { } function Y(H, J) { for (var de = H; de < H + J; de++) { - var Ie = mu(de); + var Ie = gu(de); Ie && q.set(Ie, de); } } @@ -2674,11 +2674,11 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { var nr = 0; if (an != null && an !== 0) { var Fc = (an.length << 2) + 1; - nr = yu(Fc), tt(an, nr, Fc); + nr = vu(Fc), tt(an, nr, Fc); } return nr; }, array: function(an) { - var nr = yu(an.length); + var nr = vu(an.length); return at(an, nr), nr; } }; function Ve(an) { @@ -2790,18 +2790,18 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { function Ls(H) { Cn = H, a.HEAP8 = Et = new Int8Array(H), a.HEAP16 = Nn = new Int16Array(H), a.HEAP32 = Yt = new Int32Array(H), a.HEAPU8 = en = new Uint8Array(H), a.HEAPU16 = Tn = new Uint16Array(H), a.HEAPU32 = Dn = new Uint32Array(H), a.HEAPF32 = tn = new Float32Array(H), a.HEAPF64 = Ms = new Float64Array(H); } - var ki = a.INITIAL_MEMORY || 16777216, Js, Bs = [], du = [], Ii = [], nn = false, ic = false, oc = 0; - function pu() { + var ki = a.INITIAL_MEMORY || 16777216, Js, Bs = [], pu = [], Ii = [], nn = false, ic = false, oc = 0; + function hu() { return se || oc > 0; } function uc() { if (a.preRun) for (typeof a.preRun == "function" && (a.preRun = [a.preRun]); a.preRun.length; ) dc(a.preRun.shift()); - fu(Bs); + mu(Bs); } function lc() { - nn = true, fu(du); + nn = true, mu(pu); } function Fv() { ic = true; @@ -2810,13 +2810,13 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { if (a.postRun) for (typeof a.postRun == "function" && (a.postRun = [a.postRun]); a.postRun.length; ) pc(a.postRun.shift()); - fu(Ii); + mu(Ii); } function dc(H) { Bs.unshift(H); } function rs(H) { - du.unshift(H); + pu.unshift(H); } function pc(H) { Ii.unshift(H); @@ -2846,7 +2846,7 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { } var sn; sn = "tfjs-backend-wasm.wasm", fc(sn) || (sn = b(sn)); - function hu(H) { + function fu(H) { try { if (H == sn && ee) return new Uint8Array(ee); @@ -2865,7 +2865,7 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { throw "failed to load wasm binary file at '" + sn + "'"; return H.arrayBuffer(); }).catch(function() { - return hu(sn); + return fu(sn); }); if (v) return new Promise(function(H, J) { @@ -2875,7 +2875,7 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { }); } return Promise.resolve().then(function() { - return hu(sn); + return fu(sn); }); } function rh() { @@ -2915,7 +2915,7 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { return Qe().catch(o), {}; } var Ov, Pv; - function fu(H) { + function mu(H) { for (; H.length > 0; ) { var J = H.shift(); if (typeof J == "function") { @@ -2923,7 +2923,7 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { continue; } var de = J.func; - typeof de == "number" ? J.arg === void 0 ? mu(de)() : mu(de)(J.arg) : de(J.arg === void 0 ? null : J.arg); + typeof de == "number" ? J.arg === void 0 ? gu(de)() : gu(de)(J.arg) : de(J.arg === void 0 ? null : J.arg); } } function tr(H) { @@ -2937,7 +2937,7 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { }); } var as = []; - function mu(H) { + function gu(H) { var J = as[H]; return J || (H >= as.length && (as.length = H + 1), as[H] = J = Js.get(H)), J; } @@ -3082,8 +3082,8 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { return (Nh = a._Floor = a.asm.Floor).apply(null, arguments); }, Lr = a._FloorDiv = function() { return (Lr = a._FloorDiv = a.asm.FloorDiv).apply(null, arguments); - }, gu = a._FusedBatchNorm = function() { - return (gu = a._FusedBatchNorm = a.asm.FusedBatchNorm).apply(null, arguments); + }, bu = a._FusedBatchNorm = function() { + return (bu = a._FusedBatchNorm = a.asm.FusedBatchNorm).apply(null, arguments); }, Th = a._FusedConv2D = function() { return (Th = a._FusedConv2D = a.asm.FusedConv2D).apply(null, arguments); }, $h = a._FusedDepthwiseConv2D = function() { @@ -3104,8 +3104,8 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { return (Fh = a._LessEqual = a.asm.LessEqual).apply(null, arguments); }, Oh = a._Log = function() { return (Oh = a._Log = a.asm.Log).apply(null, arguments); - }, bu = a._LogicalAnd = function() { - return (bu = a._LogicalAnd = a.asm.LogicalAnd).apply(null, arguments); + }, yu = a._LogicalAnd = function() { + return (yu = 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() { @@ -3214,8 +3214,8 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { return (Rc = a.stackSave = a.asm.stackSave).apply(null, arguments); }, Dc = a.stackRestore = function() { return (Dc = a.stackRestore = a.asm.stackRestore).apply(null, arguments); - }, yu = a.stackAlloc = function() { - return (yu = a.stackAlloc = a.asm.stackAlloc).apply(null, arguments); + }, vu = a.stackAlloc = function() { + return (vu = a.stackAlloc = a.asm.stackAlloc).apply(null, arguments); }, Sf = a.dynCall_iijjiiii = function() { return (Sf = a.dynCall_iijjiiii = a.asm.dynCall_iijjiiii).apply(null, arguments); }, Cf = a.dynCall_jiji = function() { @@ -3223,13 +3223,13 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { }; a.cwrap = Se; var Ai; - function vu(H) { + function xu(H) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + H + ")", this.status = H; } er = function H() { - Ai || xu(), Ai || (er = H); + Ai || wu(), Ai || (er = H); }; - function xu(H) { + function wu(H) { if (H = H || c, Fn > 0 || (uc(), Fn > 0)) return; function J() { @@ -3241,14 +3241,14 @@ var i$ = zt({ "src/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.js"(e, t) { }, 1), J(); }, 1)) : J(); } - a.run = xu; + a.run = wu; function Hv(H) { - re = H, pu() || (a.onExit && a.onExit(H), oe = true), d(H, new vu(H)); + re = H, hu() || (a.onExit && a.onExit(H), oe = true), d(H, new xu(H)); } if (a.preInit) for (typeof a.preInit == "function" && (a.preInit = [a.preInit]); a.preInit.length > 0; ) a.preInit.pop()(); - xu(); + wu(); var Ei; u && (Ei = { uncaughtException: process.listeners("uncaughtException").filter(function(H) { return !u.uncaughtException.indexOf(H) > -1; @@ -3301,7 +3301,7 @@ var Ud = class { return this.dataIdsCount; } }; -var tl = class { +var nl = class { refCount(e) { return On("refCount"); } @@ -3363,7 +3363,7 @@ function l$(e, t) { for (; n > 0; ) s = Math.random() * n | 0, n--, pd(e, n, s), pd(t, n, s); } -function Bu(e, t, n) { +function Vu(e, t, n) { return Math.max(e, Math.min(t, n)); } function c$(e) { @@ -3455,7 +3455,7 @@ function b$(e) { t[n] = n; return Uw(t), t; } -function Pu(e, t) { +function zu(e, t) { return t <= e.length ? e : e + " ".repeat(t - e.length); } function y$(e, t = (s) => 0, n) { @@ -3593,7 +3593,7 @@ function hd(e, t) { return n; return e; } -function ro(e) { +function ao(e) { let t = e.length; if (t < 2) return []; @@ -3794,26 +3794,26 @@ function ag(e, t) { return n.set(e, s), n.get(e); } } -var ao = "Abs"; -var nl = "Acos"; -var sl = "Acosh"; +var io = "Abs"; +var sl = "Acos"; +var rl = "Acosh"; var Ir = "Add"; var ka = "AddN"; -var rl = "All"; -var al = "Any"; +var al = "All"; +var il = "Any"; var Ia = "ArgMax"; -var il = "ArgMin"; -var ol = "Asin"; -var ul = "Asinh"; -var ll = "Atan"; -var cl = "Atanh"; -var dl = "Atan2"; +var ol = "ArgMin"; +var ul = "Asin"; +var ll = "Asinh"; +var cl = "Atan"; +var dl = "Atanh"; +var pl = "Atan2"; var Sa = "AvgPool"; var ig = "AvgPoolGrad"; var qd = "AvgPool3D"; var og = "AvgPool3DGrad"; var Ca = "BatchMatMul"; -var io = "BatchToSpaceND"; +var oo = "BatchToSpaceND"; var ug = "Bincount"; var A$ = "BroadcastTo"; var lg = "BroadcastArgs"; @@ -3822,7 +3822,7 @@ var Ta = "Ceil"; var Sr = "ClipByValue"; var jd = "Complex"; var Kd = "ComplexAbs"; -var oo = "Concat"; +var uo = "Concat"; var $a = "Conv2D"; var cg = "Conv2DBackpropFilter"; var _a = "Conv2DBackpropInput"; @@ -3831,11 +3831,11 @@ var dg = "Conv3DBackpropFilterV2"; var pg = "Conv3DBackpropInputV2"; var Aa = "Cos"; var Ea = "Cosh"; -var pl = "Cumprod"; -var uo = "Cumsum"; -var lo = "CropAndResize"; +var hl = "Cumprod"; +var lo = "Cumsum"; +var co = "CropAndResize"; var hg = "DenseBincount"; -var co = "DepthToSpace"; +var po = "DepthToSpace"; var Ra = "DepthwiseConv2dNative"; var fg = "DepthwiseConv2dNativeBackpropFilter"; var mg = "DepthwiseConv2dNativeBackpropInput"; @@ -3847,35 +3847,35 @@ var Da = "RealDiv"; var Qd = "Einsum"; var Fa = "Elu"; var bg = "EluGrad"; -var hl = "Erf"; -var po = "Equal"; +var fl = "Erf"; +var ho = "Equal"; var Oa = "Exp"; -var ho = "ExpandDims"; -var fo = "Expm1"; +var fo = "ExpandDims"; +var mo = "Expm1"; var yg = "FFT"; -var fl = "Fill"; -var mo = "FlipLeftRight"; +var ml = "Fill"; +var go = "FlipLeftRight"; var Pa = "Floor"; var za = "FloorDiv"; var Ma = "FusedBatchNorm"; -var go = "GatherV2"; -var bo = "GatherNd"; -var yo = "Greater"; +var bo = "GatherV2"; +var yo = "GatherNd"; +var vo = "Greater"; var La = "GreaterEqual"; var Ba = "Identity"; var vg = "IFFT"; var Zd = "Imag"; -var ml = "IsFinite"; -var gl = "IsInf"; -var bl = "IsNan"; +var gl = "IsFinite"; +var bl = "IsInf"; +var yl = "IsNan"; var Va = "LeakyRelu"; -var vo = "Less"; -var xo = "LessEqual"; +var xo = "Less"; +var wo = "LessEqual"; var xg = "LinSpace"; var Wa = "Log"; -var yl = "Log1p"; -var wo = "LogicalAnd"; -var vl = "LogicalNot"; +var vl = "Log1p"; +var ko = "LogicalAnd"; +var xl = "LogicalNot"; var Jd = "LogicalOr"; var E$ = "LogSoftmax"; var ep = "LRN"; @@ -3891,74 +3891,74 @@ var qa = "Mean"; var ja = "Min"; var Ka = "Minimum"; var Xa = "MirrorPad"; -var xl = "Mod"; +var wl = "Mod"; var Cg = "Multinomial"; var Ya = "Multiply"; -var ko = "Neg"; -var Io = "NotEqual"; -var So = "NonMaxSuppressionV3"; -var wl = "NonMaxSuppressionV4"; -var Co = "NonMaxSuppressionV5"; -var No = "OnesLike"; -var To = "OneHot"; -var $o = "Pack"; +var Io = "Neg"; +var So = "NotEqual"; +var Co = "NonMaxSuppressionV3"; +var kl = "NonMaxSuppressionV4"; +var No = "NonMaxSuppressionV5"; +var To = "OnesLike"; +var $o = "OneHot"; +var _o = "Pack"; var Qa = "PadV2"; -var Tde = "Pool"; +var $de = "Pool"; var Za = "Pow"; var Ja = "Prelu"; -var _o = "Prod"; -var kl = "Range"; +var Ao = "Prod"; +var Il = "Range"; var np = "Real"; -var Il = "Reciprocal"; +var Sl = "Reciprocal"; var ei = "Relu"; -var Ao = "Reshape"; -var Sl = "ResizeNearestNeighbor"; +var Eo = "Reshape"; +var Cl = "ResizeNearestNeighbor"; var Ng = "ResizeNearestNeighborGrad"; var ti = "ResizeBilinear"; var Tg = "ResizeBilinearGrad"; var ni = "Relu6"; -var Eo = "Reverse"; -var Ro = "Round"; +var Ro = "Reverse"; +var Do = "Round"; var si = "Rsqrt"; -var Do = "ScatterNd"; -var Fo = "Select"; -var Cl = "Selu"; -var Oo = "Slice"; +var Fo = "ScatterNd"; +var Oo = "Select"; +var Nl = "Selu"; +var Po = "Slice"; var ri = "Sin"; -var Po = "Sinh"; -var Nl = "Sign"; +var zo = "Sinh"; +var Tl = "Sign"; var ai = "Sigmoid"; -var Tl = "Softplus"; +var $l = "Softplus"; var ii = "Sqrt"; var oi = "Sum"; -var zo = "SpaceToBatchND"; -var Mo = "SplitV"; +var Mo = "SpaceToBatchND"; +var Lo = "SplitV"; var ui = "Softmax"; var sp = "SparseFillEmptyRows"; -var $l = "SparseReshape"; +var _l = "SparseReshape"; var rp = "SparseSegmentMean"; var ap = "SparseSegmentSum"; var ip = "SparseToDense"; var li = "SquaredDifference"; -var _l = "Square"; -var Lo = "StridedSlice"; +var Al = "Square"; +var Bo = "StridedSlice"; var op = "StringNGrams"; var $g = "StringSplit"; var _g = "StringToHashBucketFast"; var ci = "Sub"; -var Bo = "Tan"; +var Vo = "Tan"; var di = "Tanh"; var Cr = "Tile"; -var Vo = "TopK"; -var Wo = "Transform"; +var Wo = "TopK"; +var Uo = "Transform"; var pi = "Transpose"; var Ag = "Unique"; -var Uo = "Unpack"; +var Go = "Unpack"; var up = "UnsortedSegmentSum"; -var Go = "ZerosLike"; +var Ho = "ZerosLike"; var hi = "Step"; var fd = "FromPixels"; -var Ho = "RotateWithOffset"; +var qo = "RotateWithOffset"; var ra = "_FusedMatMul"; var aa = "FusedConv2D"; var ia = "FusedDepthwiseConv2D"; @@ -3969,13 +3969,13 @@ function R$(...e) { X().getBool("IS_TEST") || X().getBool("PROD") || console.log(...e); } var Qi = ag("kernelRegistry", () => /* @__PURE__ */ new Map()); -var Vu = ag("gradRegistry", () => /* @__PURE__ */ new Map()); +var Wu = ag("gradRegistry", () => /* @__PURE__ */ new Map()); function Zf(e, t) { let n = Eg(e, t); return Qi.get(n); } function nx(e) { - return Vu.get(e); + return Wu.get(e); } function Jf(e) { let t = Qi.entries(), n = []; @@ -3988,44 +3988,44 @@ function Jf(e) { } return n; } -function Al(e) { +function El(e) { let { kernelName: t, backendName: n } = e, s = Eg(t, n); Qi.has(s) && ar(`The kernel '${t}' for backend '${n}' is already registered`), Qi.set(s, e); } function D$(e) { let { kernelName: t } = e; - Vu.has(t) && X().getBool("DEBUG") && ar(`Overriding the gradient for '${t}'`), Vu.set(t, e); + Wu.has(t) && X().getBool("DEBUG") && ar(`Overriding the gradient for '${t}'`), Wu.set(t, e); } -function $de(e, t) { +function _de(e, t) { let n = Eg(e, t); if (!Qi.has(n)) throw new Error(`The kernel '${e}' for backend '${t}' is not registered`); Qi.delete(n); } -function _de(e) { - if (!Vu.has(e)) +function Ade(e) { + if (!Wu.has(e)) throw new Error(`The gradient '${e}' for backend is not registered`); - Vu.delete(e); + Wu.delete(e); } -function Ade(e, t) { +function Ede(e, t) { Jf(e).forEach((s) => { let r = Object.assign({}, s, { backendName: t }); - Al(r); + El(r); }); } function Eg(e, t) { return `${t}_${e}`; } var w = {}; -Ae(w, { arraysEqual: () => kr, assert: () => O, assertNonNegativeIntegerDimensions: () => sg, assertNonNull: () => wa, assertShapesMatch: () => pn, bytesFromStringArray: () => Xw, bytesPerElement: () => Xf, checkConversionForErrors: () => jw, clamp: () => Bu, computeStrides: () => ro, createScalarValue: () => L$, createShuffledIndices: () => b$, decodeString: () => md, distSquared: () => h$, encodeString: () => Rl, fetch: () => V$, fingerPrint64: () => M$, flatten: () => sa, getArrayFromDType: () => qw, getTypedArrayFromDType: () => Hw, hasEncodingLoss: () => x$, hexToLong: () => El, indexToLoc: () => I$, inferDtype: () => Gd, inferFromImplicitShape: () => v$, isBoolean: () => Yw, isFunction: () => hr, isInt: () => Yi, isNumber: () => Qw, isPromise: () => rg, isScalarShape: () => f$, isString: () => ir, isTypedArray: () => Qt, isValidDtype: () => Kw, locToIndex: () => k$, makeOnesTypedArray: () => ng, makeZerosNestedTypedArray: () => w$, makeZerosTypedArray: () => Hd, nearestDivisor: () => hd, nearestLargerEven: () => c$, now: () => Wu, parseAxisParam: () => ts, randUniform: () => p$, repeatedTry: () => y$, rightPad: () => Pu, shuffle: () => Uw, shuffleCombo: () => l$, sizeFromShape: () => pt, sizeToSquarishShape: () => g$, squeezeShape: () => Gw, sum: () => d$, swap: () => pd, tanh: () => m$, toNestedArray: () => Hi, toTypedArray: () => lp }); +Ae(w, { arraysEqual: () => kr, assert: () => O, assertNonNegativeIntegerDimensions: () => sg, assertNonNull: () => wa, assertShapesMatch: () => pn, bytesFromStringArray: () => Xw, bytesPerElement: () => Xf, checkConversionForErrors: () => jw, clamp: () => Vu, computeStrides: () => ao, createScalarValue: () => L$, createShuffledIndices: () => b$, decodeString: () => md, distSquared: () => h$, encodeString: () => Dl, fetch: () => V$, fingerPrint64: () => M$, flatten: () => sa, getArrayFromDType: () => qw, getTypedArrayFromDType: () => Hw, hasEncodingLoss: () => x$, hexToLong: () => Rl, indexToLoc: () => I$, inferDtype: () => Gd, inferFromImplicitShape: () => v$, isBoolean: () => Yw, isFunction: () => hr, isInt: () => Yi, isNumber: () => Qw, isPromise: () => rg, isScalarShape: () => f$, isString: () => ir, isTypedArray: () => Qt, isValidDtype: () => Kw, locToIndex: () => k$, makeOnesTypedArray: () => ng, makeZerosNestedTypedArray: () => w$, makeZerosTypedArray: () => Hd, nearestDivisor: () => hd, nearestLargerEven: () => c$, now: () => Uu, parseAxisParam: () => ts, randUniform: () => p$, repeatedTry: () => y$, rightPad: () => zu, shuffle: () => Uw, shuffleCombo: () => l$, sizeFromShape: () => pt, sizeToSquarishShape: () => g$, squeezeShape: () => Gw, sum: () => d$, swap: () => pd, tanh: () => m$, toNestedArray: () => Hi, toTypedArray: () => lp }); var sx = xa(HT()); var qr = sx.default || sx; -function El(e) { +function Rl(e) { return qr.fromString(e, true, 16); } -var tk = El("c3a5c85c97cb3127"); -var Gr = El("b492b66fbe98f273"); -var on = El("9ae16a3b2f90404f"); +var tk = Rl("c3a5c85c97cb3127"); +var Gr = Rl("b492b66fbe98f273"); +var on = Rl("9ae16a3b2f90404f"); function em(e) { return e.xor(e.shru(47)); } @@ -4042,7 +4042,7 @@ function rx(e, t) { function Lt(e, t) { return t === 0 ? e : e.shru(t).or(e.shl(64 - t)); } -function ur(e, t, n = El("9ddfea08eb382d69")) { +function ur(e, t, n = Rl("9ddfea08eb382d69")) { let s = e.xor(t).mul(n); s = s.xor(s.shru(47)); let r = t.xor(s).mul(n); @@ -4095,7 +4095,7 @@ function M$(e, t = e.length) { 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], ur(ur(i[0], o[0], p).add(em(r).mul(tk)).add(a), ur(i[1], o[1], p).add(s), p); } function L$(e, t) { - return t === "string" ? Rl(e) : lp([e], t); + return t === "string" ? Dl(e) : lp([e], t); } function B$(e, t) { return e instanceof Float32Array && t === "float32" || e instanceof Int32Array && t === "int32" || e instanceof Uint8Array && t === "bool"; @@ -4117,13 +4117,13 @@ function lp(e, t) { } else throw new Error(`Unknown data type ${t}`); } -function Wu() { +function Uu() { return X().platform.now(); } function V$(e, t) { return X().platform.fetch(e, t); } -function Rl(e, t = "utf-8") { +function Dl(e, t = "utf-8") { return t = t || "utf-8", X().platform.encode(e, t); } function md(e, t = "utf-8") { @@ -4136,14 +4136,14 @@ var W$ = class { profileKernel(e, t, n) { let s, r = () => { s = n(); - }, a, i = Wu(); + }, a, i = Uu(); if (this.backendTimer.timerAvailable()) a = this.backendTimer.time(r); else { r(); for (let u of s) u.dataSync(); - a = Promise.resolve({ kernelMs: Wu() - i }); + a = Promise.resolve({ kernelMs: Uu() - i }); } if (X().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let u = 0; u < s.length; u++) { @@ -4175,7 +4175,7 @@ function U$(e, t, n) { } var G$ = class { logKernelProfile(e, t, n, s, r, a) { - let i = typeof s == "number" ? Pu(`${s}ms`, 9) : s.error, o = Pu(e, 25), u = t.rank, l = t.size, c = Pu(t.shape.toString(), 14), p = ""; + let i = typeof s == "number" ? zu(`${s}ms`, 9) : s.error, o = zu(e, 25), u = t.rank, l = t.size, c = zu(t.shape.toString(), 14), p = ""; for (let d in r) { let h = r[d]; if (h != null) { @@ -4258,27 +4258,27 @@ function q$(e, t, n, s) { } } var ax = 20; -var Iu = 3; +var Su = 3; var Ff = 7; function j$(e, t, n, s) { - let r = ro(t), a = K$(e, t, n, r), i = t.length, o = ed(e, t, n, r, a), u = ["Tensor"]; + let r = ao(t), a = K$(e, t, n, r), i = t.length, o = ed(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 K$(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" ? $u(e) : e; + let r = pt(t), a = s[s.length - 1], i = new Array(a).fill(0), o = t.length, u = n === "complex64" ? _u(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], Tu(u[c + p], 0, n).length); + i[p] = Math.max(i[p], $u(u[c + p], 0, n).length); } return i; } -function Tu(e, t, n) { +function $u(e, t, n) { let s; - return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(Ff))} + ${parseFloat(e[1].toFixed(Ff))}j` : ir(e) ? s = `'${e}'` : n === "bool" ? s = sk(e) : s = parseFloat(e.toFixed(Ff)).toString(), Pu(s, t); + return Array.isArray(e) ? s = `${parseFloat(e[0].toFixed(Ff))} + ${parseFloat(e[1].toFixed(Ff))}j` : ir(e) ? s = `'${e}'` : n === "bool" ? s = sk(e) : s = parseFloat(e.toFixed(Ff)).toString(), zu(s, t); } function sk(e) { return e === 0 ? "false" : "true"; @@ -4287,27 +4287,27 @@ function ed(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 = $u(e); - return [Tu(m[0], 0, n)]; + let m = _u(e); + return [$u(m[0], 0, n)]; } return n === "bool" ? [sk(e[0])] : [e[0].toString()]; } if (u === 1) { if (o > ax) { - let g = Iu * i, b = Array.from(e.slice(0, g)), y = Array.from(e.slice((o - Iu) * i, o * i)); - return n === "complex64" && (b = $u(b), y = $u(y)), ["[" + b.map((v, x) => Tu(v, r[x], n)).join(", ") + ", ..., " + y.map((v, x) => Tu(v, r[o - Iu + x], n)).join(", ") + "]"]; + let g = Su * i, b = Array.from(e.slice(0, g)), y = Array.from(e.slice((o - Su) * i, o * i)); + return n === "complex64" && (b = _u(b), y = _u(y)), ["[" + b.map((v, x) => $u(v, r[x], n)).join(", ") + ", ..., " + y.map((v, x) => $u(v, r[o - Su + x], n)).join(", ") + "]"]; } - let m = n === "complex64" ? $u(e) : Array.from(e); - return ["[" + m.map((g, b) => Tu(g, r[b], n)).join(", ") + "]"]; + let m = n === "complex64" ? _u(e) : Array.from(e); + return ["[" + m.map((g, b) => $u(g, r[b], n)).join(", ") + "]"]; } let l = t.slice(1), c = s.slice(1), p = s[0] * i, d = []; if (o > ax) { - for (let m = 0; m < Iu; m++) { + for (let m = 0; m < Su; m++) { let g = m * p, b = g + p; d.push(...ed(e.slice(g, b), l, n, c, r, false)); } d.push("..."); - for (let m = o - Iu; m < o; m++) { + for (let m = o - Su; m < o; m++) { let g = m * p, b = g + p; d.push(...ed(e.slice(g, b), l, n, c, r, m === o - 1)); } @@ -4327,7 +4327,7 @@ function ed(e, t, n, s, r, a = true) { `; return d[d.length - 1] = " " + d[d.length - 1] + "]" + (a ? "" : f), d; } -function $u(e) { +function _u(e) { let t = []; for (let n = 0; n < e.length; n += 2) t.push([e[n], e[n + 1]]); @@ -4341,7 +4341,7 @@ var Vt = class { } 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 = ro(e); + this.values = n || qw(t, this.size), this.strides = ao(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})`); @@ -4404,7 +4404,7 @@ function Z$(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 = ro(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 = pt(e), this.strides = ao(e), this.dataId = n, this.id = s, this.rankType = this.rank < 5 ? this.rank.toString() : "higher"; } get rank() { return this.shape.length; @@ -4489,8 +4489,7 @@ function J$() { J$(); var gd = class extends et { constructor(e, t, n, s) { - super(e.shape, e.dtype, e.dataId, s); - this.trainable = t, this.name = n; + super(e.shape, e.dtype, e.dataId, s), this.trainable = t, this.name = n; } assign(e) { if (e.dtype !== this.dtype) @@ -4648,7 +4647,7 @@ var tm = class { throw new Error(`Cannot initialize backend ${e}, no registration found.`); try { let n = t.factory(); - if (n && !(n instanceof tl) && typeof n.then == "function") { + if (n && !(n instanceof nl) && 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, ar(`Initialization of backend ${e} failed`), ar(a.stack || a.message)), false)); return this.pendingBackendInit = r, { success: r, asyncInit: true }; } else @@ -4796,7 +4795,7 @@ var tm = class { throw new Error("Values passed to engine.makeTensor() are null"); n = n || "float32", s = s || this.backend; let r = e; - n === "string" && ir(e[0]) && (r = e.map((o) => Rl(o))); + n === "string" && ir(e[0]) && (r = e.map((o) => Dl(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 = Xw(r); @@ -4941,8 +4940,8 @@ var tm = class { return this.state.tensorInfo.get(e).backend.readToGPU(e, t); } async time(e) { - let t = Wu(), n = await this.backend.time(e); - return n.wallMs = Wu() - t, n; + let t = Uu(), n = await this.backend.time(e); + return n.wallMs = Uu() - t, n; } track(e) { return this.state.activeScope != null && (e.scopeId = this.state.activeScope.id, this.state.activeScope.track.push(e)), e; @@ -5060,7 +5059,7 @@ function _(e, t, n, s = "numeric") { let o = r !== "string" ? lp(e, r) : sa(e, [], true); return M.makeTensor(o, a, r); } -function Uu(e, t, n, s = "numeric") { +function Gu(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)); @@ -5271,7 +5270,7 @@ async function Pg(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 Dl(e) { +function Fl(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 : ux(JSON.stringify(e.modelTopology)), weightSpecsBytes: e.weightSpecs == null ? 0 : ux(JSON.stringify(e.weightSpecs)), weightDataBytes: e.weightData == null ? 0 : e.weightData.byteLength }; @@ -5390,7 +5389,7 @@ var ua = class { n(u.result.modelArtifacts); }, u.onerror = (l) => (a.close(), s(u.error)), i.oncomplete = () => a.close(); } else { - let i = Dl(t), o = a.transaction(or, "readwrite"), u = o.objectStore(or), l = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), c; + let i = Fl(t), o = a.transaction(or, "readwrite"), u = o.objectStore(or), l = u.put({ modelPath: this.modelPath, modelArtifactsInfo: i }), c; l.onsuccess = () => { c = a.transaction(Yr, "readwrite"); let d = c.objectStore(Yr).put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: i }); @@ -5493,7 +5492,7 @@ var la = class { 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 = Dl(e); + let t = JSON.stringify(e.modelTopology), n = JSON.stringify(e.weightSpecs), s = Fl(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, h_(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 }; @@ -5694,7 +5693,7 @@ ck(); var G_ = { buffer: De, cast: ce, clone: lr, print: U_ }; Q$(G_); var En = {}; -Ae(En, { browserFiles: () => Q_, browserHTTPRequest: () => nA, concatenateArrayBuffers: () => Og, copyModel: () => P_, decodeWeights: () => hk, encodeWeights: () => d_, fromMemory: () => rA, getLoadHandlers: () => k_, getModelArtifactsForJSON: () => Pg, getModelArtifactsInfoForJSON: () => Dl, getSaveHandlers: () => w_, http: () => Mg, isHTTPScheme: () => um, listModels: () => F_, loadWeights: () => Z_, moveModel: () => z_, registerLoadRouter: () => x_, registerSaveRouter: () => v_, removeModel: () => O_, weightsLoaderFactory: () => Ik, withSaveHandler: () => aA }); +Ae(En, { browserFiles: () => Q_, browserHTTPRequest: () => nA, concatenateArrayBuffers: () => Og, copyModel: () => P_, decodeWeights: () => hk, encodeWeights: () => d_, fromMemory: () => rA, getLoadHandlers: () => k_, getModelArtifactsForJSON: () => Pg, getModelArtifactsInfoForJSON: () => Fl, getSaveHandlers: () => w_, http: () => Mg, isHTTPScheme: () => um, listModels: () => F_, loadWeights: () => Z_, moveModel: () => z_, registerLoadRouter: () => x_, registerSaveRouter: () => v_, removeModel: () => O_, weightsLoaderFactory: () => Ik, withSaveHandler: () => aA }); var H_ = "model"; var q_ = ".json"; var j_ = ".weights.bin"; @@ -5719,7 +5718,7 @@ var om = class { let i = this.weightDataAnchor == null ? document.createElement("a") : this.weightDataAnchor; i.download = this.weightDataFileName, i.href = t, await cx(() => i.dispatchEvent(new MouseEvent("click"))); } - return { modelArtifactsInfo: Dl(e) }; + return { modelArtifactsInfo: Fl(e) }; } } }; @@ -5875,7 +5874,7 @@ var zg = class { t.body.append("model.json", new Blob([JSON.stringify(s)], { type: eA }), "model.json"), e.weightData != null && t.body.append("model.weights.bin", new Blob([e.weightData], { type: J_ }), "model.weights.bin"); let r = await this.fetch(this.path, t); if (r.ok) - return { modelArtifactsInfo: Dl(e), responses: [r] }; + return { modelArtifactsInfo: Fl(e), responses: [r] }; throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`); } async load() { @@ -5968,7 +5967,7 @@ function uA(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(To, a, i); + return M.runKernel($o, a, i); } var vd = L({ oneHot_: uA }); function lA(e, t) { @@ -5988,8 +5987,8 @@ function cA(e, t, n) { return ce(u, "int32"); } var dA = L({ confusionMatrix_: cA }); -var qo = {}; -Ae(qo, { assertAndGetBroadcastShape: () => ot, getBroadcastDims: () => Ck, getReductionAxes: () => _t }); +var jo = {}; +Ae(jo, { assertAndGetBroadcastShape: () => ot, getBroadcastDims: () => Ck, getReductionAxes: () => _t }); function Ck(e, t) { let n = e.length, s = []; for (let r = 0; r < n; r++) { @@ -6175,7 +6174,7 @@ function _k(e, t) { let l = 1; for (let p = a; p < n; ++p) l *= o[p], u.push(o[p]); - let c = [...ro(e.shape).map((p) => p / l), 1].slice(0, a); + let c = [...ao(e.shape).map((p) => p / l), 1].slice(0, a); return [u, i, l, c]; } var Ak = {}; @@ -6216,7 +6215,7 @@ function Ek(e, t, n) { let s = t.shape.length, r = s > 1 ? t.shape[s - 1] : 1, a = n.length, i = 1; for (let p = r; p < a; ++p) i *= n[p]; - let o = r < 1 ? 1 : r, u = pt(t.shape) / o, l = [...ro(n.slice(0, r)), 1], c = pt(n); + let o = r < 1 ? 1 : r, u = pt(t.shape) / o, l = [...ao(n.slice(0, r)), 1], c = pt(n); return { sliceRank: r, numUpdates: u, sliceSize: i, strides: l, outputSize: c }; } var wt = {}; @@ -6290,7 +6289,7 @@ function Pk(e, t, n, s, r) { } for (let o = 0; o < a.length; o++) { let u = r[o]; - a[o] < 0 && (a[o] += u), a[o] = Bu(0, a[o], r[o]); + a[o] < 0 && (a[o] += u), a[o] = Vu(0, a[o], r[o]); } return a; } @@ -6302,13 +6301,13 @@ function Mk(e, t, n, s, r, a) { let i = t[r], o = n[r] || 1; (e & 1 << r || a & 1 << r || i == null) && (o > 0 ? i = Number.MIN_SAFE_INTEGER : i = Number.MAX_SAFE_INTEGER); let u = s[r]; - return i < 0 && (i += u), i = Bu(0, i, u - 1), i; + return i < 0 && (i += u), i = Vu(0, i, u - 1), i; } function Lk(e, t, n, s, r, a) { let i = t[r], o = n[r] || 1; (e & 1 << r || a & 1 << r || i == null) && (o > 0 ? i = Number.MAX_SAFE_INTEGER : i = Number.MIN_SAFE_INTEGER); let u = s[r]; - return i < 0 && (i += u), o > 0 ? i = Bu(0, i, u) : i = Bu(-1, i, u - 1), i; + return i < 0 && (i += u), o > 0 ? i = Vu(0, i, u) : i = Vu(-1, i, u - 1), i; } function CA(e, t, n) { let s = n.length; @@ -6498,25 +6497,25 @@ function PA(e, t) { function Uk(e) { for (let t = 0; t < e.length; t++) { let n = e[t]; - Array.isArray(n) ? Uk(n) : e[t] = Rl(n); + Array.isArray(n) ? Uk(n) : e[t] = Dl(n); } return e; } -var Ede = "0.0.0"; -function Rde() { +var Rde = "0.0.0"; +function Dde() { X().set("PROD", true); } -function Dde() { +function Fde() { X().set("DEBUG", true); } -function Fde() { +function Ode() { X().set("DEPRECATION_WARNINGS_ENABLED", false), console.warn("TensorFlow.js deprecation warnings have been disabled."); } function Gk(e) { X().getBool("DEPRECATION_WARNINGS_ENABLED") && console.warn(e + " You can disable deprecation warnings with tf.disableDeprecationWarnings()."); } Z$(Gk); -function Ode() { +function Pde() { M.disposeVariables(); } function Ss() { @@ -6525,7 +6524,7 @@ function Ss() { function dm() { return M.memory(); } -function Pde(e) { +function zde(e) { return M.profile(e); } function j(e, t) { @@ -6537,25 +6536,25 @@ function Re(e) { function Ht(e) { return M.keep(e); } -function zde(e) { +function Mde(e) { return M.time(e); } -function Mde(e) { +function Lde(e) { return M.setBackend(e); } -function Lde() { +function Bde() { return M.ready(); } -function Bde() { +function Vde() { return M.backendName; } -function Vde(e) { +function Wde(e) { M.removeBackend(e); } -function Wde(e) { +function Ude(e) { return M.findBackend(e); } -function Ude(e) { +function Gde(e) { return M.findBackendFactory(e); } function pp(e, t, n = 1) { @@ -6564,7 +6563,7 @@ function pp(e, t, n = 1) { function zA() { return M.backend; } -function Gde(e, t) { +function Hde(e, t) { X().setPlatform(e, t); } function MA(e, t) { @@ -6603,18 +6602,18 @@ function WA(e) { return M.runKernel(Kd, n); } else { let n = { x: t }; - return M.runKernel(ao, n); + return M.runKernel(io, n); } } var Mt = L({ abs_: WA }); function UA(e) { let n = { x: _(e, "x", "acos") }; - return M.runKernel(nl, n); + return M.runKernel(sl, n); } var GA = L({ acos_: UA }); function HA(e) { let n = { x: _(e, "x", "acosh") }; - return M.runKernel(sl, n); + return M.runKernel(rl, n); } var qA = L({ acosh_: HA }); function jA(e) { @@ -6633,54 +6632,54 @@ function jA(e) { var KA = L({ addN_: jA }); function XA(e, t = null, n = false) { let r = { x: _(e, "x", "all", "bool") }, a = { axis: t, keepDims: n }; - return M.runKernel(rl, r, a); + return M.runKernel(al, r, a); } var qk = L({ all_: XA }); function YA(e, t = null, n = false) { let r = { x: _(e, "x", "any", "bool") }, a = { axis: t, keepDims: n }; - return M.runKernel(al, r, a); + return M.runKernel(il, r, a); } var pm = L({ any_: YA }); function QA(e, t = 0) { let s = { x: _(e, "x", "argMax") }, r = { axis: t }; return M.runKernel(Ia, s, r); } -var Gu = L({ argMax_: QA }); +var Hu = L({ argMax_: QA }); function ZA(e, t = 0) { let s = { x: _(e, "x", "argMin") }, r = { axis: t }; - return M.runKernel(il, s, r); + return M.runKernel(ol, s, r); } var JA = L({ argMin_: ZA }); function eE(e) { let n = { x: _(e, "x", "asin") }; - return M.runKernel(ol, n); + return M.runKernel(ul, n); } var tE = L({ asin_: eE }); function nE(e) { let n = { x: _(e, "x", "asinh") }; - return M.runKernel(ul, n); + return M.runKernel(ll, n); } var sE = L({ asinh_: nE }); function rE(e) { let n = { x: _(e, "x", "atan") }; - return M.runKernel(ll, n); + return M.runKernel(cl, n); } var aE = L({ atan_: rE }); function iE(e, t) { let n = _(e, "a", "atan2"), s = _(t, "b", "atan2"); [n, s] = vt(n, s); let r = { a: n, b: s }; - return M.runKernel(dl, r); + return M.runKernel(pl, r); } var oE = L({ atan2_: iE }); function uE(e) { let n = { x: _(e, "x", "atanh") }; - return M.runKernel(cl, n); + return M.runKernel(dl, n); } var lE = L({ atanh_: uE }); function cE(e, t, n, s, r = "NHWC", a) { let i = e[3], o = [...t, i], u = Xk(r); - return Fl(e, o, n, a, s, null, null, u); + return Ol(e, o, n, a, s, null, null, u); } function jk(e, t, n, s, r, a, i = "channelsLast") { let [o, u] = xd(t), l; @@ -6690,7 +6689,7 @@ function jk(e, t, n, s, r, a, i = "channelsLast") { l = [o, u, e[1], e[1]]; else throw new Error(`Unknown dataFormat ${i}`); - return Fl(e, l, n, s, r, a, false, i); + return Ol(e, l, n, s, r, a, false, i); } function dE(e, t, n, s, r, a, i = "NDHWC") { let [o, u, l] = hm(t), c, p; @@ -6702,7 +6701,7 @@ function dE(e, t, n, s, r, a, i = "NDHWC") { throw new Error(`Unknown dataFormat ${i}`); return Kk(e, c, n, s, r, false, p, a); } -function Fl(e, t, n, s, r, a, i = false, o = "channelsLast") { +function Ol(e, t, n, s, r, a, i = false, o = "channelsLast") { let [u, l, c, p] = [-1, -1, -1, -1]; if (o === "channelsLast") [u, l, c, p] = e; @@ -6828,7 +6827,7 @@ function hn(e, t, n) { } function gE(e, t) { let s = { x: _(e, "x", "reshape", "string_or_numeric") }, r = { shape: t }; - return M.runKernel(Ao, s, r); + return M.runKernel(Eo, s, r); } var G = L({ reshape_: gE }); function bE(e, t, n, s, r) { @@ -6849,7 +6848,7 @@ function yE(e, t, n, s, r, a = "NDHWC") { var Yk = L({ avgPool3d_: yE }); function vE(e, t = 0) { O(e.length >= 1, () => "Pass at least one tensor to concat"); - let n = Uu(e, "tensors", "concat", "string_or_numeric"); + let n = Gu(e, "tensors", "concat", "string_or_numeric"); if (n[0].dtype === "complex64" && n.forEach((a) => { if (a.dtype !== "complex64") throw new Error(`Cannot concatenate complex64 tensors with a tensor @@ -6857,7 +6856,7 @@ function vE(e, t = 0) { }), n.length === 1) return lr(n[0]); let s = n, r = { axis: t }; - return M.runKernel(oo, s, r); + return M.runKernel(uo, s, r); } var Ft = L({ concat_: vE }); function xE(e) { @@ -6870,24 +6869,24 @@ function wE(e, t, n) { if (s.rank === 0) throw new Error("Slicing scalar is not possible"); let r = { x: s }, a = { begin: t, size: n }; - return M.runKernel(Oo, r, a); + return M.runKernel(Po, r, a); } var He = L({ slice_: wE }); function kE(e) { let n = { x: _(e, "x", "tanh", "float32") }; return M.runKernel(di, n); } -var Hu = L({ tanh_: kE }); +var qu = L({ tanh_: kE }); function IE(e, t, n, s, r, a) { - let i = _(e, "forgetBias", "basicLSTMCell"), o = _(t, "lstmKernel", "basicLSTMCell"), u = _(n, "lstmBias", "basicLSTMCell"), l = _(s, "data", "basicLSTMCell"), c = _(r, "c", "basicLSTMCell"), p = _(a, "h", "basicLSTMCell"), d = Ft([l, p], 1), h = We(d, o), f = ie(h, u), m = f.shape[0], g = f.shape[1] / 4, b = [m, g], y = He(f, [0, 0], b), v = He(f, [0, g], b), x = He(f, [0, g * 2], b), k = He(f, [0, g * 3], b), T = ie(V(qs(y), Hu(v)), V(c, qs(ie(i, x)))), N = V(Hu(T), qs(k)); + let i = _(e, "forgetBias", "basicLSTMCell"), o = _(t, "lstmKernel", "basicLSTMCell"), u = _(n, "lstmBias", "basicLSTMCell"), l = _(s, "data", "basicLSTMCell"), c = _(r, "c", "basicLSTMCell"), p = _(a, "h", "basicLSTMCell"), d = Ft([l, p], 1), h = We(d, o), f = ie(h, u), m = f.shape[0], g = f.shape[1] / 4, b = [m, g], y = He(f, [0, 0], b), v = He(f, [0, g], b), x = He(f, [0, g * 2], b), k = He(f, [0, g * 3], b), T = ie(V(qs(y), qu(v)), V(c, qs(ie(i, x)))), N = V(qu(T), qs(k)); return [T, N]; } -var Hde = L({ basicLSTMCell_: IE }); +var qde = L({ basicLSTMCell_: IE }); function SE(e, t, n) { let s = _(e, "x", "batchToSpaceND"), r = t.reduce((o, u) => o * u); O(s.rank >= 1 + t.length, () => `input rank is ${s.rank} but should be > than blockShape.length ${t.length}`), O(n.length === t.length, () => `crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`), O(s.shape[0] % r === 0, () => `input tensor batch is ${s.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${r}`); let a = { x: s }, i = { blockShape: t, crops: n }; - return M.runKernel(io, a, i); + return M.runKernel(oo, a, i); } var Hg = L({ batchToSpaceND_: SE }); function CE(e) { @@ -6903,26 +6902,26 @@ function NE(e, t, n, s, r, a) { let d = { x: CE(i), scale: l, offset: c, mean: o, variance: u }, h = { varianceEpsilon: a }, f = M.runKernel(Ma, d, h); return G(f, i.shape); } -var qu = L({ batchNorm_: NE }); +var ju = L({ batchNorm_: NE }); function TE(e, t, n, s, r, a) { let i = _(e, "x", "batchNorm"), o = _(t, "mean", "batchNorm"), u = _(n, "variance", "batchNorm"), l; r != null && (l = _(r, "scale", "batchNorm")); let c; - return s != null && (c = _(s, "offset", "batchNorm")), O(i.rank === 2, () => `Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`), O(o.rank === 2 || o.rank === 1, () => `Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`), O(u.rank === 2 || u.rank === 1, () => `Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`), l != null && O(l.rank === 2 || l.rank === 1, () => `Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`), c != null && O(c.rank === 2 || c.rank === 1, () => `Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`), qu(i, o, u, c, l, a); + return s != null && (c = _(s, "offset", "batchNorm")), O(i.rank === 2, () => `Error in batchNorm2D: x must be rank 2 but got rank ${i.rank}.`), O(o.rank === 2 || o.rank === 1, () => `Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`), O(u.rank === 2 || u.rank === 1, () => `Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`), l != null && O(l.rank === 2 || l.rank === 1, () => `Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`), c != null && O(c.rank === 2 || c.rank === 1, () => `Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`), ju(i, o, u, c, l, a); } var $E = L({ batchNorm2d_: TE }); function _E(e, t, n, s, r, a) { let i = _(e, "x", "batchNorm"), o = _(t, "mean", "batchNorm"), u = _(n, "variance", "batchNorm"), l; r != null && (l = _(r, "scale", "batchNorm")); let c; - return s != null && (c = _(s, "offset", "batchNorm")), O(i.rank === 3, () => `Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`), O(o.rank === 3 || o.rank === 1, () => `Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`), O(u.rank === 3 || u.rank === 1, () => `Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`), l != null && O(l.rank === 3 || l.rank === 1, () => `Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`), c != null && O(c.rank === 3 || c.rank === 1, () => `Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`), qu(i, o, u, c, l, a); + return s != null && (c = _(s, "offset", "batchNorm")), O(i.rank === 3, () => `Error in batchNorm3D: x must be rank 3 but got rank ${i.rank}.`), O(o.rank === 3 || o.rank === 1, () => `Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`), O(u.rank === 3 || u.rank === 1, () => `Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`), l != null && O(l.rank === 3 || l.rank === 1, () => `Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`), c != null && O(c.rank === 3 || c.rank === 1, () => `Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`), ju(i, o, u, c, l, a); } var AE = L({ batchNorm3d_: _E }); function EE(e, t, n, s, r, a) { let i = _(e, "x", "batchNorm"), o = _(t, "mean", "batchNorm"), u = _(n, "variance", "batchNorm"), l; r != null && (l = _(r, "scale", "batchNorm")); let c; - return s != null && (c = _(s, "offset", "batchNorm")), O(i.rank === 4, () => `Error in batchNorm4D: x must be rank 4 but got rank ${i.rank}.`), O(o.rank === 4 || o.rank === 1, () => `Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`), O(u.rank === 4 || u.rank === 1, () => `Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`), l != null && O(l.rank === 4 || l.rank === 1, () => `Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`), c != null && O(c.rank === 4 || c.rank === 1, () => `Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`), qu(i, o, u, c, l, a); + return s != null && (c = _(s, "offset", "batchNorm")), O(i.rank === 4, () => `Error in batchNorm4D: x must be rank 4 but got rank ${i.rank}.`), O(o.rank === 4 || o.rank === 1, () => `Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`), O(u.rank === 4 || u.rank === 1, () => `Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`), l != null && O(l.rank === 4 || l.rank === 1, () => `Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`), c != null && O(c.rank === 4 || c.rank === 1, () => `Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`), ju(i, o, u, c, l, a); } var RE = L({ batchNorm4d_: EE }); function DE(e, t, n) { @@ -7059,12 +7058,12 @@ function sR(e) { var nI = L({ cosh_: sR }); function rR(e, t = 0, n = false, s = false) { let a = { x: _(e, "x", "cumprod") }, i = { axis: t, exclusive: n, reverse: s }; - return M.runKernel(pl, a, i); + return M.runKernel(hl, a, i); } var aR = L({ cumprod_: rR }); function iR(e, t = 0, n = false, s = false) { let a = { x: _(e, "x", "cumsum") }, i = { axis: t, exclusive: n, reverse: s }; - return M.runKernel(uo, a, i); + return M.runKernel(lo, a, i); } var sI = L({ cumsum_: iR }); function oR(e, t, n, s = false) { @@ -7082,7 +7081,7 @@ function lR(e, t, n = "NHWC") { ${a} and ${t} for depthToSpace with input shape ${s.shape}`), O(i % (t * t) === 0, () => `Dimension size must be evenly divisible by ${t * t} but is ${i} for depthToSpace with input shape ${s.shape}`); let o = { x: s }, u = { blockSize: t, dataFormat: n }; - return M.runKernel(co, o, u); + return M.runKernel(po, o, u); } var cR = L({ depthToSpace_: lR }); function dR(e, t, n, s, r = "NHWC", a = [1, 1], i) { @@ -7096,7 +7095,7 @@ function pR(e) { let n = { x: _(e, "x", "diag") }; return M.runKernel(gg, n); } -var qde = L({ diag_: pR }); +var jde = L({ diag_: pR }); function hR(e, t, n, s, r = [1, 1], a = "NHWC") { let i = _(e, "x", "dilation2d"), o = _(t, "filter", "dilation2d"); O(i.rank === 3 || i.rank === 4, () => `Error in dilation2d: input must be rank 3 or 4, but got rank ${i.rank}.`), O(o.rank === 3, () => `Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`), O(a === "NHWC", () => `Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${a}`); @@ -7110,17 +7109,17 @@ function mR(e, t) { let n = _(e, "a", "equal", "string_or_numeric"), s = _(t, "b", "equal", "string_or_numeric"); [n, s] = vt(n, s), ot(n.shape, s.shape); let r = { a: n, b: s }; - return M.runKernel(po, r); + return M.runKernel(ho, r); } var Kn = L({ equal_: mR }); function gR(e, t, n) { let s = _(t, "a", "where"), r = _(n, "b", "where"), a = _(e, "condition", "where", "bool"), i = ot(ot(a.shape, s.shape), r.shape), o = nd(a, i), u = nd(s, i), l = nd(r, i), c = { condition: o, t: u, e: l }; - return M.runKernel(Fo, c); + return M.runKernel(Oo, c); } var vn = L({ where_: gR }); function bR(e) { let n = { x: _(e, "x", "zerosLike") }; - return M.runKernel(Go, n); + return M.runKernel(Ho, n); } var je = L({ zerosLike_: bR }); function yR(e, t) { @@ -7148,7 +7147,7 @@ function xR(e, t) { return We(n, i); } } -var jde = L({ dot_: xR }); +var Kde = L({ dot_: xR }); function wR(e, ...t) { let n = t.map((r, a) => _(r, `tensors${a}`, "einsum")), s = { equation: e }; return M.runKernel(Qd, n, s); @@ -7163,7 +7162,7 @@ function SR(e) { let t = _(e, "x", "erf"); O(t.dtype === "int32" || t.dtype === "float32", () => "Input dtype must be `int32` or `float32`."), t.dtype === "int32" && (t = ce(t, "float32")); let n = { x: t }; - return M.runKernel(hl, n); + return M.runKernel(fl, n); } var CR = L({ erf_: SR }); function NR(e) { @@ -7175,12 +7174,12 @@ function TR(e, t = 0) { let n = _(e, "x", "expandDims", "string_or_numeric"); O(t <= n.rank, () => "Axis must be <= rank of the tensor"); let s = { input: n }, r = { dim: t }; - return M.runKernel(ho, s, r); + return M.runKernel(fo, s, r); } var Pn = L({ expandDims_: TR }); function $R(e) { let n = { x: _(e, "x", "expm1") }; - return M.runKernel(fo, n); + return M.runKernel(mo, n); } var _R = L({ expm1_: $R }); function AR(e, t) { @@ -7207,9 +7206,9 @@ function ER(e, t, n, s = "float32") { throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`); } var rI = L({ eye_: ER }); -function Ol(e, t, n) { +function Pl(e, t, n) { let s = { shape: e, value: t, dtype: n }; - return M.runKernel(fl, {}, s); + return M.runKernel(ml, {}, s); } function RR(e) { let n = { x: _(e, "x", "floor", "float32") }; @@ -7218,14 +7217,14 @@ function RR(e) { var mp = L({ floor_: RR }); function DR(e, t, n = 0, s = 0) { let r = _(e, "x", "gather"), a = _(t, "indices", "gather", "int32"), i = { x: r, indices: a }, o = { axis: n, batchDims: s }; - return M.runKernel(go, i, o); + return M.runKernel(bo, i, o); } -var ju = L({ gather_: DR }); +var Ku = L({ gather_: DR }); function FR(e, t) { let n = _(e, "a", "greater", "string_or_numeric"), s = _(t, "b", "greater", "string_or_numeric"); [n, s] = vt(n, s), ot(n.shape, s.shape); let r = { a: n, b: s }; - return M.runKernel(yo, r); + return M.runKernel(vo, r); } var Wn = L({ greater_: FR }); function OR(e, t) { @@ -7234,7 +7233,7 @@ function OR(e, t) { let r = { a: n, b: s }; return M.runKernel(La, r); } -var jo = L({ greaterEqual_: OR }); +var Ko = L({ greaterEqual_: OR }); function PR(e) { let n = { input: _(e, "input", "imag") }; return M.runKernel(Zd, n); @@ -7242,17 +7241,17 @@ function PR(e) { var Kg = L({ imag_: PR }); function zR(e) { let n = { x: _(e, "x", "isFinite") }; - return M.runKernel(ml, n); -} -var Kde = L({ isFinite_: zR }); -function MR(e) { - let n = { x: _(e, "x", "isInf") }; return M.runKernel(gl, n); } -var Xde = L({ isInf_: MR }); +var Xde = L({ isFinite_: zR }); +function MR(e) { + let n = { x: _(e, "x", "isInf") }; + return M.runKernel(bl, n); +} +var Yde = L({ isInf_: MR }); function LR(e) { let n = { x: _(e, "x", "isNaN") }; - return M.runKernel(bl, n); + return M.runKernel(yl, n); } var BR = L({ isNaN_: LR }); function VR(e, t = 0.2) { @@ -7264,16 +7263,16 @@ function WR(e, t) { let n = _(e, "a", "less", "string_or_numeric"), s = _(t, "b", "less", "string_or_numeric"); [n, s] = vt(n, s), ot(n.shape, s.shape); let r = { a: n, b: s }; - return M.runKernel(vo, r); + return M.runKernel(xo, r); } var aI = L({ less_: WR }); function UR(e, t) { let n = _(e, "a", "lessEqual", "string_or_numeric"), s = _(t, "b", "lessEqual", "string_or_numeric"); [n, s] = vt(n, s), ot(n.shape, s.shape); let r = { a: n, b: s }; - return M.runKernel(xo, r); + return M.runKernel(wo, r); } -var Ko = L({ lessEqual_: UR }); +var Xo = L({ lessEqual_: UR }); function GR(e, t, n) { if (n <= 0) throw new Error("The number of values should be positive."); @@ -7297,10 +7296,10 @@ function jR(e) { var Yn = L({ log_: jR }); function KR(e) { let n = { x: _(e, "x", "log1p") }; - return M.runKernel(yl, n); + return M.runKernel(vl, n); } var Yg = L({ log1p_: KR }); -function Yde(e) { +function Qde(e) { return O(hr(e), () => "The f passed in grad(f) must be a function"), (t, n) => { let s = _(t, "x", "tf.grad", "string_or_numeric"), r = n != null ? _(n, "dy", "tf.grad") : null; return M.tidy(() => { @@ -7309,24 +7308,24 @@ function Yde(e) { }); }; } -function Qde(e) { +function Zde(e) { return O(hr(e), () => "The f passed in grads(f) must be a function"), (t, n) => { O(Array.isArray(t), () => "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"); - let s = Uu(t, "args", "tf.grads", "string_or_numeric"), r = n != null ? _(n, "dy", "tf.grads") : null; + let s = Gu(t, "args", "tf.grads", "string_or_numeric"), r = n != null ? _(n, "dy", "tf.grads") : null; return M.tidy(() => { let { value: a, grads: i } = M.gradients(() => e(...s), s, r); return r != null && pn(a.shape, r.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), gp(i), i; }); }; } -function Zde(e) { +function Jde(e) { return O(hr(e), () => "The f passed in valueAndGrad(f) must be a function"), (t, n) => { O(t instanceof et, () => "The x passed in valueAndGrad(f)(x) must be a tensor"), O(n == null || n instanceof et, () => "The dy passed in valueAndGrad(f)(x, dy) must be a tensor"); let { grads: s, value: r } = M.gradients(() => e(t), [t], n); return gp(s), { grad: s[0], value: r }; }; } -function Jde(e) { +function epe(e) { return O(hr(e), () => "The f passed in valueAndGrads(f) must be a function"), (t, n) => { O(Array.isArray(t) && t.every((r) => r instanceof et), () => "The args passed in valueAndGrads(f)(args) must be array of tensors"), O(n == null || n instanceof et, () => "The dy passed in valueAndGrads(f)(args, dy) must be a tensor"); let s = M.gradients(() => e(...t), t, n); @@ -7360,19 +7359,19 @@ function gp(e) { } function YR(e) { let n = { x: _(e, "x", "neg") }; - return M.runKernel(ko, n); + return M.runKernel(Io, n); } var kt = L({ neg_: YR }); function QR(e) { let n = { x: _(e, "x", "softplus") }; - return M.runKernel(Tl, n); + return M.runKernel($l, n); } -var Pl = L({ softplus_: QR }); +var zl = L({ softplus_: QR }); function ZR(e) { let t = _(e, "x", "logSigmoid"); - return js((s) => ({ value: kt(Pl(kt(s))), gradFunc: (i) => V(i, qs(kt(s))) }))(t); + return js((s) => ({ value: kt(zl(kt(s))), gradFunc: (i) => V(i, qs(kt(s))) }))(t); } -var epe = L({ logSigmoid_: ZR }); +var tpe = L({ logSigmoid_: ZR }); function JR(e, t = null, n = false) { let r = { x: _(e, "x", "max") }, a = { reductionIndices: t, keepDims: n }; return M.runKernel(Ua, r, a); @@ -7461,12 +7460,12 @@ function oD(e, t) { let n = _(e, "a", "logicalAnd", "bool"), s = _(t, "b", "logicalAnd", "bool"); ot(n.shape, s.shape); let r = { a: n, b: s }; - return M.runKernel(wo, r); + return M.runKernel(ko, r); } var Ds = L({ logicalAnd_: oD }); function uD(e) { let n = { x: _(e, "x", "logicalNot", "bool") }; - return M.runKernel(vl, n); + return M.runKernel(xl, n); } var Jg = L({ logicalNot_: uD }); function lD(e, t) { @@ -7480,7 +7479,7 @@ function cD(e, t) { let n = _(e, "a", "logicalXor", "bool"), s = _(t, "b", "logicalXor", "bool"); return ot(n.shape, s.shape), Ds(cI(e, t), Jg(Ds(e, t))); } -var tpe = L({ logicalXor_: cD }); +var npe = L({ logicalXor_: cD }); function dD(e, t, n, s, r) { let a = _(e, "x", "maxPool"), i = 1, o = a, u = false; a.rank === 3 && (u = true, o = G(a, [1, a.shape[0], a.shape[1], a.shape[2]])), O(o.rank === 4, () => `Error in maxPool: input must be rank 4 but got rank ${o.rank}.`), O(Ps(n, i), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`), hn("maxPool", s, r); @@ -7528,7 +7527,7 @@ function Mn(e, t = "float32") { let n = ng(pt(e), t); return M.makeTensor(n, e, t); } -function npe(e, t, { indexing: n = "xy" } = {}) { +function spe(e, t, { indexing: n = "xy" } = {}) { if (n !== "xy" && n !== "ij") throw new TypeError(`${n} is not a valid third argument to meshgrid`); if (e === void 0) @@ -7568,7 +7567,7 @@ function wD(e, t) { let n = _(e, "a", "mod"), s = _(t, "b", "mod"); [n, s] = vt(n, s); let r = { a: n, b: s }; - return M.runKernel(xl, r); + return M.runKernel(wl, r); } var kD = L({ mod_: wD }); function ID(e) { @@ -7585,7 +7584,7 @@ function SD(e, t = null, n = false) { } var tb = L({ moments_: SD }); function CD(e, t, n, s) { - let r = _(t, "data", "multiRNNCell"), a = Uu(n, "c", "multiRNNCell"), i = Uu(s, "h", "multiRNNCell"), o = r, u = []; + let r = _(t, "data", "multiRNNCell"), a = Gu(n, "c", "multiRNNCell"), i = Gu(s, "h", "multiRNNCell"), o = r, u = []; for (let p = 0; p < e.length; p++) { let d = e[p](o, a[p], i[p]); u.push(d[0]), u.push(d[1]), o = d[1]; @@ -7595,7 +7594,7 @@ function CD(e, t, n, s) { l.push(u[p]), c.push(u[p + 1]); return [l, c]; } -var spe = L({ multiRNNCell_: CD }); +var rpe = L({ multiRNNCell_: CD }); function ND(e, t, n, s = false) { let r = _(e, "logits", "multinomial"), a = r.size, i = r.rank; if (a < 2) @@ -7611,12 +7610,12 @@ function $D(e, t) { let n = _(e, "a", "notEqual", "string_or_numeric"), s = _(t, "b", "notEqual", "string_or_numeric"); [n, s] = vt(n, s), ot(n.shape, s.shape); let r = { a: n, b: s }; - return M.runKernel(Io, r); + return M.runKernel(So, r); } -var Ku = L({ notEqual_: $D }); +var Xu = L({ notEqual_: $D }); function _D(e) { let n = { x: _(e, "x", "onesLike") }; - return M.runKernel(No, n); + return M.runKernel(To, n); } var Qn = L({ onesLike_: _D }); function AD(e, t) { @@ -7625,7 +7624,7 @@ function AD(e, t) { let r = G(n, [-1, 1]), a = G(s, [1, -1]); return We(r, a); } -var rpe = L({ outerProduct_: AD }); +var ape = L({ outerProduct_: AD }); function ED(e, t, n = 0) { let s = _(e, "x", "pad"); if (s.rank === 0) @@ -7637,24 +7636,24 @@ var fi = L({ pad_: ED }); function RD(e, t, n = 0) { return O(t.length === 2, () => "Invalid number of paddings. Must be length of 2."), fi(e, [t], n); } -var ape = L({ pad1d_: RD }); +var ipe = L({ pad1d_: RD }); function DD(e, t, n = 0) { return O(t.length === 2 && t[0].length === 2 && t[1].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), fi(e, t, n); } -var ipe = L({ pad2d_: DD }); +var ope = L({ pad2d_: DD }); function FD(e, t, n = 0) { return O(t.length === 3 && t[0].length === 2 && t[1].length === 2 && t[2].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), fi(e, t, n); } -var ope = L({ pad3d_: FD }); +var upe = L({ pad3d_: FD }); function OD(e, t, n = 0) { return O(t.length === 4 && t[0].length === 2 && t[1].length === 2 && t[2].length === 2 && t[3].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), fi(e, t, n); } -var upe = L({ pad4d_: OD }); +var lpe = L({ pad4d_: OD }); function PD(e, t, n) { let s = _(e, "x", "spaceToBatchND"); O(s.rank >= 1 + t.length, () => `input rank ${s.rank} should be > than [blockShape] ${t.length}`), O(n.length === t.length, () => `paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`), O(s.shape.reduce((i, o, u) => u > 0 && u <= t.length ? i && (o + n[u - 1][0] + n[u - 1][1]) % t[u - 1] === 0 : i, true), () => `input spatial dimensions ${s.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`); let r = { x: s }, a = { blockShape: t, paddings: n }; - return M.runKernel(zo, r, a); + return M.runKernel(Mo, r, a); } var nb = L({ spaceToBatchND_: PD }); function zD(e, t, n, s, r, a, i) { @@ -7674,7 +7673,7 @@ function LD(e, t) { let s = e.map((i, o) => i + (i - 1) * (t[o] - 1)).map((i) => i - 1), r = s.map((i) => Math.floor(i / 2)), a = s.map((i, o) => i - r[o]); return s.map((i, o) => [r[o], a[o]]); } -var lpe = L({ pool_: zD }); +var cpe = L({ pool_: zD }); function BD(e, t) { let n = _(e, "base", "pow"), s = _(t, "exp", "pow"); [n, s] = vt(n, s); @@ -7691,7 +7690,7 @@ function WD(e, t = null, n = false) { let s = _(e, "x", "prod"); s.dtype === "bool" && (s = ce(s, "int32")); let r = { x: s }, a = { axis: t, keepDims: n }; - return M.runKernel(_o, r, a); + return M.runKernel(Ao, r, a); } var pI = L({ prod_: WD }); function UD(e, t, n) { @@ -7708,7 +7707,7 @@ function UD(e, t, n) { r[a] = t(); return M.makeTensor(r, e, n); } -var cpe = L({ rand_: UD }); +var dpe = L({ rand_: UD }); var rb = xa(Wd()); var ab = class { constructor(e, t, n, s, r) { @@ -7781,7 +7780,7 @@ function qD(e, t, n = 1, s = "float32", r) { i.values[o] = a.nextValue(); return i.toTensor(); } -var dpe = L({ randomGamma_: qD }); +var ppe = L({ randomGamma_: qD }); function jD(e, t = 0, n = 1, s, r) { if (s != null && s === "bool") throw new Error(`Unsupported data type ${s}`); @@ -7797,12 +7796,12 @@ function XD(e, t = 0, n = 1, s = "float32", r) { a.values[o] = i.nextValue(); return a.toTensor(); } -var zl = L({ randomUniform_: XD }); -function Xu(e, t, n = 1, s = "float32") { +var Ml = L({ randomUniform_: XD }); +function Yu(e, t, n = 1, s = "float32") { if (n === 0) throw new Error("Cannot have a step of zero"); let r = { start: e, stop: t, step: n, dtype: s }; - return M.runKernel(kl, {}, r); + return M.runKernel(Il, {}, r); } function YD(e) { let n = { input: _(e, "input", "real") }; @@ -7811,7 +7810,7 @@ function YD(e) { var wd = L({ real_: YD }); function QD(e) { let n = { x: _(e, "x", "reciprocal") }; - return M.runKernel(Il, n); + return M.runKernel(Sl, n); } var ZD = L({ reciprocal_: QD }); function JD(e) { @@ -7826,32 +7825,32 @@ function e3(e) { var hI = L({ relu6_: e3 }); function t3(e, t) { let s = { x: _(e, "x", "reverse") }, r = { dims: t }; - return M.runKernel(Eo, s, r); + return M.runKernel(Ro, s, r); } var Zn = L({ reverse_: t3 }); function n3(e) { let t = _(e, "x", "reverse"); return O(t.rank === 1, () => `Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`), Zn(t, 0); } -var ppe = L({ reverse1d_: n3 }); +var hpe = L({ reverse1d_: n3 }); function s3(e, t) { let n = _(e, "x", "reverse"); return O(n.rank === 2, () => `Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`), Zn(n, t); } -var hpe = L({ reverse2d_: s3 }); +var fpe = L({ reverse2d_: s3 }); function r3(e, t) { let n = _(e, "x", "reverse"); return O(n.rank === 3, () => `Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`), Zn(n, t); } -var fpe = L({ reverse3d_: r3 }); +var mpe = L({ reverse3d_: r3 }); function a3(e, t) { let n = _(e, "x", "reverse"); return O(n.rank === 4, () => `Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`), Zn(n, t); } -var mpe = L({ reverse4d_: a3 }); +var gpe = L({ reverse4d_: a3 }); function i3(e) { let n = { x: _(e, "x", "round") }; - return M.runKernel(Ro, n); + return M.runKernel(Do, n); } var fI = L({ round_: i3 }); function o3(e) { @@ -7868,7 +7867,7 @@ function we(e, t) { } function u3(e) { let n = { x: _(e, "x", "selu") }; - return M.runKernel(Cl, n); + return M.runKernel(Nl, n); } var gI = L({ selu_: u3 }); function l3(e, t, n, s, r, a = [1, 1], i = "NHWC") { @@ -7896,7 +7895,7 @@ async function d3(e, t) { var p3 = d3; function h3(e) { let n = { x: _(e, "x", "sign") }; - return M.runKernel(Nl, n); + return M.runKernel(Tl, n); } var f3 = L({ sign_: h3 }); function m3(e) { @@ -7906,7 +7905,7 @@ function m3(e) { var bI = L({ sin_: m3 }); function g3(e) { let n = { x: _(e, "x", "sinh") }; - return M.runKernel(Po, n); + return M.runKernel(zo, n); } var yI = L({ sinh_: g3 }); function b3(e, t, n) { @@ -7967,7 +7966,7 @@ function S3(e) { var xI = L({ irfft_: S3 }); function C3(e, t, n = 0) { let r = { x: _(e, "x", "split") }, a = { numOrSizeSplits: t, axis: n }; - return M.runKernel(Mo, r, a); + return M.runKernel(Lo, r, a); } var Bn = L({ split_: C3 }); function N3(e, t) { @@ -8003,10 +8002,10 @@ function _3(e, t) { } var mr = L({ squeeze_: _3 }); function A3(e, t = 0) { - let n = Uu(e, "tensors", "stack", "string_or_numeric"); + let n = Gu(e, "tensors", "stack", "string_or_numeric"); O(n.length >= 1, () => "Pass at least one tensor to tf.stack"), n.length > 0 && O(t <= n[0].rank, () => "Axis must be <= rank of the tensor"); let s = n, r = { axis: t }; - return M.runKernel($o, s, r); + return M.runKernel(_o, s, r); } var Jn = L({ stack_: A3 }); function E3(e, t = 0) { @@ -8016,12 +8015,12 @@ function E3(e, t = 0) { var yp = L({ step_: E3 }); function R3(e, t, n, s, r = 0, a = 0, i = 0, o = 0, u = 0) { let c = { x: _(e, "x", "stridedSlice", "string_or_numeric") }, p = { begin: t, end: n, strides: s, beginMask: r, endMask: a, ellipsisMask: i, newAxisMask: o, shrinkAxisMask: u }; - return M.runKernel(Lo, c, p); + return M.runKernel(Bo, c, p); } var D3 = L({ stridedSlice_: R3 }); function F3(e) { let n = { x: _(e, "x", "tan", "float32") }; - return M.runKernel(Bo, n); + return M.runKernel(Vo, n); } var O3 = L({ tan_: F3 }); function Zt(e, t) { @@ -8041,7 +8040,7 @@ function Ki(e, t, n) { throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray"); return Nr(e, t, s, n); } -function gpe(e, t, n) { +function bpe(e, t, n) { if (wa(e), t != null && t.length !== 4) throw new Error("tensor4d() requires shape to have four numbers"); let s = Rs(e, n); @@ -8051,7 +8050,7 @@ function gpe(e, t, n) { throw new Error("tensor4d() requires shape to be provided when `values` are a flat array"); return Nr(e, t, s, n); } -function bpe(e, t, n) { +function ype(e, t, n) { if (wa(e), t != null && t.length !== 5) throw new Error("tensor5d() requires shape to have five numbers"); let s = Rs(e, n); @@ -8061,7 +8060,7 @@ function bpe(e, t, n) { throw new Error("tensor5d() requires shape to be provided when `values` are a flat array"); return Nr(e, t, s, n); } -function ype(e, t, n) { +function vpe(e, t, n) { if (wa(e), t != null && t.length !== 6) throw new Error("tensor6d() requires shape to have six numbers"); let s = Rs(e, n); @@ -8080,7 +8079,7 @@ function P3(e, t = 1, n = true) { throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`); if (t > r) throw new Error(`'k' passed to topk() must be <= the last dimension (${r}) but got ${t}`); - let a = { x: s }, i = { k: t, sorted: n }, [o, u] = M.runKernel(Vo, a, i); + let a = { x: s }, i = { k: t, sorted: n }, [o, u] = M.runKernel(Wo, a, i); return { values: o, indices: u }; } var z3 = L({ topk_: P3 }); @@ -8111,7 +8110,7 @@ function W3(e, t = 0) { let n = _(e, "x", "unstack", "string_or_numeric"); O(t >= -n.shape.length && t < n.shape.length, () => `Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`); let s = { value: n }, r = { axis: t }; - return M.runKernel(Uo, s, r); + return M.runKernel(Go, s, r); } var Fs = L({ unstack_: W3 }); function U3(e, t = true, n, s) { @@ -8139,10 +8138,10 @@ async function H3(e, t, n) { let u = 1; for (let m = a; m < a + i; m++) u *= o[m]; - let l = o.slice(0, a).concat([u], o.slice(a + i)), c = G(s, l), p = G(r, [-1]), d = await II(p), h = mr(d, [1]), f = ju(c, h, a); + let l = o.slice(0, a).concat([u], o.slice(a + i)), c = G(s, l), p = G(r, [-1]), d = await II(p), h = mr(d, [1]), f = Ku(c, h, a); return e !== s && s.dispose(), t !== r && r.dispose(), h.dispose(), c.dispose(), p.dispose(), d.dispose(), f; } -var vpe = H3; +var xpe = H3; function q3(e, t = "euclidean", n = null, s = false) { e = _(e, "x", "norm"); let r = SI(e, t, n), a = r.shape; @@ -8193,12 +8192,12 @@ function j3(e, t, n, s, r = true) { } return ie(a, c); } -var xpe = L({ movingAverage_: j3 }); +var wpe = L({ movingAverage_: j3 }); function K3(e, t, n) { let s = _(e, "indices", "scatterND", "int32"), r = _(t, "updates", "scatterND"); Bg(r, s, n); let a = { indices: s, updates: r }, i = { shape: n }; - return M.runKernel(Do, a, i); + return M.runKernel(Fo, a, i); } var X3 = L({ scatterND_: K3 }); function Y3(e, t, n, s) { @@ -8224,7 +8223,7 @@ function Q3(e, t, n, s = 0) { var NI = L({ sparseToDense_: Q3 }); function Z3(e, t) { let n = _(t, "indices", "gatherND", "int32"), r = { params: _(e, "x", "gatherND", "string_or_numeric"), indices: n }; - return M.runKernel(bo, r); + return M.runKernel(yo, r); } var J3 = L({ gatherND_: Z3 }); function eF(e, t) { @@ -8244,7 +8243,7 @@ function tF(e, t, n, s) { let r = _(e, "x", "dropout"); if (O(r.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${r.dtype} tensor instead.`), O(t >= 0 && t < 1, () => `rate must be a float in the range [0, 1), but got ${t}.`), t === 0) return e instanceof et ? r.clone() : r; - let a = eF(r, n), i = 1 - t, o = xe(mp(ie(zl(a, 0, 1, "float32", s), i)), i); + let a = eF(r, n), i = 1 - t, o = xe(mp(ie(Ml(a, 0, 1, "float32", s), i)), i); return V(r, o); } var nF = L({ dropout_: tF }); @@ -8278,7 +8277,7 @@ async function rF(e, t, n = 1) { } return e !== s && s.dispose(), t !== r && r.dispose(), fs(c, r.shape, "bool"); } -var wpe = rF; +var kpe = rF; var ha = {}; Ae(ha, { conv2d: () => oF, depthwiseConv2d: () => dF, matMul: () => hF }); function aF(e, t, n, s, r, a = "NHWC", i) { @@ -8328,7 +8327,7 @@ function iF({ x: e, filter: t, strides: n, pad: s, dataFormat: r = "NHWC", dilat } let p = _(e, "x", "conv2d", "float32"), d = _(t, "filter", "conv2d", "float32"), h = p, f = false; p.rank === 3 && (f = true, h = G(p, [1, p.shape[0], p.shape[1], p.shape[2]])), O(h.rank === 4, () => `Error in fused conv2d: input must be rank 4, but got rank ${h.rank}.`), O(d.rank === 4, () => `Error in fused conv2d: filter must be rank 4, but got rank ${d.rank}.`), hn("fused conv2d", s, i), O(h.shape[3] === d.shape[2], () => `Error in conv2d: depth of input (${h.shape[3]}) must match input depth for filter ${d.shape[2]}.`), O(Ps(n, a), () => `Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`), O(r === "NHWC", () => `Error in conv2d: got dataFormat of ${r} but only NHWC is currently supported.`); - let m = Fl(h.shape, d.shape, n, a, s, i), g; + let m = Ol(h.shape, d.shape, n, a, s, i), g; o != null && (g = _(o, "bias", "fused conv2d"), [g] = vt(g, p), ot(m.outShape, g.shape)); let b; l != null && (b = _(l, "prelu weights", "fused conv2d")); @@ -8374,7 +8373,7 @@ function cF({ x: e, filter: t, strides: n, pad: s, dataFormat: r = "NHWC", dilat } let p = _(e, "x", "depthwiseConv2d", "float32"), d = _(t, "filter", "depthwiseConv2d", "float32"), h = p, f = false; p.rank === 3 && (f = true, h = G(p, [1, p.shape[0], p.shape[1], p.shape[2]])), O(h.rank === 4, () => `Error in fused depthwiseConv2d: input must be rank 4, but got rank ${h.rank}.`), O(d.rank === 4, () => `Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${d.rank}.`), O(h.shape[3] === d.shape[2], () => `Error in fused depthwiseConv2d: number of input channels (${h.shape[3]}) must match the inChannels dimension in filter ${d.shape[2]}.`), a == null && (a = [1, 1]), O(Ps(n, a), () => `Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`), hn("fused depthwiseConv2d", s, i); - let m = Fl(h.shape, d.shape, n, a, s, i, true), g; + let m = Ol(h.shape, d.shape, n, a, s, i, true), g; o != null && (g = _(o, "bias", "fused conv2d"), [g] = vt(g, p), ot(m.outShape, g.shape)); let b; l != null && (b = _(l, "prelu weights", "fused depthwiseConv2d")); @@ -8440,7 +8439,7 @@ function bF(e, t, n, s = false, r = 0) { i.push(He(e, a, t)), a += n; if (s) for (; a < e.size; ) { - let o = a + t - e.size, u = Ft([He(e, a, t - o), Ol([o], r)]); + let o = a + t - e.size, u = Ft([He(e, a, t - o), Pl([o], r)]); i.push(u), a += n; } return i.length === 0 ? Ki([], [0, t]) : G(Ft(i), [i.length, t]); @@ -8456,14 +8455,14 @@ function xF(e, t, n, s, r = "bilinear", a = 0) { let i = _(e, "image", "cropAndResize"), o = _(t, "boxes", "cropAndResize", "float32"), u = _(n, "boxInd", "cropAndResize", "int32"), l = o.shape[0]; O(i.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${i.rank}.`), O(o.rank === 2 && o.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${l},4] but had shape ${o.shape}.`), O(u.rank === 1 && u.shape[0] === l, () => `Error in cropAndResize: boxInd must be have size [${l}] but had shape ${o.shape}.`), O(s.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`), O(s[0] >= 1 && s[1] >= 1, () => `cropSize must be atleast [1,1], but was ${s}`), O(r === "bilinear" || r === "nearest", () => `method must be bilinear or nearest, but was ${r}`); let c = { image: i, boxes: o, boxInd: u }, p = { method: r, extrapolationValue: a, cropSize: s }; - return M.runKernel(lo, c, p); + return M.runKernel(co, c, p); } var wF = L({ cropAndResize_: xF }); function kF(e) { let t = _(e, "image", "flipLeftRight", "float32"); O(t.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`); let n = { image: t }; - return M.runKernel(mo, n, {}); + return M.runKernel(go, n, {}); } var IF = L({ flipLeftRight_: kF }); function SF(e) { @@ -8477,19 +8476,19 @@ function NF(e, t, n = 0, s = 0.5) { let r = _(e, "image", "rotateWithOffset", "float32"); O(r.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${r.rank}.`); let a = { image: r }, i = { radians: t, fillValue: n, center: s }; - return M.runKernel(Ho, a, i); + return M.runKernel(qo, a, i); } var TF = L({ rotateWithOffset_: NF }); -function Xo(e, t, n, s, r, a) { +function Yo(e, t, n, s, r, a) { s == null && (s = 0.5), r == null && (r = Number.NEGATIVE_INFINITY), a == null && (a = 0); let i = e.shape[0]; return n = Math.min(n, i), O(0 <= s && s <= 1, () => `iouThreshold must be in [0, 1], but was '${s}'`), O(e.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${e.rank}'`), O(e.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`), O(t.rank === 1, () => "scores must be a 1D tensor"), O(t.shape[0] === i, () => `scores has incompatible shape with boxes. Expected ${i}, but was ${t.shape[0]}`), O(0 <= a && a <= 1, () => `softNmsSigma must be in [0, 1], but was '${a}'`), { maxOutputSize: n, iouThreshold: s, scoreThreshold: r, softNmsSigma: a }; } function $F(e, t, n, s = 0.5, r = Number.NEGATIVE_INFINITY) { - let a = _(e, "boxes", "nonMaxSuppression", "float32"), i = _(t, "scores", "nonMaxSuppression", "float32"), o = Xo(a, i, n, s, r); + let a = _(e, "boxes", "nonMaxSuppression", "float32"), i = _(t, "scores", "nonMaxSuppression", "float32"), o = Yo(a, i, n, s, r); n = o.maxOutputSize, s = o.iouThreshold, r = o.scoreThreshold; let u = { maxOutputSize: n, iouThreshold: s, scoreThreshold: r }; - return M.runKernel(So, { boxes: a, scores: i }, u); + return M.runKernel(Co, { boxes: a, scores: i }, u); } var _F = L({ nonMaxSuppression_: $F }); function AF(e, t, n) { @@ -8562,33 +8561,33 @@ function fx(e, t) { return e.score - t.score || e.score === t.score && t.boxIndex - e.boxIndex; } async function PF(e, t, n, s = 0.5, r = Number.NEGATIVE_INFINITY) { - let a = _(e, "boxes", "nonMaxSuppressionAsync"), i = _(t, "scores", "nonMaxSuppressionAsync"), o = Xo(a, i, n, s, r); + let a = _(e, "boxes", "nonMaxSuppressionAsync"), i = _(t, "scores", "nonMaxSuppressionAsync"), o = Yo(a, i, n, s, r); n = o.maxOutputSize, s = o.iouThreshold, r = o.scoreThreshold; let u = await Promise.all([a.data(), i.data()]), l = u[0], c = u[1], { selectedIndices: p } = RI(l, c, n, s, r); return a !== e && a.dispose(), i !== t && i.dispose(), Zt(p, "int32"); } var zF = PF; function MF(e, t, n, s = 0.5, r = Number.NEGATIVE_INFINITY, a = 0) { - let i = _(e, "boxes", "nonMaxSuppression"), o = _(t, "scores", "nonMaxSuppression"), u = Xo(i, o, n, s, r, a); + let i = _(e, "boxes", "nonMaxSuppression"), o = _(t, "scores", "nonMaxSuppression"), u = Yo(i, o, n, s, r, a); n = u.maxOutputSize, s = u.iouThreshold, r = u.scoreThreshold, a = u.softNmsSigma; - let l = { boxes: i, scores: o }, c = { maxOutputSize: n, iouThreshold: s, scoreThreshold: r, softNmsSigma: a }, p = M.runKernel(Co, l, c); + let l = { boxes: i, scores: o }, c = { maxOutputSize: n, iouThreshold: s, scoreThreshold: r, softNmsSigma: a }, p = M.runKernel(No, l, c); return { selectedIndices: p[0], selectedScores: p[1] }; } var LF = L({ nonMaxSuppressionWithScore_: MF }); async function BF(e, t, n, s = 0.5, r = Number.NEGATIVE_INFINITY, a = 0) { - let i = _(e, "boxes", "nonMaxSuppressionAsync"), o = _(t, "scores", "nonMaxSuppressionAsync"), u = Xo(i, o, n, s, r, a); + let i = _(e, "boxes", "nonMaxSuppressionAsync"), o = _(t, "scores", "nonMaxSuppressionAsync"), u = Yo(i, o, n, s, r, a); n = u.maxOutputSize, s = u.iouThreshold, r = u.scoreThreshold, a = u.softNmsSigma; let l = await Promise.all([i.data(), o.data()]), c = l[0], p = l[1], { selectedIndices: d, selectedScores: h } = FI(c, p, n, s, r, a); return i !== e && i.dispose(), o !== t && o.dispose(), { selectedIndices: Zt(d, "int32"), selectedScores: Zt(h) }; } var VF = BF; function WF(e, t, n, s = 0.5, r = Number.NEGATIVE_INFINITY, a = false) { - let i = _(e, "boxes", "nonMaxSuppression"), o = _(t, "scores", "nonMaxSuppression"), u = Xo(i, o, n, s, r, null), l = u.maxOutputSize, c = u.iouThreshold, p = u.scoreThreshold, d = { boxes: i, scores: o }, h = { maxOutputSize: l, iouThreshold: c, scoreThreshold: p, padToMaxOutputSize: a }, f = M.runKernel(wl, d, h); + let i = _(e, "boxes", "nonMaxSuppression"), o = _(t, "scores", "nonMaxSuppression"), u = Yo(i, o, n, s, r, null), l = u.maxOutputSize, c = u.iouThreshold, p = u.scoreThreshold, d = { boxes: i, scores: o }, h = { maxOutputSize: l, iouThreshold: c, scoreThreshold: p, padToMaxOutputSize: a }, f = M.runKernel(kl, d, h); return { selectedIndices: f[0], validOutputs: f[1] }; } var UF = L({ nonMaxSuppressionPadded_: WF }); async function GF(e, t, n, s = 0.5, r = Number.NEGATIVE_INFINITY, a = false) { - let i = _(e, "boxes", "nonMaxSuppressionAsync"), o = _(t, "scores", "nonMaxSuppressionAsync"), u = Xo(i, o, n, s, r, null), l = u.maxOutputSize, c = u.iouThreshold, p = u.scoreThreshold, [d, h] = await Promise.all([i.data(), o.data()]), { selectedIndices: f, validOutputs: m } = DI(d, h, l, c, p, a); + let i = _(e, "boxes", "nonMaxSuppressionAsync"), o = _(t, "scores", "nonMaxSuppressionAsync"), u = Yo(i, o, n, s, r, null), l = u.maxOutputSize, c = u.iouThreshold, p = u.scoreThreshold, [d, h] = await Promise.all([i.data(), o.data()]), { selectedIndices: f, validOutputs: m } = DI(d, h, l, c, p, a); return i !== e && i.dispose(), o !== t && o.dispose(), { selectedIndices: Zt(f, "int32"), validOutputs: we(m, "int32") }; } var HF = GF; @@ -8606,7 +8605,7 @@ function KF(e, t, n = false, s = false) { O(r.rank === 3 || r.rank === 4, () => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${r.rank}.`), O(t.length === 2, () => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`), O(r.dtype === "float32" || r.dtype === "int32", () => "`images` must have `int32` or `float32` as dtype"), O(s === false || n === false, () => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."); let a = r, i = false; r.rank === 3 && (i = true, a = G(r, [1, r.shape[0], r.shape[1], r.shape[2]])); - let [] = t, o = { images: a }, u = { alignCorners: n, halfPixelCenters: s, size: t }, l = M.runKernel(Sl, o, u); + let [] = t, o = { images: a }, u = { alignCorners: n, halfPixelCenters: s, size: t }, l = M.runKernel(Cl, o, u); return i ? G(l, [l.shape[1], l.shape[2], l.shape[3]]) : l; } var XF = L({ resizeNearestNeighbor_: KF }); @@ -8622,16 +8621,16 @@ function YF(e, t = "binary", n = false, s = 0.5) { let g = Qk(ce(fI(h), "int32"), fs([]), 256); l = QF(g, u); } - let f = n ? Ko(h, l) : Wn(h, l); + let f = n ? Xo(h, l) : Wn(h, l); return ce(V(f, 255), "int32"); } function QF(e, t) { let n = Zt([-1]), s = Zt([0]), r = Zt([0]), a, i, o, u, l, c; for (let p = 0; p < e.size - 1; p++) { a = He(e, 0, p + 1), i = He(e, p + 1), l = xe(ve(a), t), c = xe(ve(i), t); - let d = ve(V(a, Xu(0, a.size))); + let d = ve(V(a, Yu(0, a.size))); o = xe(d, ve(a)); - let h = Ol(i.shape, a.size), f = ie(Xu(0, i.size), h), m = V(i, f); + let h = Pl(i.shape, a.size), f = ie(Yu(0, i.size), h), m = V(i, f); u = xe(ve(m), ve(i)); let g = ge(o, u), b = ge(o, u), y = V(l, c); r = V(V(y, g), b); @@ -8645,7 +8644,7 @@ function JF(e, t, n = "nearest", s = "constant", r = 0, a) { let i = _(e, "image", "transform", "float32"), o = _(t, "transforms", "transform", "float32"); O(i.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${i.rank}.`), O(o.rank === 2 && (o.shape[0] === i.shape[0] || o.shape[0] === 1) && o.shape[1] === 8, () => "Error in transform: Input transform should be batch x 8 or 1 x 8"), O(a == null || a.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${a}.`); let u = { image: i, transforms: o }, l = { interpolation: n, fillMode: s, fillValue: r, outputShape: a }; - return M.runKernel(Wo, u, l); + return M.runKernel(Uo, u, l); } var eO = L({ transform_: JF }); function tO(e, t, n) { @@ -8658,7 +8657,7 @@ function tO(e, t, n) { if (!(n <= i)) throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${i}).`); t < 0 && (t = a), n < 0 && (n = i); - let o = G(Xu(0, a, 1, "int32"), [-1, 1]), u = Xu(0, i, 1, "int32"), l = ge(o, u), c = Ds(Ko(l, we(+t, "int32")), jo(l, we(-n, "int32"))), p = $t([a, i], s.dtype); + let o = G(Yu(0, a, 1, "int32"), [-1, 1]), u = Yu(0, i, 1, "int32"), l = ge(o, u), c = Ds(Xo(l, we(+t, "int32")), Ko(l, we(-n, "int32"))), p = $t([a, i], s.dtype); return G(Jn(Fs(G(s, [-1, a, i])).map((d) => vn(c, d, p))), r); } var nO = L({ bandPart_: tO }); @@ -8750,7 +8749,7 @@ function uO(e, t, n = 3) { if (r == null) return xe(ve(a), we(s.size)); { - let i = V(r, Mn(s.shape)), o = ce(ve(Ku(i, we(0))), "float32"); + let i = V(r, Mn(s.shape)), o = ce(ve(Xu(i, we(0))), "float32"); return xe(ve(a), o); } } @@ -8864,7 +8863,7 @@ function _O(e, t, n) { throw new Error(`Input shape should be Tensor1D but received shape ${r.shape}`); if (a.rank !== 1) throw new Error(`New shape should be Tensor1D but received shape ${a.shape}`); - let i = { inputIndices: s, inputShape: r, newShape: a }, o = M.runKernel($l, i); + let i = { inputIndices: s, inputShape: r, newShape: a }, o = M.runKernel(_l, i); return { outputIndices: o[0], outputShape: o[1] }; } var AO = L({ sparseReshape_: _O }); @@ -8927,11 +8926,11 @@ function LO(e, t) { return M.runKernel(_g, r, s); } var BO = L({ stringToHashBucketFast_: LO }); -var kpe = { fft: lb, ifft: Id, rfft: cb, irfft: xI }; -var Ipe = { hammingWindow: mF, hannWindow: AI, frame: EI, stft: vF }; +var Ipe = { fft: lb, ifft: Id, rfft: cb, irfft: xI }; +var Spe = { hammingWindow: mF, hannWindow: AI, frame: EI, stft: vF }; var qn = { flipLeftRight: IF, grayscaleToRGB: CF, resizeNearestNeighbor: XF, resizeBilinear: jF, rotateWithOffset: TF, cropAndResize: wF, nonMaxSuppression: _F, nonMaxSuppressionAsync: zF, nonMaxSuppressionWithScore: LF, nonMaxSuppressionWithScoreAsync: VF, nonMaxSuppressionPadded: UF, nonMaxSuppressionPaddedAsync: HF, threshold: ZF, transform: eO }; var VO = { bandPart: nO, gramSchmidt: rO, qr: iO }; -var Spe = { absoluteDifference: cO, computeWeightedLoss: Ys, cosineDistance: pO, hingeLoss: fO, huberLoss: gO, logLoss: yO, meanSquaredError: xO, sigmoidCrossEntropy: IO, softmaxCrossEntropy: NO }; +var Cpe = { absoluteDifference: cO, computeWeightedLoss: Ys, cosineDistance: pO, hingeLoss: fO, huberLoss: gO, logLoss: yO, meanSquaredError: xO, sigmoidCrossEntropy: IO, softmaxCrossEntropy: NO }; var Wc = { sparseFillEmptyRows: $O, sparseReshape: AO, sparseSegmentMean: RO, sparseSegmentSum: FO }; var Mf = { stringNGrams: PO, stringSplit: MO, stringToHashBucketFast: BO }; var _r = class extends Vk { @@ -8972,8 +8971,7 @@ var _r = class extends Vk { Object.defineProperty(_r, Symbol.hasInstance, { value: (e) => e.minimize != null && e.computeGradients != null && e.applyGradients != null }); var fb = class extends _r { constructor(e, t, n = null) { - super(); - this.learningRate = e, this.rho = t, this.epsilon = n, this.accumulatedGrads = [], this.accumulatedUpdates = [], n == null && (this.epsilon = M.backend.epsilon()); + super(), this.learningRate = e, this.rho = t, this.epsilon = n, this.accumulatedGrads = [], this.accumulatedUpdates = [], n == null && (this.epsilon = M.backend.epsilon()); } applyGradients(e) { (Array.isArray(e) ? e.map((n) => n.name) : Object.keys(e)).forEach((n, s) => { @@ -9014,13 +9012,12 @@ fb.className = "Adadelta"; Tr(fb); var mb = class extends _r { constructor(e, t = 0.1) { - super(); - this.learningRate = e, this.initialAccumulatorValue = t, this.accumulatedGrads = []; + super(), this.learningRate = e, this.initialAccumulatorValue = t, this.accumulatedGrads = []; } applyGradients(e) { (Array.isArray(e) ? e.map((n) => n.name) : Object.keys(e)).forEach((n, s) => { let r = M.registeredVariables[n]; - this.accumulatedGrads[s] == null && (this.accumulatedGrads[s] = { originalName: `${n}/accumulator`, variable: j(() => Ol(r.shape, this.initialAccumulatorValue).variable(false)) }); + this.accumulatedGrads[s] == null && (this.accumulatedGrads[s] = { originalName: `${n}/accumulator`, variable: j(() => Pl(r.shape, this.initialAccumulatorValue).variable(false)) }); let a = Array.isArray(e) ? e[s].tensor : e[n]; if (a == null) return; @@ -9055,8 +9052,7 @@ mb.className = "Adagrad"; Tr(mb); var gb = class extends _r { constructor(e, t, n, s = null) { - super(); - this.learningRate = e, this.beta1 = t, this.beta2 = n, this.epsilon = s, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], j(() => { + super(), this.learningRate = e, this.beta1 = t, this.beta2 = n, this.epsilon = s, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], j(() => { this.accBeta1 = we(t).variable(), this.accBeta2 = we(n).variable(); }), s == null && (this.epsilon = M.backend.epsilon()); } @@ -9102,8 +9098,7 @@ gb.className = "Adam"; Tr(gb); var bb = class extends _r { constructor(e, t, n, s = null, r = 0) { - super(); - this.learningRate = e, this.beta1 = t, this.beta2 = n, this.epsilon = s, this.decay = r, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], j(() => { + super(), this.learningRate = e, this.beta1 = t, this.beta2 = n, this.epsilon = s, this.decay = r, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], j(() => { this.iteration = we(0).variable(), this.accBeta1 = we(t).variable(); }), s == null && (this.epsilon = M.backend.epsilon()); } @@ -9144,8 +9139,7 @@ bb.className = "Adamax"; Tr(bb); var Ip = class extends _r { constructor(e) { - super(); - this.learningRate = e, this.setLearningRate(e); + super(), this.learningRate = e, this.setLearningRate(e); } applyGradients(e) { (Array.isArray(e) ? e.map((n) => n.name) : Object.keys(e)).forEach((n, s) => { @@ -9183,8 +9177,7 @@ Ip.className = "SGD"; Tr(Ip); var yb = class extends Ip { constructor(e, t, n = false) { - super(e); - this.learningRate = e, this.momentum = t, this.useNesterov = n, this.accumulations = [], this.m = we(this.momentum); + super(e), this.learningRate = e, this.momentum = t, this.useNesterov = n, this.accumulations = [], this.m = we(this.momentum); } applyGradients(e) { (Array.isArray(e) ? e.map((n) => n.name) : Object.keys(e)).forEach((n, s) => { @@ -9222,8 +9215,7 @@ yb.className = "Momentum"; Tr(yb); var vb = class extends _r { constructor(e, t = 0.9, n = 0, s = null, r = false) { - super(); - if (this.learningRate = e, this.decay = t, this.momentum = n, this.epsilon = s, this.accumulatedMeanSquares = [], this.accumulatedMoments = [], this.accumulatedMeanGrads = [], this.centered = r, s == null && (this.epsilon = M.backend.epsilon()), e == null) + if (super(), this.learningRate = e, this.decay = t, this.momentum = n, this.epsilon = s, this.accumulatedMeanSquares = [], this.accumulatedMoments = [], this.accumulatedMeanGrads = [], this.centered = r, s == null && (this.epsilon = M.backend.epsilon()), e == null) throw new Error("learningRate for RMSPropOptimizer must be defined."); } applyGradients(e) { @@ -9300,7 +9292,7 @@ function OI() { return new Promise((e) => WO(() => e())); } var S = {}; -Ae(S, { ERF_A1: () => JO, ERF_A2: () => eP, ERF_A3: () => tP, ERF_A4: () => nP, ERF_A5: () => sP, ERF_P: () => ZO, PARALLELIZE_THRESHOLD: () => xb, SELU_SCALE: () => zI, SELU_SCALEALPHA: () => PI, applyActivation: () => wp, assertAndGetBroadcastShape: () => ot, assertAxesAreInnerMostDims: () => sD, assertParamsConsistent: () => UO, assignToTypedArray: () => lP, axesAreInnerMostDims: () => Qg, calculateShapes: () => Ek, checkEinsumDimSizes: () => mP, checkPadOnDimRoundingMode: () => hn, combineLocations: () => oI, complexWithEvenIndex: () => iP, complexWithOddIndex: () => oP, computeConv2DInfo: () => Fl, computeConv3DInfo: () => Kk, computeDefaultPad: () => Ug, computeDilation2DInfo: () => cE, computeOptimalWindowSize: () => HO, computeOutAndReduceShapes: () => uI, computeOutShape: () => GO, computePool2DInfo: () => jk, computePool3DInfo: () => dE, convertConv2DDataFormat: () => Xk, decodeEinsumEquation: () => hP, eitherStridesOrDilationsAreOne: () => Ps, expandShapeToKeepDim: () => da, exponent: () => dP, exponents: () => cP, fromStringArrayToUint8: () => PP, fromUint8ToStringArray: () => OP, getAxesPermutation: () => lI, getBroadcastDims: () => Ck, getComplexWithIndex: () => uP, getEinsumComputePath: () => gP, getEinsumPermutation: () => fP, getFusedBiasGradient: () => xp, getFusedDyActivation: () => vp, getImageCenter: () => qO, getInnerMostAxes: () => rD, getPermuted: () => KO, getReductionAxes: () => _t, getReshaped: () => jO, getReshapedPermuted: () => XO, getSliceBeginCoords: () => YO, getSliceSize: () => QO, getSparseFillEmptyRowsIndicesDenseShapeMismatch: () => xP, getSparseFillEmptyRowsNegativeIndexErrorMessage: () => wP, getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: () => kP, getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: () => CP, getSparseReshapeInputOutputMismatchErrorMessage: () => TP, getSparseReshapeInputOutputMultipleErrorMessage: () => NP, getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: () => IP, getSparseReshapeNegativeOutputDimErrorMessage: () => SP, getSparseSegmentReductionIndicesOutOfRangeErrorMessage: () => EP, getSparseSegmentReductionNegativeSegmentIdsErrorMessage: () => $P, getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: () => _P, getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: () => AP, getUndoAxesPermutation: () => Zg, isIdentityPermutation: () => bP, log: () => R$, mergeRealAndImagArrays: () => rP, prepareAndValidate: () => _k, prepareSplitSize: () => vP, segment_util: () => MI, shouldFuse: () => kp, slice_util: () => wt, splitRealAndImagArrays: () => aP, tupleValuesAreOne: () => fr, upcastType: () => cn, validateInput: () => Bg, validateUpdateShape: () => Lg, warn: () => ar }); +Ae(S, { ERF_A1: () => JO, ERF_A2: () => eP, ERF_A3: () => tP, ERF_A4: () => nP, ERF_A5: () => sP, ERF_P: () => ZO, PARALLELIZE_THRESHOLD: () => xb, SELU_SCALE: () => zI, SELU_SCALEALPHA: () => PI, applyActivation: () => wp, assertAndGetBroadcastShape: () => ot, assertAxesAreInnerMostDims: () => sD, assertParamsConsistent: () => UO, assignToTypedArray: () => lP, axesAreInnerMostDims: () => Qg, calculateShapes: () => Ek, checkEinsumDimSizes: () => mP, checkPadOnDimRoundingMode: () => hn, combineLocations: () => oI, complexWithEvenIndex: () => iP, complexWithOddIndex: () => oP, computeConv2DInfo: () => Ol, computeConv3DInfo: () => Kk, computeDefaultPad: () => Ug, computeDilation2DInfo: () => cE, computeOptimalWindowSize: () => HO, computeOutAndReduceShapes: () => uI, computeOutShape: () => GO, computePool2DInfo: () => jk, computePool3DInfo: () => dE, convertConv2DDataFormat: () => Xk, decodeEinsumEquation: () => hP, eitherStridesOrDilationsAreOne: () => Ps, expandShapeToKeepDim: () => da, exponent: () => dP, exponents: () => cP, fromStringArrayToUint8: () => PP, fromUint8ToStringArray: () => OP, getAxesPermutation: () => lI, getBroadcastDims: () => Ck, getComplexWithIndex: () => uP, getEinsumComputePath: () => gP, getEinsumPermutation: () => fP, getFusedBiasGradient: () => xp, getFusedDyActivation: () => vp, getImageCenter: () => qO, getInnerMostAxes: () => rD, getPermuted: () => KO, getReductionAxes: () => _t, getReshaped: () => jO, getReshapedPermuted: () => XO, getSliceBeginCoords: () => YO, getSliceSize: () => QO, getSparseFillEmptyRowsIndicesDenseShapeMismatch: () => xP, getSparseFillEmptyRowsNegativeIndexErrorMessage: () => wP, getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: () => kP, getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: () => CP, getSparseReshapeInputOutputMismatchErrorMessage: () => TP, getSparseReshapeInputOutputMultipleErrorMessage: () => NP, getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: () => IP, getSparseReshapeNegativeOutputDimErrorMessage: () => SP, getSparseSegmentReductionIndicesOutOfRangeErrorMessage: () => EP, getSparseSegmentReductionNegativeSegmentIdsErrorMessage: () => $P, getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: () => _P, getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: () => AP, getUndoAxesPermutation: () => Zg, isIdentityPermutation: () => bP, log: () => R$, mergeRealAndImagArrays: () => rP, prepareAndValidate: () => _k, prepareSplitSize: () => vP, segment_util: () => MI, shouldFuse: () => kp, slice_util: () => wt, splitRealAndImagArrays: () => aP, tupleValuesAreOne: () => fr, upcastType: () => cn, validateInput: () => Bg, validateUpdateShape: () => Lg, warn: () => ar }); function UO(e, t) { let n = e[0].length; e.forEach((r, a) => { @@ -9608,22 +9600,22 @@ function OP(e) { } } function PP(e) { - return e.map((t) => Rl(t)); + return e.map((t) => Dl(t)); } var xs = {}; Ae(xs, { nonMaxSuppressionV3Impl: () => RI, nonMaxSuppressionV4Impl: () => DI, nonMaxSuppressionV5Impl: () => FI, whereImpl: () => kI }); -var LI = { kernelName: ao, inputsToSave: ["x"], gradFunc: (e, t) => { +var LI = { kernelName: io, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => V(e, yp(ce(n, "float32"), -1)) }; } }; -var zP = { kernelName: nl, inputsToSave: ["x"], gradFunc: (e, t) => { +var zP = { kernelName: sl, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => { let s = ct(ce(n, "float32")), r = dn(ge(we(1), s)); return kt(xe(e, r)); } }; } }; -var MP = { kernelName: sl, inputsToSave: ["x"], gradFunc: (e, t) => { +var MP = { kernelName: rl, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => { let s = dn(ge(ct(ce(n, "float32")), 1)); @@ -9650,22 +9642,22 @@ var VP = { kernelName: Ia, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => je(n) }; } }; -var WP = { kernelName: il, inputsToSave: ["x"], gradFunc: (e, t) => { +var WP = { kernelName: ol, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => je(n) }; } }; -var UP = { kernelName: ol, inputsToSave: ["x"], gradFunc: (e, t) => { +var UP = { kernelName: ul, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => xe(e, dn(ge(we(1), ct(ce(n, "float32"))))) }; } }; -var GP = { kernelName: ul, inputsToSave: ["x"], gradFunc: (e, t) => { +var GP = { kernelName: ll, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => { let s = dn(ie(we(1), ct(ce(n, "float32")))); return xe(e, s); } }; } }; -var HP = { kernelName: dl, inputsToSave: ["a", "b"], gradFunc: (e, t) => { +var HP = { kernelName: pl, inputsToSave: ["a", "b"], gradFunc: (e, t) => { let [n, s] = t, r = ot(n.shape, s.shape); return { a: () => { let o = ie(ct(n), ct(s)), u = V(e, xe(s, o)), l = _t(n.shape, r); @@ -9675,11 +9667,11 @@ var HP = { kernelName: dl, inputsToSave: ["a", "b"], gradFunc: (e, t) => { return l.length > 0 && (u = ve(u, l)), G(u, s.shape); } }; } }; -var qP = { kernelName: ll, inputsToSave: ["x"], gradFunc: (e, t) => { +var qP = { kernelName: cl, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => xe(e, ie(ct(ce(n, "float32")), 1)) }; } }; -var jP = { kernelName: cl, inputsToSave: ["x"], gradFunc: (e, t) => { +var jP = { kernelName: dl, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => xe(e, ge(we(1), ct(ce(n, "float32")))) }; } }; @@ -9711,7 +9703,7 @@ var ez = { kernelName: Ca, inputsToSave: ["a", "b"], gradFunc: (e, t, n) => { let [s, r] = t, { transposeA: a, transposeB: i } = n; return !a && !i ? { a: () => We(e, r, false, true), b: () => We(s, e, true, false) } : !a && i ? { a: () => We(e, r, false, false), b: () => We(e, s, true, false) } : a && !i ? { a: () => We(r, e, false, true), b: () => We(s, e, false, false) } : { a: () => We(r, e, true, true), b: () => We(e, s, true, true) }; } }; -var tz = { kernelName: io, gradFunc: (e, t, n) => { +var tz = { kernelName: oo, gradFunc: (e, t, n) => { let { blockShape: s, crops: r } = n; return { x: () => nb(e, s, r) }; } }; @@ -9731,10 +9723,10 @@ var sz = { kernelName: Na, gradFunc: (e) => ({ x: () => e.clone() }) }; var rz = { kernelName: Ta, gradFunc: (e) => ({ x: () => je(e) }) }; var az = { kernelName: Sr, inputsToSave: ["x"], gradFunc: (e, t, n) => { let [s] = t, { clipValueMin: r, clipValueMax: a } = n; - return { x: () => vn(Ds(jo(s, r), Ko(s, a)), e, je(e)) }; + return { x: () => vn(Ds(Ko(s, r), Xo(s, a)), e, je(e)) }; } }; var iz = { kernelName: Kd, inputsToSave: ["x"], gradFunc: LI.gradFunc }; -var oz = { kernelName: oo, saveAllInputs: true, gradFunc: (e, t, n) => { +var oz = { kernelName: uo, saveAllInputs: true, gradFunc: (e, t, n) => { let s = t.map((u) => u.shape), { axis: r } = n, a = ts(r, t[0].shape)[0], i = s.map((u) => u[a]); return Bn(e, i, a).map((u) => () => u); } }; @@ -9769,7 +9761,7 @@ var fz = { kernelName: Ea, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => V(yI(ce(n, "float32")), e) }; } }; -var mz = { kernelName: uo, inputsToSave: ["x"], gradFunc: (e, t, n) => { +var mz = { kernelName: lo, inputsToSave: ["x"], gradFunc: (e, t, n) => { let [s] = t, { axis: r, exclusive: a, reverse: i } = n; return { x: () => { let o = lI([r], s.rank), u = sI(e, r, a, !i); @@ -9790,7 +9782,7 @@ var yz = { kernelName: Fa, outputsToSave: [true], gradFunc: (e, t) => { let [n] = t, s = { dy: e, y: n }; return { x: () => M.runKernel(bg, s) }; } }; -var vz = { kernelName: hl, inputsToSave: ["x"], gradFunc: (e, t) => { +var vz = { kernelName: fl, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t, s = V(Xn(kt(ct(n))), 2 / Math.sqrt(Math.PI)); return { x: () => V(e, s) }; } }; @@ -9798,11 +9790,11 @@ var xz = { kernelName: Oa, outputsToSave: [true], gradFunc: (e, t) => { let [n] = t; return { x: () => V(e, n) }; } }; -var wz = { kernelName: ho, inputsToSave: ["input"], gradFunc: (e, t) => { +var wz = { kernelName: fo, inputsToSave: ["input"], gradFunc: (e, t) => { let [n] = t; return { input: () => G(e, n.shape) }; } }; -var kz = { kernelName: fo, inputsToSave: ["x"], gradFunc: (e, t) => { +var kz = { kernelName: mo, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => V(e, Xn(n)) }; } }; @@ -9841,7 +9833,7 @@ var Cz = { kernelName: Ma, inputsToSave: ["x", "mean", "variance", "scale"], gra return a.rank === 1 && (x = ve(x, l)), G(x, a.shape); } }; } }; -var Nz = { kernelName: go, inputsToSave: ["x", "indices"], gradFunc: (e, t, n) => { +var Nz = { kernelName: bo, inputsToSave: ["x", "indices"], gradFunc: (e, t, n) => { let [s, r] = t, { axis: a } = n, i = ts(a, s.shape)[0]; return { x: () => { let u = s.shape, l = r.size, c = u.slice(0, i), p = c.length, d = u.slice(a, u.length).slice(1), h = d.length, f = yx(0, p), m = yx(p + 1, p + 1 + h), g = vx([c, [l], d]), b = G(e, g), y = G(r, [l]), v = vx([[p], f, m]), x = qe(b, v), k = V3(x, y, s.shape[i]), T = Zg(v); @@ -9866,14 +9858,14 @@ var Tz = { kernelName: La, inputsToSave: ["a", "b"], gradFunc: (e, t) => { return { a: () => je(n), b: () => je(s) }; } }; var $z = { kernelName: Ba, gradFunc: (e) => ({ x: () => ce(e, "float32") }) }; -var _z = { kernelName: ml, gradFunc: (e) => ({ x: () => je(e) }) }; -var Az = { kernelName: gl, gradFunc: (e) => ({ x: () => je(e) }) }; -var Ez = { kernelName: bl, gradFunc: (e) => ({ x: () => je(e) }) }; +var _z = { kernelName: gl, gradFunc: (e) => ({ x: () => je(e) }) }; +var Az = { kernelName: bl, gradFunc: (e) => ({ x: () => je(e) }) }; +var Ez = { kernelName: yl, gradFunc: (e) => ({ x: () => je(e) }) }; var Rz = { kernelName: Va, inputsToSave: ["x"], gradFunc: (e, t, n) => { let [s] = t, { alpha: r } = n, a = Wn(s, 0); return { x: () => vn(a, e, V(e, r)) }; } }; -var Dz = { kernelName: yl, inputsToSave: ["x"], gradFunc: (e, t) => { +var Dz = { kernelName: vl, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => xe(e, ie(n, 1)) }; } }; @@ -9906,7 +9898,7 @@ var xx = { kernelName: Ua, inputsToSave: ["x"], outputsToSave: [true], gradFunc: } }; var Lz = { kernelName: Ga, inputsToSave: ["a", "b"], gradFunc: (e, t) => { let [n, s] = t; - return { a: () => V(e, ce(jo(n, s), "float32")), b: () => V(e, ce(aI(n, s), "float32")) }; + return { a: () => V(e, ce(Ko(n, s), "float32")), b: () => V(e, ce(aI(n, s), "float32")) }; } }; function Bz(e, t, n, s, r, a, i) { let o = _(e, "dy", "maxPool3dGrad"), u = _(t, "input", "maxPool3dGrad"), l = _(n, "output", "maxPool3dGrad"), c = o, p = u, d = l, h = false; @@ -9947,13 +9939,13 @@ var jz = { kernelName: ja, inputsToSave: ["x"], outputsToSave: [true], gradFunc: } }; var Kz = { kernelName: Ka, inputsToSave: ["a", "b"], gradFunc: (e, t) => { let [n, s] = t; - return { a: () => V(e, ce(Ko(n, s), "float32")), b: () => V(e, ce(Wn(n, s), "float32")) }; + return { a: () => V(e, ce(Xo(n, s), "float32")), b: () => V(e, ce(Wn(n, s), "float32")) }; } }; var Xz = { kernelName: Xa, inputsToSave: ["x"], gradFunc: (e, t, n) => { let s = t[0], { paddings: r } = n, a = r.map((i) => i[0]); return { x: () => He(e, a, s.shape) }; } }; -var Yz = { kernelName: xl, inputsToSave: ["a", "b"], gradFunc: (e, t) => { +var Yz = { kernelName: wl, inputsToSave: ["a", "b"], gradFunc: (e, t) => { let [n, s] = t, r = ot(n.shape, s.shape); return { a: () => { let o = _t(n.shape, r); @@ -9973,13 +9965,13 @@ var Qz = { kernelName: Ya, inputsToSave: ["a", "b"], gradFunc: (e, t) => { return u.length > 0 ? G(ve(o, u), s.shape) : o; } }; } }; -var Zz = { kernelName: ko, gradFunc: (e) => ({ x: () => kt(e) }) }; -var Jz = { kernelName: To, inputsToSave: ["indices"], gradFunc: (e, t) => { +var Zz = { kernelName: Io, gradFunc: (e) => ({ x: () => kt(e) }) }; +var Jz = { kernelName: $o, inputsToSave: ["indices"], gradFunc: (e, t) => { let n = t[0]; return { indices: () => $t(n.shape, "float32") }; } }; -var eM = { kernelName: No, gradFunc: (e) => ({ x: () => je(e) }) }; -var tM = { kernelName: $o, saveAllInputs: true, gradFunc: (e, t, n) => { +var eM = { kernelName: To, gradFunc: (e) => ({ x: () => je(e) }) }; +var tM = { kernelName: _o, saveAllInputs: true, gradFunc: (e, t, n) => { let { axis: s } = n; return Fs(e, s).map((a) => () => a); } }; @@ -10016,19 +10008,19 @@ var rM = { kernelName: Da, inputsToSave: ["a", "b"], gradFunc: (e, t) => { return kt(xe(o, ce(l, "float32"))); } }; } }; -var aM = { kernelName: Il, inputsToSave: ["x"], gradFunc: (e, t) => { +var aM = { kernelName: Sl, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => xe(e, kt(ct(n))) }; } }; var iM = { kernelName: ni, inputsToSave: ["x"], gradFunc: (e, t) => { - let [n] = t, s = V(Ko(n, 6), yp(n)); + let [n] = t, s = V(Xo(n, 6), yp(n)); return { x: () => V(e, ce(s, "float32")) }; } }; var oM = { kernelName: ei, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => V(e, ce(yp(n), "float32")) }; } }; -var uM = { kernelName: Ao, inputsToSave: ["x"], gradFunc: (e, t) => { +var uM = { kernelName: Eo, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => G(e, n.shape) }; } }; @@ -10036,24 +10028,24 @@ var lM = { kernelName: ti, inputsToSave: ["images"], gradFunc: (e, t, n) => { let [s] = t, r = { dy: e, images: s }; return { images: () => M.runKernel(Tg, r, n) }; } }; -var cM = { kernelName: Sl, inputsToSave: ["images"], gradFunc: (e, t, n) => { +var cM = { kernelName: Cl, inputsToSave: ["images"], gradFunc: (e, t, n) => { let [s] = t, r = { dy: e, images: s }; return { images: () => M.runKernel(Ng, r, n) }; } }; -var dM = { kernelName: Eo, gradFunc: (e, t, n) => { +var dM = { kernelName: Ro, gradFunc: (e, t, n) => { let { dims: s } = n, r = ts(s, e.shape); return { x: () => Zn(e, r) }; } }; -var pM = { kernelName: Ro, gradFunc: (e) => ({ x: () => je(e) }) }; +var pM = { kernelName: Do, gradFunc: (e) => ({ x: () => je(e) }) }; var hM = { kernelName: si, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => kt(xe(e, V(pa(n, 1.5), 2))) }; } }; -var fM = { kernelName: Fo, inputsToSave: ["condition"], gradFunc: (e, t) => { +var fM = { kernelName: Oo, inputsToSave: ["condition"], gradFunc: (e, t) => { let [n] = t; return { condition: () => ce(je(n), "float32"), t: () => V(e, ce(n, e.dtype)), e: () => V(e, ce(Jg(n), e.dtype)) }; } }; -var mM = { kernelName: Cl, inputsToSave: ["x"], gradFunc: (e, t) => { +var mM = { kernelName: Nl, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => { let s = Wn(n, we(0)), r = we(PI), a = we(zI), i = V(e, a), o = V(V(e, r), Xn(ce(n, "float32"))); @@ -10064,16 +10056,16 @@ var gM = { kernelName: ai, outputsToSave: [true], gradFunc: (e, t) => { let [n] = t; return { x: () => V(e, V(n, ge(we(1), n))) }; } }; -var bM = { kernelName: Nl, gradFunc: (e) => ({ x: () => je(e) }) }; +var bM = { kernelName: Tl, gradFunc: (e) => ({ x: () => je(e) }) }; var yM = { kernelName: ri, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => V(jg(ce(n, "float32")), e) }; } }; -var vM = { kernelName: Po, inputsToSave: ["x"], gradFunc: (e, t) => { +var vM = { kernelName: zo, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => V(nI(ce(n, "float32")), e) }; } }; -var xM = { kernelName: Oo, inputsToSave: ["x"], gradFunc: (e, t, n) => { +var xM = { kernelName: Po, inputsToSave: ["x"], gradFunc: (e, t, n) => { let [s] = t, { begin: r, size: a } = n, i = s.shape, [o, u] = Bk(s, r, a), l = []; for (let c = 0; c < e.rank; c++) l.push([o[c], i[c] - o[c] - u[c]]); @@ -10083,15 +10075,15 @@ var wM = { kernelName: ui, outputsToSave: [true], gradFunc: (e, t, n) => { let [s] = t, { dim: r } = n, a = true, i = V(e, s); return { logits: () => ge(i, V(ve(i, [r], a), s)) }; } }; -var kM = { kernelName: Tl, inputsToSave: ["x"], gradFunc: (e, t) => { +var kM = { kernelName: $l, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => V(e, qs(n)) }; } }; -var kx = { kernelName: zo, gradFunc: (e, t, n) => { +var kx = { kernelName: Mo, gradFunc: (e, t, n) => { let { blockShape: s, paddings: r } = n; return { x: () => Hg(e, s, r) }; } }; -var Ix = { kernelName: Mo, gradFunc: (e, t, n) => { +var Ix = { kernelName: Lo, gradFunc: (e, t, n) => { let { axis: s } = n; return { x: () => Ft(e, s) }; } }; @@ -10099,7 +10091,7 @@ var IM = { kernelName: ii, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => xe(e, V(dn(ce(n, "float32")), 2)) }; } }; -var SM = { kernelName: _l, inputsToSave: ["x"], gradFunc: (e, t) => { +var SM = { kernelName: Al, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => V(e, V(ce(n, "float32"), 2)) }; } }; @@ -10126,7 +10118,7 @@ var $M = { kernelName: oi, inputsToSave: ["x"], gradFunc: (e, t, n) => { let o = G(e, r), u = V(o, Mn(s.shape, "float32")); return { x: () => u }; } }; -var _M = { kernelName: Bo, inputsToSave: ["x"], gradFunc: (e, t) => { +var _M = { kernelName: Vo, inputsToSave: ["x"], gradFunc: (e, t) => { let [n] = t; return { x: () => xe(e, ct(jg(n))) }; } }; @@ -10165,7 +10157,7 @@ var RM = { kernelName: pi, gradFunc: (e, t, n) => { let s = n, { perm: r } = s, a = Zg(r); return { x: () => qe(e, a) }; } }; -var DM = { kernelName: Uo, gradFunc: (e, t, n) => { +var DM = { kernelName: Go, gradFunc: (e, t, n) => { let s = n, { axis: r } = s; return { value: () => Jn(e, r) }; } }; @@ -10174,14 +10166,14 @@ var FM = { kernelName: up, inputsToSave: ["segmentIds"], gradFunc: (e, t) => { return { x: () => OM(e, n) }; } }; function OM(e, t) { - let n = $r(t, je(t)), s = ju(e, n), r = jo(t, we(0, "int32")), a = s.rank - r.rank; + let n = $r(t, je(t)), s = Ku(e, n), r = Ko(t, we(0, "int32")), a = s.rank - r.rank; for (let o = 0; o < a; ++o) r = Pn(r, o + 1); r = Ds(r, Mn(s.shape, "bool")); let i = je(s); return vn(r, s, i); } -var PM = { kernelName: Go, gradFunc: (e) => ({ x: () => je(e) }) }; +var PM = { kernelName: Ho, gradFunc: (e) => ({ x: () => je(e) }) }; var zM = [LI, zP, MP, LP, BP, VP, WP, UP, GP, HP, qP, jP, YP, JP, ez, tz, nz, sz, rz, az, iz, oz, lz, uz, pz, hz, fz, mz, gz, bz, rM, yz, vz, xz, wz, kz, Sz, Iz, Cz, Nz, Tz, $z, _z, Az, Ez, Rz, Dz, Fz, Oz, Mz, xx, xx, Lz, Wz, Hz, qz, jz, Kz, Xz, Yz, Qz, Zz, Jz, eM, tM, wx, wx, nM, sM, aM, iM, oM, uM, lM, cM, dM, pM, hM, fM, mM, gM, bM, yM, vM, xM, wM, kM, kx, kx, Ix, Ix, IM, CM, SM, NM, TM, $M, _M, AM, EM, RM, DM, FM, PM]; for (let e of zM) D$(e); @@ -10196,32 +10188,27 @@ function bs() { } var Vs = class extends Error { constructor(e) { - super(e); - Object.setPrototypeOf(this, Vs.prototype); + super(e), Object.setPrototypeOf(this, Vs.prototype); } }; var hs = class extends Error { constructor(e) { - super(e); - Object.setPrototypeOf(this, hs.prototype); + super(e), Object.setPrototypeOf(this, hs.prototype); } }; var U = class extends Error { constructor(e) { - super(e); - Object.setPrototypeOf(this, U.prototype); + super(e), Object.setPrototypeOf(this, U.prototype); } }; var Fe = class extends Error { constructor(e) { - super(e); - Object.setPrototypeOf(this, Fe.prototype); + super(e), Object.setPrototypeOf(this, Fe.prototype); } }; var VI = class extends Error { constructor(e) { - super(e); - Object.setPrototypeOf(this, VI.prototype); + super(e), Object.setPrototypeOf(this, VI.prototype); } }; function fa(e, t) { @@ -10277,7 +10264,7 @@ function mm(e) { } } } -function Ml(e, t = {}, n = {}, s = "object", r = false) { +function Ll(e, t = {}, n = {}, s = "object", r = false) { if (typeof e == "string") { let a = e, i; if (a in n) @@ -10370,15 +10357,14 @@ function UI(e) { function Ib(e, t) { return j(() => dn(ve(V(e, e), t, true))); } -var Ll = class extends ae.Serializable { +var Bl = class extends ae.Serializable { getConfig() { return {}; } }; -var Sb = class extends Ll { +var Sb = class extends Bl { constructor(e) { - super(); - this.defaultMaxValue = 2, this.defaultAxis = 0, this.maxValue = e.maxValue != null ? e.maxValue : this.defaultMaxValue, this.axis = e.axis != null ? e.axis : this.defaultAxis; + super(), this.defaultMaxValue = 2, this.defaultAxis = 0, this.maxValue = e.maxValue != null ? e.maxValue : this.defaultMaxValue, this.axis = e.axis != null ? e.axis : this.defaultAxis; } apply(e) { return j(() => { @@ -10392,10 +10378,9 @@ var Sb = class extends Ll { }; Sb.className = "MaxNorm"; ae.registerClass(Sb); -var Cb = class extends Ll { +var Cb = class extends Bl { constructor(e) { - super(); - this.defaultAxis = 0, this.axis = e.axis != null ? e.axis : this.defaultAxis; + super(), this.defaultAxis = 0, this.axis = e.axis != null ? e.axis : this.defaultAxis; } apply(e) { return j(() => xe(e, ie(Rt(), Ib(e, this.axis)))); @@ -10406,17 +10391,16 @@ var Cb = class extends Ll { }; Cb.className = "UnitNorm"; ae.registerClass(Cb); -var Nb = class extends Ll { +var Nb = class extends Bl { apply(e) { return Xs(e); } }; Nb.className = "NonNeg"; ae.registerClass(Nb); -var Tb = class extends Ll { +var Tb = class extends Bl { constructor(e) { - super(); - this.defaultMinValue = 0, this.defaultMaxValue = 1, this.defaultRate = 1, this.defaultAxis = 0, this.minValue = e.minValue != null ? e.minValue : this.defaultMinValue, this.maxValue = e.maxValue != null ? e.maxValue : this.defaultMaxValue, this.rate = e.rate != null ? e.rate : this.defaultRate, this.axis = e.axis != null ? e.axis : this.defaultAxis; + super(), this.defaultMinValue = 0, this.defaultMaxValue = 1, this.defaultRate = 1, this.defaultAxis = 0, this.minValue = e.minValue != null ? e.minValue : this.defaultMinValue, this.maxValue = e.maxValue != null ? e.maxValue : this.defaultMaxValue, this.rate = e.rate != null ? e.rate : this.defaultRate, this.axis = e.axis != null ? e.axis : this.defaultAxis; } apply(e) { return j(() => { @@ -10435,7 +10419,7 @@ function Ot(e) { return wb(e); } function Nx(e, t = {}) { - return Ml(e, ae.SerializationMap.getMap().classNameMap, t, "constraint"); + return Ll(e, ae.SerializationMap.getMap().classNameMap, t, "constraint"); } function Pt(e) { if (e == null) @@ -10444,7 +10428,7 @@ function Pt(e) { let n = { className: e in Cx ? Cx[e] : e, config: {} }; return Nx(n); } else - return e instanceof Ll ? e : Nx(e); + return e instanceof Bl ? e : Nx(e); } function WM(e) { return new Sb(e); @@ -10478,19 +10462,19 @@ function Un(e) { function GI(e) { mi(YM, "PoolMode", e); } -var zu = []; +var Mu = []; var Tx = "/"; function ea(e, t) { - zu.push(e); + Mu.push(e); try { let n = t(); - return zu.pop(), n; + return Mu.pop(), n; } catch (n) { - throw zu.pop(), n; + throw Mu.pop(), n; } } function JM() { - return zu.length === 0 ? "" : zu.join(Tx) + Tx; + return Mu.length === 0 ? "" : Mu.join(Tx) + Tx; } function HI(e) { if (!jI(e)) @@ -10553,7 +10537,7 @@ function ys(e, t) { function Sp(e, t) { return ce(e, t); } -function Bl(e, t = -1) { +function Vl(e, t = -1) { let n = e.shape.slice(); return t < 0 && (t = n.length + t + 1), n.splice(t, 0, 1), G(e, n); } @@ -10561,7 +10545,7 @@ function nL(e, t) { return j(() => { if (e.shape.length !== 2) throw new U(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`); - let n = Bl(e, 1); + let n = Vl(e, 1); return gm(n, [1, t, 1]); }); } @@ -10700,9 +10684,9 @@ function Es(e, t, n, s) { } } function KI(e, t, n) { - return j(() => (Array.isArray(t) ? t = Zt(t, "int32") : t = ce(t, "int32"), ju(e, t, n))); + return j(() => (Array.isArray(t) ? t = Zt(t, "int32") : t = ce(t, "int32"), Ku(e, t, n))); } -function Vl(e) { +function Wl(e) { return V(e, e); } function bm(e, t, n) { @@ -10748,7 +10732,7 @@ function oL(e) { return Vn(t, 0, 1); }); } -function Wl(e, t, n = false) { +function Ul(e, t, n = false) { return n ? e() : t(); } var uL = ["fanIn", "fanOut", "fanAvg"]; @@ -10783,8 +10767,7 @@ Np.className = "Ones"; ae.registerClass(Np); var Ab = class extends ns { constructor(e) { - super(); - if (typeof e != "object") + if (super(), typeof e != "object") throw new U(`Expected argument of type ConstantConfig but got ${e}`); if (e.value === void 0) throw new U(`config must have value set but got ${e}`); @@ -10801,11 +10784,10 @@ Ab.className = "Constant"; ae.registerClass(Ab); var Eb = class extends ns { constructor(e) { - super(); - this.DEFAULT_MINVAL = -0.05, this.DEFAULT_MAXVAL = 0.05, this.minval = e.minval || this.DEFAULT_MINVAL, this.maxval = e.maxval || this.DEFAULT_MAXVAL, this.seed = e.seed; + super(), this.DEFAULT_MINVAL = -0.05, this.DEFAULT_MAXVAL = 0.05, this.minval = e.minval || this.DEFAULT_MINVAL, this.maxval = e.maxval || this.DEFAULT_MAXVAL, this.seed = e.seed; } apply(e, t) { - return zl(e, this.minval, this.maxval, t); + return Ml(e, this.minval, this.maxval, t); } getConfig() { return { minval: this.minval, maxval: this.maxval, seed: this.seed }; @@ -10815,8 +10797,7 @@ Eb.className = "RandomUniform"; ae.registerClass(Eb); var Rb = class extends ns { constructor(e) { - super(); - this.DEFAULT_MEAN = 0, this.DEFAULT_STDDEV = 0.05, this.mean = e.mean || this.DEFAULT_MEAN, this.stddev = e.stddev || this.DEFAULT_STDDEV, this.seed = e.seed; + super(), this.DEFAULT_MEAN = 0, this.DEFAULT_STDDEV = 0.05, this.mean = e.mean || this.DEFAULT_MEAN, this.stddev = e.stddev || this.DEFAULT_STDDEV, this.seed = e.seed; } apply(e, t) { if (t = t || "float32", t !== "float32" && t !== "int32") @@ -10831,8 +10812,7 @@ Rb.className = "RandomNormal"; ae.registerClass(Rb); var Db = class extends ns { constructor(e) { - super(); - this.DEFAULT_MEAN = 0, this.DEFAULT_STDDEV = 0.05, this.mean = e.mean || this.DEFAULT_MEAN, this.stddev = e.stddev || this.DEFAULT_STDDEV, this.seed = e.seed; + super(), this.DEFAULT_MEAN = 0, this.DEFAULT_STDDEV = 0.05, this.mean = e.mean || this.DEFAULT_MEAN, this.stddev = e.stddev || this.DEFAULT_STDDEV, this.seed = e.seed; } apply(e, t) { if (t = t || "float32", t !== "float32" && t !== "int32") @@ -10847,8 +10827,7 @@ Db.className = "TruncatedNormal"; ae.registerClass(Db); var Fb = class extends ns { constructor(e) { - super(); - this.gain = e.gain != null ? e.gain : 1; + super(), this.gain = e.gain != null ? e.gain : 1; } apply(e, t) { return j(() => { @@ -10883,8 +10862,7 @@ function pL(e, t = "channelsLast") { } var xn = class extends ns { constructor(e) { - super(); - if (e.scale < 0) + if (super(), e.scale < 0) throw new U(`scale must be a positive float. Got: ${e.scale}`); this.scale = e.scale == null ? 1 : e.scale, this.mode = e.mode == null ? "fanIn" : e.mode, cL(this.mode), this.distribution = e.distribution == null ? "normal" : e.distribution, dL(this.distribution), this.seed = e.seed; } @@ -10897,7 +10875,7 @@ var xn = class extends ns { return db(e, 0, i, t, this.seed); } else { let i = Math.sqrt(3 * a); - return zl(e, -i, i, t); + return Ml(e, -i, i, t); } } getConfig() { @@ -10968,8 +10946,7 @@ Rp.className = "LeCunNormal"; ae.registerClass(Rp); var Ob = class extends ns { constructor(e) { - super(); - if (this.DEFAULT_GAIN = 1, this.gain = e.gain == null ? this.DEFAULT_GAIN : e.gain, this.seed = e.seed, this.seed != null) + if (super(), this.DEFAULT_GAIN = 1, this.gain = e.gain == null ? this.DEFAULT_GAIN : e.gain, this.seed = e.seed, this.seed != null) throw new Fe("Random seed is not implemented for Orthogonal Initializer yet."); } apply(e, t) { @@ -10989,7 +10966,7 @@ Ob.className = "Orthogonal"; ae.registerClass(Ob); var _x = { constant: "Constant", glorotNormal: "GlorotNormal", glorotUniform: "GlorotUniform", heNormal: "HeNormal", heUniform: "HeUniform", identity: "Identity", leCunNormal: "LeCunNormal", leCunUniform: "LeCunUniform", ones: "Ones", orthogonal: "Orthogonal", randomNormal: "RandomNormal", randomUniform: "RandomUniform", truncatedNormal: "TruncatedNormal", varianceScaling: "VarianceScaling", zeros: "Zeros" }; function Ax(e, t = {}) { - return Ml(e, ae.SerializationMap.getMap().classNameMap, t, "initializer"); + return Ll(e, ae.SerializationMap.getMap().classNameMap, t, "initializer"); } function yt(e) { return wb(e); @@ -11062,7 +11039,7 @@ function TL(e) { return new Ob(e); } var $L = {}; -Ae($L, { Layer: () => Ge, RNN: () => Ar, RNNCell: () => Hl, activation: () => cV, add: () => vV, alphaDropout: () => nW, average: () => xV, averagePooling1d: () => Hy, averagePooling2d: () => qy, averagePooling3d: () => jy, avgPool1d: () => _V, avgPool2d: () => EV, avgPool3d: () => DV, avgPooling1d: () => AV, avgPooling2d: () => RV, avgPooling3d: () => FV, batchNormalization: () => NV, bidirectional: () => KV, concatenate: () => wV, conv1d: () => tV, conv2d: () => nV, conv2dTranspose: () => sV, conv3d: () => rV, conv3dTranspose: () => aV, convLstm2d: () => GV, convLstm2dCell: () => HV, cropping2D: () => oV, dense: () => dV, depthwiseConv2d: () => lV, dot: () => CV, dropout: () => pV, elu: () => XB, embedding: () => yV, flatten: () => fV, gaussianDropout: () => tW, gaussianNoise: () => eW, globalAveragePooling1d: () => OV, globalAveragePooling2d: () => PV, globalMaxPool1d: () => YV, globalMaxPool2d: () => QV, globalMaxPooling1d: () => GS, globalMaxPooling2d: () => HS, gru: () => MV, gruCell: () => LV, input: () => OB, inputLayer: () => KB, layerNormalization: () => TV, leakyReLU: () => QB, lstm: () => BV, lstmCell: () => VV, masking: () => sW, maxPool1d: () => ZV, maxPool2d: () => JV, maxPooling1d: () => qS, maxPooling2d: () => jS, maxPooling3d: () => zV, maximum: () => kV, minimum: () => IV, multiply: () => SV, permute: () => bV, prelu: () => ZB, reLU: () => YB, repeatVector: () => mV, reshape: () => gV, rnn: () => qV, separableConv2d: () => iV, simpleRNN: () => WV, simpleRNNCell: () => UV, softmax: () => JB, spatialDropout1d: () => hV, stackedRNNCells: () => jV, thresholdedReLU: () => eV, timeDistributed: () => XV, upSampling2d: () => uV, zeroPadding2d: () => $V }); +Ae($L, { Layer: () => Ge, RNN: () => Ar, RNNCell: () => ql, activation: () => cV, add: () => vV, alphaDropout: () => nW, average: () => xV, averagePooling1d: () => Hy, averagePooling2d: () => qy, averagePooling3d: () => jy, avgPool1d: () => _V, avgPool2d: () => EV, avgPool3d: () => DV, avgPooling1d: () => AV, avgPooling2d: () => RV, avgPooling3d: () => FV, batchNormalization: () => NV, bidirectional: () => KV, concatenate: () => wV, conv1d: () => tV, conv2d: () => nV, conv2dTranspose: () => sV, conv3d: () => rV, conv3dTranspose: () => aV, convLstm2d: () => GV, convLstm2dCell: () => HV, cropping2D: () => oV, dense: () => dV, depthwiseConv2d: () => lV, dot: () => CV, dropout: () => pV, elu: () => XB, embedding: () => yV, flatten: () => fV, gaussianDropout: () => tW, gaussianNoise: () => eW, globalAveragePooling1d: () => OV, globalAveragePooling2d: () => PV, globalMaxPool1d: () => YV, globalMaxPool2d: () => QV, globalMaxPooling1d: () => GS, globalMaxPooling2d: () => HS, gru: () => MV, gruCell: () => LV, input: () => OB, inputLayer: () => KB, layerNormalization: () => TV, leakyReLU: () => QB, lstm: () => BV, lstmCell: () => VV, masking: () => sW, maxPool1d: () => ZV, maxPool2d: () => JV, maxPooling1d: () => qS, maxPooling2d: () => jS, maxPooling3d: () => zV, maximum: () => kV, minimum: () => IV, multiply: () => SV, permute: () => bV, prelu: () => ZB, reLU: () => YB, repeatVector: () => mV, reshape: () => gV, rnn: () => qV, separableConv2d: () => iV, simpleRNN: () => WV, simpleRNNCell: () => UV, softmax: () => JB, spatialDropout1d: () => hV, stackedRNNCells: () => jV, thresholdedReLU: () => eV, timeDistributed: () => XV, upSampling2d: () => uV, zeroPadding2d: () => $V }); var _L = 0; function YI() { return _L++; @@ -11166,8 +11143,7 @@ var Fp = class { var DL = 0; var Ge = class extends ae.Serializable { constructor(e = {}) { - super(); - this._callHook = null, this._addedWeightNames = [], this._stateful = false, this.id = DL++, this.activityRegularizer = null, this.inputSpec = null, this.supportsMasking = false, this._trainableWeights = [], this._nonTrainableWeights = [], this._losses = [], this._updates = [], this._built = false, this.inboundNodes = [], this.outboundNodes = []; + super(), this._callHook = null, this._addedWeightNames = [], this._stateful = false, this.id = DL++, this.activityRegularizer = null, this.inputSpec = null, this.supportsMasking = false, this._trainableWeights = [], this._nonTrainableWeights = [], this._losses = [], this._updates = [], this._built = false, this.inboundNodes = [], this.outboundNodes = []; let t = e.name; if (!t) { let n = this.getClassName(); @@ -11488,10 +11464,9 @@ function QI(e, t, n) { } } } -var Yo = class extends Ge { +var Qo = class extends Ge { constructor(e) { - super({ dtype: e.dtype, name: e.name != null ? e.name : Dp("input").toString() }); - if (e.batchSize == null && (e.batchSize = null), e.sparse == null && (e.sparse = false), this.trainable = false, this.built = true, this.sparse = e.sparse, e.inputShape != null && e.batchInputShape != null) + if (super({ dtype: e.dtype, name: e.name != null ? e.name : Dp("input").toString() }), e.batchSize == null && (e.batchSize = null), e.sparse == null && (e.sparse = false), this.trainable = false, this.built = true, this.sparse = e.sparse, e.inputShape != null && e.batchInputShape != null) throw new U("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time."); let t = e.batchInputShape; if (t == null) { @@ -11515,8 +11490,8 @@ var Yo = class extends Ge { return { batchInputShape: this.batchInputShape, dtype: this.dtype, sparse: this.sparse, name: this.name }; } }; -Yo.className = "InputLayer"; -ae.registerClass(Yo); +Qo.className = "InputLayer"; +ae.registerClass(Qo); function ZI(e) { if (e.batchShape == null && e.shape == null) throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension."); @@ -11525,7 +11500,7 @@ function ZI(e) { let t = e.batchShape; e.shape != null && t == null && (t = [null].concat(e.shape)); let n = e.dtype; - return n == null && (n = "float32"), new Yo({ batchInputShape: t, name: e.name, dtype: n, sparse: e.sparse }).inboundNodes[0].outputTensors[0]; + return n == null && (n = "float32"), new Qo({ batchInputShape: t, name: e.name, dtype: n, sparse: e.sparse }).inboundNodes[0].outputTensors[0]; } async function rr(e) { if (e == null) @@ -11679,8 +11654,7 @@ var LL = class extends Ji { }; var BL = class extends Ji { constructor(e, t) { - super(); - if (this.currentEpoch = 0, this.nowFunc = e.nowFunc, this.nextFrameFunc = e.nextFrameFunc || OI, this.yieldEvery = t || "auto", this.yieldEvery === "auto" && (this.yieldEvery = PL), this.yieldEvery === "never" && e.onYield != null) + if (super(), this.currentEpoch = 0, this.nowFunc = e.nowFunc, this.nextFrameFunc = e.nextFrameFunc || OI, this.yieldEvery = t || "auto", this.yieldEvery === "auto" && (this.yieldEvery = PL), this.yieldEvery === "never" && e.onYield != null) throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback"); w.isNumber(this.yieldEvery) && (this.maybeWait = VM(this.maybeWait.bind(this), this.yieldEvery, this.nowFunc)), this.trainBegin = e.onTrainBegin, this.trainEnd = e.onTrainEnd, this.epochBegin = e.onEpochBegin, this.epochEnd = e.onEpochEnd, this.batchBegin = e.onBatchBegin, this.batchEnd = e.onBatchEnd, this.yield = e.onYield; } @@ -11746,22 +11720,22 @@ function tS(e, t, n, s, r, a, i, o, u) { return p.setParams({ epochs: n, initialEpoch: s, samples: r, steps: a, batchSize: i, verbose: t, doValidation: o, metrics: u }), { callbackList: p, history: l }; } function ms(e, t = {}, n = false) { - return Ml(e, ae.SerializationMap.getMap().classNameMap, t, "layer", n); + return Ll(e, ae.SerializationMap.getMap().classNameMap, t, "layer", n); } function Nd(e, t) { return j(() => { e.dtype !== "float32" && (e = ce(e, "float32")); - let n = ve(Vl(e), t, true), s = Ol(n.shape, Rt()), r = dn($r(n, s)); + let n = ve(Wl(e), t, true), s = Pl(n.shape, Rt()), r = dn($r(n, s)); return xe(e, r); }); } function gi(e, t) { - return j(() => St(Vl(ge(t, e)), -1)); + return j(() => St(Wl(ge(t, e)), -1)); } function Op(e, t) { return j(() => St(Mt(ge(t, e)), -1)); } -function Qo(e, t) { +function Zo(e, t) { return j(() => { let n = ge(e, t), s = Vn(Mt(e), Rt(), Number.MAX_VALUE), r = Mt(xe(n, s)); return V(100, St(r, -1)); @@ -11770,13 +11744,13 @@ function Qo(e, t) { function VL(e, t) { return j(() => { let n = Vn(t, Rt(), Number.MAX_VALUE), s = Yn(ie(1, n)), r = Vn(e, Rt(), Number.MAX_VALUE), a = Yn(ie(1, r)); - return St(Vl(ge(s, a)), -1); + return St(Wl(ge(s, a)), -1); }); } function WL(e, t) { return j(() => { let n = $r(0, ge(1, V(e, t))); - return St(Vl(n), -1); + return St(Wl(n), -1); }); } function UL(e, t) { @@ -11793,11 +11767,11 @@ function GL(e, t) { } function HL(e, t) { return j(() => { - let n = Math.log(2), s = ge(t, e), r = ge(ie(s, Pl(V(-2, s))), n); + let n = Math.log(2), s = ge(t, e), r = ge(ie(s, zl(V(-2, s))), n); return St(r, -1); }); } -function Yu(e, t, n = false) { +function Qu(e, t, n = false) { return j(() => { if (n) t = ub(t); @@ -11813,7 +11787,7 @@ function Td(e, t, n = false) { let s = ce(mp(sL(e)), "int32"); t = Vn(t, Rt(), 1 - Rt()); let r = t.shape, a = G(vd(s, r[r.length - 1]), r); - return Yu(a, t, n); + return Qu(a, t, n); }); } function qL(e, t) { @@ -11848,7 +11822,7 @@ function Mb(e, t) { return kt(ve(r, -1)); }); } -var $d = { meanSquaredError: gi, meanAbsoluteError: Op, meanAbsolutePercentageError: Qo, meanSquaredLogarithmicError: VL, squaredHinge: WL, hinge: UL, categoricalHinge: GL, logcosh: HL, categoricalCrossentropy: Yu, sparseCategoricalCrossentropy: Td, binaryCrossentropy: Pp, kullbackLeiblerDivergence: jL, poisson: KL, cosineProximity: Mb }; +var $d = { meanSquaredError: gi, meanAbsoluteError: Op, meanAbsolutePercentageError: Zo, meanSquaredLogarithmicError: VL, squaredHinge: WL, hinge: UL, categoricalHinge: GL, logcosh: HL, categoricalCrossentropy: Qu, sparseCategoricalCrossentropy: Td, binaryCrossentropy: Pp, kullbackLeiblerDivergence: jL, poisson: KL, cosineProximity: Mb }; function Wf(e) { if (typeof e == "string") { if (e in $d) @@ -11865,7 +11839,7 @@ function Lb(e, t) { }); } function Bb(e, t) { - return j(() => Sp(Kn(Gu(e, -1), Gu(t, -1)), "float32")); + return j(() => Sp(Kn(Hu(e, -1), Hu(t, -1)), "float32")); } function nS(e, t) { return j(() => ce(ve(Ds(Kn(e, 1), Kn(t, 1))), "float32")); @@ -11892,15 +11866,15 @@ function rS(e, t) { return Pp(e, t); } function aS(e, t) { - return e.rank === t.rank && (e = mr(e, [e.rank - 1])), t = Gu(t, -1), t.dtype !== e.dtype && (t = ce(t, e.dtype)), ce(Kn(e, t), "float32"); + return e.rank === t.rank && (e = mr(e, [e.rank - 1])), t = Hu(t, -1), t.dtype !== e.dtype && (t = ce(t, e.dtype)), ce(Kn(e, t), "float32"); } var ZL = gi; var JL = gi; var eB = Op; var tB = Op; -var nB = Qo; -var sB = Qo; -var Vb = Yu; +var nB = Zo; +var sB = Zo; +var Vb = Qu; var rB = Mb; var iS = Td; var _d = { binaryAccuracy: Lb, categoricalAccuracy: Bb, precision: sS, categoricalCrossentropy: Vb, sparseCategoricalCrossentropy: iS, mse: ZL, MSE: JL, mae: eB, MAE: tB, mape: nB, MAPE: sB, cosine: rB }; @@ -12063,7 +12037,7 @@ function dB(e, t, n, s) { function oS(e, t, n) { return (e === "inboundNodes" || e === "outputLayers" || e === "inputLayers") && t === 0 && typeof n == "string"; } -function Qu(e, t) { +function Zu(e, t) { if (e === null) return null; if (typeof e == "string") @@ -12074,7 +12048,7 @@ function Qu(e, t) { let n = [], s = e.length; for (let r = 0; r < s; ++r) { let a = e[r]; - oS(t, r, a) ? n.push(a) : n.push(Qu(a, t)); + oS(t, r, a) ? n.push(a) : n.push(Zu(a, t)); } return n; } else { @@ -12085,7 +12059,7 @@ function Qu(e, t) { n[s] = r; else { let a = Kr(s); - n[a] = Qu(r, a); + n[a] = Zu(r, a); } } return n; @@ -12182,7 +12156,7 @@ var Qr = class { }; var Uf = {}; var Fx = {}; -function _u(e, t, n, s) { +function Au(e, t, n, s) { let r = n == null ? false : n.training, a = Array.isArray(e), i = a ? e : [e], o = i.map((f) => f.name), u = [], l = t.names(); for (let f of o) l.indexOf(f) !== -1 ? u.push(t.getValue(f)) : u.push(null); @@ -12200,7 +12174,7 @@ function _u(e, t, n, s) { A > s.maxNumTensors && (s.maxNumTensors = A), A < s.minNumTensors && (s.minNumTensors = A); } let m = p[f], g = m.sourceLayer; - if (g instanceof Yo) + if (g instanceof Qo) continue; let b = [], y = [], v = [], x = false; for (let A of m.inputs) { @@ -12284,8 +12258,7 @@ function mB(e) { } var Is = class extends Ge { constructor(e) { - super({}); - if (this.containerNodes = /* @__PURE__ */ new Set(), this.name = e.name, this.name == null) { + if (super({}), this.containerNodes = /* @__PURE__ */ new Set(), this.name = e.name, this.name == null) { let b = this.getClassName().toLowerCase(); this.name = Dp(b); } @@ -12303,7 +12276,7 @@ var Is = class extends Ge { this.inputNames = [], this.outputNames = [], this.feedInputShapes = [], this.feedInputNames = [], this.feedOutputNames = []; for (let b = 0; b < this.inputLayers.length; b++) { let y = this.inputLayers[b]; - if (!(y instanceof Yo)) + if (!(y instanceof Qo)) throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${e.inputs}. Input ${b} (0-based) originates from layer type ${y.getClassName()}.`); this.inputNames.push(y.name), this.feedInputShapes.push(y.batchInputShape), this.feedInputNames.push(y.name); } @@ -12475,7 +12448,7 @@ var Is = class extends Ge { let n = new Qr(); for (let s = 0; s < this.inputs.length; ++s) n.add(this.inputs[s], e[s]); - return _u(this.outputs, n, t); + return Au(this.outputs, n, t); }); } computeMask(e, t) { @@ -12753,7 +12726,7 @@ async function cS(e, t, n, s) { return lr(e); if (e.shape.length === 2) { if (e.shape[1] > 1) - return Gu(e, 1); + return Hu(e, 1); if (e.shape[1] === 1) return G(e, [e.shape[0]]); throw new Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`); @@ -12918,7 +12891,7 @@ async function IB(e, t, n) { function km(e) { w.assert(e > 0 && Number.isInteger(e), () => `batchSize is required to be a positive integer, but got ${e}`); } -function Au(e, t, n) { +function Eu(e, t, n) { return e == null ? [null] : Array.isArray(e) ? e.map((s) => ta(s, t, n - t)) : ta(e, t, n - t); } function Wb(e, t) { @@ -12997,7 +12970,7 @@ async function CB(e, t, n, s = {}) { } else if (s.validationSplit != null && s.validationSplit > 0 && s.validationSplit < 1) { g = true; let A = Math.floor(r[0].shape[0] * (1 - s.validationSplit)), P = r[0].shape[0]; - c = Au(r, A, P), i = r, r = Au(r, 0, A), p = Au(a, A, P), o = a, a = Au(a, 0, A), b = c.concat(p); + c = Eu(r, A, P), i = r, r = Eu(r, 0, A), p = Eu(a, A, P), o = a, a = Eu(a, 0, A), b = c.concat(p); } else s.validationSteps != null && (g = true); let y = r.concat(a).concat(d); @@ -13016,7 +12989,7 @@ function pS(e) { for (let n = 0; n < e.length; ++n) { let s = e[n]; if (s.rank === 1) - t.push(Bl(s, 1)); + t.push(Vl(s, 1)); else { if (s.rank === 0) throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar)."); @@ -13130,11 +13103,11 @@ function TB(e, t, n) { throw new U(`Input Tensors should have the same number of samples as target Tensors. Found ${s[0]} input sample(s) and ${r[0]} target sample(s).`); } function $B(e, t, n) { - let s = [gi, Pp, Yu]; + let s = [gi, Pp, Qu]; for (let r = 0; r < e.length; ++r) { let a = e[r], i = t[r], o = n[r]; if (i != null) { - if (i === Yu && a.shape[a.shape.length - 1] === 1) + if (i === Qu && a.shape[a.shape.length - 1] === 1) throw new U(`You are passing a target array of shape ${a.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`); if (s.indexOf(i) !== -1) { let u = a.shape.slice(1), l = o.slice(1); @@ -13198,8 +13171,7 @@ function _B(e, t) { var AB = "layers-model"; var pr = class extends Is { constructor(e) { - super(e); - this.isTraining = false; + super(e), this.isTraining = false; } summary(e, t, n = console.log) { if (!this.built) @@ -13319,7 +13291,7 @@ var pr = class extends Is { throw new U(`No value is provided for the model's input ${o.name}`); a.add(o, u); } - let i = _u(r, a); + let i = Au(r, a); return n ? i : i[0]; } retrieveSymbolicTensors(e) { @@ -13350,14 +13322,14 @@ var pr = class extends Is { let r = Im(s, t), a = this.outputs.map((i) => []); for (let i = 0; i < r.length; ++i) j(() => { - let u = r[i][0], l = r[i][1], c = Au(e, u, l), p = []; + let u = r[i][0], l = r[i][1], c = Eu(e, u, l), p = []; if (Array.isArray(c)) for (let h = 0; h < c.length; ++h) p.push({ key: this.inputs[h], value: c[h] }); else p.push({ key: this.inputs[0], value: c }); let d = new Qr(p); - return _u(this.outputs, d); + return Au(this.outputs, d); }).forEach((u, l) => a[l].push(u)); return bn(a.map((i) => Ft(i, 0))); }); @@ -13441,7 +13413,7 @@ var pr = class extends Is { let c = []; for (let f = 0; f < this.inputs.length; ++f) c.push({ key: this.inputs[f], value: n[f] }); - let p = new Qr(c), d = _u(this.outputs, p, { training: true }), h; + let p = new Qr(c), d = Au(this.outputs, p, { training: true }), h; for (let f = 0; f < this.lossFunctions.length; ++f) { let g = this.lossFunctions[f](s[f], d[f]); r[f] != null && (g = bB(g, r[f])); @@ -13470,7 +13442,7 @@ var pr = class extends Is { let t = [], n, s = e.slice(0, this.inputs.length), r = e.slice(this.inputs.length, this.inputs.length + this.outputs.length), a = []; for (let u = 0; u < this.inputs.length; ++u) a.push({ key: this.inputs[u], value: s[u] }); - let i = new Qr(a), o = _u(this.outputs, i); + let i = new Qr(a), o = Au(this.outputs, i); for (let u = 0; u < this.lossFunctions.length; ++u) { let l = this.lossFunctions[u], c = St(l(r[u], o[u])); u === 0 ? n = c : n = ie(n, c), t.push(n); @@ -13565,7 +13537,7 @@ var pr = class extends Is { throw new Error("Loading loss_weights is not supported yet."); if (e.sample_weight_mode != null) throw new Error("Loading sample_weight_mode is not supported yet."); - let t = Qu(e.optimizer_config), n = ms(t), s; + let t = Zu(e.optimizer_config), n = ms(t), s; if (typeof e.loss == "string") s = Kr(e.loss); else if (Array.isArray(e.loss)) @@ -13621,7 +13593,7 @@ async function EB(e, t) { "modelTopology" in e || (e = { modelTopology: e }), e = e; let n = e.modelTopology; n.model_config != null && (n = n.model_config); - let s = Qu(n), r = ms(s, t); + let s = Zu(n), r = ms(s, t); if (e.weightsManifest != null) { let a = await En.loadWeights(e.weightsManifest, e.pathPrefix, r.weights.map((o) => o.originalName)), i = {}; for (let o of r.weights) @@ -13646,7 +13618,7 @@ async function DB(e, t, n) { throw new U("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented."); let s = await e.load(), r = s.modelTopology; r.model_config != null && (r = r.model_config); - let a = n.strict == null ? true : n.strict, i = s.weightData != null && s.weightSpecs != null && a, o = ms(Qu(r), t, i), u = s.trainingConfig; + let a = n.strict == null ? true : n.strict, i = s.weightData != null && s.weightSpecs != null && a, o = ms(Zu(r), t, i), u = s.trainingConfig; if (u != null && o.loadTrainingConfig(u), s.userDefinedMetadata != null && o.setUserDefinedMetadata(s.userDefinedMetadata), s.weightData != null) { if (s.weightSpecs == null) throw new U("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed."); @@ -13663,8 +13635,7 @@ function FB(e, t) { } var Cm = class extends pr { constructor(e) { - super({ inputs: [], outputs: [] }); - if (e = e || {}, this.trainable = true, this.built = false, this.name = e.name != null ? e.name : Dp("sequential_"), e.layers != null) + if (super({ inputs: [], outputs: [] }), e = e || {}, this.trainable = true, this.built = false, this.name = e.name != null ? e.name : Dp("sequential_"), e.layers != null) for (let t of e.layers) this.add(t); } @@ -13809,19 +13780,19 @@ var Cm = class extends pr { var Ub = Cm; Ub.className = "Sequential"; ae.registerClass(Ub); -function Cpe(e) { +function Npe(e) { return new pr(e); } -function Npe(e) { +function Tpe(e) { return new Ub(e); } -function Tpe(e, t) { +function $pe(e, t) { return t == null && (t = {}), RB(e, t); } function OB(e) { return ZI(e); } -function $pe(e, t) { +function _pe(e, t) { zb.registerCallbackConstructor(e, t); } var In = class extends ae.Serializable { @@ -13880,7 +13851,7 @@ xS.className = "hardSigmoid"; ae.registerClass(xS); var wS = class extends In { apply(e) { - return Pl(e); + return zl(e); } }; wS.className = "softplus"; @@ -13894,7 +13865,7 @@ kS.className = "softsign"; ae.registerClass(kS); var IS = class extends In { apply(e) { - return Hu(e); + return qu(e); } }; IS.className = "tanh"; @@ -13922,7 +13893,7 @@ CS.className = "swish"; ae.registerClass(CS); var NS = class extends In { apply(e) { - return j(() => V(e, Hu(Pl(e)))); + return j(() => V(e, qu(zl(e)))); } }; NS.className = "mish"; @@ -13931,7 +13902,7 @@ function br(e) { return e.getClassName(); } function Gf(e, t = {}) { - return Ml(e, ae.SerializationMap.getMap().classNameMap, t, "activation"); + return Ll(e, ae.SerializationMap.getMap().classNameMap, t, "activation"); } function yr(e) { if (e == null) { @@ -13950,15 +13921,14 @@ function Hb(e) { } var TS = class extends ae.Serializable { }; -var Ul = class extends TS { +var Gl = class extends TS { constructor(e) { - super(); - Hb(e), this.l1 = e == null || e.l1 == null ? 0.01 : e.l1, this.l2 = e == null || e.l2 == null ? 0.01 : e.l2, this.hasL1 = this.l1 !== 0, this.hasL2 = this.l2 !== 0; + super(), Hb(e), this.l1 = e == null || e.l1 == null ? 0.01 : e.l1, this.l2 = e == null || e.l2 == null ? 0.01 : e.l2, this.hasL1 = this.l1 !== 0, this.hasL2 = this.l2 !== 0; } apply(e) { return j(() => { let t = $t([1]); - return this.hasL1 && (t = ie(t, ve(V(this.l1, Mt(e))))), this.hasL2 && (t = ie(t, ve(V(this.l2, Vl(e))))), G(t, []); + return this.hasL1 && (t = ie(t, ve(V(this.l1, Mt(e))))), this.hasL2 && (t = ie(t, ve(V(this.l2, Wl(e))))), G(t, []); }); } getConfig() { @@ -13968,20 +13938,20 @@ var Ul = class extends TS { return new e({ l1: t.l1, l2: t.l2 }); } }; -Ul.className = "L1L2"; -ae.registerClass(Ul); +Gl.className = "L1L2"; +ae.registerClass(Gl); function PB(e) { - return Hb(e), new Ul({ l1: e != null ? e.l1 : null, l2: 0 }); + return Hb(e), new Gl({ l1: e != null ? e.l1 : null, l2: 0 }); } function zB(e) { - return Hb(e), new Ul({ l2: e != null ? e.l2 : null, l1: 0 }); + return Hb(e), new Gl({ l2: e != null ? e.l2 : null, l1: 0 }); } var Vx = { l1l2: "L1L2" }; function it(e) { return wb(e); } function Wx(e, t = {}) { - return Ml(e, ae.SerializationMap.getMap().classNameMap, t, "regularizer"); + return Ll(e, ae.SerializationMap.getMap().classNameMap, t, "regularizer"); } function ft(e) { if (e == null) @@ -13994,8 +13964,7 @@ function ft(e) { } var qb = class extends Ge { constructor(e) { - super(e == null ? {} : e); - this.supportsMasking = true, e != null && (this.maxValue = e.maxValue); + super(e == null ? {} : e), this.supportsMasking = true, e != null && (this.maxValue = e.maxValue); } call(e, t) { e = Oe(e); @@ -14014,8 +13983,7 @@ qb.className = "ReLU"; ae.registerClass(qb); var jb = class extends Ge { constructor(e) { - super(e == null ? {} : e); - this.DEFAULT_ALPHA = 0.3, e == null && (e = {}), this.alpha = e.alpha == null ? this.DEFAULT_ALPHA : e.alpha; + super(e == null ? {} : e), this.DEFAULT_ALPHA = 0.3, e == null && (e = {}), this.alpha = e.alpha == null ? this.DEFAULT_ALPHA : e.alpha; } call(e, t) { let n = Oe(e); @@ -14033,8 +14001,7 @@ jb.className = "LeakyReLU"; ae.registerClass(jb); var Kb = class extends Ge { constructor(e) { - super(e == null ? {} : e); - if (this.DEFAULT_ALPHA_INITIALIZER = "zeros", e == null && (e = {}), this.supportsMasking = true, this.alphaInitializer = ht(e.alphaInitializer || this.DEFAULT_ALPHA_INITIALIZER), this.alphaRegularizer = ft(e.alphaRegularizer), this.alphaConstraint = Pt(e.alphaConstraint), e.sharedAxes == null) + if (super(e == null ? {} : e), this.DEFAULT_ALPHA_INITIALIZER = "zeros", e == null && (e = {}), this.supportsMasking = true, this.alphaInitializer = ht(e.alphaInitializer || this.DEFAULT_ALPHA_INITIALIZER), this.alphaRegularizer = ft(e.alphaRegularizer), this.alphaConstraint = Pt(e.alphaConstraint), e.sharedAxes == null) this.sharedAxes = null; else if (Array.isArray(e.sharedAxes)) this.sharedAxes = e.sharedAxes; @@ -14068,8 +14035,7 @@ Kb.className = "PReLU"; ae.registerClass(Kb); var Xb = class extends Ge { constructor(e) { - super(e == null ? {} : e); - if (this.DEFAULT_ALPHA = 1, e == null && (e = {}), e.alpha != null && e.alpha !== this.DEFAULT_ALPHA) + if (super(e == null ? {} : e), this.DEFAULT_ALPHA = 1, e == null && (e = {}), e.alpha != null && e.alpha !== this.DEFAULT_ALPHA) throw new Fe(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`); this.alpha = e.alpha == null ? this.DEFAULT_ALPHA : e.alpha; } @@ -14089,8 +14055,7 @@ Xb.className = "ELU"; ae.registerClass(Xb); var Yb = class extends Ge { constructor(e) { - super(e == null ? {} : e); - this.DEFAULT_THETA = 1, e == null && (e = {}), this.theta = e.theta == null ? this.DEFAULT_THETA : e.theta; + super(e == null ? {} : e), this.DEFAULT_THETA = 1, e == null && (e = {}), this.theta = e.theta == null ? this.DEFAULT_THETA : e.theta; } call(e, t) { let n = Oe(e); @@ -14108,8 +14073,7 @@ Yb.className = "ThresholdedReLU"; ae.registerClass(Yb); var Qb = class extends Ge { constructor(e) { - super(e == null ? {} : e); - this.DEFAULT_AXIS = 1, e == null && (e = {}), this.softmax = new Gb().apply, this.axis = e.axis == null ? this.DEFAULT_AXIS : e.axis; + super(e == null ? {} : e), this.DEFAULT_AXIS = 1, e == null && (e = {}), this.softmax = new Gb().apply, this.axis = e.axis == null ? this.DEFAULT_AXIS : e.axis; } call(e, t) { let n = Oe(e); @@ -14200,8 +14164,7 @@ function LB(e, t, n, s = [1, 1, 1], r = "valid", a, i) { } var Jb = class extends Ge { constructor(e, t) { - super(t); - if (this.bias = null, this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_BIAS_INITIALIZER = "zeros", Jb.verifyArgs(t), this.rank = e, Bt(this.rank, "rank"), this.rank !== 1 && this.rank !== 2 && this.rank !== 3) + if (super(t), this.bias = null, this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_BIAS_INITIALIZER = "zeros", Jb.verifyArgs(t), this.rank = e, Bt(this.rank, "rank"), this.rank !== 1 && this.rank !== 2 && this.rank !== 3) throw new Fe(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`); if (this.kernelSize = Xi(t.kernelSize, e, "kernelSize"), this.strides = Xi(t.strides == null ? 1 : t.strides, e, "strides"), this.padding = t.padding == null ? "valid" : t.padding, Un(this.padding), this.dataFormat = t.dataFormat == null ? "channelsLast" : t.dataFormat, Ct(this.dataFormat), this.activation = yr(t.activation), this.useBias = t.useBias == null ? true : t.useBias, this.biasInitializer = ht(t.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.biasConstraint = Pt(t.biasConstraint), this.biasRegularizer = ft(t.biasRegularizer), this.activityRegularizer = ft(t.activityRegularizer), this.dilationRate = Xi(t.dilationRate == null ? 1 : t.dilationRate, e, "dilationRate"), this.rank === 1 && Array.isArray(this.dilationRate) && this.dilationRate.length !== 1) throw new U(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`); @@ -14226,10 +14189,9 @@ var Jb = class extends Ge { return Object.assign(e, t), e; } }; -var Gl = class extends Jb { +var Hl = class extends Jb { constructor(e, t) { - super(e, t); - this.kernel = null, Gl.verifyArgs(t), this.filters = t.filters, Bt(this.filters, "filters"), this.kernelInitializer = ht(t.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.kernelConstraint = Pt(t.kernelConstraint), this.kernelRegularizer = ft(t.kernelRegularizer); + super(e, t), this.kernel = null, Hl.verifyArgs(t), this.filters = t.filters, Bt(this.filters, "filters"), this.kernelInitializer = ht(t.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.kernelConstraint = Pt(t.kernelConstraint), this.kernelRegularizer = ft(t.kernelRegularizer); } build(e) { e = nt(e); @@ -14278,10 +14240,9 @@ var Gl = class extends Jb { throw new U(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`); } }; -var _S = class extends Gl { +var _S = class extends Hl { constructor(e) { - super(2, e); - _S.verifyArgs(e); + super(2, e), _S.verifyArgs(e); } getConfig() { let e = super.getConfig(); @@ -14295,10 +14256,9 @@ var _S = class extends Gl { var zp = _S; zp.className = "Conv2D"; ae.registerClass(zp); -var AS = class extends Gl { +var AS = class extends Hl { constructor(e) { - super(3, e); - AS.verifyArgs(e); + super(3, e), AS.verifyArgs(e); } getConfig() { let e = super.getConfig(); @@ -14314,8 +14274,7 @@ Mp.className = "Conv3D"; ae.registerClass(Mp); var ey = class extends zp { constructor(e) { - super(e); - if (this.inputSpec = [new Dt({ ndim: 4 })], this.padding !== "same" && this.padding !== "valid") + if (super(e), this.inputSpec = [new Dt({ ndim: 4 })], this.padding !== "same" && this.padding !== "valid") throw new U(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`); } build(e) { @@ -14356,8 +14315,7 @@ ey.className = "Conv2DTranspose"; ae.registerClass(ey); var ty = class extends Mp { constructor(e) { - super(e); - if (this.inputSpec = [new Dt({ ndim: 5 })], this.padding !== "same" && this.padding !== "valid") + if (super(e), this.inputSpec = [new Dt({ ndim: 5 })], this.padding !== "same" && this.padding !== "valid") throw new U(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`); } build(e) { @@ -14396,10 +14354,9 @@ var ty = class extends Mp { }; ty.className = "Conv3DTranspose"; ae.registerClass(ty); -var ES = class extends Gl { +var ES = class extends Hl { constructor(e, t) { - super(e, t); - if (this.DEFAULT_DEPTHWISE_INITIALIZER = "glorotUniform", this.DEFAULT_POINTWISE_INITIALIZER = "glorotUniform", this.depthwiseKernel = null, this.pointwiseKernel = null, t.filters == null) + if (super(e, t), this.DEFAULT_DEPTHWISE_INITIALIZER = "glorotUniform", this.DEFAULT_POINTWISE_INITIALIZER = "glorotUniform", this.depthwiseKernel = null, this.pointwiseKernel = null, t.filters == null) throw new U("The `filters` configuration field is required by SeparableConv, but is unspecified."); if (t.kernelInitializer != null || t.kernelRegularizer != null || t.kernelConstraint != null) throw new U("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead."); @@ -14442,10 +14399,9 @@ var ny = class extends ES { }; ny.className = "SeparableConv2D"; ae.registerClass(ny); -var RS = class extends Gl { +var RS = class extends Hl { constructor(e) { - super(1, e); - RS.verifyArgs(e), this.inputSpec = [{ ndim: 3 }]; + super(1, e), RS.verifyArgs(e), this.inputSpec = [{ ndim: 3 }]; } getConfig() { let e = super.getConfig(); @@ -14461,8 +14417,7 @@ sy.className = "Conv1D"; ae.registerClass(sy); var ry = class extends Ge { constructor(e) { - super(e); - typeof e.cropping == "number" ? this.cropping = [[e.cropping, e.cropping], [e.cropping, e.cropping]] : typeof e.cropping[0] == "number" ? this.cropping = [[e.cropping[0], e.cropping[0]], [e.cropping[1], e.cropping[1]]] : this.cropping = e.cropping, this.dataFormat = e.dataFormat === void 0 ? "channelsLast" : e.dataFormat, this.inputSpec = [{ ndim: 4 }]; + super(e), typeof e.cropping == "number" ? this.cropping = [[e.cropping, e.cropping], [e.cropping, e.cropping]] : typeof e.cropping[0] == "number" ? this.cropping = [[e.cropping[0], e.cropping[0]], [e.cropping[1], e.cropping[1]]] : this.cropping = e.cropping, this.dataFormat = e.dataFormat === void 0 ? "channelsLast" : e.dataFormat, this.inputSpec = [{ ndim: 4 }]; } computeOutputShape(e) { return this.dataFormat === "channelsFirst" ? [e[0], e[1], e[2] - this.cropping[0][0] - this.cropping[0][1], e[3] - this.cropping[1][0] - this.cropping[1][1]] : [e[0], e[1] - this.cropping[0][0] - this.cropping[0][1], e[2] - this.cropping[1][0] - this.cropping[1][1], e[3]]; @@ -14487,8 +14442,7 @@ ry.className = "Cropping2D"; ae.registerClass(ry); var ay = class extends Ge { constructor(e) { - super(e); - this.DEFAULT_SIZE = [2, 2], this.inputSpec = [{ ndim: 4 }], this.size = e.size == null ? this.DEFAULT_SIZE : e.size, this.dataFormat = e.dataFormat == null ? "channelsLast" : e.dataFormat, Ct(this.dataFormat), this.interpolation = e.interpolation == null ? "nearest" : e.interpolation, ZM(this.interpolation); + super(e), this.DEFAULT_SIZE = [2, 2], this.inputSpec = [{ ndim: 4 }], this.size = e.size == null ? this.DEFAULT_SIZE : e.size, this.dataFormat = e.dataFormat == null ? "channelsLast" : e.dataFormat, Ct(this.dataFormat), this.interpolation = e.interpolation == null ? "nearest" : e.interpolation, ZM(this.interpolation); } computeOutputShape(e) { if (this.dataFormat === "channelsFirst") { @@ -14532,8 +14486,7 @@ function BB(e, t, n = [1, 1], s = "valid", r, a) { } var iy = class extends Jb { constructor(e) { - super(2, e); - this.depthwiseKernel = null, this.depthMultiplier = e.depthMultiplier == null ? 1 : e.depthMultiplier, this.depthwiseInitializer = ht(e.depthwiseInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.depthwiseConstraint = Pt(e.depthwiseConstraint), this.depthwiseRegularizer = ft(e.depthwiseRegularizer); + super(2, e), this.depthwiseKernel = null, this.depthMultiplier = e.depthMultiplier == null ? 1 : e.depthMultiplier, this.depthwiseInitializer = ht(e.depthwiseInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.depthwiseConstraint = Pt(e.depthwiseConstraint), this.depthwiseRegularizer = ft(e.depthwiseRegularizer); } build(e) { if (e = nt(e), e.length < 4) @@ -14739,7 +14692,7 @@ var OS = class extends Ge { getInitialState(e) { return j(() => { let t = $t(e.shape); - return t = ve(t, [1, 2]), t = Bl(t), Array.isArray(this.cell.stateSize) ? this.cell.stateSize.map((n) => n > 1 ? gm(t, [1, n]) : t) : this.cell.stateSize > 1 ? [gm(t, [1, this.cell.stateSize])] : [t]; + return t = ve(t, [1, 2]), t = Vl(t), Array.isArray(this.cell.stateSize) ? this.cell.stateSize.map((n) => n > 1 ? gm(t, [1, n]) : t) : this.cell.stateSize > 1 ? [gm(t, [1, this.cell.stateSize])] : [t]; }); } get trainableWeights() { @@ -14765,12 +14718,11 @@ var OS = class extends Ge { var Ar = OS; Ar.className = "RNN"; ae.registerClass(Ar); -var Hl = class extends Ge { +var ql = class extends Ge { }; -var Lp = class extends Hl { +var Lp = class extends ql { constructor(e) { - super(e); - this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", this.units = e.units, Bt(this.units, "units"), this.activation = yr(e.activation == null ? this.DEFAULT_ACTIVATION : e.activation), this.useBias = e.useBias == null ? true : e.useBias, this.kernelInitializer = ht(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = ht(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = ht(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.kernelRegularizer = ft(e.kernelRegularizer), this.recurrentRegularizer = ft(e.recurrentRegularizer), this.biasRegularizer = ft(e.biasRegularizer), this.kernelConstraint = Pt(e.kernelConstraint), this.recurrentConstraint = Pt(e.recurrentConstraint), this.biasConstraint = Pt(e.biasConstraint), this.dropout = Zi([1, gr([0, e.dropout == null ? 0 : e.dropout])]), this.recurrentDropout = Zi([1, gr([0, e.recurrentDropout == null ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.stateSize = this.units, this.dropoutMask = null, this.recurrentDropoutMask = null; + super(e), this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", this.units = e.units, Bt(this.units, "units"), this.activation = yr(e.activation == null ? this.DEFAULT_ACTIVATION : e.activation), this.useBias = e.useBias == null ? true : e.useBias, this.kernelInitializer = ht(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = ht(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = ht(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.kernelRegularizer = ft(e.kernelRegularizer), this.recurrentRegularizer = ft(e.recurrentRegularizer), this.biasRegularizer = ft(e.biasRegularizer), this.kernelConstraint = Pt(e.kernelConstraint), this.recurrentConstraint = Pt(e.recurrentConstraint), this.biasConstraint = Pt(e.biasConstraint), this.dropout = Zi([1, gr([0, e.dropout == null ? 0 : e.dropout])]), this.recurrentDropout = Zi([1, gr([0, e.recurrentDropout == null ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.stateSize = this.units, this.dropoutMask = null, this.recurrentDropoutMask = null; } build(e) { e = nt(e), this.kernel = this.addWeight("kernel", [e[e.length - 1], this.units], null, this.kernelInitializer, this.kernelRegularizer, true, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, this.units], null, this.recurrentInitializer, this.recurrentRegularizer, true, this.recurrentConstraint), this.useBias ? this.bias = this.addWeight("bias", [this.units], null, this.biasInitializer, this.biasRegularizer, true, this.biasConstraint) : this.bias = null, this.built = true; @@ -14798,8 +14750,7 @@ Lp.className = "SimpleRNNCell"; ae.registerClass(Lp); var oy = class extends Ar { constructor(e) { - e.cell = new Lp(e); - super(e); + e.cell = new Lp(e), super(e); } call(e, t) { return j(() => { @@ -14814,10 +14765,9 @@ var oy = class extends Ar { }; oy.className = "SimpleRNN"; ae.registerClass(oy); -var Bp = class extends Hl { +var Bp = class extends ql { constructor(e) { - super(e); - if (this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", e.resetAfter) + if (super(e), this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", e.resetAfter) throw new U("GRUCell does not support reset_after parameter set to true."); this.units = e.units, Bt(this.units, "units"), this.activation = yr(e.activation === void 0 ? this.DEFAULT_ACTIVATION : e.activation), this.recurrentActivation = yr(e.recurrentActivation === void 0 ? this.DEFAULT_RECURRENT_ACTIVATION : e.recurrentActivation), this.useBias = e.useBias == null ? true : e.useBias, this.kernelInitializer = ht(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = ht(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = ht(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.kernelRegularizer = ft(e.kernelRegularizer), this.recurrentRegularizer = ft(e.recurrentRegularizer), this.biasRegularizer = ft(e.biasRegularizer), this.kernelConstraint = Pt(e.kernelConstraint), this.recurrentConstraint = Pt(e.recurrentConstraint), this.biasConstraint = Pt(e.biasConstraint), this.dropout = Zi([1, gr([0, e.dropout == null ? 0 : e.dropout])]), this.recurrentDropout = Zi([1, gr([0, e.recurrentDropout == null ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.implementation = e.implementation, this.stateSize = this.units, this.dropoutMask = null, this.recurrentDropoutMask = null; } @@ -14853,8 +14803,7 @@ Bp.className = "GRUCell"; ae.registerClass(Bp); var uy = class extends Ar { constructor(e) { - e.implementation === 0 && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), e.cell = new Bp(e); - super(e); + e.implementation === 0 && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), e.cell = new Bp(e), super(e); } call(e, t) { return j(() => { @@ -14869,10 +14818,9 @@ var uy = class extends Ar { }; uy.className = "GRU"; ae.registerClass(uy); -var ql = class extends Hl { +var jl = class extends ql { constructor(e) { - super(e); - this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", this.units = e.units, Bt(this.units, "units"), this.activation = yr(e.activation === void 0 ? this.DEFAULT_ACTIVATION : e.activation), this.recurrentActivation = yr(e.recurrentActivation === void 0 ? this.DEFAULT_RECURRENT_ACTIVATION : e.recurrentActivation), this.useBias = e.useBias == null ? true : e.useBias, this.kernelInitializer = ht(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = ht(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = ht(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.unitForgetBias = e.unitForgetBias, this.kernelRegularizer = ft(e.kernelRegularizer), this.recurrentRegularizer = ft(e.recurrentRegularizer), this.biasRegularizer = ft(e.biasRegularizer), this.kernelConstraint = Pt(e.kernelConstraint), this.recurrentConstraint = Pt(e.recurrentConstraint), this.biasConstraint = Pt(e.biasConstraint), this.dropout = Zi([1, gr([0, e.dropout == null ? 0 : e.dropout])]), this.recurrentDropout = Zi([1, gr([0, e.recurrentDropout == null ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.implementation = e.implementation, this.stateSize = [this.units, this.units], this.dropoutMask = null, this.recurrentDropoutMask = null; + super(e), this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", this.units = e.units, Bt(this.units, "units"), this.activation = yr(e.activation === void 0 ? this.DEFAULT_ACTIVATION : e.activation), this.recurrentActivation = yr(e.recurrentActivation === void 0 ? this.DEFAULT_RECURRENT_ACTIVATION : e.recurrentActivation), this.useBias = e.useBias == null ? true : e.useBias, this.kernelInitializer = ht(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = ht(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = ht(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.unitForgetBias = e.unitForgetBias, this.kernelRegularizer = ft(e.kernelRegularizer), this.recurrentRegularizer = ft(e.recurrentRegularizer), this.biasRegularizer = ft(e.biasRegularizer), this.kernelConstraint = Pt(e.kernelConstraint), this.recurrentConstraint = Pt(e.recurrentConstraint), this.biasConstraint = Pt(e.biasConstraint), this.dropout = Zi([1, gr([0, e.dropout == null ? 0 : e.dropout])]), this.recurrentDropout = Zi([1, gr([0, e.recurrentDropout == null ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.implementation = e.implementation, this.stateSize = [this.units, this.units], this.dropoutMask = null, this.recurrentDropoutMask = null; } build(e) { var t; @@ -14918,12 +14866,11 @@ var ql = class extends Hl { return { ...e, ...t }; } }; -ql.className = "LSTMCell"; -ae.registerClass(ql); +jl.className = "LSTMCell"; +ae.registerClass(jl); var ly = class extends Ar { constructor(e) { - e.implementation === 0 && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), e.cell = new ql(e); - super(e); + e.implementation === 0 && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), e.cell = new jl(e), super(e); } call(e, t) { return j(() => { @@ -14938,10 +14885,9 @@ var ly = class extends Ar { }; ly.className = "LSTM"; ae.registerClass(ly); -var Vp = class extends Hl { +var Vp = class extends ql { constructor(e) { - super(e); - this.cells = e.cells; + super(e), this.cells = e.cells; } get stateSize() { let e = []; @@ -15025,7 +14971,7 @@ var Vp = class extends Hl { Vp.className = "StackedRNNCells"; ae.registerClass(Vp); function vr(e) { - let { ones: t, rate: n, training: s = false, count: r = 1, dropoutFunc: a } = e, i = () => a != null ? a(t(), n) : XI(t(), n), o = () => Wl(i, t, s); + let { ones: t, rate: n, training: s = false, count: r = 1, dropoutFunc: a } = e, i = () => a != null ? a(t(), n) : XI(t(), n), o = () => Ul(i, t, s); return !r || r <= 1 ? Ht(o().clone()) : Array(r).fill(void 0).map(o).map((l) => Ht(l.clone())); } var PS = class extends Ar { @@ -15034,8 +14980,7 @@ var PS = class extends Ar { throw new Fe("Unrolling is not possible with convolutional RNNs."); if (Array.isArray(e.cell)) throw new Fe("It is not possible at the moment to stack convolutional cells."); - super(e); - this.inputSpec = [new Dt({ ndim: 5 })]; + super(e), this.inputSpec = [new Dt({ ndim: 5 })]; } call(e, t) { return j(() => { @@ -15086,11 +15031,10 @@ var PS = class extends Ar { } }; PS.className = "ConvRNN2D"; -var Wp = class extends ql { +var Wp = class extends jl { constructor(e) { let { filters: t, kernelSize: n, strides: s, padding: r, dataFormat: a, dilationRate: i } = e; - super({ ...e, units: t }); - this.filters = t, Bt(this.filters, "filters"), this.kernelSize = Xi(n, 2, "kernelSize"), this.kernelSize.forEach((o) => Bt(o, "kernelSize")), this.strides = Xi(s || 1, 2, "strides"), this.strides.forEach((o) => Bt(o, "strides")), this.padding = r || "valid", Un(this.padding), this.dataFormat = a || "channelsLast", Ct(this.dataFormat), this.dilationRate = Xi(i || 1, 2, "dilationRate"), this.dilationRate.forEach((o) => Bt(o, "dilationRate")); + super({ ...e, units: t }), this.filters = t, Bt(this.filters, "filters"), this.kernelSize = Xi(n, 2, "kernelSize"), this.kernelSize.forEach((o) => Bt(o, "kernelSize")), this.strides = Xi(s || 1, 2, "strides"), this.strides.forEach((o) => Bt(o, "strides")), this.padding = r || "valid", Un(this.padding), this.dataFormat = a || "channelsLast", Ct(this.dataFormat), this.dilationRate = Xi(i || 1, 2, "dilationRate"), this.dilationRate.forEach((o) => Bt(o, "dilationRate")); } build(e) { var t; @@ -15160,8 +15104,7 @@ cy.className = "ConvLSTM2D"; ae.registerClass(cy); var Up = class extends Ge { constructor(e) { - super(e); - this.rate = Math.max(Math.min(e.rate, 1), 0), this.noiseShape = e.noiseShape, this.seed = e.seed, this.supportsMasking = true; + super(e), this.rate = Math.max(Math.min(e.rate, 1), 0), this.noiseShape = e.noiseShape, this.seed = e.seed, this.supportsMasking = true; } getNoiseShape(e) { if (this.noiseShape == null) @@ -15177,7 +15120,7 @@ var Up = class extends Ge { let n = Oe(e); if (0 < this.rate && this.rate < 1) { let s = t.training == null ? false : t.training, r = this.getNoiseShape(n); - return Wl(() => XI(n, this.rate, r, this.seed), () => n, s); + return Ul(() => XI(n, this.rate, r, this.seed), () => n, s); } return e; }); @@ -15194,8 +15137,7 @@ Up.className = "Dropout"; ae.registerClass(Up); var dy = class extends Up { constructor(e) { - super(e); - this.inputSpec = [{ ndim: 3 }]; + super(e), this.inputSpec = [{ ndim: 3 }]; } getNoiseShape(e) { let t = e.shape; @@ -15206,8 +15148,7 @@ dy.className = "SpatialDropout1D"; ae.registerClass(dy); var py = class extends Ge { constructor(e) { - super(e); - if (this.activation = null, this.useBias = true, this.kernel = null, this.bias = null, this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_BIAS_INITIALIZER = "zeros", e.batchInputShape == null && e.inputShape == null && e.inputDim != null) { + if (super(e), this.activation = null, this.useBias = true, this.kernel = null, this.bias = null, this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_BIAS_INITIALIZER = "zeros", e.batchInputShape == null && e.inputShape == null && e.inputDim != null) { let t = null; e.batchSize != null && (t = e.batchSize), this.batchInputShape = [t, e.inputDim]; } @@ -15239,9 +15180,7 @@ py.className = "Dense"; ae.registerClass(py); var hy = class extends Ge { constructor(e) { - e = e || {}; - super(e); - this.inputSpec = [{ minNDim: 3 }], this.dataFormat = e.dataFormat; + e = e || {}, super(e), this.inputSpec = [{ minNDim: 3 }], this.dataFormat = e.dataFormat; } computeOutputShape(e) { e = nt(e); @@ -15274,8 +15213,7 @@ hy.className = "Flatten"; ae.registerClass(hy); var fy = class extends Ge { constructor(e) { - super(e); - this.supportsMasking = true, this.activation = yr(e.activation); + super(e), this.supportsMasking = true, this.activation = yr(e.activation); } call(e, t) { return j(() => { @@ -15293,8 +15231,7 @@ fy.className = "Activation"; ae.registerClass(fy); var my = class extends Ge { constructor(e) { - super(e); - this.n = e.n, this.inputSpec = [{ ndim: 2 }]; + super(e), this.n = e.n, this.inputSpec = [{ ndim: 2 }]; } computeOutputShape(e) { return [e[0], this.n, e[1]]; @@ -15311,8 +15248,7 @@ my.className = "RepeatVector"; ae.registerClass(my); var gy = class extends Ge { constructor(e) { - super(e); - this.targetShape = e.targetShape; + super(e), this.targetShape = e.targetShape; for (let t = 0; t < this.targetShape.length; ++t) this.isUnknown(this.targetShape[t]) && (this.targetShape[t] = null); } @@ -15365,8 +15301,7 @@ gy.className = "Reshape"; ae.registerClass(gy); var by = class extends Ge { constructor(e) { - super(e); - if (e.dims == null) + if (super(e), e.dims == null) throw new Error("Required configuration field `dims` is missing during Permute constructor call."); if (!Array.isArray(e.dims)) throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`); @@ -15394,8 +15329,7 @@ by.className = "Permute"; ae.registerClass(by); var yy = class extends Ge { constructor(e) { - super(e == null ? {} : e); - this.supportsMasking = true, e != null ? this.maskValue = e.maskValue == null ? 0 : e.maskValue : this.maskValue = 0; + super(e == null ? {} : e), this.supportsMasking = true, e != null ? this.maskValue = e.maskValue == null ? 0 : e.maskValue : this.maskValue = 0; } computeOutputShape(e) { return e; @@ -15406,12 +15340,12 @@ var yy = class extends Ge { } computeMask(e, t) { let n = Oe(e), s = -1; - return pm(Ku(n, this.maskValue), s); + return pm(Xu(n, this.maskValue), s); } call(e, t) { return j(() => { this.invokeCallHook(e, t); - let n = Oe(e), s = -1, r = true, a = pm(Ku(n, this.maskValue), s, r); + let n = Oe(e), s = -1, r = true, a = pm(Xu(n, this.maskValue), s, r); return V(n, ce(a, n.dtype)); }); } @@ -15420,8 +15354,7 @@ yy.className = "Masking"; ae.registerClass(yy); var vy = class extends Ge { constructor(e) { - super(e); - if (this.embeddings = null, this.DEFAULT_EMBEDDINGS_INITIALIZER = "randomUniform", e.batchInputShape == null && e.inputShape == null) { + if (super(e), this.embeddings = null, this.DEFAULT_EMBEDDINGS_INITIALIZER = "randomUniform", e.batchInputShape == null && e.inputShape == null) { let t = null; e.batchSize != null && (t = e.batchSize), e.inputLength == null ? this.batchInputShape = [t, null] : this.batchInputShape = [t].concat(dt(e.inputLength)); } @@ -15433,7 +15366,7 @@ var vy = class extends Ge { warnOnIncompatibleInputShape(e) { } computeMask(e, t) { - return j(() => this.maskZero ? (e = Oe(e), Ku(e, je(e))) : null); + return j(() => this.maskZero ? (e = Oe(e), Xu(e, je(e))) : null); } computeOutputShape(e) { if (e = nt(e), this.inputLength == null) @@ -15470,8 +15403,7 @@ vy.className = "Embedding"; ae.registerClass(vy); var bi = class extends Ge { constructor(e) { - super(e || {}); - this.supportsMasking = true; + super(e || {}), this.supportsMasking = true; } mergeFunction(e) { throw new Fe(); @@ -15525,7 +15457,7 @@ var bi = class extends Ge { for (let a of e) { let i = a.rank; for (let o = 0; o < r - i; ++o) - a = Bl(a, 1); + a = Vl(a, 1); n.push(a); } return this.mergeFunction(n); @@ -15668,8 +15600,7 @@ Sy.className = "Minimum"; ae.registerClass(Sy); var Cy = class extends bi { constructor(e) { - super(e); - this.DEFAULT_AXIS = -1, e == null && (e = {}), this.axis = e.axis == null ? this.DEFAULT_AXIS : e.axis, this.supportsMasking = true, this.reshapeRequired = false; + super(e), this.DEFAULT_AXIS = -1, e == null && (e = {}), this.axis = e.axis == null ? this.DEFAULT_AXIS : e.axis, this.supportsMasking = true, this.reshapeRequired = false; } build(e) { if (!(Array.isArray(e) && Array.isArray(e[0])) || e.length === 1) @@ -15746,7 +15677,7 @@ var Cy = class extends bi { }; Cy.className = "Concatenate"; ae.registerClass(Cy); -function Su(e, t) { +function Cu(e, t) { for (; e < 0; ) e += t; return e; @@ -15795,8 +15726,7 @@ function VB(e, t, n) { } var Ny = class extends bi { constructor(e) { - super(e); - this.axes = e.axes, this.normalize = e.normalize == null ? false : e.normalize, this.supportsMasking = true, this.reshapeRequired = false; + super(e), this.axes = e.axes, this.normalize = e.normalize == null ? false : e.normalize, this.supportsMasking = true, this.reshapeRequired = false; } build(e) { w.assert(Array.isArray(e) && e.length === 2 && Array.isArray(e[0]) && Array.isArray(e[1]), () => "A `Dot` layer should be called on a list of exactly 2 inputs."); @@ -15811,11 +15741,11 @@ var Ny = class extends bi { if (e.length !== 2) throw new U(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`); let t = e[0], n = e[1], s; - return Array.isArray(this.axes) ? s = this.axes.map((r, a) => Su(r, e[a].shape.length)) : s = [Su(this.axes, t.shape.length), Su(this.axes, n.shape.length)], this.normalize && (t = Nd(t, s[0]), n = Nd(n, s[1])), VB(t, n, s); + return Array.isArray(this.axes) ? s = this.axes.map((r, a) => Cu(r, e[a].shape.length)) : s = [Cu(this.axes, t.shape.length), Cu(this.axes, n.shape.length)], this.normalize && (t = Nd(t, s[0]), n = Nd(n, s[1])), VB(t, n, s); } interpretAxes(e, t) { let n; - return Array.isArray(this.axes) ? n = this.axes : n = [Su(this.axes, e.length), Su(this.axes, t.length)], n; + return Array.isArray(this.axes) ? n = this.axes : n = [Cu(this.axes, e.length), Cu(this.axes, t.length)], n; } computeOutputShape(e) { w.assert(Array.isArray(e) && e.length === 2 && Array.isArray(e[0]) && Array.isArray(e[1]), () => "A `Dot` layer should be called on a list of exactly 2 inputs."); @@ -15839,8 +15769,7 @@ Ny.className = "Dot"; ae.registerClass(Ny); var Ty = class extends Ge { constructor(e) { - super(e); - this.supportsMasking = true, this.stddev = e.stddev; + super(e), this.supportsMasking = true, this.stddev = e.stddev; } computeOutputShape(e) { return e; @@ -15853,7 +15782,7 @@ var Ty = class extends Ge { return j(() => { this.invokeCallHook(e, t); let n = Oe(e); - return Wl(() => ie(Cp(n.shape, 0, this.stddev), n), () => n, t.training || false); + return Ul(() => ie(Cp(n.shape, 0, this.stddev), n), () => n, t.training || false); }); } }; @@ -15861,8 +15790,7 @@ Ty.className = "GaussianNoise"; ae.registerClass(Ty); var $y = class extends Ge { constructor(e) { - super(e); - this.supportsMasking = true, this.rate = e.rate; + super(e), this.supportsMasking = true, this.rate = e.rate; } computeOutputShape(e) { return e; @@ -15875,7 +15803,7 @@ var $y = class extends Ge { return j(() => { this.invokeCallHook(e, t); let n = Oe(e); - return this.rate > 0 && this.rate < 1 ? Wl(() => { + return this.rate > 0 && this.rate < 1 ? Ul(() => { let r = Math.sqrt(this.rate / (1 - this.rate)); return V(n, Cp(n.shape, 1, r)); }, () => n, t.training || false) : n; @@ -15886,8 +15814,7 @@ $y.className = "GaussianDropout"; ae.registerClass($y); var _y = class extends Ge { constructor(e) { - super(e); - this.supportsMasking = true, this.rate = e.rate, this.noiseShape = e.noiseShape; + super(e), this.supportsMasking = true, this.rate = e.rate, this.noiseShape = e.noiseShape; } _getNoiseShape(e) { return this.noiseShape || Oe(e).shape; @@ -15903,8 +15830,8 @@ var _y = class extends Ge { return j(() => { if (this.rate < 1 && this.rate > 0) { let n = this._getNoiseShape(e); - return Wl(() => { - let r = Oe(e), a = 1.6732632423543772, i = 1.0507009873554805, o = -a * i, u = jo(zl(n), this.rate); + return Ul(() => { + let r = Oe(e), a = 1.6732632423543772, i = 1.0507009873554805, o = -a * i, u = Ko(Ml(n), this.rate); u = Sp(u, "float32"); let l = ((1 - this.rate) * (1 + this.rate * o ** 2)) ** -0.5, c = -l * o * this.rate, p = ie(V(r, u), V(ie(u, -1), o)); return ie(V(p, l), c); @@ -15916,7 +15843,7 @@ var _y = class extends Ge { }; _y.className = "AlphaDropout"; ae.registerClass(_y); -function Zu(e, t, n, s, r, a = 1e-3) { +function Ju(e, t, n, s, r, a = 1e-3) { let i; if (e.rank === 2) i = $E(e, t, n, s, r, a); @@ -15931,7 +15858,7 @@ function Zu(e, t, n, s, r, a = 1e-3) { function WB(e, t, n, s, r = 1e-3) { return j(() => { let a = tb(e, s), i = a.mean, o = a.variance; - return [Zu(e, i, o, n, t, r), i, o]; + return [Ju(e, i, o, n, t, r), i, o]; }); } function UB(e, t, n, s, r = 1e-3) { @@ -15940,7 +15867,7 @@ function UB(e, t, n, s, r = 1e-3) { for (let f of ys(0, e.rank)) s.indexOf(f) !== -1 ? u.push(1) : u.push(e.shape[f]); let l = G(i, u), c = G(o, u), p = t == null ? null : G(t, u), d = n == null ? null : G(n, u); - return [Zu(e, l, c, d, p, r), i, o]; + return [Ju(e, l, c, d, p, r), i, o]; }); } function GB(e, t, n, s, r = 1e-3) { @@ -15948,9 +15875,7 @@ function GB(e, t, n, s, r = 1e-3) { } var Ay = class extends Ge { constructor(e) { - e == null && (e = {}); - super(e); - this.supportsMasking = true, this.axis = e.axis == null ? -1 : e.axis, this.momentum = e.momentum == null ? 0.99 : e.momentum, this.epsilon = e.epsilon == null ? 1e-3 : e.epsilon, this.center = e.center == null ? true : e.center, this.scale = e.scale == null ? true : e.scale, this.betaInitializer = ht(e.betaInitializer || "zeros"), this.gammaInitializer = ht(e.gammaInitializer || "ones"), this.movingMeanInitializer = ht(e.movingMeanInitializer || "zeros"), this.movingVarianceInitializer = ht(e.movingVarianceInitializer || "ones"), this.betaConstraint = Pt(e.betaConstraint), this.gammaConstraint = Pt(e.gammaConstraint), this.betaRegularizer = ft(e.betaRegularizer), this.gammaRegularizer = ft(e.gammaRegularizer); + e == null && (e = {}), super(e), this.supportsMasking = true, this.axis = e.axis == null ? -1 : e.axis, this.momentum = e.momentum == null ? 0.99 : e.momentum, this.epsilon = e.epsilon == null ? 1e-3 : e.epsilon, this.center = e.center == null ? true : e.center, this.scale = e.scale == null ? true : e.scale, this.betaInitializer = ht(e.betaInitializer || "zeros"), this.gammaInitializer = ht(e.gammaInitializer || "ones"), this.movingMeanInitializer = ht(e.movingMeanInitializer || "zeros"), this.movingVarianceInitializer = ht(e.movingVarianceInitializer || "ones"), this.betaConstraint = Pt(e.betaConstraint), this.gammaConstraint = Pt(e.gammaConstraint), this.betaRegularizer = ft(e.betaRegularizer), this.gammaRegularizer = ft(e.gammaRegularizer); } build(e) { e = nt(e); @@ -15972,9 +15897,9 @@ var Ay = class extends Ge { let c = !w.arraysEqual(l, ys(0, a).slice(0, a - 1)), p = () => { if (c) { let b = G(this.movingMean.read(), u), y = G(this.movingVariance.read(), u), v = this.center ? G(this.beta.read(), u) : null, x = this.scale ? G(this.gamma.read(), u) : null; - return Zu(s, b, y, v, x, this.epsilon); + return Ju(s, b, y, v, x, this.epsilon); } else - return Zu(s, this.movingMean.read(), this.movingVariance.read(), this.beta == null ? null : this.beta.read(), this.gamma == null ? null : this.gamma.read(), this.epsilon); + return Ju(s, this.movingMean.read(), this.movingVariance.read(), this.beta == null ? null : this.beta.read(), this.gamma == null ? null : this.gamma.read(), this.epsilon); }; if (!n) return p(); @@ -15998,9 +15923,7 @@ Ay.className = "BatchNormalization"; ae.registerClass(Ay); var Ey = class extends Ge { constructor(e) { - e == null && (e = {}); - super(e); - if (this.axis = e.axis == null ? -1 : e.axis, typeof this.axis == "number") { + if (e == null && (e = {}), super(e), this.axis = e.axis == null ? -1 : e.axis, typeof this.axis == "number") { if (!Number.isInteger(this.axis)) throw new Error(`Expected axis to be an integer, but received ${this.axis}`); } else if (Array.isArray(this.axis)) { @@ -16034,7 +15957,7 @@ var Ey = class extends Ge { let l = (f) => f != null && f.shape.length !== r ? G(f, u) : f, c = l(this.gamma.read()), p = l(this.beta.read()), d = [], h = []; for (let f = 0; f < r; ++f) this.axis.indexOf(f) !== -1 ? (d.push(s[f]), h.push(1)) : (d.push(1), h.push(s[f])); - return i = ps(i, d), o = ps(o, d), c = ps(c, h), p = ps(p, h), Zu(n, i, o, p, c, this.epsilon); + return i = ps(i, d), o = ps(o, d), c = ps(c, h), p = ps(p, h), Ju(n, i, o, p, c, this.epsilon); }); } getConfig() { @@ -16058,9 +15981,7 @@ function HB(e, t, n) { } var Ry = class extends Ge { constructor(e) { - e == null && (e = {}); - super(e); - if (this.dataFormat = e.dataFormat == null ? bs() : e.dataFormat, e.padding == null) + if (e == null && (e = {}), super(e), this.dataFormat = e.dataFormat == null ? bs() : e.dataFormat, e.padding == null) this.padding = [[1, 1], [1, 1]]; else if (typeof e.padding == "number") this.padding = [[e.padding, e.padding], [e.padding, e.padding]]; @@ -16112,9 +16033,7 @@ function zS(e, t, n, s, r, a) { } var MS = class extends Ge { constructor(e) { - e.poolSize == null && (e.poolSize = 2); - super(e); - if (typeof e.poolSize == "number") + if (e.poolSize == null && (e.poolSize = 2), super(e), typeof e.poolSize == "number") this.poolSize = [e.poolSize]; else if (Array.isArray(e.poolSize) && e.poolSize.length === 1 && typeof e.poolSize[0] == "number") this.poolSize = e.poolSize; @@ -16137,7 +16056,7 @@ var MS = class extends Ge { } call(e, t) { return j(() => { - this.invokeCallHook(e, t), e = Bl(Oe(e), 2); + this.invokeCallHook(e, t), e = Vl(Oe(e), 2); let n = this.poolingFunction(Oe(e), [this.poolSize[0], 1], [this.strides[0], 1], this.padding, "channelsLast"); return mr(n, [2]); }); @@ -16169,9 +16088,7 @@ Fy.className = "AveragePooling1D"; ae.registerClass(Fy); var LS = class extends Ge { constructor(e) { - e.poolSize == null && (e.poolSize = [2, 2]); - super(e); - if (this.poolSize = Array.isArray(e.poolSize) ? e.poolSize : [e.poolSize, e.poolSize], e.strides == null) + if (e.poolSize == null && (e.poolSize = [2, 2]), super(e), this.poolSize = Array.isArray(e.poolSize) ? e.poolSize : [e.poolSize, e.poolSize], e.strides == null) this.strides = this.poolSize; else if (Array.isArray(e.strides)) { if (e.strides.length !== 2) @@ -16216,9 +16133,7 @@ Py.className = "AveragePooling2D"; ae.registerClass(Py); var BS = class extends Ge { constructor(e) { - e.poolSize == null && (e.poolSize = [2, 2, 2]); - super(e); - if (this.poolSize = Array.isArray(e.poolSize) ? e.poolSize : [e.poolSize, e.poolSize, e.poolSize], e.strides == null) + if (e.poolSize == null && (e.poolSize = [2, 2, 2]), super(e), this.poolSize = Array.isArray(e.poolSize) ? e.poolSize : [e.poolSize, e.poolSize, e.poolSize], e.strides == null) this.strides = this.poolSize; else if (Array.isArray(e.strides)) { if (e.strides.length !== 3) @@ -16263,8 +16178,7 @@ My.className = "AveragePooling3D"; ae.registerClass(My); var VS = class extends Ge { constructor(e) { - super(e); - this.inputSpec = [new Dt({ ndim: 3 })]; + super(e), this.inputSpec = [new Dt({ ndim: 3 })]; } computeOutputShape(e) { return [e[0], e[2]]; @@ -16301,8 +16215,7 @@ By.className = "GlobalMaxPooling1D"; ae.registerClass(By); var WS = class extends Ge { constructor(e) { - super(e); - this.dataFormat = e.dataFormat == null ? "channelsLast" : e.dataFormat, Ct(this.dataFormat), this.inputSpec = [new Dt({ ndim: 4 })]; + super(e), this.dataFormat = e.dataFormat == null ? "channelsLast" : e.dataFormat, Ct(this.dataFormat), this.inputSpec = [new Dt({ ndim: 4 })]; } computeOutputShape(e) { return e = e, this.dataFormat === "channelsLast" ? [e[0], e[3]] : [e[0], e[1]]; @@ -16337,8 +16250,7 @@ Wy.className = "GlobalMaxPooling2D"; ae.registerClass(Wy); var US = class extends Ge { constructor(e) { - super(e); - this.layer = e.layer; + super(e), this.layer = e.layer; } build(e) { this.built = true; @@ -16383,8 +16295,7 @@ var US = class extends Ge { }; var Uy = class extends US { constructor(e) { - super(e); - this.supportsMasking = true; + super(e), this.supportsMasking = true; } build(e) { if (e = nt(e), e.length < 3) @@ -16524,7 +16435,7 @@ var Gy = class extends US { Gy.className = "Bidirectional"; ae.registerClass(Gy); function KB(e) { - return new Yo(e); + return new Qo(e); } function XB(e) { return new Xb(e); @@ -16686,7 +16597,7 @@ function BV(e) { return new ly(e); } function VV(e) { - return new ql(e); + return new jl(e); } function WV(e) { return new oy(e); @@ -16758,13 +16669,13 @@ function hW(e, t) { return Op(e, t); } function fW(e, t) { - return Qo(e, t); + return Zo(e, t); } function mW(e, t) { - return Qo(e, t); + return Zo(e, t); } function gW(e, t) { - return Qo(e, t); + return Zo(e, t); } function bW(e, t) { return gi(e, t); @@ -16780,7 +16691,7 @@ Ae(xW, { modelFromJSON: () => EB }); var wW = {}; Ae(wW, { l1: () => IW, l1l2: () => kW, l2: () => SW }); function kW(e) { - return new Ul(e); + return new Gl(e); } function IW(e) { return PB(e); @@ -16790,8 +16701,7 @@ function SW(e) { } var CW = class extends Ji { constructor() { - super(...arguments); - this.model = null; + super(...arguments), this.model = null; } setModel(e) { if (!(e instanceof pr)) @@ -16807,8 +16717,7 @@ function Gx(e, t) { } var NW = class extends CW { constructor(e) { - super(); - if (e == null && (e = {}), e.restoreBestWeights) + if (super(), e == null && (e = {}), e.restoreBestWeights) throw new Fe("restoreBestWeights = True is not implemented in EarlyStopping yet."); this.monitor = e.monitor || "val_loss", this.minDelta = Math.abs(e.minDelta || 0), this.patience = e.patience || 0, this.verbose = e.verbose || 0, this.mode = e.mode || "auto", this.baseline = e.baseline, ["auto", "min", "max"].indexOf(this.mode) === -1 && (console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`), this.mode = "auto"), this.mode === "min" ? this.monitorFunc = jc : this.mode === "max" ? this.monitorFunc = Gx : this.monitor.indexOf("acc") !== -1 ? this.monitorFunc = Gx : this.monitorFunc = jc, this.monitorFunc === jc && (this.minDelta *= -1); } @@ -16832,7 +16741,7 @@ var NW = class extends CW { function TW(e) { return new NW(e); } -var _pe = { earlyStopping: TW }; +var Ape = { earlyStopping: TW }; var $W = X(); $W.registerFlag("KEEP_INTERMEDIATE_TENSORS", () => false, (e) => { e && console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance."); @@ -16846,14 +16755,14 @@ var Hx; })(t = e.CheckpointFormatVersion || (e.CheckpointFormatVersion = {})); })(Hx || (Hx = {})); var Ky = {}; -function Ape(e, t) { +function Epe(e, t) { let n = { tfOpName: e, category: "custom", inputs: [], attrs: [], customExecutor: t }; Ky[e] = n; } function XS(e) { return Ky[e]; } -function Epe(e) { +function Rpe(e) { delete Ky[e]; } function I(e, t, n, s, r) { @@ -16919,7 +16828,7 @@ Ae(QS, { json: () => EW }); var EW = [{ tfOpName: "Abs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Acos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Asin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Atan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Atan2", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Ceil", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ClipByValue", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "clipValueMin", type: "number" }, { start: 2, name: "clipValueMax", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Complex", category: "basic_math", inputs: [{ start: 0, name: "real", type: "tensor" }, { start: 1, name: "imag", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "ComplexAbs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Cos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Cosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Elu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Exp", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Floor", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Log", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Imag", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: true }] }, { tfOpName: "Neg", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Real", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: true }] }, { tfOpName: "Prelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "alpha", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Relu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Relu6", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Selu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sigmoid", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Rsqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Square", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Tan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Tanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Sign", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Round", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Expm1", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Log1p", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Reciprocal", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Softplus", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Asinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Acosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Atanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Erf", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Prod", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axes", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool", notSupported: true }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "LeakyRelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "alpha", name: "alpha", type: "number", defaultValue: 0.2 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "IsNan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }]; var ZS = {}; Ae(ZS, { json: () => RW }); -var RW = [{ tfOpName: "EmptyTensorList", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "maxNumElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "LoopCond", category: "control", inputs: [{ start: 0, name: "pred", type: "tensor" }] }, { tfOpName: "Switch", category: "control", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "pred", type: "tensor" }] }, { tfOpName: "Merge", category: "control", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "Enter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "frame_name", name: "frameName", type: "string" }, { tfName: "is_constant", name: "isConstant", type: "bool" }] }, { tfOpName: "Exit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "NextIteration", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayV3", category: "control", inputs: [{ start: 0, name: "size", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "dynamic_size", name: "dynamicSize", type: "bool" }, { tfName: "clear_after_read", name: "clearAfterRead", type: "bool" }, { tfName: "identical_element_shapes", name: "identicalElementShapes", type: "bool" }, { tfName: "tensor_array_name", name: "name", type: "string" }] }, { tfOpName: "TensorArrayWriteV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayReadV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayGatherV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }] }, { tfOpName: "TensorArrayScatterV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArrayConcatV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape_except0", name: "elementShapeExcept0", type: "shape", notSupported: true }] }, { tfOpName: "TensorArraySplitV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }, { start: 2, name: "lengths", type: "number[]" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArraySizeV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }] }, { tfOpName: "TensorArrayCloseV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }] }, { tfOpName: "StatelessIf", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "If", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "StatelessWhile", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "While", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "TensorListScatter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListScatterV2", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }, { start: 3, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGather", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListSetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListReserve", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListFromTensor", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListStack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }, { tfName: "num_elements", name: "numElements", type: "dtype" }] }, { tfOpName: "TensorListSplit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }, { start: 2, name: "lengths", type: "number[]" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcat", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPopBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPushBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListLength", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }] }]; +var RW = [{ tfOpName: "EmptyTensorList", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "maxNumElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "LoopCond", category: "control", inputs: [{ start: 0, name: "pred", type: "tensor" }] }, { tfOpName: "Switch", category: "control", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "pred", type: "tensor" }] }, { tfOpName: "Merge", category: "control", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "Enter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "frame_name", name: "frameName", type: "string" }, { tfName: "is_constant", name: "isConstant", type: "bool" }] }, { tfOpName: "Exit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "NextIteration", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayV3", category: "control", inputs: [{ start: 0, name: "size", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "dynamic_size", name: "dynamicSize", type: "bool" }, { tfName: "clear_after_read", name: "clearAfterRead", type: "bool" }, { tfName: "identical_element_shapes", name: "identicalElementShapes", type: "bool" }, { tfName: "tensor_array_name", name: "name", type: "string" }] }, { tfOpName: "TensorArrayWriteV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayReadV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "TensorArrayGatherV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }] }, { tfOpName: "TensorArrayScatterV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArrayConcatV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape_except0", name: "elementShapeExcept0", type: "shape", notSupported: true }] }, { tfOpName: "TensorArraySplitV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }, { start: 2, name: "lengths", type: "number[]" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArraySizeV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }] }, { tfOpName: "TensorArrayCloseV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }] }, { tfOpName: "StatelessIf", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "If", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "StatelessWhile", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "While", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "TensorListScatter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListScatterV2", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }, { start: 3, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGather", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListSetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListReserve", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListFromTensor", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListStack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }, { tfName: "num_elements", name: "numElements", type: "dtype" }] }, { tfOpName: "TensorListSplit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }, { start: 2, name: "lengths", type: "number[]" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcat", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPopBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPushBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListLength", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }] }, { tfOpName: "TensorListResize", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "size", type: "number" }] }]; var JS = {}; Ae(JS, { json: () => DW }); var DW = [{ tfOpName: "AvgPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MaxPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [], notSupported: true }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MaxPoolWithArgmax", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "include_batch_in_index", name: "includeBatchInIndex", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "AvgPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "MaxPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }] }, { tfOpName: "Conv1D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "stride", name: "stride", type: "number" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NWC" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "dilation", name: "dilation", type: "number", defaultValue: 1 }] }, { tfOpName: "Conv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "useCudnnOnGpu", name: "useCudnnOnGpu", type: "bool" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "_FusedConv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "use_cudnn_on_gpu", name: "useCudnnOnGpu", type: "bool", defaultValue: true }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-4 }, { tfName: "leakyrelu_alpha", name: "leakyreluAlpha", type: "number" }] }, { tfOpName: "Conv2DBackpropInput", category: "convolution", inputs: [{ start: 2, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 0, name: "outputShape", type: "number[]" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: true }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]", notSupported: true }] }, { tfOpName: "DepthwiseConv2d", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "DepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "FusedDepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: true }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }] }, { tfOpName: "Conv3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "Dilation2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "rates", name: "dilations", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }] }]; @@ -17311,13 +17220,13 @@ var ZW = (e, t, n) => { case "Sinh": return [yI(I("x", e, t, n))]; case "Softplus": - return [Pl(I("x", e, t, n))]; + return [zl(I("x", e, t, n))]; case "Sqrt": return [dn(I("x", e, t, n))]; case "Square": return [ct(I("x", e, t, n))]; case "Tanh": - return [Hu(I("x", e, t, n))]; + return [qu(I("x", e, t, n))]; case "Tan": return [O3(I("x", e, t, n))]; case "ClipByValue": @@ -17350,7 +17259,7 @@ function Hn(e, t, n = "") { function Kx(e) { return !(typeof e == "number" || e.some((t) => t < 0)); } -function Cu(e, t, n) { +function Nu(e, t, n) { let s = Pm(e, n), r = !Kx(s); if (r && t.length === 0) throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${s}`); @@ -17488,7 +17397,7 @@ var JW = class { this.writeMany(i, a); } }; -var jl = class { +var eo = class { constructor(e, t, n, s = -1) { this.tensors = e, this.elementShape = t, this.elementDtype = n, e != null && e.forEach((r) => { if (n !== r.dtype) @@ -17500,7 +17409,7 @@ var jl = class { return this.idTensor.id; } copy() { - return new jl([...this.tensors], this.elementShape, this.elementDtype); + return new eo([...this.tensors], this.elementShape, this.elementDtype); } clearAndClose(e) { this.tensors.forEach((t) => { @@ -17516,7 +17425,7 @@ var jl = class { if (n !== -1 && this.tensors.length !== n) throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`); Hn(e, this.elementShape, "TensorList shape mismatch: "); - let s = Cu(this.elementShape, this.tensors, e); + let s = Nu(this.elementShape, this.tensors, e); return j(() => { let r = this.tensors.map((a) => G(a, s)); return Jn(r, 0); @@ -17527,7 +17436,7 @@ var jl = class { throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`); if (this.size() === 0) throw new Error("Trying to pop from an empty list."); - let n = Cu(this.elementShape, this.tensors, e), s = this.tensors.pop(); + let n = Nu(this.elementShape, this.tensors, e), s = this.tensors.pop(); return Hn(s.shape, e, "TensorList shape mismatch: "), G(s, n); } pushBack(e) { @@ -17542,7 +17451,11 @@ var jl = class { throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`); if (this.maxNumElements !== -1 && e > this.maxNumElements) throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`); - this.tensors.length = e; + let t = new eo([], this.elementShape, this.elementDtype, this.maxNumElements); + t.tensors.length = e; + for (let n = 0; n < Math.min(this.tensors.length, e); ++n) + t.tensors[n] = this.tensors[n]; + return t; } getItem(e, t, n) { if (n !== this.elementDtype) @@ -17552,7 +17465,7 @@ var jl = class { if (this.tensors[e] == null) throw new Error(`element at index ${e} is null.`); Hn(this.tensors[e].shape, t, "TensorList shape mismatch: "); - let s = Cu(this.elementShape, this.tensors, t); + let s = Nu(this.elementShape, this.tensors, t); return G(this.tensors[e], s); } setItem(e, t) { @@ -17566,7 +17479,7 @@ var jl = class { if (t !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`); Hn(this.elementShape, n, "TensorList shape mismatch: "), e = e.slice(0, this.size()); - let s = Cu(this.elementShape, this.tensors, n); + let s = Nu(this.elementShape, this.tensors, n); return e.length === 0 ? fs([], [0].concat(s)) : j(() => { let r = e.map((a) => G(this.tensors[a], s)); return Jn(r, 0); @@ -17576,7 +17489,7 @@ var jl = class { if (!!e && e !== this.elementDtype) throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`); Hn(this.elementShape, t, "TensorList shape mismatch: "); - let n = Cu(this.elementShape, this.tensors, t); + let n = Nu(this.elementShape, this.tensors, t); return this.size() === 0 ? fs([], [0].concat(n)) : j(() => { let s = this.tensors.map((r) => G(r, n)); return Ft(s, 0); @@ -17592,10 +17505,10 @@ function e4(e, t, n) { let r = e.shape.slice(1); Hn(r, t, "TensorList shape mismatch: "); let a = Fs(e); - return new jl(a, t, s); + return new eo(a, t, s); } function t4(e, t, n) { - return new jl([], e, t, n); + return new eo([], e, t, n); } function n4(e, t, n, s) { if (t.length !== e.shape[0]) @@ -17603,7 +17516,7 @@ function n4(e, t, n, s) { let r = Math.max(...t); if (s != null && s !== -1 && r >= s) throw new Error(`Max index must be < array size (${r} vs. ${s})`); - let a = new jl([], n, e.dtype, s), i = Fs(e, 0); + let a = new eo([], n, e.dtype, s), i = Fs(e, 0); return t.forEach((o, u) => { a.setItem(o, i[u]); }), a; @@ -17622,7 +17535,7 @@ function s4(e, t, n) { c[p] = G(He(e, h, f), i); } return e.dispose(), c; - }), l = new jl([], n, e.dtype, t.length); + }), l = new eo([], n, e.dtype, t.length); for (let c = 0; c < u.length; c++) l.setItem(c, u[c]); return l; @@ -17771,6 +17684,10 @@ var r4 = async (e, t, n) => { let s = I("tensorListId", e, t, n), r = n.getTensorList(s.id); return [we(r.size(), "int32")]; } + case "TensorListResize": { + let s = I("tensorListId", e, t, n), r = I("size", e, t, n), i = n.getTensorList(s.id).resize(r); + return n.addTensorList(i), [i.idTensor]; + } default: throw TypeError(`Node type ${e.op} is not implemented`); } @@ -17854,7 +17771,7 @@ var i4 = (e, t, n) => { switch (e.op) { case "Fill": { let s = I("shape", e, t, n), r = I("dtype", e, t, n), a = I("value", e, t, n); - return [Ol(s, a, r)]; + return [Pl(s, a, r)]; } case "LinSpace": { let s = I("start", e, t, n), r = I("stop", e, t, n), a = I("num", e, t, n); @@ -17873,10 +17790,10 @@ var i4 = (e, t, n) => { case "OnesLike": return [Qn(I("x", e, t, n))]; case "RandomUniform": - return [zl(I("shape", e, t, n), I("minval", e, t, n), I("maxval", e, t, n), I("dtype", e, t, n))]; + return [Ml(I("shape", e, t, n), I("minval", e, t, n), I("maxval", e, t, n), I("dtype", e, t, n))]; case "Range": { let s = I("start", e, t, n), r = I("stop", e, t, n), a = I("step", e, t, n); - return [Xu(s, r, a, I("dtype", e, t, n))]; + return [Yu(s, r, a, I("dtype", e, t, n))]; } case "TruncatedNormal": { let s = I("shape", e, t, n), r = I("mean", e, t, n), a = I("stdDev", e, t, n), i = I("seed", e, t, n); @@ -18082,15 +17999,15 @@ var h4 = (e, t, n) => { case "Equal": return [Kn(I("a", e, t, n), I("b", e, t, n))]; case "NotEqual": - return [Ku(I("a", e, t, n), I("b", e, t, n))]; + return [Xu(I("a", e, t, n), I("b", e, t, n))]; case "Greater": return [Wn(I("a", e, t, n), I("b", e, t, n))]; case "GreaterEqual": - return [jo(I("a", e, t, n), I("b", e, t, n))]; + return [Ko(I("a", e, t, n), I("b", e, t, n))]; case "Less": return [aI(I("a", e, t, n), I("b", e, t, n))]; case "LessEqual": - return [Ko(I("a", e, t, n), I("b", e, t, n))]; + return [Xo(I("a", e, t, n), I("b", e, t, n))]; case "LogicalAnd": return [Ds(I("a", e, t, n), I("b", e, t, n))]; case "LogicalNot": @@ -18132,9 +18049,9 @@ var m4 = (e, t, n) => { switch (e.op) { case "FusedBatchNorm": case "FusedBatchNormV2": - return [qu(I("x", e, t, n), I("mean", e, t, n), I("variance", e, t, n), I("offset", e, t, n), I("scale", e, t, n), I("epsilon", e, t, n))]; + return [ju(I("x", e, t, n), I("mean", e, t, n), I("variance", e, t, n), I("offset", e, t, n), I("scale", e, t, n), I("epsilon", e, t, n))]; case "FusedBatchNormV3": - return [qu(I("x", e, t, n), I("mean", e, t, n), I("variance", e, t, n), I("offset", e, t, n), I("scale", e, t, n), I("epsilon", e, t, n))]; + return [ju(I("x", e, t, n), I("mean", e, t, n), I("variance", e, t, n), I("offset", e, t, n), I("scale", e, t, n), I("epsilon", e, t, n))]; case "LRN": return [qR(I("x", e, t, n), I("radius", e, t, n), I("bias", e, t, n), I("alpha", e, t, n), I("beta", e, t, n))]; case "Softmax": @@ -18175,7 +18092,7 @@ var g4 = (e, t, n) => { } case "ArgMax": { let i = I("axis", e, t, n); - return [Gu(I("x", e, t, n), i)]; + return [Hu(I("x", e, t, n), i)]; } case "ArgMin": { let i = I("axis", e, t, n); @@ -18213,11 +18130,11 @@ var b4 = (e, t, n) => { } case "Gather": { let s = I("x", e, t, n), r = I("indices", e, t, n); - return [ju(s, ce(r, "int32"), 0)]; + return [Ku(s, ce(r, "int32"), 0)]; } case "GatherV2": { let s = I("axis", e, t, n), r = I("batchDims", e, t, n), a = I("x", e, t, n), i = I("indices", e, t, n); - return [ju(a, ce(i, "int32"), s, r)]; + return [Ku(a, ce(i, "int32"), s, r)]; } case "Reverse": { let s = I("dims", e, t, n), r = []; @@ -18896,16 +18813,16 @@ var E4 = class { this.executor.dispose(), this.initializer && this.initializer.dispose(), this.resourceManager.dispose(); } }; -async function Rpe(e, t = {}) { +async function Dpe(e, t = {}) { if (e == null) throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model"); t == null && (t = {}), t.fromTFHub && e.load == null && (e.endsWith("/") || (e = e + "/"), e = `${e}${A4}${_4}`); let n = new E4(e, t); return await n.load(), n; } -var Dpe = "0.0.0"; +var Fpe = "0.0.0"; var R4 = {}; -Ae(R4, { CSVDataset: () => _0, Dataset: () => Zo, FileDataSource: () => P0, TextLineDataset: () => $0, URLDataSource: () => z0, array: () => tU, csv: () => pU, func: () => hU, generator: () => fU, microphone: () => gU, version_data: () => bU, webcam: () => mU, zip: () => nU }); +Ae(R4, { CSVDataset: () => _0, Dataset: () => Jo, FileDataSource: () => P0, TextLineDataset: () => $0, URLDataSource: () => z0, array: () => tU, csv: () => pU, func: () => hU, generator: () => fU, microphone: () => gU, version_data: () => bU, webcam: () => mU, zip: () => nU }); var D4 = xa(Wd()); var F4 = xa(Wd()); function O4(e, t) { @@ -18924,7 +18841,7 @@ function Rd(e, t, n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set()) if (r.recurse && r.value !== null) throw new Error("A deep map function may not return both a value and recurse=true."); if (r.recurse) - if (eo(e)) { + if (to(e)) { let a = Array.isArray(e) ? [] : {}; s.add(e); for (let i in e) { @@ -18948,7 +18865,7 @@ function y0(e, t, n = /* @__PURE__ */ new Set()) { if (r.recurse && r.value !== null) throw new Error("A deep zip function may not return both a value and recurse=true."); if (r.recurse) - if (eo(s)) { + if (to(s)) { let a = Array.isArray(s) ? [] : {}; n.add(s); for (let i in s) { @@ -18962,7 +18879,7 @@ function y0(e, t, n = /* @__PURE__ */ new Set()) { return r.value; } function v0(e) { - return e === null ? null : eo(e[0]) ? { value: null, recurse: true } : { value: e, recurse: false }; + return e === null ? null : to(e[0]) ? { value: null, recurse: true } : { value: e, recurse: false }; } async function x0(e, t) { let n = /* @__PURE__ */ new Map(); @@ -18976,7 +18893,7 @@ async function x0(e, t) { } return Rd(e, t, n); } -function eo(e) { +function to(e) { let t = false; if (X().get("IS_BROWSER")) t = e instanceof TextDecoder; @@ -18996,7 +18913,7 @@ function L4(e) { return O4(e, B4); } function B4(e) { - return e instanceof et ? { value: e.clone(), recurse: false } : eo(e) ? { value: null, recurse: true } : { value: e, recurse: false }; + return e instanceof et ? { value: e.clone(), recurse: false } : to(e) ? { value: null, recurse: true } : { value: e, recurse: false }; } var w0 = class { constructor(e) { @@ -19173,8 +19090,7 @@ var Ut = class { }; var U4 = class extends Ut { constructor(e) { - super(); - this.items = e, this.trav = 0; + super(), this.items = e, this.trav = 0; } summary() { return `Array of ${this.items.length} items`; @@ -19188,8 +19104,7 @@ var U4 = class extends Ut { }; var G4 = class extends Ut { constructor(e) { - super(); - this.nextFn = e; + super(), this.nextFn = e; } summary() { return "Function call"; @@ -19204,8 +19119,7 @@ var G4 = class extends Ut { }; var H4 = class extends Ut { constructor(e) { - super(); - this.upstream = e, this.lastRead = Promise.resolve({ value: null, done: false }); + super(), this.upstream = e, this.lastRead = Promise.resolve({ value: null, done: false }); } summary() { return `${this.upstream.summary()} -> Serial`; @@ -19219,8 +19133,7 @@ var H4 = class extends Ut { }; var q4 = class extends Ut { constructor(e, t) { - super(); - this.upstream = e, this.maxCount = t, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: false }); + super(), this.upstream = e, this.maxCount = t, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: false }); } summary() { return `${this.upstream.summary()} -> Skip`; @@ -19240,8 +19153,7 @@ var q4 = class extends Ut { }; var j4 = class extends Ut { constructor(e, t) { - super(); - this.upstream = e, this.maxCount = t, this.count = 0; + super(), this.upstream = e, this.maxCount = t, this.count = 0; } summary() { return `${this.upstream.summary()} -> Take`; @@ -19252,8 +19164,7 @@ var j4 = class extends Ut { }; var K4 = class extends Ut { constructor(e, t, n = true) { - super(); - this.upstream = e, this.batchSize = t, this.enableSmallLastBatch = n, this.lastRead = Promise.resolve({ value: null, done: false }); + super(), this.upstream = e, this.batchSize = t, this.enableSmallLastBatch = n, this.lastRead = Promise.resolve({ value: null, done: false }); } summary() { return `${this.upstream.summary()} -> RowMajorBatch`; @@ -19274,8 +19185,7 @@ var K4 = class extends Ut { }; var X4 = class extends Ut { constructor(e, t) { - super(); - this.upstream = e, this.predicate = t, this.lastRead = Promise.resolve({ value: null, done: false }); + super(), this.upstream = e, this.predicate = t, this.lastRead = Promise.resolve({ value: null, done: false }); } summary() { return `${this.upstream.summary()} -> Filter`; @@ -19294,8 +19204,7 @@ var X4 = class extends Ut { }; var Y4 = class extends Ut { constructor(e, t) { - super(); - this.upstream = e, this.transform = t; + super(), this.upstream = e, this.transform = t; } summary() { return `${this.upstream.summary()} -> Map`; @@ -19312,8 +19221,7 @@ var Y4 = class extends Ut { }; var Q4 = class extends Ut { constructor(e, t) { - super(); - this.upstream = e, this.handler = t, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: false }); + super(), this.upstream = e, this.handler = t, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: false }); } summary() { return `${this.upstream.summary()} -> handleErrors`; @@ -19333,8 +19241,7 @@ var Q4 = class extends Ut { }; var Jx = class extends Ut { constructor(e, t) { - super(); - this.upstream = e, this.transform = t; + super(), this.upstream = e, this.transform = t; } summary() { return `${this.upstream.summary()} -> AsyncMap`; @@ -19351,8 +19258,7 @@ var Jx = class extends Ut { }; var Qy = class extends Ut { constructor() { - super(); - this.outputQueue = new I0(), this.lastRead = Promise.resolve({ value: null, done: false }); + super(), this.outputQueue = new I0(), this.lastRead = Promise.resolve({ value: null, done: false }); } async next() { return this.lastRead = this.lastRead.then(() => this.serialNext()), this.lastRead; @@ -19366,8 +19272,7 @@ var Qy = class extends Ut { }; var Z4 = class extends Qy { constructor(e, t) { - super(); - this.upstream = e, this.transform = t; + super(), this.upstream = e, this.transform = t; } summary() { return `${this.upstream.summary()} -> Flatmap`; @@ -19385,8 +19290,7 @@ var Z4 = class extends Qy { }; var C0 = class extends Ut { constructor(e, t) { - super(); - this.baseErrorHandler = t, this.lastRead = null, this.iterator = null, this.moreIterators = e; + super(), this.baseErrorHandler = t, this.lastRead = null, this.iterator = null, this.moreIterators = e; } summary() { return "TODO: fill in upstream of chained summaries -> Chained"; @@ -19408,8 +19312,7 @@ var C0 = class extends Ut { var N0 = ((e) => (e[e.FAIL = 0] = "FAIL", e[e.SHORTEST = 1] = "SHORTEST", e[e.LONGEST = 2] = "LONGEST", e))(N0 || {}); var J4 = class extends Ut { constructor(e, t = 0) { - super(); - this.iterators = e, this.mismatchMode = t, this.count = 0, this.currentPromise = null; + super(), this.iterators = e, this.mismatchMode = t, this.count = 0, this.currentPromise = null; } summary() { return "{TODO: fill in upstream of zip summaries} -> Zip"; @@ -19440,8 +19343,7 @@ var J4 = class extends Ut { }; var T0 = class extends Ut { constructor(e, t) { - super(); - this.upstream = e, this.bufferSize = t, this.buffer = new w0(t); + super(), this.upstream = e, this.bufferSize = t, this.buffer = new w0(t); } summary() { return `${this.upstream.summary()} -> Prefetch`; @@ -19458,8 +19360,7 @@ var T0 = class extends Ut { }; var eU = class extends T0 { constructor(e, t, n) { - super(e, t); - this.upstream = e, this.windowSize = t, this.upstreamExhausted = false, this.random = F4.alea(n || w.now().toString()), this.lastRead = Promise.resolve({ value: null, done: false }); + super(e, t), this.upstream = e, this.windowSize = t, this.upstreamExhausted = false, this.random = F4.alea(n || w.now().toString()), this.lastRead = Promise.resolve({ value: null, done: false }); } async next() { return this.lastRead = this.lastRead.then(() => this.serialNext()), this.lastRead; @@ -19481,7 +19382,7 @@ var eU = class extends T0 { return { value: null, done: true }; } }; -var Zo = class { +var Jo = class { constructor() { this.size = null; } @@ -19552,12 +19453,11 @@ var Zo = class { return (await this.iterator()).toArrayForTest(); } }; -Zo.MAX_BUFFER_SIZE = 1e4; +Jo.MAX_BUFFER_SIZE = 1e4; function _n(e, t = null) { - return new class extends Zo { + return new class extends Jo { constructor() { - super(...arguments); - this.size = t; + super(...arguments), this.size = t; } async iterator() { return e(); @@ -19568,7 +19468,7 @@ function tU(e) { return _n(async () => S0(e), e.length); } function nU(e) { - if (!eo(e)) + if (!to(e)) throw new Error("The argument to zip() must be an object or array."); let t; if (Array.isArray(e)) @@ -19579,9 +19479,9 @@ function nU(e) { t = t == null ? e[n].size : Math.min(t, e[n].size); return _n(async () => { let n = await x0(e, (s) => { - if (s instanceof Zo) + if (s instanceof Jo) return { value: s.iterator(), recurse: false }; - if (eo(s)) + if (to(s)) return { value: null, recurse: true }; throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives."); }); @@ -19599,10 +19499,9 @@ function rU(e) { throw new Error("Can't make a batch of zero elements."); return e[0] instanceof et ? Jn(e) : fs(e); } -var $0 = class extends Zo { +var $0 = class extends Jo { constructor(e) { - super(); - this.input = e; + super(), this.input = e; } async iterator() { return (await this.input.iterator()).decodeUTF8().split(` @@ -19610,15 +19509,14 @@ var $0 = class extends Zo { } }; var Kc = '"'; -var Nu = Symbol("out"); +var Tu = Symbol("out"); var ew = Symbol("field"); var Xc = Symbol("quote"); var qf = Symbol("quoteafterquote"); var tw = Symbol("quoteinquote"); -var _0 = class extends Zo { +var _0 = class extends Jo { constructor(e, t) { - super(); - this.input = e, this.hasHeader = true, this.fullColumnNames = null, this.columnNamesValidated = false, this.columnConfigs = null, this.configuredColumnsOnly = false, this.delimiter = ",", this.delimWhitespace = false, this.base = new $0(e), t || (t = {}), this.hasHeader = t.hasHeader !== false, this.fullColumnNames = t.columnNames, this.columnConfigs = t.columnConfigs, this.configuredColumnsOnly = t.configuredColumnsOnly, t.delimWhitespace ? (w.assert(t.delimiter == null, () => "Delimiter should not be provided when delimWhitespace is true."), this.delimWhitespace = true, this.delimiter = " ") : this.delimiter = t.delimiter ? t.delimiter : ","; + super(), this.input = e, this.hasHeader = true, this.fullColumnNames = null, this.columnNamesValidated = false, this.columnConfigs = null, this.configuredColumnsOnly = false, this.delimiter = ",", this.delimWhitespace = false, this.base = new $0(e), t || (t = {}), this.hasHeader = t.hasHeader !== false, this.fullColumnNames = t.columnNames, this.columnConfigs = t.columnConfigs, this.configuredColumnsOnly = t.configuredColumnsOnly, t.delimWhitespace ? (w.assert(t.delimiter == null, () => "Delimiter should not be provided when delimWhitespace is true."), this.delimWhitespace = true, this.delimiter = " ") : this.delimiter = t.delimiter ? t.delimiter : ","; } async columnNames() { return this.columnNamesValidated || await this.setColumnNames(), this.configuredColumnsOnly ? Object.keys(this.columnConfigs) : this.fullColumnNames; @@ -19695,10 +19593,10 @@ var _0 = class extends Zo { return e === "1" || e.toLowerCase() === "true" ? 1 : 0; } parseRow(e, t = true) { - let n = [], s = 0, r = e.length, a = Nu; + let n = [], s = 0, r = e.length, a = Tu; for (let i = 0; i < r; i++) switch (a) { - case Nu: + case Tu: switch (e.charAt(i)) { case Kc: s = i + 1, a = Xc; @@ -19706,7 +19604,7 @@ var _0 = class extends Zo { case this.delimiter: if (s = i + 1, this.delimiter === " " && this.delimWhitespace) break; - n.push(""), a = Nu; + n.push(""), a = Tu; break; default: a = ew, s = i; @@ -19716,7 +19614,7 @@ var _0 = class extends Zo { case ew: switch (e.charAt(i)) { case this.delimiter: - n.push(e.substring(s, i)), a = Nu, s = i + 1; + n.push(e.substring(s, i)), a = Tu, s = i + 1; break; default: } @@ -19732,7 +19630,7 @@ var _0 = class extends Zo { case qf: switch (e.charAt(i)) { case this.delimiter: - n.push(e.substring(s, i - 1)), a = Nu, s = i + 1; + n.push(e.substring(s, i - 1)), a = Tu, s = i + 1; break; case Kc: a = Xc; @@ -19759,8 +19657,7 @@ var _0 = class extends Zo { }; var A0 = class extends Ut { constructor(e) { - super(); - this.microphoneConfig = e, this.isClosed = false, this.fftSize = e.fftSize || 1024; + super(), this.microphoneConfig = e, this.isClosed = false, this.fftSize = e.fftSize || 1024; let t = Math.log2(this.fftSize); if (this.fftSize < 0 || t < 4 || t > 14 || !Number.isInteger(t)) throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`); @@ -19837,8 +19734,7 @@ var A0 = class extends Ut { }; var E0 = class extends Ut { constructor(e, t) { - super(); - if (this.webcamVideoElement = e, this.webcamConfig = t, this.isClosed = true, this.resize = false, this.needToResize()) + if (super(), this.webcamVideoElement = e, this.webcamConfig = t, this.isClosed = true, this.resize = false, this.needToResize()) if (this.resize = true, this.cropSize = [this.webcamConfig.resizeHeight, this.webcamConfig.resizeWidth], this.cropBoxInd = Zt([0], "int32"), this.webcamConfig.centerCrop) { let n = this.webcamConfig.resizeWidth * 1 / this.webcamVideoElement.width, s = this.webcamConfig.resizeHeight * 1 / this.webcamVideoElement.height, r = (1 - n) / 2, a = (1 - s) / 2, i = r + n, o = s + a; this.cropBox = Ki([a, r, o, i], [1, 4]); @@ -19935,8 +19831,7 @@ var D0 = class extends Ut { }; var aU = class extends D0 { constructor(e, t) { - super(); - this.upstream = e, this.impl = new iU(e, t); + super(), this.upstream = e, this.impl = new iU(e, t); } summary() { return this.impl.summary(); @@ -19947,8 +19842,7 @@ var aU = class extends D0 { }; var iU = class extends Qy { constructor(e, t) { - super(); - this.upstream = e, this.separator = t, this.carryover = ""; + super(), this.upstream = e, this.separator = t, this.carryover = ""; } summary() { return `${this.upstream.summary()} -> Split('${this.separator}')`; @@ -19971,8 +19865,7 @@ var oU = class extends Ut { }; var uU = class extends D0 { constructor(e) { - super(); - this.upstream = e, this.impl = new lU(e); + super(), this.upstream = e, this.impl = new lU(e); } summary() { return this.impl.summary(); @@ -19983,8 +19876,7 @@ var uU = class extends D0 { }; var lU = class extends Qy { constructor(e) { - super(); - if (this.upstream = e, X().get("IS_BROWSER")) + if (super(), this.upstream = e, X().get("IS_BROWSER")) this.decoder = new TextDecoder("utf-8"); else { let { StringDecoder: t } = Ww(); @@ -20005,8 +19897,7 @@ var lU = class extends Qy { }; var F0 = class extends oU { constructor(e, t = {}) { - super(); - this.file = e, this.options = t, w.assert(e instanceof Uint8Array || (X().get("IS_BROWSER") ? e instanceof File || e instanceof Blob : false), () => "FileChunkIterator only supports File, Blob and Uint8Array right now."), this.offset = t.offset || 0, this.chunkSize = t.chunkSize || 1024 * 1024; + super(), this.file = e, this.options = t, w.assert(e instanceof Uint8Array || (X().get("IS_BROWSER") ? e instanceof File || e instanceof Blob : false), () => "FileChunkIterator only supports File, Blob and Uint8Array right now."), this.offset = t.offset || 0, this.chunkSize = t.chunkSize || 1024 * 1024; } summary() { return `FileChunks ${this.file}`; @@ -20047,8 +19938,7 @@ function O0(e) { } var P0 = class extends R0 { constructor(e, t = {}) { - super(); - this.input = e, this.options = t; + super(), this.input = e, this.options = t; } async iterator() { if (O0(this.input) && X().get("IS_NODE")) { @@ -20060,8 +19950,7 @@ var P0 = class extends R0 { }; var z0 = class extends R0 { constructor(e, t = {}) { - super(); - this.url = e, this.fileOptions = t; + super(), this.url = e, this.fileOptions = t; } async iterator() { return O0(this.url) ? new P0(this.url, this.fileOptions).iterator() : cU(this.url, this.fileOptions); @@ -20093,10 +19982,9 @@ function be(e, t) { }); } var yU = xs.whereImpl; -var M0 = class extends tl { +var M0 = class extends nl { constructor() { - super(); - this.blockSize = 48, this.firstUse = true, this.data = new Ud(this, Ss()); + super(), this.blockSize = 48, this.firstUse = true, this.data = new Ud(this, Ss()); } nextDataId() { return M0.nextDataId++; @@ -20211,7 +20099,7 @@ var vU = (e) => { let s = new Float32Array(w.sizeFromShape(t.shape)), r = n.data.get(t.dataId).values; return s = B0(r), n.makeOutput(s, t.shape, t.dtype); }; -var xU = { kernelName: ao, backendName: "cpu", kernelFunc: vU }; +var xU = { kernelName: io, backendName: "cpu", kernelFunc: vU }; function At(e) { return (t, n, s, r, a) => { let i = S.assertAndGetBroadcastShape(t, n), o = i.length, u = w.computeStrides(i), l = w.sizeFromShape(i), c = w.getTypedArrayFromDType(a, l), p = t.length, d = n.length, h = w.computeStrides(t), f = w.computeStrides(n), m = S.getBroadcastDims(t, i), g = S.getBroadcastDims(n, i); @@ -20361,7 +20249,7 @@ function st(e, t, n) { return o.makeTensorInfo(i.shape, c, p); }; } -function Jo(e, t, n) { +function eu(e, t, n) { return ({ inputs: s, attrs: r, backend: a }) => { let { x: i } = s; if (be(i, e), i.dtype === "string" || n === "string") @@ -20371,7 +20259,7 @@ function Jo(e, t, n) { }; } var U0 = Er((e) => Math.ceil(e)); -var TU = Jo(Ta, U0); +var TU = eu(Ta, U0); var $U = { kernelName: Ta, backendName: "cpu", kernelFunc: TU }; function tv(e, t, n, s) { let r = w.getArrayFromDType(n, w.sizeFromShape(t)); @@ -20396,16 +20284,16 @@ function tv(e, t, n, s) { return r; } var G0 = At((e, t) => e === t ? 1 : 0); -var H0 = Gt(po, G0, null, "bool"); -var _U = { kernelName: po, backendName: "cpu", kernelFunc: H0 }; +var H0 = Gt(ho, G0, null, "bool"); +var _U = { kernelName: ho, backendName: "cpu", kernelFunc: H0 }; var q0 = Er((e) => Math.exp(e)); -var j0 = Jo(Oa, q0, "float32"); +var j0 = eu(Oa, q0, "float32"); var AU = { kernelName: Oa, backendName: "cpu", kernelFunc: j0 }; var K0 = Er((e) => Math.expm1(e)); -var EU = Jo(fo, K0); -var RU = { kernelName: fo, backendName: "cpu", kernelFunc: EU }; +var EU = eu(mo, K0); +var RU = { kernelName: mo, backendName: "cpu", kernelFunc: EU }; var X0 = Er((e) => Math.floor(e)); -var DU = Jo(Pa, X0); +var DU = eu(Pa, X0); var FU = { kernelName: Pa, backendName: "cpu", kernelFunc: DU }; function Y0(e, t, n, s, r, a, i, o, u) { let l = De([s, a], n); @@ -20433,17 +20321,17 @@ function Q0(e, t, n) { return s; } var Z0 = At((e, t) => e > t ? 1 : 0); -var OU = Gt(yo, Z0, null, "bool"); -var PU = { kernelName: yo, backendName: "cpu", kernelFunc: OU }; +var OU = Gt(vo, Z0, null, "bool"); +var PU = { kernelName: vo, backendName: "cpu", kernelFunc: OU }; var J0 = At((e, t) => e >= t ? 1 : 0); var zU = Gt(La, J0, null, "bool"); var MU = { kernelName: La, backendName: "cpu", kernelFunc: zU }; var eC = At((e, t) => e < t ? 1 : 0); -var LU = Gt(vo, eC, null, "bool"); -var BU = { kernelName: vo, backendName: "cpu", kernelFunc: LU }; +var LU = Gt(xo, eC, null, "bool"); +var BU = { kernelName: xo, backendName: "cpu", kernelFunc: LU }; var tC = At((e, t) => e <= t ? 1 : 0); -var VU = Gt(xo, tC, null, "bool"); -var WU = { kernelName: xo, backendName: "cpu", kernelFunc: VU }; +var VU = Gt(wo, tC, null, "bool"); +var WU = { kernelName: wo, backendName: "cpu", kernelFunc: VU }; function nC(e, t, n) { let s = (t - e) / (n - 1), r = w.makeZerosTypedArray(n, "float32"); r[0] = e; @@ -20452,7 +20340,7 @@ function nC(e, t, n) { return r; } var sC = Er((e) => Math.log(e)); -var UU = Jo(Wa, sC); +var UU = eu(Wa, sC); var GU = { kernelName: Wa, backendName: "cpu", kernelFunc: UU }; function rC(e, t, n, s) { let r = w.getTypedArrayFromDType(s, w.sizeFromShape(n)); @@ -20486,10 +20374,10 @@ function QU(e) { let r = n.data.get(s.dataId).values, [a, i] = oC(r, s.shape, s.dtype); return n.makeTensorInfo(i, s.dtype, a); } -var ZU = { kernelName: ko, backendName: "cpu", kernelFunc: QU }; +var ZU = { kernelName: Io, backendName: "cpu", kernelFunc: QU }; var uC = At((e, t) => e !== t ? 1 : 0); -var JU = Gt(Io, uC, null, "bool"); -var eG = { kernelName: Io, backendName: "cpu", kernelFunc: JU }; +var JU = Gt(So, uC, null, "bool"); +var eG = { kernelName: So, backendName: "cpu", kernelFunc: JU }; function sv(e, t, n, s, r) { let a = t.length, i = w.sizeFromShape(t), o = w.computeStrides(t), u = w.computeStrides(r), l = w.getTypedArrayFromDType(n, w.sizeFromShape(r)); for (let c = 0; c < i; ++c) { @@ -20529,7 +20417,7 @@ function nG(e) { let h = n.data.get(p.dataId).values, { outVals: f, outShape: m, outDtype: g } = lC(p.shape, p.dtype, h, c), b = m; return i && (b = S.expandShapeToKeepDim(m, u)), d.forEach((y) => n.disposeIntermediateTensorInfo(y)), n.makeTensorInfo(b, g, f); } -var sG = { kernelName: _o, backendName: "cpu", kernelFunc: nG }; +var sG = { kernelName: Ao, backendName: "cpu", kernelFunc: nG }; function rv(e, t, n, s) { let r = e === t, a = e < t && n < 0, i = t < e && n > 1; if (r || a || i) @@ -20541,7 +20429,7 @@ function rv(e, t, n, s) { return u; } var cC = Er((e) => 1 / Math.sqrt(e)); -var rG = Jo(si, cC); +var rG = eu(si, cC); var aG = { kernelName: si, backendName: "cpu", kernelFunc: rG }; var iG = Er((e) => 1 / (1 + Math.exp(-e))); var dC = st(ai, (e) => 1 / (1 + Math.exp(-e))); @@ -20567,7 +20455,7 @@ function ga(e) { let l = n.data.get(r.dataId).values, c = Fd(l, o, u, r.shape, r.dtype); return n.makeTensorInfo(u, r.dtype, c); } -var uG = { kernelName: Oo, backendName: "cpu", kernelFunc: ga }; +var uG = { kernelName: Po, backendName: "cpu", kernelFunc: ga }; function pC(e, t, n, s, r, a, i) { let o = t[0], u = a[0], l = new Array(u), c = new Array(o), p = t[1]; if (u === 0) { @@ -20865,7 +20753,7 @@ function xC(e, t) { } return s; } -var Eu = (e, t) => { +var Ru = (e, t) => { let n = t.value - e.value; return n === 0 ? e.index - t.index : n; }; @@ -20876,20 +20764,20 @@ function wC(e, t, n = 0, s = e.length - 1) { wC(e, t, d, h); } let r = e[t], a = n, i = s; - for (w.swap(e, n, t), Eu(e[s], r) > 0 && w.swap(e, n, s); a < i; ) { - for (w.swap(e, a, i), a++, i--; Eu(e[a], r) < 0; ) + for (w.swap(e, n, t), Ru(e[s], r) > 0 && w.swap(e, n, s); a < i; ) { + for (w.swap(e, a, i), a++, i--; Ru(e[a], r) < 0; ) a = a + 1; - for (; Eu(e[i], r) > 0; ) + for (; Ru(e[i], r) > 0; ) i = i - 1; } - Eu(e[n], r) === 0 ? w.swap(e, n, i) : (i = i + 1, w.swap(e, i, s)), i <= t && (n = i + 1), t <= i && (s = i - 1); + Ru(e[n], r) === 0 ? w.swap(e, n, i) : (i = i + 1, w.swap(e, i, s)), i <= t && (n = i + 1), t <= i && (s = i - 1); } } function kC(e, t, n, s, r) { let a = t[t.length - 1], [i, o] = [e.length / a, a], u = w.getTypedArrayFromDType(n, i * s), l = w.getTypedArrayFromDType("int32", i * s); for (let p = 0; p < i; p++) { let d = p * o, h = e.subarray(d, d + o), f = new Array(h.length); - h.forEach((y, v) => f[v] = { value: y, index: v }), s < f.length && (wC(f, s), f = f.slice(0, s)), r && f.sort(Eu); + h.forEach((y, v) => f[v] = { value: y, index: v }), s < f.length && (wC(f, s), f = f.slice(0, s)), r && f.sort(Ru); let m = p * s, g = u.subarray(m, m + s), b = l.subarray(m, m + s); for (let y = 0; y < s; y++) g[y] = f[y].value, b[y] = f[y].index; @@ -20934,7 +20822,7 @@ function IC(e, t, n, s) { let h = n.slice(); return h[r] = p[1], { outputValues: d.values, outputShape: h, indices: o }; } -var Fpe = "0.0.0"; +var Ope = "0.0.0"; pp("cpu", () => new L0(), 1); var SC = st(Fa, (e) => e >= 0 ? e : Math.exp(e) - 1); var yG = { kernelName: Fa, backendName: "cpu", kernelFunc: SC }; @@ -20986,11 +20874,11 @@ function mt(e) { } return { dataId: r.dataId, shape: o, dtype: r.dtype }; } -var SG = { kernelName: Ao, backendName: "cpu", kernelFunc: mt }; +var SG = { kernelName: Eo, backendName: "cpu", kernelFunc: mt }; function _C(e) { let { inputs: t, backend: n, attrs: s } = e, { a: r, b: a } = t, { transposeA: i, transposeB: o } = s; be([r, a], "matMul"); - let u = r.shape.length, l = a.shape.length, c = i ? r.shape[u - 2] : r.shape[u - 1], p = o ? a.shape[l - 1] : a.shape[l - 2], d = i ? r.shape[u - 1] : r.shape[u - 2], h = o ? a.shape[l - 2] : a.shape[l - 1], f = r.shape.slice(0, -2), m = a.shape.slice(0, -2), g = w.sizeFromShape(f), b = w.sizeFromShape(m), v = qo.assertAndGetBroadcastShape(r.shape.slice(0, -2), a.shape.slice(0, -2)).concat([d, h]); + let u = r.shape.length, l = a.shape.length, c = i ? r.shape[u - 2] : r.shape[u - 1], p = o ? a.shape[l - 1] : a.shape[l - 2], d = i ? r.shape[u - 1] : r.shape[u - 2], h = o ? a.shape[l - 2] : a.shape[l - 1], f = r.shape.slice(0, -2), m = a.shape.slice(0, -2), g = w.sizeFromShape(f), b = w.sizeFromShape(m), v = jo.assertAndGetBroadcastShape(r.shape.slice(0, -2), a.shape.slice(0, -2)).concat([d, h]); w.assert(c === p, () => `Error in matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${r.shape} and ${a.shape} and transposeA=${i} and transposeB=${o} must match.`); let x = i ? [g, c, d] : [g, d, c], k = o ? [b, h, p] : [b, p, h], T = mt({ inputs: { x: r }, backend: n, attrs: { shape: x } }), N = mt({ inputs: { x: a }, backend: n, attrs: { shape: k } }), E = i ? T.shape[1] : T.shape[2], A = i ? T.shape[2] : T.shape[1], P = o ? N.shape[1] : N.shape[2], R = Math.max(g, b), F = n.data.get(T.dataId).values, $ = n.data.get(N.dataId).values, z = w.computeStrides(T.shape), W = w.computeStrides(N.shape), [q, K, Y] = i ? [z[0], 1, z[1]] : [z[0], z[1], 1], [Z, te, ee] = o ? [1, W[1], W[0]] : [W[1], 1, W[0]], se = A * P, ne = De([R, A, P], T.dtype), oe = ne.values, re = n.blockSize; for (let le = 0; le < R; le++) @@ -21019,10 +20907,10 @@ function NG(e) { return d; } var TG = { kernelName: ra, backendName: "cpu", kernelFunc: NG }; -var $G = st(nl, (e) => Math.acos(e)); -var _G = { kernelName: nl, backendName: "cpu", kernelFunc: $G }; -var AG = st(sl, (e) => Math.acosh(e)); -var EG = { kernelName: sl, backendName: "cpu", kernelFunc: AG }; +var $G = st(sl, (e) => Math.acos(e)); +var _G = { kernelName: sl, backendName: "cpu", kernelFunc: $G }; +var AG = st(rl, (e) => Math.acosh(e)); +var EG = { kernelName: rl, backendName: "cpu", kernelFunc: AG }; function RG(e) { let { inputs: t, backend: n } = e, s = t; be(t, "addN"); @@ -21057,7 +20945,7 @@ function FG(e) { } return g; } -var OG = { kernelName: rl, backendName: "cpu", kernelFunc: FG }; +var OG = { kernelName: al, backendName: "cpu", kernelFunc: FG }; function PG(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a, keepDims: i } = s; be(r, "any"); @@ -21080,7 +20968,7 @@ function PG(e) { } return g; } -var zG = { kernelName: al, backendName: "cpu", kernelFunc: PG }; +var zG = { kernelName: il, backendName: "cpu", kernelFunc: PG }; function MG(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a } = s; be(r, "argMax"); @@ -21114,18 +21002,18 @@ function BG(e) { } return l.forEach((g) => n.disposeIntermediateTensorInfo(g)), n.makeTensorInfo(c, "int32", h); } -var VG = { kernelName: il, backendName: "cpu", kernelFunc: BG }; -var WG = st(ol, (e) => Math.asin(e)); -var UG = { kernelName: ol, backendName: "cpu", kernelFunc: WG }; -var GG = st(ul, (e) => Math.asinh(e)); -var HG = { kernelName: ul, backendName: "cpu", kernelFunc: GG }; -var qG = st(ll, (e) => Math.atan(e)); -var jG = { kernelName: ll, backendName: "cpu", kernelFunc: qG }; +var VG = { kernelName: ol, backendName: "cpu", kernelFunc: BG }; +var WG = st(ul, (e) => Math.asin(e)); +var UG = { kernelName: ul, backendName: "cpu", kernelFunc: WG }; +var GG = st(ll, (e) => Math.asinh(e)); +var HG = { kernelName: ll, backendName: "cpu", kernelFunc: GG }; +var qG = st(cl, (e) => Math.atan(e)); +var jG = { kernelName: cl, backendName: "cpu", kernelFunc: qG }; var KG = At((e, t) => Math.atan2(e, t)); -var XG = Gt(dl, KG); -var YG = { kernelName: dl, backendName: "cpu", kernelFunc: XG }; -var QG = st(cl, (e) => Math.atanh(e)); -var ZG = { kernelName: cl, backendName: "cpu", kernelFunc: QG }; +var XG = Gt(pl, KG); +var YG = { kernelName: pl, backendName: "cpu", kernelFunc: XG }; +var QG = st(dl, (e) => Math.atanh(e)); +var ZG = { kernelName: dl, backendName: "cpu", kernelFunc: QG }; function uv(e, t, n, s, r, a) { let i = r.strideHeight, o = r.strideWidth, u = r.dilationHeight, l = r.dilationWidth, c = r.effectiveFilterHeight, p = r.effectiveFilterWidth, d = r.padInfo.top, h = r.padInfo.left, f = a === "max" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, m = De(r.outShape, n), g = m.values, b = r.outShape[1] * r.outShape[2] * r.outShape[3], y = r.outShape[2] * r.outShape[3], v = r.outShape[3]; for (let x = 0; x < r.batchSize; ++x) { @@ -21347,7 +21235,7 @@ function cH(e) { let o = a.reduce((b, y) => b * y), u = S.getReshaped(r.shape, a, o), l = S.getPermuted(u.length, a.length), c = S.getReshapedPermuted(r.shape, a, o), p = S.getSliceBeginCoords(i, a.length), d = S.getSliceSize(c, i, a.length), h = mt({ inputs: { x: r }, backend: n, attrs: { shape: u } }), f = wn({ inputs: { x: h }, backend: n, attrs: { perm: l } }), m = mt({ inputs: { x: f }, backend: n, attrs: { shape: c } }), g = ga({ inputs: { x: m }, backend: n, attrs: { begin: p, size: d } }); return n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(m), g; } -var dH = { kernelName: io, backendName: "cpu", kernelFunc: cH }; +var dH = { kernelName: oo, backendName: "cpu", kernelFunc: cH }; function pH(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, weights: a } = t, { size: i } = s, o = n.data.get(r.dataId).values, u = n.data.get(a.dataId).values, l = ev(o, u, a.dtype, a.shape, i); return n.makeTensorInfo([i], a.dtype, l); @@ -21372,12 +21260,12 @@ var yH = (e) => { return n.makeOutput(s, t.shape, "float32"); }; var vH = { kernelName: Kd, backendName: "cpu", kernelFunc: yH }; -function to(e) { +function no(e) { let { inputs: t, backend: n } = e, { input: s } = t, r = n.data.get(s.dataId).complexTensorInfos.imag, a = n.data.get(r.dataId).values; return n.makeTensorInfo(r.shape, r.dtype, a); } -var xH = { kernelName: Zd, backendName: "cpu", kernelFunc: to }; -function no(e) { +var xH = { kernelName: Zd, backendName: "cpu", kernelFunc: no }; +function so(e) { let { inputs: t, backend: n, attrs: s } = e, { axis: r } = s, a = w.parseAxisParam(r, t[0].shape)[0], i = S.computeOutShape(t.map((m) => m.shape), a); if (w.sizeFromShape(i) === 0) return n.makeTensorInfo(i, t[0].dtype, []); @@ -21386,7 +21274,7 @@ function no(e) { return Os({ inputs: { x: o[0] }, backend: n }); let u = o.map((m) => m.shape); if (S.assertParamsConsistent(u, a), o[0].dtype === "complex64") { - let m = o.map((x) => ma({ inputs: { input: x }, backend: n })), g = o.map((x) => to({ inputs: { input: x }, backend: n })), b = no({ inputs: m, backend: n, attrs: { axis: a } }), y = no({ inputs: g, backend: n, attrs: { axis: a } }), v = Rn({ inputs: { real: b, imag: y }, backend: n }); + let m = o.map((x) => ma({ inputs: { input: x }, backend: n })), g = o.map((x) => no({ inputs: { input: x }, backend: n })), b = so({ inputs: m, backend: n, attrs: { axis: a } }), y = so({ inputs: g, backend: n, attrs: { axis: a } }), v = Rn({ inputs: { real: b, imag: y }, backend: n }); return m.forEach((x) => n.disposeIntermediateTensorInfo(x)), g.forEach((x) => n.disposeIntermediateTensorInfo(x)), n.disposeIntermediateTensorInfo(b), n.disposeIntermediateTensorInfo(y), v; } let l = o.map((m) => { @@ -21397,7 +21285,7 @@ function no(e) { let p = l[0].shape[0] === 1, d = tv(c, i, t[0].dtype, p), h = S.computeOutShape(o.map((m) => m.shape), a), f = n.makeTensorInfo(h, t[0].dtype, d); return l.forEach((m) => n.disposeIntermediateTensorInfo(m)), f; } -var wH = { kernelName: oo, backendName: "cpu", kernelFunc: no }; +var wH = { kernelName: uo, backendName: "cpu", kernelFunc: so }; function RC(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, filter: a } = t, { strides: i, pad: o, dataFormat: u, dilations: l, dimRoundingMode: c } = s; be([r, a], "conv2d"); @@ -21585,8 +21473,8 @@ function EH(e) { for (let Ms = Et; Ms < en; ++Ms) { let Ls = Ms * le - Cn, ki = v * Ee + x * Tn + k * Dn + T * Ms, Js = E * ($ - 1 - Yt) + A * (z - 1 - tn) + P * (W - 1 - Ls) + R * Pe; for (let Bs = 0; Bs < te; ++Bs) { - let du = y[ki + Bs], Ii = N[Js + Bs]; - Nn += du * Ii; + let pu = y[ki + Bs], Ii = N[Js + Bs]; + Nn += pu * Ii; } } } @@ -21662,7 +21550,7 @@ function zH(e) { } return n.makeTensorInfo(b.shape, b.dtype, b.values); } -var MH = { kernelName: lo, backendName: "cpu", kernelFunc: zH }; +var MH = { kernelName: co, backendName: "cpu", kernelFunc: zH }; function LH(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a, exclusive: i, reverse: o } = s; be(r, "cumprod"); @@ -21689,7 +21577,7 @@ function LH(e) { } return g; } -var BH = { kernelName: pl, backendName: "cpu", kernelFunc: LH }; +var BH = { kernelName: hl, backendName: "cpu", kernelFunc: LH }; function VH(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a, exclusive: i, reverse: o } = s; be(r, "cumsum"); @@ -21716,7 +21604,7 @@ function VH(e) { } return g; } -var WH = { kernelName: uo, backendName: "cpu", kernelFunc: VH }; +var WH = { kernelName: lo, backendName: "cpu", kernelFunc: VH }; function UH(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, weights: a } = t, { size: i, binaryOutput: o } = s; if (r.shape.length === 1) { @@ -21746,7 +21634,7 @@ function HH(e) { } return n.makeTensorInfo([o, p, d, h], r.dtype, m); } -var qH = { kernelName: co, backendName: "cpu", kernelFunc: HH }; +var qH = { kernelName: po, backendName: "cpu", kernelFunc: HH }; function DC(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, filter: a } = t, { strides: i, pad: o, dilations: u, dimRoundingMode: l } = s; be([r, a], "depthwiseConv2DNative"); @@ -21983,16 +21871,16 @@ var c6 = S.ERF_A2; var d6 = S.ERF_A3; var p6 = S.ERF_A4; var h6 = S.ERF_A5; -var f6 = st(hl, (e) => { +var f6 = st(fl, (e) => { let t = Math.sign(e), n = Math.abs(e), s = 1 / (1 + u6 * n); return t * (1 - ((((h6 * s + p6) * s + d6) * s + c6) * s + l6) * s * Math.exp(-n * n)); }); -var m6 = { kernelName: hl, backendName: "cpu", kernelFunc: f6 }; +var m6 = { kernelName: fl, backendName: "cpu", kernelFunc: f6 }; function Od(e) { let { inputs: t, backend: n, attrs: s } = e, { input: r } = t, { dim: a } = s, i = r.shape.length, o = r.shape.slice(), u = a; return a < 0 && (w.assert(-(i + 1) <= a, () => `Axis must be in the interval [${-(i + 1)}, ${i}]`), u = i + a + 1), o.splice(u, 0, 1), mt({ inputs: { x: r }, backend: n, attrs: { shape: o } }); } -var g6 = { kernelName: ho, backendName: "cpu", kernelFunc: Od }; +var g6 = { kernelName: fo, backendName: "cpu", kernelFunc: Od }; var b6 = At((e, t) => e / t); var lv = Gt(Da, b6); var Mm = { kernelName: Da, backendName: "cpu", kernelFunc: lv }; @@ -22029,7 +21917,7 @@ function v6(e) { function Lm(e, t, n, s, r) { if (n === 1) return { real: e, imag: t }; - let a = S.mergeRealAndImagArrays(e, t), i = n / 2, o = S.complexWithEvenIndex(a), u = o.real, l = o.imag, c = [u.length], p = r.makeTensorInfo(c, "float32", u), d = r.makeTensorInfo(c, "float32", l), h = Rn({ inputs: { real: p, imag: d }, backend: r }), f = S.complexWithOddIndex(a), m = f.real, g = f.imag, b = [m.length], y = r.makeTensorInfo(b, "float32", m), v = r.makeTensorInfo(b, "float32", g), x = Rn({ inputs: { real: y, imag: v }, backend: r }), k = Lm(u, l, i, s, r), T = k.real, N = k.imag, E = [T.length], A = r.makeTensorInfo(E, "float32", T), P = r.makeTensorInfo(E, "float32", N), R = Rn({ inputs: { real: A, imag: P }, backend: r }), F = Lm(m, g, i, s, r), $ = F.real, z = F.imag, W = [$.length], q = r.makeTensorInfo(W, "float32", $), K = r.makeTensorInfo(W, "float32", z), Y = Rn({ inputs: { real: q, imag: K }, backend: r }), Z = S.exponents(n, s), te = [Z.real.length], ee = r.makeTensorInfo(te, "float32", Z.real), se = r.makeTensorInfo(te, "float32", Z.imag), ne = Rn({ inputs: { real: ee, imag: se }, backend: r }), oe = Hp({ inputs: { a: ne, b: Y }, backend: r }), re = Kl({ inputs: { a: R, b: oe }, backend: r }), le = iv({ inputs: { a: R, b: oe }, backend: r }), me = ma({ inputs: { input: re }, backend: r }), ke = ma({ inputs: { input: le }, backend: r }), Se = to({ inputs: { input: re }, backend: r }), Ee = to({ inputs: { input: le }, backend: r }), Pe = no({ inputs: [me, ke], backend: r, attrs: { axis: 0 } }), Xe = no({ inputs: [Se, Ee], backend: r, attrs: { axis: 0 } }), Je = r.data.get(Pe.dataId).values, Ye = r.data.get(Xe.dataId).values; + let a = S.mergeRealAndImagArrays(e, t), i = n / 2, o = S.complexWithEvenIndex(a), u = o.real, l = o.imag, c = [u.length], p = r.makeTensorInfo(c, "float32", u), d = r.makeTensorInfo(c, "float32", l), h = Rn({ inputs: { real: p, imag: d }, backend: r }), f = S.complexWithOddIndex(a), m = f.real, g = f.imag, b = [m.length], y = r.makeTensorInfo(b, "float32", m), v = r.makeTensorInfo(b, "float32", g), x = Rn({ inputs: { real: y, imag: v }, backend: r }), k = Lm(u, l, i, s, r), T = k.real, N = k.imag, E = [T.length], A = r.makeTensorInfo(E, "float32", T), P = r.makeTensorInfo(E, "float32", N), R = Rn({ inputs: { real: A, imag: P }, backend: r }), F = Lm(m, g, i, s, r), $ = F.real, z = F.imag, W = [$.length], q = r.makeTensorInfo(W, "float32", $), K = r.makeTensorInfo(W, "float32", z), Y = Rn({ inputs: { real: q, imag: K }, backend: r }), Z = S.exponents(n, s), te = [Z.real.length], ee = r.makeTensorInfo(te, "float32", Z.real), se = r.makeTensorInfo(te, "float32", Z.imag), ne = Rn({ inputs: { real: ee, imag: se }, backend: r }), oe = Hp({ inputs: { a: ne, b: Y }, backend: r }), re = Kl({ inputs: { a: R, b: oe }, backend: r }), le = iv({ inputs: { a: R, b: oe }, backend: r }), me = ma({ inputs: { input: re }, backend: r }), ke = ma({ inputs: { input: le }, backend: r }), Se = no({ inputs: { input: re }, backend: r }), Ee = no({ inputs: { input: le }, backend: r }), Pe = so({ inputs: [me, ke], backend: r, attrs: { axis: 0 } }), Xe = so({ inputs: [Se, Ee], backend: r, attrs: { axis: 0 } }), Je = r.data.get(Pe.dataId).values, Ye = r.data.get(Xe.dataId).values; return r.disposeIntermediateTensorInfo(p), r.disposeIntermediateTensorInfo(d), r.disposeIntermediateTensorInfo(h), r.disposeIntermediateTensorInfo(y), r.disposeIntermediateTensorInfo(v), r.disposeIntermediateTensorInfo(x), r.disposeIntermediateTensorInfo(A), r.disposeIntermediateTensorInfo(P), r.disposeIntermediateTensorInfo(R), r.disposeIntermediateTensorInfo(q), r.disposeIntermediateTensorInfo(K), r.disposeIntermediateTensorInfo(Y), r.disposeIntermediateTensorInfo(ee), r.disposeIntermediateTensorInfo(se), r.disposeIntermediateTensorInfo(ne), r.disposeIntermediateTensorInfo(oe), r.disposeIntermediateTensorInfo(re), r.disposeIntermediateTensorInfo(le), r.disposeIntermediateTensorInfo(me), r.disposeIntermediateTensorInfo(Se), r.disposeIntermediateTensorInfo(ke), r.disposeIntermediateTensorInfo(Ee), r.disposeIntermediateTensorInfo(Pe), r.disposeIntermediateTensorInfo(Xe), { real: Je, imag: Ye }; } function x6(e, t, n) { @@ -22053,11 +21941,11 @@ function cv(e) { let { backend: t, attrs: n } = e, { shape: s, value: r, dtype: a } = n, i = a || w.inferDtype(r), o = w.getArrayFromDType(i, w.sizeFromShape(s)); return S6(o, r, i), t.makeTensorInfo(s, i, o); } -var I6 = { kernelName: fl, backendName: "cpu", kernelFunc: cv }; +var I6 = { kernelName: ml, backendName: "cpu", kernelFunc: cv }; function S6(e, t, n) { e.fill(t); } -var C6 = { kernelName: mo, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { +var C6 = { kernelName: go, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { let { image: s } = e, r = n, a = w.getTypedArrayFromDType(s.dtype, w.sizeFromShape(s.shape)), [i, o, u, l] = s.shape, c = r.data.get(s.dataId).values; for (let d = 0; d < i; d++) { let h = d * u * o * l; @@ -22114,7 +22002,7 @@ function D6(e) { let d = n.data.get(r.dataId).values, h = n.bufferSync(s), f = Y0(d, h, s.dtype, l, o, c, p, s.shape, a); return n.makeTensorInfo(u, s.dtype, f.values); } -var F6 = { kernelName: bo, backendName: "cpu", kernelFunc: D6 }; +var F6 = { kernelName: yo, backendName: "cpu", kernelFunc: D6 }; function O6(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, indices: a } = t, { axis: i, batchDims: o } = s; be([r, a], "gatherV2"); @@ -22128,30 +22016,30 @@ function O6(e) { let d = w.sizeFromShape(a.shape), h = S.segment_util.collectGatherOpShapeInfo(r, a, u, p), f = mt({ inputs: { x: r }, backend: n, attrs: { shape: [h.batchSize, h.outerSize, h.dimSize, h.sliceSize] } }), m = mt({ inputs: { x: a }, backend: n, attrs: { shape: [h.batchSize, d / h.batchSize] } }), g = [h.batchSize, h.outerSize, d / h.batchSize, h.sliceSize], b = n.bufferSync(m), y = n.bufferSync(f), v = Q0(y, b, g); return n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(m), n.makeTensorInfo(h.outputShape, v.dtype, v.values); } -var P6 = { kernelName: go, backendName: "cpu", kernelFunc: O6 }; +var P6 = { kernelName: bo, backendName: "cpu", kernelFunc: O6 }; function z6(e) { let { inputs: t, backend: n } = e, { input: s } = t, r = w.sizeFromShape(s.shape), a = s.shape[s.shape.length - 1], i = r / a, o = mt({ inputs: { x: s }, backend: n, attrs: { shape: [i, a] } }), u = FC(o, true, n), l = mt({ inputs: { x: u }, backend: n, attrs: { shape: s.shape } }); return n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(u), l; } var M6 = { kernelName: vg, backendName: "cpu", kernelFunc: z6 }; -var L6 = st(ml, (e) => Number.isFinite(e) ? 1 : 0, "bool"); -var B6 = { kernelName: ml, backendName: "cpu", kernelFunc: L6 }; -var V6 = st(gl, (e) => Math.abs(e) === 1 / 0 ? 1 : 0, "bool"); -var W6 = { kernelName: gl, backendName: "cpu", kernelFunc: V6 }; -var U6 = st(bl, (e) => Number.isNaN(e) ? 1 : 0, "bool"); -var G6 = { kernelName: bl, backendName: "cpu", kernelFunc: U6 }; +var L6 = st(gl, (e) => Number.isFinite(e) ? 1 : 0, "bool"); +var B6 = { kernelName: gl, backendName: "cpu", kernelFunc: L6 }; +var V6 = st(bl, (e) => Math.abs(e) === 1 / 0 ? 1 : 0, "bool"); +var W6 = { kernelName: bl, backendName: "cpu", kernelFunc: V6 }; +var U6 = st(yl, (e) => Number.isNaN(e) ? 1 : 0, "bool"); +var G6 = { kernelName: yl, backendName: "cpu", kernelFunc: U6 }; function H6(e) { let { backend: t, attrs: n } = e, { start: s, stop: r, num: a } = n, i = nC(s, r, a); return t.makeTensorInfo([i.length], "float32", i); } var q6 = { kernelName: xg, backendName: "cpu", kernelFunc: H6 }; -var j6 = st(yl, (e) => Math.log1p(e)); -var K6 = { kernelName: yl, backendName: "cpu", kernelFunc: j6 }; +var j6 = st(vl, (e) => Math.log1p(e)); +var K6 = { kernelName: vl, backendName: "cpu", kernelFunc: j6 }; var X6 = At((e, t) => e && t); -var Y6 = Gt(wo, X6, null, "bool"); -var Q6 = { kernelName: wo, backendName: "cpu", kernelFunc: Y6 }; -var Z6 = st(vl, (e) => e ? 0 : 1, "bool"); -var J6 = { kernelName: vl, backendName: "cpu", kernelFunc: Z6 }; +var Y6 = Gt(ko, X6, null, "bool"); +var Q6 = { kernelName: ko, backendName: "cpu", kernelFunc: Y6 }; +var Z6 = st(xl, (e) => e ? 0 : 1, "bool"); +var J6 = { kernelName: xl, backendName: "cpu", kernelFunc: Z6 }; var eq = At((e, t) => e || t); var tq = Gt(Jd, eq, null, "bool"); var nq = { kernelName: Jd, backendName: "cpu", kernelFunc: tq }; @@ -22348,8 +22236,8 @@ var Sq = At((e, t) => { let n = e % t; return e < 0 && t < 0 || e >= 0 && t >= 0 ? n : (n + t) % t; }); -var Cq = Gt(xl, Sq); -var Nq = { kernelName: xl, backendName: "cpu", kernelFunc: Cq }; +var Cq = Gt(wl, Sq); +var Nq = { kernelName: wl, backendName: "cpu", kernelFunc: Cq }; var Tq = xa(Wd()); function PC(e) { let { inputs: t, backend: n, attrs: s } = e, { logits: r } = t, { dim: a } = s, i = r.shape.length, o = a; @@ -22389,7 +22277,7 @@ function Rq(e) { let l = n.data.get(r.dataId).values, c = n.data.get(a.dataId).values, { selectedIndices: p } = Eq(l, c, i, o, u); return n.makeTensorInfo([p.length], "int32", new Int32Array(p)); } -var Dq = { kernelName: So, backendName: "cpu", kernelFunc: Rq }; +var Dq = { kernelName: Co, backendName: "cpu", kernelFunc: Rq }; var Fq = xs.nonMaxSuppressionV4Impl; function Oq(e) { let { inputs: t, backend: n, attrs: s } = e, { boxes: r, scores: a } = t, { maxOutputSize: i, iouThreshold: o, scoreThreshold: u, padToMaxOutputSize: l } = s; @@ -22397,7 +22285,7 @@ function Oq(e) { let c = n.data.get(r.dataId).values, p = n.data.get(a.dataId).values, { selectedIndices: d, validOutputs: h } = Fq(c, p, i, o, u, l); return [n.makeTensorInfo([d.length], "int32", new Int32Array(d)), n.makeTensorInfo([], "int32", new Int32Array([h]))]; } -var Pq = { kernelName: wl, backendName: "cpu", kernelFunc: Oq }; +var Pq = { kernelName: kl, backendName: "cpu", kernelFunc: Oq }; var zq = xs.nonMaxSuppressionV5Impl; function Mq(e) { let { inputs: t, backend: n, attrs: s } = e, { boxes: r, scores: a } = t, { maxOutputSize: i, iouThreshold: o, scoreThreshold: u, softNmsSigma: l } = s; @@ -22405,7 +22293,7 @@ function Mq(e) { let c = n.data.get(r.dataId).values, p = n.data.get(a.dataId).values, d = i, h = o, f = u, m = l, { selectedIndices: g, selectedScores: b } = zq(c, p, d, h, f, m); return [n.makeTensorInfo([g.length], "int32", new Int32Array(g)), n.makeTensorInfo([b.length], "float32", new Float32Array(b))]; } -var Lq = { kernelName: Co, backendName: "cpu", kernelFunc: Mq }; +var Lq = { kernelName: No, backendName: "cpu", kernelFunc: Mq }; function Bq(e) { let { inputs: t, backend: n, attrs: s } = e, { indices: r } = t, { depth: a, onValue: i, offValue: o } = s; be(r, "oneHot"); @@ -22416,29 +22304,29 @@ function Bq(e) { c[p] >= 0 && c[p] < a && (l[p * a + c[p]] = i); return n.makeTensorInfo([...r.shape, a], "int32", l); } -var Vq = { kernelName: To, backendName: "cpu", kernelFunc: Bq }; +var Vq = { kernelName: $o, backendName: "cpu", kernelFunc: Bq }; function Pd(e) { let { inputs: t, backend: n } = e, { x: s } = t; if (s.dtype === "string") throw new Error("zerosLike is not supported for string tensors"); if (s.dtype === "complex64") { - let r = ma({ inputs: { input: s }, backend: n }), a = Pd({ inputs: { x: r }, backend: n }), i = to({ inputs: { input: s }, backend: n }), o = Pd({ inputs: { x: i }, backend: n }), u = Rn({ inputs: { real: a, imag: o }, backend: n }); + let r = ma({ inputs: { input: s }, backend: n }), a = Pd({ inputs: { x: r }, backend: n }), i = no({ inputs: { input: s }, backend: n }), o = Pd({ inputs: { x: i }, backend: n }), u = Rn({ inputs: { real: a, imag: o }, backend: n }); return n.disposeIntermediateTensorInfo(r), n.disposeIntermediateTensorInfo(a), n.disposeIntermediateTensorInfo(i), n.disposeIntermediateTensorInfo(o), u; } else return cv({ backend: n, attrs: { shape: s.shape, value: 0, dtype: s.dtype } }); } -var Wq = { kernelName: Go, backendName: "cpu", kernelFunc: Pd }; +var Wq = { kernelName: Ho, backendName: "cpu", kernelFunc: Pd }; function zC(e) { let { inputs: t, backend: n } = e, { x: s } = t; if (s.dtype === "string") throw new Error("onesLike is not supported for string tensors"); if (s.dtype === "complex64") { - let r = ma({ inputs: { input: s }, backend: n }), a = zC({ inputs: { x: r }, backend: n }), i = to({ inputs: { input: s }, backend: n }), o = Pd({ inputs: { x: i }, backend: n }), u = Rn({ inputs: { real: a, imag: o }, backend: n }); + let r = ma({ inputs: { input: s }, backend: n }), a = zC({ inputs: { x: r }, backend: n }), i = no({ inputs: { input: s }, backend: n }), o = Pd({ inputs: { x: i }, backend: n }), u = Rn({ inputs: { real: a, imag: o }, backend: n }); return n.disposeIntermediateTensorInfo(r), n.disposeIntermediateTensorInfo(a), n.disposeIntermediateTensorInfo(i), n.disposeIntermediateTensorInfo(o), u; } else return cv({ backend: n, attrs: { shape: s.shape, value: 1, dtype: s.dtype } }); } -var Uq = { kernelName: No, backendName: "cpu", kernelFunc: zC }; +var Uq = { kernelName: To, backendName: "cpu", kernelFunc: zC }; function MC(e) { let { inputs: t, backend: n, attrs: s } = e, { axis: r } = s; if (t.length === 1) @@ -22450,10 +22338,10 @@ function MC(e) { let o = [], u = t.map((c) => { let p = Od({ inputs: { input: c }, backend: n, attrs: { dim: r } }); return o.push(p), p; - }), l = no({ inputs: u, backend: n, attrs: { axis: r } }); + }), l = so({ inputs: u, backend: n, attrs: { axis: r } }); return o.forEach((c) => n.disposeIntermediateTensorInfo(c)), l; } -var Gq = { kernelName: $o, backendName: "cpu", kernelFunc: MC }; +var Gq = { kernelName: _o, backendName: "cpu", kernelFunc: MC }; function Hq(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { paddings: a, constantValue: i } = s; be(r, "pad"); @@ -22473,9 +22361,9 @@ function Xq(e) { let { backend: t, attrs: n } = e, { start: s, stop: r, dtype: a, step: i } = n, o = rv(s, r, i, a); return t.makeTensorInfo([o.length], a, o); } -var Yq = { kernelName: kl, backendName: "cpu", kernelFunc: Xq }; -var Qq = st(Il, (e) => 1 / e); -var Zq = { kernelName: Il, backendName: "cpu", kernelFunc: Qq }; +var Yq = { kernelName: Il, backendName: "cpu", kernelFunc: Xq }; +var Qq = st(Sl, (e) => 1 / e); +var Zq = { kernelName: Sl, backendName: "cpu", kernelFunc: Qq }; function Jq(e) { let { inputs: t, backend: n, attrs: s } = e, { images: r } = t, { alignCorners: a, halfPixelCenters: i, size: o } = s; be(r, "resizeBilinear"); @@ -22541,7 +22429,7 @@ function sj(e) { } return n.makeTensorInfo([p, l, c, f], r.dtype, g); } -var rj = { kernelName: Sl, backendName: "cpu", kernelFunc: sj }; +var rj = { kernelName: Cl, backendName: "cpu", kernelFunc: sj }; function aj(e) { let { inputs: t, backend: n, attrs: s } = e, { images: r, dy: a } = t, { alignCorners: i } = s; be([a, r], "resizeNearestNeighborGrad"); @@ -22589,8 +22477,8 @@ function oj(e) { } return n.makeTensorInfo(u.shape, u.dtype, u.values); } -var uj = { kernelName: Eo, backendName: "cpu", kernelFunc: oj }; -var lj = { kernelName: Ho, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { +var uj = { kernelName: Ro, backendName: "cpu", kernelFunc: oj }; +var lj = { kernelName: qo, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { let { image: s } = e, { radians: r, fillValue: a, center: i } = t, o = n, u = w.getTypedArrayFromDType(s.dtype, w.sizeFromShape(s.shape)), [l, c, p, d] = s.shape, [h, f] = S.getImageCenter(i, c, p), m = 255, g = Math.sin(r), b = Math.cos(r), y = o.data.get(s.dataId).values; for (let x = 0; x < l; x++) { let k = x * p * c * d; @@ -22614,11 +22502,11 @@ var lj = { kernelName: Ho, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: } return { dataId: o.write(u, s.shape, s.dtype), shape: s.shape, dtype: s.dtype }; } }; -var cj = st(Ro, (e) => { +var cj = st(Do, (e) => { let t = Math.floor(e); return e - t < 0.5 ? Math.floor(e) : e - t > 0.5 ? Math.ceil(e) : t % 2 === 0 ? t : t + 1; }); -var dj = { kernelName: Ro, backendName: "cpu", kernelFunc: cj }; +var dj = { kernelName: Do, backendName: "cpu", kernelFunc: cj }; function BC(e, t, n, s, r, a, i, o, u, l) { let c = [s / r, r], p = e.values, d = t.values; if (s === 0) @@ -22642,7 +22530,7 @@ function pj(e) { let { inputs: t, backend: n, attrs: s } = e, { indices: r, updates: a } = t, { shape: i } = s, { sliceRank: o, numUpdates: u, sliceSize: l, strides: c, outputSize: p } = S.calculateShapes(a, r, i), d = true, h = n.bufferSync(r), f = n.bufferSync(a), m = BC(h, f, i, p, l, u, o, c, 0, d); return n.makeTensorInfo(i, m.dtype, m.values); } -var hj = { kernelName: Do, backendName: "cpu", kernelFunc: pj }; +var hj = { kernelName: Fo, backendName: "cpu", kernelFunc: pj }; function fj(e) { let { inputs: t, backend: n } = e, { condition: s, t: r, e: a } = t; be([s, r, a], "select"); @@ -22652,24 +22540,24 @@ function fj(e) { o[f] === 1 ? p[d++] = u[f] : p[d++] = l[f]; return n.makeTensorInfo(r.shape, c, p); } -var mj = { kernelName: Fo, backendName: "cpu", kernelFunc: fj }; +var mj = { kernelName: Oo, backendName: "cpu", kernelFunc: fj }; var gj = S.SELU_SCALEALPHA; var bj = S.SELU_SCALE; -var yj = st(Cl, (e) => e >= 0 ? bj * e : gj * (Math.exp(e) - 1)); -var vj = { kernelName: Cl, backendName: "cpu", kernelFunc: yj }; -var xj = st(Nl, (e) => e < 0 ? -1 : e > 0 ? 1 : 0); -var wj = { kernelName: Nl, backendName: "cpu", kernelFunc: xj }; +var yj = st(Nl, (e) => e >= 0 ? bj * e : gj * (Math.exp(e) - 1)); +var vj = { kernelName: Nl, backendName: "cpu", kernelFunc: yj }; +var xj = st(Tl, (e) => e < 0 ? -1 : e > 0 ? 1 : 0); +var wj = { kernelName: Tl, backendName: "cpu", kernelFunc: xj }; var kj = st(ri, (e) => Math.sin(e)); var Ij = { kernelName: ri, backendName: "cpu", kernelFunc: kj }; -var Sj = st(Po, (e) => Math.sinh(e)); -var Cj = { kernelName: Po, backendName: "cpu", kernelFunc: Sj }; +var Sj = st(zo, (e) => Math.sinh(e)); +var Cj = { kernelName: zo, backendName: "cpu", kernelFunc: Sj }; var Nj = 11920928955078125e-23; var nw = Math.log(Nj) + 2; -var Tj = st(Tl, (e) => { +var Tj = st($l, (e) => { let t = e > -nw, n = e < nw, s = Math.exp(e), r; return n ? r = s : t ? r = e : r = Math.log(1 + s), r; }); -var $j = { kernelName: Tl, backendName: "cpu", kernelFunc: Tj }; +var $j = { kernelName: $l, backendName: "cpu", kernelFunc: Tj }; function _j(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockShape: a, paddings: i } = s; be([r], "spaceToBatchND"); @@ -22680,7 +22568,7 @@ function _j(e) { let l = LC.kernelFunc({ inputs: { x: r }, backend: n, attrs: { paddings: u, constantValue: 0 } }), c = S.getReshaped(l.shape, a, o, false), p = S.getPermuted(c.length, a.length, false), d = S.getReshapedPermuted(l.shape, a, o, false), m = mt({ inputs: { x: l }, backend: n, attrs: { shape: c } }), y = wn({ inputs: { x: m }, backend: n, attrs: { perm: p } }), k = mt({ inputs: { x: y }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(m), n.disposeIntermediateTensorInfo(y), k; } -var Aj = { kernelName: zo, backendName: "cpu", kernelFunc: _j }; +var Aj = { kernelName: Mo, backendName: "cpu", kernelFunc: _j }; function Ej(e) { let { inputs: t, backend: n } = e, { indices: s, values: r, denseShape: a, defaultValue: i } = t; if (a.shape.length !== 1) @@ -22712,7 +22600,7 @@ function Dj(e) { let i = Array.from(n.data.get(r.dataId).values), o = n.data.get(s.dataId).values, u = Array.from(n.data.get(a.dataId).values), [l, c, p] = hC(o, s.shape, s.dtype, i, u); return [n.makeTensorInfo(c, s.dtype, l), n.makeTensorInfo([p.length], a.dtype, new Int32Array(p))]; } -var Fj = { kernelName: $l, backendName: "cpu", kernelFunc: Dj }; +var Fj = { kernelName: _l, backendName: "cpu", kernelFunc: Dj }; function Oj(e) { let { inputs: t, backend: n } = e, { data: s, indices: r, segmentIds: a } = t; if (s.shape.length < 1) @@ -22759,8 +22647,8 @@ function Vj(e) { return l[o] += p, h; }); } -var Wj = { kernelName: Mo, backendName: "cpu", kernelFunc: Vj }; -var Uj = { kernelName: _l, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t }) => { +var Wj = { kernelName: Lo, backendName: "cpu", kernelFunc: Vj }; +var Uj = { kernelName: Al, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t }) => { let { x: n } = e, s = t; be(n, "square"); let r = s.data.get(n.dataId).values, a = new Float32Array(r.length); @@ -22791,7 +22679,7 @@ function qj(e) { } return k; } -var jj = { kernelName: Lo, backendName: "cpu", kernelFunc: qj }; +var jj = { kernelName: Bo, backendName: "cpu", kernelFunc: qj }; function Kj(e) { let { inputs: t, backend: n, attrs: s } = e, { separator: r, nGramWidths: a, leftPad: i, rightPad: o, padWidth: u, preserveShortSequences: l } = s, { data: c, dataSplits: p } = t, d = n.data.get(c.dataId).values, h = n.data.get(p.dataId).values, [f, m] = gC(d, h, r, a, i, o, u, l); return [n.makeTensorInfo([f.length], "string", f), n.makeTensorInfo(p.shape, "int32", m)]; @@ -22819,8 +22707,8 @@ function Zj(e) { return n.makeTensorInfo(a.shape, "int32", o); } var Jj = { kernelName: _g, backendName: "cpu", kernelFunc: Zj }; -var e5 = st(Bo, (e) => Math.tan(e)); -var t5 = { kernelName: Bo, backendName: "cpu", kernelFunc: e5 }; +var e5 = st(Vo, (e) => Math.tan(e)); +var t5 = { kernelName: Vo, backendName: "cpu", kernelFunc: e5 }; var n5 = st(di, (e) => Math.tanh(e)); var s5 = { kernelName: di, backendName: "cpu", kernelFunc: n5 }; function r5(e) { @@ -22836,7 +22724,7 @@ function i5(e) { let o = n.data.get(r.dataId).values, [u, l] = kC(o, r.shape, r.dtype, a, i); return [n.makeTensorInfo(u.shape, u.dtype, u.values), n.makeTensorInfo(l.shape, l.dtype, l.values)]; } -var o5 = { kernelName: Vo, backendName: "cpu", kernelFunc: i5 }; +var o5 = { kernelName: Wo, backendName: "cpu", kernelFunc: i5 }; function u5(e) { let { inputs: t, attrs: n, backend: s } = e, { image: r, transforms: a } = t, { interpolation: i, fillMode: o, fillValue: u, outputShape: l } = n, [c, p, d, h] = r.shape, [f, m] = l != null ? l : [p, d], g = [c, f, m, h], b = w.computeStrides(r.shape), y = b[0], v = b[1], x = b[2], k = w.getTypedArrayFromDType(r.dtype, w.sizeFromShape(g)); k.fill(u); @@ -22867,7 +22755,7 @@ function u5(e) { } return { dataId: s.write(k, g, r.dtype), shape: r.shape, dtype: r.dtype }; } -var l5 = { kernelName: Wo, backendName: "cpu", kernelFunc: u5 }; +var l5 = { kernelName: Uo, backendName: "cpu", kernelFunc: u5 }; function sw(e, t, n) { switch (n) { case "reflect": @@ -22923,16 +22811,16 @@ function p5(e, t) { function h5(e, t) { return w.clamp(0, e, t - 1); } -function Ru(e, t, n, s, r, a, i, o, u, l, c) { +function Du(e, t, n, s, r, a, i, o, u, l, c) { let p = i * s + o * r + u * a + l; return 0 <= o && o < t && 0 <= u && u < n ? e[p] : c; } function f5(e, t, n, s, r, a, i, o, u, l, c) { let p = Math.round(o), d = Math.round(u); - return Ru(e, t, n, s, r, a, i, p, d, l, c); + return Du(e, t, n, s, r, a, i, p, d, l, c); } function m5(e, t, n, s, r, a, i, o, u, l, c) { - let p = Math.floor(o), d = Math.floor(u), h = p + 1, f = d + 1, m = (f - u) * Ru(e, t, n, s, r, a, i, p, d, l, c) + (u - d) * Ru(e, t, n, s, r, a, i, p, f, l, c), g = (f - u) * Ru(e, t, n, s, r, a, i, h, d, l, c) + (u - d) * Ru(e, t, n, s, r, a, i, h, f, l, c); + let p = Math.floor(o), d = Math.floor(u), h = p + 1, f = d + 1, m = (f - u) * Du(e, t, n, s, r, a, i, p, d, l, c) + (u - d) * Du(e, t, n, s, r, a, i, p, f, l, c), g = (f - u) * Du(e, t, n, s, r, a, i, h, d, l, c) + (u - d) * Du(e, t, n, s, r, a, i, h, f, l, c); return (h - o) * m + (o - p) * g; } function g5(e) { @@ -22958,7 +22846,7 @@ function y5(e) { } return d; } -var v5 = { kernelName: Uo, backendName: "cpu", kernelFunc: y5 }; +var v5 = { kernelName: Go, backendName: "cpu", kernelFunc: y5 }; function x5(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, segmentIds: a } = t, { numSegments: i } = s; be(r, "unsortedSegmentSum"); @@ -22977,9 +22865,9 @@ function x5(e) { var w5 = { kernelName: up, backendName: "cpu", kernelFunc: x5 }; var k5 = [TG, xU, _G, EG, NU, DG, OG, zG, LG, VG, UG, HG, jG, YG, ZG, tH, sH, aH, oH, CG, lH, dH, hH, mH, SU, $U, bH, wU, vH, wH, kH, SH, NH, $H, AH, RH, FH, PH, MH, BH, WH, GH, qH, jH, XH, QH, JH, e6, t6, n6, a6, yG, o6, _U, m6, AU, g6, RU, k6, I6, C6, FU, $6, A6, R6, F6, P6, PU, MU, kU, M6, xH, B6, W6, G6, vG, BU, WU, q6, GU, K6, Q6, J6, nq, rq, iq, oq, qU, lq, dq, hq, mq, bq, vq, wq, KU, Iq, Nq, Aq, YU, ZU, Dq, Pq, Lq, eG, Vq, Uq, Gq, LC, Kq, wG, sG, Yq, IU, Mm, Zq, kG, IG, SG, ej, nj, rj, ij, uj, lj, dj, aG, hj, mj, vj, oG, wj, Ij, Cj, uG, $q, $j, Aj, Rj, Fj, Pj, Mj, Bj, Wj, dG, Uj, hG, Hj, jj, Xj, Qj, Jj, bG, s6, t5, s5, a5, o5, l5, tG, b5, v5, w5, Wq]; for (let e of k5) - Al(e); + El(e); var I5 = {}; -Ae(I5, { assertNotComplex: () => tu, bindCanvasToFramebuffer: () => O5, bindColorTextureToFramebuffer: () => ad, bindTextureToProgramUniformSampler: () => t1, bindTextureUnit: () => ZC, bindVertexBufferToProgramAttribute: () => Bm, callAndCheck: () => fe, canBeRepresented: () => VC, createFragmentShader: () => GC, createFramebuffer: () => QC, createProgram: () => HC, createStaticIndexBuffer: () => KC, createStaticVertexBuffer: () => jC, createTexture: () => XC, createVertexShader: () => UC, getBatchDim: () => ba, getExtensionOrThrow: () => Du, getFramebufferErrorMessage: () => n1, getMaxTexturesInShader: () => i1, getNumChannels: () => D5, getProgramUniformLocation: () => e1, getProgramUniformLocationOrThrow: () => JC, getRowsCols: () => ya, getShapeAs3D: () => id, getTextureShapeFromLogicalShape: () => r1, getWebGLDisjointQueryTimerVersion: () => o1, getWebGLErrorMessage: () => WC, getWebGLMaxTextureSize: () => a1, hasExtension: () => Ln, isCapableOfRenderingToFloatTexture: () => u1, isDownloadFloatTextureEnabled: () => l1, isReshapeFree: () => Ju, isWebGLFenceEnabled: () => c1, isWebGLVersionEnabled: () => Wm, linkProgram: () => qC, logShaderSourceAndInfoLog: () => pv, resetMaxTextureSize: () => P5, resetMaxTexturesInShader: () => z5, unbindColorTextureFromFramebuffer: () => Vm, unbindTextureUnit: () => F5, validateFramebuffer: () => Fu, validateProgram: () => rd, validateTextureSize: () => YC }); +Ae(I5, { assertNotComplex: () => nu, bindCanvasToFramebuffer: () => O5, bindColorTextureToFramebuffer: () => ad, bindTextureToProgramUniformSampler: () => t1, bindTextureUnit: () => ZC, bindVertexBufferToProgramAttribute: () => Bm, callAndCheck: () => fe, canBeRepresented: () => VC, createFragmentShader: () => GC, createFramebuffer: () => QC, createProgram: () => HC, createStaticIndexBuffer: () => KC, createStaticVertexBuffer: () => jC, createTexture: () => XC, createVertexShader: () => UC, getBatchDim: () => ba, getExtensionOrThrow: () => Fu, getFramebufferErrorMessage: () => n1, getMaxTexturesInShader: () => i1, getNumChannels: () => D5, getProgramUniformLocation: () => e1, getProgramUniformLocationOrThrow: () => JC, getRowsCols: () => ya, getShapeAs3D: () => id, getTextureShapeFromLogicalShape: () => r1, getWebGLDisjointQueryTimerVersion: () => o1, getWebGLErrorMessage: () => WC, getWebGLMaxTextureSize: () => a1, hasExtension: () => Ln, isCapableOfRenderingToFloatTexture: () => u1, isDownloadFloatTextureEnabled: () => l1, isReshapeFree: () => el, isWebGLFenceEnabled: () => c1, isWebGLVersionEnabled: () => Wm, linkProgram: () => qC, logShaderSourceAndInfoLog: () => pv, resetMaxTextureSize: () => P5, resetMaxTexturesInShader: () => z5, unbindColorTextureFromFramebuffer: () => Vm, unbindTextureUnit: () => F5, validateFramebuffer: () => Ou, validateProgram: () => rd, validateTextureSize: () => YC }); var Xr = {}; var jf = { alpha: false, antialias: false, premultipliedAlpha: false, preserveDrawingBuffer: false, depth: false, stencil: false, failIfMajorPerformanceCaveat: true }; function S5(e, t) { @@ -23021,11 +22909,11 @@ function Yc(e) { let t = w.sizeFromShape(e), n = Math.ceil(t / 4); return w.sizeToSquarishShape(n); } -function eu(e, t) { +function tu(e, t) { return [Math.max(1, Math.ceil(t / 2)), Math.max(1, Math.ceil(e / 2))]; } function $5(e, t) { - let [n, s] = eu(e, t); + let [n, s] = tu(e, t); return n * s * 4; } function dv(e, t) { @@ -23066,7 +22954,7 @@ function WC(e, t) { return `Unknown error code ${t}`; } } -function Du(e, t) { +function Fu(e, t) { return Qs(e, () => e.getExtension(t), 'Extension "' + t + '" not supported on this browser.'); } function UC(e, t) { @@ -23167,7 +23055,7 @@ function ad(e, t, n) { function Vm(e, t) { fe(e, () => e.bindFramebuffer(e.FRAMEBUFFER, t)), fe(e, () => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, null, 0)); } -function Fu(e) { +function Ou(e) { let t = e.checkFramebufferStatus(e.FRAMEBUFFER); if (t !== e.FRAMEBUFFER_COMPLETE) throw new Error("Error binding framebuffer: " + n1(e, t)); @@ -23236,7 +23124,7 @@ function r1(e, t = false) { function Qc(e) { return e % 2 === 0; } -function Ju(e, t) { +function el(e, t) { if (e = e.slice(-2), t = t.slice(-2), w.arraysEqual(e, t) || !e.length || !t.length || e[0] === 0 || e[1] === 0 || t[0] === 0 || t[1] === 0) return true; if (e.length !== t.length) { @@ -23339,7 +23227,7 @@ function M5(e, t) { function c1(e) { return e !== 2 ? false : vs(e).fenceSync != null; } -function tu(e, t) { +function nu(e, t) { Array.isArray(e) || (e = [e]), e.forEach((n) => { n != null && w.assert(n.dtype !== "complex64", () => `${t} does not support complex64 tensors in the WebGL backend.`); }); @@ -23572,7 +23460,7 @@ function V5(e, t, n) { return t.isPacked ? (l = U5(t.logicalShape, i, n.enableShapeUniforms), c = j5(o)) : (l = G5(t.logicalShape, i, n.enableShapeUniforms), c = q5(o)), n.packedInputs && (p += Z5), [p, u, c, r, l, a, n.userCode].join(` `); } -function nu(e, t = false) { +function su(e, t = false) { let n = e.shapeInfo.logicalShape; switch (n.length) { case 0: @@ -23609,7 +23497,7 @@ function h1(e, t) { } function W5(e, t, n = false, s) { let r = ""; - n ? r += h1(e, s) : r += nu(e, s); + n ? r += h1(e, s) : r += su(e, s); let a = e.shapeInfo.logicalShape, i = t.logicalShape; return a.length <= i.length && (n ? r += wK(e, t) : r += kK(e, t)), r; } @@ -24165,7 +24053,7 @@ function pK(e, t) { if (e.shapeInfo.isUniform) return ` float ${s}(int index) { - ${su(e)} + ${ru(e)} } `; let r = e.shapeInfo.texShape, a = r[0], i = r[1]; @@ -24261,11 +24149,11 @@ function fK(e, t) { } let { newShape: i, keptDims: o } = w.squeezeShape(n), u = i; if (u.length < n.length) { - let d = ru(e, u), h = ["row", "col"]; + let d = au(e, u), h = ["row", "col"]; return ` - ${nu(d, t)} + ${su(d, t)} float ${r}(int row, int col) { - return ${r}(${au(h, o)}); + return ${r}(${iu(h, o)}); } `; } @@ -24273,7 +24161,7 @@ function fK(e, t) { return ` float ${r}(int row, int col) { int index = round(dot(vec2(row, col), vec2(${n[1]}, 1))); - ${su(e)} + ${ru(e)} } `; let l = a[0], c = a[1], p = vi(s); @@ -24320,11 +24208,11 @@ function fK(e, t) { function mK(e, t) { let n = e.shapeInfo.logicalShape, s = e.name, r = "get" + s.charAt(0).toUpperCase() + s.slice(1), a = e.shapeInfo.texShape, i = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)]; if (n[0] === 1) { - let d = n.slice(1), h = [1, 2], f = ru(e, d), m = ["b", "row", "col"]; + let d = n.slice(1), h = [1, 2], f = au(e, d), m = ["b", "row", "col"]; return ` ${h1(f, t)} vec4 ${r}(int b, int row, int col) { - return ${r}(${au(m, h)}); + return ${r}(${iu(m, h)}); } `; } @@ -24352,11 +24240,11 @@ function mK(e, t) { function gK(e, t) { let n = e.shapeInfo.logicalShape, s = e.name, r = "get" + s.charAt(0).toUpperCase() + s.slice(1), a = n[1] * n[2], i = n[2], { newShape: o, keptDims: u } = w.squeezeShape(n), l = o; if (l.length < n.length) { - let m = ru(e, l), g = ["row", "col", "depth"]; + let m = au(e, l), g = ["row", "col", "depth"]; return ` - ${nu(m, t)} + ${su(m, t)} float ${r}(int row, int col, int depth) { - return ${r}(${au(g, u)}); + return ${r}(${iu(g, u)}); } `; } @@ -24365,7 +24253,7 @@ function gK(e, t) { float ${r}(int row, int col, int depth) { int index = round(dot(vec3(row, col, depth), vec3(${a}, ${i}, 1))); - ${su(e)} + ${ru(e)} } `; let c = e.shapeInfo.texShape, p = c[0], d = c[1], h = e.shapeInfo.flatOffset; @@ -24455,11 +24343,11 @@ function bK(e, t) { function yK(e, t) { let n = e.shapeInfo.logicalShape, s = e.name, r = "get" + s.charAt(0).toUpperCase() + s.slice(1), a = n[3], i = n[2] * a, o = n[1] * i, { newShape: u, keptDims: l } = w.squeezeShape(n); if (u.length < n.length) { - let y = ru(e, u), v = ["row", "col", "depth", "depth2"]; + let y = au(e, u), v = ["row", "col", "depth", "depth2"]; return ` - ${nu(y, t)} + ${su(y, t)} float ${r}(int row, int col, int depth, int depth2) { - return ${r}(${au(v, l)}); + return ${r}(${iu(v, l)}); } `; } @@ -24468,7 +24356,7 @@ function yK(e, t) { float ${r}(int row, int col, int depth, int depth2) { int index = round(dot(vec4(row, col, depth, depth2), vec4(${o}, ${i}, ${a}, 1))); - ${su(e)} + ${ru(e)} } `; let c = e.shapeInfo.flatOffset, p = e.shapeInfo.texShape, d = p[0], h = p[1], f = `int stride2 = ${s}Shape[3];`, m = `int stride1 = ${s}Shape[2] * stride2;`, g = `int stride0 = ${s}Shape[1] * stride1;`; @@ -24541,11 +24429,11 @@ function yK(e, t) { function vK(e) { let t = e.shapeInfo.logicalShape, n = e.name, s = "get" + n.charAt(0).toUpperCase() + n.slice(1), r = t[4], a = t[3] * r, i = t[2] * a, o = t[1] * i, { newShape: u, keptDims: l } = w.squeezeShape(t); if (u.length < t.length) { - let m = ru(e, u), g = ["row", "col", "depth", "depth2", "depth3"]; + let m = au(e, u), g = ["row", "col", "depth", "depth2", "depth3"]; return ` - ${nu(m)} + ${su(m)} float ${s}(int row, int col, int depth, int depth2, int depth3) { - return ${s}(${au(g, l)}); + return ${s}(${iu(g, l)}); } `; } @@ -24556,7 +24444,7 @@ function vK(e) { vec4(row, col, depth, depth2), vec4(${o}, ${i}, ${a}, ${r})) + depth3; - ${su(e)} + ${ru(e)} } `; let c = e.shapeInfo.flatOffset, p = e.shapeInfo.texShape, d = p[0], h = p[1]; @@ -24598,12 +24486,12 @@ function vK(e) { function xK(e) { let t = e.shapeInfo.logicalShape, n = e.name, s = "get" + n.charAt(0).toUpperCase() + n.slice(1), { newShape: r, keptDims: a } = w.squeezeShape(t); if (r.length < t.length) { - let g = ru(e, r), b = ["row", "col", "depth", "depth2", "depth3", "depth4"]; + let g = au(e, r), b = ["row", "col", "depth", "depth2", "depth3", "depth4"]; return ` - ${nu(g)} + ${su(g)} float ${s}(int row, int col, int depth, int depth2, int depth3, int depth4) { - return ${s}(${au(b, a)}); + return ${s}(${iu(b, a)}); } `; } @@ -24618,7 +24506,7 @@ function xK(e) { dot( vec2(depth3, depth4), vec2(${i}, 1))); - ${su(e)} + ${ru(e)} } `; let p = e.shapeInfo.flatOffset, d = e.shapeInfo.texShape, h = d[0], f = d[1]; @@ -24662,7 +24550,7 @@ function xK(e) { } `; } -function su(e) { +function ru(e) { let t = e.name, n = w.sizeFromShape(e.shapeInfo.logicalShape); return n < 2 ? `return ${t};` : ` for (int i = 0; i < ${n}; i++) { @@ -24741,11 +24629,11 @@ function mv(e, t, n) { let { newShape: s, keptDims: r } = w.squeezeShape(t), a = t.length, i = e && a === 3 && t[0] === 1, o = i ? t.slice(1) : s, u = !e && a > 1 && !w.arraysEqual(t, n) && s.length < a || i; return { useSqueezeShape: u, uniformShape: u ? o : t, keptDims: r }; } -function ru(e, t) { +function au(e, t) { let n = JSON.parse(JSON.stringify(e)); return n.shapeInfo.logicalShape = t, n; } -function au(e, t) { +function iu(e, t) { return t.map((n) => e[n]).join(", "); } function IK(e, t, n, s) { @@ -25136,14 +25024,14 @@ function vv(e) { return e.internalFormatPackedFloat; } function k1(e, t, n, s) { - let [r, a] = eu(t, n); + let [r, a] = tu(t, n); return Ql(e, r, a, vv(s), e.RGBA, e.FLOAT); } function xv(e) { return e.internalFormatPackedHalfFloat; } function I1(e, t, n, s) { - let [r, a] = eu(t, n); + let [r, a] = tu(t, n); return Ql(e, r, a, xv(s), e.RGBA, s.textureTypeHalfFloat); } function S1(e, t, n) { @@ -25187,12 +25075,12 @@ var Kf = class { let n = "WEBGL_color_buffer_float", s = "EXT_color_buffer_half_float"; if (this.parallelCompilationExtension = this.gl.getExtension("KHR_parallel_shader_compile"), X().getNumber("WEBGL_VERSION") === 1) { let r = "OES_texture_float", a = "OES_texture_half_float"; - if (this.textureFloatExtension = Du(this.gl, r), Ln(this.gl, a)) - this.textureHalfFloatExtension = Du(this.gl, a); + if (this.textureFloatExtension = Fu(this.gl, r), Ln(this.gl, a)) + this.textureHalfFloatExtension = Fu(this.gl, a); else if (X().get("WEBGL_FORCE_F16_TEXTURES")) throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true."); if (this.colorBufferFloatExtension = this.gl.getExtension(n), Ln(this.gl, s)) - this.colorBufferHalfFloatExtension = Du(this.gl, s); + this.colorBufferHalfFloatExtension = Fu(this.gl, s); else if (X().get("WEBGL_FORCE_F16_TEXTURES")) throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true."); } else if (n = "EXT_color_buffer_float", Ln(this.gl, n)) @@ -25300,7 +25188,7 @@ var Kf = class { } setOutputPackedMatrixTexture(e, t, n) { this.throwIfDisposed(); - let [s, r] = eu(t, n); + let [s, r] = tu(t, n); this.setOutputMatrixTextureDriver(e, s, r); } setOutputMatrixWriteRegion(e, t, n, s) { @@ -25310,7 +25198,7 @@ var Kf = class { throw new Error("setOutputPackedMatrixWriteRegion not implemented."); } debugValidate() { - this.program != null && rd(this.gl, this.program), Fu(this.gl); + this.program != null && rd(this.gl, this.program), Ou(this.gl); } executeProgram() { this.throwIfDisposed(), this.throwIfNoProgram(); @@ -25321,7 +25209,7 @@ var Kf = class { this.throwIfDisposed(), fe(this.gl, () => this.gl.finish()); } getQueryTimerExtension() { - return this.disjointQueryTimerExtension == null && (this.disjointQueryTimerExtension = Du(this.gl, X().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2 ? "EXT_disjoint_timer_query_webgl2" : "EXT_disjoint_timer_query")), this.disjointQueryTimerExtension; + return this.disjointQueryTimerExtension == null && (this.disjointQueryTimerExtension = Fu(this.gl, X().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") === 2 ? "EXT_disjoint_timer_query_webgl2" : "EXT_disjoint_timer_query")), this.disjointQueryTimerExtension; } getQueryTimerExtensionWebGL2() { return this.getQueryTimerExtension(); @@ -25388,10 +25276,10 @@ var Kf = class { this.itemsToPoll.push({ isDoneFn: e, resolveFn: t }), !(this.itemsToPoll.length > 1) && w.repeatedTry(() => (this.pollItems(), this.itemsToPoll.length === 0)); } bindTextureToFrameBuffer(e) { - this.throwIfDisposed(), ad(this.gl, e, this.framebuffer), this.debug && Fu(this.gl); + this.throwIfDisposed(), ad(this.gl, e, this.framebuffer), this.debug && Ou(this.gl); } unbindTextureToFrameBuffer() { - this.outputTexture != null ? (ad(this.gl, this.outputTexture, this.framebuffer), this.debug && Fu(this.gl)) : Vm(this.gl, this.framebuffer); + this.outputTexture != null ? (ad(this.gl, this.outputTexture, this.framebuffer), this.debug && Ou(this.gl)) : Vm(this.gl, this.framebuffer); } downloadMatrixDriver(e, t) { this.bindTextureToFrameBuffer(e); @@ -25401,7 +25289,7 @@ var Kf = class { setOutputMatrixTextureDriver(e, t, n) { this.throwIfDisposed(); let s = this.gl; - ad(s, e, this.framebuffer), this.debug && Fu(s), this.outputTexture = e, fe(s, () => s.viewport(0, 0, t, n)), fe(s, () => s.scissor(0, 0, t, n)); + ad(s, e, this.framebuffer), this.debug && Ou(s), this.outputTexture = e, fe(s, () => s.viewport(0, 0, t, n)), fe(s, () => s.scissor(0, 0, t, n)); } setOutputMatrixWriteRegionDriver(e, t, n, s) { this.throwIfDisposed(), fe(this.gl, () => this.gl.scissor(e, t, n, s)); @@ -25630,7 +25518,7 @@ function kX(e, t) { function aw(e, t, n, s, r) { let a = IX(t, s), i; if (r) { - let [u, l] = eu(e[0], e[1]); + let [u, l] = tu(e[0], e[1]); i = u * l; } else { let [u, l] = Yl(e[0], e[1]); @@ -25774,10 +25662,9 @@ var VX = 600; function WX() { return X().global.screen == null ? 1024 : X().global.screen.height * X().global.screen.width * window.devicePixelRatio * VX / 1024 / 1024; } -var z1 = class extends tl { +var z1 = class extends nl { constructor(e) { - super(); - if (this.pendingRead = /* @__PURE__ */ new WeakMap(), this.pendingDisposal = /* @__PURE__ */ new WeakSet(), this.dataRefCount = /* @__PURE__ */ new WeakMap(), this.numBytesInGPU = 0, this.uploadWaitMs = 0, this.downloadWaitMs = 0, this.lastGlFlushTime = 0, this.warnedAboutMemory = false, this.pendingDeletes = 0, this.disposed = false, !X().getBool("HAS_WEBGL")) + if (super(), this.pendingRead = /* @__PURE__ */ new WeakMap(), this.pendingDisposal = /* @__PURE__ */ new WeakSet(), this.dataRefCount = /* @__PURE__ */ new WeakMap(), this.numBytesInGPU = 0, this.uploadWaitMs = 0, this.downloadWaitMs = 0, this.lastGlFlushTime = 0, this.warnedAboutMemory = false, this.pendingDeletes = 0, this.disposed = false, !X().getBool("HAS_WEBGL")) throw new Error("WebGL is not supported on this device"); let t; if (e != null) { @@ -26069,7 +25956,7 @@ var z1 = class extends tl { } if (this.uploadToGPU(g.dataId), !!b.isPacked != !!e.packedInputs) g = b.isPacked ? this.unpackTensor(g) : this.packTensor(g), u.push(g), b = this.texData.get(g.dataId); - else if (b.isPacked && !Ju(b.shape, g.shape)) { + else if (b.isPacked && !el(b.shape, g.shape)) { let y = g, v = g.shape; g.shape = b.shape, g = this.packedReshape(g, v), u.push(g), b = this.texData.get(g.dataId), y.shape = v; } @@ -26127,7 +26014,7 @@ var z1 = class extends tl { let c = t.texShape; if (c == null && (c = r1(n, o), t.texShape = c), r != null) { let p = id(n), d, h = c[1], f = c[0], m = r instanceof Uint8Array || r instanceof Uint8ClampedArray; - (o || !m) && ([h, f] = eu(c[0], c[1])), o ? d = new EK(p, m) : d = new AK(p, m); + (o || !m) && ([h, f] = tu(c[0], c[1])), o ? d = new EK(p, m) : d = new AK(p, m); let g = m ? [f, h] : c, b = this.makeTensorInfo(g, s), y = this.texData.get(b.dataId); m ? y.usage = 2 : y.usage = 1, y.texShape = g, this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(b.dataId), h, f, r); let v = [[f, h]], x = true, k = this.runWebGLProgram(d, [b], s, v, x), T = this.texData.get(k.dataId); @@ -26203,17 +26090,17 @@ function UX(e, t) { } else throw new Error(`Unknown dtype ${t}`); } -var Ope = "0.0.0"; +var Ppe = "0.0.0"; function GX() { X().set("WEBGL_FORCE_F16_TEXTURES", true); } dp.isBrowser() && pp("webgl", () => new M1(), 2); -var Ppe = { forceHalfFloat: GX }; +var zpe = { forceHalfFloat: GX }; var L1 = ` if (isnan(a)) return a; if (isnan(b)) return b; `; -var so = class { +var ro = class { constructor(e, t, n) { this.variableNames = ["A", "B"], this.outputShape = S.assertAndGetBroadcastShape(t, n), this.enableShapeUniforms = Sn(this.outputShape.length), this.userCode = ` float binaryOperation(float a, float b) { @@ -26312,7 +26199,7 @@ var V1 = ` return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); `; function jX(e) { - let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { alpha: a } = s, i = n.makeTensorInfo([], "float32", w.createScalarValue(a, "float32")), o = X().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Zl(V1, r.shape, i.shape) : new so(B1, r.shape, i.shape), u = n.runWebGLProgram(o, [r, i], "float32"); + let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { alpha: a } = s, i = n.makeTensorInfo([], "float32", w.createScalarValue(a, "float32")), o = X().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Zl(V1, r.shape, i.shape) : new ro(B1, r.shape, i.shape), u = n.runWebGLProgram(o, [r, i], "float32"); return n.disposeIntermediateTensorInfo(i), u; } var KX = { kernelName: Va, backendName: "webgl", kernelFunc: jX }; @@ -26322,11 +26209,11 @@ var U1 = ` return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a); `; function XX(e) { - let { inputs: t, backend: n } = e, { x: s, alpha: r } = t, a = X().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Zl(U1, s.shape, r.shape) : new so(W1, s.shape, r.shape); + let { inputs: t, backend: n } = e, { x: s, alpha: r } = t, a = X().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Zl(U1, s.shape, r.shape) : new ro(W1, s.shape, r.shape); return n.runWebGLProgram(a, [s, r], "float32"); } var YX = { kernelName: Ja, backendName: "webgl", kernelFunc: XX }; -var iu = "if (isnan(x)) return x;"; +var ou = "if (isnan(x)) return x;"; var QX = ` if (isnan(a)) return a; if (isnan(b)) return b; @@ -26353,7 +26240,7 @@ function jt({ opSnippet: e, packedOpSnippet: t, checkOutOfBounds: n = false, sup let { a: u, b: l } = i, c = o; if (s && u.dtype === "complex64") { let f = c.texData.get(u.dataId), m = c.texData.get(l.dataId), [g, b] = [[f.complexTensorInfos.real, m.complexTensorInfos.real], [f.complexTensorInfos.imag, m.complexTensorInfos.imag]].map((v) => { - let [x, k] = v, T = { dataId: x.dataId, dtype: x.dtype, shape: u.shape }, N = { dataId: k.dataId, dtype: k.dtype, shape: l.shape }, E = new so(e, u.shape, l.shape); + let [x, k] = v, T = { dataId: x.dataId, dtype: x.dtype, shape: u.shape }, N = { dataId: k.dataId, dtype: k.dtype, shape: l.shape }, E = new ro(e, u.shape, l.shape); return c.runWebGLProgram(E, [T, N], cn(x.dtype, k.dtype)); }), y = Rr({ inputs: { real: g, imag: b }, backend: c }); return c.disposeIntermediateTensorInfo(g), c.disposeIntermediateTensorInfo(b), y; @@ -26364,7 +26251,7 @@ function jt({ opSnippet: e, packedOpSnippet: t, checkOutOfBounds: n = false, sup return k.values = y, x; } let d = X().getBool("WEBGL_PACK_BINARY_OPERATIONS") && t != null, h; - return d ? h = new Zl(t, u.shape, l.shape, n) : h = new so(e, u.shape, l.shape), c.runWebGLProgram(h, [u, l], p); + return d ? h = new Zl(t, u.shape, l.shape, n) : h = new ro(e, u.shape, l.shape), c.runWebGLProgram(h, [u, l], p); }; } function Kp(e, t = false) { @@ -26465,7 +26352,7 @@ function kv(e) { return d.values = l, p; } let i; - return X().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? i = new Zl(dw, s.shape, r.shape) : i = new so(dw, s.shape, r.shape), n.runWebGLProgram(i, [s, r], a); + return X().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? i = new Zl(dw, s.shape, r.shape) : i = new ro(dw, s.shape, r.shape), n.runWebGLProgram(i, [s, r], a); } var JX = { kernelName: Ya, backendName: "webgl", kernelFunc: kv }; function e8(e, t, n) { @@ -26476,9 +26363,9 @@ function he(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { shape: a } = s, i = n, o = w.sizeFromShape(r.shape), u = w.inferFromImplicitShape(a, o), l = w.sizeFromShape(u); w.assert(o === l, () => `The new shape (${u}) has ${l} elements and the old shape (${r.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`); let c = i.texData.get(r.dataId); - return c.isPacked && !Ju(r.shape, u) && !(c.texture !== null && Ju(c.shape, u)) ? e8(r, u, i) : (i.incRef(r.dataId), { dataId: r.dataId, shape: u, dtype: r.dtype }); + return c.isPacked && !el(r.shape, u) && !(c.texture !== null && el(c.shape, u)) ? e8(r, u, i) : (i.incRef(r.dataId), { dataId: r.dataId, shape: u, dtype: r.dtype }); } -var t8 = { kernelName: Ao, backendName: "webgl", kernelFunc: he }; +var t8 = { kernelName: Eo, backendName: "webgl", kernelFunc: he }; var pw = class { constructor(e, t) { this.variableNames = ["x"]; @@ -26760,7 +26647,7 @@ function qt(e) { var l8 = { kernelName: pi, backendName: "webgl", kernelFunc: qt }; var H1 = 1e3; function zd({ a: e, b: t, transposeA: n, transposeB: s, backend: r, bias: a = null, preluActivationWeights: i = null, leakyreluAlpha: o = 0, activation: u = null }) { - let l = e.shape.length, c = t.shape.length, p = n ? e.shape[l - 2] : e.shape[l - 1], d = s ? t.shape[c - 1] : t.shape[c - 2], h = n ? e.shape[l - 1] : e.shape[l - 2], f = s ? t.shape[c - 2] : t.shape[c - 1], m = e.shape.slice(0, -2), g = t.shape.slice(0, -2), b = w.sizeFromShape(m), y = w.sizeFromShape(g), x = qo.assertAndGetBroadcastShape(e.shape.slice(0, -2), t.shape.slice(0, -2)).concat([h, f]); + let l = e.shape.length, c = t.shape.length, p = n ? e.shape[l - 2] : e.shape[l - 1], d = s ? t.shape[c - 1] : t.shape[c - 2], h = n ? e.shape[l - 1] : e.shape[l - 2], f = s ? t.shape[c - 2] : t.shape[c - 1], m = e.shape.slice(0, -2), g = t.shape.slice(0, -2), b = w.sizeFromShape(m), y = w.sizeFromShape(g), x = jo.assertAndGetBroadcastShape(e.shape.slice(0, -2), t.shape.slice(0, -2)).concat([h, f]); w.assert(p === d, () => `Error in matMul: inner shapes (${p}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${s} must match.`); let k = n ? [b, p, h] : [b, h, p], T = s ? [y, f, d] : [y, d, f], N = he({ inputs: { x: e }, backend: r, attrs: { shape: k } }), E = he({ inputs: { x: t }, backend: r, attrs: { shape: T } }), A = [N, E], P = Math.max(b, y), R = n ? N.shape[1] : N.shape[2], F = a != null, $ = i != null, z = u === "leakyrelu", W = u != null ? Kp(u, true) : null, q = F || $ || z || W != null, K; if ((h === 1 || f === 1) && R > H1 && q === false) { @@ -26801,7 +26688,7 @@ function p8(e) { let r; return X().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? r = new Zr(s.shape, hw) : r = new Hs(s.shape, hw), n.runWebGLProgram(r, [s], s.dtype); } -var h8 = { kernelName: ao, backendName: "webgl", kernelFunc: p8 }; +var h8 = { kernelName: io, backendName: "webgl", kernelFunc: p8 }; var f8 = ss + ` if (abs(x) > 1.) { return NAN; @@ -26809,12 +26696,12 @@ var f8 = ss + ` return acos(x); `; var m8 = Ke({ opSnippet: f8 }); -var g8 = { kernelName: nl, backendName: "webgl", kernelFunc: m8 }; +var g8 = { kernelName: sl, backendName: "webgl", kernelFunc: m8 }; var b8 = ss + ` if (x < 1.0) return NAN; return log(x + sqrt(x * x - 1.0));`; var y8 = Ke({ opSnippet: b8 }); -var v8 = { kernelName: sl, backendName: "webgl", kernelFunc: y8 }; +var v8 = { kernelName: rl, backendName: "webgl", kernelFunc: y8 }; var fw = "return a + b;"; var x8 = jt({ opSnippet: fw, packedOpSnippet: fw, supportsComplex: true, cpuKernelImpl: FK }); var w8 = { kernelName: Ir, backendName: "webgl", kernelFunc: x8 }; @@ -26879,7 +26766,7 @@ function C8(e) { b = he({ inputs: { x: g }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(m), n.disposeIntermediateTensorInfo(g), c != null && n.disposeIntermediateTensorInfo(p), b; } -var N8 = { kernelName: rl, backendName: "webgl", kernelFunc: C8 }; +var N8 = { kernelName: al, backendName: "webgl", kernelFunc: C8 }; function T8(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a, keepDims: i } = s, o = r.shape.length, u = w.parseAxisParam(a, r.shape), l = u, c = S.getAxesPermutation(l, o), p = r; c != null && (p = qt({ inputs: { x: r }, backend: n, attrs: { perm: c } }), l = S.getInnerMostAxes(l.length, o)), S.assertAxesAreInnerMostDims("any", l, o); @@ -26891,7 +26778,7 @@ function T8(e) { b = he({ inputs: { x: g }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(m), n.disposeIntermediateTensorInfo(g), c != null && n.disposeIntermediateTensorInfo(p), b; } -var $8 = { kernelName: al, backendName: "webgl", kernelFunc: T8 }; +var $8 = { kernelName: il, backendName: "webgl", kernelFunc: T8 }; var _8 = class { constructor(e, t, n) { this.variableNames = ["A"]; @@ -27045,7 +26932,7 @@ function D8(e) { let c = K1(n, u, i[0], "min"); return l.forEach((p) => n.disposeIntermediateTensorInfo(p)), c; } -var F8 = { kernelName: il, backendName: "webgl", kernelFunc: D8 }; +var F8 = { kernelName: ol, backendName: "webgl", kernelFunc: D8 }; var O8 = ss + ` if (abs(x) > 1.) { return NAN; @@ -27053,15 +26940,15 @@ var O8 = ss + ` return asin(x); `; var P8 = Ke({ opSnippet: O8 }); -var z8 = { kernelName: ol, backendName: "webgl", kernelFunc: P8 }; +var z8 = { kernelName: ul, backendName: "webgl", kernelFunc: P8 }; var M8 = ss + "return log(x + sqrt(x * x + 1.0));"; var L8 = Ke({ opSnippet: M8 }); -var B8 = { kernelName: ul, backendName: "webgl", kernelFunc: L8 }; +var B8 = { kernelName: ll, backendName: "webgl", kernelFunc: L8 }; var V8 = ss + ` return atan(x); `; var W8 = Ke({ opSnippet: V8 }); -var U8 = { kernelName: ll, backendName: "webgl", kernelFunc: W8 }; +var U8 = { kernelName: cl, backendName: "webgl", kernelFunc: W8 }; var G8 = QX + ` return atan(a, b); `; @@ -27072,13 +26959,13 @@ var H8 = ` return result; `; var q8 = jt({ opSnippet: G8, packedOpSnippet: H8 }); -var j8 = { kernelName: dl, backendName: "webgl", kernelFunc: q8 }; +var j8 = { kernelName: pl, backendName: "webgl", kernelFunc: q8 }; var K8 = ss + ` if ((x < -1.0) || (x > 1.0)) return NAN; return (log(1.0 + x) - log(1.0 - x)) / 2.0;`; var X8 = Ke({ opSnippet: K8 }); -var Y8 = { kernelName: cl, backendName: "webgl", kernelFunc: X8 }; -var el = class { +var Y8 = { kernelName: dl, backendName: "webgl", kernelFunc: X8 }; +var tl = class { constructor(e, t, n, s = false, r = false) { if (this.variableNames = ["x"], t === "avg" && n) throw new Error("Cannot compute positions for average pool."); @@ -27420,13 +27307,13 @@ var Iv = class { }; function Q8(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t; - tu(r, "avgPool"); + nu(r, "avgPool"); let { filterSize: a, strides: i, pad: o, dimRoundingMode: u } = s, l = 1; w.assert(S.eitherStridesOrDilationsAreOne(i, l), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${l}'`); let c = S.computePool2DInfo(r.shape, a, i, l, o, u); if (c.filterWidth === 1 && c.filterHeight === 1 && w.arraysEqual(c.inShape, c.outShape)) return kn({ inputs: { x: r }, backend: n }); - let p = new el(c, "avg", false); + let p = new tl(c, "avg", false); return n.runWebGLProgram(p, [r], "float32"); } var Z8 = { kernelName: Sa, backendName: "webgl", kernelFunc: Q8 }; @@ -27554,7 +27441,7 @@ function sY(e) { var rY = { kernelName: og, backendName: "webgl", kernelFunc: sY }; function aY(e) { let { inputs: t, backend: n, attrs: s } = e, { dy: r, input: a } = t, i = a; - tu([r, a], "avgPoolGrad"); + nu([r, a], "avgPoolGrad"); let { filterSize: o, strides: u, pad: l } = s, c = S.computePool2DInfo(i.shape, o, u, 1, l), p = new tY(c); return n.runWebGLProgram(p, [r], i.dtype); } @@ -27689,7 +27576,7 @@ function gY(e, t, n, s) { let u = s.dataRefCount.get(i.slice.origDataId) || 1; return s.dataRefCount.set(i.slice.origDataId, u + 1), a; } -function ou(e) { +function uu(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { begin: a, size: i } = s, [o, u] = wt.parseSliceParams(r, a, i); if (wt.assertParamsValid(r, o, u), w.sizeFromShape(u) === 0) return n.makeTensorInfo(u, r.dtype, []); @@ -27704,14 +27591,14 @@ function ou(e) { } return n.uploadToGPU(r.dataId), gY(r, o, u, n); } -var bY = { kernelName: Oo, backendName: "webgl", kernelFunc: ou }; +var bY = { kernelName: Po, backendName: "webgl", kernelFunc: uu }; var yY = (e) => { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockShape: a, crops: i } = s; w.assert(r.shape.length <= 4, () => "batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"); - let o = a.reduce((y, v) => y * v), u = S.getReshaped(r.shape, a, o), l = S.getPermuted(u.length, a.length), c = S.getReshapedPermuted(r.shape, a, o), p = S.getSliceBeginCoords(i, a.length), d = S.getSliceSize(c, i, a.length), h = [], f = he({ inputs: { x: r }, backend: n, attrs: { shape: u } }), m = qt({ inputs: { x: f }, backend: n, attrs: { perm: l } }), g = he({ inputs: { x: m }, backend: n, attrs: { shape: c } }), b = ou({ inputs: { x: g }, backend: n, attrs: { begin: p, size: d } }); + let o = a.reduce((y, v) => y * v), u = S.getReshaped(r.shape, a, o), l = S.getPermuted(u.length, a.length), c = S.getReshapedPermuted(r.shape, a, o), p = S.getSliceBeginCoords(i, a.length), d = S.getSliceSize(c, i, a.length), h = [], f = he({ inputs: { x: r }, backend: n, attrs: { shape: u } }), m = qt({ inputs: { x: f }, backend: n, attrs: { perm: l } }), g = he({ inputs: { x: m }, backend: n, attrs: { shape: c } }), b = uu({ inputs: { x: g }, backend: n, attrs: { begin: p, size: d } }); return h.push(f), h.push(m), h.push(g), h.forEach((y) => n.disposeIntermediateTensorInfo(y)), b; }; -var vY = { kernelName: io, backendName: "webgl", kernelFunc: yY }; +var vY = { kernelName: oo, backendName: "webgl", kernelFunc: yY }; function xY(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, weights: a } = t, { size: i } = s, o = n.readSync(r.dataId), u = n.readSync(a.dataId), l = R1(o, u, a.dtype, a.shape, i); return n.makeTensorInfo([i], a.dtype, l); @@ -27724,7 +27611,7 @@ function kY(e) { var IY = { kernelName: lg, backendName: "webgl", kernelFunc: kY }; var SY = "return float(a != b);"; var X1 = jt({ opSnippet: SY, cpuKernelImpl: tX, dtype: "bool" }); -var CY = { kernelName: Io, backendName: "webgl", kernelFunc: X1 }; +var CY = { kernelName: So, backendName: "webgl", kernelFunc: X1 }; function Jl(e) { let { inputs: t, backend: n } = e, { input: s } = t, r = n.texData.get(s.dataId); return kn({ inputs: { x: r.complexTensorInfos.real }, backend: n }); @@ -27958,7 +27845,7 @@ function Y1(e) { let u = o.map((l) => l.shape); return S.assertParamsConsistent(u, a), Gi(o, a, n); } -var UY = { kernelName: oo, backendName: "webgl", kernelFunc: Y1 }; +var UY = { kernelName: uo, backendName: "webgl", kernelFunc: Y1 }; var Q1 = class { constructor(e, t = false, n = null, s = false, r = false) { this.variableNames = ["x", "W"], this.outputShape = e.outShape; @@ -28258,7 +28145,7 @@ function Z1({ x: e, filter: t, convInfo: n, backend: s, bias: r = null, preluAct let u = e.shape, l = s.texData.get(e.dataId), c = n.inChannels, p = u[0] * u[1] * u[2], d = n.outChannels, h = n.dataFormat === "channelsLast", f = false, m = false, g, b = []; if (!((p === 1 || d === 1) && c > H1) && l.isPacked && h && l.texture != null && u[2] % 2 !== 0 && w.arraysEqual(l.shape.slice(-3), u.slice(-3))) { let x = u[0] * u[1] * (u[2] + 1), k = { dataId: e.dataId, shape: [1, x, n.inChannels], dtype: e.dtype }, T = l.shape; - l.shape = l.shape.slice(), l.shape[l.shape.length - 2]++, w.assert(Ju(l.shape, k.shape), () => `packed reshape ${l.shape} to ${k.shape} isn't free`); + l.shape = l.shape.slice(), l.shape[l.shape.length - 2]++, w.assert(el(l.shape, k.shape), () => `packed reshape ${l.shape} to ${k.shape} isn't free`); let N = he({ inputs: { x: t }, backend: s, attrs: { shape: [1, n.inChannels, n.outChannels] } }); b.push(N); let E = zd({ a: k, b: N, backend: s, transposeA: f, transposeB: m, bias: r, activation: o, preluActivationWeights: a, leakyreluAlpha: i }), A = s.texData.get(E.dataId); @@ -28548,7 +28435,7 @@ function i9(e) { return n.runWebGLProgram(c, [r, a], "float32"); } var o9 = { kernelName: pg, backendName: "webgl", kernelFunc: i9 }; -var u9 = iu + ` +var u9 = ou + ` return cos(x); `; var l9 = Ke({ opSnippet: u9 }); @@ -28633,7 +28520,7 @@ var m9 = (e) => { let { inputs: t, backend: n, attrs: s } = e, { image: r, boxes: a, boxInd: i } = t, { cropSize: o, method: u, extrapolationValue: l } = s, c = new f9(r.shape, a.shape, o, u, l); return n.runWebGLProgram(c, [r, a, i], "float32"); }; -var g9 = { kernelName: lo, backendName: "webgl", kernelFunc: m9 }; +var g9 = { kernelName: co, backendName: "webgl", kernelFunc: m9 }; var bw = class { constructor(e, t, n) { this.variableNames = ["x"], this.customUniforms = [{ name: "index", type: "float" }], this.outputShape = e; @@ -28697,7 +28584,7 @@ function b9(e) { } return h; } -var y9 = { kernelName: pl, backendName: "webgl", kernelFunc: b9 }; +var y9 = { kernelName: hl, backendName: "webgl", kernelFunc: b9 }; var xw = class { constructor(e, t, n) { this.variableNames = ["x"], this.customUniforms = [{ name: "index", type: "float" }], this.outputShape = e; @@ -28761,7 +28648,7 @@ function v9(e) { } return h; } -var x9 = { kernelName: uo, backendName: "webgl", kernelFunc: v9 }; +var x9 = { kernelName: lo, backendName: "webgl", kernelFunc: v9 }; function w9(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, weights: a } = t, { size: i, binaryOutput: o } = s; if (r.shape.length === 1) { @@ -28817,7 +28704,7 @@ function S9(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockSize: a, dataFormat: i } = s, o = r.shape[0], u = i === "NHWC" ? r.shape[1] : r.shape[2], l = i === "NHWC" ? r.shape[2] : r.shape[3], c = i === "NHWC" ? r.shape[3] : r.shape[1], p = u * a, d = l * a, h = c / (a * a), f = i === "NHWC" ? [o, p, d, h] : [o, h, p, d], m = new I9(f, a, i); return n.runWebGLProgram(m, [r], r.dtype); } -var C9 = { kernelName: co, backendName: "webgl", kernelFunc: S9 }; +var C9 = { kernelName: po, backendName: "webgl", kernelFunc: S9 }; var e2 = class { constructor(e, t = false, n = null, s = false, r = false) { this.variableNames = ["x", "W"], this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = Sn(this.outputShape.length); @@ -29315,7 +29202,7 @@ var j9 = ` return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0)))); `; var K9 = (e) => { - let { inputs: t, backend: n } = e, { dy: s, y: r } = t, a = X().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Zl(j9, s.shape, r.shape) : new so(q9, s.shape, r.shape); + let { inputs: t, backend: n } = e, { dy: s, y: r } = t, a = X().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Zl(j9, s.shape, r.shape) : new ro(q9, s.shape, r.shape); return n.runWebGLProgram(a, [s, r], s.dtype); }; var X9 = { kernelName: bg, backendName: "webgl", kernelFunc: K9 }; @@ -29324,7 +29211,7 @@ var Y9 = ` `; var Q9 = "return float(a == b);"; var Z9 = jt({ opSnippet: Q9, packedOpSnippet: Y9, dtype: "bool", cpuKernelImpl: MK }); -var J9 = { kernelName: po, backendName: "webgl", kernelFunc: Z9 }; +var J9 = { kernelName: ho, backendName: "webgl", kernelFunc: Z9 }; var eQ = ` // Error function is calculated approximately with elementary function. // See "Handbook of Mathematical Functions with Formulas, @@ -29342,8 +29229,8 @@ var eQ = ` return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x)); `; var tQ = Ke({ opSnippet: eQ }); -var nQ = { kernelName: hl, backendName: "webgl", kernelFunc: tQ }; -var sQ = iu + ` +var nQ = { kernelName: fl, backendName: "webgl", kernelFunc: tQ }; +var sQ = ou + ` return exp(x); `; var rQ = ` @@ -29362,10 +29249,10 @@ function qm(e) { let { inputs: t, attrs: n, backend: s } = e, { dim: r } = n, { input: a } = t, i = a.shape.length, o = a.shape.slice(), u = r; return r < 0 && (w.assert(-(i + 1) <= r, () => `Axis must be in the interval [${-(i + 1)}, ${i}]`), u = i + r + 1), o.splice(u, 0, 1), he({ inputs: { x: a }, backend: s, attrs: { shape: o } }); } -var iQ = { kernelName: ho, backendName: "webgl", kernelFunc: qm }; +var iQ = { kernelName: fo, backendName: "webgl", kernelFunc: qm }; var Iw = "return exp(x) - 1.0;"; var oQ = Ke({ opSnippet: Iw, packedOpSnippet: Iw, cpuKernelImpl: BK }); -var uQ = { kernelName: fo, backendName: "webgl", kernelFunc: oQ }; +var uQ = { kernelName: mo, backendName: "webgl", kernelFunc: oQ }; var Sw = class { constructor(e, t, n) { this.variableNames = ["real", "imag"]; @@ -29445,7 +29332,7 @@ function ec(e) { return t.runWebGLProgram(i, [], a, o); } } -var pQ = { kernelName: fl, backendName: "webgl", kernelFunc: ec }; +var pQ = { kernelName: ml, backendName: "webgl", kernelFunc: ec }; var hQ = class { constructor(e) { this.variableNames = ["Image"], this.outputShape = []; @@ -29467,7 +29354,7 @@ var hQ = class { `; } }; -var fQ = { kernelName: mo, backendName: "webgl", kernelFunc: ({ inputs: e, backend: t }) => { +var fQ = { kernelName: go, backendName: "webgl", kernelFunc: ({ inputs: e, backend: t }) => { let { image: n } = e, s = t, r = new hQ(n.shape); return s.runWebGLProgram(r, [n], n.dtype); } }; @@ -29648,7 +29535,7 @@ function AQ(e) { let f = new _Q(i, p, [l, c]), m = n.runWebGLProgram(f, [h, d], h.dtype), g = he({ inputs: { x: m }, backend: n, attrs: { shape: u } }); return n.disposeIntermediateTensorInfo(d), n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(m), g; } -var EQ = { kernelName: bo, backendName: "webgl", kernelFunc: AQ }; +var EQ = { kernelName: yo, backendName: "webgl", kernelFunc: AQ }; var RQ = class { constructor(e, t) { this.variableNames = ["A", "indices"], this.outputShape = t, this.rank = t.length; @@ -29690,13 +29577,13 @@ function r2(e) { let b = he({ inputs: { x: g }, backend: n, attrs: { shape: l.outputShape } }); return p.forEach((y) => n.disposeIntermediateTensorInfo(y)), b; } -var FQ = { kernelName: go, backendName: "webgl", kernelFunc: r2 }; +var FQ = { kernelName: bo, backendName: "webgl", kernelFunc: r2 }; var OQ = "return float(a > b);"; var PQ = ` return vec4(greaterThan(a, b)); `; var zQ = jt({ opSnippet: OQ, packedOpSnippet: PQ, cpuKernelImpl: GK, dtype: "bool" }); -var MQ = { kernelName: yo, backendName: "webgl", kernelFunc: zQ }; +var MQ = { kernelName: vo, backendName: "webgl", kernelFunc: zQ }; var LQ = "return float(a >= b);"; var BQ = ` return vec4(greaterThanEqual(a, b)); @@ -29710,31 +29597,31 @@ function UQ(e) { var GQ = { kernelName: vg, backendName: "webgl", kernelFunc: UQ }; var HQ = "return float(!isnan(x) && !isinf(x));"; var qQ = Ke({ opSnippet: HQ, dtype: "bool" }); -var jQ = { kernelName: ml, backendName: "webgl", kernelFunc: qQ }; +var jQ = { kernelName: gl, backendName: "webgl", kernelFunc: qQ }; var KQ = "return float(isinf(x));"; var XQ = Ke({ opSnippet: KQ, dtype: "bool" }); -var YQ = { kernelName: gl, backendName: "webgl", kernelFunc: XQ }; +var YQ = { kernelName: bl, backendName: "webgl", kernelFunc: XQ }; var QQ = "return float(isnan(x));"; var ZQ = Ke({ opSnippet: QQ, dtype: "bool" }); -var JQ = { kernelName: bl, backendName: "webgl", kernelFunc: ZQ }; +var JQ = { kernelName: yl, backendName: "webgl", kernelFunc: ZQ }; var eZ = "return float(a < b);"; var tZ = ` return vec4(lessThan(a, b)); `; var nZ = jt({ opSnippet: eZ, packedOpSnippet: tZ, cpuKernelImpl: qK, dtype: "bool" }); -var sZ = { kernelName: vo, backendName: "webgl", kernelFunc: nZ }; +var sZ = { kernelName: xo, backendName: "webgl", kernelFunc: nZ }; var rZ = "return float(a <= b);"; var aZ = ` return vec4(lessThanEqual(a, b)); `; var iZ = jt({ opSnippet: rZ, packedOpSnippet: aZ, cpuKernelImpl: jK, dtype: "bool" }); -var oZ = { kernelName: xo, backendName: "webgl", kernelFunc: iZ }; +var oZ = { kernelName: wo, backendName: "webgl", kernelFunc: iZ }; function uZ(e) { let { backend: t, attrs: n } = e, { start: s, stop: r, num: a } = n, i = KK(s, r, a); return t.makeTensorInfo([i.length], "float32", i); } var lZ = { kernelName: xg, backendName: "webgl", kernelFunc: uZ }; -var cZ = iu + ` +var cZ = ou + ` return x < 0.0 ? 0./0. : log(x); `; var dZ = ` @@ -29748,11 +29635,11 @@ var dZ = ` `; var pZ = Ke({ opSnippet: cZ, packedOpSnippet: dZ, cpuKernelImpl: XK }); var hZ = { kernelName: Wa, backendName: "webgl", kernelFunc: pZ }; -var fZ = iu + ` +var fZ = ou + ` return log(1.0 + x); `; var mZ = Ke({ opSnippet: fZ }); -var gZ = { kernelName: yl, backendName: "webgl", kernelFunc: mZ }; +var gZ = { kernelName: vl, backendName: "webgl", kernelFunc: mZ }; var bZ = "return float(a >= 1.0 && b >= 1.0);"; var yZ = ` return vec4( @@ -29760,10 +29647,10 @@ var yZ = ` vec4(greaterThanEqual(b, vec4(1.0)))); `; var vZ = jt({ opSnippet: bZ, packedOpSnippet: yZ, dtype: "bool" }); -var xZ = { kernelName: wo, backendName: "webgl", kernelFunc: vZ }; +var xZ = { kernelName: ko, backendName: "webgl", kernelFunc: vZ }; var wZ = "return float(!(x >= 1.0));"; var kZ = Ke({ opSnippet: wZ }); -var IZ = { kernelName: vl, backendName: "webgl", kernelFunc: kZ }; +var IZ = { kernelName: xl, backendName: "webgl", kernelFunc: kZ }; var SZ = "return float(a >= 1.0 || b >= 1.0);"; var CZ = ` return min( @@ -29988,13 +29875,13 @@ var LZ = jt({ opSnippet: zZ, packedOpSnippet: MZ, cpuKernelImpl: QK }); var BZ = { kernelName: Ga, backendName: "webgl", kernelFunc: LZ }; function VZ(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t; - tu(r, "maxPool"); + nu(r, "maxPool"); let { filterSize: a, strides: i, pad: o, dimRoundingMode: u } = s, l = 1; w.assert(S.eitherStridesOrDilationsAreOne(i, l), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${i} and dilations '${l}'`); let c = S.computePool2DInfo(r.shape, a, i, l, o, u); if (c.filterWidth === 1 && c.filterHeight === 1 && w.arraysEqual(c.inShape, c.outShape)) return kn({ inputs: { x: r }, backend: n }); - let p = new el(c, "max", false); + let p = new tl(c, "max", false); return n.runWebGLProgram(p, [r], r.dtype); } var WZ = { kernelName: Ha, backendName: "webgl", kernelFunc: VZ }; @@ -30134,14 +30021,14 @@ function jZ(e) { var KZ = { kernelName: Ig, backendName: "webgl", kernelFunc: jZ }; function XZ(e) { let { inputs: t, backend: n, attrs: s } = e, { dy: r, input: a, output: i } = t, o = a; - tu([a, i], "maxPoolGrad"); - let { filterSize: u, strides: l, pad: c, dimRoundingMode: p } = s, d = S.computePool2DInfo(o.shape, u, l, 1, c, p), h = true, f = new el(d, "max", h), m = n.runWebGLProgram(f, [o], o.dtype), g = new HZ(d), b = n.runWebGLProgram(g, [r, m], o.dtype); + nu([a, i], "maxPoolGrad"); + let { filterSize: u, strides: l, pad: c, dimRoundingMode: p } = s, d = S.computePool2DInfo(o.shape, u, l, 1, c, p), h = true, f = new tl(d, "max", h), m = n.runWebGLProgram(f, [o], o.dtype), g = new HZ(d), b = n.runWebGLProgram(g, [r, m], o.dtype); return n.disposeIntermediateTensorInfo(m), b; } var YZ = { kernelName: kg, backendName: "webgl", kernelFunc: XZ }; function QZ(e, t, n, s) { - let r = new el(n, "max", false), a = s.runWebGLProgram(r, [e], "float32"); - r = new el(n, "max", true, true, t); + let r = new tl(n, "max", false), a = s.runWebGLProgram(r, [e], "float32"); + r = new tl(n, "max", true, true, t); let i = s.runWebGLProgram(r, [e], "float32"); return [a, i]; } @@ -30327,7 +30214,7 @@ var p7 = ` return result; `; var h7 = jt({ opSnippet: d7, packedOpSnippet: p7 }); -var f7 = { kernelName: xl, backendName: "webgl", kernelFunc: h7 }; +var f7 = { kernelName: wl, backendName: "webgl", kernelFunc: h7 }; var m7 = class { constructor(e, t, n) { this.variableNames = ["probs"], this.customUniforms = [{ name: "seed", type: "float" }], this.outputShape = [e, n], this.userCode = ` @@ -30415,28 +30302,28 @@ function C7(e) { let r; return X().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? r = new Zr(s.shape, S7) : r = new Hs(s.shape, I7), n.runWebGLProgram(r, [s], s.dtype); } -var N7 = { kernelName: ko, backendName: "webgl", kernelFunc: C7 }; +var N7 = { kernelName: Io, backendName: "webgl", kernelFunc: C7 }; var T7 = xs.nonMaxSuppressionV3Impl; function $7(e) { S.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); let { inputs: t, backend: n, attrs: s } = e, { boxes: r, scores: a } = t, { maxOutputSize: i, iouThreshold: o, scoreThreshold: u } = s, l = n.readSync(r.dataId), c = n.readSync(a.dataId), { selectedIndices: p } = T7(l, c, i, o, u); return n.makeTensorInfo([p.length], "int32", new Int32Array(p)); } -var _7 = { kernelName: So, backendName: "webgl", kernelFunc: $7 }; +var _7 = { kernelName: Co, backendName: "webgl", kernelFunc: $7 }; var A7 = xs.nonMaxSuppressionV4Impl; function E7(e) { S.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); let { inputs: t, backend: n, attrs: s } = e, { boxes: r, scores: a } = t, { maxOutputSize: i, iouThreshold: o, scoreThreshold: u, padToMaxOutputSize: l } = s, c = n.readSync(r.dataId), p = n.readSync(a.dataId), { selectedIndices: d, validOutputs: h } = A7(c, p, i, o, u, l); return [n.makeTensorInfo([d.length], "int32", new Int32Array(d)), n.makeTensorInfo([], "int32", new Int32Array([h]))]; } -var R7 = { kernelName: wl, backendName: "webgl", kernelFunc: E7 }; +var R7 = { kernelName: kl, backendName: "webgl", kernelFunc: E7 }; var D7 = xs.nonMaxSuppressionV5Impl; function F7(e) { S.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); let { inputs: t, backend: n, attrs: s } = e, { boxes: r, scores: a } = t, { maxOutputSize: i, iouThreshold: o, scoreThreshold: u, softNmsSigma: l } = s, c = n.readSync(r.dataId), p = n.readSync(a.dataId), d = i, h = o, f = u, m = l, { selectedIndices: g, selectedScores: b } = D7(c, p, d, h, f, m); return [n.makeTensorInfo([g.length], "int32", new Int32Array(g)), n.makeTensorInfo([b.length], "float32", new Float32Array(b))]; } -var O7 = { kernelName: Co, backendName: "webgl", kernelFunc: F7 }; +var O7 = { kernelName: No, backendName: "webgl", kernelFunc: F7 }; var P7 = class { constructor(e, t, n, s) { this.variableNames = ["indices"], this.outputShape = [e, t], this.userCode = ` @@ -30455,7 +30342,7 @@ var z7 = (e) => { let d = [...r.shape, a], h = he({ inputs: { x: p }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(p), h; }; -var M7 = { kernelName: To, backendName: "webgl", kernelFunc: z7 }; +var M7 = { kernelName: $o, backendName: "webgl", kernelFunc: z7 }; function Md(e) { let { inputs: t, backend: n } = e, { x: s } = t; if (s.dtype === "complex64") { @@ -30464,7 +30351,7 @@ function Md(e) { } else return ec({ attrs: { shape: s.shape, dtype: s.dtype, value: s.dtype === "string" ? "" : 0 }, backend: n }); } -var L7 = { kernelName: Go, backendName: "webgl", kernelFunc: Md }; +var L7 = { kernelName: Ho, backendName: "webgl", kernelFunc: Md }; function l2(e) { let { inputs: t, backend: n } = e, { x: s } = t; if (s.dtype === "string") @@ -30475,7 +30362,7 @@ function l2(e) { } else return ec({ attrs: { shape: s.shape, dtype: s.dtype, value: 1 }, backend: n }); } -var B7 = { kernelName: No, backendName: "webgl", kernelFunc: l2 }; +var B7 = { kernelName: To, backendName: "webgl", kernelFunc: l2 }; function V7(e) { let { inputs: t, backend: n, attrs: s } = e, { axis: r } = s; if (t.length === 1) @@ -30490,7 +30377,7 @@ function V7(e) { }), l = Y1({ inputs: u, backend: n, attrs: { axis: r } }); return o.forEach((c) => n.disposeIntermediateTensorInfo(c)), l; } -var W7 = { kernelName: $o, backendName: "webgl", kernelFunc: V7 }; +var W7 = { kernelName: _o, backendName: "webgl", kernelFunc: V7 }; var U7 = class { constructor(e, t, n) { this.variableNames = ["x"], this.customUniforms = [{ name: "value", type: "float" }], this.outputShape = t.map((u, l) => u[0] + e[l] + u[1]); @@ -30617,15 +30504,15 @@ function Y7(e) { } return u.forEach((f) => n.disposeIntermediateTensorInfo(f)), h; } -var Q7 = { kernelName: _o, backendName: "webgl", kernelFunc: Y7 }; +var Q7 = { kernelName: Ao, backendName: "webgl", kernelFunc: Y7 }; var d2 = (e) => { let { backend: t, attrs: n } = e, { start: s, stop: r, step: a, dtype: i } = n, o = sX(s, r, a, i); return t.makeTensorInfo([o.length], i, o); }; -var Z7 = { kernelName: kl, backendName: "webgl", kernelFunc: d2 }; +var Z7 = { kernelName: Il, backendName: "webgl", kernelFunc: d2 }; var J7 = "return 1.0 / x;"; var eJ = Ke({ opSnippet: J7 }); -var tJ = { kernelName: Il, backendName: "webgl", kernelFunc: eJ }; +var tJ = { kernelName: Sl, backendName: "webgl", kernelFunc: eJ }; var nJ = ss + ` return (x < 0.0) ? 0.0 : x; `; @@ -30969,7 +30856,7 @@ function vJ(e) { let { inputs: t, backend: n, attrs: s } = e, { images: r } = t, { alignCorners: a, halfPixelCenters: i, size: o } = s, [u, l] = o, c = X().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new yJ(r.shape, u, l, a, i) : new bJ(r.shape, u, l, a, i); return n.runWebGLProgram(c, [r], r.dtype); } -var xJ = { kernelName: Sl, backendName: "webgl", kernelFunc: vJ }; +var xJ = { kernelName: Cl, backendName: "webgl", kernelFunc: vJ }; var wJ = class { constructor(e, t, n) { this.variableNames = ["dy"], this.outputShape = [], this.outputShape = t; @@ -31141,7 +31028,7 @@ function NJ(e) { let u = X().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new CJ(r.shape, o) : new SJ(r.shape, o); return n.runWebGLProgram(u, [r], r.dtype); } -var TJ = { kernelName: Eo, backendName: "webgl", kernelFunc: NJ }; +var TJ = { kernelName: Ro, backendName: "webgl", kernelFunc: NJ }; var $J = class { constructor(e, t) { this.variableNames = ["Image"], this.outputShape = [], this.customUniforms = [{ name: "params", type: "vec4" }]; @@ -31170,7 +31057,7 @@ var $J = class { `; } }; -var _J = { kernelName: Ho, backendName: "webgl", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { +var _J = { kernelName: qo, backendName: "webgl", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { let { image: s } = e, { radians: r, fillValue: a, center: i } = t, o = n, u = new $J(s.shape, a), [l, c] = S.getImageCenter(i, s.shape[1], s.shape[2]), p = [[l, c, Math.sin(r), Math.cos(r)]]; return o.runWebGLProgram(u, [s], s.dtype, p); } }; @@ -31191,7 +31078,7 @@ var AJ = ` } `; var EJ = Ke({ opSnippet: AJ }); -var RJ = { kernelName: Ro, backendName: "webgl", kernelFunc: EJ }; +var RJ = { kernelName: Do, backendName: "webgl", kernelFunc: EJ }; var DJ = "return inversesqrt(x);"; var FJ = Ke({ opSnippet: DJ, cpuKernelImpl: rX }); var OJ = { kernelName: si, backendName: "webgl", kernelFunc: FJ }; @@ -31233,7 +31120,7 @@ function PJ(e) { let h = he({ inputs: { x: r }, backend: n, attrs: { shape: [u, o] } }), f = he({ inputs: { x: a }, backend: n, attrs: { shape: [u, l] } }), m = n.makeTensorInfo([], "float32", new Float32Array([0])), g = new p2(u, o, h.shape.length, f.shape.length, c, d), b = n.runWebGLProgram(g, [f, h, m], f.dtype), y = he({ inputs: { x: b }, backend: n, attrs: { shape: i } }); return n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(b), n.disposeIntermediateTensorInfo(m), y; } -var zJ = { kernelName: Do, backendName: "webgl", kernelFunc: PJ }; +var zJ = { kernelName: Fo, backendName: "webgl", kernelFunc: PJ }; var MJ = class { constructor(e, t, n) { this.variableNames = ["c", "a", "b"], this.outputShape = t; @@ -31266,7 +31153,7 @@ function LJ(e) { let { inputs: t, backend: n } = e, { condition: s, t: r, e: a } = t, i = new MJ(s.shape.length, r.shape, r.shape.length); return n.runWebGLProgram(i, [s, r, a], cn(r.dtype, a.dtype)); } -var BJ = { kernelName: Fo, backendName: "webgl", kernelFunc: LJ }; +var BJ = { kernelName: Oo, backendName: "webgl", kernelFunc: LJ }; var VJ = ` // Stable and Attracting Fixed Point (0, 1) for Normalized Weights. // see: https://arxiv.org/abs/1706.02515 @@ -31275,8 +31162,8 @@ var VJ = ` return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0); `; var WJ = Ke({ opSnippet: VJ }); -var UJ = { kernelName: Cl, backendName: "webgl", kernelFunc: WJ }; -var GJ = iu + ` +var UJ = { kernelName: Nl, backendName: "webgl", kernelFunc: WJ }; +var GJ = ou + ` return 1.0 / (1.0 + exp(-1.0 * x)); `; var HJ = ` @@ -31297,8 +31184,8 @@ var KJ = ` return sign(x); `; var XJ = Ke({ opSnippet: KJ }); -var YJ = { kernelName: Nl, backendName: "webgl", kernelFunc: XJ }; -var QJ = iu + ` +var YJ = { kernelName: Tl, backendName: "webgl", kernelFunc: XJ }; +var QJ = ou + ` return sin(x); `; var ZJ = Ke({ opSnippet: QJ }); @@ -31308,7 +31195,7 @@ var eee = ` return (e2x - 1.0 / e2x) / 2.0; `; var tee = Ke({ opSnippet: eee }); -var nee = { kernelName: Po, backendName: "webgl", kernelFunc: tee }; +var nee = { kernelName: zo, backendName: "webgl", kernelFunc: tee }; var see = ` float epsilon = 1.1920928955078125e-7; float threshold = log(epsilon) + 2.0; @@ -31331,7 +31218,7 @@ var see = ` return result; `; var ree = Ke({ opSnippet: see }); -var aee = { kernelName: Tl, backendName: "webgl", kernelFunc: ree }; +var aee = { kernelName: $l, backendName: "webgl", kernelFunc: ree }; var iee = (e) => { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockShape: a, paddings: i } = s; w.assert(r.shape.length <= 4, () => "spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"); @@ -31342,7 +31229,7 @@ var iee = (e) => { let l = [], c = c2({ inputs: { x: r }, backend: n, attrs: { paddings: u, constantValue: 0 } }), p = S.getReshaped(c.shape, a, o, false), d = S.getPermuted(p.length, a.length, false), h = S.getReshapedPermuted(c.shape, a, o, false), f = he({ inputs: { x: c }, backend: n, attrs: { shape: p } }), m = qt({ inputs: { x: f }, backend: n, attrs: { perm: d } }), g = he({ inputs: { x: m }, backend: n, attrs: { shape: h } }); return l.push(c), l.push(f), l.push(m), l.forEach((b) => n.disposeIntermediateTensorInfo(b)), g; }; -var oee = { kernelName: zo, backendName: "webgl", kernelFunc: iee }; +var oee = { kernelName: Mo, backendName: "webgl", kernelFunc: iee }; function uee(e) { let { inputs: t, backend: n } = e, { indices: s, values: r, denseShape: a, defaultValue: i } = t; if (a.shape.length !== 1) @@ -31372,7 +31259,7 @@ function cee(e) { let i = Array.from(n.readSync(r.dataId)), o = n.readSync(s.dataId), u = Array.from(n.readSync(a.dataId)), [l, c, p] = uX(o, s.shape, s.dtype, i, u); return [n.makeTensorInfo(c, s.dtype, l), n.makeTensorInfo([p.length], a.dtype, new Int32Array(p))]; } -var dee = { kernelName: $l, backendName: "webgl", kernelFunc: cee }; +var dee = { kernelName: _l, backendName: "webgl", kernelFunc: cee }; function pee(e) { let { inputs: t, backend: n } = e, { data: s, indices: r, segmentIds: a } = t; if (s.shape.length < 1) @@ -31411,17 +31298,17 @@ function yee(e) { return u.map((d) => { let h = [...p]; h[o] = d; - let f = ou({ inputs: { x: r }, backend: n, attrs: { begin: c, size: h } }); + let f = uu({ inputs: { x: r }, backend: n, attrs: { begin: c, size: h } }); return c[o] += d, f; }); } -var vee = { kernelName: Mo, backendName: "webgl", kernelFunc: yee }; +var vee = { kernelName: Lo, backendName: "webgl", kernelFunc: yee }; var Tw = "return sqrt(x);"; var xee = Ke({ opSnippet: Tw, packedOpSnippet: Tw, cpuKernelImpl: lX }); var wee = { kernelName: ii, backendName: "webgl", kernelFunc: xee }; var kee = "return x * x;"; var Iee = Ke({ opSnippet: kee }); -var See = { kernelName: _l, backendName: "webgl", kernelFunc: Iee }; +var See = { kernelName: Al, backendName: "webgl", kernelFunc: Iee }; var $w = "return (a - b) * (a - b);"; var Cee = jt({ opSnippet: $w, packedOpSnippet: $w }); var Nee = { kernelName: li, backendName: "webgl", kernelFunc: Cee }; @@ -31459,7 +31346,7 @@ function Aee(e) { k = he({ inputs: { x: r }, backend: n, attrs: { shape: f } }); else if (g || b) { w.assert(r.shape.length >= 1, () => `Input must have rank at least 1, got: ${r.shape.length}`); - let N = wt.computeOutShape(y, v, x), E = ou({ inputs: { x: r }, backend: n, attrs: { begin: y, size: N } }); + let N = wt.computeOutShape(y, v, x), E = uu({ inputs: { x: r }, backend: n, attrs: { begin: y, size: N } }); k = he({ inputs: { x: E }, backend: n, attrs: { shape: f } }), n.disposeIntermediateTensorInfo(E); } else if (n.shouldExecuteOnCPU([r])) { let E = n.readSync(r.dataId), A = De(r.shape, r.dtype, E), P = cX(h, A, x, y); @@ -31471,7 +31358,7 @@ function Aee(e) { let T = he({ inputs: { x: k }, backend: n, attrs: { shape: f } }); return n.disposeIntermediateTensorInfo(k), T; } -var Eee = { kernelName: Lo, backendName: "webgl", kernelFunc: Aee }; +var Eee = { kernelName: Bo, backendName: "webgl", kernelFunc: Aee }; function Ree(e) { let { inputs: t, backend: n, attrs: s } = e, { separator: r, nGramWidths: a, leftPad: i, rightPad: o, padWidth: u, preserveShortSequences: l } = s, { data: c, dataSplits: p } = t, d = n.readSync(c.dataId), h = n.readSync(p.dataId), [f, m] = dX(d, h, r, a, i, o, u, l); return [n.makeTensorInfo([f.length], "string", f), n.makeTensorInfo(p.shape, "int32", m)]; @@ -31501,7 +31388,7 @@ function Pee(e) { var zee = { kernelName: _g, backendName: "webgl", kernelFunc: Pee }; var Mee = "return tan(x);"; var Lee = Ke({ opSnippet: Mee }); -var Bee = { kernelName: Bo, backendName: "webgl", kernelFunc: Lee }; +var Bee = { kernelName: Vo, backendName: "webgl", kernelFunc: Lee }; var Vee = ` float e2x = exp(-2.0 * abs(x)); return sign(x) * (1.0 - e2x) / (1.0 + e2x); @@ -31667,7 +31554,7 @@ function Xee(e) { k(K, Y, v.shape); } let T = v; - v = ou({ inputs: { x: v }, backend: n, attrs: { begin: 0, size: [m, a] } }), Ur(n, T); + v = uu({ inputs: { x: v }, backend: n, attrs: { begin: 0, size: [m, a] } }), Ur(n, T); let N = r2({ inputs: { x: g, indices: v }, backend: n, attrs: { axis: 1, batchDims: 1 } }); Ur(n, g); let E = l.slice(0, -1); @@ -31675,7 +31562,7 @@ function Xee(e) { let A = N; return N = he({ inputs: { x: N }, attrs: { shape: E }, backend: n }), Ur(n, A), [N, v]; } -var Yee = { kernelName: Vo, backendName: "webgl", kernelFunc: Xee }; +var Yee = { kernelName: Wo, backendName: "webgl", kernelFunc: Xee }; var Qee = class { constructor(e, t, n, s, r, a) { this.variableNames = ["Image", "Transforms"], this.outputShape = a; @@ -31816,10 +31703,10 @@ function Zee(e) { let { inputs: t, backend: n, attrs: s } = e, { image: r, transforms: a } = t, { interpolation: i, fillMode: o, fillValue: u, outputShape: l } = s, [c, p, d, h] = r.shape, [f, m] = l != null ? l : [p, d], g = [c, f, m, h], b = new Qee(p, d, i, o, u, g); return n.runWebGLProgram(b, [r, a], "float32"); } -var Jee = { kernelName: Wo, backendName: "webgl", kernelFunc: Zee }; +var Jee = { kernelName: Uo, backendName: "webgl", kernelFunc: Zee }; function ete(e) { let { inputs: t, attrs: n, backend: s } = e, { axis: r } = n, { x: a } = t; - tu(a, "unique"), console.warn("WARNING: ", "UI might be locked temporarily as data is being downloaded"); + nu(a, "unique"), console.warn("WARNING: ", "UI might be locked temporarily as data is being downloaded"); let i = s.readSync(a.dataId), { outputValues: o, outputShape: u, indices: l } = bX(i, r, a.shape, a.dtype); return [s.makeTensorInfo(u, a.dtype, o), s.makeTensorInfo([l.length], "int32", l)]; } @@ -31835,12 +31722,12 @@ function nte(e) { let f = new Array(u); for (let m = 0; m < f.length; m++) { d[a] = m; - let g = ou({ inputs: { x: i }, backend: n, attrs: { begin: d, size: h } }), b = he({ inputs: { x: g }, backend: n, attrs: { shape: l } }); + let g = uu({ inputs: { x: i }, backend: n, attrs: { begin: d, size: h } }), b = he({ inputs: { x: g }, backend: n, attrs: { shape: l } }); f[m] = b, p.push(g); } return p.forEach((m) => n.disposeIntermediateTensorInfo(m)), f; } -var ste = { kernelName: Uo, backendName: "webgl", kernelFunc: nte }; +var ste = { kernelName: Go, backendName: "webgl", kernelFunc: nte }; var rte = class { constructor(e, t) { this.variableNames = ["x", "segmentIds"]; @@ -31980,7 +31867,7 @@ function ate(e) { var ite = { kernelName: up, backendName: "webgl", kernelFunc: ate }; var ote = [d8, h8, g8, v8, w8, S8, N8, $8, R8, F8, z8, B8, U8, j8, Y8, Z8, eY, rY, iY, uY, pY, vY, wY, IY, _Y, EY, OY, qX, MY, UY, jY, JY, t9, s9, a9, o9, c9, h9, g9, y9, x9, k9, C9, T9, E9, D9, P9, L9, V9, H9, X9, J9, nQ, aQ, iQ, uQ, cQ, pQ, fQ, gQ, xQ, IQ, NQ, $Q, EQ, FQ, MQ, WQ, HX, GQ, VY, jQ, YQ, JQ, KX, sZ, oZ, lZ, hZ, gZ, xZ, IZ, TZ, EZ, FZ, PZ, BZ, WZ, GZ, KZ, YZ, ZZ, e7, n7, i7, c7, f7, k7, JX, N7, _7, R7, O7, CY, M7, B7, W7, H7, X7, YX, Q7, Z7, NY, y7, tJ, aJ, lJ, t8, hJ, gJ, xJ, IJ, TJ, _J, RJ, OJ, zJ, BJ, UJ, jJ, YJ, JJ, nee, bY, x7, aee, oee, lee, dee, hee, mee, bee, vee, wee, See, Nee, $ee, Eee, Dee, Oee, zee, v7, u8, Bee, Uee, qee, Yee, Jee, l8, tte, ste, ite, L7]; for (let e of ote) - Al(e); + El(e); var zs = X(); zs.registerFlag("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE", () => 15); zs.registerFlag("WEBGPU_CPU_FORWARD", () => true); @@ -32189,10 +32076,14 @@ var qte = `if (a < 0.0) { return 1.0/0.0; } var jte = "return f32(!(a >= 1.0));"; var Kte = "return -a;"; var Xte = "if (a < 0.0) { return uniforms.alpha * a; } return a;"; -var Yte = "if(a < 0.0) { return 0.0; } return a;"; -var Qte = "return clamp(a, 0.0, 6.0);"; -var Zte = "return clamp(a, vec4(0.0, 0.0, 0.0, 0.0), vec4(6.0, 6.0, 6.0, 6.0));"; -var Jte = ` +var Yte = ` + let aLessThanZero = vec4(a < vec4(0.0)); + return (aLessThanZero * (uniforms.alpha * a)) + ((vec4(1.0) - aLessThanZero) * a); +`; +var Qte = "if(a < 0.0) { return 0.0; } return a;"; +var Zte = "return clamp(a, 0.0, 6.0);"; +var Jte = "return clamp(a, vec4(0.0, 0.0, 0.0, 0.0), vec4(6.0, 6.0, 6.0, 6.0));"; +var ene = ` var resFloat = a * vec4(a >= vec4(0.0)); let isNaN = isnanVec4(a); @@ -32210,20 +32101,20 @@ var Jte = ` } return resFloat; `; -var ene = "return 1.0/sqrt(a);"; -var tne = "return 1.0 / (1.0 + exp(-1.0 * a));"; -var nne = "return sin(a);"; -var sne = ` +var tne = "return 1.0/sqrt(a);"; +var nne = "return 1.0 / (1.0 + exp(-1.0 * a));"; +var sne = "return sin(a);"; +var rne = ` let e2x = exp(a); return (e2x - 1.0 / e2x) / 2.0; `; -var rne = "return sqrt(a);"; -var ane = "return a * a;"; -var ine = ` +var ane = "return sqrt(a);"; +var ine = "return a * a;"; +var one = ` let e2x = exp(-2.0 * abs(a)); return sign(a) * (1.0 - e2x) / (1.0 + e2x); `; -var one = "return f32(i32((a)));"; +var une = "return f32(i32((a)));"; function Hr(e, t) { switch (e) { case 0: @@ -32251,27 +32142,27 @@ function Hr(e, t) { case 11: return Kte; case 14: - return Xte; + return t ? Yte : Xte; case 12: - return t ? Jte : Yte; + return t ? ene : Qte; case 13: - return t ? Zte : Qte; + return t ? Jte : Zte; case 15: - return ene; - case 18: return tne; - case 16: + case 18: return nne; - case 17: + case 16: return sne; - case 19: + case 17: return rne; - case 20: + case 19: return ane; - case 21: + case 20: return ine; - case 22: + case 21: return one; + case 22: + return une; default: throw new Error(`BinaryType ${e} is not implemented!`); } @@ -32290,12 +32181,12 @@ function Zs(e, t = false) { if (e === "prelu") return tc(14, t); if (e === "sigmoid") - return Hr(18); + return Hr(18, t); if (e === "leakyrelu") - return Hr(14); + return Hr(14, t); throw new Error(`Activation ${e} has not been implemented for the WebGPU backend.`); } -function une(e, t) { +function lne(e, t) { if (Math.max(...e) > 3) throw new Error("Cannot symbolically compute strides for rank > 4 tensor."); let n = e.length, s = e.map((a) => `${t}[${a}]`), r = new Array(n - 1); @@ -32340,7 +32231,7 @@ function Ue() { let index = getGlobalIndex(); `; } -function lne(e, t, n, s = false) { +function cne(e, t, n, s = false) { let r = []; if (r.push(` let workGroupSizeX = ${n.workGroupSize[0]}u; @@ -32398,10 +32289,10 @@ function lne(e, t, n, s = false) { }), a !== "" && r.push(` @group(0) @binding(${1 + n.variableNames.length}) var uniforms: Uniforms; `); - let [o, u] = mne(t.shape, n.dispatchLayout), l = [Ew, r.join(` -`), Rw(t.shape), o, cne(t.shape.length)]; - if (n.atomic || l.push(dne(t.shape, t.dtype, n.isVec4)), u === t.shape.length) { - let p = e.map((d) => pne(d, t.shape, n.isVec4, n.dispatchLayout.x.length === t.shape.length)).join(` + let [o, u] = gne(t.shape, n.dispatchLayout), l = [Ew, r.join(` +`), Rw(t.shape), o, dne(t.shape.length)]; + if (n.atomic || l.push(pne(t.shape, t.dtype, n.isVec4)), u === t.shape.length) { + let p = e.map((d) => hne(d, t.shape, n.isVec4, n.dispatchLayout.x.length === t.shape.length)).join(` `); l.push(p); } @@ -32456,7 +32347,7 @@ var Ew = ` return vec4(isnan(val[0]), isnan(val[1]), isnan(val[2]), isnan(val[3])); } `; -function cne(e) { +function dne(e) { let t = ""; switch (e) { case 0: @@ -32495,7 +32386,7 @@ function cne(e) { } return t; } -function dne(e, t, n) { +function pne(e, t, n) { let s = e.length, r = cd(t, n), a; if (n ? a = `fn setOutputAtIndex(flatIndex : i32, value : vec4) { result[flatIndex] = ${r}(value); @@ -32531,11 +32422,11 @@ function dne(e, t, n) { } return a; } -function pne(e, t, n, s) { - let r = hne(e, n); - return e.shape.length <= t.length && (r += fne(e, t, n, s)), r; +function hne(e, t, n, s) { + let r = fne(e, n); + return e.shape.length <= t.length && (r += mne(e, t, n, s)), r; } -function hne(e, t) { +function fne(e, t) { let n = e.name, s = e.shape.length, r = Wt(s), a = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = ["d0", "d1", "d2", "d3"].slice(0, s), o = i.map((c) => `${c} : i32`).join(", "); if (s < 1) return t ? ` @@ -32560,7 +32451,7 @@ function hne(e, t) { } `; } -function fne(e, t, n, s) { +function mne(e, t, n, s) { let r = e.name, a = r.charAt(0).toUpperCase() + r.slice(1), i = "get" + a + "ByOutput", o = e.shape.length, u = t.length, l = Wt(u); if (w.arraysEqual(e.shape, t) && s) return n ? ` @@ -32636,7 +32527,7 @@ function fne(e, t, n, s) { } `; } -function mne(e, t) { +function gne(e, t) { let { x: n, y: s = [], z: r = [] } = t, a = e.length; if (n.length === a) return [`fn getOutputCoords() -> ${Wt(a)}{ @@ -32651,7 +32542,7 @@ function mne(e, t) { if (u += h.length, h.length === 1) i += `let d${h[0]} = i32(globalId[${d}]);`; else { - let f = une(h, "uniforms.outShape"); + let f = lne(h, "uniforms.outShape"); i += `var index${d} = i32(globalId[${d}]);`; for (let m = 0; m < f.length; m++) i += `let d${h[m]} = index${d} / ${f[m]};`, m === f.length - 1 ? i += `let d${h[m + 1]} = index${d} - d${h[m]} * ${f[m]};` : i += `index${d} = index${d} - d${h[m]} * ${f[m]};`; @@ -32808,7 +32699,7 @@ function y2(e, t, n, s) { } }`; } -var gne = class { +var bne = class { constructor(e, t, n, s = null, r = null, a = null) { this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workGroupSize = [8, 8, 1], this.isVec4 = true, this.outputShape = t, this.dispatchLayout = { x: [2], y: [1], z: [0] }, t[1] === 1 ? this.elementsPerThread = [4, 1, 1] : this.elementsPerThread = [4, 4, 1], this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, this.elementsPerThread); let i = s != null, o = a != null; @@ -32954,7 +32845,7 @@ function $v(e, t) { } `; } -function bne(e) { +function yne(e) { return ` let TileSize = ${e[0] * 4}; var mm_Asub : array, ${e[0]}>; @@ -33069,11 +32960,11 @@ var v2 = class { ${s} setOutputAtCoords(batch, row, col, value); } - ${this.outputShape[1] > 1 ? $v([this.workPerThread, this.workPerThread, 1], this.workGroupSize) : bne(this.workGroupSize)} + ${this.outputShape[1] > 1 ? $v([this.workPerThread, this.workPerThread, 1], this.workGroupSize) : yne(this.workGroupSize)} `; } }; -function yne() { +function vne() { return ` var sumValues : array; ${Dr()} @@ -33107,7 +32998,7 @@ function yne() { } `; } -var vne = class { +var xne = class { constructor(e, t = false, n = false, s = null, r = null, a = null) { this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workGroupSize = [256, 1, 1], this.outputShape = e, this.dispatchLayout = { x: [], y: [1, 2], z: [0] }, this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize); let i = s != null, o = a != null; @@ -33151,11 +33042,11 @@ var vne = class { ${s} setOutputAtCoords(batch, row, col, value); } - ${yne()} + ${vne()} `; } }; -function xne(e) { +function wne(e) { let t = e[1] / 2, n = e[0], s = t > n ? t : n; return ` var mm_Asub1 : array, ${t}>; @@ -33246,7 +33137,7 @@ function xne(e) { } `; } -var wne = class { +var kne = class { constructor(e, t, n, s = null, r = null, a = null) { this.variableNames = ["A", "B"], this.uniforms = "dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.workGroupSize = [8, 16, 1], w.assert(e[1] <= 16 || t[2] <= 16, () => "This program can be only used when A width or B Height are small"), this.outputShape = n, this.dispatchLayout = { x: [2], y: [1], z: [0] }, this.dispatch = [Math.ceil(n[2] / this.workGroupSize[0]), Math.ceil(n[1] * 2 / this.workGroupSize[1]), n[0]]; let i = s != null; @@ -33295,7 +33186,7 @@ var wne = class { setOutputAtCoords(batch, row, col, value); } } - ${xne(this.workGroupSize)} + ${wne(this.workGroupSize)} `; } }; @@ -33303,12 +33194,12 @@ function Me(e) { let { inputs: t, attrs: n } = e, { x: s } = t, { shape: r } = n, a = w.sizeFromShape(s.shape), i = w.inferFromImplicitShape(r, a), o = w.sizeFromShape(i); return w.assert(a === o, () => `The new shape (${i}) has ${o} elements and the old shape (${s.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`), e.backend.incRef(s.dataId), { dataId: s.dataId, shape: i, dtype: s.dtype }; } -var kne = { kernelName: Ao, backendName: "webgpu", kernelFunc: Me }; +var Ine = { kernelName: Eo, backendName: "webgpu", kernelFunc: Me }; function _v({ a: e, b: t, transposeA: n, transposeB: s, backend: r, bias: a = null, preluActivationWeights: i = null, leakyreluAlpha: o = 0, activation: u = null }) { - let l = e.shape.length, c = t.shape.length, p = n ? e.shape[l - 2] : e.shape[l - 1], d = s ? t.shape[c - 1] : t.shape[c - 2], h = n ? e.shape[l - 1] : e.shape[l - 2], f = s ? t.shape[c - 2] : t.shape[c - 1], m = e.shape.slice(0, -2), g = t.shape.slice(0, -2), b = w.sizeFromShape(m), y = w.sizeFromShape(g), x = qo.assertAndGetBroadcastShape(e.shape.slice(0, -2), t.shape.slice(0, -2)).concat([h, f]); + let l = e.shape.length, c = t.shape.length, p = n ? e.shape[l - 2] : e.shape[l - 1], d = s ? t.shape[c - 1] : t.shape[c - 2], h = n ? e.shape[l - 1] : e.shape[l - 2], f = s ? t.shape[c - 2] : t.shape[c - 1], m = e.shape.slice(0, -2), g = t.shape.slice(0, -2), b = w.sizeFromShape(m), y = w.sizeFromShape(g), x = jo.assertAndGetBroadcastShape(e.shape.slice(0, -2), t.shape.slice(0, -2)).concat([h, f]); w.assert(p === d, () => `Error in matMul: inner shapes (${p}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${s} must match.`); let k = n ? [b, p, h] : [b, h, p], T = s ? [y, f, d] : [y, d, f], N = Me({ inputs: { x: e }, backend: r, attrs: { shape: k } }), E = Me({ inputs: { x: t }, backend: r, attrs: { shape: T } }), A = [N, E], P = Math.max(b, y), R = p % 4 === 0 && f % 4 === 0 && !n && !s && f >= 32, F; - h * f <= 32 ? F = new vne([P, h, f], n, s, a, u, i) : !n && !s && (h <= 16 && (f <= 512 || d >= 2 * f) || f <= 16 && (h <= 512 || p >= 2 * h)) ? F = new wne(k, T, [P, h, f], a, u, i) : R ? F = new gne(k, [P, h, f], X().get("WEBGPU_MATMUL_WORK_PER_THREAD"), a, u, i) : F = new v2(k, [P, h, f], X().get("WEBGPU_MATMUL_WORK_PER_THREAD"), n, s, a, u, i); + h * f <= 32 ? F = new xne([P, h, f], n, s, a, u, i) : !n && !s && (h <= 16 && (f <= 512 || d >= 2 * f) || f <= 16 && (h <= 512 || p >= 2 * h)) ? F = new kne(k, T, [P, h, f], a, u, i) : R ? F = new bne(k, [P, h, f], X().get("WEBGPU_MATMUL_WORK_PER_THREAD"), a, u, i) : F = new v2(k, [P, h, f], X().get("WEBGPU_MATMUL_WORK_PER_THREAD"), n, s, a, u, i); let $ = [N, E]; a && $.push(a), i && $.push(i); let z = [{ type: "int32", data: [h] }, { type: "int32", data: [f] }, { type: "int32", data: [p] }]; @@ -33319,11 +33210,11 @@ function _v({ a: e, b: t, transposeA: n, transposeB: s, backend: r, bias: a = nu r.disposeData(K.dataId); return q; } -function Ine(e) { +function Sne(e) { let { inputs: t, backend: n, attrs: s } = e, { a: r, b: a, bias: i, preluActivationWeights: o } = t, { transposeA: u, transposeB: l, activation: c, leakyreluAlpha: p } = s; return _v({ a: r, b: a, transposeA: u, transposeB: l, backend: n, bias: i, preluActivationWeights: o, leakyreluAlpha: p, activation: c }); } -var Sne = { kernelName: ra, backendName: "webgpu", kernelFunc: Ine }; +var Cne = { kernelName: ra, backendName: "webgpu", kernelFunc: Sne }; var Dw = class { constructor(e, t, n) { this.variableNames = ["AReal", "AImag", "BReal", "BImag"], this.workGroupSize = [128, 1, 1], this.size = true, this.outputShape = S.assertAndGetBroadcastShape(t, n), this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = `binaryOpComplex_${e}`, this.op = e; @@ -33347,7 +33238,7 @@ var Dw = class { `; } }; -var Cne = class { +var Nne = class { constructor(e, t, n, s) { this.variableNames = ["A", "B"], this.size = true; let r = 256; @@ -33385,7 +33276,7 @@ var Cne = class { `; } }; -var Nne = class { +var Tne = class { constructor(e, t, n) { this.variableNames = ["A", "B"], this.workPerThread = 4, this.isVec4 = true, this.size = true; let s = 128; @@ -33429,20 +33320,20 @@ var x2 = class { }; function Fw(e, t, n) { if (w.arraysEqual(t, n) && w.sizeFromShape(t) % 4 === 0) - return new Nne(e, t, n); + return new Tne(e, t, n); let r = t.length === 1 && n.length > 1 && t[0] < 1024, a = n.length === 1 && t.length > 1 && n[0] < 1024; - return r || a ? new Cne(e, t, n, a) : new x2(e, t, n); + return r || a ? new Nne(e, t, n, a) : new x2(e, t, n); } function es(e) { let { inputs: t } = e, { x: n } = t; return e.backend.incRef(n.dataId), { dataId: n.dataId, shape: n.shape, dtype: n.dtype }; } -var Tne = { kernelName: Ba, backendName: "webgpu", kernelFunc: es }; -function uu(e) { +var $ne = { kernelName: Ba, backendName: "webgpu", kernelFunc: es }; +function lu(e) { let { inputs: t, backend: n } = e, { real: s, imag: r } = t, a = n.makeTensorInfo(s.shape, "complex64"), i = n.tensorMap.get(a.dataId), o = es({ inputs: { x: s }, backend: n }), u = es({ inputs: { x: r }, backend: n }); return i.complexTensorInfos = { real: o, imag: u }, a; } -var $ne = { kernelName: jd, backendName: "webgpu", kernelFunc: uu }; +var _ne = { kernelName: jd, backendName: "webgpu", kernelFunc: lu }; var nc = class { constructor(e, t) { this.variableNames = ["A"], this.size = true; @@ -33488,7 +33379,7 @@ function mn({ opSnippet: e, cpuKernelImpl: t, supportsComplex: n = false, dtype: let g = new Dw(17, i.shape, o.shape), b = new Dw(18, i.shape, o.shape), y = [{ dataId: p.complexTensorInfos.real.dataId, dtype: p.complexTensorInfos.real.dtype, shape: i.shape }, { dataId: p.complexTensorInfos.imag.dataId, dtype: p.complexTensorInfos.imag.dtype, shape: i.shape }, { dataId: d.complexTensorInfos.real.dataId, dtype: d.complexTensorInfos.real.dtype, shape: o.shape }, { dataId: d.complexTensorInfos.imag.dataId, dtype: d.complexTensorInfos.imag.dtype, shape: o.shape }]; h = u.runWebGPUProgram(g, y, "float32"), f = u.runWebGPUProgram(b, y, "float32"); } - let m = uu({ inputs: { real: h, imag: f }, backend: u }); + let m = lu({ inputs: { real: h, imag: f }, backend: u }); return u.disposeData(h.dataId), u.disposeData(f.dataId), m; } let l = s || cn(i.dtype, o.dtype); @@ -33500,12 +33391,12 @@ function mn({ opSnippet: e, cpuKernelImpl: t, supportsComplex: n = false, dtype: return u.runWebGPUProgram(c, [i, o], l); }; } -var { addImpl: _ne, ceilImpl: Ane, concatImpl: Ene, equalImpl: Rne, expImpl: Dne, expm1Impl: Fne, floorImpl: One, gatherNdImpl: Pne, gatherV2Impl: zne, greaterEqualImpl: Mne, greaterImpl: Lne, lessEqualImpl: Bne, lessImpl: Vne, logImpl: Wne, maxImpl: Une, maximumImpl: Gne, minimumImpl: Hne, multiplyImpl: qne, negImpl: jne, notEqualImpl: Kne, prodImpl: Xne, rangeImpl: Yne, rsqrtImpl: Qne, simpleAbsImpl: Zne, sliceImpl: Jne, stridedSliceImpl: ese, stringNGramsImpl: tse, subImpl: nse, tileImpl: sse, topKImpl: rse, transposeImpl: ase, uniqueImpl: zpe } = Zy; -var ise = Kt({ opType: 0, cpuKernelImpl: Zne }); -var ose = { kernelName: ao, backendName: "webgpu", kernelFunc: ise }; -var use = mn({ opSnippet: 1, cpuKernelImpl: _ne, supportsComplex: true }); -var lse = { kernelName: Ir, backendName: "webgpu", kernelFunc: use }; -var cse = class { +var { addImpl: Ane, ceilImpl: Ene, concatImpl: Rne, equalImpl: Dne, expImpl: Fne, expm1Impl: One, floorImpl: Pne, gatherNdImpl: zne, gatherV2Impl: Mne, greaterEqualImpl: Lne, greaterImpl: Bne, lessEqualImpl: Vne, lessImpl: Wne, logImpl: Une, maxImpl: Gne, maximumImpl: Hne, minimumImpl: qne, multiplyImpl: jne, negImpl: Kne, notEqualImpl: Xne, prodImpl: Yne, rangeImpl: Qne, rsqrtImpl: Zne, simpleAbsImpl: Jne, sliceImpl: ese, stridedSliceImpl: tse, stringNGramsImpl: nse, subImpl: sse, tileImpl: rse, topKImpl: ase, transposeImpl: ise, uniqueImpl: Mpe } = Zy; +var ose = Kt({ opType: 0, cpuKernelImpl: Jne }); +var use = { kernelName: io, backendName: "webgpu", kernelFunc: ose }; +var lse = mn({ opSnippet: 1, cpuKernelImpl: Ane, supportsComplex: true }); +var cse = { kernelName: Ir, backendName: "webgpu", kernelFunc: lse }; +var dse = class { constructor(e) { this.workPerThread = 4, this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e[0], this.variableNames = e.map((t, n) => `T${n}`), this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]), this.shaderKey = "addN"; } @@ -33530,14 +33421,14 @@ var cse = class { `; } }; -function dse(e) { +function pse(e) { let { inputs: t, backend: n } = e, s = t; if (s.length === 1) return es({ inputs: { x: s[0] }, backend: n }); - let r = s.map((o) => o.dtype).reduce((o, u) => cn(o, u)), a = s.map((o) => o.shape), i = new cse(a); + let r = s.map((o) => o.dtype).reduce((o, u) => cn(o, u)), a = s.map((o) => o.shape), i = new dse(a); return n.runWebGPUProgram(i, s, r); } -var pse = { kernelName: ka, backendName: "webgpu", kernelFunc: dse }; +var hse = { kernelName: ka, backendName: "webgpu", kernelFunc: pse }; var w2 = class { constructor(e, t, n) { this.workGroupSize = [64, 1, 1], this.variableNames = ["x"], this.uniforms = "axis : i32, infinityValue : f32,", this.size = true; @@ -33631,7 +33522,7 @@ var w2 = class { `; } }; -var hse = class { +var fse = class { constructor(e, t) { this.variableNames = ["A"], this.workGroupSize = [16, 16, 1]; let n = new Array(e.length); @@ -33665,7 +33556,7 @@ var hse = class { `; } }; -var fse = class { +var mse = class { constructor(e, t) { this.variableNames = ["A"], this.workPerThread = 4, this.workGroupSize = [64, 1, 1], this.size = true; let n = new Array(e.length); @@ -33674,7 +33565,7 @@ var fse = class { this.outputShape = n, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]), this.newDim = t, this.shaderKey = `transpose_${t}`; } getUserCode() { - let e = Wt(this.outputShape.length), t = mse(this.newDim); + let e = Wt(this.outputShape.length), t = gse(this.newDim); return ` ${Ue()} @@ -33690,7 +33581,7 @@ var fse = class { `; } }; -function mse(e) { +function gse(e) { let t = e.length; if (t > 4) throw Error(`Transpose for rank ${t} is not yet supported`); @@ -33704,31 +33595,31 @@ function wi(e) { for (let c = 0; c < u.length; c++) u[c] = r.shape[a[c]]; if (n.shouldExecuteOnCPU([r])) { - let p = i.tensorMap.get(r.dataId).values, d = ase(p, r.shape, r.dtype, a, u); + let p = i.tensorMap.get(r.dataId).values, d = ise(p, r.shape, r.dtype, a, u); return n.makeTensorInfo(u, r.dtype, d); } if (r.shape.length === 2 && w.arraysEqual(a, [1, 0])) { - let c = new hse(r.shape, a); + let c = new fse(r.shape, a); return i.runWebGPUProgram(c, [r], r.dtype); } - let l = new fse(r.shape, a); + let l = new mse(r.shape, a); return i.runWebGPUProgram(l, [r], r.dtype); } -var gse = { kernelName: pi, backendName: "webgpu", kernelFunc: wi }; -function bse(e) { +var bse = { kernelName: pi, backendName: "webgpu", kernelFunc: wi }; +function yse(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a } = s, i = w.parseAxisParam(a, r.shape), o = S.getAxesPermutation(i, r.shape.length), u = r, l = []; o != null && (u = wi({ inputs: { x: r }, backend: n, attrs: { perm: o } }), l.push(u), i = S.getInnerMostAxes(i.length, u.shape.length)), S.assertAxesAreInnerMostDims("argMax", [i[0]], u.shape.length); let c = new w2(u.shape, i[0], "max"), p = [{ type: "int32", data: [i[0]] }, { type: "float32", data: [Number.NEGATIVE_INFINITY] }], d = n.runWebGPUProgram(c, [u], "int32", p); return l.forEach((h) => n.disposeData(h.dataId)), d; } -var yse = { kernelName: Ia, backendName: "webgpu", kernelFunc: bse }; -function vse(e) { +var vse = { kernelName: Ia, backendName: "webgpu", kernelFunc: yse }; +function xse(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a } = s, i = w.parseAxisParam(a, r.shape), o = S.getAxesPermutation(i, r.shape.length), u = r, l = []; o != null && (u = wi({ inputs: { x: r }, backend: n, attrs: { perm: o } }), l.push(u), i = S.getInnerMostAxes(i.length, u.shape.length)), S.assertAxesAreInnerMostDims("argMin", [i[0]], u.shape.length); let c = new w2(u.shape, i[0], "min"), p = [{ type: "int32", data: [i[0]] }, { type: "float32", data: [Number.POSITIVE_INFINITY] }], d = n.runWebGPUProgram(c, [u], "int32", p); return l.forEach((h) => n.disposeData(h.dataId)), d; } -var xse = { kernelName: il, backendName: "webgpu", kernelFunc: vse }; +var wse = { kernelName: ol, backendName: "webgpu", kernelFunc: xse }; var k2 = class { constructor(e, t) { this.variableNames = ["x"], this.uniforms = "stride : vec2, pad : vec2, dilation : vec2, convDims : vec2, filterDims : vec2,", this.workGroupSize = [128, 1, 1], this.size = true, this.outputShape = e.outShape, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = `pool2D_${t}`, this.poolType = t; @@ -33796,25 +33687,25 @@ var I2 = class { `; } }; -function wse(e) { +function kse(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { filterSize: a, strides: i, pad: o, dimRoundingMode: u } = s, l = 1, c = S.computePool2DInfo(r.shape, a, i, l, o, u); if (c.filterWidth === 1 && c.filterHeight === 1 && w.arraysEqual(c.inShape, c.outShape)) return es({ inputs: { x: r }, backend: n }); let p, d = [{ type: "int32", data: [c.strideHeight, c.strideWidth] }]; return c.filterHeight === 1 && c.filterWidth === 1 ? p = new I2(c) : (p = new k2(c, "avg"), d.push({ type: "int32", data: [c.padInfo.top, c.padInfo.left] }, { type: "int32", data: [c.dilationHeight, c.dilationWidth] }, { type: "int32", data: [c.inHeight, c.inWidth] }, { type: "int32", data: [c.effectiveFilterHeight, c.effectiveFilterWidth] })), n.runWebGPUProgram(p, [r], r.dtype, d); } -var kse = { kernelName: Sa, backendName: "webgpu", kernelFunc: wse }; -function Ise(e) { +var Ise = { kernelName: Sa, backendName: "webgpu", kernelFunc: kse }; +function Sse(e) { let { inputs: t, backend: n, attrs: s } = e, { a: r, b: a } = t, { transposeA: i, transposeB: o } = s; return _v({ a: r, b: a, transposeA: i, transposeB: o, backend: n }); } -var Sse = { kernelName: Ca, backendName: "webgpu", kernelFunc: Ise }; -var Cse = class { +var Cse = { kernelName: Ca, backendName: "webgpu", kernelFunc: Sse }; +var Nse = class { constructor(e, t) { this.variableNames = ["source"], this.workPerThread = 1, this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = t, this.rank = t.length, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]), this.start = e, this.uniforms = `start : ${Wt(e.length)}, `, this.shaderKey = "slice"; } getUserCode() { - let e = Wt(this.rank), t = Nse(this.rank), n; + let e = Wt(this.rank), t = Tse(this.rank), n; return this.start.length === 1 ? n = this.outputShape.map((r, a) => "sourceLoc = uniforms.start + coords;") : n = this.outputShape.map((r, a) => `sourceLoc.${Km[a]} = uniforms.start[${a}] + coords.${Km[a]};`), ` ${Ue()} if (index < uniforms.size) { @@ -33829,40 +33720,40 @@ var Cse = class { } }; var Km = ["x", "y", "z", "w", "u", "v"]; -function Nse(e) { +function Tse(e) { if (e === 1) return "sourceLoc"; if (e <= 6) return Km.slice(0, e).map((t) => `sourceLoc.${t}`).join(","); throw Error(`Slicing for rank ${e} is not yet supported`); } -function lu(e) { +function cu(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { begin: a, size: i } = s, [o, u] = wt.parseSliceParams(r, a, i); if (wt.assertParamsValid(r, o, u), n.shouldExecuteOnCPU([r]) || r.dtype === "string") { - let p = n.tensorMap.get(r.dataId), d = Jne(p.values, o, u, r.shape, r.dtype); + let p = n.tensorMap.get(r.dataId), d = ese(p.values, o, u, r.shape, r.dtype); return n.makeTensorInfo(u, r.dtype, d); } if (w.sizeFromShape(u) === 0) return n.makeTensorInfo(u, r.dtype, []); - let l = new Cse(o, u), c = [{ type: "int32", data: o }]; + let l = new Nse(o, u), c = [{ type: "int32", data: o }]; return n.runWebGPUProgram(l, [r], r.dtype, c); } -var Tse = { kernelName: Oo, backendName: "webgpu", kernelFunc: lu }; -var $se = (e) => { +var $se = { kernelName: Po, backendName: "webgpu", kernelFunc: cu }; +var _se = (e) => { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockShape: a, crops: i } = s; w.assert(r.shape.length <= 4, () => "batchToSpaceND for rank > 4 with a WebGPU backend not implemented yet"); - let o = a.reduce((y, v) => y * v), u = S.getReshaped(r.shape, a, o), l = S.getPermuted(u.length, a.length), c = S.getReshapedPermuted(r.shape, a, o), p = S.getSliceBeginCoords(i, a.length), d = S.getSliceSize(c, i, a.length), h = [], f = Me({ inputs: { x: r }, backend: n, attrs: { shape: u } }), m = wi({ inputs: { x: f }, backend: n, attrs: { perm: l } }), g = Me({ inputs: { x: m }, backend: n, attrs: { shape: c } }), b = lu({ inputs: { x: g }, backend: n, attrs: { begin: p, size: d } }); + let o = a.reduce((y, v) => y * v), u = S.getReshaped(r.shape, a, o), l = S.getPermuted(u.length, a.length), c = S.getReshapedPermuted(r.shape, a, o), p = S.getSliceBeginCoords(i, a.length), d = S.getSliceSize(c, i, a.length), h = [], f = Me({ inputs: { x: r }, backend: n, attrs: { shape: u } }), m = wi({ inputs: { x: f }, backend: n, attrs: { perm: l } }), g = Me({ inputs: { x: m }, backend: n, attrs: { shape: c } }), b = cu({ inputs: { x: g }, backend: n, attrs: { begin: p, size: d } }); return h.push(f), h.push(m), h.push(g), h.forEach((y) => n.disposeData(y.dataId)), b; }; -var _se = { kernelName: io, backendName: "webgpu", kernelFunc: $se }; -var S2 = mn({ opSnippet: 10, dtype: "bool", cpuKernelImpl: Kne }); -var Ase = { kernelName: Io, backendName: "webgpu", kernelFunc: S2 }; +var Ase = { kernelName: oo, backendName: "webgpu", kernelFunc: _se }; +var S2 = mn({ opSnippet: 10, dtype: "bool", cpuKernelImpl: Xne }); +var Ese = { kernelName: So, backendName: "webgpu", kernelFunc: S2 }; function sc(e) { let { inputs: t, backend: n } = e, { input: s } = t, r = n.tensorMap.get(s.dataId); return es({ inputs: { x: r.complexTensorInfos.real }, backend: n }); } -var Ese = { kernelName: np, backendName: "webgpu", kernelFunc: sc }; -function Rse(e, t) { +var Rse = { kernelName: np, backendName: "webgpu", kernelFunc: sc }; +function Dse(e, t) { let n = new nc(e.shape, 22), s = t.runWebGPUProgram(n, [e], "int32"); return { dataId: s.dataId, shape: s.shape, dtype: s.dtype }; } @@ -33871,7 +33762,7 @@ function Xm(e) { if (a === "complex64") { if (r.dtype === "complex64") return es({ inputs: { x: r }, backend: n }); - let i = $t(r.shape), o = Xm({ inputs: { x: r }, backend: n, attrs: { dtype: "float32" } }), u = uu({ inputs: { real: o, imag: i }, backend: n }); + let i = $t(r.shape), o = Xm({ inputs: { x: r }, backend: n, attrs: { dtype: "float32" } }), u = lu({ inputs: { real: o, imag: i }, backend: n }); return i.dispose(), n.disposeData(o.dataId), u; } if (r.dtype === "complex64") { @@ -33883,17 +33774,17 @@ function Xm(e) { return { dataId: i.dataId, shape: i.shape, dtype: a }; } if (a === "int32") - return Rse(r, n); + return Dse(r, n); if (a === "bool") { let i = n.makeTensorInfo([], "bool", w.getTypedArrayFromDType("bool", 1)), u = S2({ inputs: { a: r, b: i }, backend: n }); return n.disposeData(i.dataId), u; } throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${a}`); } -var Dse = { kernelName: Na, backendName: "webgpu", kernelFunc: Xm }; -var Fse = Kt({ opType: 1, cpuKernelImpl: Ane }); -var Ose = { kernelName: Ta, backendName: "webgpu", kernelFunc: Fse }; -var Pse = class { +var Fse = { kernelName: Na, backendName: "webgpu", kernelFunc: Xm }; +var Ose = Kt({ opType: 1, cpuKernelImpl: Ene }); +var Pse = { kernelName: Ta, backendName: "webgpu", kernelFunc: Ose }; +var zse = class { constructor(e) { this.variableNames = ["A"], this.uniforms = "minVal : f32, maxVal : f32,", this.workPerThread = 4, this.workGroupSize = [64, 1, 1], this.isVec4 = true, this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]), this.shaderKey = "clipVec4"; } @@ -33917,7 +33808,7 @@ var Pse = class { `; } }; -var zse = class { +var Mse = class { constructor(e) { this.variableNames = ["A"], this.uniforms = "minVal : f32, maxVal : f32,", this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = "clip"; } @@ -33936,12 +33827,12 @@ var zse = class { `; } }; -function Mse(e) { +function Lse(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { clipValueMin: a, clipValueMax: i } = s, o, u = [{ type: "float32", data: [a] }, { type: "float32", data: [i] }]; - return w.sizeFromShape(r.shape) % 4 === 0 ? o = new Pse(r.shape) : o = new zse(r.shape), n.runWebGPUProgram(o, [r], r.dtype, u); + return w.sizeFromShape(r.shape) % 4 === 0 ? o = new zse(r.shape) : o = new Mse(r.shape), n.runWebGPUProgram(o, [r], r.dtype, u); } -var Lse = { kernelName: Sr, backendName: "webgpu", kernelFunc: Mse }; -var Bse = class { +var Bse = { kernelName: Sr, backendName: "webgpu", kernelFunc: Lse }; +var Vse = class { constructor(e) { this.uniforms = "", this.workPerThread = 4, this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = S.computeOutShape(e, 1), this.variableNames = e.map((t, n) => `T${n}`), this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]), this.offsetLength = e.length - 1; for (let t = 0; t < this.offsetLength; t++) @@ -33979,11 +33870,11 @@ function Zp(e) { let { inputs: t, backend: n } = e, { input: s } = t, r = n.tensorMap.get(s.dataId); return es({ inputs: { x: r.complexTensorInfos.imag }, backend: n }); } -var Vse = { kernelName: Zd, backendName: "webgpu", kernelFunc: Zp }; +var Wse = { kernelName: Zd, backendName: "webgpu", kernelFunc: Zp }; function Ym(e, t, n) { let s = e[0].dtype; if (s === "complex64") { - let h = e.map((y) => sc({ inputs: { input: y }, backend: n })), f = e.map((y) => Zp({ inputs: { input: y }, backend: n })), m = Ym(h, t, n), g = Ym(f, t, n), b = uu({ inputs: { real: m, imag: g }, backend: n }); + let h = e.map((y) => sc({ inputs: { input: y }, backend: n })), f = e.map((y) => Zp({ inputs: { input: y }, backend: n })), m = Ym(h, t, n), g = Ym(f, t, n), b = lu({ inputs: { real: m, imag: g }, backend: n }); return h.forEach((y) => n.disposeData(y.dataId)), f.forEach((y) => n.disposeData(y.dataId)), n.disposeData(m.dataId), n.disposeData(g.dataId), b; } let r = n.shouldExecuteOnCPU(e); @@ -33991,10 +33882,10 @@ function Ym(e, t, n) { let h = e.map((x) => { let k = w.sizeFromShape(x.shape.slice(t)); return Me({ inputs: { x }, backend: n, attrs: { shape: [-1, k] } }); - }), f = h.map((x) => ({ vals: n.readSync(x.dataId), shape: x.shape })), m = S.computeOutShape(h.map((x) => x.shape), 1), g = h[0].shape[0] === 1, b = Ene(f, m, s, g), y = S.computeOutShape(e.map((x) => x.shape), t), v = n.makeTensorInfo(y, s, b); + }), f = h.map((x) => ({ vals: n.readSync(x.dataId), shape: x.shape })), m = S.computeOutShape(h.map((x) => x.shape), 1), g = h[0].shape[0] === 1, b = Rne(f, m, s, g), y = S.computeOutShape(e.map((x) => x.shape), t), v = n.makeTensorInfo(y, s, b); return h.forEach((x) => n.disposeData(x.dataId)), v; } - let { tensors2D: a, outShape: i } = Wse(e, t, n), o = a.map((h) => h.shape), u = new Bse(o), l = [], c = new Array(o.length - 1); + let { tensors2D: a, outShape: i } = Use(e, t, n), o = a.map((h) => h.shape), u = new Vse(o), l = [], c = new Array(o.length - 1); if (c.length > 0) { c[0] = o[0][1], l.push({ type: "int32", data: [c[0]] }); for (let h = 1; h < c.length; h++) @@ -34005,7 +33896,7 @@ function Ym(e, t, n) { let d = Me({ inputs: { x: p }, backend: n, attrs: { shape: i } }); return n.disposeData(p.dataId), d; } -function Wse(e, t, n) { +function Use(e, t, n) { let s = S.computeOutShape(e.map((a) => a.shape), t); return { tensors2D: e.map((a) => Me({ inputs: { x: a }, backend: n, attrs: { shape: [w.sizeFromShape(a.shape.slice(0, t)), w.sizeFromShape(a.shape.slice(t))] } })), outShape: s }; } @@ -34019,8 +33910,8 @@ function C2(e) { let u = o.map((l) => l.shape); return S.assertParamsConsistent(u, a), Ym(o, a, n); } -var Use = { kernelName: oo, backendName: "webgpu", kernelFunc: C2 }; -var Gse = class { +var Gse = { kernelName: uo, backendName: "webgpu", kernelFunc: C2 }; +var Hse = class { constructor(e, t = false, n = null, s = false, r = false) { this.variableNames = ["x", "W"], this.uniforms = `filterDims : vec2, pad : vec2, stride : vec2, dilation : vec2, dimAOuter : i32, dimBOuter : i32, dimInner : i32,`, this.workGroupSize = [8, 8, 1], this.isVec4 = true, this.outputShape = e.outShape, w.assert(e.dataFormat === "channelsLast", () => "TODO: NCHW is unimplemented"), this.dispatchLayout = { x: [3], y: [1, 2], z: [0] }, this.outputShape[1] === 1 ? this.elementsPerThread = [4, 1, 1] : this.elementsPerThread = [4, 4, 1], this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, this.elementsPerThread), this.convInfo = e, this.addBias = t, this.activation = n, this.hasPreluActivationWeights = s, this.hasLeakyreluAlpha = r, this.addBias && this.variableNames.push("bias"), this.hasPreluActivationWeights && this.variableNames.push("preluActivationWeights"), this.hasLeakyreluAlpha && this.variableNames.push("leakyreluAlpha"), this.tileAOuter = this.outputShape[1] === 1 ? 1 : this.workGroupSize[1] * this.elementsPerThread[1], this.tileBOuter = this.workGroupSize[0] * this.elementsPerThread[0], this.tileInner = this.tileBOuter, [this.fitA, this.fitB] = this.getShapeFit(), this.shaderKey = `conv2DMMVec4_${this.activation}_${this.fitA}_${this.fitB}_${this.elementsPerThread}`; @@ -34147,7 +34038,7 @@ var Gse = class { `; } }; -var Hse = class { +var qse = class { constructor(e, t = false, n = null, s = false) { this.variableNames = ["x", "W"], this.uniforms = "filterDims : vec2, pad : vec2, stride : vec2, dilation : vec2, dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.outputShape = e.outShape, w.assert(e.dataFormat === "channelsLast", () => "TODO: NCHW is unimplemented"), this.dispatchLayout = { x: [3], y: [1, 2], z: [0] }, this.workGroupSize = Cv(this.dispatchLayout, this.outputShape), this.elementsPerThread = Nv(this.dispatchLayout, this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, this.elementsPerThread), t && this.variableNames.push("bias"), s && this.variableNames.push("preluActivationWeights"), this.convInfo = e, this.addBias = t, this.activation = n, this.hasPreluActivationWeights = s, [this.fitA, this.fitB] = this.getShapeFit(), this.shaderKey = `conv2DMM_${this.elementsPerThread}_${this.activation}_${this.fitA}_${this.fitB}`; } @@ -34222,7 +34113,7 @@ var Hse = class { `; } }; -var qse = class { +var jse = class { constructor(e, t = false, n = null, s = false) { this.variableNames = ["x", "W"], this.uniforms = "filterDims : vec2, pad : vec2, stride : vec2, dilation : vec2,", this.workGroupSize = [128, 1, 1], this.outputShape = e.outShape, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), w.assert(e.dataFormat === "channelsLast", () => "TODO: NCHW is unimplemented"), t && this.variableNames.push("bias"), s && this.variableNames.push("preluActivationWeights"), this.convInfo = e, this.addBias = t, this.activation = n, this.hasPreluActivationWeights = s, this.shaderKey = `conv2DNaive_${this.activation}`; } @@ -34291,7 +34182,7 @@ var qse = class { `; } }; -var jse = class { +var Kse = class { constructor(e, t) { this.variableNames = ["A"], this.uniforms = `pad : vec2, stride : vec2, dilation : vec2, outWidth : i32, itemsPerBlockRow : i32, inChannels : i32,`, this.workPerThread = 4, this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]), this.isChannelsLast = t, this.shaderKey = `im2col_${this.isChannelsLast}`; @@ -34330,7 +34221,7 @@ var jse = class { `; } }; -function Kse({ x: e, filter: t, convInfo: n, backend: s, bias: r = null, preluActivationWeights: a = null, leakyreluAlpha: i = 0, activation: o = null }) { +function Xse({ x: e, filter: t, convInfo: n, backend: s, bias: r = null, preluActivationWeights: a = null, leakyreluAlpha: i = 0, activation: o = null }) { let u = e.shape, l = n.dataFormat === "channelsLast", c = false, p = false, d = n.filterHeight === n.inHeight && n.filterWidth === n.inWidth && n.padInfo.type === "VALID", h, f; if (d) { let b = n.inHeight * n.inWidth * n.inChannels; @@ -34342,10 +34233,10 @@ function Kse({ x: e, filter: t, convInfo: n, backend: s, bias: r = null, preluAc let m = _v({ a: h, b: f, transposeA: c, transposeB: p, backend: s, bias: r, activation: o, preluActivationWeights: a, leakyreluAlpha: i }), g = Me({ inputs: { x: m }, backend: s, attrs: { shape: n.outShape } }); return s.disposeData(h.dataId), s.disposeData(f.dataId), s.disposeData(m.dataId), g; } -function Xse({ x: e, filter: t, convInfo: n, backend: s, bias: r = null, preluActivationWeights: a = null, leakyreluAlpha: i = 0, activation: o = null }) { +function Yse({ x: e, filter: t, convInfo: n, backend: s, bias: r = null, preluActivationWeights: a = null, leakyreluAlpha: i = 0, activation: o = null }) { let { filterWidth: u, filterHeight: l, inChannels: c, strideWidth: p, strideHeight: d, padInfo: h, outWidth: f, outHeight: m, dilationWidth: g, dilationHeight: b, dataFormat: y } = n, v = y === "channelsLast", x = u * l * c, k = m * f, T = [k, x], N = false, E = false, A = [], P = Me({ inputs: { x: e }, backend: s, attrs: { shape: e.shape.slice(1) } }), R = Me({ inputs: { x: t }, backend: s, attrs: { shape: [1, x, -1] } }); A.push(P), A.push(R); - let F = new jse(T, v), $ = [{ type: "int32", data: [h.left, h.top] }, { type: "int32", data: [p, d] }, { type: "int32", data: [g, b] }, { type: "int32", data: [f] }, { type: "int32", data: [c * u] }, { type: "int32", data: [c] }], z = s.runWebGPUProgram(F, [P], P.dtype, $), W = Me({ inputs: { x: z }, backend: s, attrs: { shape: [1, T[0], T[1]] } }); + let F = new Kse(T, v), $ = [{ type: "int32", data: [h.left, h.top] }, { type: "int32", data: [p, d] }, { type: "int32", data: [g, b] }, { type: "int32", data: [f] }, { type: "int32", data: [c * u] }, { type: "int32", data: [c] }], z = s.runWebGPUProgram(F, [P], P.dtype, $), W = Me({ inputs: { x: z }, backend: s, attrs: { shape: [1, T[0], T[1]] } }); A.push(z), A.push(W); let q = [1, T[0], T[1]], K = new v2(q, [1, k, n.outChannels], X().get("WEBGPU_MATMUL_WORK_PER_THREAD"), N, E, r, o, a), Y = q[1], Z = q[2], te = n.outChannels, ee = [{ type: "int32", data: [Y] }, { type: "int32", data: [te] }, { type: "int32", data: [Z] }], se = [W, R]; r && se.push(r), a && se.push(a), o === "leakyrelu" && ($.push({ type: "float32", data: [i] }), K.uniforms += " alpha : f32,"); @@ -34358,26 +34249,26 @@ function Xse({ x: e, filter: t, convInfo: n, backend: s, bias: r = null, preluAc function N2({ x: e, filter: t, convInfo: n, backend: s, bias: r = null, preluActivationWeights: a = null, leakyreluAlpha: i = 0, activation: o = null }) { let u = r != null, l = a != null, c; if (n.filterHeight === n.inHeight && n.filterWidth === n.inWidth && n.padInfo.type === "VALID" || n.filterHeight === 1 && n.filterWidth === 1 && n.dilationHeight === 1 && n.dilationWidth === 1 && n.strideHeight === 1 && n.strideWidth === 1 && (n.padInfo.type === "SAME" || n.padInfo.type === "VALID")) - return Kse({ x: e, filter: t, convInfo: n, backend: s, bias: r, activation: o, preluActivationWeights: a, leakyreluAlpha: i }); + return Xse({ x: e, filter: t, convInfo: n, backend: s, bias: r, activation: o, preluActivationWeights: a, leakyreluAlpha: i }); if (X().getBool("WEBGPU_CONV_SEPARATE_IM2COL_SHADER") && e.shape[0] === 1) - return Xse({ x: e, filter: t, convInfo: n, backend: s, bias: r, preluActivationWeights: a, leakyreluAlpha: i, activation: o }); - let d = X().getBool("WEBGPU_USE_NAIVE_CONV2D"), h = (n.inChannels % 4 === 0 || n.inChannels === 3 && n.padInfo.type === "VALID") && n.outChannels % 4 === 0 && n.outChannels >= 32, f = [n.padInfo.top, n.padInfo.left], m = [{ type: "int32", data: [n.filterHeight, n.filterWidth] }, { type: "int32", data: [...f] }, { type: "int32", data: [n.strideHeight, n.strideWidth] }, { type: "int32", data: [n.dilationHeight, n.dilationWidth] }]; + return Yse({ x: e, filter: t, convInfo: n, backend: s, bias: r, preluActivationWeights: a, leakyreluAlpha: i, activation: o }); + let d = X().getBool("WEBGPU_USE_NAIVE_CONV2D"), h = (n.inChannels % 4 === 0 || n.inChannels === 3 && n.padInfo.type === "VALID") && n.outChannels % 4 === 0, f = [n.padInfo.top, n.padInfo.left], m = [{ type: "int32", data: [n.filterHeight, n.filterWidth] }, { type: "int32", data: [...f] }, { type: "int32", data: [n.strideHeight, n.strideWidth] }, { type: "int32", data: [n.dilationHeight, n.dilationWidth] }]; if (d) - c = new qse(n, u, o, l); + c = new jse(n, u, o, l); else { - h ? c = new Gse(n, u, o, l) : c = new Hse(n, u, o, l); + h ? c = new Hse(n, u, o, l) : c = new qse(n, u, o, l); let b = n.outShape[1] * n.outShape[2], y = n.outShape[3], v = n.filterHeight * n.filterWidth * n.inShape[3]; m.push({ type: "int32", data: [b] }, { type: "int32", data: [y] }, { type: "int32", data: [v] }); } let g = [e, t]; return u && g.push(r), l && g.push(a), o === "leakyrelu" && (m.push({ type: "float32", data: [i] }), c.uniforms += " alpha : f32,"), s.runWebGPUProgram(c, g, e.dtype, m); } -function Yse(e) { +function Qse(e) { let { inputs: t, attrs: n, backend: s } = e, { x: r, filter: a } = t, { strides: i, pad: o, dataFormat: u, dilations: l, dimRoundingMode: c } = n, p = S.convertConv2DDataFormat(u), d = S.computeConv2DInfo(r.shape, a.shape, i, l, o, c, false, p); return N2({ x: r, filter: a, convInfo: d, backend: s }); } -var Qse = { kernelName: $a, backendName: "webgpu", kernelFunc: Yse }; -var Zse = class { +var Zse = { kernelName: $a, backendName: "webgpu", kernelFunc: Qse }; +var Jse = class { constructor(e) { this.variableNames = ["x", "W"], this.uniforms = "filterDims : vec2, pads : vec2, stride : vec2, outBackprop : vec4, dimAOuter : i32, dimBOuter : i32, dimInner : i32,", this.outputShape = e.inShape, w.assert(e.dataFormat === "channelsLast", () => "TODO: NCHW is unimplemented"), this.dispatchLayout = { x: [3], y: [1, 2], z: [0] }, this.workGroupSize = Cv(this.dispatchLayout, this.outputShape), this.elementsPerThread = Nv(this.dispatchLayout, this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, this.elementsPerThread), this.shaderKey = `conv2DDerInputMM_${this.elementsPerThread}`; } @@ -34439,7 +34330,7 @@ var Zse = class { `; } }; -var Jse = class { +var ere = class { constructor(e) { this.variableNames = ["dy", "W"], this.uniforms = "filterDims : vec2, pads : vec2, stride : vec2, outBackprop : vec4,", this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e.inShape, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.isChannelsLast = e.dataFormat === "channelsLast", this.shaderKey = `conv2DDerInput_${this.isChannelsLast}`; } @@ -34497,23 +34388,23 @@ var Jse = class { `; } }; -function ere(e) { +function tre(e) { let { inputs: t, backend: n, attrs: s } = e, { dy: r, filter: a } = t, { inputShape: i, strides: o, pad: u, dataFormat: l, dimRoundingMode: c } = s, p = S.convertConv2DDataFormat(l), d = S.computeConv2DInfo(i, a.shape, o, 1, u, c, false, p), h = [{ type: "int32", data: [d.filterHeight, d.filterWidth] }, { type: "int32", data: [d.filterHeight - 1 - d.padInfo.top, d.filterWidth - 1 - d.padInfo.left] }, { type: "int32", data: [d.strideHeight, d.strideWidth] }, { type: "int32", data: [d.batchSize, d.outHeight, d.outWidth, d.outChannels] }], f; if (X().getBool("WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE")) - f = new Jse(d); + f = new ere(d); else { - f = new Zse(d); + f = new Jse(d); let m = d.inShape[1] * d.inShape[2], g = d.inShape[3], b = d.filterHeight * d.filterWidth * d.outChannels; h.push({ type: "uint32", data: [m] }, { type: "uint32", data: [g] }, { type: "uint32", data: [b] }); } return n.runWebGPUProgram(f, [r, a], "float32", h); } -var tre = { kernelName: _a, backendName: "webgpu", kernelFunc: ere }; -var nre = Kt({ opType: 2 }); -var sre = { kernelName: Aa, backendName: "webgpu", kernelFunc: nre }; -var rre = Kt({ opType: 3 }); -var are = { kernelName: Ea, backendName: "webgpu", kernelFunc: rre }; -var ire = class { +var nre = { kernelName: _a, backendName: "webgpu", kernelFunc: tre }; +var sre = Kt({ opType: 2 }); +var rre = { kernelName: Aa, backendName: "webgpu", kernelFunc: sre }; +var are = Kt({ opType: 3 }); +var ire = { kernelName: Ea, backendName: "webgpu", kernelFunc: are }; +var ore = class { constructor(e, t, n, s) { this.variableNames = ["Image", "Boxes", "BoxInd"], this.uniforms = "extrapolationValue : f32,", this.workGroupSize = [64, 1, 1], this.size = true; let [r] = t; @@ -34580,12 +34471,12 @@ var ire = class { `; } }; -var ore = (e) => { - let { inputs: t, backend: n, attrs: s } = e, { image: r, boxes: a, boxInd: i } = t, { cropSize: o, method: u, extrapolationValue: l } = s, c = new ire(r.shape[3], a.shape, o, u), p = [{ type: "float32", data: [l] }]; +var ure = (e) => { + let { inputs: t, backend: n, attrs: s } = e, { image: r, boxes: a, boxInd: i } = t, { cropSize: o, method: u, extrapolationValue: l } = s, c = new ore(r.shape[3], a.shape, o, u), p = [{ type: "float32", data: [l] }]; return n.runWebGPUProgram(c, [r, a, i], "float32", p); }; -var ure = { kernelName: lo, backendName: "webgpu", kernelFunc: ore }; -var lre = class { +var lre = { kernelName: co, backendName: "webgpu", kernelFunc: ure }; +var cre = class { constructor(e, t) { this.variableNames = ["x"], this.workGroupSize = [64, 1, 1], this.size = true, this.uniforms = "blockSize : i32,", this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = `depthToSpace_${t}`, this.dataFormat = t; } @@ -34628,11 +34519,11 @@ var lre = class { return this.dataFormat === "NHWC" ? "getX(b, in_h, in_w, in_d)" : "getX(b, in_d, in_h, in_w)"; } }; -function cre(e) { - let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockSize: a, dataFormat: i } = s, o = r.shape[0], u = i === "NHWC" ? r.shape[1] : r.shape[2], l = i === "NHWC" ? r.shape[2] : r.shape[3], c = i === "NHWC" ? r.shape[3] : r.shape[1], p = u * a, d = l * a, h = c / (a * a), f = i === "NHWC" ? [o, p, d, h] : [o, h, p, d], m = [{ type: "int32", data: [a] }], g = new lre(f, i); +function dre(e) { + let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockSize: a, dataFormat: i } = s, o = r.shape[0], u = i === "NHWC" ? r.shape[1] : r.shape[2], l = i === "NHWC" ? r.shape[2] : r.shape[3], c = i === "NHWC" ? r.shape[3] : r.shape[1], p = u * a, d = l * a, h = c / (a * a), f = i === "NHWC" ? [o, p, d, h] : [o, h, p, d], m = [{ type: "int32", data: [a] }], g = new cre(f, i); return n.runWebGPUProgram(g, [r], r.dtype, m); } -var dre = { kernelName: co, backendName: "webgpu", kernelFunc: cre }; +var pre = { kernelName: po, backendName: "webgpu", kernelFunc: dre }; var T2 = class { constructor(e, t = false, n = null, s = false) { this.variableNames = ["x", "W"], this.uniforms = "pad : vec2, stride : vec2, dilation : vec2, inDims : vec2,", this.workGroupSize = [4, 4, 4], this.isVec4 = true, this.outputShape = e.outShape, this.dispatchLayout = { x: [0, 1], y: [2], z: [3] }, this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, [1, 4, 4]), w.assert(e.dataFormat === "channelsLast", () => "TODO: NCHW is unimplemented"), t && this.variableNames.push("bias"), s && this.variableNames.push("preluActivationWeights"), this.convInfo = e, this.addBias = t, this.activation = n, this.hasPreluActivation = s, this.shaderKey = `depthwise3x3_${n}`; @@ -34815,16 +34706,16 @@ var $2 = class { `; } }; -function pre(e) { +function hre(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, filter: a } = t, { strides: i, pad: o, dilations: u, dimRoundingMode: l } = s, c = u; c == null && (c = [1, 1]); let p = S.computeConv2DInfo(r.shape, a.shape, i, c, o, l, true), d = [{ type: "int32", data: [p.padInfo.top, p.padInfo.left] }, { type: "int32", data: [p.strideHeight, p.strideWidth] }, { type: "int32", data: [p.dilationHeight, p.dilationWidth] }, { type: "int32", data: [p.inHeight, p.inWidth] }], h; return p.batchSize === 1 && p.inHeight === p.outHeight && p.inWidth === p.outWidth && p.strideHeight === 1 && p.strideWidth === 1 && p.filterHeight === p.filterWidth && p.inChannels === p.outChannels && p.dilationHeight === 1 && p.dilationWidth === 1 && p.filterHeight === 3 && p.inChannels % 4 === 0 ? h = new T2(p) : (h = new $2(p), d.push({ type: "int32", data: [p.filterHeight] }, { type: "int32", data: [p.filterWidth] }, { type: "int32", data: [p.outChannels / p.inChannels] })), n.runWebGPUProgram(h, [r, a], r.dtype, d); } -var hre = { kernelName: Ra, backendName: "webgpu", kernelFunc: pre }; -var _2 = mn({ opSnippet: 0, cpuKernelImpl: qne, supportsComplex: true }); -var fre = { kernelName: Ya, backendName: "webgpu", kernelFunc: _2 }; -var mre = class { +var fre = { kernelName: Ra, backendName: "webgpu", kernelFunc: hre }; +var _2 = mn({ opSnippet: 0, cpuKernelImpl: jne, supportsComplex: true }); +var mre = { kernelName: Ya, backendName: "webgpu", kernelFunc: _2 }; +var gre = class { constructor(e, t) { this.workGroupSize = [64, 1, 1], this.variableNames = ["x"], this.uniforms = "reduceSize : i32,", this.size = true, this.inputShape = [e.batchSize, e.inSize]; let [n] = S.computeOutAndReduceShapes(this.inputShape, [1]); @@ -34895,18 +34786,18 @@ function rc(e, t, n, s, r) { let m = r.tensorMap.get(c.dataId).values; switch (s) { case "max": - let g = Une(m, w.sizeFromShape(d), h, e.dtype); + let g = Gne(m, w.sizeFromShape(d), h, e.dtype); f = r.makeTensorInfo(h, e.dtype, g); break; case "prod": - let { outVals: b, outShape: y, outDtype: v } = Xne(c.shape, c.dtype, m, u); + let { outVals: b, outShape: y, outDtype: v } = Yne(c.shape, c.dtype, m, u); f = r.makeTensorInfo(y, v, b); break; default: throw new Error(`${s} CPU implementation is not yet supported.`); } } else { - let m = w.sizeFromShape(d), b = w.sizeFromShape(c.shape) / m, y = { windowSize: m, inSize: m, batchSize: b, outSize: 1 }, v = s === "mean" ? "float32" : cp(e.dtype), x = [{ type: "int32", data: [m] }], k = new mre(y, s), T = r.runWebGPUProgram(k, [c], v, x); + let m = w.sizeFromShape(d), b = w.sizeFromShape(c.shape) / m, y = { windowSize: m, inSize: m, batchSize: b, outSize: 1 }, v = s === "mean" ? "float32" : cp(e.dtype), x = [{ type: "int32", data: [m] }], k = new gre(y, s), T = r.runWebGPUProgram(k, [c], v, x); i.push(T), f = Me({ inputs: { x: T }, attrs: { shape: h }, backend: r }); } return i.forEach((m) => r.disposeData(m.dataId)), f; @@ -34915,8 +34806,8 @@ function Av(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a, keepDims: i } = s; return rc(r, a, i, "sum", n); } -var gre = { kernelName: oi, backendName: "webgpu", kernelFunc: Av }; -function bre(e) { +var bre = { kernelName: oi, backendName: "webgpu", kernelFunc: Av }; +function yre(e) { let { inputs: t, backend: n, attrs: s } = e, { equation: r } = s, a = t, { allDims: i, summedDims: o, idDims: u } = S.decodeEinsumEquation(r, a.length); S.checkEinsumDimSizes(i.length, u, a); let { path: l, steps: c } = S.getEinsumComputePath(o, u), p = c.length, d = null, h = i.length, f = []; @@ -34935,21 +34826,21 @@ function bre(e) { m !== d && n.disposeData(m.dataId); return d; } -var yre = { kernelName: Qd, backendName: "webgpu", kernelFunc: bre }; -var vre = Kt({ opType: 4 }); -var xre = { kernelName: Fa, backendName: "webgpu", kernelFunc: vre }; -var wre = mn({ opSnippet: 4, dtype: "bool", cpuKernelImpl: Rne }); -var kre = { kernelName: po, backendName: "webgpu", kernelFunc: wre }; -var A2 = Kt({ opType: 5, cpuKernelImpl: Dne, dtype: "float32" }); -var Ire = { kernelName: Oa, backendName: "webgpu", kernelFunc: A2 }; +var vre = { kernelName: Qd, backendName: "webgpu", kernelFunc: yre }; +var xre = Kt({ opType: 4 }); +var wre = { kernelName: Fa, backendName: "webgpu", kernelFunc: xre }; +var kre = mn({ opSnippet: 4, dtype: "bool", cpuKernelImpl: Dne }); +var Ire = { kernelName: ho, backendName: "webgpu", kernelFunc: kre }; +var A2 = Kt({ opType: 5, cpuKernelImpl: Fne, dtype: "float32" }); +var Sre = { kernelName: Oa, backendName: "webgpu", kernelFunc: A2 }; function Qm(e) { let { inputs: t, attrs: n, backend: s } = e, { dim: r } = n, { input: a } = t, i = a.shape.length, o = a.shape.slice(), u = r; return r < 0 && (w.assert(-(i + 1) <= r, () => `Axis must be in the interval [${-(i + 1)}, ${i}]`), u = i + r + 1), o.splice(u, 0, 1), Me({ inputs: { x: a }, backend: s, attrs: { shape: o } }); } -var Sre = { kernelName: ho, backendName: "webgpu", kernelFunc: Qm }; -var Cre = Kt({ opType: 6, cpuKernelImpl: Fne }); -var Nre = { kernelName: fo, backendName: "webgpu", kernelFunc: Cre }; -var Tre = class { +var Cre = { kernelName: fo, backendName: "webgpu", kernelFunc: Qm }; +var Nre = Kt({ opType: 6, cpuKernelImpl: One }); +var Tre = { kernelName: mo, backendName: "webgpu", kernelFunc: Nre }; +var $re = class { constructor(e) { this.variableNames = [], this.outputShape = [], this.uniforms = "value : f32,", this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = "fill"; } @@ -34963,18 +34854,18 @@ var Tre = class { `; } }; -function cu(e) { +function du(e) { let { backend: t, attrs: n } = e, { shape: s, value: r } = n, { dtype: a } = n; if (a = a || w.inferDtype(r), a === "string") { let i = w.getArrayFromDType(a, w.sizeFromShape(s)); return i.fill(r), t.makeTensorInfo(s, a, i); } else { - let i = new Tre(s), o = [{ type: "float32", data: [r] }]; + let i = new $re(s), o = [{ type: "float32", data: [r] }]; return t.runWebGPUProgram(i, [], a, o); } } -var $re = { kernelName: fl, backendName: "webgpu", kernelFunc: cu }; -var _re = class { +var _re = { kernelName: ml, backendName: "webgpu", kernelFunc: du }; +var Are = class { constructor(e) { this.outputShape = [], this.variableNames = ["x"], this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = "flipLeftRight"; } @@ -34991,20 +34882,20 @@ var _re = class { `; } }; -var Are = { kernelName: mo, backendName: "webgpu", kernelFunc: ({ inputs: e, backend: t }) => { - let { image: n } = e, s = t, r = new _re(n.shape); +var Ere = { kernelName: go, backendName: "webgpu", kernelFunc: ({ inputs: e, backend: t }) => { + let { image: n } = e, s = t, r = new Are(n.shape); return s.runWebGPUProgram(r, [n], n.dtype); } }; -var Ere = Kt({ opType: 7, cpuKernelImpl: One }); -var Rre = { kernelName: Pa, backendName: "webgpu", kernelFunc: Ere }; -var Dre = mn({ opSnippet: 12, dtype: "int32" }); -var Fre = { kernelName: za, backendName: "webgpu", kernelFunc: Dre }; -var Ore = (e, t, n, s, r) => { +var Rre = Kt({ opType: 7, cpuKernelImpl: Pne }); +var Dre = { kernelName: Pa, backendName: "webgpu", kernelFunc: Rre }; +var Fre = mn({ opSnippet: 12, dtype: "int32" }); +var Ore = { kernelName: za, backendName: "webgpu", kernelFunc: Fre }; +var Pre = (e, t, n, s, r) => { let a = [s, ...n]; return r && a.push(r), e.createBindGroup({ layout: t, entries: a.map((i, o) => ({ binding: o, resource: i })) }); }; var E2 = (e, t, n, s, r, a = false) => { - let i = { dtype: r.dtype, shape: r.shape }, o = lne(s, i, t, a), u = e.createShaderModule({ code: o, label: t.constructor.name }); + let i = { dtype: r.dtype, shape: r.shape }, o = cne(s, i, t, a), u = e.createShaderModule({ code: o, label: t.constructor.name }); return e.createComputePipeline({ layout: n, compute: { module: u, entryPoint: "main" }, label: t.constructor.name }); }; function R2(e, t, n, s = "", r = "") { @@ -35027,9 +34918,9 @@ function Ow(e) { y = c.inputTexture.createView(); return n.runFromPixelsProgram(c, g.bufferInfo.buffer, f, y, l.dataId), l; } -var Pre = { kernelName: fd, backendName: "webgpu", kernelFunc: zre }; +var zre = { kernelName: fd, backendName: "webgpu", kernelFunc: Mre }; var Bi; -function zre(e) { +function Mre(e) { let { inputs: t, backend: n, attrs: s } = e, { pixels: r } = t, { numChannels: a } = s; if (r == null) throw new Error("pixels passed to tf.browser.fromPixels() can not be null"); @@ -35048,7 +34939,7 @@ function zre(e) { let m = n.makeTensorInfo(d, "int32"), g = n.tensorMap.get(m.dataId); return g.values = new Int32Array(f), n.maybeReleaseBuffer(m.dataId), n.uploadToGPU(m.dataId), m; } -var Mre = class { +var Lre = class { constructor(e, t, n, s, r) { this.uniforms = "varianceEpsilon : f32,", this.workGroupSize = [128, 1, 1], this.size = true, this.variableNames = ["x", "mean", "variance"], S.assertAndGetBroadcastShape(e, t), S.assertAndGetBroadcastShape(e, n), this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), s != null && (S.assertAndGetBroadcastShape(e, s), this.variableNames.push("offset")), r != null && (S.assertAndGetBroadcastShape(e, r), this.variableNames.push("scale")), this.offsetShape = s, this.scaleShape = r, this.shaderKey = "batchNorm"; } @@ -35072,20 +34963,20 @@ var Mre = class { `; } }; -var Lre = { kernelName: Ma, backendName: "webgpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { +var Bre = { kernelName: Ma, backendName: "webgpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { let { x: s, scale: r, offset: a, mean: i, variance: o } = e, { varianceEpsilon: u } = t, l = n, c = [s, i, o], p = null; a != null && (p = a.shape, c.push(a)); let d = null; r != null && (d = r.shape, c.push(r)); - let h = new Mre(s.shape, i.shape, o.shape, p, d), f = [{ type: "float32", data: [u] }]; + let h = new Lre(s.shape, i.shape, o.shape, p, d), f = [{ type: "float32", data: [u] }]; return l.runWebGPUProgram(h, c, s.dtype, f); } }; -function Bre(e) { +function Vre(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, filter: a, bias: i, preluActivationWeights: o } = t, { strides: u, pad: l, dataFormat: c, dilations: p, dimRoundingMode: d, activation: h, leakyreluAlpha: f } = s, m = S.convertConv2DDataFormat(c), g = S.computeConv2DInfo(r.shape, a.shape, u, p, l, d, false, m); return N2({ x: r, filter: a, convInfo: g, backend: n, bias: i, preluActivationWeights: o, leakyreluAlpha: f, activation: h }); } -var Vre = { kernelName: aa, backendName: "webgpu", kernelFunc: Bre }; -function Wre(e) { +var Wre = { kernelName: aa, backendName: "webgpu", kernelFunc: Vre }; +function Ure(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r, filter: a, bias: i, preluActivationWeights: o } = t, { strides: u, pad: l, dilations: c, dimRoundingMode: p, activation: d, leakyreluAlpha: h } = s, f = c; f == null && (f = [1, 1]), w.assert(S.eitherStridesOrDilationsAreOne(u, f), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${f}'`); let m = S.computeConv2DInfo(r.shape, a.shape, u, f, l, p, true), g = [r, a], b = i != null, y = o != null; @@ -35093,8 +34984,8 @@ function Wre(e) { let v = [{ type: "int32", data: [m.padInfo.top, m.padInfo.left] }, { type: "int32", data: [m.strideHeight, m.strideWidth] }, { type: "int32", data: [m.dilationHeight, m.dilationWidth] }, { type: "int32", data: [m.inHeight, m.inWidth] }], x; return m.batchSize === 1 && m.inHeight === m.outHeight && m.inWidth === m.outWidth && m.strideHeight === 1 && m.strideWidth === 1 && m.filterHeight === m.filterWidth && m.inChannels === m.outChannels && m.dilationHeight === 1 && m.dilationWidth === 1 && m.filterHeight === 3 && m.inChannels % 4 === 0 ? x = new T2(m, b, d, y) : (x = new $2(m, b, d, y), v.push({ type: "int32", data: [m.filterHeight] }, { type: "int32", data: [m.filterWidth] }, { type: "int32", data: [m.outChannels / m.inChannels] })), d === "leakyrelu" && (v.push({ type: "float32", data: [h] }), x.uniforms += " alpha : f32,"), n.runWebGPUProgram(x, g, "float32", v); } -var Ure = { kernelName: ia, backendName: "webgpu", kernelFunc: Wre }; -var Gre = class { +var Gre = { kernelName: ia, backendName: "webgpu", kernelFunc: Ure }; +var Hre = class { constructor(e, t) { this.variableNames = ["A", "indices"], this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = t, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = `gathernd_${e}`, this.sliceDim = e, this.uniforms = `sliceDim : i32, strides : ${Wt(e)},`; } @@ -35117,22 +35008,22 @@ var Gre = class { `; } }; -function Hre(e) { +function qre(e) { let { inputs: t, backend: n } = e, { params: s, indices: r } = t, a = r.shape, i = a[a.length - 1], o = w.sizeFromShape(s.shape), [u, l, c, p] = S.prepareAndValidate(s, r), d = Me({ inputs: { x: r }, backend: n, attrs: { shape: [l, i] } }), h = Me({ inputs: { x: s }, backend: n, attrs: { shape: [w.sizeFromShape(s.shape) / c, c] } }); if (n.shouldExecuteOnCPU([s, r]) || s.dtype === "string") { - let y = n.readSync(r.dataId), v = n.bufferSync(s), x = Pne(y, v, s.dtype, l, i, c, p, s.shape, o); + let y = n.readSync(r.dataId), v = n.bufferSync(s), x = zne(y, v, s.dtype, l, i, c, p, s.shape, o); return n.makeTensorInfo(u, s.dtype, x.values); } - let f = new Gre(i, [l, c]), m = [{ type: "int32", data: [i] }, { type: "int32", data: p }], g = n.runWebGPUProgram(f, [h, d], h.dtype, m), b = Me({ inputs: { x: g }, backend: n, attrs: { shape: u } }); + let f = new Hre(i, [l, c]), m = [{ type: "int32", data: [i] }, { type: "int32", data: p }], g = n.runWebGPUProgram(f, [h, d], h.dtype, m), b = Me({ inputs: { x: g }, backend: n, attrs: { shape: u } }); return n.disposeData(d.dataId), n.disposeData(h.dataId), n.disposeData(g.dataId), b; } -var qre = { kernelName: bo, backendName: "webgpu", kernelFunc: Hre }; -var jre = class { +var jre = { kernelName: yo, backendName: "webgpu", kernelFunc: qre }; +var Kre = class { constructor(e, t) { this.variableNames = ["A", "indices"], this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e.slice(), this.aShape = e, this.outputShape = t, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = "gather"; } getUserCode() { - let e = Kre(this.aShape); + let e = Xre(this.aShape); return ` ${Ue()} if (index < uniforms.size) { @@ -35145,7 +35036,7 @@ var jre = class { `; } }; -function Kre(e) { +function Xre(e) { let t = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], n = []; for (let s = 0; s < e.length; s++) s === 2 ? n.push("indexZ") : n.push(`${t[s]}`); @@ -35156,42 +35047,42 @@ function D2(e) { p.push(d), p.push(h); let f = [l.batchSize, l.outerSize, c / l.batchSize, l.sliceSize]; if (n.shouldExecuteOnCPU([r, a])) { - let v = n.tensorMap.get(h.dataId).values, x = De(h.shape, h.dtype, v), T = n.tensorMap.get(d.dataId).values, N = De(d.shape, d.dtype, T), E = zne(N, x, f); + let v = n.tensorMap.get(h.dataId).values, x = De(h.shape, h.dtype, v), T = n.tensorMap.get(d.dataId).values, N = De(d.shape, d.dtype, T), E = Mne(N, x, f); return p.forEach((A) => n.disposeData(A.dataId)), n.makeTensorInfo(l.outputShape, E.dtype, E.values); } - let m = new jre(d.shape, f), g = n.runWebGPUProgram(m, [d, h], d.dtype); + let m = new Kre(d.shape, f), g = n.runWebGPUProgram(m, [d, h], d.dtype); p.push(g); let b = Me({ inputs: { x: g }, backend: n, attrs: { shape: l.outputShape } }); return p.forEach((y) => n.disposeData(y.dataId)), b; } -var Xre = { kernelName: go, backendName: "webgpu", kernelFunc: D2 }; -var Yre = mn({ opSnippet: 5, cpuKernelImpl: Lne, dtype: "bool" }); -var Qre = { kernelName: yo, backendName: "webgpu", kernelFunc: Yre }; -var Zre = mn({ opSnippet: 6, dtype: "bool", cpuKernelImpl: Mne }); -var Jre = { kernelName: La, backendName: "webgpu", kernelFunc: Zre }; -function eae(e) { +var Yre = { kernelName: bo, backendName: "webgpu", kernelFunc: D2 }; +var Qre = mn({ opSnippet: 5, cpuKernelImpl: Bne, dtype: "bool" }); +var Zre = { kernelName: vo, backendName: "webgpu", kernelFunc: Qre }; +var Jre = mn({ opSnippet: 6, dtype: "bool", cpuKernelImpl: Lne }); +var eae = { kernelName: La, backendName: "webgpu", kernelFunc: Jre }; +function tae(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { alpha: a } = s, i = [{ type: "float32", data: [a] }], o = new nc(r.shape, 14); return o.uniforms = "alpha : f32,", n.runWebGPUProgram(o, [r], "float32", i); } -var tae = { kernelName: Va, backendName: "webgpu", kernelFunc: eae }; -var nae = mn({ opSnippet: 7, dtype: "bool", cpuKernelImpl: Vne }); -var sae = { kernelName: vo, backendName: "webgpu", kernelFunc: nae }; -var rae = mn({ opSnippet: 8, dtype: "bool", cpuKernelImpl: Bne }); -var aae = { kernelName: xo, backendName: "webgpu", kernelFunc: rae }; -var iae = Kt({ opType: 9, cpuKernelImpl: Wne }); -var oae = { kernelName: Wa, backendName: "webgpu", kernelFunc: iae }; -var uae = mn({ opSnippet: 9, dtype: "bool" }); -var lae = { kernelName: wo, backendName: "webgpu", kernelFunc: uae }; -var cae = Kt({ opType: 10 }); -var dae = { kernelName: vl, backendName: "webgpu", kernelFunc: cae }; +var nae = { kernelName: Va, backendName: "webgpu", kernelFunc: tae }; +var sae = mn({ opSnippet: 7, dtype: "bool", cpuKernelImpl: Wne }); +var rae = { kernelName: xo, backendName: "webgpu", kernelFunc: sae }; +var aae = mn({ opSnippet: 8, dtype: "bool", cpuKernelImpl: Vne }); +var iae = { kernelName: wo, backendName: "webgpu", kernelFunc: aae }; +var oae = Kt({ opType: 9, cpuKernelImpl: Une }); +var uae = { kernelName: Wa, backendName: "webgpu", kernelFunc: oae }; +var lae = mn({ opSnippet: 9, dtype: "bool" }); +var cae = { kernelName: ko, backendName: "webgpu", kernelFunc: lae }; +var dae = Kt({ opType: 10 }); +var pae = { kernelName: xl, backendName: "webgpu", kernelFunc: dae }; function F2(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { reductionIndices: a, keepDims: i } = s; return rc(r, a, i, "max", n); } -var pae = { kernelName: Ua, backendName: "webgpu", kernelFunc: F2 }; -var hae = mn({ opSnippet: 15, cpuKernelImpl: Gne }); -var fae = { kernelName: Ga, backendName: "webgpu", kernelFunc: hae }; -function mae(e) { +var hae = { kernelName: Ua, backendName: "webgpu", kernelFunc: F2 }; +var fae = mn({ opSnippet: 15, cpuKernelImpl: Hne }); +var mae = { kernelName: Ga, backendName: "webgpu", kernelFunc: fae }; +function gae(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { filterSize: a, strides: i, pad: o, dimRoundingMode: u } = s, l = 1, c = S.computePool2DInfo(r.shape, a, i, l, o, u), p, d = []; if (c.filterHeight === 1 && c.filterWidth === 1) { if (w.arraysEqual(c.inShape, c.outShape)) @@ -35201,20 +35092,20 @@ function mae(e) { p = new k2(c, "max"), d.push({ type: "int32", data: [c.strideHeight, c.strideWidth] }, { type: "int32", data: [c.padInfo.top, c.padInfo.left] }, { type: "int32", data: [c.dilationHeight, c.dilationWidth] }, { type: "int32", data: [c.inHeight, c.inWidth] }, { type: "int32", data: [c.effectiveFilterHeight, c.effectiveFilterWidth] }); return n.runWebGPUProgram(p, [r], r.dtype, d); } -var gae = { kernelName: Ha, backendName: "webgpu", kernelFunc: mae }; -function bae(e) { +var bae = { kernelName: Ha, backendName: "webgpu", kernelFunc: gae }; +function yae(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { keepDims: a, axis: i } = s; return rc(r, i, a, "mean", n); } -var yae = { kernelName: qa, backendName: "webgpu", kernelFunc: bae }; -function vae(e) { +var vae = { kernelName: qa, backendName: "webgpu", kernelFunc: yae }; +function xae(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a, keepDims: i } = s; return rc(r, a, i, "min", n); } -var xae = { kernelName: ja, backendName: "webgpu", kernelFunc: vae }; -var wae = mn({ opSnippet: 16, cpuKernelImpl: Hne }); -var kae = { kernelName: Ka, backendName: "webgpu", kernelFunc: wae }; -var Iae = class { +var wae = { kernelName: ja, backendName: "webgpu", kernelFunc: xae }; +var kae = mn({ opSnippet: 16, cpuKernelImpl: qne }); +var Iae = { kernelName: Ka, backendName: "webgpu", kernelFunc: kae }; +var Sae = class { constructor(e, t, n) { this.uniforms = "", this.variableNames = ["x"], this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = t.map((s, r) => s[0] + e[r] + s[1]), this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.xShape = e, t.map((s, r) => { this.uniforms += ` pad${r} : vec2,`; @@ -35242,53 +35133,53 @@ var Iae = class { `; } }; -var Sae = { kernelName: Xa, backendName: "webgpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { - let { x: s } = e, { paddings: r, mode: a } = t, i = n, o = r.map((c) => ({ type: "int32", data: [c[0], c[1]] })), u = new Iae(s.shape, r, a); +var Cae = { kernelName: Xa, backendName: "webgpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { + let { x: s } = e, { paddings: r, mode: a } = t, i = n, o = r.map((c) => ({ type: "int32", data: [c[0], c[1]] })), u = new Sae(s.shape, r, a); return i.runWebGPUProgram(u, [s], s.dtype, o); } }; -function Cae(e) { +function Nae(e) { let { inputs: t, backend: n } = e, { x: s } = t; if (n.shouldExecuteOnCPU([s])) { - let a = n.tensorMap.get(s.dataId), [i, o] = jne(a.values, s.shape, s.dtype); + let a = n.tensorMap.get(s.dataId), [i, o] = Kne(a.values, s.shape, s.dtype); return n.makeTensorInfo(o, s.dtype, i); } let r = new nc(s.shape, 11); return n.runWebGPUProgram(r, [s], s.dtype); } -var Nae = { kernelName: ko, backendName: "webgpu", kernelFunc: Cae }; -function Tae(e) { +var Tae = { kernelName: Io, backendName: "webgpu", kernelFunc: Nae }; +function $ae(e) { console.warn("tf.nonMaxSuppression() in webgpu locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); let { inputs: t, backend: n, attrs: s } = e, { boxes: r, scores: a } = t, { maxOutputSize: i, iouThreshold: o, scoreThreshold: u } = s, l = n.readSync(r.dataId), c = n.readSync(a.dataId), { selectedIndices: p } = xs.nonMaxSuppressionV3Impl(l, c, i, o, u); return n.makeTensorInfo([p.length], "int32", new Int32Array(p)); } -var $ae = { kernelName: So, backendName: "webgpu", kernelFunc: Tae }; -function _ae(e) { +var _ae = { kernelName: Co, backendName: "webgpu", kernelFunc: $ae }; +function Aae(e) { console.warn("tf.nonMaxSuppression() in webgpu locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); let { inputs: t, backend: n, attrs: s } = e, { boxes: r, scores: a } = t, { maxOutputSize: i, iouThreshold: o, scoreThreshold: u, softNmsSigma: l } = s, c = n.readSync(r.dataId), p = n.readSync(a.dataId), d = i, h = o, f = u, m = l, { selectedIndices: g, selectedScores: b } = xs.nonMaxSuppressionV5Impl(c, p, d, h, f, m); return [n.makeTensorInfo([g.length], "int32", new Int32Array(g)), n.makeTensorInfo([b.length], "float32", new Float32Array(b))]; } -var Aae = { kernelName: Co, backendName: "webgpu", kernelFunc: _ae }; +var Eae = { kernelName: No, backendName: "webgpu", kernelFunc: Aae }; function Ld(e) { let { inputs: t, backend: n } = e, { x: s } = t; if (s.dtype === "complex64") { - let r = sc({ inputs: { input: s }, backend: n }), a = Ld({ inputs: { x: r }, backend: n }), i = Zp({ inputs: { input: s }, backend: n }), o = Ld({ inputs: { x: i }, backend: n }), u = uu({ inputs: { real: a, imag: o }, backend: n }); + let r = sc({ inputs: { input: s }, backend: n }), a = Ld({ inputs: { x: r }, backend: n }), i = Zp({ inputs: { input: s }, backend: n }), o = Ld({ inputs: { x: i }, backend: n }), u = lu({ inputs: { real: a, imag: o }, backend: n }); return n.disposeData(r.dataId), n.disposeData(a.dataId), n.disposeData(i.dataId), n.disposeData(o.dataId), u; } else - return cu({ attrs: { shape: s.shape, dtype: s.dtype, value: s.dtype === "string" ? "" : 0 }, backend: n }); + return du({ attrs: { shape: s.shape, dtype: s.dtype, value: s.dtype === "string" ? "" : 0 }, backend: n }); } -var Eae = { kernelName: Go, backendName: "webgpu", kernelFunc: Ld }; +var Rae = { kernelName: Ho, backendName: "webgpu", kernelFunc: Ld }; function O2(e) { let { inputs: t, backend: n } = e, { x: s } = t; if (s.dtype === "string") throw new Error("onesLike is not supported under string dtype"); if (s.dtype === "complex64") { - let r = sc({ inputs: { input: s }, backend: n }), a = O2({ inputs: { x: r }, backend: n }), i = Zp({ inputs: { input: s }, backend: n }), o = Ld({ inputs: { x: i }, backend: n }), u = uu({ inputs: { real: a, imag: o }, backend: n }); + let r = sc({ inputs: { input: s }, backend: n }), a = O2({ inputs: { x: r }, backend: n }), i = Zp({ inputs: { input: s }, backend: n }), o = Ld({ inputs: { x: i }, backend: n }), u = lu({ inputs: { real: a, imag: o }, backend: n }); return n.disposeData(r.dataId), n.disposeData(a.dataId), n.disposeData(i.dataId), n.disposeData(o.dataId), u; } else - return cu({ attrs: { shape: s.shape, dtype: s.dtype, value: 1 }, backend: n }); + return du({ attrs: { shape: s.shape, dtype: s.dtype, value: 1 }, backend: n }); } -var Rae = { kernelName: No, backendName: "webgpu", kernelFunc: O2 }; -function Dae(e) { +var Dae = { kernelName: To, backendName: "webgpu", kernelFunc: O2 }; +function Fae(e) { let { inputs: t, backend: n, attrs: s } = e, { axis: r } = s; if (t.length === 1) return Qm({ inputs: { input: t[0] }, backend: n, attrs: { dim: r } }); @@ -35302,8 +35193,8 @@ function Dae(e) { }), l = C2({ inputs: u, backend: n, attrs: { axis: r } }); return o.forEach((c) => n.disposeData(c.dataId)), l; } -var Fae = { kernelName: $o, backendName: "webgpu", kernelFunc: Dae }; -var Oae = class { +var Oae = { kernelName: _o, backendName: "webgpu", kernelFunc: Fae }; +var Pae = class { constructor(e, t) { this.variableNames = ["x"], this.uniforms = "constantValue : f32,", this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = t.map((n, s) => n[0] + e[s] + n[1]), this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), t.map((n, s) => { this.uniforms += ` pad${s} : vec2,`; @@ -35335,38 +35226,38 @@ var P2 = (e) => { return es({ inputs: { x: r }, backend: n }); if (w.sizeFromShape(r.shape) === 0) { let l = a.map((c, p) => c[0] + r.shape[p] + c[1]); - return cu({ backend: n, attrs: { shape: l, value: i, dtype: r.dtype } }); + return du({ backend: n, attrs: { shape: l, value: i, dtype: r.dtype } }); } let o = [{ type: "float32", data: [i] }]; a.map((l) => o.push({ type: "int32", data: [l[0], l[1]] })); - let u = new Oae(r.shape, a); + let u = new Pae(r.shape, a); return n.runWebGPUProgram(u, [r], r.dtype, o); }; -var Pae = { kernelName: Qa, backendName: "webgpu", kernelFunc: P2 }; -var zae = mn({ opSnippet: 13 }); -var Mae = { kernelName: Za, backendName: "webgpu", kernelFunc: zae }; -function Lae(e) { +var zae = { kernelName: Qa, backendName: "webgpu", kernelFunc: P2 }; +var Mae = mn({ opSnippet: 13 }); +var Lae = { kernelName: Za, backendName: "webgpu", kernelFunc: Mae }; +function Bae(e) { let { inputs: t, backend: n } = e, { x: s, alpha: r } = t, a = new x2(14, s.shape, r.shape); return n.runWebGPUProgram(a, [s, r], "float32"); } -var Bae = { kernelName: Ja, backendName: "webgpu", kernelFunc: Lae }; -function Vae(e) { +var Vae = { kernelName: Ja, backendName: "webgpu", kernelFunc: Bae }; +function Wae(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a, keepDims: i } = s; return rc(r, a, i, "prod", n); } -var Wae = { kernelName: _o, backendName: "webgpu", kernelFunc: Vae }; -var Uae = (e) => { - let { backend: t, attrs: n } = e, { start: s, stop: r, step: a, dtype: i } = n, o = Yne(s, r, a, i); +var Uae = { kernelName: Ao, backendName: "webgpu", kernelFunc: Wae }; +var Gae = (e) => { + let { backend: t, attrs: n } = e, { start: s, stop: r, step: a, dtype: i } = n, o = Qne(s, r, a, i); return t.makeTensorInfo([o.length], i, o); }; -var Gae = { kernelName: kl, backendName: "webgpu", kernelFunc: Uae }; +var Hae = { kernelName: Il, backendName: "webgpu", kernelFunc: Gae }; var z2 = mn({ opSnippet: 3 }); -var Hae = { kernelName: Da, backendName: "webgpu", kernelFunc: z2 }; -var qae = Kt({ opType: 12 }); -var jae = { kernelName: ei, backendName: "webgpu", kernelFunc: qae }; -var Kae = Kt({ opType: 13 }); -var Xae = { kernelName: ni, backendName: "webgpu", kernelFunc: Kae }; -var Yae = class { +var qae = { kernelName: Da, backendName: "webgpu", kernelFunc: z2 }; +var jae = Kt({ opType: 12 }); +var Kae = { kernelName: ei, backendName: "webgpu", kernelFunc: jae }; +var Xae = Kt({ opType: 13 }); +var Yae = { kernelName: ni, backendName: "webgpu", kernelFunc: Xae }; +var Qae = class { constructor(e, t, n) { this.variableNames = ["x"], this.uniforms = "adjustHeightWidth : vec2, halfPixelCenters : f32,", this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = [e[0], t, n, e[3]], this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = "resizeBilinear"; } @@ -35417,12 +35308,12 @@ var Yae = class { `; } }; -function Qae(e) { - let { inputs: t, backend: n, attrs: s } = e, { images: r } = t, { alignCorners: a, size: i, halfPixelCenters: o } = s, [u, l] = i, c = a && u > 1 ? 1 : 0, p = a && l > 1 ? 1 : 0, h = [{ type: "float32", data: [c, p] }, { type: "float32", data: [o ? 0.5 : 0] }], f = new Yae(r.shape, u, l); +function Zae(e) { + let { inputs: t, backend: n, attrs: s } = e, { images: r } = t, { alignCorners: a, size: i, halfPixelCenters: o } = s, [u, l] = i, c = a && u > 1 ? 1 : 0, p = a && l > 1 ? 1 : 0, h = [{ type: "float32", data: [c, p] }, { type: "float32", data: [o ? 0.5 : 0] }], f = new Qae(r.shape, u, l); return n.runWebGPUProgram(f, [r], "float32", h); } -var Zae = { kernelName: ti, backendName: "webgpu", kernelFunc: Qae }; -var Jae = class { +var Jae = { kernelName: ti, backendName: "webgpu", kernelFunc: Zae }; +var eie = class { constructor(e, t, n, s) { this.variableNames = ["x"], this.uniforms = "adjustHeightWidth : vec2, roundBase : f32,", this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = [e[0], t, n, e[3]], this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.halfPixelCenters = s, this.shaderKey = `resizeNearest_${s}`; } @@ -35462,12 +35353,12 @@ var Jae = class { `; } }; -function eie(e) { - let { inputs: t, backend: n, attrs: s } = e, { images: r } = t, { alignCorners: a, halfPixelCenters: i, size: o } = s, [u, l] = o, c = a && u > 1 ? 1 : 0, p = a && l > 1 ? 1 : 0, h = [{ type: "float32", data: [c, p] }, { type: "float32", data: [a ? 0.5 : 0] }], f = new Jae(r.shape, u, l, i); +function tie(e) { + let { inputs: t, backend: n, attrs: s } = e, { images: r } = t, { alignCorners: a, halfPixelCenters: i, size: o } = s, [u, l] = o, c = a && u > 1 ? 1 : 0, p = a && l > 1 ? 1 : 0, h = [{ type: "float32", data: [c, p] }, { type: "float32", data: [a ? 0.5 : 0] }], f = new eie(r.shape, u, l, i); return n.runWebGPUProgram(f, [r], r.dtype, h); } -var tie = { kernelName: Sl, backendName: "webgpu", kernelFunc: eie }; -var nie = class { +var nie = { kernelName: Cl, backendName: "webgpu", kernelFunc: tie }; +var sie = class { constructor(e, t) { this.outputShape = [], this.variableNames = ["x"], this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.uniforms = `centerX : f32, centerY : f32, sinRadians : f32, cosRadians : f32,`, this.shaderKey = "rotate", this.outputShape = e, typeof t == "number" ? (this.uniforms += " fillValue : f32,", this.fillSnippet = "var outputValue = uniforms.fillValue;", this.shaderKey += "_float") : (this.uniforms += " fillValue : vec3,", this.fillSnippet = "var outputValue = uniforms.fillValue[coords[3]];", this.shaderKey += "_vec3"); @@ -35497,13 +35388,13 @@ var nie = class { `; } }; -var sie = { kernelName: Ho, backendName: "webgpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { - let { image: s } = e, { radians: r, fillValue: a, center: i } = t, o = n, u = new nie(s.shape, a), [l, c] = S.getImageCenter(i, s.shape[1], s.shape[2]), p = [{ type: "float32", data: [l] }, { type: "float32", data: [c] }, { type: "float32", data: [Math.sin(r)] }, { type: "float32", data: [Math.cos(r)] }]; +var rie = { kernelName: qo, backendName: "webgpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { + let { image: s } = e, { radians: r, fillValue: a, center: i } = t, o = n, u = new sie(s.shape, a), [l, c] = S.getImageCenter(i, s.shape[1], s.shape[2]), p = [{ type: "float32", data: [l] }, { type: "float32", data: [c] }, { type: "float32", data: [Math.sin(r)] }, { type: "float32", data: [Math.cos(r)] }]; return typeof a == "number" ? p.push({ type: "float32", data: [Number.parseFloat(a.toFixed(2))] }) : p.push({ type: "float32", data: a }), o.runWebGPUProgram(u, [s], s.dtype, p); } }; -var rie = Kt({ opType: 15, cpuKernelImpl: Qne }); -var aie = { kernelName: si, backendName: "webgpu", kernelFunc: rie }; -var iie = class { +var aie = Kt({ opType: 15, cpuKernelImpl: Zne }); +var iie = { kernelName: si, backendName: "webgpu", kernelFunc: aie }; +var oie = class { constructor(e, t, n, s, r, a, i) { this.variableNames = ["updates", "indices"], this.workGroupSize = [64, 1, 1], this.atomic = true, this.outputShape = a, this.type = i, this.dispatchLayout = Be(e), this.dispatch = _e(this.dispatchLayout, e, this.workGroupSize), this.sliceDimGreaterThanOne = t > 1, this.shaderKey = `scatter_${n}_${s}_${this.sliceDimGreaterThanOne}_${i}`; let o = Wt(r.length); @@ -35555,15 +35446,15 @@ var iie = class { }`; } }; -function oie(e) { +function uie(e) { let { inputs: t, backend: n, attrs: s } = e, { indices: r, updates: a } = t, { shape: i } = s, { sliceRank: o, numUpdates: u, sliceSize: l, strides: c, outputSize: p } = S.calculateShapes(a, r, i), d = [p / l, l]; if (p === 0) return n.makeTensorInfo(i, r.dtype); - let h = Me({ inputs: { x: r }, backend: n, attrs: { shape: [u, o] } }), f = Me({ inputs: { x: a }, backend: n, attrs: { shape: [u, l] } }), m = f.dtype, g = cu({ backend: n, attrs: { shape: d, value: 0, dtype: m } }), b = w.sizeFromShape(f.shape), y = [{ type: "int32", data: [o] }, { type: "int32", data: c }, { type: "int32", data: [b] }], v = new iie(f.shape, o, h.shape.length, f.shape.length, c, d, m), x = n.runWebGPUProgram(v, [f, h], m, y, g), k = Me({ inputs: { x }, backend: n, attrs: { shape: i } }); + let h = Me({ inputs: { x: r }, backend: n, attrs: { shape: [u, o] } }), f = Me({ inputs: { x: a }, backend: n, attrs: { shape: [u, l] } }), m = f.dtype, g = du({ backend: n, attrs: { shape: d, value: 0, dtype: m } }), b = w.sizeFromShape(f.shape), y = [{ type: "int32", data: [o] }, { type: "int32", data: c }, { type: "int32", data: [b] }], v = new oie(f.shape, o, h.shape.length, f.shape.length, c, d, m), x = n.runWebGPUProgram(v, [f, h], m, y, g), k = Me({ inputs: { x }, backend: n, attrs: { shape: i } }); return n.disposeData(h.dataId), n.disposeData(f.dataId), n.disposeData(x.dataId), k; } -var uie = { kernelName: Do, backendName: "webgpu", kernelFunc: oie }; -var lie = class { +var lie = { kernelName: Fo, backendName: "webgpu", kernelFunc: uie }; +var cie = class { constructor(e, t, n) { this.variableNames = ["c", "a", "b"], this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = t, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.cRank = e, this.rank = n, this.shaderKey = "select"; } @@ -35594,25 +35485,25 @@ var lie = class { `; } }; -function cie(e) { - let { inputs: t, backend: n } = e, { condition: s, t: r, e: a } = t, i = new lie(s.shape.length, r.shape, r.shape.length); +function die(e) { + let { inputs: t, backend: n } = e, { condition: s, t: r, e: a } = t, i = new cie(s.shape.length, r.shape, r.shape.length); return n.runWebGPUProgram(i, [s, r, a], cn(r.dtype, a.dtype)); } -var die = { kernelName: Fo, backendName: "webgpu", kernelFunc: cie }; -var pie = Kt({ opType: 18 }); -var hie = { kernelName: ai, backendName: "webgpu", kernelFunc: pie }; -var fie = Kt({ opType: 16 }); -var mie = { kernelName: ri, backendName: "webgpu", kernelFunc: fie }; -var gie = Kt({ opType: 17 }); -var bie = { kernelName: Po, backendName: "webgpu", kernelFunc: gie }; -var M2 = mn({ opSnippet: 2, cpuKernelImpl: nse, supportsComplex: true }); -var yie = { kernelName: ci, backendName: "webgpu", kernelFunc: M2 }; -function vie(e) { +var pie = { kernelName: Oo, backendName: "webgpu", kernelFunc: die }; +var hie = Kt({ opType: 18 }); +var fie = { kernelName: ai, backendName: "webgpu", kernelFunc: hie }; +var mie = Kt({ opType: 16 }); +var gie = { kernelName: ri, backendName: "webgpu", kernelFunc: mie }; +var bie = Kt({ opType: 17 }); +var yie = { kernelName: zo, backendName: "webgpu", kernelFunc: bie }; +var M2 = mn({ opSnippet: 2, cpuKernelImpl: sse, supportsComplex: true }); +var vie = { kernelName: ci, backendName: "webgpu", kernelFunc: M2 }; +function xie(e) { let { inputs: t, backend: n, attrs: s } = e, { logits: r } = t, { dim: a } = s, i = w.parseAxisParam([a], r.shape), o = F2({ inputs: { x: r }, backend: n, attrs: { reductionIndices: i, keepDims: false } }), u = S.expandShapeToKeepDim(o.shape, i), l = Me({ inputs: { x: o }, backend: n, attrs: { shape: u } }), c = M2({ inputs: { a: r, b: l }, backend: n }), p = A2({ inputs: { x: c }, backend: n }), d = Av({ inputs: { x: p }, backend: n, attrs: { axis: i, keepDims: false } }), h = Me({ inputs: { x: d }, backend: n, attrs: { shape: u } }), f = z2({ inputs: { a: p, b: h }, backend: n }); return n.disposeData(o.dataId), n.disposeData(l.dataId), n.disposeData(c.dataId), n.disposeData(p.dataId), n.disposeData(d.dataId), n.disposeData(h.dataId), f; } -var xie = { kernelName: ui, backendName: "webgpu", kernelFunc: vie }; -var wie = (e) => { +var wie = { kernelName: ui, backendName: "webgpu", kernelFunc: xie }; +var kie = (e) => { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockShape: a, paddings: i } = s; w.assert(r.shape.length <= 4, () => "spaceToBatchND for rank > 4 with a WebGPU backend not implemented yet"); let o = a.reduce((b, y) => b * y), u = [[0, 0]]; @@ -35622,8 +35513,8 @@ var wie = (e) => { let l = [], c = P2({ inputs: { x: r }, backend: n, attrs: { paddings: u, constantValue: 0 } }), p = S.getReshaped(c.shape, a, o, false), d = S.getPermuted(p.length, a.length, false), h = S.getReshapedPermuted(c.shape, a, o, false), f = Me({ inputs: { x: c }, backend: n, attrs: { shape: p } }), m = wi({ inputs: { x: f }, backend: n, attrs: { perm: d } }), g = Me({ inputs: { x: m }, backend: n, attrs: { shape: h } }); return l.push(c), l.push(f), l.push(m), l.forEach((b) => n.disposeData(b.dataId)), g; }; -var kie = { kernelName: zo, backendName: "webgpu", kernelFunc: wie }; -var Iie = class { +var Iie = { kernelName: Mo, backendName: "webgpu", kernelFunc: kie }; +var Sie = class { constructor(e, t, n, s, r, a, i = true) { this.variableNames = ["updates", "indices", "defaultValue"], this.workGroupSize = [64, 1, 1], this.workPerThread = 4, this.size = true, this.outputShape = a, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]); let o = t > 1; @@ -35669,30 +35560,30 @@ var Iie = class { }`; } }; -function Sie(e) { - let { inputs: t, backend: n, attrs: s } = e, { sparseIndices: r, sparseValues: a, defaultValue: i } = t, { outputShape: o } = s, { sliceRank: u, numUpdates: l, strides: c, outputSize: p } = S.calculateShapes(a, r, o), d = false, h = [{ type: "int32", data: [l] }, { type: "int32", data: [u] }, { type: "int32", data: c }], f = new Iie(l, u, r.shape.length, a.shape.length, c, [p, 1], d), m = n.runWebGPUProgram(f, [a, r, i], a.dtype, h), g = Me({ inputs: { x: m }, backend: n, attrs: { shape: o } }); +function Cie(e) { + let { inputs: t, backend: n, attrs: s } = e, { sparseIndices: r, sparseValues: a, defaultValue: i } = t, { outputShape: o } = s, { sliceRank: u, numUpdates: l, strides: c, outputSize: p } = S.calculateShapes(a, r, o), d = false, h = [{ type: "int32", data: [l] }, { type: "int32", data: [u] }, { type: "int32", data: c }], f = new Sie(l, u, r.shape.length, a.shape.length, c, [p, 1], d), m = n.runWebGPUProgram(f, [a, r, i], a.dtype, h), g = Me({ inputs: { x: m }, backend: n, attrs: { shape: o } }); return n.disposeData(m.dataId), g; } -var Cie = { kernelName: ip, backendName: "webgpu", kernelFunc: Sie }; -function Nie(e) { +var Nie = { kernelName: ip, backendName: "webgpu", kernelFunc: Cie }; +function Tie(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { numOrSizeSplits: a, axis: i } = s, o = w.parseAxisParam(i, r.shape)[0], u = S.prepareSplitSize(r, a, o), l = r.shape.length, c = new Array(l).fill(0), p = r.shape.slice(); return u.map((d) => { let h = [...p]; h[o] = d; - let f = lu({ inputs: { x: r }, backend: n, attrs: { begin: c, size: h } }); + let f = cu({ inputs: { x: r }, backend: n, attrs: { begin: c, size: h } }); return c[o] += d, f; }); } -var Tie = { kernelName: Mo, backendName: "webgpu", kernelFunc: Nie }; -var $ie = Kt({ opType: 19 }); -var _ie = { kernelName: ii, backendName: "webgpu", kernelFunc: $ie }; -var Aie = { kernelName: _l, backendName: "webgpu", kernelFunc: ({ inputs: e, backend: t }) => { +var $ie = { kernelName: Lo, backendName: "webgpu", kernelFunc: Tie }; +var _ie = Kt({ opType: 19 }); +var Aie = { kernelName: ii, backendName: "webgpu", kernelFunc: _ie }; +var Eie = { kernelName: Al, backendName: "webgpu", kernelFunc: ({ inputs: e, backend: t }) => { let { x: n } = e, s = t, r = new nc(n.shape, 20); return s.runWebGPUProgram(r, [n], n.dtype); } }; -var Eie = mn({ opSnippet: 11 }); -var Rie = { kernelName: li, backendName: "webgpu", kernelFunc: Eie }; -var Die = class { +var Rie = mn({ opSnippet: 11 }); +var Die = { kernelName: li, backendName: "webgpu", kernelFunc: Rie }; +var Fie = class { constructor(e) { this.variableNames = ["x"], this.workPerThread = 1, this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize, [this.workPerThread, 1, 1]); let t = Wt(this.outputShape.length); @@ -35716,32 +35607,32 @@ var Die = class { `; } }; -function Fie(e) { +function Oie(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { begin: a, end: i, strides: o, beginMask: u, endMask: l, ellipsisMask: c, newAxisMask: p, shrinkAxisMask: d } = s, { finalShapeSparse: h, finalShape: f, isIdentity: m, sliceDim0: g, isSimpleSlice: b, begin: y, end: v, strides: x } = wt.sliceInfo(r.shape, a, i, o, u, l, c, p, d), k; if (m) k = Me({ inputs: { x: r }, backend: n, attrs: { shape: f } }); else if (g || b) { w.assert(r.shape.length >= 1, () => `Input must have rank at least 1, got: ${r.shape.length}`); - let T = wt.computeOutShape(y, v, x), N = lu({ inputs: { x: r }, backend: n, attrs: { begin: y, size: T } }); + let T = wt.computeOutShape(y, v, x), N = cu({ inputs: { x: r }, backend: n, attrs: { begin: y, size: T } }); k = Me({ inputs: { x: N }, backend: n, attrs: { shape: f } }), n.disposeData(N.dataId); } else if (n.shouldExecuteOnCPU([r])) { - let N = n.readSync(r.dataId), E = De(r.shape, r.dtype, N), A = ese(h, E, x, y); + let N = n.readSync(r.dataId), E = De(r.shape, r.dtype, N), A = tse(h, E, x, y); k = n.makeTensorInfo(f, r.dtype, A.values); } else { - let N = new Die(h), E = [{ type: "int32", data: y }, { type: "int32", data: x }], A = n.runWebGPUProgram(N, [r], r.dtype, E); + let N = new Fie(h), E = [{ type: "int32", data: y }, { type: "int32", data: x }], A = n.runWebGPUProgram(N, [r], r.dtype, E); k = Me({ inputs: { x: A }, backend: n, attrs: { shape: f } }), n.disposeData(A.dataId); } return k; } -var Oie = { kernelName: Lo, backendName: "webgpu", kernelFunc: Fie }; -function Pie(e) { - let { inputs: t, backend: n, attrs: s } = e, { separator: r, nGramWidths: a, leftPad: i, rightPad: o, padWidth: u, preserveShortSequences: l } = s, { data: c, dataSplits: p } = t, d = n.readSync(c.dataId), h = n.readSync(p.dataId), [f, m] = tse(d, h, r, a, i, o, u, l); +var Pie = { kernelName: Bo, backendName: "webgpu", kernelFunc: Oie }; +function zie(e) { + let { inputs: t, backend: n, attrs: s } = e, { separator: r, nGramWidths: a, leftPad: i, rightPad: o, padWidth: u, preserveShortSequences: l } = s, { data: c, dataSplits: p } = t, d = n.readSync(c.dataId), h = n.readSync(p.dataId), [f, m] = nse(d, h, r, a, i, o, u, l); return [n.makeTensorInfo([f.length], "string", f), n.makeTensorInfo(p.shape, "int32", m)]; } -var zie = { kernelName: op, backendName: "webgpu", kernelFunc: Pie }; -var Mie = Kt({ opType: 21 }); -var Lie = { kernelName: di, backendName: "webgpu", kernelFunc: Mie }; -var Bie = class { +var Mie = { kernelName: op, backendName: "webgpu", kernelFunc: zie }; +var Lie = Kt({ opType: 21 }); +var Bie = { kernelName: di, backendName: "webgpu", kernelFunc: Lie }; +var Vie = class { constructor(e, t) { this.variableNames = ["A"], this.workGroupSize = [64, 1, 1], this.size = true; let n = new Array(e.length); @@ -35750,7 +35641,7 @@ var Bie = class { this.outputShape = n, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.rank = this.outputShape.length, this.shaderKey = "tile"; } getUserCode() { - let e = Vie(this.rank, "uniforms."); + let e = Wie(this.rank, "uniforms."); return ` ${Ue()} if (index < uniforms.size) { @@ -35761,7 +35652,7 @@ var Bie = class { `; } }; -function Vie(e, t = "") { +function Wie(e, t = "") { if (e >= 5) throw Error(`Tile for rank ${e} is not yet supported`); if (e === 1) @@ -35771,17 +35662,17 @@ function Vie(e, t = "") { s.push(`(${n[r]} % ${t}aShape[${r}])`); return s.join(); } -function Wie(e) { +function Uie(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { reps: a } = s; if (n.shouldExecuteOnCPU([r]) || r.dtype === "string" || r.shape.length >= 5) { - let u = n.readSync(r.dataId), l = r.dtype === "string" ? u.map((d) => w.decodeString(d)) : u, c = De(r.shape, r.dtype, l), p = sse(c, a); + let u = n.readSync(r.dataId), l = r.dtype === "string" ? u.map((d) => w.decodeString(d)) : u, c = De(r.shape, r.dtype, l), p = rse(c, a); return n.makeTensorInfo(p.shape, p.dtype, p.values); } - let i = new Bie(r.shape, a); + let i = new Vie(r.shape, a); return n.runWebGPUProgram(i, [r], r.dtype); } -var Uie = { kernelName: Cr, backendName: "webgpu", kernelFunc: Wie }; -var Gie = class { +var Gie = { kernelName: Cr, backendName: "webgpu", kernelFunc: Uie }; +var Hie = class { constructor(e) { this.variableNames = ["x", "indices"], this.workGroupSize = [256, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.uniforms = `inputSize : i32, firstPass : i32, negativeInf : f32, dir : i32, inc : i32,`, this.shaderKey = "swap"; @@ -35857,7 +35748,7 @@ var Gie = class { `; } }; -var Hie = class { +var qie = class { constructor(e) { this.variableNames = ["x", "indices"], this.workGroupSize = [256, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.uniforms = "inputSize : i32, firstPass : i32, k : i32,", this.shaderKey = "merge"; } @@ -35933,18 +35824,18 @@ function Pw(e) { t *= 2; return t; } -function qie(e) { +function jie(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { k: a, sorted: i } = s, o = r.shape, u = o[o.length - 1]; if (n.shouldExecuteOnCPU([r])) { - let k = n.readSync(r.dataId), [T, N] = rse(k, o, r.dtype, a, i); + let k = n.readSync(r.dataId), [T, N] = ase(k, o, r.dtype, a, i); return [n.makeTensorInfo(T.shape, T.dtype, T.values), n.makeTensorInfo(N.shape, N.dtype, N.values)]; } if (a === 0) return o[o.length - 1] = 0, [n.makeTensorInfo(o, r.dtype, []), n.makeTensorInfo(o, "int32", [])]; if (u === 1) - return [r, cu({ attrs: { shape: o, dtype: "int32", value: 0 }, backend: n })]; + return [r, du({ attrs: { shape: o, dtype: "int32", value: 0 }, backend: n })]; let c = w.sizeFromShape(o) / u, p = Me({ inputs: { x: r }, attrs: { shape: [c, u] }, backend: n }), d = Pw(a), h = Pw(u), f = null, m = () => f === null ? [p, p] : [p, f], g = (k, T, N) => { - let E = m(), A = new Gie(N), R = [{ type: "int32", data: [u] }, { type: "int32", data: [f === null ? 1 : 0] }, { type: "float32", data: [Number.NEGATIVE_INFINITY] }, { type: "int32", data: [k] }, { type: "int32", data: [T] }], F = f; + let E = m(), A = new Hie(N), R = [{ type: "int32", data: [u] }, { type: "int32", data: [f === null ? 1 : 0] }, { type: "float32", data: [Number.NEGATIVE_INFINITY] }, { type: "int32", data: [k] }, { type: "int32", data: [T] }], F = f; f = n.runWebGPUProgram(A, E, "int32", R), Vi(n, F); }; for (let k = 1; k < d; k *= 2) { @@ -35953,14 +35844,14 @@ function qie(e) { g(T, N, [c, h]); } for (let k = h; k > d; k /= 2) { - let T = m(), N = new Hie([c, k / 2]), A = [{ type: "int32", data: [u] }, { type: "int32", data: [f === null ? 1 : 0] }, { type: "int32", data: [d] }], P = f; + let T = m(), N = new qie([c, k / 2]), A = [{ type: "int32", data: [u] }, { type: "int32", data: [f === null ? 1 : 0] }, { type: "int32", data: [d] }], P = f; f = n.runWebGPUProgram(N, T, "int32", A), Vi(n, P); let R = d / 2, F = R * 2; for (let $ = R; $ >= 1; $ /= 2) g(F, $, f.shape); } let b = f; - f = lu({ inputs: { x: f }, backend: n, attrs: { begin: 0, size: [c, a] } }), Vi(n, b); + f = cu({ inputs: { x: f }, backend: n, attrs: { begin: 0, size: [c, a] } }), Vi(n, b); let y = D2({ inputs: { x: p, indices: f }, backend: n, attrs: { axis: 1, batchDims: 1 } }); Vi(n, p); let v = o.slice(0, -1); @@ -35968,8 +35859,8 @@ function qie(e) { let x = y; return y = Me({ inputs: { x: y }, attrs: { shape: v }, backend: n }), Vi(n, x), [y, f]; } -var jie = { kernelName: Vo, backendName: "webgpu", kernelFunc: qie }; -var Kie = class { +var Kie = { kernelName: Wo, backendName: "webgpu", kernelFunc: jie }; +var Xie = class { constructor(e) { this.variableNames = ["Image", "Transforms"], this.uniforms = "interpolationModeId : i32, fillModeId : i32, fillValue : f32,", this.workGroupSize = [64, 1, 1], this.size = true, this.outputShape = e, this.dispatchLayout = Be(this.outputShape), this.dispatch = _e(this.dispatchLayout, this.outputShape, this.workGroupSize), this.shaderKey = "transform"; } @@ -36093,8 +35984,8 @@ var Kie = class { `; } }; -function Xie(e) { - let { inputs: t, backend: n, attrs: s } = e, { image: r, transforms: a } = t, { interpolation: i, fillMode: o, fillValue: u, outputShape: l } = s, [c, p, d, h] = r.shape, [f, m] = l != null ? l : [p, d], g = [c, f, m, h], b = new Kie(g), y = i === "nearest" ? 1 : 2, v; +function Yie(e) { + let { inputs: t, backend: n, attrs: s } = e, { image: r, transforms: a } = t, { interpolation: i, fillMode: o, fillValue: u, outputShape: l } = s, [c, p, d, h] = r.shape, [f, m] = l != null ? l : [p, d], g = [c, f, m, h], b = new Xie(g), y = i === "nearest" ? 1 : 2, v; switch (o) { case "constant": v = 1; @@ -36115,8 +36006,8 @@ function Xie(e) { let x = [{ type: "int32", data: [y] }, { type: "int32", data: [v] }, { type: "float32", data: [u] }]; return n.runWebGPUProgram(b, [r, a], "float32", x); } -var Yie = { kernelName: Wo, backendName: "webgpu", kernelFunc: Xie }; -function Qie(e) { +var Qie = { kernelName: Uo, backendName: "webgpu", kernelFunc: Yie }; +function Zie(e) { let { inputs: t, backend: n, attrs: s } = e, { value: r } = t, { axis: a } = s; a < 0 && (a += r.shape.length); let i = r, o = i.shape.length, u = r.shape[a], l = new Array(o - 1), c = 0; @@ -36127,16 +36018,16 @@ function Qie(e) { let f = new Array(u); for (let m = 0; m < f.length; m++) { d[a] = m; - let g = lu({ inputs: { x: i }, backend: n, attrs: { begin: d, size: h } }), b = Me({ inputs: { x: g }, backend: n, attrs: { shape: l } }); + let g = cu({ inputs: { x: i }, backend: n, attrs: { begin: d, size: h } }), b = Me({ inputs: { x: g }, backend: n, attrs: { shape: l } }); f[m] = b, p.push(g); } return p.forEach((m) => n.disposeData(m.dataId)), f; } -var Zie = { kernelName: Uo, backendName: "webgpu", kernelFunc: Qie }; -var Jie = [Sne, ose, lse, pse, yse, xse, kse, Sse, _se, Dse, Ose, Lse, $ne, Use, Qse, tre, sre, are, ure, dre, hre, yre, xre, kre, Ire, Sre, Nre, $re, Are, Pre, Rre, Fre, Lre, Vre, Ure, qre, Xre, Qre, Jre, Tne, Vse, tae, sae, aae, oae, lae, dae, pae, fae, gae, yae, xae, kae, Sae, fre, Nae, $ae, Aae, Ase, Rae, Fae, Pae, Mae, Bae, Wae, Gae, Ese, Hae, jae, Xae, kne, Zae, tie, sie, aie, uie, die, hie, mie, bie, Tse, Oie, zie, xie, kie, Cie, Tie, _ie, Aie, Rie, yie, gre, Lie, Uie, jie, Yie, gse, Zie, Eae]; -for (let e of Jie) - Al(e); -var eoe = class { +var Jie = { kernelName: Go, backendName: "webgpu", kernelFunc: Zie }; +var eoe = [Cne, use, cse, hse, vse, wse, Ise, Cse, Ase, Fse, Pse, Bse, _ne, Gse, Zse, nre, rre, ire, lre, pre, fre, vre, wre, Ire, Sre, Cre, Tre, _re, Ere, zre, Dre, Ore, Bre, Wre, Gre, jre, Yre, Zre, eae, $ne, Wse, nae, rae, iae, uae, cae, pae, hae, mae, bae, vae, wae, Iae, Cae, mre, Tae, _ae, Eae, Ese, Dae, Oae, zae, Lae, Vae, Uae, Hae, Rse, qae, Kae, Yae, Ine, Jae, nie, rie, iie, lie, pie, fie, gie, yie, $se, Pie, Mie, wie, Iie, Nie, $ie, Aie, Eie, Die, vie, bre, Bie, Gie, Kie, Qie, bse, Jie, Rae]; +for (let e of eoe) + El(e); +var toe = class { constructor(e) { this.device = e, this.numUsedBuffers = 0, this.numFreeBuffers = 0, this.freeBuffers = /* @__PURE__ */ new Map(), this.usedBuffers = /* @__PURE__ */ new Map(), this.numBytesUsed = 0, this.numBytesAllocated = 0; } @@ -36245,10 +36136,9 @@ var L2 = class { return { bindGroupLayout: n, pipelineLayout: s }; } }; -var toe = class extends L2 { +var noe = class extends L2 { constructor() { - super(...arguments); - this.layout = null, this.useImport = true; + super(...arguments), this.layout = null, this.useImport = true; } getUserCode() { return this.makeFromPixelsSource(); @@ -36263,7 +36153,7 @@ var toe = class extends L2 { return { bindGroupLayout: n, pipelineLayout: s }; } }; -var noe = X().getNumber("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD"); +var soe = X().getNumber("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD"); var Mw = (e, t) => { let n = e.limits.maxComputeWorkgroupsPerDimension, s = t.dispatchLayout, r = t.dispatch; if (r.every((i) => i <= n)) @@ -36272,12 +36162,11 @@ var Mw = (e, t) => { let a = Math.ceil(Math.sqrt(r[0])); return a > n ? (a = Math.ceil(Math.cbrt(r[0])), w.assert(a <= n, () => "Total dispatch size exceeds WebGPU maximum."), [a, a, a]) : [a, a, 1]; }; -var B2 = class extends tl { +var B2 = class extends nl { constructor(e, t = false) { - super(); - if (this.commandQueueOwnedIds = /* @__PURE__ */ new WeakSet(), this.tensorDisposalQueue = [], this.uniformDisposalQueue = [], this.stagingDisposalQueue = [], this.disposed = false, this.uploadWaitMs = 0, this.downloadWaitMs = 0, this.dispatchNumberInEncoder = 0, !Tv()) + if (super(), this.commandQueueOwnedIds = /* @__PURE__ */ new WeakSet(), this.tensorDisposalQueue = [], this.uniformDisposalQueue = [], this.stagingDisposalQueue = [], this.disposed = false, this.uploadWaitMs = 0, this.downloadWaitMs = 0, this.dispatchNumberInEncoder = 0, !Tv()) throw new Error("WebGPU is not supported on this device"); - this.layoutCache = {}, this.pipelineCache = {}, this.device = e, this.queue = e.queue, this.currentCommandEncoder = null, this.currentComputePass = null, this.supportTimeQuery = t, this.bufferManager = new eoe(this.device), this.tensorMap = new Ud(this, Ss()), this.supportTimeQuery && (this.querySet = this.device.createQuerySet({ type: "timestamp", count: 2 })), X().getBool("WEBGPU_USE_PROFILE_TOOL") && (this.dummyCanvas = document.createElement("canvas"), this.dummyCanvas.width = 1, this.dummyCanvas.height = 1, this.dummyContext = this.dummyCanvas.getContext("webgpu"), this.dummyContext.configure({ device: e, format: "bgra8unorm" }), document.body.appendChild(this.dummyCanvas)); + this.layoutCache = {}, this.pipelineCache = {}, this.device = e, this.queue = e.queue, this.currentCommandEncoder = null, this.currentComputePass = null, this.supportTimeQuery = t, this.bufferManager = new toe(this.device), this.tensorMap = new Ud(this, Ss()), this.supportTimeQuery && (this.querySet = this.device.createQuerySet({ type: "timestamp", count: 2 })), X().getBool("WEBGPU_USE_PROFILE_TOOL") && (this.dummyCanvas = document.createElement("canvas"), this.dummyCanvas.width = 1, this.dummyCanvas.height = 1, this.dummyContext = this.dummyCanvas.getContext("webgpu"), this.dummyContext.configure({ device: e, format: "bgra8unorm" }), document.body.appendChild(this.dummyCanvas)); } nextDataId() { return B2.nextDataId++; @@ -36355,7 +36244,7 @@ var B2 = class extends tl { case "copyExternal": return this.fromPixelProgram || (this.fromPixelProgram = new L2()), this.fromPixelProgram; case "import": - return this.fromPixelImportProgram || (this.fromPixelImportProgram = new toe()), this.fromPixelImportProgram; + return this.fromPixelImportProgram || (this.fromPixelImportProgram = new noe()), this.fromPixelImportProgram; default: w.assert(false, () => "Unsupported fromPixels shape"); return; @@ -36518,7 +36407,7 @@ var B2 = class extends tl { if (N.dtype === "complex64") throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts."); return this.uploadToGPU(N.dataId), { dtype: this.tensorMap.get(N.dataId).dtype, shape: N.shape, name: e.variableNames[E] }; - }), p = c.map((N) => N.dtype).concat(r.dtype), d = c.map((N) => S.getBroadcastDims(N.shape, r.shape)), h = c.map((N) => w.arraysEqual(N.shape, r.shape)).join("_"), f = d.map((N) => N.join("_")).join(";"), m = R2(e, i, p, f, h), { bindGroupLayout: g, pipelineLayout: b } = this.getCachedOrCreateLayout(e.variableNames.length), y = this.getAndSavePipeline(m, () => E2(this.device, e, b, c, r)), v = this.activeTimers != null, x = Ore(this.device, g, t.map((N) => this.tensorToBinding(N)), this.tensorToBinding(r), l); + }), p = c.map((N) => N.dtype).concat(r.dtype), d = c.map((N) => S.getBroadcastDims(N.shape, r.shape)), h = c.map((N) => w.arraysEqual(N.shape, r.shape)).join("_"), f = d.map((N) => N.join("_")).join(";"), m = R2(e, i, p, f, h), { bindGroupLayout: g, pipelineLayout: b } = this.getCachedOrCreateLayout(e.variableNames.length), y = this.getAndSavePipeline(m, () => E2(this.device, e, b, c, r)), v = this.activeTimers != null, x = Pre(this.device, g, t.map((N) => this.tensorToBinding(N)), this.tensorToBinding(r), l); this.ensureCommandEncoderReady(); let k = this.getComputePass(); v && this.supportTimeQuery && k.writeTimestamp(this.querySet, 0), k.setPipeline(y), k.setBindGroup(0, x), k.dispatch(e.dispatch[0], e.dispatch[1], e.dispatch[2]), v && this.supportTimeQuery && k.writeTimestamp(this.querySet, 1), this.dispatchNumberInEncoder++, t.forEach((N) => { @@ -36540,7 +36429,7 @@ var B2 = class extends tl { let s = new BigUint64Array(n.getMappedRange()), r = Number(s[1] - s[0]); return n.unmap(), this.bufferManager.releaseBuffer(n, 16, GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST), this.bufferManager.releaseBuffer(t, 16, GPUBufferUsage.COPY_SRC | GPUBufferUsage.QUERY_RESOLVE), r / 1e6; } - shouldExecuteOnCPU(e, t = noe) { + shouldExecuteOnCPU(e, t = soe) { return X().getBool("WEBGPU_CPU_FORWARD") && e.every((n) => this.tensorMap.get(n.dataId).bufferInfo.buffer == null && w.sizeFromShape(n.shape) < t); } numDataIds() { @@ -36552,8 +36441,8 @@ var B2 = class extends tl { }; var Ev = B2; Ev.nextDataId = 0; -var soe = {}; -Ae(soe, { WebGPUBackend: () => Ev, webgpu_util: () => m2 }); +var roe = {}; +Ae(roe, { WebGPUBackend: () => Ev, webgpu_util: () => m2 }); Tv() && pp("webgpu", async () => { X().set("CHECK_COMPUTATION_FOR_ERRORS", false); let e = { powerPreference: X().get("WEBGPU_USE_LOW_POWER_GPU") ? "low-power" : "high-performance" }, t = await navigator.gpu.requestAdapter(e), n = t.limits, s = {}, r = t.features.has("timestamp-query"); @@ -36564,10 +36453,10 @@ Tv() && pp("webgpu", async () => { var It = ((e) => (e[e.float32 = 0] = "float32", e[e.int32 = 1] = "int32", e[e.bool = 2] = "bool", e[e.string = 3] = "string", e[e.complex64 = 4] = "complex64", e))(It || {}); var Jp = ((e) => (e[e.linear = 0] = "linear", e[e.relu = 1] = "relu", e[e.relu6 = 2] = "relu6", e[e.prelu = 3] = "prelu", e[e.leakyrelu = 4] = "leakyrelu", e[e.sigmoid = 5] = "sigmoid", e[e.elu = 6] = "elu", e))(Jp || {}); var V2; -function roe(e) { +function aoe(e) { V2 = e.wasm.cwrap(ra, null, ["number", "array", "number", "number", "array", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function aoe(e) { +function ioe(e) { let { inputs: t, backend: n, attrs: s } = e, { a: r, b: a, bias: i, preluActivationWeights: o } = t; if (r.dtype !== "float32" || a.dtype !== "float32") throw new Error("_FusedMatMul for non non-float32 tensors not yet supported."); @@ -36581,10 +36470,10 @@ function aoe(e) { let m = o == null ? 0 : n.dataIdMap.get(o.dataId).id, g = Jp[c]; if (g == null) throw new Error(`${c} activation not yet supported for FusedConv2D in the wasm backend.`); - let b = u ? r.shape[2] : r.shape[1], y = l ? a.shape[1] : a.shape[2], v = qo.assertAndGetBroadcastShape(r.shape.slice(0, -2), a.shape.slice(0, -2)), x = n.makeOutput([...v, b, y], r.dtype), k = n.dataIdMap.get(x.dataId).id, T = new Uint8Array(new Int32Array(r.shape).buffer), N = new Uint8Array(new Int32Array(a.shape).buffer); + let b = u ? r.shape[2] : r.shape[1], y = l ? a.shape[1] : a.shape[2], v = jo.assertAndGetBroadcastShape(r.shape.slice(0, -2), a.shape.slice(0, -2)), x = n.makeOutput([...v, b, y], r.dtype), k = n.dataIdMap.get(x.dataId).id, T = new Uint8Array(new Int32Array(r.shape).buffer), N = new Uint8Array(new Int32Array(a.shape).buffer); return V2(d, T, r.shape.length, h, N, a.shape.length, u, l, g, f, m, p || 0, k), x; } -var ioe = { kernelName: ra, backendName: "wasm", setupFunc: roe, kernelFunc: aoe }; +var ooe = { kernelName: ra, backendName: "wasm", setupFunc: aoe, kernelFunc: ioe }; function Xt(e, t) { let n; function s(a) { @@ -36596,7 +36485,7 @@ function Xt(e, t) { } return { kernelName: e, backendName: "wasm", setupFunc: s, kernelFunc: r }; } -var ooe = Xt(ao); +var uoe = Xt(io); function gn(e, t, n) { let s; function r(i) { @@ -36611,34 +36500,34 @@ function gn(e, t, n) { } return { kernelName: e, backendName: "wasm", setupFunc: r, kernelFunc: a }; } -var uoe = true; -var loe = gn(Ir, uoe); +var loe = true; +var coe = gn(Ir, loe); var W2; -function coe(e) { +function doe(e) { W2 = e.wasm.cwrap(ka, null, ["array", "number", "number", "number"]); } -function doe(e) { +function poe(e) { let { inputs: t, backend: n } = e, s = n.makeOutput(t[0].shape, t[0].dtype); if (w.sizeFromShape(s.shape) === 0) return s; let r = t.map((o) => n.dataIdMap.get(o.dataId).id), a = new Uint8Array(new Int32Array(r).buffer), i = n.dataIdMap.get(s.dataId).id; return W2(a, r.length, It[s.dtype], i), s; } -var poe = { kernelName: ka, backendName: "wasm", setupFunc: coe, kernelFunc: doe }; +var hoe = { kernelName: ka, backendName: "wasm", setupFunc: doe, kernelFunc: poe }; function eh(e) { let { inputs: { x: t }, backend: n } = e, s = n.makeOutput(t.shape, t.dtype), r = n.typedArrayFromHeap(t); return n.typedArrayFromHeap(s).set(r), s; } -var hoe = { kernelName: Ba, backendName: "wasm", kernelFunc: eh }; +var foe = { kernelName: Ba, backendName: "wasm", kernelFunc: eh }; var U2; -function foe(e) { +function moe(e) { U2 = e.wasm.cwrap(pi, null, ["number", "array", "number", "number", "number", "array", "number"]); } function wr(e) { - let { inputs: t, backend: n, attrs: s } = e, [r, a] = goe(t.x.shape, s.perm), i = true; + let { inputs: t, backend: n, attrs: s } = e, [r, a] = boe(t.x.shape, s.perm), i = true; for (let f = 0; f < a.length; f++) a[f] !== f && (i = false); - let o = moe(t.x.shape, s.perm), u = { dataId: t.x.dataId, shape: r, dtype: t.x.dtype }; + let o = goe(t.x.shape, s.perm), u = { dataId: t.x.dataId, shape: r, dtype: t.x.dtype }; if (i) { let f = eh({ inputs: t, backend: n }); return f.shape = o, f; @@ -36646,13 +36535,13 @@ function wr(e) { let l = n.makeOutput(o, u.dtype), c = n.dataIdMap.get(u.dataId).id, p = n.dataIdMap.get(l.dataId).id, d = new Uint8Array(new Int32Array(a).buffer), h = new Uint8Array(new Int32Array(u.shape).buffer); return U2(c, h, u.shape.length, It[u.dtype], p, d, a.length), l; } -function moe(e, t) { +function goe(e, t) { let n = new Array(e.length); for (let s = 0; s < n.length; s++) n[s] = e[t[s]]; return n; } -function goe(e, t) { +function boe(e, t) { let n = [], s = []; for (let r = 0; r < e.length; ++r) e[r] !== 1 && n.push(e[r]), e[t[r]] !== 1 && s.push(t[r]); @@ -36664,7 +36553,7 @@ function goe(e, t) { } return [n, s]; } -var boe = { kernelName: pi, backendName: "wasm", kernelFunc: wr, setupFunc: foe }; +var yoe = { kernelName: pi, backendName: "wasm", kernelFunc: wr, setupFunc: moe }; function Fr(e, t, n) { let s = e.shape, r = e.shape.length, a = w.parseAxisParam(t, s), i = a, o = S.getAxesPermutation(i, r), u = null, l = false; if (o != null) { @@ -36678,10 +36567,10 @@ function Fr(e, t, n) { return { transposed: u, originalAxes: a, axes: i, inputWasTransposed: l }; } var G2; -function yoe(e) { - G2 = e.wasm.cwrap(rl, null, ["number, number, number"]); -} function voe(e) { + G2 = e.wasm.cwrap(al, null, ["number, number, number"]); +} +function xoe(e) { let { backend: t, inputs: n, attrs: s } = e, { axis: r, keepDims: a } = s, { x: i } = n, u = t.dataIdMap.get(i.dataId).id, l = i, { transposed: c, axes: p, originalAxes: d, inputWasTransposed: h } = Fr(i, r, t); if (h) { let v = t.dataIdMap.get(c.dataId).id; @@ -36700,12 +36589,12 @@ function voe(e) { } return y; } -var xoe = { kernelName: rl, backendName: "wasm", setupFunc: yoe, kernelFunc: voe }; +var woe = { kernelName: al, backendName: "wasm", setupFunc: voe, kernelFunc: xoe }; var H2; -function woe(e) { - H2 = e.wasm.cwrap(al, null, ["number, number, number"]); -} function koe(e) { + H2 = e.wasm.cwrap(il, null, ["number, number, number"]); +} +function Ioe(e) { let { backend: t, inputs: n, attrs: s } = e, { axis: r, keepDims: a } = s, { x: i } = n, u = t.dataIdMap.get(i.dataId).id, l = i, { transposed: c, axes: p, originalAxes: d, inputWasTransposed: h } = Fr(i, r, t); if (h) { let v = t.dataIdMap.get(c.dataId).id; @@ -36724,12 +36613,12 @@ function koe(e) { } return y; } -var Ioe = { kernelName: al, backendName: "wasm", setupFunc: woe, kernelFunc: koe }; +var Soe = { kernelName: il, backendName: "wasm", setupFunc: koe, kernelFunc: Ioe }; var q2; -function Soe(e) { +function Coe(e) { q2 = e.wasm.cwrap(Ia, null, ["number", "number", "number", "number", "number"]); } -function Coe(e) { +function Noe(e) { let { backend: t, inputs: n, attrs: s } = e, { axis: r } = s, { x: a } = n, i = t.dataIdMap.get(a.dataId).id, o = i, u = a, { transposed: l, axes: c, inputWasTransposed: p } = Fr(a, r, t); if (p) { let b = t.dataIdMap.get(l.dataId).id; @@ -36738,12 +36627,12 @@ function Coe(e) { let d = u.shape.slice(0, -1), h = t.makeOutput(d, "int32"), f = t.dataIdMap.get(h.dataId).id, m = w.sizeFromShape(h.shape), g = u.shape[c[0]]; return q2(o, It[u.dtype], m, g, f), p && t.disposeData(l.dataId), h; } -var Noe = { kernelName: Ia, backendName: "wasm", kernelFunc: Coe, setupFunc: Soe }; +var Toe = { kernelName: Ia, backendName: "wasm", kernelFunc: Noe, setupFunc: Coe }; var j2; -function Toe(e) { +function $oe(e) { j2 = e.wasm.cwrap(Sa, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function $oe(e) { +function _oe(e) { let { inputs: t, attrs: n, backend: s } = e, r = t.x, a = s.dataIdMap.get(r.dataId).id, { filterSize: i, strides: o, pad: u, dimRoundingMode: l } = n, c = S.computePool2DInfo(r.shape, i, o, 1, u, l), p = c.filterHeight, d = c.filterWidth, h = c.padInfo.top, f = c.padInfo.right, m = c.padInfo.bottom, g = c.padInfo.left, b = c.strideHeight, y = c.strideWidth, v = c.inChannels; if (c.dataFormat !== "channelsLast") throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`); @@ -36752,26 +36641,26 @@ function $oe(e) { let x = s.makeOutput(c.outShape, "float32"), k = s.dataIdMap.get(x.dataId).id; return j2(a, r.shape[0], r.shape[1], r.shape[2], p, d, h, f, m, g, b, y, v, k), x; } -var _oe = { kernelName: Sa, backendName: "wasm", setupFunc: Toe, kernelFunc: $oe }; +var Aoe = { kernelName: Sa, backendName: "wasm", setupFunc: $oe, kernelFunc: _oe }; function yn(e) { let { inputs: t, attrs: n } = e, { x: s } = t, { shape: r } = n, a = w.sizeFromShape(s.shape), i = w.inferFromImplicitShape(r, a); return w.assert(a === w.sizeFromShape(i), () => `new shape: ${i}, old shape: ${s.shape}. New shape and old shape must have the same number of elements.`), e.backend.incRef(s.dataId), { dataId: s.dataId, shape: i, dtype: s.dtype }; } -var Aoe = { kernelName: Ao, backendName: "wasm", kernelFunc: yn }; +var Eoe = { kernelName: Eo, backendName: "wasm", kernelFunc: yn }; var K2; -function Eoe(e) { +function Roe(e) { K2 = e.wasm.cwrap(Ca, null, ["number", "array", "number", "number", "array", "number", "number", "number", "number"]); } -function Roe(e) { +function Doe(e) { let { inputs: t, backend: n, attrs: s } = e, { a: r, b: a } = t, { transposeA: i, transposeB: o } = s; if (r.dtype !== "float32" || a.dtype !== "float32") throw new Error("BatchMatMul for non non-float32 tensors not yet supported."); - let u = r.shape.length, l = a.shape.length, c = i ? r.shape[u - 2] : r.shape[u - 1], p = o ? a.shape[l - 1] : a.shape[l - 2], d = i ? r.shape[u - 1] : r.shape[u - 2], h = o ? a.shape[l - 2] : a.shape[l - 1], f = r.shape.slice(0, -2), m = a.shape.slice(0, -2), g = w.sizeFromShape(f), b = w.sizeFromShape(m), v = qo.assertAndGetBroadcastShape(r.shape.slice(0, -2), a.shape.slice(0, -2)).concat([d, h]); + let u = r.shape.length, l = a.shape.length, c = i ? r.shape[u - 2] : r.shape[u - 1], p = o ? a.shape[l - 1] : a.shape[l - 2], d = i ? r.shape[u - 1] : r.shape[u - 2], h = o ? a.shape[l - 2] : a.shape[l - 1], f = r.shape.slice(0, -2), m = a.shape.slice(0, -2), g = w.sizeFromShape(f), b = w.sizeFromShape(m), v = jo.assertAndGetBroadcastShape(r.shape.slice(0, -2), a.shape.slice(0, -2)).concat([d, h]); w.assert(c === p, () => `Error in matMul: inner shapes (${c}) and (${p}) of Tensors with shapes ${r.shape} and ${a.shape} and transposeA=${i} and transposeB=${o} must match.`); let x = i ? [g, c, d] : [g, d, c], k = o ? [b, h, p] : [b, p, h], T = yn({ inputs: { x: r }, backend: n, attrs: { shape: x } }), N = yn({ inputs: { x: a }, backend: n, attrs: { shape: k } }), E = n.dataIdMap.get(T.dataId).id, A = n.dataIdMap.get(N.dataId).id, P = i ? T.shape[2] : T.shape[1], R = o ? N.shape[1] : N.shape[2], F = Math.max(g, b), $ = n.makeOutput([F, P, R], T.dtype), z = n.dataIdMap.get($.dataId).id, W = new Uint8Array(new Int32Array(T.shape).buffer), q = new Uint8Array(new Int32Array(N.shape).buffer); return K2(E, W, T.shape.length, A, q, N.shape.length, i, o, z), n.disposeData(T.dataId), n.disposeData(N.dataId), $.shape = v, $; } -var Doe = { kernelName: Ca, backendName: "wasm", setupFunc: Eoe, kernelFunc: Roe }; +var Foe = { kernelName: Ca, backendName: "wasm", setupFunc: Roe, kernelFunc: Doe }; function va(e) { let { inputs: { x: t }, attrs: { begin: n, size: s }, backend: r } = e, [a, i] = wt.parseSliceParams(t, n, s), o = wt.isSliceContinous(t.shape, a, i), u = r.readSync(t.dataId), l = r.makeOutput(i, t.dtype), c = w.computeStrides(t.shape), p = r.dataIdMap.get(l.dataId); if (o) { @@ -36784,25 +36673,25 @@ function va(e) { } let d = r.typedArrayFromHeap(l), h = t.shape.length; if (h === 2) - Foe(u, c[0], d, a, i); + Ooe(u, c[0], d, a, i); else if (h === 3) - Ooe(u, c[0], c[1], d, a, i); + Poe(u, c[0], c[1], d, a, i); else if (h === 4) - Poe(u, c[0], c[1], c[2], d, a, i); + zoe(u, c[0], c[1], c[2], d, a, i); else { let f = Fd(u, a, i, t.shape, t.dtype); d.set(f); } return l; } -function Foe(e, t, n, s, r) { +function Ooe(e, t, n, s, r) { let a = 0, i = s[0], o = s[1], u = i + r[0]; for (let l = i; l < u; l++) { let c = l * t + o; n.set(e.subarray(c, c + r[1]), a), a += r[1]; } } -function Ooe(e, t, n, s, r, a) { +function Poe(e, t, n, s, r, a) { let i = 0, o = r[0], u = r[1], l = r[2], c = o + a[0], p = u + a[1]; for (let d = o; d < c; d++) for (let h = u; h < p; h++) { @@ -36810,7 +36699,7 @@ function Ooe(e, t, n, s, r, a) { s.set(e.subarray(f, f + a[2]), i), i += a[2]; } } -function Poe(e, t, n, s, r, a, i) { +function zoe(e, t, n, s, r, a, i) { let o = 0, u = a[0], l = a[1], c = a[2], p = u + i[0], d = l + i[1], h = c + i[2], f = a[3]; for (let m = u; m < p; m++) for (let g = l; g < d; g++) @@ -36819,27 +36708,27 @@ function Poe(e, t, n, s, r, a, i) { r.set(e.subarray(y, y + i[3]), o), o += i[3]; } } -var zoe = { kernelName: Oo, backendName: "wasm", kernelFunc: va }; -function Moe(e) { +var Moe = { kernelName: Po, backendName: "wasm", kernelFunc: va }; +function Loe(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockShape: a, crops: i } = s, o = a.reduce((b, y) => b * y), u = S.getReshaped(r.shape, a, o), l = S.getPermuted(u.length, a.length), c = S.getReshapedPermuted(r.shape, a, o), p = S.getSliceBeginCoords(i, a.length), d = S.getSliceSize(c, i, a.length), h = yn({ inputs: { x: r }, backend: n, attrs: { shape: u } }), f = wr({ inputs: { x: h }, backend: n, attrs: { perm: l } }), m = yn({ inputs: { x: f }, backend: n, attrs: { shape: c } }), g = va({ inputs: { x: m }, backend: n, attrs: { begin: p, size: d } }); return n.disposeData(h.dataId), n.disposeData(f.dataId), n.disposeData(h.dataId), g; } -var Loe = { kernelName: io, backendName: "wasm", kernelFunc: Moe }; +var Boe = { kernelName: oo, backendName: "wasm", kernelFunc: Loe }; function ac(e) { let { inputs: { x: t }, attrs: { dtype: n }, backend: s } = e, r = s.makeOutput(t.shape, n), a = s.typedArrayFromHeap(t); return s.typedArrayFromHeap(r).set(a), r; } -var Boe = { kernelName: Na, backendName: "wasm", kernelFunc: ac }; -var Voe = Xt(Ta); +var Voe = { kernelName: Na, backendName: "wasm", kernelFunc: ac }; +var Woe = Xt(Ta); var X2; -function Woe(e) { +function Uoe(e) { X2 = e.wasm.cwrap(Sr, null, ["number", "number", "number", "number"]); } -function Uoe(e) { +function Goe(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { clipValueMin: a, clipValueMax: i } = s, o = n.dataIdMap.get(r.dataId).id, u = n.makeOutput(r.shape, r.dtype), l = n.dataIdMap.get(u.dataId).id; return X2(o, a, i, l), u; } -var Goe = { kernelName: Sr, backendName: "wasm", setupFunc: Woe, kernelFunc: Uoe }; +var Hoe = { kernelName: Sr, backendName: "wasm", setupFunc: Uoe, kernelFunc: Goe }; function Y2(e) { let { inputs: t, backend: n } = e, s = w.parseAxisParam(e.attrs.axis, t[0].shape)[0], r = S.computeOutShape(t.map((h) => h.shape), s), a = t.filter((h) => w.sizeFromShape(h.shape) > 0); if (a.length === 1) @@ -36872,47 +36761,47 @@ function Y2(e) { } return i; } -var Hoe = { kernelName: oo, backendName: "wasm", kernelFunc: Y2 }; +var qoe = { kernelName: uo, backendName: "wasm", kernelFunc: Y2 }; var Q2; -function qoe(e) { +function joe(e) { Q2 = e.wasm.cwrap($a, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function joe(e) { +function Koe(e) { let { inputs: t, attrs: n, backend: s } = e, { x: r, filter: a } = t, i = s.dataIdMap.get(r.dataId).id, o = s.dataIdMap.get(a.dataId).id, { strides: u, dilations: l, pad: c, dimRoundingMode: p, dataFormat: d } = n, h = S.convertConv2DDataFormat(d), f = S.computeConv2DInfo(r.shape, a.shape, u, l, c, p, false, h), m = f.filterHeight, g = f.filterWidth, b = f.padInfo.top, y = f.padInfo.right, v = f.padInfo.bottom, x = f.padInfo.left, k = f.dilationHeight, T = f.dilationWidth, N = f.strideHeight, E = f.strideWidth, A = f.inChannels, P = f.outChannels, R = f.padInfo.type === "SAME" ? 1 : 0; if (f.dataFormat !== "channelsLast") throw new Error(`wasm backend Conv2D does not support dataFormat:'${f.dataFormat}'. Please use 'channelsLast'.`); let F = s.makeOutput(f.outShape, "float32"), $ = s.dataIdMap.get(F.dataId).id; return Q2(i, r.shape[0], r.shape[1], r.shape[2], o, m, g, b, y, v, x, R, k, T, N, E, A, P, $), F; } -var Koe = { kernelName: $a, backendName: "wasm", setupFunc: qoe, kernelFunc: joe }; +var Xoe = { kernelName: $a, backendName: "wasm", setupFunc: joe, kernelFunc: Koe }; var Z2; -function Xoe(e) { +function Yoe(e) { Z2 = e.wasm.cwrap(_a, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function Yoe(e) { +function Qoe(e) { let { backend: t, inputs: n, attrs: s } = e, { dy: r, filter: a } = n, { strides: i, pad: o, dataFormat: u, dimRoundingMode: l, inputShape: c } = s, p = 1, d = S.convertConv2DDataFormat(u), h = S.computeConv2DInfo(c, a.shape, i, p, o, l, false, d), { batchSize: f, filterHeight: m, filterWidth: g, inChannels: b, inHeight: y, inWidth: v, outChannels: x, outHeight: k, outWidth: T, strideHeight: N, strideWidth: E } = h, A = m - 1 - h.padInfo.top, P = g - 1 - h.padInfo.left, R = h.dataFormat === "channelsLast", F = w.computeStrides(h.inShape), $ = w.computeStrides(r.shape), [z, W, q] = w.computeStrides(a.shape), K = F[0], Y = R ? F[1] : F[2], Z = R ? F[2] : 1, te = R ? 1 : F[1], ee = $[0], se = R ? $[1] : $[2], ne = R ? $[2] : 1, oe = R ? 1 : $[1], re = t.makeOutput(h.inShape, "float32"), le = t.dataIdMap.get(re.dataId).id, me = t.dataIdMap.get(r.dataId).id, ke = t.dataIdMap.get(a.dataId).id; return Z2(me, ke, f, m, g, y, v, b, k, T, x, N, E, A, P, z, W, q, K, Y, Z, te, ee, se, ne, oe, le), re; } -var Qoe = { kernelName: _a, backendName: "wasm", setupFunc: Xoe, kernelFunc: Yoe }; -var Zoe = Xt(Aa); -var Joe = Xt(Ea); +var Zoe = { kernelName: _a, backendName: "wasm", setupFunc: Yoe, kernelFunc: Qoe }; +var Joe = Xt(Aa); +var eue = Xt(Ea); var J2 = ((e) => (e[e.bilinear = 0] = "bilinear", e[e.nearest = 1] = "nearest", e))(J2 || {}); var eN; -function eue(e) { - eN = e.wasm.cwrap(lo, null, ["number", "number", "number", "number", "array", "number", "number", "number", "number", "number"]); -} function tue(e) { + eN = e.wasm.cwrap(co, null, ["number", "number", "number", "number", "array", "number", "number", "number", "number", "number"]); +} +function nue(e) { let { backend: t, inputs: n, attrs: s } = e, { method: r, extrapolationValue: a, cropSize: i } = s, { image: o, boxes: u, boxInd: l } = n, c = u.shape[0], [p, d] = i, h = [c, p, d, o.shape[3]], f = t.dataIdMap.get(o.dataId), m; o.dtype !== "float32" && (m = ac({ backend: t, inputs: { x: o }, attrs: { dtype: "float32" } }), f = t.dataIdMap.get(m.dataId)); let g = f.id, b = t.dataIdMap.get(u.dataId).id, y = t.dataIdMap.get(l.dataId).id, v = t.makeOutput(h, "float32"), x = t.dataIdMap.get(v.dataId).id, k = new Uint8Array(new Int32Array(o.shape).buffer); return eN(g, b, y, c, k, p, d, J2[r], a, x), m != null && t.disposeData(m.dataId), v; } -var nue = { kernelName: lo, backendName: "wasm", setupFunc: eue, kernelFunc: tue }; +var sue = { kernelName: co, backendName: "wasm", setupFunc: tue, kernelFunc: nue }; var tN; -function sue(e) { - tN = e.wasm.cwrap(pl, null, ["number", "number", "number", "number", "number", "number"]); -} function rue(e) { + tN = e.wasm.cwrap(hl, null, ["number", "number", "number", "number", "number", "number"]); +} +function aue(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a, exclusive: i, reverse: o } = s, u = r.shape.length; w.assert(r.dtype === "float32" || r.dtype === "int32", () => `cumprod does not support ${r.dtype} tensors in the WASM backend`); let l = S.getAxesPermutation([a], u), c = r; @@ -36928,12 +36817,12 @@ function rue(e) { } return g; } -var aue = { kernelName: pl, backendName: "wasm", setupFunc: sue, kernelFunc: rue }; +var iue = { kernelName: hl, backendName: "wasm", setupFunc: rue, kernelFunc: aue }; var nN; -function iue(e) { - nN = e.wasm.cwrap(uo, null, ["number", "number", "number", "number", "number", "number"]); -} function oue(e) { + nN = e.wasm.cwrap(lo, null, ["number", "number", "number", "number", "number", "number"]); +} +function uue(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { axis: a, exclusive: i, reverse: o } = s, u = r.shape.length; w.assert(r.dtype === "float32" || r.dtype === "int32", () => `cumsum does not support ${r.dtype} tensors in the WASM backend`); let l = S.getAxesPermutation([a], u), c = r; @@ -36949,71 +36838,71 @@ function oue(e) { } return g; } -var uue = { kernelName: uo, backendName: "wasm", setupFunc: iue, kernelFunc: oue }; +var lue = { kernelName: lo, backendName: "wasm", setupFunc: oue, kernelFunc: uue }; var sN; -function lue(e) { - sN = e.wasm.cwrap(co, null, ["number", "number", "number", "array", "number", "array", "array", "number", "number"]); -} function cue(e) { + sN = e.wasm.cwrap(po, null, ["number", "number", "number", "array", "number", "array", "array", "number", "number"]); +} +function due(e) { let { backend: t, inputs: n, attrs: s } = e, { x: r } = n, { blockSize: a, dataFormat: i } = s, o = r.shape[0], u = i === "NHWC" ? r.shape[1] : r.shape[2], l = i === "NHWC" ? r.shape[2] : r.shape[3], c = i === "NHWC" ? r.shape[3] : r.shape[1], p = u * a, d = l * a, h = c / (a * a), f = i === "NHWC" ? [o, p, d, h] : [o, h, p, d], m = t.makeOutput(f, "float32"), b = t.dataIdMap.get(r.dataId).id, y = new Uint8Array(new Int32Array(w.computeStrides(r.shape)).buffer), v = new Uint8Array(new Int32Array(f).buffer), x = new Uint8Array(new Int32Array(w.computeStrides(f)).buffer), k = t.dataIdMap.get(m.dataId).id; return sN(b, a, i === "NHWC" ? 1 : 0, y, r.shape.length - 1, v, x, f.length, k), m; } -var due = { kernelName: co, backendName: "wasm", setupFunc: lue, kernelFunc: cue }; +var pue = { kernelName: po, backendName: "wasm", setupFunc: cue, kernelFunc: due }; var rN; -function pue(e) { +function hue(e) { rN = e.wasm.cwrap(Ra, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function hue(e) { +function fue(e) { let { inputs: t, attrs: n, backend: s } = e, { x: r, filter: a } = t, i = s.dataIdMap.get(r.dataId).id, o = s.dataIdMap.get(a.dataId).id, { strides: u, dilations: l, pad: c, dimRoundingMode: p } = n, d = l == null ? [1, 1] : l, h = S.computeConv2DInfo(r.shape, a.shape, u, d, c, p, true), f = h.filterHeight, m = h.filterWidth, g = h.padInfo.top, b = h.padInfo.right, y = h.padInfo.bottom, v = h.padInfo.left, x = h.dilationHeight, k = h.dilationWidth, T = h.strideHeight, N = h.strideWidth, E = h.inChannels, A = h.outChannels, P = h.padInfo.type === "SAME" ? 1 : 0; if (h.dataFormat !== "channelsLast") throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${h.dataFormat}'. Please use 'channelsLast'.`); let R = s.makeOutput(h.outShape, "float32"), F = s.dataIdMap.get(R.dataId).id; return rN(i, r.shape[0], r.shape[1], r.shape[2], o, f, m, g, b, y, v, P, x, k, T, N, E, A, F), R; } -var fue = { kernelName: Ra, backendName: "wasm", setupFunc: pue, kernelFunc: hue }; -var mue = Xt(Fa); -var gue = false; -var bue = gn(po, gue, "bool"); -var yue = Xt(Oa, "float32"); +var mue = { kernelName: Ra, backendName: "wasm", setupFunc: hue, kernelFunc: fue }; +var gue = Xt(Fa); +var bue = false; +var yue = gn(ho, bue, "bool"); +var vue = Xt(Oa, "float32"); function Zm(e) { let { inputs: t, attrs: n, backend: s } = e, { input: r } = t, { dim: a } = n, i = r.shape.length, o = r.shape.slice(), u = a; return a < 0 && (w.assert(-(i + 1) <= a, () => `Axis must be in the interval [${-(i + 1)}, ${i}]`), u = i + a + 1), o.splice(u, 0, 1), yn({ inputs: { x: r }, backend: s, attrs: { shape: o } }); } -var vue = { kernelName: ho, backendName: "wasm", kernelFunc: Zm }; +var xue = { kernelName: fo, backendName: "wasm", kernelFunc: Zm }; function aN(e) { let { attrs: { shape: t, value: n, dtype: s }, backend: r } = e, a = r.makeOutput(t, s); return r.typedArrayFromHeap(a).fill(n), a; } -var xue = { kernelName: fl, backendName: "wasm", kernelFunc: aN }; +var wue = { kernelName: ml, backendName: "wasm", kernelFunc: aN }; var iN; -function wue(e) { - iN = e.wasm.cwrap(mo, null, ["number", "number", "number", "number", "number", "number"]); -} function kue(e) { + iN = e.wasm.cwrap(go, null, ["number", "number", "number", "number", "number", "number"]); +} +function Iue(e) { let { inputs: t, backend: n } = e, { image: s } = t, r = n.makeOutput(s.shape, s.dtype), a = n.dataIdMap.get(s.dataId).id, i = n.dataIdMap.get(r.dataId).id, [o, u, l, c] = s.shape; return iN(a, o, u, l, c, i), r; } -var Iue = { kernelName: mo, backendName: "wasm", kernelFunc: kue, setupFunc: wue }; -var Sue = Xt(Pa); -var Cue = false; -var Nue = gn(za, Cue); +var Sue = { kernelName: go, backendName: "wasm", kernelFunc: Iue, setupFunc: kue }; +var Cue = Xt(Pa); +var Nue = false; +var Tue = gn(za, Nue); var oN; -function Tue(e) { +function $ue(e) { oN = e.wasm.cwrap(Ma, null, ["number", "number", "number", "number", "number", "number", "number"]); } -function $ue(e) { +function _ue(e) { let { backend: t, inputs: n, attrs: s } = e, { varianceEpsilon: r } = s, { x: a, mean: i, variance: o, offset: u, scale: l } = n, c = t.dataIdMap.get(a.dataId).id, p = t.dataIdMap.get(i.dataId).id, d = t.dataIdMap.get(o.dataId).id, h = u != null ? t.dataIdMap.get(u.dataId).id : 0, f = l != null ? t.dataIdMap.get(l.dataId).id : 0, m = t.makeOutput(a.shape, a.dtype); if (w.sizeFromShape(a.shape) === 0) return m; let g = t.dataIdMap.get(m.dataId).id; return oN(c, p, d, h, f, r, g), m; } -var _ue = { kernelName: Ma, backendName: "wasm", setupFunc: Tue, kernelFunc: $ue }; +var Aue = { kernelName: Ma, backendName: "wasm", setupFunc: $ue, kernelFunc: _ue }; var uN; -function Aue(e) { +function Eue(e) { uN = e.wasm.cwrap(aa, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function Eue(e) { +function Rue(e) { let { inputs: t, attrs: n, backend: s } = e, { x: r, filter: a, bias: i, preluActivationWeights: o } = t, { strides: u, pad: l, dilations: c, dataFormat: p, dimRoundingMode: d, activation: h, leakyreluAlpha: f } = n, m = S.computeConv2DInfo(r.shape, a.shape, u, c, l, d), g = Jp[h]; if (g == null) throw new Error(`${h} activation not yet supported for FusedConv2D in the wasm backend.`); @@ -37032,12 +36921,12 @@ function Eue(e) { let te = s.makeOutput(m.outShape, "float32"), ee = s.dataIdMap.get(te.dataId).id, se = o == null ? 0 : s.dataIdMap.get(o.dataId).id; return uN(b, K, Y, Z, y, k, T, x, N, E, A, P, q, R, F, $, z, W, v, g, se, f || 0, ee), te; } -var Rue = { kernelName: aa, backendName: "wasm", setupFunc: Aue, kernelFunc: Eue }; +var Due = { kernelName: aa, backendName: "wasm", setupFunc: Eue, kernelFunc: Rue }; var lN; -function Due(e) { +function Fue(e) { lN = e.wasm.cwrap(ia, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function Fue(e) { +function Oue(e) { let { inputs: t, attrs: n, backend: s } = e, { x: r, filter: a, bias: i, preluActivationWeights: o } = t, { strides: u, pad: l, dilations: c, dataFormat: p, dimRoundingMode: d, activation: h, leakyreluAlpha: f } = n, m = S.computeConv2DInfo(r.shape, a.shape, u, c, l, d, true), g = Jp[h]; if (g == null) throw new Error(`${h} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`); @@ -37056,24 +36945,24 @@ function Fue(e) { let te = s.makeOutput(m.outShape, "float32"), ee = s.dataIdMap.get(te.dataId).id, se = o == null ? 0 : s.dataIdMap.get(o.dataId).id; return lN(b, K, Y, Z, y, k, T, x, N, E, A, P, q, R, F, $, z, W, v, g, se, f || 0, ee), te; } -var Oue = { kernelName: ia, backendName: "wasm", setupFunc: Due, kernelFunc: Fue }; +var Pue = { kernelName: ia, backendName: "wasm", setupFunc: Fue, kernelFunc: Oue }; var cN; -function Pue(e) { - cN = e.wasm.cwrap(bo, null, ["number", "number", "number", "number", "number", "number", "array", "number"]); -} function zue(e) { + cN = e.wasm.cwrap(yo, null, ["number", "number", "number", "number", "number", "number", "array", "number"]); +} +function Mue(e) { let { backend: t, inputs: n } = e, { params: s, indices: r } = n, [a, i, o, u] = $k.prepareAndValidate(s, r), l = t.makeOutput(a, s.dtype); if (i === 0) return l; let c = r.shape, p = c[c.length - 1], h = t.dataIdMap.get(s.dataId).id, m = t.dataIdMap.get(r.dataId).id, g = new Uint8Array(new Int32Array(u).buffer), b = t.dataIdMap.get(l.dataId).id; return cN(h, It[s.dtype], m, i, p, o, g, b), l; } -var Mue = { kernelName: bo, backendName: "wasm", setupFunc: Pue, kernelFunc: zue }; +var Lue = { kernelName: yo, backendName: "wasm", setupFunc: zue, kernelFunc: Mue }; var dN; -function Lue(e) { +function Bue(e) { dN = e.wasm.cwrap("Gather", null, ["number", "number", "array", "number", "number", "number", "array", "number"]); } -function Bue(e) { +function Vue(e) { let { backend: t, inputs: n, attrs: s } = e, { x: r, indices: a } = n, { axis: i, batchDims: o } = s, u = w.parseAxisParam(i, r.shape)[0], l = t.readSync(a.dataId), c = r.shape[u]; for (let A = 0; A < l.length; ++A) { let P = l[A]; @@ -37085,16 +36974,16 @@ function Bue(e) { let b = d.shape.length - 1, v = t.dataIdMap.get(d.dataId).id, k = t.dataIdMap.get(f.dataId).id, T = t.dataIdMap.get(g.dataId).id, N = new Uint8Array(new Int32Array(w.computeStrides(d.shape)).buffer), E = new Uint8Array(new Int32Array(w.computeStrides(m)).buffer); return dN(v, It[r.dtype], N, b, k, p.batchSize, E, T), t.disposeData(d.dataId), t.disposeData(f.dataId), g.shape = p.outputShape, g; } -var Vue = { kernelName: go, backendName: "wasm", setupFunc: Lue, kernelFunc: Bue }; -var Wue = false; -var Uue = gn(yo, Wue, "bool"); -var Gue = false; -var Hue = gn(La, Gue, "bool"); +var Wue = { kernelName: bo, backendName: "wasm", setupFunc: Bue, kernelFunc: Vue }; +var Uue = false; +var Gue = gn(vo, Uue, "bool"); +var Hue = false; +var que = gn(La, Hue, "bool"); var pN; -function que(e) { +function jue(e) { pN = e.wasm.cwrap(Va, null, ["number", "number", "number", "number"]); } -function jue(e) { +function Kue(e) { let { inputs: { x: t }, attrs: { alpha: n }, backend: s } = e, r = s.dataIdMap.get(t.dataId).id, a = s.makeOutput(t.shape, "float32"); if (w.sizeFromShape(t.shape) !== 0) { let i = s.dataIdMap.get(a.dataId).id; @@ -37102,19 +36991,19 @@ function jue(e) { } return a; } -var Kue = { kernelName: Va, backendName: "wasm", setupFunc: que, kernelFunc: jue }; -var Xue = false; -var Yue = gn(vo, Xue, "bool"); -var Que = false; -var Zue = gn(xo, Que, "bool"); -var Jue = Xt(Wa); -var ele = false; -var tle = gn(wo, ele, "bool"); +var Xue = { kernelName: Va, backendName: "wasm", setupFunc: jue, kernelFunc: Kue }; +var Yue = false; +var Que = gn(xo, Yue, "bool"); +var Zue = false; +var Jue = gn(wo, Zue, "bool"); +var ele = Xt(Wa); +var tle = false; +var nle = gn(ko, tle, "bool"); var hN; -function nle(e) { +function sle(e) { hN = e.wasm.cwrap(Ua, null, ["number", "number", "number", "number"]); } -function sle(e) { +function rle(e) { let { backend: t, inputs: n, attrs: s } = e, { reductionIndices: r, keepDims: a } = s, { x: i } = n, u = t.dataIdMap.get(i.dataId).id, l = i, { transposed: c, axes: p, originalAxes: d, inputWasTransposed: h } = Fr(i, r, t); if (h) { let v = t.dataIdMap.get(c.dataId).id; @@ -37133,14 +37022,14 @@ function sle(e) { } return y; } -var rle = { kernelName: Ua, backendName: "wasm", setupFunc: nle, kernelFunc: sle }; -var ale = false; -var ile = gn(Ga, ale); +var ale = { kernelName: Ua, backendName: "wasm", setupFunc: sle, kernelFunc: rle }; +var ile = false; +var ole = gn(Ga, ile); var fN; -function ole(e) { +function ule(e) { fN = e.wasm.cwrap(Ha, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function ule(e) { +function lle(e) { let { inputs: t, attrs: n, backend: s } = e, r = t.x, a = s.dataIdMap.get(r.dataId).id; w.assert(r.dtype === "float32", () => `Error in MaxPool: only float32 input is supported. Got ${r.dtype}.`); let { filterSize: i, strides: o, pad: u, dimRoundingMode: l } = n, c = S.computePool2DInfo(r.shape, i, o, 1, u, l), p = c.filterHeight, d = c.filterWidth, h = c.padInfo.top, f = c.padInfo.right, m = c.padInfo.bottom, g = c.padInfo.left, b = c.dilationHeight, y = c.dilationWidth, v = c.strideHeight, x = c.strideWidth, k = c.inChannels, T = c.outChannels; @@ -37149,12 +37038,12 @@ function ule(e) { let N = s.makeOutput(c.outShape, "float32"), E = s.dataIdMap.get(N.dataId).id; return fN(a, r.shape[0], r.shape[1], r.shape[2], p, d, h, f, m, g, b, y, v, x, k, T, E), N; } -var lle = { kernelName: Ha, backendName: "wasm", setupFunc: ole, kernelFunc: ule }; +var cle = { kernelName: Ha, backendName: "wasm", setupFunc: ule, kernelFunc: lle }; var mN; -function cle(e) { +function dle(e) { mN = e.wasm.cwrap(qa, null, ["number, number, number"]); } -function dle(e) { +function ple(e) { let { backend: t, inputs: n, attrs: s } = e, { axis: r, keepDims: a } = s, { x: i } = n, o = t.dataIdMap.get(i.dataId).id, u = o, l = i, { transposed: c, axes: p, originalAxes: d, inputWasTransposed: h } = Fr(i, r, t), f = p; if (h) { let x = t.dataIdMap.get(c.dataId).id; @@ -37174,12 +37063,12 @@ function dle(e) { } return l.dtype !== "float32" && t.disposeData(y.dataId), v; } -var ple = { kernelName: qa, backendName: "wasm", setupFunc: cle, kernelFunc: dle }; +var hle = { kernelName: qa, backendName: "wasm", setupFunc: dle, kernelFunc: ple }; var gN; -function hle(e) { +function fle(e) { gN = e.wasm.cwrap(ja, null, ["number", "number", "number", "number"]); } -function fle(e) { +function mle(e) { let { backend: t, inputs: n, attrs: s } = e, { axis: r, keepDims: a } = s, { x: i } = n, o = t.dataIdMap.get(i.dataId).id, u = o, l = i, { transposed: c, axes: p, originalAxes: d, inputWasTransposed: h } = Fr(i, r, t); if (h) { let v = t.dataIdMap.get(c.dataId).id; @@ -37198,74 +37087,74 @@ function fle(e) { } return y; } -var mle = { kernelName: ja, backendName: "wasm", setupFunc: hle, kernelFunc: fle }; -var gle = false; -var ble = gn(Ka, gle); +var gle = { kernelName: ja, backendName: "wasm", setupFunc: fle, kernelFunc: mle }; +var ble = false; +var yle = gn(Ka, ble); var bN = ((e) => (e[e.reflect = 0] = "reflect", e[e.symmetric = 1] = "symmetric", e))(bN || {}); var yN; -function yle(e) { +function vle(e) { yN = e.wasm.cwrap(Xa, null, ["number", "array", "number", "number", "array", "array", "number", "number"]); } -function vle(e) { +function xle(e) { let { inputs: { x: t }, backend: n, attrs: { paddings: s, mode: r } } = e, a = s.map((f, m) => f[0] + t.shape[m] + f[1]), i = n.dataIdMap.get(t.dataId).id, o = n.makeOutput(a, t.dtype), u = n.dataIdMap.get(o.dataId).id, l = new Uint8Array(new Int32Array(t.shape).buffer), c = s.map((f) => f[0]), p = s.map((f) => f[1]), d = new Uint8Array(new Int32Array(c).buffer), h = new Uint8Array(new Int32Array(p).buffer); return yN(i, l, t.shape.length, It[t.dtype], d, h, bN[r], u), o; } -var xle = { kernelName: Xa, backendName: "wasm", kernelFunc: vle, setupFunc: yle }; -var wle = true; -var kle = gn(Ya, wle); -var Ile = Xt(ko); +var wle = { kernelName: Xa, backendName: "wasm", kernelFunc: xle, setupFunc: vle }; +var kle = true; +var Ile = gn(Ya, kle); +var Sle = Xt(Io); function Rv(e, t) { let n = new Int32Array(e.wasm.HEAPU8.buffer, t, 4), s = n[0], r = n[1], a = n[2], i = n[3]; return e.wasm._free(t), { pSelectedIndices: s, selectedSize: r, pSelectedScores: a, pValidOutputs: i }; } var vN; -function Sle(e) { - vN = e.wasm.cwrap(So, "number", ["number", "number", "number", "number", "number"]); -} function Cle(e) { + vN = e.wasm.cwrap(Co, "number", ["number", "number", "number", "number", "number"]); +} +function Nle(e) { let { backend: t, inputs: n, attrs: s } = e, { iouThreshold: r, maxOutputSize: a, scoreThreshold: i } = s, { boxes: o, scores: u } = n, l = t.dataIdMap.get(o.dataId).id, c = t.dataIdMap.get(u.dataId).id, p = vN(l, c, a, r, i), { pSelectedIndices: d, selectedSize: h, pSelectedScores: f, pValidOutputs: m } = Rv(t, p); return t.wasm._free(f), t.wasm._free(m), t.makeOutput([h], "int32", d); } -var Nle = { kernelName: So, backendName: "wasm", setupFunc: Sle, kernelFunc: Cle }; +var Tle = { kernelName: Co, backendName: "wasm", setupFunc: Cle, kernelFunc: Nle }; var xN; -function Tle(e) { - xN = e.wasm.cwrap(wl, "number", ["number", "number", "number", "number", "number", "bool"]); -} function $le(e) { + xN = e.wasm.cwrap(kl, "number", ["number", "number", "number", "number", "number", "bool"]); +} +function _le(e) { let { backend: t, inputs: n, attrs: s } = e, { iouThreshold: r, maxOutputSize: a, scoreThreshold: i, padToMaxOutputSize: o } = s, { boxes: u, scores: l } = n, c = t.dataIdMap.get(u.dataId).id, p = t.dataIdMap.get(l.dataId).id, d = xN(c, p, a, r, i, o), { pSelectedIndices: h, selectedSize: f, pSelectedScores: m, pValidOutputs: g } = Rv(t, d); t.wasm._free(m); let b = t.makeOutput([f], "int32", h), y = t.makeOutput([], "int32", g); return [b, y]; } -var _le = { kernelName: wl, backendName: "wasm", setupFunc: Tle, kernelFunc: $le }; +var Ale = { kernelName: kl, backendName: "wasm", setupFunc: $le, kernelFunc: _le }; var wN; -function Ale(e) { - wN = e.wasm.cwrap(Co, "number", ["number", "number", "number", "number", "number", "number"]); -} function Ele(e) { + wN = e.wasm.cwrap(No, "number", ["number", "number", "number", "number", "number", "number"]); +} +function Rle(e) { let { backend: t, inputs: n, attrs: s } = e, { iouThreshold: r, maxOutputSize: a, scoreThreshold: i, softNmsSigma: o } = s, { boxes: u, scores: l } = n, c = t.dataIdMap.get(u.dataId).id, p = t.dataIdMap.get(l.dataId).id, d = wN(c, p, a, r, i, o), { pSelectedIndices: h, selectedSize: f, pSelectedScores: m, pValidOutputs: g } = Rv(t, d); t.wasm._free(g); let b = t.makeOutput([f], "int32", h), y = t.makeOutput([f], "float32", m); return [b, y]; } -var Rle = { kernelName: Co, backendName: "wasm", setupFunc: Ale, kernelFunc: Ele }; -var Dle = false; -var Fle = gn(Io, Dle, "bool"); +var Dle = { kernelName: No, backendName: "wasm", setupFunc: Ele, kernelFunc: Rle }; +var Fle = false; +var Ole = gn(So, Fle, "bool"); var kN; -function Ole(e) { - kN = e.wasm.cwrap(To, null, ["number", "number", "number", "number", "number"]); -} function Ple(e) { + kN = e.wasm.cwrap($o, null, ["number", "number", "number", "number", "number"]); +} +function zle(e) { let { inputs: t, backend: n, attrs: s } = e, { indices: r } = t, { depth: a, onValue: i, offValue: o } = s, u = n.makeOutput([...r.shape, a], "int32"), l = n.dataIdMap.get(u.dataId).id, p = n.dataIdMap.get(r.dataId).id; return kN(p, a, i, o, l), u; } -var zle = { kernelName: To, backendName: "wasm", setupFunc: Ole, kernelFunc: Ple }; -function Mle(e) { +var Mle = { kernelName: $o, backendName: "wasm", setupFunc: Ple, kernelFunc: zle }; +function Lle(e) { let { inputs: { x: t }, backend: n } = e, s = n.makeOutput(t.shape, t.dtype); return n.typedArrayFromHeap(s).fill(1), s; } -var Lle = { kernelName: No, backendName: "wasm", kernelFunc: Mle }; -function Ble(e) { +var Ble = { kernelName: To, backendName: "wasm", kernelFunc: Lle }; +function Vle(e) { let { inputs: t, backend: n, attrs: s } = e, { axis: r } = s; if (t.length === 1) return Zm({ inputs: { input: t[0] }, backend: n, attrs: { dim: r } }); @@ -37279,37 +37168,37 @@ function Ble(e) { }), l = Y2({ inputs: u, backend: n, attrs: { axis: r } }); return o.forEach((c) => n.disposeData(c.dataId)), l; } -var Vle = { kernelName: $o, backendName: "wasm", kernelFunc: Ble }; +var Wle = { kernelName: _o, backendName: "wasm", kernelFunc: Vle }; var IN; -function Wle(e) { +function Ule(e) { IN = e.wasm.cwrap(Qa, null, ["number", "array", "number", "number", "array", "array", "number", "number"]); } -function Ule(e) { +function Gle(e) { let { inputs: { x: t }, backend: n, attrs: { paddings: s, constantValue: r } } = e, a = s.map((m, g) => m[0] + t.shape[g] + m[1]); if (w.sizeFromShape(t.shape) === 0) return aN({ backend: n, attrs: { shape: a, value: r, dtype: t.dtype } }); let i = n.dataIdMap.get(t.dataId).id, o = n.makeOutput(a, t.dtype), l = n.dataIdMap.get(o.dataId).id, c = new Uint8Array(new Int32Array(t.shape).buffer), p = s.map((m) => m[0]), d = s.map((m) => m[1]), h = new Uint8Array(new Int32Array(p).buffer), f = new Uint8Array(new Int32Array(d).buffer); return IN(i, c, t.shape.length, It[t.dtype], h, f, r, l), o; } -var SN = { kernelName: Qa, backendName: "wasm", kernelFunc: Ule, setupFunc: Wle }; -var Gle = false; -var Hle = gn(Za, Gle); +var SN = { kernelName: Qa, backendName: "wasm", kernelFunc: Gle, setupFunc: Ule }; +var Hle = false; +var qle = gn(Za, Hle); var CN; -function qle(e) { +function jle(e) { CN = e.wasm.cwrap(Ja, null, ["number", "number", "number"]); } -function jle(e) { +function Kle(e) { let { inputs: t, backend: n } = e, { x: s, alpha: r } = t, a = n.dataIdMap.get(s.dataId).id, i = n.dataIdMap.get(r.dataId).id, o = a, u = s, l = u; u.dtype !== "float32" && (l = ac({ backend: n, inputs: { x: s }, attrs: { dtype: "float32" } }), o = n.dataIdMap.get(l.dataId).id); let c = n.makeOutput(s.shape, "float32"), p = n.dataIdMap.get(c.dataId).id; return CN(o, i, p), u.dtype !== "float32" && n.disposeData(l.dataId), c; } -var Kle = { kernelName: Ja, backendName: "wasm", setupFunc: qle, kernelFunc: jle }; +var Xle = { kernelName: Ja, backendName: "wasm", setupFunc: jle, kernelFunc: Kle }; var NN; -function Xle(e) { - NN = e.wasm.cwrap(_o, null, ["number", "number", "number", "number"]); -} function Yle(e) { + NN = e.wasm.cwrap(Ao, null, ["number", "number", "number", "number"]); +} +function Qle(e) { let { backend: t, inputs: n, attrs: s } = e, { axis: r, keepDims: a } = s, { x: i } = n, o = t.dataIdMap.get(i.dataId).id, u = o, l = i, { transposed: c, axes: p, originalAxes: d, inputWasTransposed: h } = Fr(i, r, t), f = p; if (h) { let v = t.dataIdMap.get(c.dataId).id; @@ -37327,21 +37216,21 @@ function Yle(e) { } return y; } -var Qle = { kernelName: _o, backendName: "wasm", setupFunc: Xle, kernelFunc: Yle }; -var Zle = (e) => { +var Zle = { kernelName: Ao, backendName: "wasm", setupFunc: Yle, kernelFunc: Qle }; +var Jle = (e) => { let { backend: t, attrs: n } = e, { start: s, stop: r, step: a, dtype: i } = n, o = rv(s, r, a, i), u = t.makeOutput([o.length], i); return t.typedArrayFromHeap(u).set(o), u; }; -var Jle = { kernelName: kl, backendName: "wasm", kernelFunc: Zle }; -var ece = true; -var tce = gn(Da, ece); -var nce = Xt(ei); -var sce = Xt(ni); +var ece = { kernelName: Il, backendName: "wasm", kernelFunc: Jle }; +var tce = true; +var nce = gn(Da, tce); +var sce = Xt(ei); +var rce = Xt(ni); var TN; -function rce(e) { +function ace(e) { TN = e.wasm.cwrap(ti, null, ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function ace(e) { +function ice(e) { let { backend: t, inputs: n, attrs: s } = e, { images: r } = n, { alignCorners: a, halfPixelCenters: i, size: o } = s, [u, l] = o, [c, p, d, h] = r.shape, f = [c, u, l, h], m = t.dataIdMap.get(r.dataId), g; m.dtype !== "float32" && (g = ac({ backend: t, inputs: { x: r }, attrs: { dtype: "float32" } }), m = t.dataIdMap.get(g.dataId)); let b = m.id, y = t.makeOutput(f, "float32"); @@ -37350,12 +37239,12 @@ function ace(e) { let v = t.dataIdMap.get(y.dataId).id; return TN(b, c, p, d, h, u, l, a ? 1 : 0, i ? 1 : 0, v), g != null && t.disposeData(g.dataId), y; } -var ice = { kernelName: ti, backendName: "wasm", setupFunc: rce, kernelFunc: ace }; +var oce = { kernelName: ti, backendName: "wasm", setupFunc: ace, kernelFunc: ice }; var $N; -function oce(e) { - $N = e.wasm.cwrap(Eo, null, ["number", "array", "number", "array", "number", "number"]); -} function uce(e) { + $N = e.wasm.cwrap(Ro, null, ["number", "array", "number", "array", "number", "number"]); +} +function lce(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { dims: a } = s, i = w.parseAxisParam(a, r.shape); if (r.shape.length === 0) return eh({ inputs: { x: r }, backend: n }); @@ -37364,59 +37253,59 @@ function uce(e) { let d = yn({ inputs: { x: o }, attrs: { shape: r.shape }, backend: n }); return n.disposeData(o.dataId), d; } -var lce = { kernelName: Eo, backendName: "wasm", kernelFunc: uce, setupFunc: oce }; +var cce = { kernelName: Ro, backendName: "wasm", kernelFunc: lce, setupFunc: uce }; var _N; -function cce(e) { - _N = e.wasm.cwrap(Ho, null, ["number", "number", "number", "number", "number", "number", "number", "number", "array", "number", "number"]); -} function dce(e) { + _N = e.wasm.cwrap(qo, null, ["number", "number", "number", "number", "number", "number", "number", "number", "array", "number", "number"]); +} +function pce(e) { let { inputs: t, backend: n, attrs: s } = e, { image: r } = t, { radians: a, fillValue: i, center: o } = s, u = n.makeOutput(r.shape, r.dtype), l = n.dataIdMap.get(r.dataId).id, c = n.dataIdMap.get(u.dataId).id, [p, d, h, f] = r.shape, [m, g] = S.getImageCenter(o, d, h), b = i === 0, y = 255, v = typeof i == "number" ? [i, i, i, b ? 0 : y] : [...i, y], x = new Uint8Array(new Int32Array(v).buffer); return _N(l, p, d, h, f, a, m, g, x, v.length, c), u; } -var pce = { kernelName: Ho, backendName: "wasm", kernelFunc: dce, setupFunc: cce }; -var hce = Xt(Ro); -var fce = Xt(si); +var hce = { kernelName: qo, backendName: "wasm", kernelFunc: pce, setupFunc: dce }; +var fce = Xt(Do); +var mce = Xt(si); var AN; -function mce(e) { - AN = e.wasm.cwrap(Do, null, ["number", "number", "number", "number", "number", "number", "array", "number", "number"]); -} function gce(e) { + AN = e.wasm.cwrap(Fo, null, ["number", "number", "number", "number", "number", "number", "array", "number", "number"]); +} +function bce(e) { let { backend: t, inputs: n, attrs: s } = e, { indices: r, updates: a } = n, { shape: i } = s, o = t.makeOutput(i, a.dtype); if (w.sizeFromShape(i) === 0) return o; let { sliceRank: u, numUpdates: l, sliceSize: c, strides: p, outputSize: d } = Ak.calculateShapes(a, r, i), f = t.dataIdMap.get(r.dataId).id, g = t.dataIdMap.get(a.dataId).id, b = new Uint8Array(new Int32Array(p).buffer), y = t.dataIdMap.get(o.dataId).id; return AN(f, g, It[a.dtype], u, l, c, b, d, y), o; } -var bce = { kernelName: Do, backendName: "wasm", setupFunc: mce, kernelFunc: gce }; +var yce = { kernelName: Fo, backendName: "wasm", setupFunc: gce, kernelFunc: bce }; var EN; -function yce(e) { +function vce(e) { EN = e.wasm.cwrap("SelectV2", null, ["number", "number", "number", "number", "number"]); } -function vce(e) { +function xce(e) { let { inputs: t, backend: n } = e, { condition: s, t: r, e: a } = t, i = n.dataIdMap.get(s.dataId).id, o = n.dataIdMap.get(r.dataId).id, u = n.dataIdMap.get(a.dataId).id, l = n.makeOutput(r.shape, r.dtype), c = n.dataIdMap.get(l.dataId).id, p = s.shape.length, d = r.shape.length, h = p === 0 || p > 1 || d === 1 ? 1 : w.sizeFromShape(r.shape.slice(1)); return EN(i, o, u, h, c), l; } -var xce = { kernelName: Fo, backendName: "wasm", kernelFunc: vce, setupFunc: yce }; +var wce = { kernelName: Oo, backendName: "wasm", kernelFunc: xce, setupFunc: vce }; var RN; -function wce(e) { +function kce(e) { RN = e.wasm.cwrap(ai, null, ["number", "number"]); } -function kce(e) { +function Ice(e) { let { backend: t, inputs: { x: n } } = e, s = t.dataIdMap.get(n.dataId).id, r = t.makeOutput(n.shape, n.dtype), a = t.dataIdMap.get(r.dataId).id; return w.sizeFromShape(r.shape) === 0 || RN(s, a), r; } -var Ice = { kernelName: "Sigmoid", backendName: "wasm", setupFunc: wce, kernelFunc: kce }; -var Sce = Xt(ri); +var Sce = { kernelName: "Sigmoid", backendName: "wasm", setupFunc: kce, kernelFunc: Ice }; +var Cce = Xt(ri); var DN; -function Cce(e) { +function Nce(e) { DN = e.wasm.cwrap(ui, null, ["number", "number", "number", "number"]); } -function Nce(e) { +function Tce(e) { let { backend: t, inputs: { logits: n }, attrs: { dim: s } } = e, r = t.dataIdMap.get(n.dataId).id, a = t.makeOutput(n.shape, n.dtype), i = t.dataIdMap.get(a.dataId).id, o = n.shape[s], u = w.sizeFromShape(n.shape) / o; return w.sizeFromShape(a.shape) === 0 || DN(r, i, o, u), a; } -var Tce = { kernelName: ui, backendName: "wasm", setupFunc: Cce, kernelFunc: Nce }; -function $ce(e) { +var $ce = { kernelName: ui, backendName: "wasm", setupFunc: Nce, kernelFunc: Tce }; +function _ce(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, { blockShape: a, paddings: i } = s, o = w.sizeFromShape(a), u = [[0, 0]]; u.push(...i); for (let T = 1 + a.length; T < r.shape.length; ++T) @@ -37424,12 +37313,12 @@ function $ce(e) { let l = SN.kernelFunc({ inputs: { x: r }, backend: n, attrs: { paddings: u, constantValue: 0 } }), c = S.getReshaped(l.shape, a, o, false), p = S.getPermuted(c.length, a.length, false), d = S.getReshapedPermuted(l.shape, a, o, false), m = yn({ inputs: { x: l }, backend: n, attrs: { shape: c } }), y = wr({ inputs: { x: m }, backend: n, attrs: { perm: p } }), k = yn({ inputs: { x: y }, backend: n, attrs: { shape: d } }); return n.disposeData(l.dataId), n.disposeData(m.dataId), n.disposeData(y.dataId), k; } -var _ce = { kernelName: zo, backendName: "wasm", kernelFunc: $ce }; +var Ace = { kernelName: Mo, backendName: "wasm", kernelFunc: _ce }; var FN; -function Ace(e) { +function Ece(e) { FN = e.wasm.cwrap("SparseFillEmptyRows", "number", ["number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number"]); } -function Ece(e) { +function Rce(e) { let { backend: t, inputs: n } = e, { indices: s, values: r, denseShape: a, defaultValue: i } = n, o = s.shape[0], u = s.shape[1], l = t.readSync(a.dataId)[0], c = [o + l, u], p = t.dataIdMap.get(s.dataId).id, d = t.dataIdMap.get(r.dataId).id, h = t.dataIdMap.get(i.dataId).id, f = t.makeOutput(c, s.dtype), m = t.dataIdMap.get(f.dataId).id, g = t.makeOutput(c.slice(0, 1), r.dtype), b = t.dataIdMap.get(g.dataId).id, y = t.makeOutput([l], "bool"), v = t.dataIdMap.get(y.dataId).id, x = t.makeOutput([o], s.dtype), k = t.dataIdMap.get(x.dataId).id, T = t.makeOutput([4], "int32"), N = t.dataIdMap.get(T.dataId).id, E = FN(p, d, It[r.dtype], o, l, u, h, m, b, v, k, N), A = t.readSync(T.dataId), P; switch (A[0]) { case 1: { @@ -37451,12 +37340,12 @@ function Ece(e) { let R = f, F = g; return E !== c[0] && (R = va({ inputs: { x: f }, attrs: { begin: 0, size: [E, u] }, backend: t }), F = va({ inputs: { x: g }, attrs: { begin: 0, size: E }, backend: t }), t.disposeData(f.dataId), t.disposeData(g.dataId)), [R, F, y, x]; } -var Rce = { kernelName: sp, backendName: "wasm", setupFunc: Ace, kernelFunc: Ece }; +var Dce = { kernelName: sp, backendName: "wasm", setupFunc: Ece, kernelFunc: Rce }; var ON; -function Dce(e) { - ON = e.wasm.cwrap($l, null, ["number", "number", "number", "number", "number", "number", "number"]); -} function Fce(e) { + ON = e.wasm.cwrap(_l, null, ["number", "number", "number", "number", "number", "number", "number"]); +} +function Oce(e) { let { backend: t, inputs: n } = e, { inputIndices: s, inputShape: r, newShape: a } = n; if (s.shape.length !== 2) throw new Error(`Input indices should be a matrix but received shape @@ -37498,7 +37387,7 @@ function Fce(e) { throw t.disposeData(p.dataId), t.disposeData(h.dataId), new Error(y); return [p, h]; } -var Oce = { kernelName: $l, backendName: "wasm", setupFunc: Dce, kernelFunc: Fce }; +var Pce = { kernelName: _l, backendName: "wasm", setupFunc: Fce, kernelFunc: Oce }; var PN; function zN(e) { PN = e.wasm.cwrap("SparseSegmentReduction", null, ["number", "number", "number", "number", "number", "number", "number", "number", "number"]); @@ -37534,15 +37423,15 @@ function MN(e, t) { throw n.disposeData(m.dataId), new Error(x); return m; } -function Pce(e) { +function zce(e) { return MN(e, true); } -var zce = { kernelName: rp, backendName: "wasm", setupFunc: zN, kernelFunc: Pce }; -function Mce(e) { +var Mce = { kernelName: rp, backendName: "wasm", setupFunc: zN, kernelFunc: zce }; +function Lce(e) { return MN(e, false); } -var Lce = { kernelName: ap, backendName: "wasm", setupFunc: zN, kernelFunc: Mce }; -function Bce(e) { +var Bce = { kernelName: ap, backendName: "wasm", setupFunc: zN, kernelFunc: Lce }; +function Vce(e) { let { inputs: t, attrs: n, backend: s } = e, { x: r } = t, { numOrSizeSplits: a, axis: i } = n, o = w.parseAxisParam(i, r.shape)[0], u = S.prepareSplitSize(r, a, o), l = new Array(r.shape.length).fill(0), c = r.shape.slice(); return u.map((p) => { let d = [...c]; @@ -37551,25 +37440,25 @@ function Bce(e) { return l[o] += p, h; }); } -var Vce = { kernelName: Mo, backendName: "wasm", kernelFunc: Bce }; -var Wce = Xt(ii); -var Uce = Xt(_l); -var Gce = true; -var Hce = gn(li, Gce); +var Wce = { kernelName: Lo, backendName: "wasm", kernelFunc: Vce }; +var Uce = Xt(ii); +var Gce = Xt(Al); +var Hce = true; +var qce = gn(li, Hce); var LN; -function qce(e) { +function jce(e) { LN = e.wasm.cwrap(hi, null, ["number", "number", "number", "number"]); } -function jce(e) { +function Kce(e) { let { backend: t, inputs: n, attrs: s } = e, { alpha: r } = s, { x: a } = n, i = t.dataIdMap.get(a.dataId).id, o = t.makeOutput(a.shape, a.dtype), u = t.dataIdMap.get(o.dataId).id; return LN(i, r, It[a.dtype], u), o; } -var Kce = { kernelName: hi, backendName: "wasm", setupFunc: qce, kernelFunc: jce }; +var Xce = { kernelName: hi, backendName: "wasm", setupFunc: jce, kernelFunc: Kce }; var BN; -function Xce(e) { - BN = e.wasm.cwrap(Lo, null, ["number", "array", "number", "array", "array", "array", "array", "array", "number", "number"]); -} function Yce(e) { + BN = e.wasm.cwrap(Bo, null, ["number", "array", "number", "array", "array", "array", "array", "array", "number", "number"]); +} +function Qce(e) { let { backend: t, inputs: n, attrs: s } = e, { x: r } = n, { begin: a, end: i, strides: o, beginMask: u, endMask: l, ellipsisMask: c, newAxisMask: p, shrinkAxisMask: d } = s, { finalShapeSparse: h, finalShape: f, isIdentity: m, sliceDim0: g, isSimpleSlice: b, begin: y, end: v, strides: x } = wt.sliceInfo(r.shape, a, i, o, u, l, c, p, d), k; if (m) k = yn({ inputs: { x: r }, backend: t, attrs: { shape: f } }); @@ -37583,14 +37472,14 @@ function Yce(e) { } return k; } -var Qce = { kernelName: Lo, backendName: "wasm", setupFunc: Xce, kernelFunc: Yce }; -var Zce = true; -var Jce = gn(ci, Zce); +var Zce = { kernelName: Bo, backendName: "wasm", setupFunc: Yce, kernelFunc: Qce }; +var Jce = true; +var ede = gn(ci, Jce); var VN; -function ede(e) { +function tde(e) { VN = e.wasm.cwrap(oi, null, ["number", "number", "number", "number"]); } -function tde(e) { +function nde(e) { let { backend: t, inputs: n, attrs: s } = e, { axis: r, keepDims: a } = s, { x: i } = n, o = t.dataIdMap.get(i.dataId).id, u = o, l = i, { transposed: c, axes: p, originalAxes: d, inputWasTransposed: h } = Fr(i, r, t), f = p; if (h) { let v = t.dataIdMap.get(c.dataId).id; @@ -37608,37 +37497,37 @@ function tde(e) { } return y; } -var nde = { kernelName: oi, backendName: "wasm", setupFunc: ede, kernelFunc: tde }; -var sde = Xt(Bo); -var rde = Xt(di); +var sde = { kernelName: oi, backendName: "wasm", setupFunc: tde, kernelFunc: nde }; +var rde = Xt(Vo); +var ade = Xt(di); var WN; -function ade(e) { +function ide(e) { WN = e.wasm.cwrap(Cr, null, ["number", "array", "number", "array", "number", "number"]); } -function ide(e) { +function ode(e) { let { inputs: t, backend: n, attrs: s } = e, { x: r } = t, a = n.dataIdMap.get(r.dataId).id, { reps: i } = s, o = new Array(r.shape.length); for (let d = 0; d < o.length; d++) o[d] = r.shape[d] * i[d]; let u = new Uint8Array(new Int32Array(r.shape).buffer), l = new Uint8Array(new Int32Array(o).buffer), c = n.makeOutput(o, r.dtype), p = n.dataIdMap.get(c.dataId).id; return WN(a, u, r.shape.length, l, o.length, It[c.dtype], p), c; } -var ode = { kernelName: Cr, backendName: "wasm", setupFunc: ade, kernelFunc: ide }; +var ude = { kernelName: Cr, backendName: "wasm", setupFunc: ide, kernelFunc: ode }; var UN; -function ude(e) { - UN = e.wasm.cwrap(Vo, null, ["number", "array", "number", "number", "number", "bool", "number", "number"]); +function lde(e) { + UN = e.wasm.cwrap(Wo, null, ["number", "array", "number", "number", "number", "bool", "number", "number"]); } -var lde = ({ inputs: e, backend: t, attrs: n }) => { +var cde = ({ inputs: e, backend: t, attrs: n }) => { let { x: s } = e, { k: r, sorted: a } = n, i = t.dataIdMap.get(s.dataId).id, o = new Uint8Array(new Int32Array(s.shape).buffer), u = s.shape.slice(); u[u.length - 1] = r; let l = t.makeOutput(u, s.dtype), c = t.dataIdMap.get(l.dataId).id, p = t.makeOutput(u, "int32"), d = t.dataIdMap.get(p.dataId).id; return UN(i, o, s.shape.length, It[s.dtype], r, a, c, d), [l, p]; }; -var cde = { kernelName: Vo, backendName: "wasm", setupFunc: ude, kernelFunc: lde }; +var dde = { kernelName: Wo, backendName: "wasm", setupFunc: lde, kernelFunc: cde }; var GN; -function dde(e) { - GN = e.wasm.cwrap(Wo, null, ["number", "number", "bool", "number", "number", "number", "number", "number", "number", "array", "number", "number", "number", "number", "number"]); -} function pde(e) { + GN = e.wasm.cwrap(Uo, null, ["number", "number", "bool", "number", "number", "number", "number", "number", "number", "array", "number", "number", "number", "number", "number"]); +} +function hde(e) { let { backend: t, inputs: n, attrs: s } = e, { image: r, transforms: a } = n, { interpolation: i, fillMode: o, fillValue: u, outputShape: l } = s, [c, p, d, h] = r.shape, [f, m] = l != null ? l : [p, d], g = [c, f, m, h], b = new Uint8Array(new Int32Array(w.computeStrides(r.shape)).buffer), y = t.makeOutput(g, r.dtype), v = t.dataIdMap.get(y.dataId).id, k = t.dataIdMap.get(r.dataId).id, N = t.dataIdMap.get(a.dataId).id, E = i === "nearest" ? 1 : 2, A; switch (o) { case "constant": @@ -37659,8 +37548,8 @@ function pde(e) { } return GN(k, N, a.shape[0] > 1, c, f, m, h, d, p, b, r.shape.length - 1, E, A, u, v), y; } -var hde = { kernelName: Wo, backendName: "wasm", setupFunc: dde, kernelFunc: pde }; -function fde(e) { +var fde = { kernelName: Uo, backendName: "wasm", setupFunc: pde, kernelFunc: hde }; +function mde(e) { let { inputs: t, backend: n, attrs: s } = e, { value: r } = t, { axis: a } = s; a < 0 && (a += r.shape.length); let i = r.shape[a], o = r.shape.length, u = new Array(o - 1), l = 0; @@ -37672,15 +37561,15 @@ function fde(e) { p[a] = h, c[h] = va({ inputs: { x: r }, attrs: { begin: p, size: d }, backend: n }); return c.map(({ dataId: h, dtype: f }) => ({ dataId: h, dtype: f, shape: u })); } -var mde = { kernelName: Uo, backendName: "wasm", kernelFunc: fde }; -function gde(e) { +var gde = { kernelName: Go, backendName: "wasm", kernelFunc: mde }; +function bde(e) { let { inputs: { x: t }, backend: n } = e, s = n.makeOutput(t.shape, t.dtype); return n.typedArrayFromHeap(s).fill(0), s; } -var bde = { kernelName: Go, backendName: "wasm", kernelFunc: gde }; -var yde = [ioe, ooe, loe, poe, xoe, Ioe, Noe, _oe, Doe, Loe, Boe, Voe, Goe, Hoe, Koe, Qoe, Zoe, Joe, nue, aue, uue, due, fue, mue, bue, yue, vue, xue, Iue, Sue, Nue, _ue, Rue, Oue, Mue, Vue, Uue, Hue, hoe, Kue, Yue, Zue, Jue, tle, rle, ile, lle, ple, mle, ble, xle, kle, Ile, Nle, _le, Rle, Fle, zle, Lle, Vle, SN, Hle, Kle, Qle, Jle, tce, nce, sce, Aoe, ice, lce, pce, hce, fce, bce, xce, Ice, Sce, zoe, Tce, _ce, Rce, Oce, zce, Lce, Vce, Wce, Uce, Hce, Kce, Qce, Jce, nde, sde, rde, ode, cde, hde, boe, mde, bde]; -for (let e of yde) - Al(e); +var yde = { kernelName: Ho, backendName: "wasm", kernelFunc: bde }; +var vde = [ooe, uoe, coe, hoe, woe, Soe, Toe, Aoe, Foe, Boe, Voe, Woe, Hoe, qoe, Xoe, Zoe, Joe, eue, sue, iue, lue, pue, mue, gue, yue, vue, xue, wue, Sue, Cue, Tue, Aue, Due, Pue, Lue, Wue, Gue, que, foe, Xue, Que, Jue, ele, nle, ale, ole, cle, hle, gle, yle, wle, Ile, Sle, Tle, Ale, Dle, Ole, Mle, Ble, Wle, SN, qle, Xle, Zle, ece, nce, sce, rce, Eoe, oce, cce, hce, fce, mce, yce, wce, Sce, Cce, Moe, $ce, Ace, Dce, Pce, Mce, Bce, Wce, Uce, Gce, qce, Xce, Zce, ede, sde, rde, ade, ude, dde, fde, yoe, gde, yde]; +for (let e of vde) + El(e); var Jm = X(); Jm.registerFlag("WASM_HAS_SIMD_SUPPORT", async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]))); Jm.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT", async () => { @@ -37693,13 +37582,12 @@ Jm.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT", async () => { } }); var Lw = xa(a$()); -var vde = `"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",function(data){onmessage({data:data})});var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8"))},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+" +var xde = `"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",function(data){onmessage({data:data})});var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8"))},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+" ");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=((info,receiveInstance)=>{var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports});self.onmessage=(e=>{try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module).then(function(instance){Module=instance})}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0,1);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInit();try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(Module["keepRuntimeAlive"]()){Module["PThread"].setExitStatus(result)}else{Module["__emscripten_thread_exit"](result)}}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){Module["_emscripten_current_thread_process_queued_calls"]()}}else if(e.data.cmd==="processProxyingQueue"){if(Module["_pthread_self"]()){Module["_emscripten_proxy_execute_queue"](e.data.queue)}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}});`; -var xde = xa(i$()); -var wde = class extends tl { +var wde = xa(i$()); +var kde = class extends nl { constructor(e) { - super(); - this.wasm = e, this.dataIdNextNumber = 1, this.wasm.tfjs.initWithThreadsCount(HN), eg = this.wasm.tfjs.getThreadsCount(), this.dataIdMap = new Ud(this, Ss()); + super(), this.wasm = e, this.dataIdNextNumber = 1, this.wasm.tfjs.initWithThreadsCount(HN), eg = this.wasm.tfjs.getThreadsCount(), this.dataIdMap = new Ud(this, Ss()); } write(e, t, n) { let s = { id: this.dataIdNextNumber++ }; @@ -37731,7 +37619,7 @@ var wde = class extends tl { return (t == null || t === 0) && (n == null || n >= i.length) ? i : i.slice(t, n); t = t || 0, n = n || w.sizeFromShape(a); let o = w.bytesPerElement(r), u = this.wasm.HEAPU8.slice(s + t * o, s + n * o); - return Sde(u.buffer, r); + return Cde(u.buffer, r); } disposeData(e, t = false) { if (this.dataIdMap.has(e)) { @@ -37787,7 +37675,7 @@ var wde = class extends tl { } } }; -function kde(e) { +function Ide(e) { return (t, n) => (w.fetch(e, { credentials: "same-origin" }).then((s) => { s.ok || t.env.a(`failed to load wasm binary file at '${e}'`), s.arrayBuffer().then((r) => { WebAssembly.instantiate(r, t).then((a) => { @@ -37800,34 +37688,34 @@ function Bw(e, t, n) { if (Bd != null) return Bd; let s = "tfjs-backend-wasm.wasm"; - return e && t ? s = "tfjs-backend-wasm-threaded-simd.wasm" : e && (s = "tfjs-backend-wasm-simd.wasm"), Mu != null && Mu[s] != null ? Mu[s] : n + s; + return e && t ? s = "tfjs-backend-wasm-threaded-simd.wasm" : e && (s = "tfjs-backend-wasm-simd.wasm"), Lu != null && Lu[s] != null ? Lu[s] : n + s; } -async function Ide() { +async function Sde() { let [e, t] = await Promise.all([X().getAsync("WASM_HAS_SIMD_SUPPORT"), X().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]); return new Promise((n, s) => { let r = {}; r.locateFile = (o, u) => { if (o.endsWith(".worker.js")) { - let l = vde.replace(/\n/g, "\\n"), c = new Blob([l], { type: "application/javascript" }); + let l = xde.replace(/\n/g, "\\n"), c = new Blob([l], { type: "application/javascript" }); return URL.createObjectURL(c); } - return o.endsWith(".wasm") ? Bw(e, t, Ou != null ? Ou : u) : u + o; - }, Dv && (r.instantiateWasm = kde(Bw(e, t, Ou != null ? Ou : ""))); + return o.endsWith(".wasm") ? Bw(e, t, Pu != null ? Pu : u) : u + o; + }, Dv && (r.instantiateWasm = Ide(Bw(e, t, Pu != null ? Pu : ""))); let a = false; r.onAbort = () => { - if (a || Lu) + if (a || Bu) return; - Lu = true, s({ message: "Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers" }); + Bu = true, s({ message: "Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers" }); }; let i; - t && e && Bd == null ? (r.mainScriptUrlOrBlob = new Blob(["var WasmBackendModuleThreadedSimd = " + Lw.default.toString()], { type: "text/javascript" }), i = (0, Lw.default)(r)) : i = (0, xde.default)(r), i.then((o) => { - a = true, Lu = false; + t && e && Bd == null ? (r.mainScriptUrlOrBlob = new Blob(["var WasmBackendModuleThreadedSimd = " + Lw.default.toString()], { type: "text/javascript" }), i = (0, Lw.default)(r)) : i = (0, wde.default)(r), i.then((o) => { + a = true, Bu = false; let u = null; o.tfjs = { init: o.cwrap("init", null, []), initWithThreadsCount: o.cwrap("init_with_threads_count", null, ["number"]), getThreadsCount: o.cwrap("get_threads_count", "number", []), registerTensor: o.cwrap("register_tensor", null, ["number", "number", "number"]), disposeData: o.cwrap("dispose_data", u, ["number"]), dispose: o.cwrap("dispose", u, []) }, n({ wasm: o }); }); }); } -function Sde(e, t) { +function Cde(e, t) { switch (t) { case "float32": return new Float32Array(e); @@ -37839,25 +37727,25 @@ function Sde(e, t) { throw new Error(`Unknown dtype ${t}`); } } -var Cde = ["tfjs-backend-wasm.wasm", "tfjs-backend-wasm-simd.wasm", "tfjs-backend-wasm-threaded-simd.wasm"]; +var Nde = ["tfjs-backend-wasm.wasm", "tfjs-backend-wasm-simd.wasm", "tfjs-backend-wasm-threaded-simd.wasm"]; var Bd = null; -var Ou = null; -var Mu = {}; -var Lu = false; +var Pu = null; +var Lu = {}; +var Bu = false; var Dv = false; -function Mpe(e, t = false) { - if (Gk("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."), Lu) +function Lpe(e, t = false) { + if (Gk("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."), Bu) throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPath()` before you call `tf.setBackend()` or `tf.ready()`"); Bd = e, Dv = t; } -function Lpe(e, t = false) { - if (Lu) +function Bpe(e, t = false) { + if (Bu) throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPaths()` before you call `tf.setBackend()` or `tf.ready()`"); if (typeof e == "string") - Ou = e; + Pu = e; else { - Mu = e; - let n = Cde.filter((s) => Mu[s] == null); + Lu = e; + let n = Nde.filter((s) => Lu[s] == null); if (n.length > 0) throw new Error(`There were no entries found for the following binaries: ${n.join(",")}. Please either call setWasmPaths with a map providing a path for each binary, or with a string indicating the directory where all the binaries can be found.`); } @@ -37865,22 +37753,22 @@ function Lpe(e, t = false) { } var HN = -1; var eg = -1; -function Bpe(e) { +function Vpe(e) { HN = e; } -function Vpe() { +function Wpe() { if (eg === -1) throw new Error("WASM backend not initialized."); return eg; } -var Wpe = "0.0.0"; -var Nde = 2; +var Upe = "0.0.0"; +var Tde = 2; pp("wasm", async () => { - let { wasm: e } = await Ide(); - return new wde(e); -}, Nde); -var sr = "3.15.0-20220401"; -var Upe = { tfjs: sr, "tfjs-core": sr, "tfjs-data": sr, "tfjs-layers": sr, "tfjs-converter": sr, "tfjs-backend-cpu": sr, "tfjs-backend-webgl": sr, "tfjs-backend-wasm": sr }; + let { wasm: e } = await Sde(); + return new kde(e); +}, Tde); +var sr = "3.15.0-20220405"; +var Gpe = { tfjs: sr, "tfjs-core": sr, "tfjs-data": sr, "tfjs-layers": sr, "tfjs-converter": sr, "tfjs-backend-cpu": sr, "tfjs-backend-webgl": sr, "tfjs-backend-wasm": sr }; // src/image/imagefxshaders.ts var vertexIdentity = ` @@ -38913,7 +38801,7 @@ var Env = class { __publicField(this, "ImageData"); this.browser = typeof navigator !== "undefined"; this.node = typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined"; - this.tfjs = { version: Upe["tfjs-core"] }; + this.tfjs = { version: Gpe["tfjs-core"] }; this.offscreen = typeof OffscreenCanvas !== "undefined"; this.initial = true; this.worker = this.browser && this.offscreen ? typeof WorkerGlobalScope !== "undefined" : void 0; @@ -38936,7 +38824,7 @@ var Env = class { this.backends = Object.keys(Ss().registryFactory); this.wasm.supported = typeof WebAssembly !== "undefined"; this.wasm.backend = this.backends.includes("wasm"); - if (this.wasm.supported && this.wasm.backend && Bde() === "wasm") { + if (this.wasm.supported && this.wasm.backend && Vde() === "wasm") { this.wasm.simd = await X().getAsync("WASM_HAS_SIMD_SUPPORT"); this.wasm.multithread = await X().getAsync("WASM_HAS_MULTITHREAD_SUPPORT"); } @@ -38944,7 +38832,7 @@ var Env = class { const ctx = c ? c.getContext("webgl2") : void 0; this.webgl.supported = typeof ctx !== "undefined"; this.webgl.backend = this.backends.includes("webgl"); - if (this.webgl.supported && this.webgl.backend && (Bde() === "webgl" || Bde() === "humangl")) { + if (this.webgl.supported && this.webgl.backend && (Vde() === "webgl" || Vde() === "humangl")) { const gl2 = zA().gpgpu !== "undefined" ? await zA().getGPGPUContext().gl : null; if (gl2) { this.webgl.version = gl2.getParameter(gl2.VERSION); @@ -38960,7 +38848,7 @@ var Env = class { this.webgpu.supported = false; } try { - this.kernels = Jf(Bde()).map((kernel) => kernel.kernelName.toLowerCase()); + this.kernels = Jf(Vde()).map((kernel) => kernel.kernelName.toLowerCase()); } catch (e) { } } @@ -43308,7 +43196,7 @@ async function max2d(inputs, minScore) { const newScore = (await max.data())[0]; Re([reshaped, max]); if (newScore > minScore) { - const coordinates = Gu(reshaped, 0); + const coordinates = Hu(reshaped, 0); const mod = kD(coordinates, width); const x = (await mod.data())[0]; const div = xe(coordinates, we(width, "int32")); @@ -43781,7 +43669,7 @@ async function predict11(image, config3, idx, count2) { obj.gender = gender[0] <= 0.5 ? "female" : "male"; obj.genderScore = Math.min(0.99, confidence); } - const argmax = Gu(resT.find((t) => t.shape[1] === 100), 1); + const argmax = Hu(resT.find((t) => t.shape[1] === 100), 1); const age = (await argmax.data())[0]; Re(argmax); const ageT = resT.find((t) => t.shape[1] === 100); @@ -47647,7 +47535,7 @@ async function detectHands(input, config3) { t.filtered = Jn(classScores, 1); Re(classScores); t.max = As(t.filtered, 1); - t.argmax = Gu(t.filtered, 1); + t.argmax = Hu(t.filtered, 1); let id2 = 0; t.nms = await qn.nonMaxSuppressionAsync(t.boxes, t.max, (config3.hand.maxDetected || 0) + 1, config3.hand.iouThreshold || 0, config3.hand.minConfidence || 1); const nms = await t.nms.data(); @@ -48746,7 +48634,7 @@ async function register(instance) { log("error: humangl backend invalid context"); reset(instance); } - if (!Wde(config2.name)) { + if (!Ude(config2.name)) { try { config2.canvas = await canvas(100, 100); } catch (err) { @@ -48796,7 +48684,7 @@ async function register(instance) { const kernels = Jf("webgl"); kernels.forEach((kernelConfig) => { const newKernelConfig = { ...kernelConfig, backendName: config2.name }; - Al(newKernelConfig); + El(newKernelConfig); }); } catch (err) { log("error: cannot update WebGL backend registration:", err); @@ -48825,25 +48713,25 @@ function registerCustomOps() { if (!env.kernels.includes("mod")) { const kernelMod = { kernelName: "Mod", - backendName: Bde(), + backendName: Vde(), kernelFunc: (op2) => j(() => ge(op2.inputs.a, V(xe(op2.inputs.a, op2.inputs.b), op2.inputs.b))) }; - Al(kernelMod); + El(kernelMod); env.kernels.push("mod"); } if (!env.kernels.includes("floormod")) { const kernelMod = { kernelName: "FloorMod", - backendName: Bde(), + backendName: Vde(), kernelFunc: (op2) => j(() => Hk(op2.inputs.a / op2.inputs.b) * op2.inputs.b + kD(op2.inputs.a, op2.inputs.b)) }; - Al(kernelMod); + El(kernelMod); env.kernels.push("floormod"); } } async function check(instance, force = false) { instance.state = "backend"; - if (force || env.initial || instance.config.backend && instance.config.backend.length > 0 && Bde() !== instance.config.backend) { + if (force || env.initial || instance.config.backend && instance.config.backend.length > 0 && Vde() !== instance.config.backend) { const timeStamp = now(); if (instance.config.backend && instance.config.backend.length > 0) { if (typeof window === "undefined" && typeof WorkerGlobalScope !== "undefined" && instance.config.debug) { @@ -48887,7 +48775,7 @@ async function check(instance, force = false) { if (instance.config.debug) log("wasm path:", instance.config.wasmPath); if (typeof (tfjs_esm_exports == null ? void 0 : tfjs_esm_exports.setWasmPaths) !== "undefined") - await Lpe(instance.config.wasmPath, instance.config.wasmPlatformFetch); + await Bpe(instance.config.wasmPath, instance.config.wasmPlatformFetch); else throw new Error("backend error: attempting to use wasm backend but wasm path is not set"); const simd = await X().getAsync("WASM_HAS_SIMD_SUPPORT"); @@ -48898,15 +48786,15 @@ async function check(instance, force = false) { log("warning: wasm simd support is not enabled"); } try { - await Mde(instance.config.backend); - await Lde(); + await Lde(instance.config.backend); + await Bde(); init(); } catch (err) { log("error: cannot set backend:", instance.config.backend, err); return false; } } - if (Bde() === "humangl") { + if (Vde() === "humangl") { Jw.set("CHECK_COMPUTATION_FOR_ERRORS", false); Jw.set("WEBGL_CPU_FORWARD", true); Jw.set("WEBGL_USE_SHAPES_UNIFORMS", true); @@ -48921,12 +48809,12 @@ async function check(instance, force = false) { log(`gl version:${gl2.getParameter(gl2.VERSION)} renderer:${gl2.getParameter(gl2.RENDERER)}`); } } - if (Bde() === "webgpu") { + if (Vde() === "webgpu") { } - Rde(); - await Lde(); + Dde(); + await Bde(); instance.performance.initBackend = Math.trunc(now() - timeStamp); - instance.config.backend = Bde(); + instance.config.backend = Vde(); await env.updateBackend(); registerCustomOps(); } @@ -48942,9 +48830,9 @@ function fakeOps(kernelNames, config3) { log("kernelFunc", kernelName, config3.backend); } }; - Al(kernelConfig); + El(kernelConfig); } - env.kernels = Jf(Bde()).map((kernel) => kernel.kernelName.toLowerCase()); + env.kernels = Jf(Vde()).map((kernel) => kernel.kernelName.toLowerCase()); } // src/util/draw.ts @@ -51005,7 +50893,7 @@ var Human = class { (_a2 = this.events) == null ? void 0 : _a2.dispatchEvent(new Event(event)); }); this.env = env; - config.wasmPath = Upe["tfjs-core"].includes("-") ? "https://vladmandic.github.io/tfjs/dist/" : `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${Ede}/dist/`; + config.wasmPath = Gpe["tfjs-core"].includes("-") ? "https://vladmandic.github.io/tfjs/dist/" : `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${Rde}/dist/`; config.modelBasePath = env.browser ? "../models/" : "file://models/"; config.backend = env.browser ? "humangl" : "tensorflow"; this.version = version; @@ -51082,7 +50970,7 @@ var Human = class { log(`tfjs version: ${this.tf.version["tfjs-core"]}`); if (!await check(this)) log("error: backend check failed"); - await Lde(); + await Bde(); if (this.env.browser) { if (this.config.debug) log("configuration:", this.config); diff --git a/dist/human.esm.js.map b/dist/human.esm.js.map index bdffc527..493bc08d 100644 --- a/dist/human.esm.js.map +++ b/dist/human.esm.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/util/util.ts", "../src/config.ts", "tfjs.esm.js", "../src/image/imagefxshaders.ts", "../src/image/imagefx.ts", "../src/image/enhance.ts", "../src/image/image.ts", "../src/util/env.ts", "../src/tfjs/load.ts", "../src/models.ts", "../src/gear/gear.ts", "../src/tfjs/constants.ts", "../src/gear/ssrnet-age.ts", "../src/gear/ssrnet-gender.ts", "../src/face/antispoof.ts", "../src/face/facemeshcoords.ts", "../src/face/facemeshutil.ts", "../src/face/blazeface.ts", "../src/body/blazeposecoords.ts", "../src/body/blazeposedetector.ts", "../src/util/box.ts", "../src/body/blazepose.ts", "../src/object/labels.ts", "../src/object/centernet.ts", "../src/body/efficientposecoords.ts", "../src/body/efficientpose.ts", "../src/gear/emotion.ts", "../src/face/mobilefacenet.ts", "../src/face/iris.ts", "../src/face/facemesh.ts", "../src/face/faceres.ts", "../src/hand/handposeutil.ts", "../src/hand/handposeanchors.ts", "../src/hand/handposedetector.ts", "../src/hand/handposepipeline.ts", "../src/hand/fingerdef.ts", "../src/hand/fingergesture.ts", "../src/hand/fingerpose.ts", "../src/hand/handpose.ts", "../src/hand/handtrack.ts", "../src/face/liveness.ts", "../src/body/movenetcoords.ts", "../src/body/movenetfix.ts", "../src/body/movenet.ts", "../src/object/nanodet.ts", "../src/body/posenetutils.ts", "../src/body/posenet.ts", "../src/segmentation/segmentation.ts", "../src/tfjs/humangl.ts", "../src/tfjs/backend.ts", "../src/util/draw.ts", "../src/face/mask.ts", "../src/face/angles.ts", "../src/face/face.ts", "../src/gesture/gesture.ts", "../src/util/interpolate.ts", "../src/face/match.ts", "../src/util/persons.ts", "../src/sample.ts", "../src/warmup.ts", "../src/human.ts"], - "sourcesContent": ["import type { Config } from '../exports';\n\n/**\n * Simple helper functions used accross codebase\n */\n\n// helper function: wrapper around console output\nexport function log(...msg): void {\n const dt = new Date();\n const ts = `${dt.getHours().toString().padStart(2, '0')}:${dt.getMinutes().toString().padStart(2, '0')}:${dt.getSeconds().toString().padStart(2, '0')}.${dt.getMilliseconds().toString().padStart(3, '0')}`;\n // eslint-disable-next-line no-console\n if (msg) console.log(ts, 'Human:', ...msg);\n}\n\n// helper function: join two paths\nexport function join(folder: string, file: string): string {\n const separator = folder.endsWith('/') ? '' : '/';\n const skipJoin = file.startsWith('.') || file.startsWith('/') || file.startsWith('http:') || file.startsWith('https:') || file.startsWith('file:');\n const path = skipJoin ? `${file}` : `${folder}${separator}${file}`;\n if (!path.toLocaleLowerCase().includes('.json')) throw new Error(`modelpath error: expecting json file: ${path}`);\n return path;\n}\n\n// helper function: gets elapsed time on both browser and nodejs\nexport const now = () => {\n if (typeof performance !== 'undefined') return performance.now();\n return parseInt((Number(process.hrtime.bigint()) / 1000 / 1000).toString());\n};\n\n// helper function: checks current config validity\nexport function validate(defaults: Partial, config: Partial, parent = 'config', msgs: Array<{ reason: string, where: string, expected?: string }> = []) {\n for (const key of Object.keys(config)) {\n if (typeof config[key] === 'object') {\n validate(defaults[key], config[key], key, msgs);\n } else {\n const defined = defaults && (typeof defaults[key] !== 'undefined');\n if (!defined) msgs.push({ reason: 'unknown property', where: `${parent}.${key} = ${config[key]}` });\n const same = defaults && typeof defaults[key] === typeof config[key];\n if (defined && !same) msgs.push({ reason: 'property type mismatch', where: `${parent}.${key} = ${config[key]}`, expected: typeof defaults[key] });\n }\n // ok = ok && defined && same;\n }\n if (config.debug && parent === 'config' && msgs.length > 0) log('invalid configuration', msgs);\n return msgs;\n}\n\n// helper function: perform deep merge of multiple objects so it allows full inheritance with overrides\nexport function mergeDeep(...objects) {\n const isObject = (obj) => obj && typeof obj === 'object';\n return objects.reduce((prev, obj) => {\n Object.keys(obj || {}).forEach((key) => {\n const pVal = prev[key];\n const oVal = obj[key];\n if (Array.isArray(pVal) && Array.isArray(oVal)) prev[key] = pVal.concat(...oVal);\n else if (isObject(pVal) && isObject(oVal)) prev[key] = mergeDeep(pVal, oVal);\n else prev[key] = oVal;\n });\n return prev;\n }, {});\n}\n\n// helper function: return min and max from input array\nexport const minmax = (data: Array) => data.reduce((acc: Array, val) => {\n acc[0] = (acc[0] === undefined || val < acc[0]) ? val : acc[0];\n acc[1] = (acc[1] === undefined || val > acc[1]) ? val : acc[1];\n return acc;\n}, []);\n\n// helper function: async wait\nexport async function wait(time: number) {\n const waiting = new Promise((resolve) => { setTimeout(() => resolve(true), time); });\n await waiting;\n}\n", "/* eslint-disable indent */\n/* eslint-disable no-multi-spaces */\n\n/** Generic config type inherited by all module types */\nexport interface GenericConfig {\n /** is module enabled? */\n enabled: boolean,\n /** path to model json file (relative to `modelBasePath` */\n modelPath: string,\n /** how many max frames to go without re-running model if cached results are acceptable\n * for two-phase models such as face and hand caching applies to bounding boxes detection only */\n skipFrames: number,\n /** how many max milliseconds to go without re-running model if cached results are acceptable\n * for two-phase models such as face and hand caching applies to bounding boxes detection only */\n skipTime: number,\n}\n\n/** Detector part of face configuration */\nexport interface FaceDetectorConfig extends GenericConfig {\n /** is face rotation correction performed after detecting face?\n * used to correctly analyze faces under high angles\n */\n rotation: boolean,\n /** maximum number of detected faces */\n maxDetected: number,\n /** minimum confidence for a detected face before results are discarded */\n minConfidence: number,\n /** minimum overlap between two detected faces before one is discarded */\n iouThreshold: number,\n /** should child models perform on masked image of a face */\n mask: boolean,\n /** should face detection return processed and cropped face tensor that can with an external model for addtional processing?\n * if enabled it must be manually deallocated to avoid memory leak */\n return: boolean,\n}\n\n/** Mesh part of face configuration */\nexport interface FaceMeshConfig extends GenericConfig {}\n\n/** Iris part of face configuration */\nexport interface FaceIrisConfig extends GenericConfig {}\n\n/** Description or face embedding part of face configuration\n * - also used by age and gender detection\n */\nexport interface FaceDescriptionConfig extends GenericConfig {\n /** minimum confidence for a detected face before results are discarded */\n minConfidence: number,\n}\n\n/** Emotion part of face configuration */\nexport interface FaceEmotionConfig extends GenericConfig {\n /** minimum confidence for a detected face before results are discarded */\n minConfidence: number,\n}\n\n/** Anti-spoofing part of face configuration */\nexport interface FaceAntiSpoofConfig extends GenericConfig {}\n\n/** Liveness part of face configuration */\nexport interface FaceLivenessConfig extends GenericConfig {}\n\n/** Configures all face-specific options: face detection, mesh analysis, age, gender, emotion detection and face description */\nexport interface FaceConfig extends GenericConfig {\n detector: Partial,\n mesh: Partial,\n iris: Partial,\n description: Partial,\n emotion: Partial,\n antispoof: Partial,\n liveness: Partial,\n}\n\n/** Configures all body detection specific options */\nexport interface BodyConfig extends GenericConfig {\n /** maximum number of detected bodies */\n maxDetected: number,\n /** minimum confidence for a detected body before results are discarded */\n minConfidence: number,\n /* experimental\n /** experimental: detector used for body model before actual analysis\n detector?: {\n /** experimental: enable body detector before body landmarks\n enabled: boolean,\n /** experimental: path to optional body detector model json file\n modelPath: string,\n /** experimental: minimum confidence for a detected body before results are discarded\n minConfidence: number,\n /** experimental: minimum overlap between two detected bodies before one is discarded\n iouThreshold: number\n },\n */\n}\n\n/** Configures all hand detection specific options */\nexport interface HandConfig extends GenericConfig {\n /** should hand rotation correction be performed after hand detection? */\n rotation: boolean,\n /** minimum confidence for a detected hand before results are discarded */\n minConfidence: number,\n /** minimum overlap between two detected hands before one is discarded */\n iouThreshold: number,\n /** maximum number of detected hands */\n maxDetected: number,\n /** should hand landmarks be detected or just return detected hand box */\n landmarks: boolean,\n detector: {\n /** path to hand detector model json */\n modelPath?: string,\n },\n skeleton: {\n /** path to hand skeleton model json */\n modelPath?: string,\n },\n}\n\n/** Configures all object detection specific options */\nexport interface ObjectConfig extends GenericConfig {\n /** minimum confidence for a detected objects before results are discarded */\n minConfidence: number,\n /** minimum overlap between two detected objects before one is discarded */\n iouThreshold: number,\n /** maximum number of detected objects */\n maxDetected: number,\n}\n\n/** Configures all body segmentation module\n * removes background from input containing person\n * if segmentation is enabled it will run as preprocessing task before any other model\n * alternatively leave it disabled and use it on-demand using human.segmentation method which can\n * remove background or replace it with user-provided background\n*/\nexport interface SegmentationConfig extends GenericConfig {\n /** blur segmentation output by pixels for more realistic image */\n blur: number,\n}\n\n/** Run input through image filters before inference\n * - available only in Browser environments\n * - image filters run with near-zero latency as they are executed on the GPU using WebGL\n*/\nexport interface FilterConfig {\n /** are image filters enabled? */\n enabled: boolean,\n /** perform image histogram equalization\n * - equalization is performed on input as a whole and detected face before its passed for further analysis\n */\n equalization: boolean,\n /** resize input width\n * - if both width and height are set to 0, there is no resizing\n * - if just one is set, second one is scaled automatically\n * - if both are set, values are used as-is\n */\n width: number,\n /** resize input height\n * - if both width and height are set to 0, there is no resizing\n * - if just one is set, second one is scaled automatically\n * - if both are set, values are used as-is\n */\n height: number,\n /** return processed canvas imagedata in result */\n return: boolean,\n /** flip input as mirror image */\n flip: boolean,\n /** range: -1 (darken) to 1 (lighten) */\n brightness: number,\n /** range: -1 (reduce contrast) to 1 (increase contrast) */\n contrast: number,\n /** range: 0 (no sharpening) to 1 (maximum sharpening) */\n sharpness: number,\n /** range: 0 (no blur) to N (blur radius in pixels) */\n blur: number\n /** range: -1 (reduce saturation) to 1 (increase saturation) */\n saturation: number,\n /** range: 0 (no change) to 360 (hue rotation in degrees) */\n hue: number,\n /** image negative */\n negative: boolean,\n /** image sepia colors */\n sepia: boolean,\n /** image vintage colors */\n vintage: boolean,\n /** image kodachrome colors */\n kodachrome: boolean,\n /** image technicolor colors */\n technicolor: boolean,\n /** image polaroid camera effect */\n polaroid: boolean,\n /** range: 0 (no pixelate) to N (number of pixels to pixelate) */\n pixelate: number,\n}\n\n/** Controlls gesture detection */\nexport interface GestureConfig {\n /** is gesture detection enabled? */\n enabled: boolean,\n}\n/** Possible TensorFlow backends */\nexport type BackendType = ['cpu', 'wasm', 'webgl', 'humangl', 'tensorflow', 'webgpu'];\n\n/** Possible values for `human.warmup` */\nexport type WarmupType = ['' | 'none' | 'face' | 'full' | 'body'];\n\n/**\n * Configuration interface definition for **Human** library\n * Contains all configurable parameters\n * Defaults: [config](https://github.com/vladmandic/human/blob/main/src/config.ts#L262)\n */\nexport interface Config {\n /** Backend used for TFJS operations\n * valid build-in backends are:\n * - Browser: `cpu`, `wasm`, `webgl`, `humangl`, `webgpu`\n * - NodeJS: `cpu`, `wasm`, `tensorflow`\n * default: `humangl` for browser and `tensorflow` for nodejs\n */\n backend: '' | 'cpu' | 'wasm' | 'webgl' | 'humangl' | 'tensorflow' | 'webgpu',\n\n /** Path to *.wasm files if backend is set to `wasm`\n *\n * default: auto-detects to link to CDN `jsdelivr` when running in browser\n */\n wasmPath: string,\n\n /** Force WASM loader to use platform fetch\n *\n * default: auto-detects to link to CDN `jsdelivr` when running in browser\n */\n wasmPlatformFetch: boolean,\n\n /** Print debug statements to console\n *\n * default: `true`\n */\n debug: boolean,\n\n /** Perform model loading and inference concurrently or sequentially\n *\n * default: `true`\n */\n async: boolean,\n\n /** What to use for `human.warmup()`\n * - warmup pre-initializes all models for faster inference but can take significant time on startup\n * - used by `webgl`, `humangl` and `webgpu` backends\n *\n * default: `full`\n */\n warmup: '' | 'none' | 'face' | 'full' | 'body',\n\n /** Base model path (typically starting with file://, http:// or https://) for all models\n * - individual modelPath values are relative to this path\n *\n * default: `../models/` for browsers and `file://models/` for nodejs\n */\n modelBasePath: string,\n\n /** Cache models in IndexDB on first sucessfull load\n * default: true if indexdb is available (browsers), false if its not (nodejs)\n */\n cacheModels: boolean,\n\n /** Cache sensitivity\n * - values 0..1 where 0.01 means reset cache if input changed more than 1%\n * - set to 0 to disable caching\n *\n * default: 0.7\n */\n cacheSensitivity: number;\n\n /** Perform immediate garbage collection on deallocated tensors instead of caching them */\n deallocate: boolean;\n\n /** Internal Variable */\n skipAllowed: boolean;\n\n /** Filter config {@link FilterConfig} */\n filter: Partial,\n\n /** Gesture config {@link GestureConfig} */\n gesture: Partial;\n\n /** Face config {@link FaceConfig} */\n face: Partial,\n\n /** Body config {@link BodyConfig} */\n body: Partial,\n\n /** Hand config {@link HandConfig} */\n hand: Partial,\n\n /** Object config {@link ObjectConfig} */\n object: Partial,\n\n /** Segmentation config {@link SegmentationConfig} */\n segmentation: Partial,\n}\n\n/** - [See all default Config values...](https://github.com/vladmandic/human/blob/main/src/config.ts#L262) */\nconst config: Config = {\n backend: '',\n modelBasePath: '',\n cacheModels: true,\n wasmPath: '',\n wasmPlatformFetch: false,\n debug: true,\n async: true,\n warmup: 'full',\n cacheSensitivity: 0.70,\n skipAllowed: false,\n deallocate: false,\n filter: {\n enabled: true,\n equalization: false,\n width: 0,\n height: 0,\n flip: false,\n return: true,\n brightness: 0,\n contrast: 0,\n sharpness: 0,\n blur: 0,\n saturation: 0,\n hue: 0,\n negative: false,\n sepia: false,\n vintage: false,\n kodachrome: false,\n technicolor: false,\n polaroid: false,\n pixelate: 0,\n },\n gesture: {\n enabled: true,\n },\n face: {\n enabled: true,\n detector: {\n modelPath: 'blazeface.json',\n rotation: true,\n maxDetected: 1,\n skipFrames: 99,\n skipTime: 2500,\n minConfidence: 0.2,\n iouThreshold: 0.1,\n mask: false,\n return: false,\n },\n mesh: {\n enabled: true,\n modelPath: 'facemesh.json',\n },\n iris: {\n enabled: true,\n modelPath: 'iris.json',\n },\n emotion: {\n enabled: true,\n minConfidence: 0.1,\n skipFrames: 99,\n skipTime: 1500,\n modelPath: 'emotion.json',\n },\n description: {\n enabled: true,\n modelPath: 'faceres.json',\n skipFrames: 99,\n skipTime: 3000,\n minConfidence: 0.1,\n },\n antispoof: {\n enabled: false,\n skipFrames: 99,\n skipTime: 4000,\n modelPath: 'antispoof.json',\n },\n liveness: {\n enabled: false,\n skipFrames: 99,\n skipTime: 4000,\n modelPath: 'liveness.json',\n },\n },\n body: {\n enabled: true,\n modelPath: 'movenet-lightning.json',\n maxDetected: -1,\n minConfidence: 0.3,\n skipFrames: 1,\n skipTime: 200,\n },\n hand: {\n enabled: true,\n rotation: true,\n skipFrames: 99,\n skipTime: 1000,\n minConfidence: 0.50,\n iouThreshold: 0.2,\n maxDetected: -1,\n landmarks: true,\n detector: {\n modelPath: 'handtrack.json',\n },\n skeleton: {\n modelPath: 'handlandmark-full.json',\n },\n },\n object: {\n enabled: false,\n modelPath: 'mb3-centernet.json',\n minConfidence: 0.2,\n iouThreshold: 0.4,\n maxDetected: 10,\n skipFrames: 99,\n skipTime: 2000,\n },\n segmentation: {\n enabled: false,\n modelPath: 'selfie.json',\n blur: 8,\n },\n};\n\nexport { config as defaults };\n", "/*\n Human\n homepage: \n author: '\n*/\n\nvar LT=Object.create,Vd=Object.defineProperty,BT=Object.getOwnPropertyDescriptor,Vw=Object.getOwnPropertyNames,VT=Object.getPrototypeOf,WT=Object.prototype.hasOwnProperty,UT=e=>Vd(e,\"__esModule\",{value:!0}),zt=(e,t)=>function(){return t||(0,e[Vw(e)[0]])((t={exports:{}}).exports,t),t.exports},Ae=(e,t)=>{for(var n in t)Vd(e,n,{get:t[n],enumerable:!0})},GT=(e,t,n,s)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let r of Vw(t))!WT.call(e,r)&&(n||r!==\"default\")&&Vd(e,r,{get:()=>t[r],enumerable:!(s=BT(t,r))||s.enumerable});return e},xa=(e,t)=>GT(UT(Vd(e!=null?LT(VT(e)):{},\"default\",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),HT=zt({\"src/node_modules/long/src/long.js\"(e,t){t.exports=s;var n=null;try{n=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(F){}function s(F,$,z){this.low=F|0,this.high=$|0,this.unsigned=!!z}s.prototype.__isLong__,Object.defineProperty(s.prototype,\"__isLong__\",{value:!0});function r(F){return(F&&F.__isLong__)===!0}s.isLong=r;var a={},i={};function o(F,$){var z,W,q;return $?(F>>>=0,(q=0<=F&&F<256)&&(W=i[F],W)?W:(z=l(F,(F|0)<0?-1:0,!0),q&&(i[F]=z),z)):(F|=0,(q=-128<=F&&F<128)&&(W=a[F],W)?W:(z=l(F,F<0?-1:0,!1),q&&(a[F]=z),z))}s.fromInt=o;function u(F,$){if(isNaN(F))return $?x:v;if($){if(F<0)return x;if(F>=g)return A}else{if(F<=-b)return P;if(F+1>=b)return E}return F<0?u(-F,$).neg():l(F%m|0,F/m|0,$)}s.fromNumber=u;function l(F,$,z){return new s(F,$,z)}s.fromBits=l;var c=Math.pow;function p(F,$,z){if(F.length===0)throw Error(\"empty string\");if(F===\"NaN\"||F===\"Infinity\"||F===\"+Infinity\"||F===\"-Infinity\")return v;if(typeof $==\"number\"?(z=$,$=!1):$=!!$,z=z||10,z<2||360)throw Error(\"interior hyphen\");if(W===0)return p(F.substring(1),$,z).neg();for(var q=u(c(z,8)),K=v,Y=0;Y>>0:this.low},R.toNumber=function(){return this.unsigned?(this.high>>>0)*m+(this.low>>>0):this.high*m+(this.low>>>0)},R.toString=function($){if($=$||10,$<2||36<$)throw RangeError(\"radix\");if(this.isZero())return\"0\";if(this.isNegative())if(this.eq(P)){var z=u($),W=this.div(z),q=W.mul(z).sub(this);return W.toString($)+q.toInt().toString($)}else return\"-\"+this.neg().toString($);for(var K=u(c($,6),this.unsigned),Y=this,Z=\"\";;){var te=Y.div(K),ee=Y.sub(te.mul(K)).toInt()>>>0,se=ee.toString($);if(Y=te,Y.isZero())return se+Z;for(;se.length<6;)se=\"0\"+se;Z=\"\"+se+Z}},R.getHighBits=function(){return this.high},R.getHighBitsUnsigned=function(){return this.high>>>0},R.getLowBits=function(){return this.low},R.getLowBitsUnsigned=function(){return this.low>>>0},R.getNumBitsAbs=function(){if(this.isNegative())return this.eq(P)?64:this.neg().getNumBitsAbs();for(var $=this.high!=0?this.high:this.low,z=31;z>0&&($&1<=0},R.isOdd=function(){return(this.low&1)===1},R.isEven=function(){return(this.low&1)===0},R.equals=function($){return r($)||($=d($)),this.unsigned!==$.unsigned&&this.high>>>31===1&&$.high>>>31===1?!1:this.high===$.high&&this.low===$.low},R.eq=R.equals,R.notEquals=function($){return!this.eq($)},R.neq=R.notEquals,R.ne=R.notEquals,R.lessThan=function($){return this.comp($)<0},R.lt=R.lessThan,R.lessThanOrEqual=function($){return this.comp($)<=0},R.lte=R.lessThanOrEqual,R.le=R.lessThanOrEqual,R.greaterThan=function($){return this.comp($)>0},R.gt=R.greaterThan,R.greaterThanOrEqual=function($){return this.comp($)>=0},R.gte=R.greaterThanOrEqual,R.ge=R.greaterThanOrEqual,R.compare=function($){if(r($)||($=d($)),this.eq($))return 0;var z=this.isNegative(),W=$.isNegative();return z&&!W?-1:!z&&W?1:this.unsigned?$.high>>>0>this.high>>>0||$.high===this.high&&$.low>>>0>this.low>>>0?-1:1:this.sub($).isNegative()?-1:1},R.comp=R.compare,R.negate=function(){return!this.unsigned&&this.eq(P)?P:this.not().add(k)},R.neg=R.negate,R.add=function($){r($)||($=d($));var z=this.high>>>16,W=this.high&65535,q=this.low>>>16,K=this.low&65535,Y=$.high>>>16,Z=$.high&65535,te=$.low>>>16,ee=$.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)},R.subtract=function($){return r($)||($=d($)),this.add($.neg())},R.sub=R.subtract,R.multiply=function($){if(this.isZero())return v;if(r($)||($=d($)),n){var z=n.mul(this.low,this.high,$.low,$.high);return l(z,n.get_high(),this.unsigned)}if($.isZero())return v;if(this.eq(P))return $.isOdd()?P:v;if($.eq(P))return this.isOdd()?P:v;if(this.isNegative())return $.isNegative()?this.neg().mul($.neg()):this.neg().mul($).neg();if($.isNegative())return this.mul($.neg()).neg();if(this.lt(y)&&$.lt(y))return u(this.toNumber()*$.toNumber(),this.unsigned);var W=this.high>>>16,q=this.high&65535,K=this.low>>>16,Y=this.low&65535,Z=$.high>>>16,te=$.high&65535,ee=$.low>>>16,se=$.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)},R.mul=R.multiply,R.divide=function($){if(r($)||($=d($)),$.isZero())throw Error(\"division by zero\");if(n){if(!this.unsigned&&this.high===-2147483648&&$.low===-1&&$.high===-1)return this;var z=(this.unsigned?n.div_u:n.div_s)(this.low,this.high,$.low,$.high);return l(z,n.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?x:v;var W,q,K;if(this.unsigned){if($.unsigned||($=$.toUnsigned()),$.gt(this))return x;if($.gt(this.shru(1)))return T;K=x}else{if(this.eq(P)){if($.eq(k)||$.eq(N))return P;if($.eq(P))return k;var Y=this.shr(1);return W=Y.div($).shl(1),W.eq(v)?$.isNegative()?k:N:(q=this.sub($.mul(W)),K=W.add(q.div($)),K)}else if($.eq(P))return this.unsigned?x:v;if(this.isNegative())return $.isNegative()?this.neg().div($.neg()):this.neg().div($).neg();if($.isNegative())return this.div($.neg()).neg();K=v}for(q=this;q.gte($);){W=Math.max(1,Math.floor(q.toNumber()/$.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($);se.isNegative()||se.gt(q);)W-=te,ee=u(W,this.unsigned),se=ee.mul($);ee.isZero()&&(ee=k),K=K.add(ee),q=q.sub(se)}return K},R.div=R.divide,R.modulo=function($){if(r($)||($=d($)),n){var z=(this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,$.low,$.high);return l(z,n.get_high(),this.unsigned)}return this.sub(this.div($).mul($))},R.mod=R.modulo,R.rem=R.modulo,R.not=function(){return l(~this.low,~this.high,this.unsigned)},R.and=function($){return r($)||($=d($)),l(this.low&$.low,this.high&$.high,this.unsigned)},R.or=function($){return r($)||($=d($)),l(this.low|$.low,this.high|$.high,this.unsigned)},R.xor=function($){return r($)||($=d($)),l(this.low^$.low,this.high^$.high,this.unsigned)},R.shiftLeft=function($){return r($)&&($=$.toInt()),($&=63)===0?this:$<32?l(this.low<<$,this.high<<$|this.low>>>32-$,this.unsigned):l(0,this.low<<$-32,this.unsigned)},R.shl=R.shiftLeft,R.shiftRight=function($){return r($)&&($=$.toInt()),($&=63)===0?this:$<32?l(this.low>>>$|this.high<<32-$,this.high>>$,this.unsigned):l(this.high>>$-32,this.high>=0?0:-1,this.unsigned)},R.shr=R.shiftRight,R.shiftRightUnsigned=function($){if(r($)&&($=$.toInt()),$&=63,$===0)return this;var z=this.high;if($<32){var W=this.low;return l(W>>>$|z<<32-$,z>>>$,this.unsigned)}else return $===32?l(z,0,this.unsigned):l(z>>>$-32,0,this.unsigned)},R.shru=R.shiftRightUnsigned,R.shr_u=R.shiftRightUnsigned,R.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},R.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},R.toBytes=function($){return $?this.toBytesLE():this.toBytesBE()},R.toBytesLE=function(){var $=this.high,z=this.low;return[z&255,z>>>8&255,z>>>16&255,z>>>24,$&255,$>>>8&255,$>>>16&255,$>>>24]},R.toBytesBE=function(){var $=this.high,z=this.low;return[$>>>24,$>>>16&255,$>>>8&255,$&255,z>>>24,z>>>16&255,z>>>8&255,z&255]},s.fromBytes=function($,z,W){return W?s.fromBytesLE($,z):s.fromBytesBE($,z)},s.fromBytesLE=function($,z){return new s($[0]|$[1]<<8|$[2]<<16|$[3]<<24,$[4]|$[5]<<8|$[6]<<16|$[7]<<24,z)},s.fromBytesBE=function($,z){return new s($[4]<<24|$[5]<<16|$[6]<<8|$[7],$[0]<<24|$[1]<<16|$[2]<<8|$[3],z)}}}),qT=zt({\"(disabled):src/node_modules/node-fetch/browser.js\"(){}}),jT=zt({\"(disabled):util\"(){}}),KT=zt({\"src/node_modules/seedrandom/lib/alea.js\"(e,t){(function(n,s,r){function a(l){var c=this,p=u();c.next=function(){var d=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=d-(c.c=d|0)},c.c=1,c.s0=p(\" \"),c.s1=p(\" \"),c.s2=p(\" \"),c.s0-=p(l),c.s0<0&&(c.s0+=1),c.s1-=p(l),c.s1<0&&(c.s1+=1),c.s2-=p(l),c.s2<0&&(c.s2+=1),p=null}function i(l,c){return c.c=l.c,c.s0=l.s0,c.s1=l.s1,c.s2=l.s2,c}function o(l,c){var p=new a(l),d=c&&c.state,h=p.next;return h.int32=function(){return p.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,d&&(typeof d==\"object\"&&i(d,p),h.state=function(){return i(p,{})}),h}function u(){var l=4022871197,c=function(p){p=String(p);for(var d=0;d>>0,h-=l,h*=l,l=h>>>0,h-=l,l+=h*4294967296}return(l>>>0)*23283064365386963e-26};return c}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.alea=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),XT=zt({\"src/node_modules/seedrandom/lib/xor128.js\"(e,t){(function(n,s,r){function a(u){var l=this,c=\"\";l.x=0,l.y=0,l.z=0,l.w=0,l.next=function(){var d=l.x^l.x<<11;return l.x=l.y,l.y=l.z,l.z=l.w,l.w^=l.w>>>19^d^d>>>8},u===(u|0)?l.x=u:c+=u;for(var p=0;p>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p==\"object\"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xor128=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),YT=zt({\"src/node_modules/seedrandom/lib/xorwow.js\"(e,t){(function(n,s,r){function a(u){var l=this,c=\"\";l.next=function(){var d=l.x^l.x>>>2;return l.x=l.y,l.y=l.z,l.z=l.w,l.w=l.v,(l.d=l.d+362437|0)+(l.v=l.v^l.v<<4^(d^d<<1))|0},l.x=0,l.y=0,l.z=0,l.w=0,l.v=0,u===(u|0)?l.x=u:c+=u;for(var p=0;p>>4),l.next()}function i(u,l){return l.x=u.x,l.y=u.y,l.z=u.z,l.w=u.w,l.v=u.v,l.d=u.d,l}function o(u,l){var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p==\"object\"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xorwow=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),QT=zt({\"src/node_modules/seedrandom/lib/xorshift7.js\"(e,t){(function(n,s,r){function a(u){var l=this;l.next=function(){var p=l.x,d=l.i,h,f,m;return h=p[d],h^=h>>>7,f=h^h<<24,h=p[d+1&7],f^=h^h>>>10,h=p[d+3&7],f^=h^h>>>3,h=p[d+4&7],f^=h^h<<7,h=p[d+7&7],h=h^h<<13,f^=h^h<<9,p[d]=f,l.i=d+1&7,f};function c(p,d){var h,f,m=[];if(d===(d|0))f=m[0]=d;else for(d=\"\"+d,h=0;h0;--h)p.next()}c(l,u)}function i(u,l){return l.x=u.x.slice(),l.i=u.i,l}function o(u,l){u==null&&(u=+new Date);var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(p.x&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xorshift7=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),ZT=zt({\"src/node_modules/seedrandom/lib/xor4096.js\"(e,t){(function(n,s,r){function a(u){var l=this;l.next=function(){var p=l.w,d=l.X,h=l.i,f,m;return l.w=p=p+1640531527|0,m=d[h+34&127],f=d[h=h+1&127],m^=m<<13,f^=f<<17,m^=m>>>15,f^=f>>>12,m=d[h]=m^f,l.i=h,m+(p^p>>>16)|0};function c(p,d){var h,f,m,g,b,y=[],v=128;for(d===(d|0)?(f=d,d=null):(d=d+\"\\0\",f=0,v=Math.max(v,d.length)),m=0,g=-32;g>>15,f^=f<<4,f^=f>>>13,g>=0&&(b=b+1640531527|0,h=y[g&127]^=f+b,m=h==0?m+1:0);for(m>=128&&(y[(d&&d.length||0)&127]=-1),m=127,g=4*128;g>0;--g)f=y[m+34&127],h=y[m=m+1&127],f^=f<<13,h^=h<<17,f^=f>>>15,h^=h>>>12,y[m]=f^h;p.w=b,p.X=y,p.i=m}c(l,u)}function i(u,l){return l.i=u.i,l.w=u.w,l.X=u.X.slice(),l}function o(u,l){u==null&&(u=+new Date);var c=new a(u),p=l&&l.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(p.X&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.xor4096=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),JT=zt({\"src/node_modules/seedrandom/lib/tychei.js\"(e,t){(function(n,s,r){function a(u){var l=this,c=\"\";l.next=function(){var d=l.b,h=l.c,f=l.d,m=l.a;return d=d<<25^d>>>7^h,h=h-f|0,f=f<<24^f>>>8^m,m=m-d|0,l.b=d=d<<20^d>>>12^h,l.c=h=h-f|0,l.d=f<<16^h>>>16^m,l.a=m-d|0},l.a=0,l.b=0,l.c=-1640531527,l.d=1367130551,u===Math.floor(u)?(l.a=u/4294967296|0,l.b=u|0):c+=u;for(var p=0;p>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,m=(h+f)/(1<<21);while(m===0);return m},d.int32=c.next,d.quick=d,p&&(typeof p==\"object\"&&i(p,c),d.state=function(){return i(c,{})}),d}s&&s.exports?s.exports=o:r&&r.amd?r(function(){return o}):this.tychei=o})(e,typeof t==\"object\"&&t,typeof define==\"function\"&&define)}}),e$=zt({\"(disabled):crypto\"(){}}),t$=zt({\"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,T,N){var E=[];T=T==!0?{entropy:!0}:T||{};var A=y(b(T.entropy?[k,x(s)]:k==null?v():k,3),E),P=new m(E),R=function(){for(var F=P.g(i),$=l,z=0;F=p;)F/=2,$/=2,z>>>=1;return(F+z)/$};return R.int32=function(){return P.g(4)|0},R.quick=function(){return P.g(4)/4294967296},R.double=R,y(x(P.S),s),(T.pass||N||function(F,$,z,W){return W&&(W.S&&g(W,P),F.state=function(){return g(P,{})}),z?(r[u]=F,$):F})(R,A,\"global\"in T?T.global:this==r,T.state)}function m(k){var T,N=k.length,E=this,A=0,P=E.i=E.j=0,R=E.S=[];for(N||(k=[N++]);A{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!=nn&&rs(Ce.buffer),ic}function i(){return Ce.buffer!=nn&&rs(Ce.buffer),oc}function o(){return Ce.buffer!=nn&&rs(Ce.buffer),pu}function u(){return Ce.buffer!=nn&&rs(Ce.buffer),uc}function l(){return Ce.buffer!=nn&&rs(Ce.buffer),lc}function c(){return Ce.buffer!=nn&&rs(Ce.buffer),cc}function p(){return Ce.buffer!=nn&&rs(Ce.buffer),dc}var d=typeof r!=\"undefined\"?r:{},h,f;d.ready=new Promise(function(C,D){h=C,f=D});var m;typeof process!=\"undefined\"&&process.listeners&&(m={uncaughtException:process.listeners(\"uncaughtException\"),unhandledRejection:process.listeners(\"unhandledRejection\")});var g=Object.assign({},d),b=[],y=\"./this.program\",v=(C,D)=>{throw D},x=typeof window==\"object\",k=typeof importScripts==\"function\",T=typeof process==\"object\"&&typeof process.versions==\"object\"&&typeof process.versions.node==\"string\",N=d.ENVIRONMENT_IS_PTHREAD||!1,E=\"\";function A(C){return d.locateFile?d.locateFile(C,E):E+C}var P,R,F,$;function z(C){if(C instanceof wu)return;ee(\"exiting due to exception: \"+C)}var W,q,K;if(T){k?E=dd().dirname(E)+\"/\":E=__dirname+\"/\",K=()=>{q||(W=tg(),q=dd())},P=function(B,Q){return K(),B=q.normalize(B),W.readFileSync(B,Q?void 0:\"utf8\")},F=D=>{var B=P(D,!0);return B.buffer||(B=new Uint8Array(B)),B},R=(D,B,Q)=>{K(),D=q.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){if(!(D instanceof wu))throw D}),process.on(\"unhandledRejection\",function(D){throw D}),v=(D,B)=>{if(Pr())throw process.exitCode=D,B;z(B),process.exit(D)},d.inspect=function(){return\"[Emscripten Module object]\"};let C;try{C=n$()}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=C.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=\"\",T||(P=C=>{var D=new XMLHttpRequest;return D.open(\"GET\",C,!1),D.send(null),D.responseText},k&&(F=C=>{var D=new XMLHttpRequest;return D.open(\"GET\",C,!1),D.responseType=\"arraybuffer\",D.send(null),new Uint8Array(D.response)}),R=(C,D,B)=>{var Q=new XMLHttpRequest;Q.open(\"GET\",C,!0),Q.responseType=\"arraybuffer\",Q.onload=()=>{if(Q.status==200||Q.status==0&&Q.response){D(Q.response);return}B()},Q.onerror=B,Q.send(null)}),$=C=>document.title=C);T&&typeof performance==\"undefined\"&&(global.performance=s$().performance);var Y=console.log.bind(console),Z=console.warn.bind(console);T&&(K(),Y=C=>W.writeSync(1,C+`\n`),Z=C=>W.writeSync(2,C+`\n`));var te=d.print||Y,ee=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(C){ne.shown||(ne.shown={}),ne.shown[C]||(ne.shown[C]=1,ee(C))}function oe(C,D){if(typeof WebAssembly.Function==\"function\"){for(var B={i:\"i32\",j:\"i64\",f:\"f32\",d:\"f64\"},Q={parameters:[],results:D[0]==\"v\"?[]:[B[D[0]]]},ue=1;ue{Se=C},Pe=Atomics.load,Xe=Atomics.store,Je=Atomics.compareExchange,Ye;d.wasmBinary&&(Ye=d.wasmBinary);var tt=d.noExitRuntime||!0;typeof WebAssembly!=\"object\"&&Ci(\"no native wasm support detected\");var Ce,ut,at=!1,Jt;function Nt(C,D){C||Ci(D)}function Cn(C){var D=d[\"_\"+C];return D}function Et(C,D,B,Q,ue){var pe={string:function($n){var Oi=0;if($n!=null&&$n!==0){var ex=($n.length<<2)+1;Oi=Fi(ex),Ls($n,Oi,ex)}return Oi},array:function($n){var Oi=Fi($n.length);return Bs($n,Oi),Oi}};function ye($n){return D===\"string\"?tn($n):D===\"boolean\"?Boolean($n):$n}var Te=Cn(C),bt=[],us=0;if(Q)for(var ls=0;ls(B.buffer instanceof SharedArrayBuffer&&(B=new Uint8Array(B)),D.decode.call(D,B))}var Yt=typeof TextDecoder!=\"undefined\"?new Tn(\"utf8\"):void 0;function Dn(C,D,B){for(var Q=D+B,ue=D;C[ue]&&!(ue>=Q);)++ue;if(ue-D>16&&C.subarray&&Yt)return Yt.decode(C.subarray(D,ue));for(var pe=\"\";D>10,56320|us&1023)}}return pe}function tn(C,D){return C?Dn(i(),C,D):\"\"}function Ms(C,D,B,Q){if(!(Q>0))return 0;for(var ue=B,pe=B+Q-1,ye=0;ye=55296&&Te<=57343){var bt=C.charCodeAt(++ye);Te=65536+((Te&1023)<<10)|bt&1023}if(Te<=127){if(B>=pe)break;D[B++]=Te}else if(Te<=2047){if(B+1>=pe)break;D[B++]=192|Te>>6,D[B++]=128|Te&63}else if(Te<=65535){if(B+2>=pe)break;D[B++]=224|Te>>12,D[B++]=128|Te>>6&63,D[B++]=128|Te&63}else{if(B+3>=pe)break;D[B++]=240|Te>>18,D[B++]=128|Te>>12&63,D[B++]=128|Te>>6&63,D[B++]=128|Te&63}}return D[B]=0,B-ue}function Ls(C,D,B){return Ms(C,i(),D,B)}function ki(C){for(var D=0,B=0;B=55296&&Q<=57343&&(Q=65536+((Q&1023)<<10)|C.charCodeAt(++B)&1023),Q<=127?++D:Q<=2047?D+=2:Q<=65535?D+=3:D+=4}return D}var Js=typeof TextDecoder!=\"undefined\"?new Tn(\"utf-16le\"):void 0;function Bs(C,D){a().set(C,D)}function du(C,D,B){for(var Q=0;Q>0]=C.charCodeAt(Q);B||(a()[D>>0]=0)}function Ii(C,D){return C%D>0&&(C+=D-C%D),C}var nn,ic,oc,pu,uc,lc,Fv,cc,dc;N&&(nn=d.buffer);function rs(C){nn=C,d.HEAP8=ic=new Int8Array(C),d.HEAP16=pu=new Int16Array(C),d.HEAP32=lc=new Int32Array(C),d.HEAPU8=oc=new Uint8Array(C),d.HEAPU16=uc=new Uint16Array(C),d.HEAPU32=Fv=new Uint32Array(C),d.HEAPF32=cc=new Float32Array(C),d.HEAPF64=dc=new Float64Array(C)}var pc=d.INITIAL_MEMORY||16777216;if(N)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:!0}),!(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\"),T&&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),pc=nn.byteLength,rs(nn);var Fn,Si=[],er=[],th=[],hc=[],Or=!1,nh=!1,fc=0;function Pr(){return tt||fc>0}function sn(){if(d.preRun)for(typeof d.preRun==\"function\"&&(d.preRun=[d.preRun]);d.preRun.length;)Ov(d.preRun.shift());vc(Si)}function hu(){Or=!0,!N&&vc(er)}function sh(){N||($e.terminateAllThreads(),nh=!0)}function rh(){if(!N){if(d.postRun)for(typeof d.postRun==\"function\"&&(d.postRun=[d.postRun]);d.postRun.length;)fu(d.postRun.shift());vc(hc)}}function Ov(C){Si.unshift(C)}function Pv(C){er.unshift(C)}function fu(C){hc.unshift(C)}var tr=0,mc=null,as=null;function mu(C){tr++,d.monitorRunDependencies&&d.monitorRunDependencies(tr)}function zv(C){if(tr--,d.monitorRunDependencies&&d.monitorRunDependencies(tr),tr==0&&(mc!==null&&(clearInterval(mc),mc=null),as)){var D=as;as=null,D()}}d.preloadedImages={},d.preloadedAudios={};function Ci(C){N?postMessage({cmd:\"onAbort\",arg:C}):d.onAbort&&d.onAbort(C),C=\"Aborted(\"+C+\")\",ee(C),at=!0,Jt=1,C+=\". Build with -s ASSERTIONS=1 for more info.\";var D=new WebAssembly.RuntimeError(C);throw f(D),D}var ah=\"data:application/octet-stream;base64,\";function gc(C){return C.startsWith(ah)}function bc(C){return C.startsWith(\"file://\")}var rn;rn=\"tfjs-backend-wasm-threaded-simd.wasm\",gc(rn)||(rn=A(rn));function yc(C){try{if(C==rn&&Ye)return new Uint8Array(Ye);if(F)return F(C);throw\"both async and sync fetching of the wasm failed\"}catch(D){Ci(D)}}function Ni(){if(!Ye&&(x||k)){if(typeof fetch==\"function\"&&!bc(rn))return fetch(rn,{credentials:\"same-origin\"}).then(function(C){if(!C.ok)throw\"failed to load wasm binary file at '\"+rn+\"'\";return C.arrayBuffer()}).catch(function(){return yc(rn)});if(R)return new Promise(function(C,D){R(rn,function(B){C(new Uint8Array(B))},D)})}return Promise.resolve().then(function(){return yc(rn)})}function ih(){var C={env:Ec,wasi_snapshot_preview1:Ec};function D(ye,Te){var bt=ye.exports;if(d.asm=bt,hh(d.asm.emscripten_tls_init),Fn=d.asm.__indirect_function_table,Pv(d.asm.__wasm_call_ctors),ut=Te,!N){var us=$e.unusedWorkers.length;$e.unusedWorkers.forEach(function(ls){$e.loadWasmModuleToWorker(ls,function(){--us||zv(\"wasm-instantiate\")})})}}N||mu(\"wasm-instantiate\");function B(ye){D(ye.instance,ye.module)}function Q(ye){return Ni().then(function(Te){return WebAssembly.instantiate(Te,C)}).then(function(Te){return Te}).then(ye,function(Te){ee(\"failed to asynchronously prepare wasm: \"+Te),Ci(Te)})}function ue(){return!Ye&&typeof WebAssembly.instantiateStreaming==\"function\"&&!gc(rn)&&!bc(rn)&&typeof fetch==\"function\"?fetch(rn,{credentials:\"same-origin\"}).then(function(ye){var Te=WebAssembly.instantiateStreaming(ye,C);return Te.then(B,function(bt){return ee(\"wasm streaming compile failed: \"+bt),ee(\"falling back to ArrayBuffer instantiation\"),Q(B)})}):Q(B)}if(d.instantiateWasm)try{var pe=d.instantiateWasm(C,D);return pe}catch(ye){return ee(\"Module.instantiateWasm callback failed with error: \"+ye),!1}return ue().catch(f),{}}var Mv,Lv,oh={};function vc(C){for(;C.length>0;){var D=C.shift();if(typeof D==\"function\"){D(d);continue}var B=D.func;typeof B==\"number\"?D.arg===void 0?$i(B)():$i(B)(D.arg):B(D.arg===void 0?null:D.arg)}}function Ti(C){var D=Ef(),B=C();return Pc(D),B}function qN(C){return C}function Bv(C){var D=/\\b_Z[\\w\\d_]+/g;return C.replace(D,function(B){var Q=B;return B===Q?B:Q+\" [\"+B+\"]\"})}function uh(C){l()[C>>2]=0;var D=$e.pthreads[C];delete $e.pthreads[C],D.worker.terminate(),Af(C),$e.runningWorkers.splice($e.runningWorkers.indexOf(D.worker),1),D.worker.pthread=void 0}function lh(C){var D=$e.pthreads[C];D.worker.postMessage({cmd:\"cancel\"})}function xc(C){var D=$e.pthreads[C];if(D){l()[C>>2]=0;var B=D.worker;$e.returnWorkerToPool(B)}}function wc(C){OT(C)}function ch(C){if(C instanceof wu||C==\"unwind\")return Jt;v(1,C)}var $e={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],init:function(){N?$e.initWorker():$e.initMainThread()},initMainThread:function(){for(var C=8,D=0;D>2]=0;try{C()}finally{l()[Jv>>2]=1}},receiveObjectTransfer:function(C){},threadInit:function(){for(var C in $e.tlsInitFunctions)$e.tlsInitFunctions[C]()},loadWasmModuleToWorker:function(C,D){C.onmessage=B=>{var Q=B.data,ue=Q.cmd;if(C.pthread&&($e.currentProxiedOperationCallerThread=C.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;return}ue===\"processQueuedMainThreadWork\"?Kv():ue===\"spawnThread\"?Ic(Q):ue===\"cleanupThread\"?xc(Q.thread):ue===\"killThread\"?uh(Q.thread):ue===\"cancelThread\"?lh(Q.thread):ue===\"loaded\"?(C.loaded=!0,D&&D(C),C.runPthread&&(C.runPthread(),delete C.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\"?C.postMessage(Q):ue===\"onAbort\"?d.onAbort&&d.onAbort(Q.arg):ee(\"worker sent an unknown command \"+ue),$e.currentProxiedOperationCallerThread=void 0},C.onerror=B=>{var Q=\"worker sent an error!\";throw ee(Q+\" \"+B.filename+\":\"+B.lineno+\": \"+B.message),B},T&&(C.on(\"message\",function(B){C.onmessage({data:B})}),C.on(\"error\",function(B){C.onerror(B)}),C.on(\"detachedExit\",function(){})),C.postMessage({cmd:\"load\",urlOrBlob:d.mainScriptUrlOrBlob||s,wasmMemory:Ce,wasmModule:ut})},allocateUnusedWorker:function(){var C=A(\"tfjs-backend-wasm-threaded-simd.worker.js\");$e.unusedWorkers.push(new Worker(C))},getNewWorker:function(){return $e.unusedWorkers.length==0&&($e.allocateUnusedWorker(),$e.loadWasmModuleToWorker($e.unusedWorkers[0])),$e.unusedWorkers.pop()}};function dh(){var C=Oc(),D=l()[C+44>>2],B=l()[C+48>>2],Q=D-B;Zv(D,Q),Pc(D)}d.establishStackSpace=dh;function kc(C){if(N)return Lr(1,0,C);try{wc(C)}catch(D){ch(D)}}var zr=[];function $i(C){var D=zr[C];return D||(C>=zr.length&&(zr.length=C+1),zr[C]=D=Fn.get(C)),D}function ph(C,D){return $i(C)(D)}d.invokeEntryPoint=ph;function Vv(){var C=new Error;if(!C.stack){try{throw new Error}catch(D){C=D}if(!C.stack)return\"(no stack trace available)\"}return C.stack.toString()}function hh(C,D,B){$e.tlsInitFunctions.push(C)}function Wv(C,D){Fn.set(C,D),zr[C]=D}var Mr;T?Mr=()=>{var C=process.hrtime();return C[0]*1e3+C[1]/1e6}:N?Mr=()=>performance.now()-d.__performance_now_clock_drift:Mr=()=>performance.now();var fh=!0;function mh(C){return l()[jv()>>2]=C,C}function gh(C,D){var B;if(C===0)B=Date.now();else if((C===1||C===4)&&fh)B=Mr();else return mh(28),-1;return l()[D>>2]=B/1e3|0,l()[D+4>>2]=B%1e3*1e3*1e3|0,0}function bh(C,D){return gh(C,D)}function yh(C){Xv(C,!k,1,!x),$e.threadInit()}function vh(C){N?postMessage({cmd:\"cleanupThread\",thread:C}):xc(C)}function Ic(C){var D=$e.getNewWorker();if(!D)return 6;$e.runningWorkers.push(D);var B=$e.pthreads[C.pthread_ptr]={worker:D,threadInfoStruct:C.pthread_ptr};D.pthread=B;var Q={cmd:\"run\",start_routine:C.startRoutine,arg:C.arg,threadInfoStruct:C.pthread_ptr};return D.runPthread=()=>{Q.time=performance.now(),D.postMessage(Q,C.transferList)},D.loaded&&(D.runPthread(),delete D.runPthread),0}function xh(C,D,B,Q){if(typeof SharedArrayBuffer==\"undefined\")return ee(\"Current environment does not support SharedArrayBuffer, pthreads are not available!\"),6;var ue=[],pe=0;if(N&&(ue.length===0||pe))return Yv(687865856,C,D,B,Q);if(pe)return pe;var ye={startRoutine:B,pthread_ptr:C,arg:Q,transferList:ue};return N?(ye.cmd=\"spawnThread\",postMessage(ye,ue),0):Ic(ye)}function wh(){return 2097152}function kh(C,D){if(C==D)postMessage({cmd:\"processQueuedMainThreadWork\"});else if(N)postMessage({targetThread:C,cmd:\"processThreadQueue\"});else{var B=$e.pthreads[C],Q=B&&B.worker;if(!Q)return;Q.postMessage({cmd:\"processThreadQueue\"})}return 1}function Ih(){Ci(\"\")}function Sh(){T||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(){return 2147483648}function Ch(C,D,B){i().copyWithin(C,D,D+B)}function Nh(){return T?r$().cpus().length:navigator.hardwareConcurrency}function Lr(C,D){var B=arguments.length-2,Q=arguments;return Ti(function(){for(var ue=B,pe=Fi(ue*8),ye=pe>>3,Te=0;Te>3,ue=0;ue>>16),rs(Ce.buffer),1}catch(D){}}function _h(C){var D=i().length;if(C=C>>>0,C<=D)return!1;var B=Sc();if(C>B)return!1;for(var Q=1;Q<=4;Q*=2){var ue=D*(1+.2/Q);ue=Math.min(ue,C+100663296);var pe=Math.min(B,Ii(Math.max(C,ue),65536)),ye=$h(pe);if(ye)return!0}return!1}var Le={inEventHandler:0,removeAllEventListeners:function(){for(var C=Le.eventHandlers.length-1;C>=0;--C)Le._removeHandler(C);Le.eventHandlers=[],Le.deferredCalls=[]},registerRemoveEventListeners:function(){Le.removeEventListenersRegistered||(th.push(Le.removeAllEventListeners),Le.removeEventListenersRegistered=!0)},deferredCalls:[],deferCall:function(C,D,B){function Q(ye,Te){if(ye.length!=Te.length)return!1;for(var bt in ye)if(ye[bt]!=Te[bt])return!1;return!0}for(var ue in Le.deferredCalls){var pe=Le.deferredCalls[ue];if(pe.targetFunction==C&&Q(pe.argsList,B))return}Le.deferredCalls.push({targetFunction:C,precedence:D,argsList:B}),Le.deferredCalls.sort(function(ye,Te){return ye.precedence>2]=B,l()[pe+4>>2]=Q,l()[pe+8>>2]=ue,_f(C,637534208,D,Q,pe)})},getTargetThreadForEventCallback:function(C){switch(C){case 1:return 0;case 2:return $e.currentProxiedOperationCallerThread;default:return C}},getNodeNameForTarget:function(C){return C?C==window?\"#window\":C==screen?\"#screen\":C&&C.nodeName?C.nodeName:\"\":\"\"},fullscreenEnabled:function(){return document.fullscreenEnabled||document.webkitFullscreenEnabled}};function Ah(C){var D=ki(C)+1,B=$f(D);return Ls(C,B,D),B}function Eh(C,D,B,Q){Ti(function(){var ue=Fi(12),pe=0;D&&(pe=Ah(D)),l()[ue>>2]=pe,l()[ue+4>>2]=B,l()[ue+8>>2]=Q,_f(C,657457152,0,pe,ue)})}function Rh(C,D,B,Q){D=D?tn(D):\"\",Eh(C,D,B,Q)}function Dh(C){return C>2?tn(C):C}var Fh=[0,typeof document!=\"undefined\"?document:0,typeof window!=\"undefined\"?window:0];function Oh(C){C=Dh(C);var D=Fh[C]||(typeof document!=\"undefined\"?document.querySelector(C):void 0);return D}function bu(C){return Oh(C)}function Cc(C,D,B){var Q=bu(C);if(!Q)return-4;if(Q.canvasSharedPtr&&(l()[Q.canvasSharedPtr>>2]=D,l()[Q.canvasSharedPtr+4>>2]=B),Q.offscreenCanvas||!Q.controlTransferredOffscreen){Q.offscreenCanvas&&(Q=Q.offscreenCanvas);var ue=!1;if(Q.GLctxObject&&Q.GLctxObject.GLctx){var pe=Q.GLctxObject.GLctx.getParameter(2978);ue=pe[0]===0&&pe[1]===0&&pe[2]===Q.width&&pe[3]===Q.height}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 Rh(ye,C,D,B),1}else return-4;return 0}function Nc(C,D,B){return N?Lr(2,1,C,D,B):Cc(C,D,B)}function Ph(C,D,B){var Q=bu(C);return Q?Cc(C,D,B):Nc(C,D,B)}function zh(){throw\"unwind\"}function Mh(C){var D=C.getExtension(\"ANGLE_instanced_arrays\");if(D)return C.vertexAttribDivisor=function(B,Q){D.vertexAttribDivisorANGLE(B,Q)},C.drawArraysInstanced=function(B,Q,ue,pe){D.drawArraysInstancedANGLE(B,Q,ue,pe)},C.drawElementsInstanced=function(B,Q,ue,pe,ye){D.drawElementsInstancedANGLE(B,Q,ue,pe,ye)},1}function Lh(C){var D=C.getExtension(\"OES_vertex_array_object\");if(D)return C.createVertexArray=function(){return D.createVertexArrayOES()},C.deleteVertexArray=function(B){D.deleteVertexArrayOES(B)},C.bindVertexArray=function(B){D.bindVertexArrayOES(B)},C.isVertexArray=function(B){return D.isVertexArrayOES(B)},1}function Bh(C){var D=C.getExtension(\"WEBGL_draw_buffers\");if(D)return C.drawBuffers=function(B,Q){D.drawBuffersWEBGL(B,Q)},1}function Vh(C){return!!(C.multiDrawWebgl=C.getExtension(\"WEBGL_multi_draw\"))}var gt={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],shaders:[],vaos:[],contexts:{},offscreenCanvases:{},queries:[],stringCache:{},unpackAlignment:4,recordError:function(D){gt.lastError||(gt.lastError=D)},getNewId:function(C){for(var D=gt.counter++,B=C.length;B>2]:-1;ue+=tn(l()[B+pe*4>>2],ye<0?void 0:ye)}return ue},createContext:function(C,D){C.getContextSafariWebGL2Fixed||(C.getContextSafariWebGL2Fixed=C.getContext,C.getContext=function(ue,pe){var ye=C.getContextSafariWebGL2Fixed(ue,pe);return ue==\"webgl\"==ye instanceof WebGLRenderingContext?ye:null});var B=C.getContext(\"webgl\",D);if(!B)return 0;var Q=gt.registerContext(B,D);return Q},registerContext:function(C,D){var B=$f(8);l()[B+4>>2]=Oc();var Q={handle:B,attributes:D,version:D.majorVersion,GLctx:C};return C.canvas&&(C.canvas.GLctxObject=Q),gt.contexts[B]=Q,(typeof D.enableExtensionsByDefault==\"undefined\"||D.enableExtensionsByDefault)&>.initExtensions(Q),B},makeContextCurrent:function(C){return gt.currentContext=gt.contexts[C],d.ctx=Ac=gt.currentContext&>.currentContext.GLctx,!(C&&!Ac)},getContext:function(C){return gt.contexts[C]},deleteContext:function(C){gt.currentContext===gt.contexts[C]&&(gt.currentContext=null),typeof Le==\"object\"&&Le.removeAllHandlersOnTarget(gt.contexts[C].GLctx.canvas),gt.contexts[C]&>.contexts[C].GLctx.canvas&&(gt.contexts[C].GLctx.canvas.GLctxObject=void 0),qv(gt.contexts[C].handle),gt.contexts[C]=null},initExtensions:function(C){if(C||(C=gt.currentContext),!C.initExtensionsDone){C.initExtensionsDone=!0;var D=C.GLctx;Mh(D),Lh(D),Bh(D),D.disjointTimerQueryExt=D.getExtension(\"EXT_disjoint_timer_query\"),Vh(D);var B=D.getSupportedExtensions()||[];B.forEach(function(Q){!Q.includes(\"lose_context\")&&!Q.includes(\"debug\")&&D.getExtension(Q)})}}},Wh=[\"default\",\"low-power\",\"high-performance\"];function Uh(C,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:Wh[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=bu(C);if(!pe||ue.explicitSwapControl)return 0;var ye=gt.createContext(pe,ue);return ye}function Gh(C,D){return Uh(C,D)}var _i={mappings:{},buffers:[null,[],[]],printChar:function(C,D){var B=_i.buffers[C];D===0||D===10?((C===1?te:ee)(Dn(B,0)),B.length=0):B.push(D)},varargs:void 0,get:function(){_i.varargs+=4;var C=l()[_i.varargs-4>>2];return C},getStr:function(C){var D=tn(C);return D},get64:function(C,D){return C}};function Tc(C){return N?Lr(3,1,C):0}function $c(C,D,B,Q,ue){if(N)return Lr(4,1,C,D,B,Q,ue)}function _c(C,D,B,Q){if(N)return Lr(5,1,C,D,B,Q);for(var ue=0,pe=0;pe>2],Te=l()[D+4>>2];D+=8;for(var bt=0;bt>2]=ue,0}function Hh(C){Ee(C)}$e.init();var Ac,qh=[null,kc,Nc,Tc,$c,_c],Uv=!1,Ec={__clock_gettime:bh,__emscripten_init_main_thread_js:yh,__emscripten_thread_cleanup:vh,__pthread_create_js:xh,_emscripten_default_pthread_stack_size:wh,_emscripten_notify_thread_queue:kh,abort:Ih,emscripten_check_blocking_allowed:Sh,emscripten_get_heap_max:Sc,emscripten_get_now:Mr,emscripten_memcpy_big:Ch,emscripten_num_logical_cores:Nh,emscripten_receive_on_main_thread_js:Th,emscripten_resize_heap:_h,emscripten_set_canvas_element_size:Ph,emscripten_unwind_to_js_event_loop:zh,emscripten_webgl_create_context:Gh,exit:wc,fd_close:Tc,fd_seek:$c,fd_write:_c,memory:Ce||d.wasmMemory,setTempRet0:Hh},Gv=ih(),jh=d.___wasm_call_ctors=function(){return(jh=d.___wasm_call_ctors=d.asm.__wasm_call_ctors).apply(null,arguments)},Kh=d._init=function(){return(Kh=d._init=d.asm.init).apply(null,arguments)},Xh=d._init_with_threads_count=function(){return(Xh=d._init_with_threads_count=d.asm.init_with_threads_count).apply(null,arguments)},Yh=d._get_threads_count=function(){return(Yh=d._get_threads_count=d.asm.get_threads_count).apply(null,arguments)},Qh=d._register_tensor=function(){return(Qh=d._register_tensor=d.asm.register_tensor).apply(null,arguments)},Zh=d._dispose_data=function(){return(Zh=d._dispose_data=d.asm.dispose_data).apply(null,arguments)},Jh=d._dispose=function(){return(Jh=d._dispose=d.asm.dispose).apply(null,arguments)},ef=d._Abs=function(){return(ef=d._Abs=d.asm.Abs).apply(null,arguments)},tf=d._Add=function(){return(tf=d._Add=d.asm.Add).apply(null,arguments)},nf=d._AddN=function(){return(nf=d._AddN=d.asm.AddN).apply(null,arguments)},sf=d._All=function(){return(sf=d._All=d.asm.All).apply(null,arguments)},rf=d._Any=function(){return(rf=d._Any=d.asm.Any).apply(null,arguments)},af=d._ArgMax=function(){return(af=d._ArgMax=d.asm.ArgMax).apply(null,arguments)},of=d._AvgPool=function(){return(of=d._AvgPool=d.asm.AvgPool).apply(null,arguments)},uf=d._BatchMatMul=function(){return(uf=d._BatchMatMul=d.asm.BatchMatMul).apply(null,arguments)},lf=d._Ceil=function(){return(lf=d._Ceil=d.asm.Ceil).apply(null,arguments)},cf=d._ClipByValue=function(){return(cf=d._ClipByValue=d.asm.ClipByValue).apply(null,arguments)},df=d._Conv2D=function(){return(df=d._Conv2D=d.asm.Conv2D).apply(null,arguments)},pf=d._Conv2DBackpropInput=function(){return(pf=d._Conv2DBackpropInput=d.asm.Conv2DBackpropInput).apply(null,arguments)},hf=d._Cos=function(){return(hf=d._Cos=d.asm.Cos).apply(null,arguments)},ff=d._Cosh=function(){return(ff=d._Cosh=d.asm.Cosh).apply(null,arguments)},mf=d._CropAndResize=function(){return(mf=d._CropAndResize=d.asm.CropAndResize).apply(null,arguments)},gf=d._Cumprod=function(){return(gf=d._Cumprod=d.asm.Cumprod).apply(null,arguments)},bf=d._Cumsum=function(){return(bf=d._Cumsum=d.asm.Cumsum).apply(null,arguments)},yf=d._DepthToSpace=function(){return(yf=d._DepthToSpace=d.asm.DepthToSpace).apply(null,arguments)},vf=d._DepthwiseConv2dNative=function(){return(vf=d._DepthwiseConv2dNative=d.asm.DepthwiseConv2dNative).apply(null,arguments)},xf=d._Elu=function(){return(xf=d._Elu=d.asm.Elu).apply(null,arguments)},wf=d._Equal=function(){return(wf=d._Equal=d.asm.Equal).apply(null,arguments)},kf=d._Exp=function(){return(kf=d._Exp=d.asm.Exp).apply(null,arguments)},If=d._FlipLeftRight=function(){return(If=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)},yu=d._FusedBatchNorm=function(){return(yu=d._FusedBatchNorm=d.asm.FusedBatchNorm).apply(null,arguments)},Sf=d._FusedConv2D=function(){return(Sf=d._FusedConv2D=d.asm.FusedConv2D).apply(null,arguments)},Cf=d._FusedDepthwiseConv2D=function(){return(Cf=d._FusedDepthwiseConv2D=d.asm.FusedDepthwiseConv2D).apply(null,arguments)},Ai=d._Gather=function(){return(Ai=d._Gather=d.asm.Gather).apply(null,arguments)},vu=d._GatherNd=function(){return(vu=d._GatherNd=d.asm.GatherNd).apply(null,arguments)},xu=d._Greater=function(){return(xu=d._Greater=d.asm.Greater).apply(null,arguments)},Hv=d._GreaterEqual=function(){return(Hv=d._GreaterEqual=d.asm.GreaterEqual).apply(null,arguments)},Ei=d._LeakyRelu=function(){return(Ei=d._LeakyRelu=d.asm.LeakyRelu).apply(null,arguments)},Ri=d._Less=function(){return(Ri=d._Less=d.asm.Less).apply(null,arguments)},Nf=d._LessEqual=function(){return(Nf=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)},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)},ze=d._Minimum=function(){return(ze=d._Minimum=d.asm.Minimum).apply(null,arguments)},Tt=d._MirrorPad=function(){return(Tt=d._MirrorPad=d.asm.MirrorPad).apply(null,arguments)},is=d._Multiply=function(){return(is=d._Multiply=d.asm.Multiply).apply(null,arguments)},os=d._Neg=function(){return(os=d._Neg=d.asm.Neg).apply(null,arguments)},Di=d._NonMaxSuppressionV3=function(){return(Di=d._NonMaxSuppressionV3=d.asm.NonMaxSuppressionV3).apply(null,arguments)},Br=d._NonMaxSuppressionV4=function(){return(Br=d._NonMaxSuppressionV4=d.asm.NonMaxSuppressionV4).apply(null,arguments)},Tf=d._NonMaxSuppressionV5=function(){return(Tf=d._NonMaxSuppressionV5=d.asm.NonMaxSuppressionV5).apply(null,arguments)},an=d._NotEqual=function(){return(an=d._NotEqual=d.asm.NotEqual).apply(null,arguments)},nr=d._OneHot=function(){return(nr=d._OneHot=d.asm.OneHot).apply(null,arguments)},Fc=d._PadV2=function(){return(Fc=d._PadV2=d.asm.PadV2).apply(null,arguments)},jN=d._Pow=function(){return(jN=d._Pow=d.asm.Pow).apply(null,arguments)},KN=d._Prelu=function(){return(KN=d._Prelu=d.asm.Prelu).apply(null,arguments)},XN=d._Prod=function(){return(XN=d._Prod=d.asm.Prod).apply(null,arguments)},YN=d._RealDiv=function(){return(YN=d._RealDiv=d.asm.RealDiv).apply(null,arguments)},QN=d._Relu=function(){return(QN=d._Relu=d.asm.Relu).apply(null,arguments)},ZN=d._Relu6=function(){return(ZN=d._Relu6=d.asm.Relu6).apply(null,arguments)},JN=d._ResizeBilinear=function(){return(JN=d._ResizeBilinear=d.asm.ResizeBilinear).apply(null,arguments)},eT=d._Reverse=function(){return(eT=d._Reverse=d.asm.Reverse).apply(null,arguments)},tT=d._RotateWithOffset=function(){return(tT=d._RotateWithOffset=d.asm.RotateWithOffset).apply(null,arguments)},nT=d._Round=function(){return(nT=d._Round=d.asm.Round).apply(null,arguments)},sT=d._Rsqrt=function(){return(sT=d._Rsqrt=d.asm.Rsqrt).apply(null,arguments)},rT=d._ScatterNd=function(){return(rT=d._ScatterNd=d.asm.ScatterNd).apply(null,arguments)},aT=d._SelectV2=function(){return(aT=d._SelectV2=d.asm.SelectV2).apply(null,arguments)},iT=d._Sigmoid=function(){return(iT=d._Sigmoid=d.asm.Sigmoid).apply(null,arguments)},oT=d._Sin=function(){return(oT=d._Sin=d.asm.Sin).apply(null,arguments)},uT=d._Softmax=function(){return(uT=d._Softmax=d.asm.Softmax).apply(null,arguments)},lT=d._SparseFillEmptyRows=function(){return(lT=d._SparseFillEmptyRows=d.asm.SparseFillEmptyRows).apply(null,arguments)},cT=d._SparseReshape=function(){return(cT=d._SparseReshape=d.asm.SparseReshape).apply(null,arguments)},dT=d._SparseSegmentReduction=function(){return(dT=d._SparseSegmentReduction=d.asm.SparseSegmentReduction).apply(null,arguments)},pT=d._Sqrt=function(){return(pT=d._Sqrt=d.asm.Sqrt).apply(null,arguments)},hT=d._Square=function(){return(hT=d._Square=d.asm.Square).apply(null,arguments)},fT=d._SquaredDifference=function(){return(fT=d._SquaredDifference=d.asm.SquaredDifference).apply(null,arguments)},mT=d._Step=function(){return(mT=d._Step=d.asm.Step).apply(null,arguments)},gT=d._StridedSlice=function(){return(gT=d._StridedSlice=d.asm.StridedSlice).apply(null,arguments)},bT=d._Sub=function(){return(bT=d._Sub=d.asm.Sub).apply(null,arguments)},yT=d._Sum=function(){return(yT=d._Sum=d.asm.Sum).apply(null,arguments)},vT=d._Tan=function(){return(vT=d._Tan=d.asm.Tan).apply(null,arguments)},xT=d._Tanh=function(){return(xT=d._Tanh=d.asm.Tanh).apply(null,arguments)},wT=d._Tile=function(){return(wT=d._Tile=d.asm.Tile).apply(null,arguments)},kT=d._TopK=function(){return(kT=d._TopK=d.asm.TopK).apply(null,arguments)},IT=d._Transform=function(){return(IT=d._Transform=d.asm.Transform).apply(null,arguments)},ST=d._Transpose=function(){return(ST=d._Transpose=d.asm.Transpose).apply(null,arguments)},CT=d.__FusedMatMul=function(){return(CT=d.__FusedMatMul=d.asm._FusedMatMul).apply(null,arguments)},$f=d._malloc=function(){return($f=d._malloc=d.asm.malloc).apply(null,arguments)},qv=d._free=function(){return(qv=d._free=d.asm.free).apply(null,arguments)},NT=d._emscripten_tls_init=function(){return(NT=d._emscripten_tls_init=d.asm.emscripten_tls_init).apply(null,arguments)},jv=d.___errno_location=function(){return(jv=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)},Kv=d._emscripten_main_thread_process_queued_calls=function(){return(Kv=d._emscripten_main_thread_process_queued_calls=d.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},TT=d.__emscripten_thread_crashed=function(){return(TT=d.__emscripten_thread_crashed=d.asm._emscripten_thread_crashed).apply(null,arguments)},Xv=d.__emscripten_thread_init=function(){return(Xv=d.__emscripten_thread_init=d.asm._emscripten_thread_init).apply(null,arguments)},$T=d._emscripten_current_thread_process_queued_calls=function(){return($T=d._emscripten_current_thread_process_queued_calls=d.asm.emscripten_current_thread_process_queued_calls).apply(null,arguments)},_T=d._emscripten_main_browser_thread_id=function(){return(_T=d._emscripten_main_browser_thread_id=d.asm.emscripten_main_browser_thread_id).apply(null,arguments)},AT=d._emscripten_sync_run_in_main_thread_2=function(){return(AT=d._emscripten_sync_run_in_main_thread_2=d.asm.emscripten_sync_run_in_main_thread_2).apply(null,arguments)},Yv=d._emscripten_sync_run_in_main_thread_4=function(){return(Yv=d._emscripten_sync_run_in_main_thread_4=d.asm.emscripten_sync_run_in_main_thread_4).apply(null,arguments)},Qv=d._emscripten_run_in_main_runtime_thread_js=function(){return(Qv=d._emscripten_run_in_main_runtime_thread_js=d.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)},_f=d._emscripten_dispatch_to_thread_=function(){return(_f=d._emscripten_dispatch_to_thread_=d.asm.emscripten_dispatch_to_thread_).apply(null,arguments)},Af=d.__emscripten_thread_free_data=function(){return(Af=d.__emscripten_thread_free_data=d.asm._emscripten_thread_free_data).apply(null,arguments)},ET=d.__emscripten_thread_exit=function(){return(ET=d.__emscripten_thread_exit=d.asm._emscripten_thread_exit).apply(null,arguments)},RT=d._memalign=function(){return(RT=d._memalign=d.asm.memalign).apply(null,arguments)},Zv=d._emscripten_stack_set_limits=function(){return(Zv=d._emscripten_stack_set_limits=d.asm.emscripten_stack_set_limits).apply(null,arguments)},Ef=d.stackSave=function(){return(Ef=d.stackSave=d.asm.stackSave).apply(null,arguments)},Pc=d.stackRestore=function(){return(Pc=d.stackRestore=d.asm.stackRestore).apply(null,arguments)},Fi=d.stackAlloc=function(){return(Fi=d.stackAlloc=d.asm.stackAlloc).apply(null,arguments)},DT=d.dynCall_iijjiiii=function(){return(DT=d.dynCall_iijjiiii=d.asm.dynCall_iijjiiii).apply(null,arguments)},FT=d.dynCall_jiji=function(){return(FT=d.dynCall_jiji=d.asm.dynCall_jiji).apply(null,arguments)},Jv=d.__emscripten_allow_main_runtime_queued_calls=21456;d.cwrap=en,d.keepRuntimeAlive=Pr,d.PThread=$e,d.PThread=$e,d.wasmMemory=Ce,d.ExitStatus=wu;var zc;function wu(C){this.name=\"ExitStatus\",this.message=\"Program terminated with exit(\"+C+\")\",this.status=C}as=function C(){zc||Rf(),zc||(as=C)};function Rf(C){if(C=C||b,tr>0)return;if(N){h(d),hu(),postMessage({cmd:\"loaded\"});return}if(sn(),tr>0)return;function D(){zc||(zc=!0,d.calledRun=!0,!at&&(hu(),h(d),d.onRuntimeInitialized&&d.onRuntimeInitialized(),rh()))}d.setStatus?(d.setStatus(\"Running...\"),setTimeout(function(){setTimeout(function(){d.setStatus(\"\")},1),D()},1)):D()}d.run=Rf;function OT(C,D){if(Jt=C,!D&&N)throw kc(C),\"unwind\";Pr()||sh(),PT(C)}function PT(C){Jt=C,Pr()||($e.terminateAllThreads(),d.onExit&&d.onExit(C),at=!0),v(C,new wu(C))}if(d.preInit)for(typeof d.preInit==\"function\"&&(d.preInit=[d.preInit]);d.preInit.length>0;)d.preInit.pop()();Rf();var Mc;m&&(Mc={uncaughtException:process.listeners(\"uncaughtException\").filter(function(C){return!m.uncaughtException.indexOf(C)>-1}),unhandledRejection:process.listeners(\"unhandledRejection\").filter(function(C){return!m.unhandledRejection.indexOf(C)>-1})});var Lc;if(typeof WasmBackendModule!=\"undefined\")Lc=WasmBackendModule;else if(typeof r!=\"undefined\")Lc=r;else throw new Error(\"Could not find wasm module in post.js\");if(Mc){var zT=Lc._dispose;Lc._dispose=function(){zT(),Mc.uncaughtException.forEach(function(C){process.removeListener(\"uncaughtException\",C)}),Mc.unhandledRejection.forEach(function(C){process.removeListener(\"unhandledRejection\",C)})}}return r.ready}})();typeof e==\"object\"&&typeof t==\"object\"?t.exports=n:typeof define==\"function\"&&define.amd?define([],function(){return n}):typeof e==\"object\"&&(e.WasmBackendModuleThreadedSimd=n)}}),i$=zt({\"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});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},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 T(H){if(H instanceof vu)return;R(\"exiting due to exception: \"+H)}var N,E,A;m?(f?g=dd().dirname(g)+\"/\":g=__dirname+\"/\",A=()=>{E||(N=tg(),E=dd())},y=function(J,de){return A(),J=E.normalize(J),N.readFileSync(J,de?void 0:\"utf8\")},x=H=>{var J=y(H,!0);return J.buffer||(J=new Uint8Array(J)),J},v=(H,J,de)=>{A(),H=E.normalize(H),N.readFile(H,function(Ie,Qe){Ie?de(Ie):J(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 vu))throw H}),process.on(\"unhandledRejection\",function(H){throw H}),d=(H,J)=>{if(pu())throw process.exitCode=H,J;T(J),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,!1),J.send(null),J.responseText},f&&(x=H=>{var J=new XMLHttpRequest;return J.open(\"GET\",H,!1),J.responseType=\"arraybuffer\",J.send(null),new Uint8Array(J.response)}),v=(H,J,de)=>{var Ie=new XMLHttpRequest;Ie.open(\"GET\",H,!0),Ie.responseType=\"arraybuffer\",Ie.onload=()=>{if(Ie.status==200||Ie.status==0&&Ie.response){J(Ie.response);return}de()},Ie.onerror=de,Ie.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);var F=4;function $(H){$.shown||($.shown={}),$.shown[H]||($.shown[H]=1,R(H))}function z(H,J){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{Z=H},ee;a.wasmBinary&&(ee=a.wasmBinary);var se=a.noExitRuntime||!0;typeof WebAssembly!=\"object\"&&Or(\"no native wasm support detected\");var ne,oe=!1,re;function le(H,J){H||Or(J)}function me(H){var J=a[\"_\"+H];return J}function ke(H,J,de,Ie,Qe){var Ze={string:function(an){var nr=0;if(an!=null&&an!==0){var Fc=(an.length<<2)+1;nr=yu(Fc),tt(an,nr,Fc)}return nr},array:function(an){var nr=yu(an.length);return at(an,nr),nr}};function Ve(an){return J===\"string\"?Je(an):J===\"boolean\"?Boolean(an):an}var ze=me(H),Tt=[],is=0;if(Ie)for(var os=0;os=Ie);)++Qe;if(Qe-J>16&&H.subarray&&Pe)return Pe.decode(H.subarray(J,Qe));for(var Ze=\"\";J>10,56320|is&1023)}}return Ze}function Je(H,J){return H?Xe(en,H,J):\"\"}function Ye(H,J,de,Ie){if(!(Ie>0))return 0;for(var Qe=de,Ze=de+Ie-1,Ve=0;Ve=55296&&ze<=57343){var Tt=H.charCodeAt(++Ve);ze=65536+((ze&1023)<<10)|Tt&1023}if(ze<=127){if(de>=Ze)break;J[de++]=ze}else if(ze<=2047){if(de+1>=Ze)break;J[de++]=192|ze>>6,J[de++]=128|ze&63}else if(ze<=65535){if(de+2>=Ze)break;J[de++]=224|ze>>12,J[de++]=128|ze>>6&63,J[de++]=128|ze&63}else{if(de+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}}return J[de]=0,de-Qe}function tt(H,J,de){return Ye(H,en,J,de)}function Ce(H){for(var J=0,de=0;de=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}return J}var ut=typeof TextDecoder!=\"undefined\"?new TextDecoder(\"utf-16le\"):void 0;function at(H,J){Et.set(H,J)}function Jt(H,J,de){for(var Ie=0;Ie>0]=H.charCodeAt(Ie);de||(Et[J>>0]=0)}function Nt(H,J){return H%J>0&&(H+=J-H%J),H}var Cn,Et,en,Nn,Tn,Yt,Dn,tn,Ms;function Ls(H){Cn=H,a.HEAP8=Et=new Int8Array(H),a.HEAP16=Nn=new Int16Array(H),a.HEAP32=Yt=new Int32Array(H),a.HEAPU8=en=new Uint8Array(H),a.HEAPU16=Tn=new Uint16Array(H),a.HEAPU32=Dn=new Uint32Array(H),a.HEAPF32=tn=new Float32Array(H),a.HEAPF64=Ms=new Float64Array(H)}var ki=a.INITIAL_MEMORY||16777216,Js,Bs=[],du=[],Ii=[],nn=!1,ic=!1,oc=0;function pu(){return se||oc>0}function uc(){if(a.preRun)for(typeof a.preRun==\"function\"&&(a.preRun=[a.preRun]);a.preRun.length;)dc(a.preRun.shift());fu(Bs)}function lc(){nn=!0,fu(du)}function Fv(){ic=!0}function cc(){if(a.postRun)for(typeof a.postRun==\"function\"&&(a.postRun=[a.postRun]);a.postRun.length;)pc(a.postRun.shift());fu(Ii)}function dc(H){Bs.unshift(H)}function rs(H){du.unshift(H)}function pc(H){Ii.unshift(H)}var Fn=0,Si=null,er=null;function th(H){Fn++,a.monitorRunDependencies&&a.monitorRunDependencies(Fn)}function hc(H){if(Fn--,a.monitorRunDependencies&&a.monitorRunDependencies(Fn),Fn==0&&(Si!==null&&(clearInterval(Si),Si=null),er)){var J=er;er=null,J()}}a.preloadedImages={},a.preloadedAudios={};function Or(H){a.onAbort&&a.onAbort(H),H=\"Aborted(\"+H+\")\",R(H),oe=!0,re=1,H+=\". Build with -s ASSERTIONS=1 for more info.\";var J=new WebAssembly.RuntimeError(H);throw o(J),J}var nh=\"data:application/octet-stream;base64,\";function fc(H){return H.startsWith(nh)}function Pr(H){return H.startsWith(\"file://\")}var sn;sn=\"tfjs-backend-wasm.wasm\",fc(sn)||(sn=b(sn));function hu(H){try{if(H==sn&&ee)return new Uint8Array(ee);if(x)return x(H);throw\"both async and sync fetching of the wasm failed\"}catch(J){Or(J)}}function sh(){if(!ee&&(h||f)){if(typeof fetch==\"function\"&&!Pr(sn))return fetch(sn,{credentials:\"same-origin\"}).then(function(H){if(!H.ok)throw\"failed to load wasm binary file at '\"+sn+\"'\";return H.arrayBuffer()}).catch(function(){return hu(sn)});if(v)return new Promise(function(H,J){v(sn,function(de){H(new Uint8Array(de))},J)})}return Promise.resolve().then(function(){return hu(sn)})}function rh(){var H={env:Ti,wasi_snapshot_preview1:Ti};function J(Ve,ze){var Tt=Ve.exports;a.asm=Tt,ne=a.asm.memory,Ls(ne.buffer),Js=a.asm.__indirect_function_table,rs(a.asm.__wasm_call_ctors),hc(\"wasm-instantiate\")}th(\"wasm-instantiate\");function de(Ve){J(Ve.instance)}function Ie(Ve){return sh().then(function(ze){return WebAssembly.instantiate(ze,H)}).then(function(ze){return ze}).then(Ve,function(ze){R(\"failed to asynchronously prepare wasm: \"+ze),Or(ze)})}function Qe(){return!ee&&typeof WebAssembly.instantiateStreaming==\"function\"&&!fc(sn)&&!Pr(sn)&&typeof fetch==\"function\"?fetch(sn,{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)})}):Ie(de)}if(a.instantiateWasm)try{var Ze=a.instantiateWasm(H,J);return Ze}catch(Ve){return R(\"Module.instantiateWasm callback failed with error: \"+Ve),!1}return Qe().catch(o),{}}var Ov,Pv;function fu(H){for(;H.length>0;){var J=H.shift();if(typeof J==\"function\"){J(a);continue}var de=J.func;typeof de==\"number\"?J.arg===void 0?mu(de)():mu(de)(J.arg):de(J.arg===void 0?null:J.arg)}}function tr(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+\"]\"})}var as=[];function mu(H){var J=as[H];return J||(H>=as.length&&(as.length=H+1),as[H]=J=Js.get(H)),J}function zv(){var H=new Error;if(!H.stack){try{throw new Error}catch(J){H=J}if(!H.stack)return\"(no stack trace available)\"}return H.stack.toString()}function Ci(H,J){Js.set(H,J),as[H]=J}function ah(){Or(\"\")}function gc(H,J,de){en.copyWithin(H,J,J+de)}function bc(){return 2147483648}function rn(H){try{return ne.grow(H-Cn.byteLength+65535>>>16),Ls(ne.buffer),1}catch(J){}}function yc(H){var J=en.length;H=H>>>0;var de=bc();if(H>de)return!1;for(var Ie=1;Ie<=4;Ie*=2){var Qe=J*(1+.2/Ie);Qe=Math.min(Qe,H+100663296);var Ze=Math.min(de,Nt(Math.max(H,Qe),65536)),Ve=rn(Ze);if(Ve)return!0}return!1}var Ni={mappings:{},buffers:[null,[],[]],printChar:function(H,J){var de=Ni.buffers[H];J===0||J===10?((H===1?P:R)(Xe(de,0)),de.length=0):de.push(J)},varargs:void 0,get:function(){Ni.varargs+=4;var H=Yt[Ni.varargs-4>>2];return H},getStr:function(H){var J=Je(H);return J},get64:function(H,J){return H}};function ih(H){return 0}function Mv(H,J,de,Ie,Qe){}function Lv(H,J,de,Ie){for(var Qe=0,Ze=0;Ze>2],ze=Yt[J+4>>2];J+=8;for(var Tt=0;Tt>2]=Qe,0}function oh(H){te(H)}var vc=!1,Ti={abort:ah,emscripten_memcpy_big:gc,emscripten_resize_heap:yc,fd_close:ih,fd_seek:Mv,fd_write:Lv,setTempRet0:oh},qN=rh(),Bv=a.___wasm_call_ctors=function(){return(Bv=a.___wasm_call_ctors=a.asm.__wasm_call_ctors).apply(null,arguments)},uh=a._init=function(){return(uh=a._init=a.asm.init).apply(null,arguments)},lh=a._init_with_threads_count=function(){return(lh=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)},ch=a._dispose_data=function(){return(ch=a._dispose_data=a.asm.dispose_data).apply(null,arguments)},$e=a._dispose=function(){return($e=a._dispose=a.asm.dispose).apply(null,arguments)},dh=a._Abs=function(){return(dh=a._Abs=a.asm.Abs).apply(null,arguments)},kc=a._Add=function(){return(kc=a._Add=a.asm.Add).apply(null,arguments)},zr=a._AddN=function(){return(zr=a._AddN=a.asm.AddN).apply(null,arguments)},$i=a._All=function(){return($i=a._All=a.asm.All).apply(null,arguments)},ph=a._Any=function(){return(ph=a._Any=a.asm.Any).apply(null,arguments)},Vv=a._ArgMax=function(){return(Vv=a._ArgMax=a.asm.ArgMax).apply(null,arguments)},hh=a._AvgPool=function(){return(hh=a._AvgPool=a.asm.AvgPool).apply(null,arguments)},Wv=a._BatchMatMul=function(){return(Wv=a._BatchMatMul=a.asm.BatchMatMul).apply(null,arguments)},Mr=a._Ceil=function(){return(Mr=a._Ceil=a.asm.Ceil).apply(null,arguments)},fh=a._ClipByValue=function(){return(fh=a._ClipByValue=a.asm.ClipByValue).apply(null,arguments)},mh=a._Conv2D=function(){return(mh=a._Conv2D=a.asm.Conv2D).apply(null,arguments)},gh=a._Conv2DBackpropInput=function(){return(gh=a._Conv2DBackpropInput=a.asm.Conv2DBackpropInput).apply(null,arguments)},bh=a._Cos=function(){return(bh=a._Cos=a.asm.Cos).apply(null,arguments)},yh=a._Cosh=function(){return(yh=a._Cosh=a.asm.Cosh).apply(null,arguments)},vh=a._CropAndResize=function(){return(vh=a._CropAndResize=a.asm.CropAndResize).apply(null,arguments)},Ic=a._Cumprod=function(){return(Ic=a._Cumprod=a.asm.Cumprod).apply(null,arguments)},xh=a._Cumsum=function(){return(xh=a._Cumsum=a.asm.Cumsum).apply(null,arguments)},wh=a._DepthToSpace=function(){return(wh=a._DepthToSpace=a.asm.DepthToSpace).apply(null,arguments)},kh=a._DepthwiseConv2dNative=function(){return(kh=a._DepthwiseConv2dNative=a.asm.DepthwiseConv2dNative).apply(null,arguments)},Ih=a._Elu=function(){return(Ih=a._Elu=a.asm.Elu).apply(null,arguments)},Sh=a._Equal=function(){return(Sh=a._Equal=a.asm.Equal).apply(null,arguments)},Sc=a._Exp=function(){return(Sc=a._Exp=a.asm.Exp).apply(null,arguments)},Ch=a._FlipLeftRight=function(){return(Ch=a._FlipLeftRight=a.asm.FlipLeftRight).apply(null,arguments)},Nh=a._Floor=function(){return(Nh=a._Floor=a.asm.Floor).apply(null,arguments)},Lr=a._FloorDiv=function(){return(Lr=a._FloorDiv=a.asm.FloorDiv).apply(null,arguments)},gu=a._FusedBatchNorm=function(){return(gu=a._FusedBatchNorm=a.asm.FusedBatchNorm).apply(null,arguments)},Th=a._FusedConv2D=function(){return(Th=a._FusedConv2D=a.asm.FusedConv2D).apply(null,arguments)},$h=a._FusedDepthwiseConv2D=function(){return($h=a._FusedDepthwiseConv2D=a.asm.FusedDepthwiseConv2D).apply(null,arguments)},_h=a._Gather=function(){return(_h=a._Gather=a.asm.Gather).apply(null,arguments)},Le=a._GatherNd=function(){return(Le=a._GatherNd=a.asm.GatherNd).apply(null,arguments)},Ah=a._Greater=function(){return(Ah=a._Greater=a.asm.Greater).apply(null,arguments)},Eh=a._GreaterEqual=function(){return(Eh=a._GreaterEqual=a.asm.GreaterEqual).apply(null,arguments)},Rh=a._LeakyRelu=function(){return(Rh=a._LeakyRelu=a.asm.LeakyRelu).apply(null,arguments)},Dh=a._Less=function(){return(Dh=a._Less=a.asm.Less).apply(null,arguments)},Fh=a._LessEqual=function(){return(Fh=a._LessEqual=a.asm.LessEqual).apply(null,arguments)},Oh=a._Log=function(){return(Oh=a._Log=a.asm.Log).apply(null,arguments)},bu=a._LogicalAnd=function(){return(bu=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)},Ph=a._Maximum=function(){return(Ph=a._Maximum=a.asm.Maximum).apply(null,arguments)},zh=a._Mean=function(){return(zh=a._Mean=a.asm.Mean).apply(null,arguments)},Mh=a._Min=function(){return(Mh=a._Min=a.asm.Min).apply(null,arguments)},Lh=a._Minimum=function(){return(Lh=a._Minimum=a.asm.Minimum).apply(null,arguments)},Bh=a._MirrorPad=function(){return(Bh=a._MirrorPad=a.asm.MirrorPad).apply(null,arguments)},Vh=a._Multiply=function(){return(Vh=a._Multiply=a.asm.Multiply).apply(null,arguments)},gt=a._Neg=function(){return(gt=a._Neg=a.asm.Neg).apply(null,arguments)},Wh=a._NonMaxSuppressionV3=function(){return(Wh=a._NonMaxSuppressionV3=a.asm.NonMaxSuppressionV3).apply(null,arguments)},Uh=a._NonMaxSuppressionV4=function(){return(Uh=a._NonMaxSuppressionV4=a.asm.NonMaxSuppressionV4).apply(null,arguments)},Gh=a._NonMaxSuppressionV5=function(){return(Gh=a._NonMaxSuppressionV5=a.asm.NonMaxSuppressionV5).apply(null,arguments)},_i=a._NotEqual=function(){return(_i=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)},Hh=a._Prelu=function(){return(Hh=a._Prelu=a.asm.Prelu).apply(null,arguments)},Ac=a._Prod=function(){return(Ac=a._Prod=a.asm.Prod).apply(null,arguments)},qh=a._RealDiv=function(){return(qh=a._RealDiv=a.asm.RealDiv).apply(null,arguments)},Uv=a._Relu=function(){return(Uv=a._Relu=a.asm.Relu).apply(null,arguments)},Ec=a._Relu6=function(){return(Ec=a._Relu6=a.asm.Relu6).apply(null,arguments)},Gv=a._ResizeBilinear=function(){return(Gv=a._ResizeBilinear=a.asm.ResizeBilinear).apply(null,arguments)},jh=a._Reverse=function(){return(jh=a._Reverse=a.asm.Reverse).apply(null,arguments)},Kh=a._RotateWithOffset=function(){return(Kh=a._RotateWithOffset=a.asm.RotateWithOffset).apply(null,arguments)},Xh=a._Round=function(){return(Xh=a._Round=a.asm.Round).apply(null,arguments)},Yh=a._Rsqrt=function(){return(Yh=a._Rsqrt=a.asm.Rsqrt).apply(null,arguments)},Qh=a._ScatterNd=function(){return(Qh=a._ScatterNd=a.asm.ScatterNd).apply(null,arguments)},Zh=a._SelectV2=function(){return(Zh=a._SelectV2=a.asm.SelectV2).apply(null,arguments)},Jh=a._Sigmoid=function(){return(Jh=a._Sigmoid=a.asm.Sigmoid).apply(null,arguments)},ef=a._Sin=function(){return(ef=a._Sin=a.asm.Sin).apply(null,arguments)},tf=a._Softmax=function(){return(tf=a._Softmax=a.asm.Softmax).apply(null,arguments)},nf=a._SparseFillEmptyRows=function(){return(nf=a._SparseFillEmptyRows=a.asm.SparseFillEmptyRows).apply(null,arguments)},sf=a._SparseReshape=function(){return(sf=a._SparseReshape=a.asm.SparseReshape).apply(null,arguments)},rf=a._SparseSegmentReduction=function(){return(rf=a._SparseSegmentReduction=a.asm.SparseSegmentReduction).apply(null,arguments)},af=a._Sqrt=function(){return(af=a._Sqrt=a.asm.Sqrt).apply(null,arguments)},of=a._Square=function(){return(of=a._Square=a.asm.Square).apply(null,arguments)},uf=a._SquaredDifference=function(){return(uf=a._SquaredDifference=a.asm.SquaredDifference).apply(null,arguments)},lf=a._Step=function(){return(lf=a._Step=a.asm.Step).apply(null,arguments)},cf=a._StridedSlice=function(){return(cf=a._StridedSlice=a.asm.StridedSlice).apply(null,arguments)},df=a._Sub=function(){return(df=a._Sub=a.asm.Sub).apply(null,arguments)},pf=a._Sum=function(){return(pf=a._Sum=a.asm.Sum).apply(null,arguments)},hf=a._Tan=function(){return(hf=a._Tan=a.asm.Tan).apply(null,arguments)},ff=a._Tanh=function(){return(ff=a._Tanh=a.asm.Tanh).apply(null,arguments)},mf=a._Tile=function(){return(mf=a._Tile=a.asm.Tile).apply(null,arguments)},gf=a._TopK=function(){return(gf=a._TopK=a.asm.TopK).apply(null,arguments)},bf=a._Transform=function(){return(bf=a._Transform=a.asm.Transform).apply(null,arguments)},yf=a._Transpose=function(){return(yf=a._Transpose=a.asm.Transpose).apply(null,arguments)},vf=a.__FusedMatMul=function(){return(vf=a.__FusedMatMul=a.asm._FusedMatMul).apply(null,arguments)},xf=a._malloc=function(){return(xf=a._malloc=a.asm.malloc).apply(null,arguments)},wf=a._free=function(){return(wf=a._free=a.asm.free).apply(null,arguments)},kf=a.___errno_location=function(){return(kf=a.___errno_location=a.asm.__errno_location).apply(null,arguments)},If=a._emscripten_main_thread_process_queued_calls=function(){return(If=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)},yu=a.stackAlloc=function(){return(yu=a.stackAlloc=a.asm.stackAlloc).apply(null,arguments)},Sf=a.dynCall_iijjiiii=function(){return(Sf=a.dynCall_iijjiiii=a.asm.dynCall_iijjiiii).apply(null,arguments)},Cf=a.dynCall_jiji=function(){return(Cf=a.dynCall_jiji=a.asm.dynCall_jiji).apply(null,arguments)};a.cwrap=Se;var Ai;function vu(H){this.name=\"ExitStatus\",this.message=\"Program terminated with exit(\"+H+\")\",this.status=H}er=function H(){Ai||xu(),Ai||(er=H)};function xu(H){if(H=H||c,Fn>0||(uc(),Fn>0))return;function J(){Ai||(Ai=!0,a.calledRun=!0,!oe&&(lc(),i(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),cc()))}a.setStatus?(a.setStatus(\"Running...\"),setTimeout(function(){setTimeout(function(){a.setStatus(\"\")},1),J()},1)):J()}a.run=xu;function Hv(H){re=H,pu()||(a.onExit&&a.onExit(H),oe=!0),d(H,new vu(H))}if(a.preInit)for(typeof a.preInit==\"function\"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();xu();var Ei;u&&(Ei={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 Ri;if(typeof r!=\"undefined\")Ri=r;else if(typeof WasmBackendModuleThreadedSimd!=\"undefined\")Ri=WasmBackendModuleThreadedSimd;else throw new Error(\"Could not find wasm module in post.js\");if(Ei){var Nf=Ri._dispose;Ri._dispose=function(){Nf(),Ei.uncaughtException.forEach(function(H){process.removeListener(\"uncaughtException\",H)}),Ei.unhandledRejection.forEach(function(H){process.removeListener(\"unhandledRejection\",H)})}}return r.ready}})();typeof e==\"object\"&&typeof t==\"object\"?t.exports=n:typeof define==\"function\"&&define.amd?define([],function(){return n}):typeof e==\"object\"&&(e.WasmBackendModule=n)}}),o$=1e-7,u$=1e-4,Ud=class{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}},tl=class{refCount(e){return On(\"refCount\")}incRef(e){return On(\"incRef\")}timerAvailable(){return!0}time(e){return On(\"time\")}read(e){return On(\"read\")}readSync(e){return On(\"readSync\")}readToGPU(e,t){return On(\"readToGPU\")}numDataIds(){return On(\"numDataIds\")}disposeData(e,t){return On(\"disposeData\")}write(e,t,n){return On(\"write\")}move(e,t,n,s,r){return On(\"move\")}memory(){return On(\"memory\")}floatPrecision(){return On(\"floatPrecision\")}epsilon(){return this.floatPrecision()===32?o$:u$}dispose(){return On(\"dispose\")}};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 Uw(e){let t=e.length,n=0;for(;t>0;)n=Math.random()*t|0,t--,pd(e,t,n)}function l$(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)}function Bu(e,t,n){return Math.max(e,Math.min(t,n))}function c$(e){return e%2===0?e:e+1}function pd(e,t,n){let s=e[t];e[t]=e[n],e[n]=s}function d$(e){let t=0;for(let n=0;nn+` Shapes ${e} and ${t} must match`)}function wa(e){O(e!=null,()=>\"The input to the tensor constructor must be a non-null value.\")}function sa(e,t=[],n=!1){if(t==null&&(t=[]),Array.isArray(e)||Qt(e)&&!n)for(let s=0;s0,n){return new Promise((s,r)=>{let a=0,i=()=>{if(e()){s();return}a++;let o=t(a);if(n!=null&&a>=n){r();return}setTimeout(i,o)};i()})}function v$(e,t){let n=1,s=-1;for(let a=0;a=0)n*=e[a];else if(e[a]===-1){if(s!==-1)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${s} and dim ${a}`);s=a}else if(e[a]<0)throw Error(`Shapes can not be < 0. Found ${e[a]} at dim ${a}`);if(s===-1){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(n===0)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!==0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);let r=e.slice();return r[s]=t/n,r}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`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`),O(e.every(s=>Yi(s)),()=>`All values in axis param must be integers but got axis ${e}`),e.map(s=>s<0?n+s:s)}function Gw(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;oo)&&e[o]===1&&(n.push(e[o]),s.push(o)),a[i]<=o&&i++}e[o]!==1&&(n.push(e[o]),s.push(o))}return{newShape:n,keptDims:s}}function Hw(e,t){let n=null;if(e==null||e===\"float32\")n=new Float32Array(t);else if(e===\"int32\")n=new Int32Array(t);else if(e===\"bool\")n=new Uint8Array(t);else throw new Error(`Unknown data type ${e}`);return n}function qw(e,t){let n=null;if(e==null||e===\"float32\")n=new Float32Array(t);else if(e===\"int32\")n=new Int32Array(t);else if(e===\"bool\")n=new Uint8Array(t);else if(e===\"string\")n=new Array(t);else throw new Error(`Unknown data type ${e}`);return n}function jw(e,t){for(let n=0;nt+=n.length),t}function ir(e){return typeof e==\"string\"||e instanceof String}function Yw(e){return typeof e==\"boolean\"}function Qw(e){return typeof e==\"number\"}function Gd(e){return Array.isArray(e)?Gd(e[0]):e instanceof Float32Array?\"float32\":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?\"int32\":Qw(e)?\"float32\":ir(e)?\"string\":Yw(e)?\"bool\":\"float32\"}function hr(e){return!!(e&&e.constructor&&e.call&&e.apply)}function hd(e,t){for(let n=t;n=0;--s)n[s]=n[s+1]*e[s+1];return n}function Zw(e,t,n,s=!1){let r=new Array;if(t.length===1){let a=t[0]*(s?2:1);for(let i=0;iu*l)*(s?2:1);for(let u=0;ur*a)*(n?2:1);if(s===0)return[];if(s!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?\" for a complex tensor\":\"\"}.`);return Zw(0,e,t,n)}function ng(e,t){let n=Hd(e,t);for(let s=0;ss*r,1);if(t==null||t===\"float32\")return Hi(e,new Float32Array(n));if(t===\"int32\")return Hi(e,new Int32Array(n));if(t===\"bool\")return Hi(e,new Uint8Array(n));throw new Error(`Unknown data type ${t}`)}function sg(e){e.forEach(t=>{O(Number.isInteger(t)&&t>=0,()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`)})}function k$(e,t,n){if(t===0)return 0;if(t===1)return e[0];let s=e[e.length-1];for(let r=0;r{let[s,r]=n.split(\":\");this.urlFlags[s]=T$(s,r)})}};function C$(e){let t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(n,...s)=>(N$(t,s[0],s[1]),s.join(\"=\"))),t}function N$(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||\"\")}function T$(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 Jw}var Jw=null;function $$(e){Jw=e}var Df;function ek(){if(Df==null){let e;if(typeof window!=\"undefined\")e=window;else if(typeof global!=\"undefined\")e=global;else if(typeof process!=\"undefined\")e=process;else if(typeof self!=\"undefined\")e=self;else throw new Error(\"Could not find a global object\");Df=e}return Df}function _$(){let e=ek();return e._tfGlobals==null&&(e._tfGlobals=new Map),e._tfGlobals}function ag(e,t){let n=_$();if(n.has(e))return n.get(e);{let s=t();return n.set(e,s),n.get(e)}}var ao=\"Abs\",nl=\"Acos\",sl=\"Acosh\",Ir=\"Add\",ka=\"AddN\",rl=\"All\",al=\"Any\",Ia=\"ArgMax\",il=\"ArgMin\",ol=\"Asin\",ul=\"Asinh\",ll=\"Atan\",cl=\"Atanh\",dl=\"Atan2\",Sa=\"AvgPool\",ig=\"AvgPoolGrad\",qd=\"AvgPool3D\",og=\"AvgPool3DGrad\",Ca=\"BatchMatMul\",io=\"BatchToSpaceND\",ug=\"Bincount\",A$=\"BroadcastTo\",lg=\"BroadcastArgs\",Na=\"Cast\",Ta=\"Ceil\",Sr=\"ClipByValue\",jd=\"Complex\",Kd=\"ComplexAbs\",oo=\"Concat\",$a=\"Conv2D\",cg=\"Conv2DBackpropFilter\",_a=\"Conv2DBackpropInput\",Xd=\"Conv3D\",dg=\"Conv3DBackpropFilterV2\",pg=\"Conv3DBackpropInputV2\",Aa=\"Cos\",Ea=\"Cosh\",pl=\"Cumprod\",uo=\"Cumsum\",lo=\"CropAndResize\",hg=\"DenseBincount\",co=\"DepthToSpace\",Ra=\"DepthwiseConv2dNative\",fg=\"DepthwiseConv2dNativeBackpropFilter\",mg=\"DepthwiseConv2dNativeBackpropInput\",gg=\"Diag\",Yd=\"Dilation2D\",Yf=\"Dilation2DBackpropInput\",Qf=\"Dilation2DBackpropFilter\",Da=\"RealDiv\",Qd=\"Einsum\",Fa=\"Elu\",bg=\"EluGrad\",hl=\"Erf\",po=\"Equal\",Oa=\"Exp\",ho=\"ExpandDims\",fo=\"Expm1\",yg=\"FFT\",fl=\"Fill\",mo=\"FlipLeftRight\",Pa=\"Floor\",za=\"FloorDiv\",Ma=\"FusedBatchNorm\",go=\"GatherV2\",bo=\"GatherNd\",yo=\"Greater\",La=\"GreaterEqual\",Ba=\"Identity\",vg=\"IFFT\",Zd=\"Imag\",ml=\"IsFinite\",gl=\"IsInf\",bl=\"IsNan\",Va=\"LeakyRelu\",vo=\"Less\",xo=\"LessEqual\",xg=\"LinSpace\",Wa=\"Log\",yl=\"Log1p\",wo=\"LogicalAnd\",vl=\"LogicalNot\",Jd=\"LogicalOr\",E$=\"LogSoftmax\",ep=\"LRN\",wg=\"LRNGrad\",Ua=\"Max\",Ga=\"Maximum\",Ha=\"MaxPool\",kg=\"MaxPoolGrad\",tp=\"MaxPool3D\",Ig=\"MaxPool3DGrad\",Sg=\"MaxPoolWithArgmax\",qa=\"Mean\",ja=\"Min\",Ka=\"Minimum\",Xa=\"MirrorPad\",xl=\"Mod\",Cg=\"Multinomial\",Ya=\"Multiply\",ko=\"Neg\",Io=\"NotEqual\",So=\"NonMaxSuppressionV3\",wl=\"NonMaxSuppressionV4\",Co=\"NonMaxSuppressionV5\",No=\"OnesLike\",To=\"OneHot\",$o=\"Pack\",Qa=\"PadV2\",Tde=\"Pool\",Za=\"Pow\",Ja=\"Prelu\",_o=\"Prod\",kl=\"Range\",np=\"Real\",Il=\"Reciprocal\",ei=\"Relu\",Ao=\"Reshape\",Sl=\"ResizeNearestNeighbor\",Ng=\"ResizeNearestNeighborGrad\",ti=\"ResizeBilinear\",Tg=\"ResizeBilinearGrad\",ni=\"Relu6\",Eo=\"Reverse\",Ro=\"Round\",si=\"Rsqrt\",Do=\"ScatterNd\",Fo=\"Select\",Cl=\"Selu\",Oo=\"Slice\",ri=\"Sin\",Po=\"Sinh\",Nl=\"Sign\",ai=\"Sigmoid\",Tl=\"Softplus\",ii=\"Sqrt\",oi=\"Sum\",zo=\"SpaceToBatchND\",Mo=\"SplitV\",ui=\"Softmax\",sp=\"SparseFillEmptyRows\",$l=\"SparseReshape\",rp=\"SparseSegmentMean\",ap=\"SparseSegmentSum\",ip=\"SparseToDense\",li=\"SquaredDifference\",_l=\"Square\",Lo=\"StridedSlice\",op=\"StringNGrams\",$g=\"StringSplit\",_g=\"StringToHashBucketFast\",ci=\"Sub\",Bo=\"Tan\",di=\"Tanh\",Cr=\"Tile\",Vo=\"TopK\",Wo=\"Transform\",pi=\"Transpose\",Ag=\"Unique\",Uo=\"Unpack\",up=\"UnsortedSegmentSum\",Go=\"ZerosLike\",hi=\"Step\",fd=\"FromPixels\",Ho=\"RotateWithOffset\",ra=\"_FusedMatMul\",aa=\"FusedConv2D\",ia=\"FusedDepthwiseConv2D\";function ar(...e){X().getBool(\"IS_TEST\")||X().getBool(\"PROD\")||console.warn(...e)}function R$(...e){X().getBool(\"IS_TEST\")||X().getBool(\"PROD\")||console.log(...e)}var Qi=ag(\"kernelRegistry\",()=>new Map),Vu=ag(\"gradRegistry\",()=>new Map);function Zf(e,t){let n=Eg(e,t);return Qi.get(n)}function nx(e){return Vu.get(e)}function Jf(e){let t=Qi.entries(),n=[];for(;;){let{done:s,value:r}=t.next();if(s)break;let[a,i]=r,[o]=a.split(\"_\");o===e&&n.push(i)}return n}function Al(e){let{kernelName:t,backendName:n}=e,s=Eg(t,n);Qi.has(s)&&ar(`The kernel '${t}' for backend '${n}' is already registered`),Qi.set(s,e)}function D$(e){let{kernelName:t}=e;Vu.has(t)&&X().getBool(\"DEBUG\")&&ar(`Overriding the gradient for '${t}'`),Vu.set(t,e)}function $de(e,t){let n=Eg(e,t);if(!Qi.has(n))throw new Error(`The kernel '${e}' for backend '${t}' is not registered`);Qi.delete(n)}function _de(e){if(!Vu.has(e))throw new Error(`The gradient '${e}' for backend is not registered`);Vu.delete(e)}function Ade(e,t){Jf(e).forEach(s=>{let r=Object.assign({},s,{backendName:t});Al(r)})}function Eg(e,t){return`${t}_${e}`}var w={};Ae(w,{arraysEqual:()=>kr,assert:()=>O,assertNonNegativeIntegerDimensions:()=>sg,assertNonNull:()=>wa,assertShapesMatch:()=>pn,bytesFromStringArray:()=>Xw,bytesPerElement:()=>Xf,checkConversionForErrors:()=>jw,clamp:()=>Bu,computeStrides:()=>ro,createScalarValue:()=>L$,createShuffledIndices:()=>b$,decodeString:()=>md,distSquared:()=>h$,encodeString:()=>Rl,fetch:()=>V$,fingerPrint64:()=>M$,flatten:()=>sa,getArrayFromDType:()=>qw,getTypedArrayFromDType:()=>Hw,hasEncodingLoss:()=>x$,hexToLong:()=>El,indexToLoc:()=>I$,inferDtype:()=>Gd,inferFromImplicitShape:()=>v$,isBoolean:()=>Yw,isFunction:()=>hr,isInt:()=>Yi,isNumber:()=>Qw,isPromise:()=>rg,isScalarShape:()=>f$,isString:()=>ir,isTypedArray:()=>Qt,isValidDtype:()=>Kw,locToIndex:()=>k$,makeOnesTypedArray:()=>ng,makeZerosNestedTypedArray:()=>w$,makeZerosTypedArray:()=>Hd,nearestDivisor:()=>hd,nearestLargerEven:()=>c$,now:()=>Wu,parseAxisParam:()=>ts,randUniform:()=>p$,repeatedTry:()=>y$,rightPad:()=>Pu,shuffle:()=>Uw,shuffleCombo:()=>l$,sizeFromShape:()=>pt,sizeToSquarishShape:()=>g$,squeezeShape:()=>Gw,sum:()=>d$,swap:()=>pd,tanh:()=>m$,toNestedArray:()=>Hi,toTypedArray:()=>lp});var sx=xa(HT()),qr=sx.default||sx;function El(e){return qr.fromString(e,!0,16)}var tk=El(\"c3a5c85c97cb3127\"),Gr=El(\"b492b66fbe98f273\"),on=El(\"9ae16a3b2f90404f\");function em(e){return e.xor(e.shru(47))}function nk(e,t,n){let s=e.slice(t,t+n);return qr.fromBytes(Array.from(s),!0,!0)}function lt(e,t){return nk(e,t,8)}function rx(e,t){return nk(e,t,4)}function Lt(e,t){return t===0?e:e.shru(t).or(e.shl(64-t))}function ur(e,t,n=El(\"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 F$(e,t,n,s,r,a){r=r.add(e),a=Lt(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)]}function Vc(e,t,n,s){return F$(lt(e,t),lt(e,t+8),lt(e,t+16),lt(e,t+24),n,s)}function O$(e,t=e.length){if(t>=8){let n=on.add(t*2),s=lt(e,0).add(on),r=lt(e,t-8),a=Lt(r,37).mul(n).add(s),i=Lt(s,25).add(r).mul(n);return ur(a,i,n)}if(t>=4){let n=on.add(t*2),s=rx(e,0);return ur(s.shl(3).add(t),rx(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 em(on.mul(a).xor(tk.mul(i))).mul(on)}return on}function P$(e,t=e.length){let n=on.add(t*2),s=lt(e,0).mul(Gr),r=lt(e,8),a=lt(e,t-8).mul(n),i=lt(e,t-16).mul(on);return ur(Lt(s.add(r),43).add(Lt(a,30)).add(i),s.add(Lt(r.add(on),18)).add(a),n)}function z$(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=Lt(s.add(r),43).add(Lt(a,30)).add(i),u=ur(o,s.add(Lt(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 ur(Lt(l.add(c),43).add(Lt(p,30)).add(d),l.add(Lt(c.add(s),18)).add(p),n)}function M$(e,t=e.length){let n=qr.fromNumber(81,!0);if(t<=32)return t<=16?O$(e,t):P$(e,t);if(t<=64)return z$(e,t);let s=n,r=n.mul(Gr).add(113),a=em(r.mul(on).add(113)).mul(on),i=[qr.UZERO,qr.UZERO],o=[qr.UZERO,qr.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(Gr),r=Lt(r.add(i[1]).add(lt(e,u+48)),42).mul(Gr),s=s.xor(o[1]),r=r.add(i[0]).add(lt(e,u+40)),a=Lt(a.add(o[0]),33).mul(Gr),i=Vc(e,u,i[1].mul(Gr),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;while(u!==l);let p=Gr.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],ur(ur(i[0],o[0],p).add(em(r).mul(tk)).add(a),ur(i[1],o[1],p).add(s),p)}function L$(e,t){return t===\"string\"?Rl(e):lp([e],t)}function B$(e,t){return e instanceof Float32Array&&t===\"float32\"||e instanceof Int32Array&&t===\"int32\"||e instanceof Uint8Array&&t===\"bool\"}function lp(e,t){if(t===\"string\")throw new Error(\"Cannot convert a string[] to a TypedArray\");if(Array.isArray(e)&&(e=sa(e)),X().getBool(\"DEBUG\")&&jw(e,t),B$(e,t))return e;if(t==null||t===\"float32\"||t===\"complex64\")return new Float32Array(e);if(t===\"int32\")return new Int32Array(e);if(t===\"bool\"){let n=new Uint8Array(e.length);for(let s=0;s{s=n()},a,i=Wu();if(this.backendTimer.timerAvailable())a=this.backendTimer.time(r);else{r();for(let u of s)u.dataSync();a=Promise.resolve({kernelMs:Wu()-i})}if(X().getBool(\"CHECK_COMPUTATION_FOR_ERRORS\"))for(let u=0;u{U$(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():\"\")}}logKernelProfile(e){let{kernelName:t,outputs:n,timeMs:s,inputs:r,extraInfo:a}=e;n.forEach(i=>{Promise.all([i.data(),s,a]).then(o=>{this.logger.logKernelProfile(t,i,o[0],o[1],r,o[2])})})}};function U$(e,t,n){if(t!==\"float32\")return!1;for(let s=0;s0?f:\"\"} `}}console.log(`%c${o}\t%c${i}\t%c${u}D ${c}\t%c${l}\t%c${p}\t%c${a}`,\"font-weight:bold\",\"color:red\",\"color:blue\",\"color: orange\",\"color: green\",\"color: steelblue\")}};function H$(e,t,n){let s={},r={};for(let u=0;us[m.id]=!0),h=!0,r[l.id]=!0;break}if(h)break}}let a={};a[n.id]=!0;let i={};for(let u=e.length-1;u>=0;u--){let l=e[u],c=l.inputs;for(let p=0;p=0;r--){let a=t[r],i=[];if(a.outputs.forEach(u=>{let l=e[u.id];l!=null?i.push(l):i.push(null)}),a.gradient==null)throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`);let o=a.gradient(i);for(let u in a.inputs){if(!(u in o))throw new Error(`Cannot backprop through input ${u}. Available gradients found: ${Object.keys(o)}.`);let l=n(()=>o[u]());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(!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;else{let p=e[c.id];e[c.id]=s(p,l),p.dispose()}}}}var ax=20,Iu=3,Ff=7;function j$(e,t,n,s){let r=ro(t),a=K$(e,t,n,r),i=t.length,o=ed(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(`\n`)),u.join(`\n`)}function K$(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\"?$u(e):e;if(o>1)for(let l=0;lax){let g=Iu*i,b=Array.from(e.slice(0,g)),y=Array.from(e.slice((o-Iu)*i,o*i));return n===\"complex64\"&&(b=$u(b),y=$u(y)),[\"[\"+b.map((v,x)=>Tu(v,r[x],n)).join(\", \")+\", ..., \"+y.map((v,x)=>Tu(v,r[o-Iu+x],n)).join(\", \")+\"]\"]}let m=n===\"complex64\"?$u(e):Array.from(e);return[\"[\"+m.map((g,b)=>Tu(g,r[b],n)).join(\", \")+\"]\"]}let l=t.slice(1),c=s.slice(1),p=s[0]*i,d=[];if(o>ax){for(let m=0;m`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=ro(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})`);let n=this.locToIndex(t);this.values[n]=e}get(...e){e.length===0&&(e=[0]);let t=0;for(let s of e){if(s<0||s>=this.shape[t]){let r=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(r)}t++}let n=e[e.length-1];for(let s=0;smd(n))}catch(n){throw new Error(\"Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().\")}}return e}dataToGPU(e){return this.throwIfDisposed(),cs().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();let e=cs().readSync(this.dataId);if(this.dtype===\"string\")try{return e.map(t=>md(t))}catch(t){throw new Error(\"Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().\")}return e}async bytes(){this.throwIfDisposed();let e=await cs().read(this.dataId);return this.dtype===\"string\"?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(cs().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error(\"Tensor is disposed.\")}print(e=!1){return Wi.print(this,e)}clone(){return this.throwIfDisposed(),Wi.clone(this)}toString(e=!1){let t=this.dataSync();return j$(t,this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Wi.cast(this,e)}variable(e=!0,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 J$(){return ag(\"Tensor\",()=>et)}J$();var gd=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(!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)}dispose(){cs().disposeVariable(this),this.isDisposedInternal=!0}};Object.defineProperty(gd,Symbol.hasInstance,{value:e=>e instanceof et&&e.assign!=null&&e.assign instanceof Function});var _s={};Ae(_s,{assertTypesMatch:()=>uk,getTensorsInContainer:()=>Rg,isTensorInList:()=>n_,makeTypesMatch:()=>vt});var e_=(e=>(e.R0=\"R0\",e.R1=\"R1\",e.R2=\"R2\",e.R3=\"R3\",e.R4=\"R4\",e.R5=\"R5\",e.R6=\"R6\",e))(e_||{}),rk=(e=>(e.float32=\"float32\",e.int32=\"int32\",e.bool=\"int32\",e.complex64=\"complex64\",e))(rk||{}),ak=(e=>(e.float32=\"float32\",e.int32=\"int32\",e.bool=\"bool\",e.complex64=\"complex64\",e))(ak||{}),ik=(e=>(e.float32=\"float32\",e.int32=\"float32\",e.bool=\"float32\",e.complex64=\"complex64\",e))(ik||{}),ok=(e=>(e.float32=\"complex64\",e.int32=\"complex64\",e.bool=\"complex64\",e.complex64=\"complex64\",e))(ok||{}),t_={float32:ik,int32:rk,bool:ak,complex64:ok};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 t_[e][t]}function cp(e){return cn(e,\"int32\")}function vt(e,t){if(e.dtype===t.dtype)return[e,t];let n=cn(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function uk(e,t){O(e.dtype===t.dtype,()=>`The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)}function n_(e,t){return t.some(n=>n.id===e.id)}function Rg(e){let t=[];return lk(e,t,new Set),t}function lk(e,t,n){if(e==null)return;if(e instanceof et){t.push(e);return}if(!s_(e))return;let s=e;for(let r in s){let a=s[r];n.has(a)||(n.add(a),lk(a,t,n))}}function s_(e){return Array.isArray(e)||typeof e==\"object\"}function Of(e){return e.kernelName!=null}var ix=class{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map(e=>e.name)))}}}dispose(){for(let e in this.registeredVariables)this.registeredVariables[e].dispose()}},tm=class{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new ix}async ready(){if(this.pendingBackendInit!=null)return this.pendingBackendInit.then(()=>{});if(this.backendInstance!=null)return;let e=this.getSortedBackends();for(let t=0;t{t.setupFunc!=null&&t.setupFunc(this.backendInstance)})}disposeRegisteredKernels(e){Jf(e).forEach(n=>{n.disposeFunc!=null&&n.disposeFunc(this.registry[e])})}initializeBackend(e){let t=this.registryFactory[e];if(t==null)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{let n=t.factory();if(n&&!(n instanceof tl)&&typeof n.then==\"function\"){let s=++this.pendingBackendInitId,r=n.then(a=>s(sthis.registryFactory[t].priority-this.registryFactory[e].priority)}initializeBackendsAndReturnBest(){let e=this.getSortedBackends();for(let t=0;tthis.startScope(n),()=>this.endScope(s),()=>(s=t(),s instanceof Promise&&console.error(\"Cannot return a Promise inside of tidy.\"),s))}scopedRun(e,t,n){e();try{let s=n();return t(),s}catch(s){throw t(),s}}nextTensorId(){return tm.nextTensorId++}nextVariableId(){return tm.nextVariableId++}clone(e){let t=M.runKernel(Ba,{x:e}),n={x:e},s=a=>({x:()=>{let i=\"float32\",o={x:a},u={dtype:i};return M.runKernel(Na,o,u)}}),r=[];return this.addTapeNode(this.state.activeScope.name,n,[t],s,r,{}),t}runKernel(e,t,n){if(this.backendName==null&&this.backend,!(Zf(e,this.backendName)!=null))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool(\"IS_TEST\")}checkKernelForMemLeak(e,t,n){let s=this.backend.numDataIds(),r=0;n.forEach(o=>{r+=o.dtype===\"complex64\"?3:1});let a=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],i=s-t-r-a;if(i>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${i} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[],s=this.isTapeOn(),r=this.state.numBytes,a=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);let i;this.backendName==null&&this.backend;let o,u=Of(e)?e.kernelName:this.state.activeScope!=null?this.state.activeScope.name:\"\";if(Of(e)){let{kernelName:h,inputs:f,attrs:m}=e;this.backendName==null&&this.backend;let g=Zf(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:T,dtype:N}=x;return this.makeTensorFromDataId(k,T,N)});if(s){let x=this.getTensorsForGradient(h,f,v);n=this.saveTensorsForBackwardMode(x)}return v}}else{let{forwardFunc:h}=e,f=m=>{!s||(n=m.map(g=>this.keep(this.clone(g))))};i=()=>{let m=this.backend.numDataIds();o=this.tidy(()=>h(this.backend,f));let g=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,m,g),g}}let{inputs:l,attrs:c}=e,p=Of(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]}saveTensorsForBackwardMode(e){return e.map(n=>this.keep(this.clone(n)))}getTensorsForGradient(e,t,n){let s=nx(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]);let o=n.filter((u,l)=>a[l]);return i.concat(o)}return[]}makeTensor(e,t,n,s){if(e==null)throw new Error(\"Values passed to engine.makeTensor() are null\");n=n||\"float32\",s=s||this.backend;let r=e;n===\"string\"&&ir(e[0])&&(r=e.map(o=>Rl(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=Xw(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}makeVariable(e,t=!0,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());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}trackTensor(e,t){this.state.numTensors++,e.dtype===\"string\"&&this.state.numStringTensors++;let n=0;e.dtype!==\"complex64\"&&e.dtype!==\"string\"&&(n=e.size*Xf(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)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))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*Xf(e.dtype);this.state.numBytes-=n}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(let e in this.state.registeredVariables){let t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),this.state.registeredVariables[e.name]!=null&&delete this.state.registeredVariables[e.name]}memory(){let e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,e.reasons==null&&(e.reasons=[]),e.reasons.push(\"Memory usage by string tensors is approximate (2 bytes per character)\")),e}async profile(e){this.state.profiling=!0;let t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map(s=>s.totalBytesSnapshot)),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(let s of this.state.activeProfile.kernels)s.kernelTimeMs=await s.kernelTimeMs,s.extraInfo=await s.extraInfo;return this.state.activeProfile}isTapeOn(){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=nx(e);o!=null&&(s=o.gradFunc),s!=null&&(i.gradient=u=>(u=u.map((l,c)=>{if(l==null){let p=n[c],d=Hd(p.size,p.dtype);return this.makeTensor(d,p.shape,p.dtype)}return l}),s(u.length>1?u:u[0],r,a))),this.state.activeTape.push(i)}keep(e){return e.kept=!0,e}startTape(){this.state.gradientDepth===0&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){let t={track:[],name:\"unnamed scope\",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){let t=Rg(e),n=new Set(t.map(r=>r.id));for(let r=0;r{!r.kept&&r.scopeId===s.id&&this.track(r)})}gradients(e,t,n,s=!1){if(O(t.length>0,()=>\"gradients() received an empty list of xs.\"),n!=null&&n.dtype!==\"float32\")throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);let 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=H$(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?r_(r.shape):n,q$(i,a,u=>this.tidy(u),a_);let o=t.map(u=>i[u.id]);return this.state.gradientDepth===0&&(this.state.activeTape.forEach(u=>{for(let l of u.saved)l.dispose()}),this.state.activeTape=null),{value:r,grads:o}})}customGrad(e){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(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={};return l.forEach((p,d)=>{c[d]=()=>p}),c};return this.runKernelFunc({forwardFunc:r,backwardsFunc:a,inputs:s})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){let t=Wu(),n=await this.backend.time(e);return n.wallMs=Wu()-t,n}track(e){return this.state.activeScope!=null&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new ix;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}},Dg=tm;Dg.nextTensorId=0;Dg.nextVariableId=0;function r_(e){let t=ng(pt(e),\"float32\");return M.makeTensor(t,e,\"float32\")}function ck(){let e=ek();if(e._tfengine==null){let t=new S$(e);e._tfengine=new Dg(t)}return $$(e._tfengine.ENV),Y$(()=>e._tfengine),e._tfengine}var M=ck();function a_(e,t){let n={a:e,b:t};return M.runKernel(Ir,n)}var dp={};Ae(dp,{isBrowser:()=>dk,isMobile:()=>u_,mockIsMobile:()=>o_});function i_(){return typeof navigator!=\"undefined\"&&navigator!=null}var nm;function o_(e){nm=e}function u_(e){if(nm!==void 0)return nm;if(e||i_()){if(e||(e=navigator),e.product===\"ReactNative\")return!0;let t=e.userAgent||e.vendor||(typeof window!=\"undefined\"?window.opera:\"\");if(!t){let n=e;return n.userAgentData&&n.userAgentData.mobile}return/(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(t.substr(0,4))}return!1}function dk(){return typeof window!=\"undefined\"&&window.document!=null||typeof WorkerGlobalScope!=\"undefined\"}var jn=X();jn.registerFlag(\"DEBUG\",()=>!1,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.\")});jn.registerFlag(\"IS_BROWSER\",()=>dk());jn.registerFlag(\"IS_NODE\",()=>typeof process!=\"undefined\"&&typeof process.versions!=\"undefined\"&&typeof process.versions.node!=\"undefined\");jn.registerFlag(\"IS_CHROME\",()=>typeof navigator!=\"undefined\"&&navigator!=null&&navigator.userAgent!=null&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor));jn.registerFlag(\"PROD\",()=>!1);jn.registerFlag(\"TENSORLIKE_CHECK_SHAPE_CONSISTENCY\",()=>jn.getBool(\"DEBUG\"));jn.registerFlag(\"DEPRECATION_WARNINGS_ENABLED\",()=>!0);jn.registerFlag(\"IS_TEST\",()=>!1);jn.registerFlag(\"CHECK_COMPUTATION_FOR_ERRORS\",()=>!0);jn.registerFlag(\"WRAP_TO_IMAGEBITMAP\",()=>!1);jn.registerFlag(\"ENGINE_COMPILE_ONLY\",()=>!1);function Rs(e,t){let n=e;if(Qt(e))return t===\"string\"?[]:[e.length];if(!Array.isArray(e))return[];let s=[];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\")&&pk(e,s,[]),s}function pk(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=0&&(r=s),ox(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);!Qt(e)&&!Array.isArray(e)&&(e=[e]);let o=r!==\"string\"?lp(e,r):sa(e,[],!0);return M.makeTensor(o,a,r)}function Uu(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 l_=\"__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+l_;let r=(...a)=>{M.startScope(n);try{let i=s(...a);return rg(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:!0}),r}function c_(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(jd,r)}var oa=L({complex_:c_});function Nr(e,t,n,s){if(s==null&&(s=Gd(e)),s===\"complex64\")throw new Error(\"Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).\");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){sg(t);let r=pt(t),a=pt(n);O(r===a,()=>`Based on the provided shape, [${t}], the tensor should have ${r} values but has ${a}`);for(let i=0;i`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)}}return!Qt(e)&&!Array.isArray(e)&&(e=[e]),t=t||n,e=s!==\"string\"?lp(e,s):sa(e,[],!0),M.makeTensor(e,t,s)}function fs(e,t,n){let s=Rs(e,n);return Nr(e,t,s,n)}var sm={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},bd=4;async function d_(e,t){let n=[],s=[],r=Array.isArray(e)?e.map(i=>i.name):Object.keys(e);for(let i=0;i{let d=await u.bytes(),h=d.reduce((g,b)=>g+b.length,0)+bd*d.length,f=new Uint8Array(h),m=0;for(let g=0;g{if(t+=a.byteLength,n.push(a.byteLength===a.buffer.byteLength?a:new a.constructor(a)),!(a instanceof Float32Array||a instanceof Int32Array||a instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${a.constructor.name}`)});let s=new Uint8Array(t),r=0;return n.forEach(a=>{s.set(new Uint8Array(a.buffer),r),r+=a.byteLength}),s.buffer}var Fg=typeof Buffer!=\"undefined\"&&(typeof Blob==\"undefined\"||typeof atob==\"undefined\"||typeof btoa==\"undefined\");function ux(e){return Fg?Buffer.byteLength(e):new Blob([e]).size}function h_(e){if(Fg)return Buffer.from(e).toString(\"base64\");let t=new Uint8Array(e),n=\"\";for(let s=0,r=t.length;s{t+=r.byteLength});let n=new Uint8Array(t),s=0;return e.forEach(r=>{n.set(new Uint8Array(r),s),s+=r.byteLength}),n.buffer}function lx(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 fk(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 Pg(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);n.weightSpecs=s,n.weightData=r}return e.signature!=null&&(n.signature=e.signature),e.userDefinedMetadata!=null&&(n.userDefinedMetadata=e.userDefinedMetadata),e.modelInitializer!=null&&(n.modelInitializer=e.modelInitializer),n}function Dl(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:ux(JSON.stringify(e.modelTopology)),weightSpecsBytes:e.weightSpecs==null?0:ux(JSON.stringify(e.weightSpecs)),weightDataBytes:e.weightData==null?0:e.weightData.byteLength}}function m_(){let e=n=>{let s=n<<13,r=0;for(;(s&8388608)===0;)r-=8388608,s<<=1;return s&=-8388609,r+=947912704,s|r},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let n=1024;n<2048;n++)t[n]=939524096+(n-1024<<13);return t}function g_(){let e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}function b_(){let e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}function y_(){let e=m_(),t=g_(),n=b_();return s=>{let r=new ArrayBuffer(4*s.length),a=new Uint32Array(r);for(let i=0;i>10]+(o&1023)]+t[o>>10];a[i]=u}return new Float32Array(r)}}var xt=class{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return xt.instance==null&&(xt.instance=new xt),xt.instance}static registerSaveRouter(e){xt.getInstance().saveRouters.push(e)}static registerLoadRouter(e){xt.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return xt.getHandlers(e,\"save\")}static getLoadHandlers(e,t){return xt.getHandlers(e,\"load\",t)}static getHandlers(e,t,n){let s=[];return(t===\"load\"?xt.getInstance().loadRouters:xt.getInstance().saveRouters).forEach(a=>{let i=a(e,n);i!==null&&s.push(i)}),s}},v_=e=>xt.registerSaveRouter(e),x_=e=>xt.registerLoadRouter(e),w_=e=>xt.getSaveHandlers(e),k_=(e,t)=>xt.getLoadHandlers(e,t),rm=\"tensorflowjs\",am=1,Yr=\"models_store\",or=\"model_info_store\";function mk(){if(!X().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 im(e){let t=e.result;t.createObjectStore(Yr,{keyPath:\"modelPath\"}),t.createObjectStore(or,{keyPath:\"modelPath\"})}var ua=class{constructor(e){if(this.indexedDB=mk(),e==null||!e)throw new Error(\"For IndexedDB, modelPath must not be null, undefined or empty.\");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error(\"BrowserLocalStorage.save() does not support saving model topology in binary formats yet.\");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise((n,s)=>{let r=this.indexedDB.open(rm,am);r.onupgradeneeded=()=>im(r),r.onsuccess=()=>{let a=r.result;if(t==null){let i=a.transaction(Yr,\"readonly\"),u=i.objectStore(Yr).get(this.modelPath);u.onsuccess=()=>{if(u.result==null)return a.close(),s(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));n(u.result.modelArtifacts)},u.onerror=l=>(a.close(),s(u.error)),i.oncomplete=()=>a.close()}else{let i=Dl(t),o=a.transaction(or,\"readwrite\"),u=o.objectStore(or),l=u.put({modelPath:this.modelPath,modelArtifactsInfo:i}),c;l.onsuccess=()=>{c=a.transaction(Yr,\"readwrite\");let d=c.objectStore(Yr).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:i});d.onsuccess=()=>n({modelArtifactsInfo:i}),d.onerror=h=>{u=o.objectStore(or);let f=u.delete(this.modelPath);f.onsuccess=()=>(a.close(),s(d.error)),f.onerror=m=>(a.close(),s(d.error))}},l.onerror=p=>(a.close(),s(l.error)),o.oncomplete=()=>{c==null?a.close():c.oncomplete=()=>a.close()}}},r.onerror=a=>s(r.error)})}};ua.URL_SCHEME=\"indexeddb://\";var gk=e=>X().getBool(\"IS_BROWSER\")&&!Array.isArray(e)&&e.startsWith(ua.URL_SCHEME)?I_(e.slice(ua.URL_SCHEME.length)):null;xt.registerSaveRouter(gk);xt.registerLoadRouter(gk);function I_(e){return new ua(e)}function S_(e){return e.startsWith(ua.URL_SCHEME)?e.slice(ua.URL_SCHEME.length):e}var C_=class{constructor(){this.indexedDB=mk()}async listModels(){return new Promise((e,t)=>{let n=this.indexedDB.open(rm,am);n.onupgradeneeded=()=>im(n),n.onsuccess=()=>{let s=n.result,r=s.transaction(or,\"readonly\"),i=r.objectStore(or).getAll();i.onsuccess=()=>{let o={};for(let u of i.result)o[u.modelPath]=u.modelArtifactsInfo;e(o)},i.onerror=o=>(s.close(),t(i.error)),r.oncomplete=()=>s.close()},n.onerror=s=>t(n.error)})}async removeModel(e){return e=S_(e),new Promise((t,n)=>{let s=this.indexedDB.open(rm,am);s.onupgradeneeded=()=>im(s),s.onsuccess=()=>{let r=s.result,a=r.transaction(or,\"readwrite\"),i=a.objectStore(or),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.`));{let l=i.delete(e),c=()=>{u=r.transaction(Yr,\"readwrite\");let d=u.objectStore(Yr).delete(e);d.onsuccess=()=>t(o.result.modelArtifactsInfo),d.onerror=h=>n(o.error)};l.onsuccess=c,l.onerror=p=>(c(),r.close(),n(o.error))}},o.onerror=l=>(r.close(),n(o.error)),a.oncomplete=()=>{u==null?r.close():u.oncomplete=()=>r.close()}},s.onerror=r=>n(s.error)})}},Gs=\"/\",Ui=\"tensorflowjs_models\",bk=\"info\",N_=\"model_topology\",T_=\"weight_specs\",$_=\"weight_data\",__=\"model_metadata\";function yk(e){return{info:[Ui,e,bk].join(Gs),topology:[Ui,e,N_].join(Gs),weightSpecs:[Ui,e,T_].join(Gs),weightData:[Ui,e,$_].join(Gs),modelMetadata:[Ui,e,__].join(Gs)}}function vk(e){for(let t of Object.values(e))window.localStorage.removeItem(t)}function A_(e){let t=e.split(Gs);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(Gs)}function E_(e){return e.startsWith(la.URL_SCHEME)?e.slice(la.URL_SCHEME.length):e}var la=class{constructor(e){if(!X().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=yk(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=Dl(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,h_(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 vk(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}.`)}}}async load(){let e=JSON.parse(this.LS.getItem(this.keys.info));if(e==null)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if(e.modelTopologyType!==\"JSON\")throw new Error(\"BrowserLocalStorage does not support loading non-JSON model topology yet.\");let t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(n==null)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;let s=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(s==null)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=s;let r=this.LS.getItem(this.keys.modelMetadata);if(r!=null){let i=JSON.parse(r);t.format=i.format,t.generatedBy=i.generatedBy,t.convertedBy=i.convertedBy,i.signature!=null&&(t.signature=i.signature),i.userDefinedMetadata!=null&&(t.userDefinedMetadata=i.userDefinedMetadata),i.modelInitializer!=null&&(t.modelInitializer=i.modelInitializer),i.trainingConfig!=null&&(t.trainingConfig=i.trainingConfig)}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=f_(a),t}};la.URL_SCHEME=\"localstorage://\";var xk=e=>X().getBool(\"IS_BROWSER\")&&!Array.isArray(e)&&e.startsWith(la.URL_SCHEME)?R_(e.slice(la.URL_SCHEME.length)):null;xt.registerSaveRouter(xk);xt.registerLoadRouter(xk);function R_(e){return new la(e)}var D_=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}async listModels(){let e={},t=Ui+Gs,n=Gs+bk;for(let s=0;s\"scheme must not be undefined or null.\"),e.endsWith(qi)&&(e=e.slice(0,e.indexOf(qi))),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}static getManager(e){let t=this.getInstance().managers[e];if(t==null)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(this.getInstance().managers)}};function td(e){if(e.indexOf(qi)===-1)throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${zn.getSchemes().join(\",\")}`);return{scheme:e.split(qi)[0],path:e.split(qi)[1]}}async function wk(e,t,n=!1){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();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 F_(){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+qi+r;t[a]=s[r]}}return t}async function O_(e){let t=td(e);return zn.getManager(t.scheme).removeModel(t.path)}async function P_(e,t){return wk(e,t,!1)}async function z_(e,t){return wk(e,t,!0)}var M_=class{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if(t!==\"utf-8\"&&t!==\"utf8\")throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return this.textEncoder==null&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}};if(X().get(\"IS_BROWSER\")){X().setPlatform(\"browser\",new M_);try{zn.registerManager(la.URL_SCHEME,new D_)}catch(e){}try{zn.registerManager(ua.URL_SCHEME,new C_)}catch(e){}}var L_={importFetch:()=>qT()},Pf,B_=class{constructor(){this.util=jT(),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return X().global.fetch!=null?X().global.fetch(e,t):(Pf==null&&(Pf=L_.importFetch()),Pf(e,t))}now(){let e=process.hrtime();return e[0]*1e3+e[1]/1e6}encode(e,t){if(t!==\"utf-8\"&&t!==\"utf8\")throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return e.length===0?\"\":new this.util.TextDecoder(t).decode(e)}};X().get(\"IS_NODE\")&&!X().get(\"IS_BROWSER\")&&X().setPlatform(\"node\",new B_);function De(e,t=\"float32\",n){return t=t||\"float32\",sg(e),new Vt(e,t,n)}function V_(e,t){let n=_(e,\"x\",\"cast\");if(!Kw(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(Na,s,r)}var ce=L({cast_:V_});function W_(e){let n={x:_(e,\"x\",\"clone\",\"string_or_numeric\")};return M.runKernel(Ba,n)}var lr=L({clone_:W_});function U_(e,t=!1){console.log(e.toString(t))}ck();var G_={buffer:De,cast:ce,clone:lr,print:U_};Q$(G_);var En={};Ae(En,{browserFiles:()=>Q_,browserHTTPRequest:()=>nA,concatenateArrayBuffers:()=>Og,copyModel:()=>P_,decodeWeights:()=>hk,encodeWeights:()=>d_,fromMemory:()=>rA,getLoadHandlers:()=>k_,getModelArtifactsForJSON:()=>Pg,getModelArtifactsInfoForJSON:()=>Dl,getSaveHandlers:()=>w_,http:()=>Mg,isHTTPScheme:()=>um,listModels:()=>F_,loadWeights:()=>Z_,moveModel:()=>z_,registerLoadRouter:()=>x_,registerSaveRouter:()=>v_,removeModel:()=>O_,weightsLoaderFactory:()=>Ik,withSaveHandler:()=>aA});var H_=\"model\",q_=\".json\",j_=\".weights.bin\";function cx(e){return new Promise(t=>setTimeout(t)).then(e)}var om=class{constructor(e){if(!X().getBool(\"IS_BROWSER\"))throw new Error(\"browserDownloads() cannot proceed because the current environment is not a browser.\");e.startsWith(om.URL_SCHEME)&&(e=e.slice(om.URL_SCHEME.length)),(e==null||e.length===0)&&(e=H_),this.modelJsonFileName=e+q_,this.weightDataFileName=e+j_}async save(e){if(typeof document==\"undefined\")throw new Error(\"Browser downloads are not supported in this environment since `document` is not present\");let t=window.URL.createObjectURL(new Blob([e.weightData],{type:\"application/octet-stream\"}));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=fk(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 cx(()=>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 cx(()=>i.dispatchEvent(new MouseEvent(\"click\")))}return{modelArtifactsInfo:Dl(e)}}}},yd=om;yd.URL_SCHEME=\"downloads://\";var K_=class{constructor(e){if(e==null||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise((e,t)=>{let n=new FileReader;n.onload=s=>{let r=JSON.parse(s.target.result),a=r.modelTopology;if(a==null){t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));return}if(r.weightsManifest==null){t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));return}if(this.weightsFiles.length===0){e({modelTopology:a});return}let o=Pg(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)})}loadWeights(e){let t=[],n=[];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,Og(a)])}loadWeightsFile(e,t){return new Promise((n,s)=>{let r=new FileReader;r.onload=a=>{let i=a.target.result;n(i)},r.onerror=a=>s(`Failed to weights data from file of path '${e}'.`),r.readAsArrayBuffer(t)})}checkManifestAndWeightFiles(e){let t=[],n=this.weightsFiles.map(r=>lx(r.name)),s={};for(let r of e)r.paths.forEach(a=>{let i=lx(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)throw new Error(`Weight file with basename '${i}' is not provided.`);s[a]=this.weightsFiles[n.indexOf(i)]});if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return s}},X_=e=>X().getBool(\"IS_BROWSER\")&&!Array.isArray(e)&&e.startsWith(yd.URL_SCHEME)?Y_(e.slice(yd.URL_SCHEME.length)):null;xt.registerSaveRouter(X_);function Y_(e=\"model\"){return new yd(e)}function Q_(e){return new K_(e)}function dx(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);return t(c),l}),u);function i(u){O(u!=null&&Array.isArray(u)&&u.length>0,()=>\"promises must be a none empty array\")}function o(u,l){O(u>=0&&u<=1,()=>`Progress fraction must be in range [0, 1], but got startFraction ${u}`),O(l>=0&&l<=1,()=>`Progress fraction must be in range [0, 1], but got endFraction ${l}`),O(l>=u,()=>`startFraction must be no more than endFraction, but got startFraction ${u} and endFraction ${l}`)}return Promise.all(e.map(a))}async function kk(e,t){t==null&&(t={});let n=t.fetchFunc==null?X().platform.fetch:t.fetchFunc,s=e.map(p=>n(p,t.requestInit,{isBinary:!0})),r=0,a=.5,o=(t.onProgress==null?await Promise.all(s):await dx(s,t.onProgress,r,a)).map(p=>p.arrayBuffer()),u=.5,l=1;return t.onProgress==null?await Promise.all(o):await dx(o,t.onProgress,u,l)}async function Z_(e,t=\"\",n,s){return Ik(i=>kk(i,{requestInit:s}))(e,t,n)}function Ik(e){return async(t,n=\"\",s)=>{let r=t.map(()=>!1),a={},i=s!=null?s.map(()=>!1):[],o=[];if(t.forEach((h,f)=>{let m=0;h.weights.forEach(g=>{let b=\"quantization\"in g?g.quantization.dtype:g.dtype,y=sm[b]*pt(g.shape),v=()=>{r[f]=!0,a[f]==null&&(a[f]=[]),a[f].push({manifestEntry:g,groupOffset:m,sizeBytes:y})};s!=null?s.forEach((x,k)=>{x===g.name&&(v(),i[k]=!0)}):v(),o.push(g.name),m+=y})}),!i.every(h=>h)){let h=s.filter((f,m)=>!i[m]);throw new Error(`Could not find weights in manifest with names: ${h.join(\", \")}. \nManifest JSON has weights with names: ${o.join(\", \")}.`)}let u=r.reduce((h,f,m)=>(f&&h.push(m),h),[]),l=[];u.forEach(h=>{t[h].paths.forEach(f=>{let m=n+(n.endsWith(\"/\")?\"\":\"/\")+f;l.push(m)})});let c=await e(l),p={},d=0;return u.forEach(h=>{let f=t[h].paths.length,m=0;for(let x=0;x{let k=g.slice(x.groupOffset,x.groupOffset+x.sizeBytes),T=hk(k,[x.manifestEntry]);for(let N in T)p[N]=T[N]}),d+=f}),p}}var J_=\"application/octet-stream\",eA=\"application/json\",zg=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)throw new Error(\"requestInit is expected to have no pre-existing body, but has one.\");this.requestInit=t.requestInit||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)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=fk(e,n);t.body.append(\"model.json\",new Blob([JSON.stringify(s)],{type:eA}),\"model.json\"),e.weightData!=null&&t.body.append(\"model.weights.bin\",new Blob([e.weightData],{type:J_}),\"model.weights.bin\");let r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Dl(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){let e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(r){let a=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(\".pb\")?a+=\" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.\":a+=\" Please make sure the server is serving valid JSON for this request.\",new Error(a)}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 Pg(t,r=>this.loadWeights(r))}async loadWeights(e){let t=Array.isArray(this.path)?this.path[1]:this.path,[n,s]=tA(t),r=this.weightPathPrefix||n,a=[];for(let l of e)a.push(...l.weights);let i=[],o=[];for(let l of e)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 kk(i,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});return[a,Og(u)]}};zg.URL_SCHEME_REGEX=/^https?:\\/\\//;function tA(e){let t=e.lastIndexOf(\"/\"),n=e.lastIndexOf(\"?\"),s=e.substring(0,t),r=n>t?e.substring(n):\"\";return[s+\"/\",r]}function um(e){return e.match(zg.URL_SCHEME_REGEX)!=null}var Sk=(e,t)=>{if(typeof fetch==\"undefined\"&&(t==null||t.fetchFunc==null))return null;{let n=!0;if(Array.isArray(e)?n=e.every(s=>um(s)):n=um(e),n)return Mg(e,t)}return null};xt.registerSaveRouter(Sk);xt.registerLoadRouter(Sk);function Mg(e,t){return new zg(e,t)}function nA(e,t){return Mg(e,t)}var zf=class{constructor(e){this.modelArtifacts=e}async load(){return this.modelArtifacts}},sA=class{constructor(e){this.saveHandler=e}async save(e){return this.saveHandler(e)}};function rA(e,t,n,s){return arguments.length===1?e.modelTopology!=null||e.weightSpecs!=null?new zf(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 zf({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 zf({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:s}))}function aA(e){return new sA(e)}var iA={};Ae(iA,{confusionMatrix:()=>dA});function oA(e,t,n=!1,s=!1){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(Ca,i,o)}var We=L({matMul_:oA});function uA(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(To,a,i)}var vd=L({oneHot_:uA});function lA(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`All entries in 'perm' must be between 0 and ${n.rank-1} but got ${t}`)}),n.rank<=1)return n.clone();let s={x:n},r={perm:t};return M.runKernel(pi,s,r)}var qe=L({transpose_:lA});function cA(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=qe(a),u=We(o,i);return ce(u,\"int32\")}var dA=L({confusionMatrix_:cA}),qo={};Ae(qo,{assertAndGetBroadcastShape:()=>ot,getBroadcastDims:()=>Ck,getReductionAxes:()=>_t});function Ck(e,t){let n=e.length,s=[];for(let r=0;r1&&i===1&&s.unshift(a)}return s}function _t(e,t){let n=[];for(let s=0;s1)&&n.unshift(a)}return n}function ot(e,t){let n=[],s=Math.max(e.length,t.length);for(let r=0;rvA,fromPixelsAsync:()=>bA,toPixels:()=>yA});function pA(e,t,n){if(wa(e),t!=null&&t.length!==3)throw new Error(\"tensor3d() requires shape to have three numbers\");let s=Rs(e,n);if(s.length!==3&&s.length!==1)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 Nr(e,t,s,n)}var Vr;function Tk(e,t=3){if(t>4)throw new Error(\"Cannot construct Tensor with more than 4 channels from pixels.\");if(e==null)throw new Error(\"pixels passed to tf.browser.fromPixels() can not be null\");let n=!1,s=!1,r=!1,a=!1,i=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if(typeof ImageData!=\"undefined\"&&e instanceof ImageData)s=!0;else if(typeof HTMLVideoElement!=\"undefined\"&&e instanceof HTMLVideoElement)r=!0;else if(typeof HTMLImageElement!=\"undefined\"&&e instanceof HTMLImageElement)a=!0;else if(e.getContext!=null)i=!0;else if(typeof ImageBitmap!=\"undefined\"&&e instanceof ImageBitmap)o=!0;else throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${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