@pexip/media-processor 20.0.1 → 20.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var It=typeof self<"u"?self:{};function za(e,t){e=e.split(".");var r,n=It;for((e[0]in n)||n.execScript===void 0||n.execScript("var "+e[0]);e.length&&(r=e.shift());)e.length||t===void 0?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=t}function kt(){throw Error("Invalid UTF8")}function Fs(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var Ir,On,xu=typeof TextDecoder<"u",yu,vu=typeof TextEncoder<"u";function Ka(e){if(vu)e=(yu||(yu=new TextEncoder)).encode(e);else{let r=0,n=new Uint8Array(3*e.length);for(let o=0;o<e.length;o++){var t=e.charCodeAt(o);if(t<128)n[r++]=t;else{if(t<2048)n[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&o<e.length){let s=e.charCodeAt(++o);if(s>=56320&&s<=57343){t=1024*(t-55296)+s-56320+65536,n[r++]=t>>18|240,n[r++]=t>>12&63|128,n[r++]=t>>6&63|128,n[r++]=63&t|128;continue}o--}t=65533}n[r++]=t>>12|224,n[r++]=t>>6&63|128}n[r++]=63&t|128}}e=r===n.length?n:n.subarray(0,r)}return e}var xo,Xr;e:{for(Pn=["CLOSURE_FLAGS"],Mr=It,Fr=0;Fr<Pn.length;Fr++)if((Mr=Mr[Pn[Fr]])==null){Xr=null;break e}Xr=Mr}var Pn,Mr,Fr,yr,Us=Xr&&Xr[610401301];xo=Us!=null&&Us;var Os=It.navigator;function $n(e){return!!xo&&!!yr&&yr.brands.some(({brand:t})=>t&&t.indexOf(e)!=-1)}function Ue(e){var t;return(t=It.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function ft(){return!!xo&&!!yr&&yr.brands.length>0}function Bn(){return ft()?$n("Chromium"):(Ue("Chrome")||Ue("CriOS"))&&!(!ft()&&Ue("Edge"))||Ue("Silk")}function yo(e){return yo[" "](e),e}yr=Os&&Os.userAgentData||null,yo[" "]=function(){};var Eu=!ft()&&(Ue("Trident")||Ue("MSIE"));!Ue("Android")||Bn(),Bn(),Ue("Safari")&&(Bn()||!ft()&&Ue("Coast")||!ft()&&Ue("Opera")||!ft()&&Ue("Edge")||(ft()?$n("Microsoft Edge"):Ue("Edg/"))||ft()&&$n("Opera"));var $a={},dr=null;function bu(e){let t=e.length,r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);let n=new Uint8Array(r),o=0;return function(s,a){function i(l){for(;c<s.length;){let h=s.charAt(c++),f=dr[h];if(f!=null)return f;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return l}qa();let c=0;for(;;){let l=i(-1),h=i(0),f=i(64),d=i(64);if(d===64&&l===-1)break;a(l<<2|h>>4),f!=64&&(a(h<<4&240|f>>2),d!=64&&a(f<<6&192|d))}}(e,function(s){n[o++]=s}),o!==r?n.subarray(0,o):n}function qa(){if(!dr){dr={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=e.concat(t[r].split(""));$a[r]=n;for(let o=0;o<n.length;o++){let s=n[o];dr[s]===void 0&&(dr[s]=o)}}}}var Ja=typeof Uint8Array<"u",Qa=!Eu&&typeof btoa=="function";function Ps(e){if(!Qa){var t;t===void 0&&(t=0),qa(),t=$a[t];var r=Array(Math.floor(e.length/3)),n=t[64]||"";let c=0,l=0;for(;c<e.length-2;c+=3){var o=e[c],s=e[c+1],a=e[c+2],i=t[o>>2];o=t[(3&o)<<4|s>>4],s=t[(15&s)<<2|a>>6],a=t[63&a],r[l++]=i+o+s+a}switch(i=0,a=n,e.length-c){case 2:a=t[(15&(i=e[c+1]))<<2]||n;case 1:e=e[c],r[l]=t[e>>2]+t[(3&e)<<4|i>>4]+a+n}return r.join("")}for(t="",r=0,n=e.length-10240;r<n;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}var Bs=/[-_.]/g,Tu={"-":"+",_:"/",".":"="};function _u(e){return Tu[e]||""}function Za(e){if(!Qa)return bu(e);Bs.test(e)&&(e=e.replace(Bs,_u)),e=atob(e);let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function _r(e){return Ja&&e!=null&&e instanceof Uint8Array}var Gt={};function Mt(){return Au||(Au=new at(null,Gt))}function vo(e){ei(Gt);var t=e.g;return(t=t==null||_r(t)?t:typeof t=="string"?Za(t):null)==null?t:e.g=t}var at=class{h(){return new Uint8Array(vo(this)||0)}constructor(e,t){if(ei(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}},Au,Ru;function ei(e){if(e!==Gt)throw Error("illegal external caller")}function ti(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function ri(){let e=Error();ti(e,"incident"),function(t){It.setTimeout(()=>{throw t},0)}(e)}function qn(e){return ti(e=Error(e),"warning"),e}function Eo(){return typeof BigInt=="function"}function we(e){return Array.prototype.slice.call(e)}var Kt=typeof Symbol=="function"&&typeof Symbol()=="symbol";function tn(e){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol():e}var Ar=tn(),Ds=tn("0di"),Dn=tn("2ex"),ir=tn("1oa"),rn=Kt?(e,t)=>{e[Ar]|=t}:(e,t)=>{e.G!==void 0?e.G|=t:Object.defineProperties(e,{G:{value:t,configurable:!0,writable:!0,enumerable:!1}})},Jn=Kt?(e,t)=>{e[Ar]&=~t}:(e,t)=>{e.G!==void 0&&(e.G&=~t)},re=Kt?e=>0|e[Ar]:e=>0|e.G,G=Kt?e=>e[Ar]:e=>e.G,oe=Kt?(e,t)=>{e[Ar]=t}:(e,t)=>{e.G!==void 0?e.G=t:Object.defineProperties(e,{G:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function $t(e){return rn(e,34),e}function wu(e,t){oe(t,-30975&(0|e))}function Qn(e,t){oe(t,-30941&(34|e))}var bo,Rr={},ni={};function Ns(e){return!(!e||typeof e!="object"||e.Ia!==ni)}function To(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function _o(e,t){if(e!=null){if(typeof e=="string")e=e?new at(e,Gt):Mt();else if(e.constructor!==at)if(_r(e))e=e.length?new at(new Uint8Array(e),Gt):Mt();else{if(!t)throw Error();e=void 0}}return e}function Hr(e){return!(!Array.isArray(e)||e.length)&&!!(1&re(e))}var Gs=[];function _t(e){if(2&e)throw Error()}oe(Gs,55),bo=Object.freeze(Gs);var Yr=class e{constructor(t,r,n){this.l=0,this.g=t,this.h=r,this.m=n}next(){if(this.l<this.g.length){let t=this.g[this.l++];return{done:!1,value:this.h?this.h.call(this.m,t):t}}return{done:!0,value:void 0}}[Symbol.iterator](){return new e(this.g,this.h,this.m)}},mt;function oi(e,t){(t=mt?t[mt]:void 0)&&(e[mt]=we(t))}var ku=Object.freeze({});function nn(e){return e.Pa=!0,e}var Su=nn(e=>typeof e=="number"),Vs=nn(e=>typeof e=="string"),Cu=nn(e=>typeof e=="boolean"),on=typeof It.BigInt=="function"&&typeof It.BigInt(0)=="bigint",Zn=nn(e=>on?e>=Iu&&e<=Fu:e[0]==="-"?js(e,Lu):js(e,Mu)),Lu=Number.MIN_SAFE_INTEGER.toString(),Iu=on?BigInt(Number.MIN_SAFE_INTEGER):void 0,Mu=Number.MAX_SAFE_INTEGER.toString(),Fu=on?BigInt(Number.MAX_SAFE_INTEGER):void 0;function js(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){let n=e[r],o=t[r];if(n>o)return!1;if(n<o)return!0}}var Uu=typeof Uint8Array.prototype.slice=="function",si,V=0,Z=0;function Ws(e){let t=e>>>0;V=t,Z=(e-t)/4294967296>>>0}function Vt(e){if(e<0){Ws(-e);let[t,r]=ko(V,Z);V=t>>>0,Z=r>>>0}else Ws(e)}function Ao(e){let t=si||(si=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),Z=0,V=t.getUint32(0,!0)}function Ro(e,t){let r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:vr(e,t)}function wo(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Ro(e,t))=="number"?r?-e:e:r?"-"+e:e}function vr(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else Eo()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+Xs(r)+Xs(e));return r}function Xs(e){return e=String(e),"0000000".slice(e.length)+e}function sn(e){if(e.length<16)Vt(Number(e));else if(Eo())e=BigInt(e),V=Number(e&BigInt(4294967295))>>>0,Z=Number(e>>BigInt(32)&BigInt(4294967295));else{let t=+(e[0]==="-");Z=V=0;let r=e.length;for(let n=t,o=(r-t)%6+t;o<=r;n=o,o+=6){let s=Number(e.slice(n,o));Z*=1e6,V=1e6*V+s,V>=4294967296&&(Z+=Math.trunc(V/4294967296),Z>>>=0,V>>>=0)}if(t){let[n,o]=ko(V,Z);V=n,Z=o}}}function ko(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function At(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function ai(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}var Ou=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function an(e){let t=typeof e;switch(t){case"bigint":return!0;case"number":return Number.isFinite(e)}return t==="string"&&Ou.test(e)}function qt(e){if(e==null)return e;if(typeof e=="string"){if(!e)return;e=+e}return typeof e=="number"&&Number.isFinite(e)?0|e:void 0}function ii(e){if(e==null)return e;if(typeof e=="string"){if(!e)return;e=+e}return typeof e=="number"&&Number.isFinite(e)?e>>>0:void 0}function Hs(e){return e[0]!=="-"&&(e.length<20||e.length===20&&Number(e.substring(0,6))<184467)}function So(e){return e=Math.trunc(e),Number.isSafeInteger(e)||(Vt(e),e=wo(V,Z)),e}function Co(e){var t=Math.trunc(Number(e));if(Number.isSafeInteger(t))return String(t);if((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),!(e[0]==="-"?e.length<20||e.length===20&&Number(e.substring(0,7))>-922337:e.length<19||e.length===19&&Number(e.substring(0,6))<922337))if(sn(e),e=V,2147483648&(t=Z))if(Eo())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,n]=ko(e,t);e="-"+vr(r,n)}else e=vr(e,t);return e}function zr(e){return e==null?e:typeof e=="bigint"?(Zn(e)?e=Number(e):(e=BigInt.asIntN(64,e),e=Zn(e)?Number(e):String(e)),e):an(e)?typeof e=="number"?So(e):Co(e):void 0}function Pu(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(BigInt.asUintN(64,e));if(an(e)){if(t==="string")return t=Math.trunc(Number(e)),Number.isSafeInteger(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Hs(e)||(sn(e),e=vr(V,Z))),e;if(t==="number")return(e=Math.trunc(e))>=0&&Number.isSafeInteger(e)?e:function(r){if(r<0){Vt(r);var n=vr(V,Z);return r=Number(n),Number.isSafeInteger(r)?r:n}return Hs(n=String(r))?n:(Vt(r),Ro(V,Z))}(e)}}function ci(e){if(typeof e!="string")throw Error();return e}function Jt(e){if(e!=null&&typeof e!="string")throw Error();return e}function gt(e){return e==null||typeof e=="string"?e:void 0}function Lo(e,t,r,n){if(e!=null&&typeof e=="object"&&e.X===Rr)return e;if(!Array.isArray(e))return r?2&n?(e=t[Ds])?t=e:($t((e=new t).u),t=t[Ds]=e):t=new t:t=void 0,t;let o=r=re(e);return o===0&&(o|=32&n),o|=2&n,o!==r&&oe(e,o),new t(e)}function Bu(e,t,r){if(t)e:{if(!an(t=e))throw qn("int64");switch(typeof t){case"string":t=Co(t);break e;case"bigint":if(e=t=BigInt.asIntN(64,t),Vs(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(Su(e)&&!Number.isSafeInteger(e))throw Error(String(e));t=on?BigInt(t):Cu(t)?t?"1":"0":Vs(t)?t.trim()||"0":String(t);break e;default:t=So(t)}}else t=zr(e);return typeof(r=(e=t)==null?r?0:void 0:e)=="string"&&(t=+r,Number.isSafeInteger(t))?t:r}function ui(e){var t;return cr===void 0&&(cr=typeof Proxy=="function"?Ys(Proxy):null),(t=!cr)||(ur===void 0&&(ur=typeof WeakMap=="function"?Ys(WeakMap):null),t=!ur),t?e:(t=jt?.get(e))?t:Math.random()>.01?e:(function(r){if(Nn===void 0){let n=new cr([],{});Nn=Array.prototype.concat.call([],n).length===1}Nn&&typeof Symbol=="function"&&Symbol.isConcatSpreadable&&(r[Symbol.isConcatSpreadable]=!0)}(e),function(r,n){(jt||(jt=new ur)).set(r,n),(hi||(hi=new ur)).set(n,r)}(e,t=new cr(e,{set:(r,n,o)=>(ri(),r[n]=o,!0)})),t)}var jt,hi,cr,ur,Nn,Kr,li,Du;function Ys(e){try{return e.toString().indexOf("[native code]")!==-1?e:null}catch{return null}}function xt(e,t,r){return e=di(e,t[0],t[1],r?1:2),t!==li&&r&&rn(e,16384),e}function di(e,t,r,n){if(n=n??0,e==null&&(e=Kr),Kr=void 0,e==null){var o=96;r?(e=[r],o|=512):e=[],t&&(o=-33521665&o|(1023&t)<<15)}else{if(!Array.isArray(e))throw Error("narr");if(2048&(o=re(e)))throw Error("farr");if(64&o)return e;if(n===1||n===2||(o|=64),r&&(o|=512,r!==e[0]))throw Error("mid");e:{if(n=(r=e).length){let s=n-1;if(To(r[s])){if((t=s-(+!!(512&(o|=256))-1))>=1024)throw Error("pvtlmt");o=-33521665&o|(1023&t)<<15;break e}}if(t){if((t=Math.max(t,n-(+!!(512&o)-1)))>1024)throw Error("spvt");o=-33521665&o|(1023&t)<<15}}}return oe(e,o),e}var Nu={},Gu=function(){try{return yo(new class extends Map{constructor(){super()}}),!1}catch{return!0}}(),pr=class{constructor(){this.g=new Map}get(t){return this.g.get(t)}set(t,r){return this.g.set(t,r),this.size=this.g.size,this}delete(t){return t=this.g.delete(t),this.size=this.g.size,t}clear(){this.g.clear(),this.size=this.g.size}has(t){return this.g.has(t)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(t,r){return this.g.forEach(t,r)}[Symbol.iterator](){return this.entries()}},Vu=Gu?(Object.setPrototypeOf(pr.prototype,Map.prototype),Object.defineProperties(pr.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),pr):class extends Map{constructor(){super()}};function zs(e){return e}function Gn(e){if(2&e.M)throw Error("Cannot mutate an immutable Map")}var Pe=class extends Vu{constructor(e,t,r=zs,n=zs){super();let o=re(e);o|=64,oe(e,o),this.M=o,this.T=t,this.S=r,this.Z=this.T?ju:n;for(let s=0;s<e.length;s++){let a=e[s],i=r(a[0],!1,!0),c=a[1];t?c===void 0&&(c=null):c=n(a[1],!1,!0,void 0,void 0,o),super.set(i,c)}}oa(e=Ks){if(this.size!==0)return this.Y(e)}Y(e=Ks){let t=[],r=super.entries();for(var n;!(n=r.next()).done;)(n=n.value)[0]=e(n[0]),n[1]=e(n[1]),t.push(n);return t}clear(){Gn(this),super.clear()}delete(e){return Gn(this),super.delete(this.S(e,!0,!1))}entries(){var e=this.na();return new Yr(e,Wu,this)}keys(){return this.Ha()}values(){var e=this.na();return new Yr(e,Pe.prototype.get,this)}forEach(e,t){super.forEach((r,n)=>{e.call(t,this.get(n),n,this)})}set(e,t){return Gn(this),(e=this.S(e,!0,!1))==null?this:t==null?(super.delete(e),this):super.set(e,this.Z(t,!0,!0,this.T,!1,this.M))}Na(e){let t=this.S(e[0],!1,!0);e=e[1],e=this.T?e===void 0?null:e:this.Z(e,!1,!0,void 0,!1,this.M),super.set(t,e)}has(e){return super.has(this.S(e,!1,!1))}get(e){e=this.S(e,!1,!1);let t=super.get(e);if(t!==void 0){var r=this.T;return r?((r=this.Z(t,!1,!0,r,this.sa,this.M))!==t&&super.set(e,r),r):t}}na(){return Array.from(super.keys())}Ha(){return super.keys()}[Symbol.iterator](){return this.entries()}};function ju(e,t,r,n,o,s){return e=Lo(e,n,r,s),o&&(e=un(e)),e}function Ks(e){return e}function Wu(e){return[e,this.get(e)]}var Xu;function $s(){return Xu||(Xu=new Pe($t([]),void 0,void 0,void 0,Nu))}function Io(e,t,r,n,o){if(e!=null){if(Array.isArray(e))e=Hr(e)?void 0:o&&2&re(e)?e:cn(e,t,r,n!==void 0,o);else if(To(e)){let s={};for(let a in e)s[a]=Io(e[a],t,r,n,o);e=s}else e=t(e,n);return e}}function cn(e,t,r,n,o){let s=n||r?re(e):0;n=n?!!(32&s):void 0;let a=we(e);for(let i=0;i<a.length;i++)a[i]=Io(a[i],t,r,n,o);return r&&(oi(a,e),r(s,a)),a}function Hu(e){return Io(e,Mo,void 0,void 0,!1)}function Mo(e){return e.X===Rr?e.toJSON():e instanceof Pe?e.oa(Hu):function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return Zn(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(Hr(t))return}else{if(_r(t))return Ps(t);if(t instanceof at){let r=t.g;return r==null?"":typeof r=="string"?r:t.g=Ps(r)}if(t instanceof Pe)return t.oa()}}return t}(e)}function eo(e,t,r=Qn){if(e!=null){if(Ja&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var n=re(e);return 2&n?e:(t&&(t=n===0||!!(32&n)&&!(64&n||!(16&n))),t?(oe(e,-12293&(34|n)),e):cn(e,eo,4&n?Qn:r,!0,!0))}return e.X===Rr?(r=e.u,e=2&(n=G(r))?e:Fo(e,r,n,!0)):e instanceof Pe&&!(2&e.M)&&(r=$t(e.Y(eo)),e=new Pe(r,e.T,e.S,e.Z)),e}}function Fo(e,t,r,n){return e=e.constructor,Kr=t=fi(t,r,n),t=new e(t),Kr=void 0,t}function fi(e,t,r){let n=r||2&t?Qn:wu,o=!!(32&t);return e=function(s,a,i){let c=we(s);var l=c.length;let h=256&a?c[l-1]:void 0;for(l+=h?-1:0,a=512&a?1:0;a<l;a++)c[a]=i(c[a]);if(h){a=c[a]={};for(let f in h)a[f]=i(h[f])}return oi(c,s),c}(e,t,s=>eo(s,o,n)),rn(e,32|(r?2:0)),e}function un(e){let t=e.u,r=G(t);return 2&r?Fo(e,t,r,!1):e}function vt(e,t){return ht(e=e.u,G(e),t)}function qs(e,t,r,n){if(!((t=n+(+!!(512&t)-1))<0||t>=e.length||t>=r))return e[t]}function ht(e,t,r,n){if(r===-1)return null;let o=t>>15&1023||536870912;if(!(r>=o)){var s=e.length;return n&&256&t&&(n=e[s-1][r])!=null?(qs(e,t,o,r)&&Dn!=null&&((t=(e=Ru??(Ru={}))[Dn]||0)>=4||(e[Dn]=t+1,ri())),n):qs(e,t,o,r)}return 256&t?e[e.length-1][r]:void 0}function X(e,t,r){let n=e.u,o=G(n);return _t(o),J(n,o,t,r),e}function J(e,t,r,n){let o=t>>15&1023||536870912;if(r>=o){let s,a=t;if(256&t)s=e[e.length-1];else{if(n==null)return a;s=e[o+(+!!(512&t)-1)]={},a|=256}return s[r]=n,r<o&&(e[r+(+!!(512&t)-1)]=void 0),a!==t&&oe(e,a),a}return e[r+(+!!(512&t)-1)]=n,256&t&&r in(e=e[e.length-1])&&delete e[r],t}function Dr(e,t){e=e.u;let r=G(e),n=ht(e,r,t),o=At(n);return o!=null&&o!==n&&J(e,r,t,o),o}function pi(e){e=e.u;let t=G(e),r=ht(e,t,1),n=_o(r,!0);return n!=null&&n!==r&&J(e,t,1,n),n}function St(){return ku===void 0?2:4}function Ct(e,t,r,n,o){let s=e.u,a=2&(e=G(s))?1:n;o=!!o,n=Uo(s,e,t);var i=re(n);if(!(4&i)){4&i&&(n=we(n),i=it(i,e),e=J(s,e,t,n));let l=0,h=0;for(;l<n.length;l++){let f=r(n[l]);f!=null&&(n[h++]=f)}h<l&&(n.length=h),i=-4097&(20|(i=Oo(i,e))),oe(n,i&=-8193),2&i&&Object.freeze(n)}let c;return a===1||a===4&&32&i?Ve(i)||(o=i,(i|=2)!==o&&oe(n,i),Object.freeze(n)):(r=a===5&&(!!(32&i)||Ve(i)||!!jt?.get(n)),(a===2||r)&&Ve(i)&&(n=we(n),i=yt(i=it(i,e),e,o),oe(n,i),e=J(s,e,t,n)),Ve(i)||(t=i,(i=yt(i,e,o))!==t&&oe(n,i)),r?c=ui(n):a!==2||o||jt?.delete(n)),c||n}function Uo(e,t,r,n){return e=ht(e,t,r,n),Array.isArray(e)?e:bo}function Oo(e,t){return e===0&&(e=it(e,t)),1|e}function Ve(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function mi(e){e=we(e);for(let t=0;t<e.length;t++){let r=e[t]=we(e[t]);Array.isArray(r[1])&&(r[1]=$t(r[1]))}return e}function to(e,t,r,n){e=e.u;let o=G(e);_t(o),J(e,o,t,(n==="0"?Number(r)===0:r===n)?void 0:r)}function Qt(e,t,r,n,o){_t(t);var s=!(!(64&t)&&16384&t);let a=(o=Uo(e,t,r,o))!==bo;if(s||!a){let i=s=a?re(o):0;(!a||2&i||Ve(i)||4&i&&!(32&i))&&(o=we(o),i=it(i,t),t=J(e,t,r,o)),i=-13&Oo(i,t),i=yt(n?-17&i:16|i,t,!0),i!==s&&oe(o,i)}return o}function Vn(e,t){var r=oc;return Bo(Po(e=e.u),e,G(e),r)===t?t:-1}function Po(e){if(Kt)return e[ir]??(e[ir]=new Map);if(ir in e)return e[ir];let t=new Map;return Object.defineProperty(e,ir,{value:t}),t}function gi(e,t,r,n){let o=Po(e),s=Bo(o,e,t,r);return s!==n&&(s&&(t=J(e,t,s)),o.set(r,n)),t}function Bo(e,t,r,n){let o=e.get(n);if(o!=null)return o;o=0;for(let s=0;s<n.length;s++){let a=n[s];ht(t,r,a)!=null&&(o!==0&&(r=J(t,r,o)),o=a)}return e.set(n,o),o}function Do(e,t,r,n){let o,s=G(e);if((n=ht(e,s,r,n))!=null&&n.X===Rr)return(t=un(n))!==n&&J(e,s,r,t),t.u;if(Array.isArray(n)){let a=re(n);o=2&a?xt(fi(n,a,!1),t,!0):64&a?n:xt(o,t,!0)}else o=xt(void 0,t,!0);return o!==n&&J(e,s,r,o),o}function xi(e,t,r,n){e=e.u;let o=G(e);return(t=Lo(n=ht(e,o,r,n),t,!1,o))!==n&&t!=null&&J(e,o,r,t),t}function O(e,t,r,n=!1){if((t=xi(e,t,r,n))==null)return t;if(e=e.u,!(2&(n=G(e)))){let o=un(t);o!==t&&J(e,n,r,t=o)}return t}function yi(e,t,r,n,o,s,a){e=e.u;var i=!!(2&t);o=i?1:o,s=!!s,a&&(a=!i),i=Uo(e,t,n);var c=re(i),l=!!(4&c);if(!l){var h=i,f=t;let b=!!(2&(c=Oo(c,t)));b&&(f|=2);let R=!b,A=!0,k=0,S=0;for(;k<h.length;k++){let p=Lo(h[k],r,!1,f);if(p instanceof r){if(!b){let x=!!(2&re(p.u));R&&(R=!x),A&&(A=x)}h[S++]=p}}S<k&&(h.length=S),c|=4,c=A?16|c:-17&c,oe(h,c=R?8|c:-9&c),b&&Object.freeze(h)}if(a&&!(8&c||!i.length&&(o===1||o===4&&32&c))){for(Ve(c)&&(i=we(i),c=it(c,t),t=J(e,t,n,i)),r=i,a=c,h=0;h<r.length;h++)(c=r[h])!==(f=un(c))&&(r[h]=f);a|=8,a=r.length?-17&a:16|a,oe(r,a),c=a}let d;return o===1||o===4&&32&c?Ve(c)||(t=c,(c|=!i.length||16&c&&(!l||32&c)?2:2048)!==t&&oe(i,c),Object.freeze(i)):(l=o===5&&(!!(32&c)||Ve(c)||!!jt?.get(i)),(o===2||l)&&Ve(c)&&(i=we(i),c=yt(c=it(c,t),t,s),oe(i,c),t=J(e,t,n,i)),Ve(c)||(n=c,(c=yt(c,t,s))!==n&&oe(i,c)),l?d=ui(i):o!==2||s||jt?.delete(i)),d||i}function ct(e,t,r){let n=G(e.u);return yi(e,n,t,r,St(),!1,!(2&n))}function T(e,t,r,n){return n==null&&(n=void 0),X(e,r,n)}function mr(e,t,r,n){n==null&&(n=void 0);e:{e=e.u;let o=G(e);if(_t(o),n==null){let s=Po(e);if(Bo(s,e,o,r)!==t)break e;s.set(r,0)}else o=gi(e,o,r,t);J(e,o,t,n)}}function it(e,t){return-2049&(e=32|(2&t?2|e:-3&e))}function yt(e,t,r){return 32&t&&r||(e&=-33),e}function $r(e,t,r,n){let o=G(e.u);_t(o),e=yi(e,o,r,t,2,!0),n=n??new r,e.push(n),2&re(n.u)?Jn(e,8):Jn(e,16)}function je(e,t){return e??t}function Oe(e,t){return qt(vt(e,t))}function te(e,t){return je(Dr(e,t),0)}function et(e,t){return je(gt(vt(e,t)),"")}function Er(e,t,r){if(r!=null&&typeof r!="boolean")throw e=typeof r,Error(`Expected boolean but got ${e!="object"?e:r?Array.isArray(r)?"array":e:"null"}: ${r}`);X(e,t,r)}function tt(e,t,r){if(r!=null){if(typeof r!="number"||!Number.isFinite(r))throw qn("int32");r|=0}X(e,t,r)}function y(e,t,r){if(r!=null&&typeof r!="number")throw Error(`Value of float/double field must be a number, found ${typeof r}: ${r}`);X(e,t,r)}function qr(e,t,r){{let a=e.u,i=G(a);if(_t(i),r==null)J(a,i,t);else{r=hi?.get(r)||r;var n=e=re(r),o=Ve(e),s=o||Object.isFrozen(r);for(o||(e=0),s||(r=we(r),n=0,e=yt(e=it(e,i),i,!0),s=!1),e|=21,o=0;o<r.length;o++){let c=r[o],l=ci(c);Object.is(c,l)||(s&&(r=we(r),n=0,e=yt(e=it(e,i),i,!0),s=!1),r[o]=l)}e!==n&&(s&&(r=we(r),e=yt(e=it(e,i),i,!0)),oe(r,e)),J(a,i,t,r)}}}function hn(e,t,r){_t(G(e.u)),Ct(e,t,gt,2,!0).push(ci(r))}function vi(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function No(){return Error("Failed to read varint, encoding is invalid.")}function Ei(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function Go(e){if(typeof e=="string")return{buffer:Za(e),O:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),O:!1};if(e.constructor===Uint8Array)return{buffer:e,O:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),O:!1};if(e.constructor===at)return{buffer:vo(e)||new Uint8Array(0),O:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),O:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function Vo(e,t){let r,n=0,o=0,s=0,a=e.h,i=e.g;do r=a[i++],n|=(127&r)<<s,s+=7;while(s<32&&128&r);for(s>32&&(o|=(127&r)>>4),s=3;s<32&&128&r;s+=7)r=a[i++],o|=(127&r)<<s;if(Lt(e,i),r<128)return t(n>>>0,o>>>0);throw No()}function jo(e){let t=0,r=e.g,n=r+10,o=e.h;for(;r<n;){let s=o[r++];if(t|=s,(128&s)==0)return Lt(e,r),!!(127&t)}throw No()}function Et(e){let t=e.h,r=e.g,n=t[r++],o=127&n;if(128&n&&(n=t[r++],o|=(127&n)<<7,128&n&&(n=t[r++],o|=(127&n)<<14,128&n&&(n=t[r++],o|=(127&n)<<21,128&n&&(n=t[r++],o|=n<<28,128&n&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw No();return Lt(e,r),o}function ut(e){return Et(e)>>>0}function ro(e){var t=e.h;let r=e.g,n=t[r],o=t[r+1],s=t[r+2];return t=t[r+3],Lt(e,e.g+4),(n<<0|o<<8|s<<16|t<<24)>>>0}function no(e){var t=ro(e);e=2*(t>>31)+1;let r=t>>>23&255;return t&=8388607,r==255?t?NaN:e*(1/0):r==0?1401298464324817e-60*e*t:e*Math.pow(2,r-150)*(t+8388608)}function Yu(e){return Et(e)}function jn(e,t,{ca:r=!1}={}){e.ca=r,t&&(t=Go(t),e.h=t.buffer,e.m=t.O,e.j=0,e.l=e.h.length,e.g=e.j)}function Lt(e,t){if(e.g=t,t>e.l)throw Ei(e.l,t)}function bi(e,t){if(t<0)throw Error(`Tried to read a negative byte length: ${t}`);let r=e.g,n=r+t;if(n>e.l)throw Ei(t,e.l-r);return e.g=n,r}function Ti(e,t){if(t==0)return Mt();var r=bi(e,t);return e.ca&&e.m?r=e.h.subarray(r,r+t):(e=e.h,r=r===(t=r+t)?new Uint8Array(0):Uu?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Mt():new at(r,Gt)}Pe.prototype.toJSON=void 0,Pe.prototype.Ia=ni;var Js=[];function _i(e){var t=e.g;if(t.g==t.l)return!1;e.l=e.g.g;var r=ut(e.g);if(t=r>>>3,!((r&=7)>=0&&r<=5))throw vi(r,e.l);if(t<1)throw Error(`Invalid field number: ${t} (at position ${e.l})`);return e.m=t,e.h=r,!0}function Nr(e){switch(e.h){case 0:e.h!=0?Nr(e):jo(e.g);break;case 1:Lt(e=e.g,e.g+8);break;case 2:if(e.h!=2)Nr(e);else{var t=ut(e.g);Lt(e=e.g,e.g+t)}break;case 5:Lt(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!_i(e))throw Error("Unmatched start-group tag: stream EOF");if(e.h==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}Nr(e)}break;default:throw vi(e.h,e.l)}}function wr(e,t,r){let n=e.g.l,o=ut(e.g),s=e.g.g+o,a=s-n;if(a<=0&&(e.g.l=s,r(t,e,void 0,void 0,void 0),a=s-e.g.g),a)throw Error(`Message parsing ended unexpectedly. Expected to read ${o} bytes, instead read ${o-a} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=s,e.g.l=n,t}function Wo(e){var t=ut(e.g),r=bi(e=e.g,t);if(e=e.h,xu){var n,o=e;(n=On)||(n=On=new TextDecoder("utf-8",{fatal:!0})),t=r+t,o=r===0&&t===o.length?o:o.subarray(r,t);try{var s=n.decode(o)}catch(i){if(Ir===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),Ir=!0}catch{Ir=!1}}throw!Ir&&(On=void 0),i}}else{t=(s=r)+t,r=[];let i,c=null;for(;s<t;){var a=e[s++];a<128?r.push(a):a<224?s>=t?kt():(i=e[s++],a<194||(192&i)!=128?(s--,kt()):r.push((31&a)<<6|63&i)):a<240?s>=t-1?kt():(i=e[s++],(192&i)!=128||a===224&&i<160||a===237&&i>=160||(192&(n=e[s++]))!=128?(s--,kt()):r.push((15&a)<<12|(63&i)<<6|63&n)):a<=244?s>=t-2?kt():(i=e[s++],(192&i)!=128||i-144+(a<<28)>>30!=0||(192&(n=e[s++]))!=128||(192&(o=e[s++]))!=128?(s--,kt()):(a=(7&a)<<18|(63&i)<<12|(63&n)<<6|63&o,a-=65536,r.push(55296+(a>>10&1023),56320+(1023&a)))):kt(),r.length>=8192&&(c=Fs(c,r),r.length=0)}s=Fs(c,r)}return s}function Ai(e){let t=ut(e.g);return Ti(e.g,t)}function ln(e,t,r){var n=ut(e.g);for(n=e.g.g+n;e.g.g<n;)r.push(t(e.g))}var Ur=[],Jr;function Xe(e,t,r){t.g?t.m(e,t.g,t.h,r,!0):t.m(e,t.h,r,!0)}var g=class{constructor(e,t){this.u=di(e,t)}toJSON(){return Ri(this)}l(){var e=k2;return e.g?e.l(this,e.g,e.h,!0):e.l(this,e.h,e.defaultValue,!0)}clone(){let e=this.u;return Fo(this,e,G(e),!1)}O(){return!!(2&re(this.u))}};function Ri(e){e=e.u,e=Jr?e:cn(e,Mo,void 0,void 0,!1);{var t=!Jr;let l=e.length;if(l){var r=e[l-1],n=To(r);n?l--:r=void 0;var o=e;if(n){e:{var s,a=r,i=!1;if(a)for(let h in a)isNaN(+h)?(s??(s={}))[h]=a[h]:(n=a[h],Array.isArray(n)&&(Hr(n)||Ns(n)&&n.size===0)&&(n=null),n==null&&(i=!0),n!=null&&((s??(s={}))[h]=n));if(i||(s=a),s)for(let h in s){i=s;break e}i=null}a=i==null?r!=null:i!==r}for(;l>0&&((s=o[l-1])==null||Hr(s)||Ns(s)&&s.size===0);l--)var c=!0;(o!==e||a||c)&&(t?(c||a||i)&&(o.length=l):o=Array.prototype.slice.call(o,0,l),i&&o.push(i)),c=o}else c=e}return c}function Qs(e){return e?/^\d+$/.test(e)?(sn(e),new oo(V,Z)):null:zu||(zu=new oo(0,0))}g.prototype.X=Rr,g.prototype.toString=function(){try{return Jr=!0,Ri(this).toString()}finally{Jr=!1}};var oo=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}},zu;function Zs(e){return e?/^-?\d+$/.test(e)?(sn(e),new so(V,Z)):null:Ku||(Ku=new so(0,0))}var so=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}},Ku;function Bt(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function Zt(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function dn(e,t){if(t>=0)Zt(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function br(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function Wt(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function Se(e,t,r){Zt(e.g,8*t+r)}function Xo(e,t){return Se(e,t,2),t=e.g.end(),Wt(e,t),t.push(e.h),t}function Ho(e,t){var r=t.pop();for(r=e.h+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.h++;t.push(r),e.h++}function fn(e,t,r){Se(e,t,2),Zt(e.g,r.length),Wt(e,e.g.end()),Wt(e,r)}function Qr(e,t,r,n){r!=null&&(t=Xo(e,t),n(r,e),Ho(e,t))}function He(){let e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var Yo=He(),wi=He(),zo=He(),Ko=He(),ki=He(),Si=He(),$o=He(),Ci=He(),Li=He(),er=class{constructor(e,t,r){this.g=e,this.h=t,e=Yo,this.l=!!e&&r===e||!1}};function pn(e,t){return new er(e,t,Yo)}function Ii(e,t,r,n,o){Qr(e,r,Oi(t,n),o)}var $u=pn(function(e,t,r,n,o){return e.h===2&&(wr(e,Do(t,n,r),o),!0)},Ii),qu=pn(function(e,t,r,n,o){return e.h===2&&(wr(e,Do(t,n,r,!0),o),!0)},Ii),mn=Symbol(),qo=Symbol(),ea=Symbol(),ta=Symbol(),Mi,Fi;function Ft(e,t,r,n){var o=n[e];if(o)return o;(o={}).W=function(f){switch(typeof f){case"boolean":return li||(li=[0,void 0,!0]);case"number":return f>0?void 0:f===0?Du||(Du=[0,void 0]):[-f,void 0];case"string":return[0,f];case"object":return f}}(n[0]);var s=n[1];let a=1;s&&s.constructor===Object&&(o.ha=s,typeof(s=n[++a])=="function"&&(o.ma=!0,Mi??(Mi=s),Fi??(Fi=n[a+1]),s=n[a+=2]));let i={};for(;s&&Array.isArray(s)&&s.length&&typeof s[0]=="number"&&s[0]>0;){for(var c=0;c<s.length;c++)i[s[c]]=s;s=n[++a]}for(c=1;s!==void 0;){let f;typeof s=="number"&&(c+=s,s=n[++a]);var l=void 0;if(s instanceof er?f=s:(f=$u,a--),f?.l){s=n[++a],l=n;var h=a;typeof s=="function"&&(s=s(),l[h]=s),l=s}for(h=c+1,typeof(s=n[++a])=="number"&&s<0&&(h-=s,s=n[++a]);c<h;c++){let d=i[c];l?r(o,c,f,l,d):t(o,c,f,d)}}return n[e]=o}function Ui(e){return Array.isArray(e)?e[0]instanceof er?e:[qu,e]:[e,void 0]}function Oi(e,t){return e instanceof g?e.u:Array.isArray(e)?xt(e,t,!1):void 0}function Jo(e,t,r,n){let o=r.g;e[t]=n?(s,a,i)=>o(s,a,i,n):o}function Qo(e,t,r,n,o){let s=r.g,a,i;e[t]=(c,l,h)=>s(c,l,h,i||(i=Ft(qo,Jo,Qo,n).W),a||(a=Zo(n)),o)}function Zo(e){let t=e[ea];if(t!=null)return t;let r=Ft(qo,Jo,Qo,e);return t=r.ma?(n,o)=>Mi(n,o,r):(n,o)=>{let s=G(n);for(;_i(o)&&o.h!=4;){var a=o.m,i=r[a];if(i==null){var c=r.ha;c&&(c=c[a])&&(c=Ju(c))!=null&&(i=r[a]=c)}i!=null&&i(o,n,a)||(a=(i=o).l,Nr(i),i.ga?i=void 0:(c=i.g.g-a,i.g.g=a,i=Ti(i.g,c)),a=n,i&&(mt||(mt=Symbol()),(c=a[mt])?c.push(i):a[mt]=[i]))}return 16384&s&&$t(n),!0},e[ea]=t}function Ju(e){let t=(e=Ui(e))[0].g;if(e=e[1]){let r=Zo(e),n=Ft(qo,Jo,Qo,e).W;return(o,s,a)=>t(o,s,a,n,r)}return t}function gn(e,t,r){e[t]=r.h}function xn(e,t,r,n){let o,s,a=r.h;e[t]=(i,c,l)=>a(i,c,l,s||(s=Ft(mn,gn,xn,n).W),o||(o=Pi(n)))}function Pi(e){let t=e[ta];if(!t){let r=Ft(mn,gn,xn,e);t=(n,o)=>Bi(n,o,r),e[ta]=t}return t}function Bi(e,t,r){for(var n=re(e),o=+!!(512&n)-1,s=e.length,a=512&n?1:0,i=s+(256&n?-1:0);a<i;a++){let c=e[a];if(c==null)continue;let l=a-o,h=ra(r,l);h&&h(t,c,l)}if(256&n){n=e[s-1];for(let c in n)o=+c,Number.isNaN(o)||(s=n[o])!=null&&(i=ra(r,o))&&i(t,s,o)}if(e=mt?e[mt]:void 0)for(Wt(t,t.g.end()),r=0;r<e.length;r++)Wt(t,vo(e[r])||new Uint8Array(0))}function ra(e,t){var r=e[t];if(r)return r;if((r=e.ha)&&(r=r[t])){var n=(r=Ui(r))[0].h;if(r=r[1]){let o=Pi(r),s=Ft(mn,gn,xn,r).W;r=e.ma?Fi(s,o):(a,i,c)=>n(a,i,c,s,o)}else r=n;return e[t]=r}}function tr(e,t){if(Array.isArray(t)){var r=re(t);if(4&r)return t;for(var n=0,o=0;n<t.length;n++){let s=e(t[n]);s!=null&&(t[o++]=s)}return o<n&&(t.length=o),oe(t,-12289&(5|r)),2&r&&Object.freeze(t),t}}function ye(e,t,r){return new er(e,t,r)}function rr(e,t,r){return new er(e,t,r)}function ve(e,t,r){J(e,G(e),t,r)}var Qu=pn(function(e,t,r,n,o){return e.h===2&&(e=wr(e,xt([void 0,void 0],n,!0),o),_t(n=G(t)),(o=ht(t,n,r))instanceof Pe?(2&o.M)!=0?((o=o.Y()).push(e),J(t,n,r,o)):o.Na(e):Array.isArray(o)?(2&re(o)&&J(t,n,r,o=mi(o)),o.push(e)):J(t,n,r,[e]),!0)},function(e,t,r,n,o){if(t instanceof Pe)t.forEach((s,a)=>{Qr(e,r,xt([a,s],n,!1),o)});else if(Array.isArray(t))for(let s=0;s<t.length;s++){let a=t[s];Array.isArray(a)&&Qr(e,r,xt(a,n,!1),o)}});function Di(e,t,r){if(t=function(n){if(n==null)return n;let o=typeof n;if(o==="bigint")return String(BigInt.asIntN(64,n));if(an(n)){if(o==="string")return Co(n);if(o==="number")return So(n)}}(t),t!=null&&(typeof t=="string"&&Zs(t),t!=null))switch(Se(e,r,0),typeof t){case"number":e=e.g,Vt(t),Bt(e,V,Z);break;case"bigint":r=BigInt.asUintN(64,t),r=new so(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Bt(e.g,r.h,r.g);break;default:r=Zs(t),Bt(e.g,r.h,r.g)}}function Ni(e,t,r){(t=qt(t))!=null&&t!=null&&(Se(e,r,0),dn(e.g,t))}function Gi(e,t,r){(t=ai(t))!=null&&(Se(e,r,0),e.g.g.push(t?1:0))}function Vi(e,t,r){(t=gt(t))!=null&&fn(e,r,Ka(t))}function ji(e,t,r,n,o){Qr(e,r,Oi(t,n),o)}function Wi(e,t,r){(t=t==null||typeof t=="string"||_r(t)||t instanceof at?t:void 0)!=null&&fn(e,r,Go(t).buffer)}function Xi(e,t,r){return(e.h===5||e.h===2)&&(t=Qt(t,G(t),r,!1,!1),e.h==2?ln(e,no,t):t.push(no(e.g)),!0)}var ot=ye(function(e,t,r){if(e.h!==1)return!1;var n=e.g;e=ro(n);let o=ro(n);n=2*(o>>31)+1;let s=o>>>20&2047;return e=4294967296*(1048575&o)+e,ve(t,r,s==2047?e?NaN:n*(1/0):s==0?5e-324*n*e:n*Math.pow(2,s-1075)*(e+4503599627370496)),!0},function(e,t,r){(t=At(t))!=null&&(Se(e,r,1),e=e.g,(r=si||(si=new DataView(new ArrayBuffer(8)))).setFloat64(0,+t,!0),V=r.getUint32(0,!0),Z=r.getUint32(4,!0),br(e,V),br(e,Z))},He()),ce=ye(function(e,t,r){return e.h===5&&(ve(t,r,no(e.g)),!0)},function(e,t,r){(t=At(t))!=null&&(Se(e,r,5),e=e.g,Ao(t),br(e,V))},$o),Zu=rr(Xi,function(e,t,r){if((t=tr(At,t))!=null)for(let a=0;a<t.length;a++){var n=e,o=r,s=t[a];s!=null&&(Se(n,o,5),n=n.g,Ao(s),br(n,V))}},$o),es=rr(Xi,function(e,t,r){if((t=tr(At,t))!=null&&t.length){Se(e,r,2),Zt(e.g,4*t.length);for(let n=0;n<t.length;n++)r=e.g,Ao(t[n]),br(r,V)}},$o),bt=ye(function(e,t,r){return e.h===0&&(ve(t,r,Vo(e.g,wo)),!0)},Di,Si),Wn=ye(function(e,t,r){return e.h===0&&(ve(t,r,(e=Vo(e.g,wo))===0?void 0:e),!0)},Di,Si),e2=ye(function(e,t,r){return e.h===0&&(ve(t,r,Vo(e.g,Ro)),!0)},function(e,t,r){if((t=Pu(t))!=null&&(typeof t=="string"&&Qs(t),t!=null))switch(Se(e,r,0),typeof t){case"number":e=e.g,Vt(t),Bt(e,V,Z);break;case"bigint":r=BigInt.asUintN(64,t),r=new oo(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Bt(e.g,r.h,r.g);break;default:r=Qs(t),Bt(e.g,r.h,r.g)}},He()),ee=ye(function(e,t,r){return e.h===0&&(ve(t,r,Et(e.g)),!0)},Ni,Ko),yn=rr(function(e,t,r){return(e.h===0||e.h===2)&&(t=Qt(t,G(t),r,!1,!1),e.h==2?ln(e,Et,t):t.push(Et(e.g)),!0)},function(e,t,r){if((t=tr(qt,t))!=null&&t.length){r=Xo(e,r);for(let n=0;n<t.length;n++)dn(e.g,t[n]);Ho(e,r)}},Ko),Pt=ye(function(e,t,r){return e.h===0&&(ve(t,r,(e=Et(e.g))===0?void 0:e),!0)},Ni,Ko),q=ye(function(e,t,r){return e.h===0&&(ve(t,r,jo(e.g)),!0)},Gi,wi),Dt=ye(function(e,t,r){return e.h===0&&(ve(t,r,(e=jo(e.g))===!1?void 0:e),!0)},Gi,wi),fe=rr(function(e,t,r){return e.h===2&&(e=Wo(e),Qt(t,G(t),r,!1).push(e),!0)},function(e,t,r){if((t=tr(gt,t))!=null)for(let a=0;a<t.length;a++){var n=e,o=r,s=t[a];s!=null&&fn(n,o,Ka(s))}},zo),pt=ye(function(e,t,r){return e.h===2&&(ve(t,r,(e=Wo(e))===""?void 0:e),!0)},Vi,zo),D=ye(function(e,t,r){return e.h===2&&(ve(t,r,Wo(e)),!0)},Vi,zo),ie=function(e,t,r=Yo){return new er(e,t,r)}(function(e,t,r,n,o){return e.h===2&&(n=xt(void 0,n,!0),Qt(t,G(t),r,!0).push(n),wr(e,n,o),!0)},function(e,t,r,n,o){if(Array.isArray(t))for(let s=0;s<t.length;s++)ji(e,t[s],r,n,o)}),N=pn(function(e,t,r,n,o,s){return e.h===2&&(gi(t,re(t),s,r),wr(e,t=Do(t,n,r),o),!0)},ji),Hi=ye(function(e,t,r){return e.h===2&&(ve(t,r,Ai(e)),!0)},Wi,Ci),t2=rr(function(e,t,r){return(e.h===0||e.h===2)&&(t=Qt(t,G(t),r,!1,!1),e.h==2?ln(e,ut,t):t.push(ut(e.g)),!0)},function(e,t,r){if((t=tr(ii,t))!=null)for(let a=0;a<t.length;a++){var n=e,o=r,s=t[a];s!=null&&(Se(n,o,0),Zt(n.g,s))}},ki),r2=ye(function(e,t,r){return e.h===0&&(ve(t,r,(e=ut(e.g))===0?void 0:e),!0)},function(e,t,r){(t=ii(t))!=null&&t!=null&&(Se(e,r,0),Zt(e.g,t))},ki),We=ye(function(e,t,r){return e.h===0&&(ve(t,r,Et(e.g)),!0)},function(e,t,r){(t=qt(t))!=null&&(t=parseInt(t,10),Se(e,r,0),dn(e.g,t))},Li),ao=class{constructor(t,r){this.h=t,this.g=r,this.l=O,this.m=T,this.defaultValue=void 0}};function Ye(e,t){return new ao(e,t)}function Rt(e,t){return(r,n)=>{if(Ur.length){let s=Ur.pop();s.o(n),jn(s.g,r,n),r=s}else r=new class{constructor(s,a){if(Js.length){let i=Js.pop();jn(i,s,a),s=i}else s=new class{constructor(i,c){this.h=null,this.m=!1,this.g=this.l=this.j=0,jn(this,i,c)}clear(){this.h=null,this.m=!1,this.g=this.l=this.j=0,this.ca=!1}}(s,a);this.g=s,this.l=this.g.g,this.h=this.m=-1,this.o(a)}o({ga:s=!1}={}){this.ga=s}}(r,n);try{let s=new e,a=s.u;Zo(t)(a,r);var o=s}finally{r.g.clear(),r.m=-1,r.h=-1,Ur.length<100&&Ur.push(r)}return o}}function vn(e){return function(){let t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){let a=this.g;return this.g=[],a}}}};Bi(this.u,t,Ft(mn,gn,xn,e)),Wt(t,t.g.end());let r=new Uint8Array(t.h),n=t.l,o=n.length,s=0;for(let a=0;a<o;a++){let i=n[a];r.set(i,s),s+=i.length}return t.l=[r],r}}var na=class extends g{constructor(e){super(e)}},oa=[0,pt,ye(function(e,t,r){return e.h===2&&(ve(t,r,(e=Ai(e))===Mt()?void 0:e),!0)},function(e,t,r){if(t!=null){if(t instanceof g){let n=t.Qa;return void(n&&(t=n(t),t!=null&&fn(e,r,Go(t).buffer)))}if(Array.isArray(t))return}Wi(e,t,r)},Ci)],Xn,sa=globalThis.trustedTypes;function aa(e){Xn===void 0&&(Xn=function(){let r=null;if(!sa)return r;try{let n=o=>o;r=sa.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}());var t=Xn;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function n2(e,...t){if(t.length===0)return aa(e[0]);let r=e[0];for(let n=0;n<t.length;n++)r+=encodeURIComponent(t[n])+e[n+1];return aa(r)}var Yi=[0,ee,We,q,-1,yn,We,-1],o2=class extends g{constructor(){super()}},zi=[0,q,D,q,We,-1,rr(function(e,t,r){return(e.h===0||e.h===2)&&(t=Qt(t,G(t),r,!1,!1),e.h==2?ln(e,Yu,t):t.push(Et(e.g)),!0)},function(e,t,r){if((t=tr(qt,t))!=null&&t.length){r=Xo(e,r);for(let n=0;n<t.length;n++)dn(e.g,t[n]);Ho(e,r)}},Li),D,-1,[0,q,-1],We,q,-1],Ki=[0,D,-2],ia=class extends g{constructor(){super()}},$i=[0],qi=[0,ee,q,1,q,-3],ke=class extends g{constructor(e){super(e,2)}},se={};se[336783863]=[0,D,q,-1,ee,[0,[1,2,3,4,5,6,7],N,$i,N,zi,N,Ki,N,qi,N,Yi,N,[0,D,-2],N,[0,D,We]],[0,D],q,[0,[1,3],[2,4],N,[0,yn],-1,N,[0,fe],-1,ie,[0,D,-1]],D];var ca=[0,Wn,-1,Dt,-3,Wn,yn,pt,Pt,Wn,-1,Dt,Pt,Dt,-2,pt];function Ce(e,t){to(e,2,Jt(t),"")}function H(e,t){hn(e,3,t)}function F(e,t){hn(e,4,t)}var xe=class extends g{constructor(e){super(e,500)}o(e){return T(this,0,7,e)}},gr=[-1,{}],ua=[0,D,1,gr],ha=[0,D,fe,gr];function Le(e,t){$r(e,1,xe,t)}function Y(e,t){hn(e,10,t)}function P(e,t){hn(e,15,t)}var be=class extends g{constructor(e){super(e,500)}o(e){return T(this,0,1001,e)}},Ji=[-500,ie,[-500,pt,-1,fe,-3,[-2,se,q],ie,oa,Pt,-1,ua,ha,ie,[0,pt,Dt],pt,ca,Pt,fe,987,fe],4,ie,[-500,D,-1,[-1,{}],998,D],ie,[-500,D,fe,-1,[-2,{},q],997,fe,-1],Pt,ie,[-500,D,fe,gr,998,fe],fe,Pt,ua,ha,ie,[0,pt,-1,gr],fe,-2,ca,pt,-1,Dt,[0,Dt,r2],978,gr,ie,oa];be.prototype.g=vn(Ji);var s2=Rt(be,Ji),a2=class extends g{constructor(e){super(e)}},Qi=class extends g{constructor(e){super(e)}g(){return ct(this,a2,1)}},Zi=[0,ie,[0,ee,ce,D,-1]],En=Rt(Qi,Zi),i2=class extends g{constructor(e){super(e)}},c2=class extends g{constructor(e){super(e)}},Hn=class extends g{constructor(e){super(e)}h(){return O(this,i2,2)}g(){return ct(this,c2,5)}},ec=Rt(class extends g{constructor(e){super(e)}},[0,fe,yn,es,[0,We,[0,ee,-3],[0,ce,-3],[0,ee,-1,[0,ie,[0,ee,-2]]],ie,[0,ce,-1,D,ce]],D,-1,bt,ie,[0,ee,ce],fe,bt]),tc=class extends g{constructor(e){super(e)}},Nt=Rt(class extends g{constructor(e){super(e)}},[0,ie,[0,ce,-4]]),rc=class extends g{constructor(e){super(e)}},kr=Rt(class extends g{constructor(e){super(e)}},[0,ie,[0,ce,-4]]),u2=class extends g{constructor(e){super(e)}},h2=[0,ee,-1,es,We],nc=class extends g{constructor(){super()}};nc.prototype.g=vn([0,ce,-4,bt]);var l2=class extends g{constructor(e){super(e)}},d2=Rt(class extends g{constructor(e){super(e)}},[0,ie,[0,1,ee,D,Zi],bt]),la=class extends g{constructor(e){super(e)}},f2=class extends g{constructor(e){super(e)}pa(){let e=pi(this);return e??Mt()}},p2=class extends g{constructor(e){super(e)}},oc=[1,2],m2=Rt(class extends g{constructor(e){super(e)}},[0,ie,[0,oc,N,[0,es],N,[0,Hi],ee,D],bt]),ts=class extends g{constructor(e){super(e)}},sc=[0,D,ee,ce,fe,-1],da=class extends g{constructor(e){super(e)}},g2=[0,q,-1],fa=class extends g{constructor(e){super(e)}},Gr=[1,2,3,4,5],Zr=class extends g{constructor(e){super(e)}g(){return pi(this)!=null}h(){return gt(vt(this,2))!=null}},$=class extends g{constructor(e){super(e)}g(){return ai(vt(this,2))??!1}},ac=[0,Hi,D,[0,ee,bt,-1],[0,e2,bt]],ne=[0,ac,q,[0,Gr,N,qi,N,zi,N,Yi,N,$i,N,Ki],We],bn=class extends g{constructor(e){super(e)}},rs=[0,ne,ce,-1,ee],x2=Ye(502141897,bn);se[502141897]=rs;var y2=Rt(class extends g{constructor(e){super(e)}},[0,[0,We,-1,Zu,t2],h2]),ic=class extends g{constructor(e){super(e)}},cc=class extends g{constructor(e){super(e)}},ns=[0,ne,ce,[0,ne],q],uc=[0,ne,rs,ns,ce,[0,[0,ac]]],v2=Ye(508968150,cc);se[508968150]=uc,se[508968149]=ns;var hc=class extends g{constructor(e){super(e)}},E2=Ye(513916220,hc);se[513916220]=[0,ne,uc,ee];var Ut=class extends g{constructor(e){super(e)}h(){return O(this,ts,2)}g(){X(this,2)}},lc=[0,ne,sc];se[478825465]=lc;var b2=class extends g{constructor(e){super(e)}},dc=class extends g{constructor(e){super(e)}},os=class extends g{constructor(e){super(e)}},ss=class extends g{constructor(e){super(e)}},fc=class extends g{constructor(e){super(e)}},pa=[0,ne,[0,ne],lc,-1],pc=[0,ne,ce,ee],as=[0,ne,ce],mc=[0,ne,pc,as,ce],T2=Ye(479097054,fc);se[479097054]=[0,ne,mc,pa],se[463370452]=pa,se[464864288]=pc;var _2=Ye(462713202,ss);se[462713202]=mc,se[474472470]=as;var A2=class extends g{constructor(e){super(e)}},gc=class extends g{constructor(e){super(e)}},xc=class extends g{constructor(e){super(e)}},yc=class extends g{constructor(){super()}},is=[0,ne,ce,-1,ee],io=[0,ne,ce,q];yc.prototype.g=vn([0,ne,as,[0,ne],rs,ns,is,io]);var vc=class extends g{constructor(e){super(e)}},R2=Ye(456383383,vc);se[456383383]=[0,ne,sc];var Ec=class extends g{constructor(e){super(e)}},w2=Ye(476348187,Ec);se[476348187]=[0,ne,g2];var bc=class extends g{constructor(e){super(e)}},ma=class extends g{constructor(e){super(e)}},Tc=[0,We,-1],k2=Ye(458105876,class extends g{constructor(e){super(e)}g(){var e=this.u;let t=G(e),r=2&t;return e=function(n,o,s){var a=ma;let i=2&o,c=!1;if(s==null){if(i)return $s();s=[]}else if(s.constructor===Pe){if((2&s.M)==0||i)return s;s=s.Y()}else Array.isArray(s)?c=!!(2&re(s)):s=[];if(i){if(!s.length)return $s();c||(c=!0,$t(s))}else c&&(c=!1,s=mi(s));return c||(64&re(s)?Jn(s,32):32&o&&rn(s,32)),J(n,o,2,a=new Pe(s,a,Bu,void 0)),a}(e,t,ht(e,t,2)),!r&&ma&&(e.sa=!0),e}});se[458105876]=[0,Tc,Qu,[!0,bt,[0,D,-1,fe]]];var cs=class extends g{constructor(e){super(e)}},_c=Ye(458105758,cs);se[458105758]=[0,ne,D,Tc];var Ac=class extends g{constructor(e){super(e)}},S2=Ye(443442058,Ac);se[443442058]=[0,ne,D,ee,ce,fe,-1],se[514774813]=is;var Rc=class extends g{constructor(e){super(e)}},C2=Ye(516587230,Rc);function co(e,t){return t=t?t.clone():new ts,e.displayNamesLocale!==void 0?X(t,1,Jt(e.displayNamesLocale)):e.displayNamesLocale===void 0&&X(t,1),e.maxResults!==void 0?tt(t,2,e.maxResults):"maxResults"in e&&X(t,2),e.scoreThreshold!==void 0?y(t,3,e.scoreThreshold):"scoreThreshold"in e&&X(t,3),e.categoryAllowlist!==void 0?qr(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&X(t,4),e.categoryDenylist!==void 0?qr(t,5,e.categoryDenylist):"categoryDenylist"in e&&X(t,5),t}function us(e,t=-1,r=""){return{categories:e.map(n=>({index:je(Oe(n,1),0)??-1,score:te(n,2)??0,categoryName:et(n,3)??"",displayName:et(n,4)??""})),headIndex:t,headName:r}}function wc(e){var t=Ct(e,3,At,St()),r=Ct(e,2,qt,St()),n=Ct(e,1,gt,St()),o=Ct(e,9,gt,St());let s={categories:[],keypoints:[]};for(let a=0;a<t.length;a++)s.categories.push({score:t[a],index:r[a]??-1,categoryName:n[a]??"",displayName:o[a]??""});if((t=O(e,Hn,4)?.h())&&(s.boundingBox={originX:Oe(t,1)??0,originY:Oe(t,2)??0,width:Oe(t,3)??0,height:Oe(t,4)??0,angle:0}),O(e,Hn,4)?.g().length)for(let a of O(e,Hn,4).g())s.keypoints.push({x:Dr(a,1)??0,y:Dr(a,2)??0,score:Dr(a,4)??0,label:gt(vt(a,3))??""});return s}function Tn(e){let t=[];for(let r of ct(e,rc,1))t.push({x:te(r,1)??0,y:te(r,2)??0,z:te(r,3)??0,visibility:te(r,4)??0});return t}function xr(e){let t=[];for(let r of ct(e,tc,1))t.push({x:te(r,1)??0,y:te(r,2)??0,z:te(r,3)??0,visibility:te(r,4)??0});return t}function ga(e){return Array.from(e,t=>t>127?t-256:t)}function xa(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let r=0,n=0,o=0;for(let s=0;s<e.length;s++)r+=e[s]*t[s],n+=e[s]*e[s],o+=t[s]*t[s];if(n<=0||o<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(n*o)}var Or;se[516587230]=[0,ne,is,io,ce],se[518928384]=io;var L2=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function kc(){if(Or===void 0)try{await WebAssembly.instantiate(L2),Or=!0}catch{Or=!1}return Or}async function hr(e,t=n2``){let r=await kc()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var dt=class{};function Sc(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function ya(e){if(typeof importScripts!="function"){let t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise((r,n)=>{t.addEventListener("load",()=>{r()},!1),t.addEventListener("error",o=>{n(o)},!1),document.body.appendChild(t)})}importScripts(e.toString())}function Cc(e){return e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height]}function v(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function va(e,t,r){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(r?e.i._bindTextureToStream(r):e.i._bindTextureToCanvas(),!(r=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);let[n,o]=Cc(t);return!e.l||n===e.i.canvas.width&&o===e.i.canvas.height||(e.i.canvas.width=n,e.i.canvas.height=o),[n,o]}function Ea(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");let n=new Uint32Array(t.length);for(let o=0;o<t.length;o++)n[o]=e.i.stringToNewUTF8(t[o]);t=e.i._malloc(4*n.length),e.i.HEAPU32.set(n,t>>2),r(t);for(let o of n)e.i._free(o);e.i._free(t)}function qe(e,t,r){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=r}function lt(e,t,r){let n=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(o,s,a)=>{s?(r(n,a),n=[]):n.push(o)}}dt.forVisionTasks=function(e){return hr("vision",e)},dt.forTextTasks=function(e){return hr("text",e)},dt.forGenAiExperimentalTasks=function(e){return hr("genai_experimental",e)},dt.forGenAiTasks=function(e){return hr("genai",e)},dt.forAudioTasks=function(e){return hr("audio",e)},dt.isSimdSupported=function(){return kc()};async function I2(e,t,r,n){return e=await(async(o,s,a,i,c)=>{if(s&&await ya(s),!self.ModuleFactory||a&&(await ya(a),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&c&&((s=self.Module).locateFile=c.locateFile,c.mainScriptUrlOrBlob&&(s.mainScriptUrlOrBlob=c.mainScriptUrlOrBlob)),c=await self.ModuleFactory(self.Module||c),self.ModuleFactory=self.Module=void 0,new o(c,i)})(e,r.wasmLoaderPath,r.assetLoaderPath,t,{locateFile:o=>o.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&o.endsWith(".data")?r.assetBinaryPath.toString():o}),await e.o(n),e}function Yn(e,t){let r=O(e.baseOptions,Zr,1)||new Zr;typeof t=="string"?(X(r,2,Jt(t)),X(r,1)):t instanceof Uint8Array&&(X(r,1,_o(t,!1)),X(r,2)),T(e.baseOptions,0,1,r)}function ba(e){try{let t=e.H.length;if(t===1)throw Error(e.H[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.H.map(r=>r.message).join(", "))}finally{e.H=[]}}function m(e,t){e.B=Math.max(e.B,t)}function _n(e,t){e.A=new xe,Ce(e.A,"PassThroughCalculator"),H(e.A,"free_memory"),F(e.A,"free_memory_unused_out"),Y(t,"free_memory"),Le(t,e.A)}function Xt(e,t){H(e.A,t),F(e.A,t+"_unused_out")}function An(e){e.g.addBoolToStream(!0,"free_memory",e.B)}var Vr=class{constructor(e){this.g=e,this.H=[],this.B=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){if(t){let r=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(O(this.baseOptions,Zr,1)?.g()||O(this.baseOptions,Zr,1)?.h()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(n,o){let s=O(n.baseOptions,fa,3);if(!s){var a=s=new fa,i=new ia;mr(a,4,Gr,i)}"delegate"in o&&(o.delegate==="GPU"?(o=s,a=new o2,mr(o,2,Gr,a)):(o=s,a=new ia,mr(o,4,Gr,a))),T(n.baseOptions,0,3,s)}(this,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then(n=>{if(n.ok)return n.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${n.status})`)}).then(n=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(n),!0,!1,!1),Yn(this,"/model.dat"),this.m(),this.J()});if(r.modelAssetBuffer instanceof Uint8Array)Yn(this,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(n){let o=[];for(var s=0;;){let{done:a,value:i}=await n.read();if(a)break;o.push(i),s+=i.length}if(o.length===0)return new Uint8Array(0);if(o.length===1)return o[0];n=new Uint8Array(s),s=0;for(let a of o)n.set(a,s),s+=a.length;return n}(r.modelAssetBuffer).then(n=>{Yn(this,n),this.m(),this.J()})}return this.m(),this.J(),Promise.resolve()}J(){}ea(){let e;if(this.g.ea(t=>{e=s2(t)}),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener((r,n)=>{this.H.push(Error(n))}),this.g.La(),this.g.setGraph(e,t),this.A=void 0,ba(this)}finishProcessing(){this.g.finishProcessing(),ba(this)}close(){this.A=void 0,this.g.closeGraph()}};function ge(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}Vr.prototype.close=Vr.prototype.close,za("TaskRunner",Vr);var uo=class{constructor(t,r,n,o){this.g=t,this.h=r,this.m=n,this.l=o}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}};function Ta(e,t,r){let n=e.g;if(r=ge(n.createShader(r),"Failed to create WebGL shader"),n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${n.getShaderInfoLog(r)}`);return n.attachShader(e.h,r),r}function _a(e,t){let r=e.g,n=ge(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);let o=ge(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,o),r.enableVertexAttribArray(e.P),r.vertexAttribPointer(e.P,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);let s=ge(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,s),r.enableVertexAttribArray(e.J),r.vertexAttribPointer(e.J,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.bindVertexArray(null),new uo(r,n,o,s)}function hs(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function Sr(e,t,r,n){return hs(e,t),e.h||(e.m(),e.C()),r?(e.s||(e.s=_a(e,!0)),r=e.s):(e.v||(e.v=_a(e,!1)),r=e.v),t.useProgram(e.h),r.bind(),e.l(),e=n(),r.g.bindVertexArray(null),e}function Tt(e,t,r){return hs(e,t),e=ge(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r??t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r??t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),e}function Rn(e,t,r){hs(e,t),e.A||(e.A=ge(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.A),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0)}function ls(e){e.g?.bindFramebuffer(e.g.FRAMEBUFFER,null)}var nr=class{H(){return`
1
+ var It=typeof self<"u"?self:{};function za(e,t){e=e.split(".");var r,n=It;for((e[0]in n)||n.execScript===void 0||n.execScript("var "+e[0]);e.length&&(r=e.shift());)e.length||t===void 0?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=t}function kt(){throw Error("Invalid UTF8")}function Fs(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var Ir,On,xu=typeof TextDecoder<"u",yu,vu=typeof TextEncoder<"u";function Ka(e){if(vu)e=(yu||(yu=new TextEncoder)).encode(e);else{let r=0,n=new Uint8Array(3*e.length);for(let o=0;o<e.length;o++){var t=e.charCodeAt(o);if(t<128)n[r++]=t;else{if(t<2048)n[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&o<e.length){let s=e.charCodeAt(++o);if(s>=56320&&s<=57343){t=1024*(t-55296)+s-56320+65536,n[r++]=t>>18|240,n[r++]=t>>12&63|128,n[r++]=t>>6&63|128,n[r++]=63&t|128;continue}o--}t=65533}n[r++]=t>>12|224,n[r++]=t>>6&63|128}n[r++]=63&t|128}}e=r===n.length?n:n.subarray(0,r)}return e}var xo,Xr;e:{for(Pn=["CLOSURE_FLAGS"],Mr=It,Fr=0;Fr<Pn.length;Fr++)if((Mr=Mr[Pn[Fr]])==null){Xr=null;break e}Xr=Mr}var Pn,Mr,Fr,yr,Us=Xr&&Xr[610401301];xo=Us!=null&&Us;var Os=It.navigator;function $n(e){return!!xo&&!!yr&&yr.brands.some(({brand:t})=>t&&t.indexOf(e)!=-1)}function Ue(e){var t;return(t=It.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function ft(){return!!xo&&!!yr&&yr.brands.length>0}function Bn(){return ft()?$n("Chromium"):(Ue("Chrome")||Ue("CriOS"))&&!(!ft()&&Ue("Edge"))||Ue("Silk")}function yo(e){return yo[" "](e),e}yr=Os&&Os.userAgentData||null,yo[" "]=function(){};var Eu=!ft()&&(Ue("Trident")||Ue("MSIE"));!Ue("Android")||Bn(),Bn(),Ue("Safari")&&(Bn()||!ft()&&Ue("Coast")||!ft()&&Ue("Opera")||!ft()&&Ue("Edge")||(ft()?$n("Microsoft Edge"):Ue("Edg/"))||ft()&&$n("Opera"));var $a={},dr=null;function bu(e){let t=e.length,r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);let n=new Uint8Array(r),o=0;return function(s,a){function i(l){for(;c<s.length;){let h=s.charAt(c++),p=dr[h];if(p!=null)return p;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return l}qa();let c=0;for(;;){let l=i(-1),h=i(0),p=i(64),d=i(64);if(d===64&&l===-1)break;a(l<<2|h>>4),p!=64&&(a(h<<4&240|p>>2),d!=64&&a(p<<6&192|d))}}(e,function(s){n[o++]=s}),o!==r?n.subarray(0,o):n}function qa(){if(!dr){dr={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=e.concat(t[r].split(""));$a[r]=n;for(let o=0;o<n.length;o++){let s=n[o];dr[s]===void 0&&(dr[s]=o)}}}}var Ja=typeof Uint8Array<"u",Qa=!Eu&&typeof btoa=="function";function Ps(e){if(!Qa){var t;t===void 0&&(t=0),qa(),t=$a[t];var r=Array(Math.floor(e.length/3)),n=t[64]||"";let c=0,l=0;for(;c<e.length-2;c+=3){var o=e[c],s=e[c+1],a=e[c+2],i=t[o>>2];o=t[(3&o)<<4|s>>4],s=t[(15&s)<<2|a>>6],a=t[63&a],r[l++]=i+o+s+a}switch(i=0,a=n,e.length-c){case 2:a=t[(15&(i=e[c+1]))<<2]||n;case 1:e=e[c],r[l]=t[e>>2]+t[(3&e)<<4|i>>4]+a+n}return r.join("")}for(t="",r=0,n=e.length-10240;r<n;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}var Bs=/[-_.]/g,Tu={"-":"+",_:"/",".":"="};function _u(e){return Tu[e]||""}function Za(e){if(!Qa)return bu(e);Bs.test(e)&&(e=e.replace(Bs,_u)),e=atob(e);let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function _r(e){return Ja&&e!=null&&e instanceof Uint8Array}var Gt={};function Mt(){return Au||(Au=new at(null,Gt))}function vo(e){ei(Gt);var t=e.g;return(t=t==null||_r(t)?t:typeof t=="string"?Za(t):null)==null?t:e.g=t}var at=class{h(){return new Uint8Array(vo(this)||0)}constructor(e,t){if(ei(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}},Au,Ru;function ei(e){if(e!==Gt)throw Error("illegal external caller")}function ti(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function ri(){let e=Error();ti(e,"incident"),function(t){It.setTimeout(()=>{throw t},0)}(e)}function qn(e){return ti(e=Error(e),"warning"),e}function Eo(){return typeof BigInt=="function"}function we(e){return Array.prototype.slice.call(e)}var Kt=typeof Symbol=="function"&&typeof Symbol()=="symbol";function tn(e){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol():e}var Ar=tn(),Ds=tn("0di"),Dn=tn("2ex"),ir=tn("1oa"),rn=Kt?(e,t)=>{e[Ar]|=t}:(e,t)=>{e.G!==void 0?e.G|=t:Object.defineProperties(e,{G:{value:t,configurable:!0,writable:!0,enumerable:!1}})},Jn=Kt?(e,t)=>{e[Ar]&=~t}:(e,t)=>{e.G!==void 0&&(e.G&=~t)},re=Kt?e=>0|e[Ar]:e=>0|e.G,G=Kt?e=>e[Ar]:e=>e.G,oe=Kt?(e,t)=>{e[Ar]=t}:(e,t)=>{e.G!==void 0?e.G=t:Object.defineProperties(e,{G:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function $t(e){return rn(e,34),e}function wu(e,t){oe(t,-30975&(0|e))}function Qn(e,t){oe(t,-30941&(34|e))}var bo,Rr={},ni={};function Ns(e){return!(!e||typeof e!="object"||e.Ia!==ni)}function To(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function _o(e,t){if(e!=null){if(typeof e=="string")e=e?new at(e,Gt):Mt();else if(e.constructor!==at)if(_r(e))e=e.length?new at(new Uint8Array(e),Gt):Mt();else{if(!t)throw Error();e=void 0}}return e}function Hr(e){return!(!Array.isArray(e)||e.length)&&!!(1&re(e))}var Gs=[];function _t(e){if(2&e)throw Error()}oe(Gs,55),bo=Object.freeze(Gs);var Yr=class e{constructor(t,r,n){this.l=0,this.g=t,this.h=r,this.m=n}next(){if(this.l<this.g.length){let t=this.g[this.l++];return{done:!1,value:this.h?this.h.call(this.m,t):t}}return{done:!0,value:void 0}}[Symbol.iterator](){return new e(this.g,this.h,this.m)}},mt;function oi(e,t){(t=mt?t[mt]:void 0)&&(e[mt]=we(t))}var ku=Object.freeze({});function nn(e){return e.Pa=!0,e}var Su=nn(e=>typeof e=="number"),Vs=nn(e=>typeof e=="string"),Cu=nn(e=>typeof e=="boolean"),on=typeof It.BigInt=="function"&&typeof It.BigInt(0)=="bigint",Zn=nn(e=>on?e>=Iu&&e<=Fu:e[0]==="-"?js(e,Lu):js(e,Mu)),Lu=Number.MIN_SAFE_INTEGER.toString(),Iu=on?BigInt(Number.MIN_SAFE_INTEGER):void 0,Mu=Number.MAX_SAFE_INTEGER.toString(),Fu=on?BigInt(Number.MAX_SAFE_INTEGER):void 0;function js(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){let n=e[r],o=t[r];if(n>o)return!1;if(n<o)return!0}}var Uu=typeof Uint8Array.prototype.slice=="function",si,V=0,Z=0;function Ws(e){let t=e>>>0;V=t,Z=(e-t)/4294967296>>>0}function Vt(e){if(e<0){Ws(-e);let[t,r]=ko(V,Z);V=t>>>0,Z=r>>>0}else Ws(e)}function Ao(e){let t=si||(si=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),Z=0,V=t.getUint32(0,!0)}function Ro(e,t){let r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:vr(e,t)}function wo(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Ro(e,t))=="number"?r?-e:e:r?"-"+e:e}function vr(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else Eo()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+Xs(r)+Xs(e));return r}function Xs(e){return e=String(e),"0000000".slice(e.length)+e}function sn(e){if(e.length<16)Vt(Number(e));else if(Eo())e=BigInt(e),V=Number(e&BigInt(4294967295))>>>0,Z=Number(e>>BigInt(32)&BigInt(4294967295));else{let t=+(e[0]==="-");Z=V=0;let r=e.length;for(let n=t,o=(r-t)%6+t;o<=r;n=o,o+=6){let s=Number(e.slice(n,o));Z*=1e6,V=1e6*V+s,V>=4294967296&&(Z+=Math.trunc(V/4294967296),Z>>>=0,V>>>=0)}if(t){let[n,o]=ko(V,Z);V=n,Z=o}}}function ko(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function At(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function ai(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}var Ou=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function an(e){let t=typeof e;switch(t){case"bigint":return!0;case"number":return Number.isFinite(e)}return t==="string"&&Ou.test(e)}function qt(e){if(e==null)return e;if(typeof e=="string"){if(!e)return;e=+e}return typeof e=="number"&&Number.isFinite(e)?0|e:void 0}function ii(e){if(e==null)return e;if(typeof e=="string"){if(!e)return;e=+e}return typeof e=="number"&&Number.isFinite(e)?e>>>0:void 0}function Hs(e){return e[0]!=="-"&&(e.length<20||e.length===20&&Number(e.substring(0,6))<184467)}function So(e){return e=Math.trunc(e),Number.isSafeInteger(e)||(Vt(e),e=wo(V,Z)),e}function Co(e){var t=Math.trunc(Number(e));if(Number.isSafeInteger(t))return String(t);if((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),!(e[0]==="-"?e.length<20||e.length===20&&Number(e.substring(0,7))>-922337:e.length<19||e.length===19&&Number(e.substring(0,6))<922337))if(sn(e),e=V,2147483648&(t=Z))if(Eo())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,n]=ko(e,t);e="-"+vr(r,n)}else e=vr(e,t);return e}function zr(e){return e==null?e:typeof e=="bigint"?(Zn(e)?e=Number(e):(e=BigInt.asIntN(64,e),e=Zn(e)?Number(e):String(e)),e):an(e)?typeof e=="number"?So(e):Co(e):void 0}function Pu(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(BigInt.asUintN(64,e));if(an(e)){if(t==="string")return t=Math.trunc(Number(e)),Number.isSafeInteger(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Hs(e)||(sn(e),e=vr(V,Z))),e;if(t==="number")return(e=Math.trunc(e))>=0&&Number.isSafeInteger(e)?e:function(r){if(r<0){Vt(r);var n=vr(V,Z);return r=Number(n),Number.isSafeInteger(r)?r:n}return Hs(n=String(r))?n:(Vt(r),Ro(V,Z))}(e)}}function ci(e){if(typeof e!="string")throw Error();return e}function Jt(e){if(e!=null&&typeof e!="string")throw Error();return e}function gt(e){return e==null||typeof e=="string"?e:void 0}function Lo(e,t,r,n){if(e!=null&&typeof e=="object"&&e.X===Rr)return e;if(!Array.isArray(e))return r?2&n?(e=t[Ds])?t=e:($t((e=new t).u),t=t[Ds]=e):t=new t:t=void 0,t;let o=r=re(e);return o===0&&(o|=32&n),o|=2&n,o!==r&&oe(e,o),new t(e)}function Bu(e,t,r){if(t)e:{if(!an(t=e))throw qn("int64");switch(typeof t){case"string":t=Co(t);break e;case"bigint":if(e=t=BigInt.asIntN(64,t),Vs(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(Su(e)&&!Number.isSafeInteger(e))throw Error(String(e));t=on?BigInt(t):Cu(t)?t?"1":"0":Vs(t)?t.trim()||"0":String(t);break e;default:t=So(t)}}else t=zr(e);return typeof(r=(e=t)==null?r?0:void 0:e)=="string"&&(t=+r,Number.isSafeInteger(t))?t:r}function ui(e){var t;return cr===void 0&&(cr=typeof Proxy=="function"?Ys(Proxy):null),(t=!cr)||(ur===void 0&&(ur=typeof WeakMap=="function"?Ys(WeakMap):null),t=!ur),t?e:(t=jt?.get(e))?t:Math.random()>.01?e:(function(r){if(Nn===void 0){let n=new cr([],{});Nn=Array.prototype.concat.call([],n).length===1}Nn&&typeof Symbol=="function"&&Symbol.isConcatSpreadable&&(r[Symbol.isConcatSpreadable]=!0)}(e),function(r,n){(jt||(jt=new ur)).set(r,n),(hi||(hi=new ur)).set(n,r)}(e,t=new cr(e,{set:(r,n,o)=>(ri(),r[n]=o,!0)})),t)}var jt,hi,cr,ur,Nn,Kr,li,Du;function Ys(e){try{return e.toString().indexOf("[native code]")!==-1?e:null}catch{return null}}function xt(e,t,r){return e=di(e,t[0],t[1],r?1:2),t!==li&&r&&rn(e,16384),e}function di(e,t,r,n){if(n=n??0,e==null&&(e=Kr),Kr=void 0,e==null){var o=96;r?(e=[r],o|=512):e=[],t&&(o=-33521665&o|(1023&t)<<15)}else{if(!Array.isArray(e))throw Error("narr");if(2048&(o=re(e)))throw Error("farr");if(64&o)return e;if(n===1||n===2||(o|=64),r&&(o|=512,r!==e[0]))throw Error("mid");e:{if(n=(r=e).length){let s=n-1;if(To(r[s])){if((t=s-(+!!(512&(o|=256))-1))>=1024)throw Error("pvtlmt");o=-33521665&o|(1023&t)<<15;break e}}if(t){if((t=Math.max(t,n-(+!!(512&o)-1)))>1024)throw Error("spvt");o=-33521665&o|(1023&t)<<15}}}return oe(e,o),e}var Nu={},Gu=function(){try{return yo(new class extends Map{constructor(){super()}}),!1}catch{return!0}}(),pr=class{constructor(){this.g=new Map}get(t){return this.g.get(t)}set(t,r){return this.g.set(t,r),this.size=this.g.size,this}delete(t){return t=this.g.delete(t),this.size=this.g.size,t}clear(){this.g.clear(),this.size=this.g.size}has(t){return this.g.has(t)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(t,r){return this.g.forEach(t,r)}[Symbol.iterator](){return this.entries()}},Vu=Gu?(Object.setPrototypeOf(pr.prototype,Map.prototype),Object.defineProperties(pr.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),pr):class extends Map{constructor(){super()}};function zs(e){return e}function Gn(e){if(2&e.M)throw Error("Cannot mutate an immutable Map")}var Pe=class extends Vu{constructor(e,t,r=zs,n=zs){super();let o=re(e);o|=64,oe(e,o),this.M=o,this.T=t,this.S=r,this.Z=this.T?ju:n;for(let s=0;s<e.length;s++){let a=e[s],i=r(a[0],!1,!0),c=a[1];t?c===void 0&&(c=null):c=n(a[1],!1,!0,void 0,void 0,o),super.set(i,c)}}oa(e=Ks){if(this.size!==0)return this.Y(e)}Y(e=Ks){let t=[],r=super.entries();for(var n;!(n=r.next()).done;)(n=n.value)[0]=e(n[0]),n[1]=e(n[1]),t.push(n);return t}clear(){Gn(this),super.clear()}delete(e){return Gn(this),super.delete(this.S(e,!0,!1))}entries(){var e=this.na();return new Yr(e,Wu,this)}keys(){return this.Ha()}values(){var e=this.na();return new Yr(e,Pe.prototype.get,this)}forEach(e,t){super.forEach((r,n)=>{e.call(t,this.get(n),n,this)})}set(e,t){return Gn(this),(e=this.S(e,!0,!1))==null?this:t==null?(super.delete(e),this):super.set(e,this.Z(t,!0,!0,this.T,!1,this.M))}Na(e){let t=this.S(e[0],!1,!0);e=e[1],e=this.T?e===void 0?null:e:this.Z(e,!1,!0,void 0,!1,this.M),super.set(t,e)}has(e){return super.has(this.S(e,!1,!1))}get(e){e=this.S(e,!1,!1);let t=super.get(e);if(t!==void 0){var r=this.T;return r?((r=this.Z(t,!1,!0,r,this.sa,this.M))!==t&&super.set(e,r),r):t}}na(){return Array.from(super.keys())}Ha(){return super.keys()}[Symbol.iterator](){return this.entries()}};function ju(e,t,r,n,o,s){return e=Lo(e,n,r,s),o&&(e=un(e)),e}function Ks(e){return e}function Wu(e){return[e,this.get(e)]}var Xu;function $s(){return Xu||(Xu=new Pe($t([]),void 0,void 0,void 0,Nu))}function Io(e,t,r,n,o){if(e!=null){if(Array.isArray(e))e=Hr(e)?void 0:o&&2&re(e)?e:cn(e,t,r,n!==void 0,o);else if(To(e)){let s={};for(let a in e)s[a]=Io(e[a],t,r,n,o);e=s}else e=t(e,n);return e}}function cn(e,t,r,n,o){let s=n||r?re(e):0;n=n?!!(32&s):void 0;let a=we(e);for(let i=0;i<a.length;i++)a[i]=Io(a[i],t,r,n,o);return r&&(oi(a,e),r(s,a)),a}function Hu(e){return Io(e,Mo,void 0,void 0,!1)}function Mo(e){return e.X===Rr?e.toJSON():e instanceof Pe?e.oa(Hu):function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return Zn(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(Hr(t))return}else{if(_r(t))return Ps(t);if(t instanceof at){let r=t.g;return r==null?"":typeof r=="string"?r:t.g=Ps(r)}if(t instanceof Pe)return t.oa()}}return t}(e)}function eo(e,t,r=Qn){if(e!=null){if(Ja&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var n=re(e);return 2&n?e:(t&&(t=n===0||!!(32&n)&&!(64&n||!(16&n))),t?(oe(e,-12293&(34|n)),e):cn(e,eo,4&n?Qn:r,!0,!0))}return e.X===Rr?(r=e.u,e=2&(n=G(r))?e:Fo(e,r,n,!0)):e instanceof Pe&&!(2&e.M)&&(r=$t(e.Y(eo)),e=new Pe(r,e.T,e.S,e.Z)),e}}function Fo(e,t,r,n){return e=e.constructor,Kr=t=fi(t,r,n),t=new e(t),Kr=void 0,t}function fi(e,t,r){let n=r||2&t?Qn:wu,o=!!(32&t);return e=function(s,a,i){let c=we(s);var l=c.length;let h=256&a?c[l-1]:void 0;for(l+=h?-1:0,a=512&a?1:0;a<l;a++)c[a]=i(c[a]);if(h){a=c[a]={};for(let p in h)a[p]=i(h[p])}return oi(c,s),c}(e,t,s=>eo(s,o,n)),rn(e,32|(r?2:0)),e}function un(e){let t=e.u,r=G(t);return 2&r?Fo(e,t,r,!1):e}function vt(e,t){return ht(e=e.u,G(e),t)}function qs(e,t,r,n){if(!((t=n+(+!!(512&t)-1))<0||t>=e.length||t>=r))return e[t]}function ht(e,t,r,n){if(r===-1)return null;let o=t>>15&1023||536870912;if(!(r>=o)){var s=e.length;return n&&256&t&&(n=e[s-1][r])!=null?(qs(e,t,o,r)&&Dn!=null&&((t=(e=Ru??(Ru={}))[Dn]||0)>=4||(e[Dn]=t+1,ri())),n):qs(e,t,o,r)}return 256&t?e[e.length-1][r]:void 0}function X(e,t,r){let n=e.u,o=G(n);return _t(o),J(n,o,t,r),e}function J(e,t,r,n){let o=t>>15&1023||536870912;if(r>=o){let s,a=t;if(256&t)s=e[e.length-1];else{if(n==null)return a;s=e[o+(+!!(512&t)-1)]={},a|=256}return s[r]=n,r<o&&(e[r+(+!!(512&t)-1)]=void 0),a!==t&&oe(e,a),a}return e[r+(+!!(512&t)-1)]=n,256&t&&r in(e=e[e.length-1])&&delete e[r],t}function Dr(e,t){e=e.u;let r=G(e),n=ht(e,r,t),o=At(n);return o!=null&&o!==n&&J(e,r,t,o),o}function pi(e){e=e.u;let t=G(e),r=ht(e,t,1),n=_o(r,!0);return n!=null&&n!==r&&J(e,t,1,n),n}function St(){return ku===void 0?2:4}function Ct(e,t,r,n,o){let s=e.u,a=2&(e=G(s))?1:n;o=!!o,n=Uo(s,e,t);var i=re(n);if(!(4&i)){4&i&&(n=we(n),i=it(i,e),e=J(s,e,t,n));let l=0,h=0;for(;l<n.length;l++){let p=r(n[l]);p!=null&&(n[h++]=p)}h<l&&(n.length=h),i=-4097&(20|(i=Oo(i,e))),oe(n,i&=-8193),2&i&&Object.freeze(n)}let c;return a===1||a===4&&32&i?Ve(i)||(o=i,(i|=2)!==o&&oe(n,i),Object.freeze(n)):(r=a===5&&(!!(32&i)||Ve(i)||!!jt?.get(n)),(a===2||r)&&Ve(i)&&(n=we(n),i=yt(i=it(i,e),e,o),oe(n,i),e=J(s,e,t,n)),Ve(i)||(t=i,(i=yt(i,e,o))!==t&&oe(n,i)),r?c=ui(n):a!==2||o||jt?.delete(n)),c||n}function Uo(e,t,r,n){return e=ht(e,t,r,n),Array.isArray(e)?e:bo}function Oo(e,t){return e===0&&(e=it(e,t)),1|e}function Ve(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function mi(e){e=we(e);for(let t=0;t<e.length;t++){let r=e[t]=we(e[t]);Array.isArray(r[1])&&(r[1]=$t(r[1]))}return e}function to(e,t,r,n){e=e.u;let o=G(e);_t(o),J(e,o,t,(n==="0"?Number(r)===0:r===n)?void 0:r)}function Qt(e,t,r,n,o){_t(t);var s=!(!(64&t)&&16384&t);let a=(o=Uo(e,t,r,o))!==bo;if(s||!a){let i=s=a?re(o):0;(!a||2&i||Ve(i)||4&i&&!(32&i))&&(o=we(o),i=it(i,t),t=J(e,t,r,o)),i=-13&Oo(i,t),i=yt(n?-17&i:16|i,t,!0),i!==s&&oe(o,i)}return o}function Vn(e,t){var r=oc;return Bo(Po(e=e.u),e,G(e),r)===t?t:-1}function Po(e){if(Kt)return e[ir]??(e[ir]=new Map);if(ir in e)return e[ir];let t=new Map;return Object.defineProperty(e,ir,{value:t}),t}function gi(e,t,r,n){let o=Po(e),s=Bo(o,e,t,r);return s!==n&&(s&&(t=J(e,t,s)),o.set(r,n)),t}function Bo(e,t,r,n){let o=e.get(n);if(o!=null)return o;o=0;for(let s=0;s<n.length;s++){let a=n[s];ht(t,r,a)!=null&&(o!==0&&(r=J(t,r,o)),o=a)}return e.set(n,o),o}function Do(e,t,r,n){let o,s=G(e);if((n=ht(e,s,r,n))!=null&&n.X===Rr)return(t=un(n))!==n&&J(e,s,r,t),t.u;if(Array.isArray(n)){let a=re(n);o=2&a?xt(fi(n,a,!1),t,!0):64&a?n:xt(o,t,!0)}else o=xt(void 0,t,!0);return o!==n&&J(e,s,r,o),o}function xi(e,t,r,n){e=e.u;let o=G(e);return(t=Lo(n=ht(e,o,r,n),t,!1,o))!==n&&t!=null&&J(e,o,r,t),t}function O(e,t,r,n=!1){if((t=xi(e,t,r,n))==null)return t;if(e=e.u,!(2&(n=G(e)))){let o=un(t);o!==t&&J(e,n,r,t=o)}return t}function yi(e,t,r,n,o,s,a){e=e.u;var i=!!(2&t);o=i?1:o,s=!!s,a&&(a=!i),i=Uo(e,t,n);var c=re(i),l=!!(4&c);if(!l){var h=i,p=t;let g=!!(2&(c=Oo(c,t)));g&&(p|=2);let A=!g,R=!0,S=0,w=0;for(;S<h.length;S++){let f=Lo(h[S],r,!1,p);if(f instanceof r){if(!g){let y=!!(2&re(f.u));A&&(A=!y),R&&(R=y)}h[w++]=f}}w<S&&(h.length=w),c|=4,c=R?16|c:-17&c,oe(h,c=A?8|c:-9&c),g&&Object.freeze(h)}if(a&&!(8&c||!i.length&&(o===1||o===4&&32&c))){for(Ve(c)&&(i=we(i),c=it(c,t),t=J(e,t,n,i)),r=i,a=c,h=0;h<r.length;h++)(c=r[h])!==(p=un(c))&&(r[h]=p);a|=8,a=r.length?-17&a:16|a,oe(r,a),c=a}let d;return o===1||o===4&&32&c?Ve(c)||(t=c,(c|=!i.length||16&c&&(!l||32&c)?2:2048)!==t&&oe(i,c),Object.freeze(i)):(l=o===5&&(!!(32&c)||Ve(c)||!!jt?.get(i)),(o===2||l)&&Ve(c)&&(i=we(i),c=yt(c=it(c,t),t,s),oe(i,c),t=J(e,t,n,i)),Ve(c)||(n=c,(c=yt(c,t,s))!==n&&oe(i,c)),l?d=ui(i):o!==2||s||jt?.delete(i)),d||i}function ct(e,t,r){let n=G(e.u);return yi(e,n,t,r,St(),!1,!(2&n))}function T(e,t,r,n){return n==null&&(n=void 0),X(e,r,n)}function mr(e,t,r,n){n==null&&(n=void 0);e:{e=e.u;let o=G(e);if(_t(o),n==null){let s=Po(e);if(Bo(s,e,o,r)!==t)break e;s.set(r,0)}else o=gi(e,o,r,t);J(e,o,t,n)}}function it(e,t){return-2049&(e=32|(2&t?2|e:-3&e))}function yt(e,t,r){return 32&t&&r||(e&=-33),e}function $r(e,t,r,n){let o=G(e.u);_t(o),e=yi(e,o,r,t,2,!0),n=n??new r,e.push(n),2&re(n.u)?Jn(e,8):Jn(e,16)}function je(e,t){return e??t}function Oe(e,t){return qt(vt(e,t))}function te(e,t){return je(Dr(e,t),0)}function et(e,t){return je(gt(vt(e,t)),"")}function Er(e,t,r){if(r!=null&&typeof r!="boolean")throw e=typeof r,Error(`Expected boolean but got ${e!="object"?e:r?Array.isArray(r)?"array":e:"null"}: ${r}`);X(e,t,r)}function tt(e,t,r){if(r!=null){if(typeof r!="number"||!Number.isFinite(r))throw qn("int32");r|=0}X(e,t,r)}function v(e,t,r){if(r!=null&&typeof r!="number")throw Error(`Value of float/double field must be a number, found ${typeof r}: ${r}`);X(e,t,r)}function qr(e,t,r){{let a=e.u,i=G(a);if(_t(i),r==null)J(a,i,t);else{r=hi?.get(r)||r;var n=e=re(r),o=Ve(e),s=o||Object.isFrozen(r);for(o||(e=0),s||(r=we(r),n=0,e=yt(e=it(e,i),i,!0),s=!1),e|=21,o=0;o<r.length;o++){let c=r[o],l=ci(c);Object.is(c,l)||(s&&(r=we(r),n=0,e=yt(e=it(e,i),i,!0),s=!1),r[o]=l)}e!==n&&(s&&(r=we(r),e=yt(e=it(e,i),i,!0)),oe(r,e)),J(a,i,t,r)}}}function hn(e,t,r){_t(G(e.u)),Ct(e,t,gt,2,!0).push(ci(r))}function vi(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function No(){return Error("Failed to read varint, encoding is invalid.")}function Ei(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function Go(e){if(typeof e=="string")return{buffer:Za(e),O:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),O:!1};if(e.constructor===Uint8Array)return{buffer:e,O:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),O:!1};if(e.constructor===at)return{buffer:vo(e)||new Uint8Array(0),O:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),O:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function Vo(e,t){let r,n=0,o=0,s=0,a=e.h,i=e.g;do r=a[i++],n|=(127&r)<<s,s+=7;while(s<32&&128&r);for(s>32&&(o|=(127&r)>>4),s=3;s<32&&128&r;s+=7)r=a[i++],o|=(127&r)<<s;if(Lt(e,i),r<128)return t(n>>>0,o>>>0);throw No()}function jo(e){let t=0,r=e.g,n=r+10,o=e.h;for(;r<n;){let s=o[r++];if(t|=s,(128&s)==0)return Lt(e,r),!!(127&t)}throw No()}function Et(e){let t=e.h,r=e.g,n=t[r++],o=127&n;if(128&n&&(n=t[r++],o|=(127&n)<<7,128&n&&(n=t[r++],o|=(127&n)<<14,128&n&&(n=t[r++],o|=(127&n)<<21,128&n&&(n=t[r++],o|=n<<28,128&n&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw No();return Lt(e,r),o}function ut(e){return Et(e)>>>0}function ro(e){var t=e.h;let r=e.g,n=t[r],o=t[r+1],s=t[r+2];return t=t[r+3],Lt(e,e.g+4),(n<<0|o<<8|s<<16|t<<24)>>>0}function no(e){var t=ro(e);e=2*(t>>31)+1;let r=t>>>23&255;return t&=8388607,r==255?t?NaN:e*(1/0):r==0?1401298464324817e-60*e*t:e*Math.pow(2,r-150)*(t+8388608)}function Yu(e){return Et(e)}function jn(e,t,{ca:r=!1}={}){e.ca=r,t&&(t=Go(t),e.h=t.buffer,e.m=t.O,e.j=0,e.l=e.h.length,e.g=e.j)}function Lt(e,t){if(e.g=t,t>e.l)throw Ei(e.l,t)}function bi(e,t){if(t<0)throw Error(`Tried to read a negative byte length: ${t}`);let r=e.g,n=r+t;if(n>e.l)throw Ei(t,e.l-r);return e.g=n,r}function Ti(e,t){if(t==0)return Mt();var r=bi(e,t);return e.ca&&e.m?r=e.h.subarray(r,r+t):(e=e.h,r=r===(t=r+t)?new Uint8Array(0):Uu?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Mt():new at(r,Gt)}Pe.prototype.toJSON=void 0,Pe.prototype.Ia=ni;var Js=[];function _i(e){var t=e.g;if(t.g==t.l)return!1;e.l=e.g.g;var r=ut(e.g);if(t=r>>>3,!((r&=7)>=0&&r<=5))throw vi(r,e.l);if(t<1)throw Error(`Invalid field number: ${t} (at position ${e.l})`);return e.m=t,e.h=r,!0}function Nr(e){switch(e.h){case 0:e.h!=0?Nr(e):jo(e.g);break;case 1:Lt(e=e.g,e.g+8);break;case 2:if(e.h!=2)Nr(e);else{var t=ut(e.g);Lt(e=e.g,e.g+t)}break;case 5:Lt(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!_i(e))throw Error("Unmatched start-group tag: stream EOF");if(e.h==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}Nr(e)}break;default:throw vi(e.h,e.l)}}function wr(e,t,r){let n=e.g.l,o=ut(e.g),s=e.g.g+o,a=s-n;if(a<=0&&(e.g.l=s,r(t,e,void 0,void 0,void 0),a=s-e.g.g),a)throw Error(`Message parsing ended unexpectedly. Expected to read ${o} bytes, instead read ${o-a} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=s,e.g.l=n,t}function Wo(e){var t=ut(e.g),r=bi(e=e.g,t);if(e=e.h,xu){var n,o=e;(n=On)||(n=On=new TextDecoder("utf-8",{fatal:!0})),t=r+t,o=r===0&&t===o.length?o:o.subarray(r,t);try{var s=n.decode(o)}catch(i){if(Ir===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),Ir=!0}catch{Ir=!1}}throw!Ir&&(On=void 0),i}}else{t=(s=r)+t,r=[];let i,c=null;for(;s<t;){var a=e[s++];a<128?r.push(a):a<224?s>=t?kt():(i=e[s++],a<194||(192&i)!=128?(s--,kt()):r.push((31&a)<<6|63&i)):a<240?s>=t-1?kt():(i=e[s++],(192&i)!=128||a===224&&i<160||a===237&&i>=160||(192&(n=e[s++]))!=128?(s--,kt()):r.push((15&a)<<12|(63&i)<<6|63&n)):a<=244?s>=t-2?kt():(i=e[s++],(192&i)!=128||i-144+(a<<28)>>30!=0||(192&(n=e[s++]))!=128||(192&(o=e[s++]))!=128?(s--,kt()):(a=(7&a)<<18|(63&i)<<12|(63&n)<<6|63&o,a-=65536,r.push(55296+(a>>10&1023),56320+(1023&a)))):kt(),r.length>=8192&&(c=Fs(c,r),r.length=0)}s=Fs(c,r)}return s}function Ai(e){let t=ut(e.g);return Ti(e.g,t)}function ln(e,t,r){var n=ut(e.g);for(n=e.g.g+n;e.g.g<n;)r.push(t(e.g))}var Ur=[],Jr;function Xe(e,t,r){t.g?t.m(e,t.g,t.h,r,!0):t.m(e,t.h,r,!0)}var x=class{constructor(e,t){this.u=di(e,t)}toJSON(){return Ri(this)}l(){var e=k2;return e.g?e.l(this,e.g,e.h,!0):e.l(this,e.h,e.defaultValue,!0)}clone(){let e=this.u;return Fo(this,e,G(e),!1)}O(){return!!(2&re(this.u))}};function Ri(e){e=e.u,e=Jr?e:cn(e,Mo,void 0,void 0,!1);{var t=!Jr;let l=e.length;if(l){var r=e[l-1],n=To(r);n?l--:r=void 0;var o=e;if(n){e:{var s,a=r,i=!1;if(a)for(let h in a)isNaN(+h)?(s??(s={}))[h]=a[h]:(n=a[h],Array.isArray(n)&&(Hr(n)||Ns(n)&&n.size===0)&&(n=null),n==null&&(i=!0),n!=null&&((s??(s={}))[h]=n));if(i||(s=a),s)for(let h in s){i=s;break e}i=null}a=i==null?r!=null:i!==r}for(;l>0&&((s=o[l-1])==null||Hr(s)||Ns(s)&&s.size===0);l--)var c=!0;(o!==e||a||c)&&(t?(c||a||i)&&(o.length=l):o=Array.prototype.slice.call(o,0,l),i&&o.push(i)),c=o}else c=e}return c}function Qs(e){return e?/^\d+$/.test(e)?(sn(e),new oo(V,Z)):null:zu||(zu=new oo(0,0))}x.prototype.X=Rr,x.prototype.toString=function(){try{return Jr=!0,Ri(this).toString()}finally{Jr=!1}};var oo=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}},zu;function Zs(e){return e?/^-?\d+$/.test(e)?(sn(e),new so(V,Z)):null:Ku||(Ku=new so(0,0))}var so=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}},Ku;function Bt(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function Zt(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function dn(e,t){if(t>=0)Zt(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function br(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function Wt(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function Se(e,t,r){Zt(e.g,8*t+r)}function Xo(e,t){return Se(e,t,2),t=e.g.end(),Wt(e,t),t.push(e.h),t}function Ho(e,t){var r=t.pop();for(r=e.h+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.h++;t.push(r),e.h++}function fn(e,t,r){Se(e,t,2),Zt(e.g,r.length),Wt(e,e.g.end()),Wt(e,r)}function Qr(e,t,r,n){r!=null&&(t=Xo(e,t),n(r,e),Ho(e,t))}function He(){let e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var Yo=He(),wi=He(),zo=He(),Ko=He(),ki=He(),Si=He(),$o=He(),Ci=He(),Li=He(),er=class{constructor(e,t,r){this.g=e,this.h=t,e=Yo,this.l=!!e&&r===e||!1}};function pn(e,t){return new er(e,t,Yo)}function Ii(e,t,r,n,o){Qr(e,r,Oi(t,n),o)}var $u=pn(function(e,t,r,n,o){return e.h===2&&(wr(e,Do(t,n,r),o),!0)},Ii),qu=pn(function(e,t,r,n,o){return e.h===2&&(wr(e,Do(t,n,r,!0),o),!0)},Ii),mn=Symbol(),qo=Symbol(),ea=Symbol(),ta=Symbol(),Mi,Fi;function Ft(e,t,r,n){var o=n[e];if(o)return o;(o={}).W=function(p){switch(typeof p){case"boolean":return li||(li=[0,void 0,!0]);case"number":return p>0?void 0:p===0?Du||(Du=[0,void 0]):[-p,void 0];case"string":return[0,p];case"object":return p}}(n[0]);var s=n[1];let a=1;s&&s.constructor===Object&&(o.ha=s,typeof(s=n[++a])=="function"&&(o.ma=!0,Mi??(Mi=s),Fi??(Fi=n[a+1]),s=n[a+=2]));let i={};for(;s&&Array.isArray(s)&&s.length&&typeof s[0]=="number"&&s[0]>0;){for(var c=0;c<s.length;c++)i[s[c]]=s;s=n[++a]}for(c=1;s!==void 0;){let p;typeof s=="number"&&(c+=s,s=n[++a]);var l=void 0;if(s instanceof er?p=s:(p=$u,a--),p?.l){s=n[++a],l=n;var h=a;typeof s=="function"&&(s=s(),l[h]=s),l=s}for(h=c+1,typeof(s=n[++a])=="number"&&s<0&&(h-=s,s=n[++a]);c<h;c++){let d=i[c];l?r(o,c,p,l,d):t(o,c,p,d)}}return n[e]=o}function Ui(e){return Array.isArray(e)?e[0]instanceof er?e:[qu,e]:[e,void 0]}function Oi(e,t){return e instanceof x?e.u:Array.isArray(e)?xt(e,t,!1):void 0}function Jo(e,t,r,n){let o=r.g;e[t]=n?(s,a,i)=>o(s,a,i,n):o}function Qo(e,t,r,n,o){let s=r.g,a,i;e[t]=(c,l,h)=>s(c,l,h,i||(i=Ft(qo,Jo,Qo,n).W),a||(a=Zo(n)),o)}function Zo(e){let t=e[ea];if(t!=null)return t;let r=Ft(qo,Jo,Qo,e);return t=r.ma?(n,o)=>Mi(n,o,r):(n,o)=>{let s=G(n);for(;_i(o)&&o.h!=4;){var a=o.m,i=r[a];if(i==null){var c=r.ha;c&&(c=c[a])&&(c=Ju(c))!=null&&(i=r[a]=c)}i!=null&&i(o,n,a)||(a=(i=o).l,Nr(i),i.ga?i=void 0:(c=i.g.g-a,i.g.g=a,i=Ti(i.g,c)),a=n,i&&(mt||(mt=Symbol()),(c=a[mt])?c.push(i):a[mt]=[i]))}return 16384&s&&$t(n),!0},e[ea]=t}function Ju(e){let t=(e=Ui(e))[0].g;if(e=e[1]){let r=Zo(e),n=Ft(qo,Jo,Qo,e).W;return(o,s,a)=>t(o,s,a,n,r)}return t}function gn(e,t,r){e[t]=r.h}function xn(e,t,r,n){let o,s,a=r.h;e[t]=(i,c,l)=>a(i,c,l,s||(s=Ft(mn,gn,xn,n).W),o||(o=Pi(n)))}function Pi(e){let t=e[ta];if(!t){let r=Ft(mn,gn,xn,e);t=(n,o)=>Bi(n,o,r),e[ta]=t}return t}function Bi(e,t,r){for(var n=re(e),o=+!!(512&n)-1,s=e.length,a=512&n?1:0,i=s+(256&n?-1:0);a<i;a++){let c=e[a];if(c==null)continue;let l=a-o,h=ra(r,l);h&&h(t,c,l)}if(256&n){n=e[s-1];for(let c in n)o=+c,Number.isNaN(o)||(s=n[o])!=null&&(i=ra(r,o))&&i(t,s,o)}if(e=mt?e[mt]:void 0)for(Wt(t,t.g.end()),r=0;r<e.length;r++)Wt(t,vo(e[r])||new Uint8Array(0))}function ra(e,t){var r=e[t];if(r)return r;if((r=e.ha)&&(r=r[t])){var n=(r=Ui(r))[0].h;if(r=r[1]){let o=Pi(r),s=Ft(mn,gn,xn,r).W;r=e.ma?Fi(s,o):(a,i,c)=>n(a,i,c,s,o)}else r=n;return e[t]=r}}function tr(e,t){if(Array.isArray(t)){var r=re(t);if(4&r)return t;for(var n=0,o=0;n<t.length;n++){let s=e(t[n]);s!=null&&(t[o++]=s)}return o<n&&(t.length=o),oe(t,-12289&(5|r)),2&r&&Object.freeze(t),t}}function ye(e,t,r){return new er(e,t,r)}function rr(e,t,r){return new er(e,t,r)}function ve(e,t,r){J(e,G(e),t,r)}var Qu=pn(function(e,t,r,n,o){return e.h===2&&(e=wr(e,xt([void 0,void 0],n,!0),o),_t(n=G(t)),(o=ht(t,n,r))instanceof Pe?(2&o.M)!=0?((o=o.Y()).push(e),J(t,n,r,o)):o.Na(e):Array.isArray(o)?(2&re(o)&&J(t,n,r,o=mi(o)),o.push(e)):J(t,n,r,[e]),!0)},function(e,t,r,n,o){if(t instanceof Pe)t.forEach((s,a)=>{Qr(e,r,xt([a,s],n,!1),o)});else if(Array.isArray(t))for(let s=0;s<t.length;s++){let a=t[s];Array.isArray(a)&&Qr(e,r,xt(a,n,!1),o)}});function Di(e,t,r){if(t=function(n){if(n==null)return n;let o=typeof n;if(o==="bigint")return String(BigInt.asIntN(64,n));if(an(n)){if(o==="string")return Co(n);if(o==="number")return So(n)}}(t),t!=null&&(typeof t=="string"&&Zs(t),t!=null))switch(Se(e,r,0),typeof t){case"number":e=e.g,Vt(t),Bt(e,V,Z);break;case"bigint":r=BigInt.asUintN(64,t),r=new so(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Bt(e.g,r.h,r.g);break;default:r=Zs(t),Bt(e.g,r.h,r.g)}}function Ni(e,t,r){(t=qt(t))!=null&&t!=null&&(Se(e,r,0),dn(e.g,t))}function Gi(e,t,r){(t=ai(t))!=null&&(Se(e,r,0),e.g.g.push(t?1:0))}function Vi(e,t,r){(t=gt(t))!=null&&fn(e,r,Ka(t))}function ji(e,t,r,n,o){Qr(e,r,Oi(t,n),o)}function Wi(e,t,r){(t=t==null||typeof t=="string"||_r(t)||t instanceof at?t:void 0)!=null&&fn(e,r,Go(t).buffer)}function Xi(e,t,r){return(e.h===5||e.h===2)&&(t=Qt(t,G(t),r,!1,!1),e.h==2?ln(e,no,t):t.push(no(e.g)),!0)}var ot=ye(function(e,t,r){if(e.h!==1)return!1;var n=e.g;e=ro(n);let o=ro(n);n=2*(o>>31)+1;let s=o>>>20&2047;return e=4294967296*(1048575&o)+e,ve(t,r,s==2047?e?NaN:n*(1/0):s==0?5e-324*n*e:n*Math.pow(2,s-1075)*(e+4503599627370496)),!0},function(e,t,r){(t=At(t))!=null&&(Se(e,r,1),e=e.g,(r=si||(si=new DataView(new ArrayBuffer(8)))).setFloat64(0,+t,!0),V=r.getUint32(0,!0),Z=r.getUint32(4,!0),br(e,V),br(e,Z))},He()),ce=ye(function(e,t,r){return e.h===5&&(ve(t,r,no(e.g)),!0)},function(e,t,r){(t=At(t))!=null&&(Se(e,r,5),e=e.g,Ao(t),br(e,V))},$o),Zu=rr(Xi,function(e,t,r){if((t=tr(At,t))!=null)for(let a=0;a<t.length;a++){var n=e,o=r,s=t[a];s!=null&&(Se(n,o,5),n=n.g,Ao(s),br(n,V))}},$o),es=rr(Xi,function(e,t,r){if((t=tr(At,t))!=null&&t.length){Se(e,r,2),Zt(e.g,4*t.length);for(let n=0;n<t.length;n++)r=e.g,Ao(t[n]),br(r,V)}},$o),bt=ye(function(e,t,r){return e.h===0&&(ve(t,r,Vo(e.g,wo)),!0)},Di,Si),Wn=ye(function(e,t,r){return e.h===0&&(ve(t,r,(e=Vo(e.g,wo))===0?void 0:e),!0)},Di,Si),e2=ye(function(e,t,r){return e.h===0&&(ve(t,r,Vo(e.g,Ro)),!0)},function(e,t,r){if((t=Pu(t))!=null&&(typeof t=="string"&&Qs(t),t!=null))switch(Se(e,r,0),typeof t){case"number":e=e.g,Vt(t),Bt(e,V,Z);break;case"bigint":r=BigInt.asUintN(64,t),r=new oo(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Bt(e.g,r.h,r.g);break;default:r=Qs(t),Bt(e.g,r.h,r.g)}},He()),ee=ye(function(e,t,r){return e.h===0&&(ve(t,r,Et(e.g)),!0)},Ni,Ko),yn=rr(function(e,t,r){return(e.h===0||e.h===2)&&(t=Qt(t,G(t),r,!1,!1),e.h==2?ln(e,Et,t):t.push(Et(e.g)),!0)},function(e,t,r){if((t=tr(qt,t))!=null&&t.length){r=Xo(e,r);for(let n=0;n<t.length;n++)dn(e.g,t[n]);Ho(e,r)}},Ko),Pt=ye(function(e,t,r){return e.h===0&&(ve(t,r,(e=Et(e.g))===0?void 0:e),!0)},Ni,Ko),q=ye(function(e,t,r){return e.h===0&&(ve(t,r,jo(e.g)),!0)},Gi,wi),Dt=ye(function(e,t,r){return e.h===0&&(ve(t,r,(e=jo(e.g))===!1?void 0:e),!0)},Gi,wi),fe=rr(function(e,t,r){return e.h===2&&(e=Wo(e),Qt(t,G(t),r,!1).push(e),!0)},function(e,t,r){if((t=tr(gt,t))!=null)for(let a=0;a<t.length;a++){var n=e,o=r,s=t[a];s!=null&&fn(n,o,Ka(s))}},zo),pt=ye(function(e,t,r){return e.h===2&&(ve(t,r,(e=Wo(e))===""?void 0:e),!0)},Vi,zo),D=ye(function(e,t,r){return e.h===2&&(ve(t,r,Wo(e)),!0)},Vi,zo),ie=function(e,t,r=Yo){return new er(e,t,r)}(function(e,t,r,n,o){return e.h===2&&(n=xt(void 0,n,!0),Qt(t,G(t),r,!0).push(n),wr(e,n,o),!0)},function(e,t,r,n,o){if(Array.isArray(t))for(let s=0;s<t.length;s++)ji(e,t[s],r,n,o)}),N=pn(function(e,t,r,n,o,s){return e.h===2&&(gi(t,re(t),s,r),wr(e,t=Do(t,n,r),o),!0)},ji),Hi=ye(function(e,t,r){return e.h===2&&(ve(t,r,Ai(e)),!0)},Wi,Ci),t2=rr(function(e,t,r){return(e.h===0||e.h===2)&&(t=Qt(t,G(t),r,!1,!1),e.h==2?ln(e,ut,t):t.push(ut(e.g)),!0)},function(e,t,r){if((t=tr(ii,t))!=null)for(let a=0;a<t.length;a++){var n=e,o=r,s=t[a];s!=null&&(Se(n,o,0),Zt(n.g,s))}},ki),r2=ye(function(e,t,r){return e.h===0&&(ve(t,r,(e=ut(e.g))===0?void 0:e),!0)},function(e,t,r){(t=ii(t))!=null&&t!=null&&(Se(e,r,0),Zt(e.g,t))},ki),We=ye(function(e,t,r){return e.h===0&&(ve(t,r,Et(e.g)),!0)},function(e,t,r){(t=qt(t))!=null&&(t=parseInt(t,10),Se(e,r,0),dn(e.g,t))},Li),ao=class{constructor(t,r){this.h=t,this.g=r,this.l=O,this.m=T,this.defaultValue=void 0}};function Ye(e,t){return new ao(e,t)}function Rt(e,t){return(r,n)=>{if(Ur.length){let s=Ur.pop();s.o(n),jn(s.g,r,n),r=s}else r=new class{constructor(s,a){if(Js.length){let i=Js.pop();jn(i,s,a),s=i}else s=new class{constructor(i,c){this.h=null,this.m=!1,this.g=this.l=this.j=0,jn(this,i,c)}clear(){this.h=null,this.m=!1,this.g=this.l=this.j=0,this.ca=!1}}(s,a);this.g=s,this.l=this.g.g,this.h=this.m=-1,this.o(a)}o({ga:s=!1}={}){this.ga=s}}(r,n);try{let s=new e,a=s.u;Zo(t)(a,r);var o=s}finally{r.g.clear(),r.m=-1,r.h=-1,Ur.length<100&&Ur.push(r)}return o}}function vn(e){return function(){let t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){let a=this.g;return this.g=[],a}}}};Bi(this.u,t,Ft(mn,gn,xn,e)),Wt(t,t.g.end());let r=new Uint8Array(t.h),n=t.l,o=n.length,s=0;for(let a=0;a<o;a++){let i=n[a];r.set(i,s),s+=i.length}return t.l=[r],r}}var na=class extends x{constructor(e){super(e)}},oa=[0,pt,ye(function(e,t,r){return e.h===2&&(ve(t,r,(e=Ai(e))===Mt()?void 0:e),!0)},function(e,t,r){if(t!=null){if(t instanceof x){let n=t.Qa;return void(n&&(t=n(t),t!=null&&fn(e,r,Go(t).buffer)))}if(Array.isArray(t))return}Wi(e,t,r)},Ci)],Xn,sa=globalThis.trustedTypes;function aa(e){Xn===void 0&&(Xn=function(){let r=null;if(!sa)return r;try{let n=o=>o;r=sa.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}());var t=Xn;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function n2(e,...t){if(t.length===0)return aa(e[0]);let r=e[0];for(let n=0;n<t.length;n++)r+=encodeURIComponent(t[n])+e[n+1];return aa(r)}var Yi=[0,ee,We,q,-1,yn,We,-1],o2=class extends x{constructor(){super()}},zi=[0,q,D,q,We,-1,rr(function(e,t,r){return(e.h===0||e.h===2)&&(t=Qt(t,G(t),r,!1,!1),e.h==2?ln(e,Yu,t):t.push(Et(e.g)),!0)},function(e,t,r){if((t=tr(qt,t))!=null&&t.length){r=Xo(e,r);for(let n=0;n<t.length;n++)dn(e.g,t[n]);Ho(e,r)}},Li),D,-1,[0,q,-1],We,q,-1],Ki=[0,D,-2],ia=class extends x{constructor(){super()}},$i=[0],qi=[0,ee,q,1,q,-3],ke=class extends x{constructor(e){super(e,2)}},se={};se[336783863]=[0,D,q,-1,ee,[0,[1,2,3,4,5,6,7],N,$i,N,zi,N,Ki,N,qi,N,Yi,N,[0,D,-2],N,[0,D,We]],[0,D],q,[0,[1,3],[2,4],N,[0,yn],-1,N,[0,fe],-1,ie,[0,D,-1]],D];var ca=[0,Wn,-1,Dt,-3,Wn,yn,pt,Pt,Wn,-1,Dt,Pt,Dt,-2,pt];function Ce(e,t){to(e,2,Jt(t),"")}function H(e,t){hn(e,3,t)}function F(e,t){hn(e,4,t)}var xe=class extends x{constructor(e){super(e,500)}o(e){return T(this,0,7,e)}},gr=[-1,{}],ua=[0,D,1,gr],ha=[0,D,fe,gr];function Le(e,t){$r(e,1,xe,t)}function Y(e,t){hn(e,10,t)}function P(e,t){hn(e,15,t)}var be=class extends x{constructor(e){super(e,500)}o(e){return T(this,0,1001,e)}},Ji=[-500,ie,[-500,pt,-1,fe,-3,[-2,se,q],ie,oa,Pt,-1,ua,ha,ie,[0,pt,Dt],pt,ca,Pt,fe,987,fe],4,ie,[-500,D,-1,[-1,{}],998,D],ie,[-500,D,fe,-1,[-2,{},q],997,fe,-1],Pt,ie,[-500,D,fe,gr,998,fe],fe,Pt,ua,ha,ie,[0,pt,-1,gr],fe,-2,ca,pt,-1,Dt,[0,Dt,r2],978,gr,ie,oa];be.prototype.g=vn(Ji);var s2=Rt(be,Ji),a2=class extends x{constructor(e){super(e)}},Qi=class extends x{constructor(e){super(e)}g(){return ct(this,a2,1)}},Zi=[0,ie,[0,ee,ce,D,-1]],En=Rt(Qi,Zi),i2=class extends x{constructor(e){super(e)}},c2=class extends x{constructor(e){super(e)}},Hn=class extends x{constructor(e){super(e)}h(){return O(this,i2,2)}g(){return ct(this,c2,5)}},ec=Rt(class extends x{constructor(e){super(e)}},[0,fe,yn,es,[0,We,[0,ee,-3],[0,ce,-3],[0,ee,-1,[0,ie,[0,ee,-2]]],ie,[0,ce,-1,D,ce]],D,-1,bt,ie,[0,ee,ce],fe,bt]),tc=class extends x{constructor(e){super(e)}},Nt=Rt(class extends x{constructor(e){super(e)}},[0,ie,[0,ce,-4]]),rc=class extends x{constructor(e){super(e)}},kr=Rt(class extends x{constructor(e){super(e)}},[0,ie,[0,ce,-4]]),u2=class extends x{constructor(e){super(e)}},h2=[0,ee,-1,es,We],nc=class extends x{constructor(){super()}};nc.prototype.g=vn([0,ce,-4,bt]);var l2=class extends x{constructor(e){super(e)}},d2=Rt(class extends x{constructor(e){super(e)}},[0,ie,[0,1,ee,D,Zi],bt]),la=class extends x{constructor(e){super(e)}},f2=class extends x{constructor(e){super(e)}pa(){let e=pi(this);return e??Mt()}},p2=class extends x{constructor(e){super(e)}},oc=[1,2],m2=Rt(class extends x{constructor(e){super(e)}},[0,ie,[0,oc,N,[0,es],N,[0,Hi],ee,D],bt]),ts=class extends x{constructor(e){super(e)}},sc=[0,D,ee,ce,fe,-1],da=class extends x{constructor(e){super(e)}},g2=[0,q,-1],fa=class extends x{constructor(e){super(e)}},Gr=[1,2,3,4,5],Zr=class extends x{constructor(e){super(e)}g(){return pi(this)!=null}h(){return gt(vt(this,2))!=null}},$=class extends x{constructor(e){super(e)}g(){return ai(vt(this,2))??!1}},ac=[0,Hi,D,[0,ee,bt,-1],[0,e2,bt]],ne=[0,ac,q,[0,Gr,N,qi,N,zi,N,Yi,N,$i,N,Ki],We],bn=class extends x{constructor(e){super(e)}},rs=[0,ne,ce,-1,ee],x2=Ye(502141897,bn);se[502141897]=rs;var y2=Rt(class extends x{constructor(e){super(e)}},[0,[0,We,-1,Zu,t2],h2]),ic=class extends x{constructor(e){super(e)}},cc=class extends x{constructor(e){super(e)}},ns=[0,ne,ce,[0,ne],q],uc=[0,ne,rs,ns,ce,[0,[0,ac]]],v2=Ye(508968150,cc);se[508968150]=uc,se[508968149]=ns;var hc=class extends x{constructor(e){super(e)}},E2=Ye(513916220,hc);se[513916220]=[0,ne,uc,ee];var Ut=class extends x{constructor(e){super(e)}h(){return O(this,ts,2)}g(){X(this,2)}},lc=[0,ne,sc];se[478825465]=lc;var b2=class extends x{constructor(e){super(e)}},dc=class extends x{constructor(e){super(e)}},os=class extends x{constructor(e){super(e)}},ss=class extends x{constructor(e){super(e)}},fc=class extends x{constructor(e){super(e)}},pa=[0,ne,[0,ne],lc,-1],pc=[0,ne,ce,ee],as=[0,ne,ce],mc=[0,ne,pc,as,ce],T2=Ye(479097054,fc);se[479097054]=[0,ne,mc,pa],se[463370452]=pa,se[464864288]=pc;var _2=Ye(462713202,ss);se[462713202]=mc,se[474472470]=as;var A2=class extends x{constructor(e){super(e)}},gc=class extends x{constructor(e){super(e)}},xc=class extends x{constructor(e){super(e)}},yc=class extends x{constructor(){super()}},is=[0,ne,ce,-1,ee],io=[0,ne,ce,q];yc.prototype.g=vn([0,ne,as,[0,ne],rs,ns,is,io]);var vc=class extends x{constructor(e){super(e)}},R2=Ye(456383383,vc);se[456383383]=[0,ne,sc];var Ec=class extends x{constructor(e){super(e)}},w2=Ye(476348187,Ec);se[476348187]=[0,ne,g2];var bc=class extends x{constructor(e){super(e)}},ma=class extends x{constructor(e){super(e)}},Tc=[0,We,-1],k2=Ye(458105876,class extends x{constructor(e){super(e)}g(){var e=this.u;let t=G(e),r=2&t;return e=function(n,o,s){var a=ma;let i=2&o,c=!1;if(s==null){if(i)return $s();s=[]}else if(s.constructor===Pe){if((2&s.M)==0||i)return s;s=s.Y()}else Array.isArray(s)?c=!!(2&re(s)):s=[];if(i){if(!s.length)return $s();c||(c=!0,$t(s))}else c&&(c=!1,s=mi(s));return c||(64&re(s)?Jn(s,32):32&o&&rn(s,32)),J(n,o,2,a=new Pe(s,a,Bu,void 0)),a}(e,t,ht(e,t,2)),!r&&ma&&(e.sa=!0),e}});se[458105876]=[0,Tc,Qu,[!0,bt,[0,D,-1,fe]]];var cs=class extends x{constructor(e){super(e)}},_c=Ye(458105758,cs);se[458105758]=[0,ne,D,Tc];var Ac=class extends x{constructor(e){super(e)}},S2=Ye(443442058,Ac);se[443442058]=[0,ne,D,ee,ce,fe,-1],se[514774813]=is;var Rc=class extends x{constructor(e){super(e)}},C2=Ye(516587230,Rc);function co(e,t){return t=t?t.clone():new ts,e.displayNamesLocale!==void 0?X(t,1,Jt(e.displayNamesLocale)):e.displayNamesLocale===void 0&&X(t,1),e.maxResults!==void 0?tt(t,2,e.maxResults):"maxResults"in e&&X(t,2),e.scoreThreshold!==void 0?v(t,3,e.scoreThreshold):"scoreThreshold"in e&&X(t,3),e.categoryAllowlist!==void 0?qr(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&X(t,4),e.categoryDenylist!==void 0?qr(t,5,e.categoryDenylist):"categoryDenylist"in e&&X(t,5),t}function us(e,t=-1,r=""){return{categories:e.map(n=>({index:je(Oe(n,1),0)??-1,score:te(n,2)??0,categoryName:et(n,3)??"",displayName:et(n,4)??""})),headIndex:t,headName:r}}function wc(e){var t=Ct(e,3,At,St()),r=Ct(e,2,qt,St()),n=Ct(e,1,gt,St()),o=Ct(e,9,gt,St());let s={categories:[],keypoints:[]};for(let a=0;a<t.length;a++)s.categories.push({score:t[a],index:r[a]??-1,categoryName:n[a]??"",displayName:o[a]??""});if((t=O(e,Hn,4)?.h())&&(s.boundingBox={originX:Oe(t,1)??0,originY:Oe(t,2)??0,width:Oe(t,3)??0,height:Oe(t,4)??0,angle:0}),O(e,Hn,4)?.g().length)for(let a of O(e,Hn,4).g())s.keypoints.push({x:Dr(a,1)??0,y:Dr(a,2)??0,score:Dr(a,4)??0,label:gt(vt(a,3))??""});return s}function Tn(e){let t=[];for(let r of ct(e,rc,1))t.push({x:te(r,1)??0,y:te(r,2)??0,z:te(r,3)??0,visibility:te(r,4)??0});return t}function xr(e){let t=[];for(let r of ct(e,tc,1))t.push({x:te(r,1)??0,y:te(r,2)??0,z:te(r,3)??0,visibility:te(r,4)??0});return t}function ga(e){return Array.from(e,t=>t>127?t-256:t)}function xa(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let r=0,n=0,o=0;for(let s=0;s<e.length;s++)r+=e[s]*t[s],n+=e[s]*e[s],o+=t[s]*t[s];if(n<=0||o<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(n*o)}var Or;se[516587230]=[0,ne,is,io,ce],se[518928384]=io;var L2=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function kc(){if(Or===void 0)try{await WebAssembly.instantiate(L2),Or=!0}catch{Or=!1}return Or}async function hr(e,t=n2``){let r=await kc()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var dt=class{};function Sc(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function ya(e){if(typeof importScripts!="function"){let t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise((r,n)=>{t.addEventListener("load",()=>{r()},!1),t.addEventListener("error",o=>{n(o)},!1),document.body.appendChild(t)})}importScripts(e.toString())}function Cc(e){return e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height]}function E(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function va(e,t,r){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(r?e.i._bindTextureToStream(r):e.i._bindTextureToCanvas(),!(r=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);let[n,o]=Cc(t);return!e.l||n===e.i.canvas.width&&o===e.i.canvas.height||(e.i.canvas.width=n,e.i.canvas.height=o),[n,o]}function Ea(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");let n=new Uint32Array(t.length);for(let o=0;o<t.length;o++)n[o]=e.i.stringToNewUTF8(t[o]);t=e.i._malloc(4*n.length),e.i.HEAPU32.set(n,t>>2),r(t);for(let o of n)e.i._free(o);e.i._free(t)}function qe(e,t,r){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=r}function lt(e,t,r){let n=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(o,s,a)=>{s?(r(n,a),n=[]):n.push(o)}}dt.forVisionTasks=function(e){return hr("vision",e)},dt.forTextTasks=function(e){return hr("text",e)},dt.forGenAiExperimentalTasks=function(e){return hr("genai_experimental",e)},dt.forGenAiTasks=function(e){return hr("genai",e)},dt.forAudioTasks=function(e){return hr("audio",e)},dt.isSimdSupported=function(){return kc()};async function I2(e,t,r,n){return e=await(async(o,s,a,i,c)=>{if(s&&await ya(s),!self.ModuleFactory||a&&(await ya(a),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&c&&((s=self.Module).locateFile=c.locateFile,c.mainScriptUrlOrBlob&&(s.mainScriptUrlOrBlob=c.mainScriptUrlOrBlob)),c=await self.ModuleFactory(self.Module||c),self.ModuleFactory=self.Module=void 0,new o(c,i)})(e,r.wasmLoaderPath,r.assetLoaderPath,t,{locateFile:o=>o.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&o.endsWith(".data")?r.assetBinaryPath.toString():o}),await e.o(n),e}function Yn(e,t){let r=O(e.baseOptions,Zr,1)||new Zr;typeof t=="string"?(X(r,2,Jt(t)),X(r,1)):t instanceof Uint8Array&&(X(r,1,_o(t,!1)),X(r,2)),T(e.baseOptions,0,1,r)}function ba(e){try{let t=e.H.length;if(t===1)throw Error(e.H[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.H.map(r=>r.message).join(", "))}finally{e.H=[]}}function m(e,t){e.B=Math.max(e.B,t)}function _n(e,t){e.A=new xe,Ce(e.A,"PassThroughCalculator"),H(e.A,"free_memory"),F(e.A,"free_memory_unused_out"),Y(t,"free_memory"),Le(t,e.A)}function Xt(e,t){H(e.A,t),F(e.A,t+"_unused_out")}function An(e){e.g.addBoolToStream(!0,"free_memory",e.B)}var Vr=class{constructor(e){this.g=e,this.H=[],this.B=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){if(t){let r=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(O(this.baseOptions,Zr,1)?.g()||O(this.baseOptions,Zr,1)?.h()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(n,o){let s=O(n.baseOptions,fa,3);if(!s){var a=s=new fa,i=new ia;mr(a,4,Gr,i)}"delegate"in o&&(o.delegate==="GPU"?(o=s,a=new o2,mr(o,2,Gr,a)):(o=s,a=new ia,mr(o,4,Gr,a))),T(n.baseOptions,0,3,s)}(this,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then(n=>{if(n.ok)return n.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${n.status})`)}).then(n=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(n),!0,!1,!1),Yn(this,"/model.dat"),this.m(),this.J()});if(r.modelAssetBuffer instanceof Uint8Array)Yn(this,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(n){let o=[];for(var s=0;;){let{done:a,value:i}=await n.read();if(a)break;o.push(i),s+=i.length}if(o.length===0)return new Uint8Array(0);if(o.length===1)return o[0];n=new Uint8Array(s),s=0;for(let a of o)n.set(a,s),s+=a.length;return n}(r.modelAssetBuffer).then(n=>{Yn(this,n),this.m(),this.J()})}return this.m(),this.J(),Promise.resolve()}J(){}ea(){let e;if(this.g.ea(t=>{e=s2(t)}),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener((r,n)=>{this.H.push(Error(n))}),this.g.La(),this.g.setGraph(e,t),this.A=void 0,ba(this)}finishProcessing(){this.g.finishProcessing(),ba(this)}close(){this.A=void 0,this.g.closeGraph()}};function ge(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}Vr.prototype.close=Vr.prototype.close,za("TaskRunner",Vr);var uo=class{constructor(t,r,n,o){this.g=t,this.h=r,this.m=n,this.l=o}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}};function Ta(e,t,r){let n=e.g;if(r=ge(n.createShader(r),"Failed to create WebGL shader"),n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${n.getShaderInfoLog(r)}`);return n.attachShader(e.h,r),r}function _a(e,t){let r=e.g,n=ge(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);let o=ge(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,o),r.enableVertexAttribArray(e.P),r.vertexAttribPointer(e.P,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);let s=ge(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,s),r.enableVertexAttribArray(e.J),r.vertexAttribPointer(e.J,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.bindVertexArray(null),new uo(r,n,o,s)}function hs(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function Sr(e,t,r,n){return hs(e,t),e.h||(e.m(),e.C()),r?(e.s||(e.s=_a(e,!0)),r=e.s):(e.v||(e.v=_a(e,!1)),r=e.v),t.useProgram(e.h),r.bind(),e.l(),e=n(),r.g.bindVertexArray(null),e}function Tt(e,t,r){return hs(e,t),e=ge(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r??t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r??t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),e}function Rn(e,t,r){hs(e,t),e.A||(e.A=ge(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.A),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0)}function ls(e){e.g?.bindFramebuffer(e.g.FRAMEBUFFER,null)}var nr=class{H(){return`
2
2
  precision mediump float;
3
3
  varying vec2 vTex;
4
4
  uniform sampler2D inputTexture;
@@ -38,7 +38,7 @@ var It=typeof self<"u"?self:{};function za(e,t){e=e.split(".");var r,n=It;for((e
38
38
  overlayColor = mix(defaultColor, overlayColor, overlayColor.a);
39
39
  gl_FragColor = mix(defaultColor, overlayColor, confidence);
40
40
  }
41
- `}C(){let e=this.g;e.activeTexture(e.TEXTURE1),this.j=Tt(this,e),e.activeTexture(e.TEXTURE2),this.B=Tt(this,e)}m(){super.m();let e=this.g;this.K=ge(e.getUniformLocation(this.h,"defaultTexture"),"Uniform location"),this.L=ge(e.getUniformLocation(this.h,"overlayTexture"),"Uniform location"),this.I=ge(e.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();let e=this.g;e.uniform1i(this.I,0),e.uniform1i(this.K,1),e.uniform1i(this.L,2)}close(){this.j&&this.g.deleteTexture(this.j),this.B&&this.g.deleteTexture(this.B),super.close()}};function st(e,t){switch(t){case 0:return e.g.find(r=>r instanceof Uint8Array);case 1:return e.g.find(r=>r instanceof Float32Array);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function ho(e){var t=st(e,1);if(!t){if(t=st(e,0))t=new Float32Array(t).map(n=>n/255);else{t=new Float32Array(e.width*e.height);let n=Ht(e);var r=ds(e);if(Rn(r,n,Lc(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(e.width*e.height*4),n.readPixels(0,0,e.width,e.height,n.RGBA,n.FLOAT,r);for(let o=0,s=0;o<t.length;++o,s+=4)t[o]=r[s]}else n.readPixels(0,0,e.width,e.height,n.RED,n.FLOAT,t)}e.g.push(t)}return t}function Lc(e){let t=st(e,2);if(!t){let r=Ht(e);t=Mc(e);let n=ho(e),o=Ic(e);r.texImage2D(r.TEXTURE_2D,0,o,e.width,e.height,0,r.RED,r.FLOAT,n),lo(e)}return t}function Ht(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return e.h||(e.h=ge(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Ic(e){if(e=Ht(e),!Pr)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Pr=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Pr=e.R16F}return Pr}function ds(e){return e.l||(e.l=new nr),e.l}function Mc(e){let t=Ht(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=st(e,2);return r||(r=Tt(ds(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function lo(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Pr,ae=class{constructor(e,t,r,n,o,s,a){this.g=e,this.m=t,this.j=r,this.canvas=n,this.l=o,this.width=s,this.height=a,this.j&&--Aa===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Ga(){return!!st(this,0)}ka(){return!!st(this,1)}R(){return!!st(this,2)}ja(){return(t=st(e=this,0))||(t=ho(e),t=new Uint8Array(t.map(r=>255*r)),e.g.push(t)),t;var e,t}ia(){return ho(this)}N(){return Lc(this)}clone(){let e=[];for(let t of this.g){let r;if(t instanceof Uint8Array)r=new Uint8Array(t);else if(t instanceof Float32Array)r=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{let n=Ht(this),o=ds(this);n.activeTexture(n.TEXTURE1),r=Tt(o,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);let s=Ic(this);n.texImage2D(n.TEXTURE_2D,0,s,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),Rn(o,n,r),Sr(o,n,!1,()=>{Mc(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),lo(this)}),ls(o),lo(this)}}e.push(r)}return new ae(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Ht(this).deleteTexture(st(this,2)),Aa=-1}};ae.prototype.close=ae.prototype.close,ae.prototype.clone=ae.prototype.clone,ae.prototype.getAsWebGLTexture=ae.prototype.N,ae.prototype.getAsFloat32Array=ae.prototype.ia,ae.prototype.getAsUint8Array=ae.prototype.ja,ae.prototype.hasWebGLTexture=ae.prototype.R,ae.prototype.hasFloat32Array=ae.prototype.ka,ae.prototype.hasUint8Array=ae.prototype.Ga;var Aa=250,U2={color:"white",lineWidth:4,radius:6};function zn(e){return{...U2,fillColor:(e=e||{}).color,...e}}function nt(e,t){return e instanceof Function?e(t):e}function Ra(e,t,r){return Math.max(Math.min(t,r),Math.min(Math.max(t,r),e))}function lr(e){if(!e.l)throw Error("CPU rendering requested but CanvasRenderingContext2D not provided.");return e.l}function Tr(e){if(!e.j)throw Error("GPU rendering requested but WebGL2RenderingContext not provided.");return e.j}function wa(e,t,r){if(t.R())r(t.N());else{let n=t.ka()?t.ia():t.ja();e.m=e.m??new nr;let o=Tr(e);r((e=new ae([n],t.m,!1,o.canvas,e.m,t.width,t.height)).N()),e.close()}}function ka(e,t,r,n){let o=function(i){return i.g||(i.g=new M2),i.g}(e),s=Tr(e),a=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r;Sr(o,s,!0,()=>{(function(c,l,h,f){let d=c.g;if(d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,l),d.activeTexture(d.TEXTURE1),d.bindTexture(d.TEXTURE_2D,c.B),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,h),c.I&&function(b,R){if(b!==R)return!1;b=b.entries(),R=R.entries();for(let[k,S]of b){b=k;let p=S;var A=R.next();if(A.done)return!1;let[x,E]=A.value;if(A=E,b!==x||p[0]!==A[0]||p[1]!==A[1]||p[2]!==A[2]||p[3]!==A[3])return!1}return!!R.next().done}(c.I,f))d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j);else{c.I=f;let b=Array(1024).fill(0);f.forEach((R,A)=>{if(R.length!==4)throw Error(`Color at index ${A} is not a four-channel value.`);b[4*A]=R[0],b[4*A+1]=R[1],b[4*A+2]=R[2],b[4*A+3]=R[3]}),d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,256,1,0,d.RGBA,d.UNSIGNED_BYTE,new Uint8Array(b))}})(o,t,a,n),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.drawArrays(s.TRIANGLE_FAN,0,4);let i=o.g;i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE2),i.bindTexture(i.TEXTURE_2D,null)})}function Sa(e,t,r,n){let o=Tr(e),s=function(c){return c.h||(c.h=new F2),c.h}(e),a=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r,i=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n;Sr(s,o,!0,()=>{var c=s.g;c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,t),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,s.j),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,s.B),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLE_FAN,0,4),o.bindTexture(o.TEXTURE_2D,null),(c=s.g).activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,null)})}var me=class{constructor(e,t){e instanceof CanvasRenderingContext2D||e instanceof OffscreenCanvasRenderingContext2D?(this.l=e,this.j=t):this.j=e}za(e,t){if(e){var r=lr(this);t=zn(t),r.save();var n=r.canvas,o=0;for(let s of e)r.fillStyle=nt(t.fillColor,{index:o,from:s}),r.strokeStyle=nt(t.color,{index:o,from:s}),r.lineWidth=nt(t.lineWidth,{index:o,from:s}),(e=new Path2D).arc(s.x*n.width,s.y*n.height,nt(t.radius,{index:o,from:s}),0,2*Math.PI),r.fill(e),r.stroke(e),++o;r.restore()}}ya(e,t,r){if(e&&t){var n=lr(this);r=zn(r),n.save();var o=n.canvas,s=0;for(let a of t){n.beginPath(),t=e[a.start];let i=e[a.end];t&&i&&(n.strokeStyle=nt(r.color,{index:s,from:t,to:i}),n.lineWidth=nt(r.lineWidth,{index:s,from:t,to:i}),n.moveTo(t.x*o.width,t.y*o.height),n.lineTo(i.x*o.width,i.y*o.height)),++s,n.stroke()}n.restore()}}va(e,t){let r=lr(this);t=zn(t),r.save(),r.beginPath(),r.lineWidth=nt(t.lineWidth,{}),r.strokeStyle=nt(t.color,{}),r.fillStyle=nt(t.fillColor,{}),r.moveTo(e.originX,e.originY),r.lineTo(e.originX+e.width,e.originY),r.lineTo(e.originX+e.width,e.originY+e.height),r.lineTo(e.originX,e.originY+e.height),r.lineTo(e.originX,e.originY),r.stroke(),r.fill(),r.restore()}wa(e,t,r=[0,0,0,255]){this.l?function(n,o,s,a){let i=Tr(n);wa(n,o,c=>{ka(n,c,s,a),(c=lr(n)).drawImage(i.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,r,t):ka(this,e.N(),r,t)}xa(e,t,r){this.l?function(n,o,s,a){let i=Tr(n);wa(n,o,c=>{Sa(n,c,s,a),(c=lr(n)).drawImage(i.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,t,r):Sa(this,e.N(),t,r)}close(){this.g?.close(),this.g=void 0,this.h?.close(),this.h=void 0,this.m?.close(),this.m=void 0}};function Ze(e,t){switch(t){case 0:return e.g.find(r=>r instanceof ImageData);case 1:return e.g.find(r=>typeof ImageBitmap<"u"&&r instanceof ImageBitmap);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function Fc(e){var t=Ze(e,0);if(!t){t=Yt(e);let r=wn(e),n=new Uint8Array(e.width*e.height*4);Rn(r,t,jr(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,n),ls(r),t=new ImageData(new Uint8ClampedArray(n.buffer),e.width,e.height),e.g.push(t)}return t}function jr(e){let t=Ze(e,2);if(!t){let r=Yt(e);t=Wr(e);let n=Ze(e,1)||Fc(e);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,n),fr(e)}return t}function Yt(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");return e.h||(e.h=ge(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function wn(e){return e.l||(e.l=new nr),e.l}function Wr(e){let t=Yt(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=Ze(e,2);return r||(r=Tt(wn(e),t),e.g.push(r),e.m=!0),t.bindTexture(t.TEXTURE_2D,r),r}function fr(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Ca(e){let t=Yt(e);return Sr(wn(e),t,!0,()=>function(r,n){let o=r.canvas;if(o.width===r.width&&o.height===r.height)return n();let s=o.width,a=o.height;return o.width=r.width,o.height=r.height,r=n(),o.width=s,o.height=a,r}(e,()=>{if(t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),!(e.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return e.canvas.transferToImageBitmap()}))}me.prototype.close=me.prototype.close,me.prototype.drawConfidenceMask=me.prototype.xa,me.prototype.drawCategoryMask=me.prototype.wa,me.prototype.drawBoundingBox=me.prototype.va,me.prototype.drawConnectors=me.prototype.ya,me.prototype.drawLandmarks=me.prototype.za,me.lerp=function(e,t,r,n,o){return Ra(n*(1-(e-t)/(r-t))+o*(1-(r-e)/(r-t)),n,o)},me.clamp=Ra,za("DrawingUtils",me);var he=class{constructor(e,t,r,n,o,s,a){this.g=e,this.j=t,this.m=r,this.canvas=n,this.l=o,this.width=s,this.height=a,(this.j||this.m)&&--La===0&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Fa(){return!!Ze(this,0)}la(){return!!Ze(this,1)}R(){return!!Ze(this,2)}Da(){return Fc(this)}Ca(){var e=Ze(this,1);return e||(jr(this),Wr(this),e=Ca(this),fr(this),this.g.push(e),this.j=!0),e}N(){return jr(this)}clone(){let e=[];for(let t of this.g){let r;if(t instanceof ImageData)r=new ImageData(t.data,this.width,this.height);else if(t instanceof WebGLTexture){let n=Yt(this),o=wn(this);n.activeTexture(n.TEXTURE1),r=Tt(o,n),n.bindTexture(n.TEXTURE_2D,r),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,this.width,this.height,0,n.RGBA,n.UNSIGNED_BYTE,null),n.bindTexture(n.TEXTURE_2D,null),Rn(o,n,r),Sr(o,n,!1,()=>{Wr(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),fr(this)}),ls(o),fr(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);jr(this),Wr(this),r=Ca(this),fr(this)}e.push(r)}return new he(e,this.la(),this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Ze(this,1).close(),this.m&&Yt(this).deleteTexture(Ze(this,2)),La=-1}};he.prototype.close=he.prototype.close,he.prototype.clone=he.prototype.clone,he.prototype.getAsWebGLTexture=he.prototype.N,he.prototype.getAsImageBitmap=he.prototype.Ca,he.prototype.getAsImageData=he.prototype.Da,he.prototype.hasWebGLTexture=he.prototype.R,he.prototype.hasImageBitmap=he.prototype.la,he.prototype.hasImageData=he.prototype.Fa;var La=250;function ze(...e){return e.map(([t,r])=>({start:t,end:r}))}var O2=function(e){return class extends e{La(){this.i._registerModelResourcesGraphService()}}}((Ia=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:Sc()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){let t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){let r=e.length,n=this.i._malloc(r);this.i.HEAPU8.set(e,n),t?this.i._changeBinaryGraph(r,n):this.i._changeTextGraph(r,n),this.i._free(n)}configureAudio(e,t,r,n,o){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),v(this,n||"input_audio",s=>{v(this,o=o||"audio_header",a=>{this.i._configureAudio(s,a,e,t??0,r)})})}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ea(e){qe(this,"__graph_config__",t=>{e(t)}),v(this,"__graph_config__",t=>{this.i._getGraphConfig(t,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,n,o){let s=4*e.length;this.h!==s&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(s),this.h=s),this.i.HEAPF32.set(e,this.g/4),v(this,n,a=>{this.i._addAudioToInputStream(this.g,t,r,a,o)})}addGpuBufferToStream(e,t,r){v(this,t,n=>{let[o,s]=va(this,e,n);this.i._addBoundTextureToStream(n,o,s,r)})}addBoolToStream(e,t,r){v(this,t,n=>{this.i._addBoolToInputStream(e,n,r)})}addDoubleToStream(e,t,r){v(this,t,n=>{this.i._addDoubleToInputStream(e,n,r)})}addFloatToStream(e,t,r){v(this,t,n=>{this.i._addFloatToInputStream(e,n,r)})}addIntToStream(e,t,r){v(this,t,n=>{this.i._addIntToInputStream(e,n,r)})}addUintToStream(e,t,r){v(this,t,n=>{this.i._addUintToInputStream(e,n,r)})}addStringToStream(e,t,r){v(this,t,n=>{v(this,e,o=>{this.i._addStringToInputStream(o,n,r)})})}addStringRecordToStream(e,t,r){v(this,t,n=>{Ea(this,Object.keys(e),o=>{Ea(this,Object.values(e),s=>{this.i._addFlatHashMapToInputStream(o,s,Object.keys(e).length,n,r)})})})}addProtoToStream(e,t,r,n){v(this,r,o=>{v(this,t,s=>{let a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,s,o,n),this.i._free(a)})})}addEmptyPacketToStream(e,t){v(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){v(this,t,n=>{let o=this.i._allocateBoolVector(e.length);if(!o)throw Error("Unable to allocate new bool vector on heap.");for(let s of e)this.i._addBoolVectorEntry(o,s);this.i._addBoolVectorToInputStream(o,n,r)})}addDoubleVectorToStream(e,t,r){v(this,t,n=>{let o=this.i._allocateDoubleVector(e.length);if(!o)throw Error("Unable to allocate new double vector on heap.");for(let s of e)this.i._addDoubleVectorEntry(o,s);this.i._addDoubleVectorToInputStream(o,n,r)})}addFloatVectorToStream(e,t,r){v(this,t,n=>{let o=this.i._allocateFloatVector(e.length);if(!o)throw Error("Unable to allocate new float vector on heap.");for(let s of e)this.i._addFloatVectorEntry(o,s);this.i._addFloatVectorToInputStream(o,n,r)})}addIntVectorToStream(e,t,r){v(this,t,n=>{let o=this.i._allocateIntVector(e.length);if(!o)throw Error("Unable to allocate new int vector on heap.");for(let s of e)this.i._addIntVectorEntry(o,s);this.i._addIntVectorToInputStream(o,n,r)})}addUintVectorToStream(e,t,r){v(this,t,n=>{let o=this.i._allocateUintVector(e.length);if(!o)throw Error("Unable to allocate new unsigned int vector on heap.");for(let s of e)this.i._addUintVectorEntry(o,s);this.i._addUintVectorToInputStream(o,n,r)})}addStringVectorToStream(e,t,r){v(this,t,n=>{let o=this.i._allocateStringVector(e.length);if(!o)throw Error("Unable to allocate new string vector on heap.");for(let s of e)v(this,s,a=>{this.i._addStringVectorEntry(o,a)});this.i._addStringVectorToInputStream(o,n,r)})}addBoolToInputSidePacket(e,t){v(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){v(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){v(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){v(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){v(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){v(this,t,r=>{v(this,e,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(e,t,r){v(this,r,n=>{v(this,t,o=>{let s=this.i._malloc(e.length);this.i.HEAPU8.set(e,s),this.i._addProtoToInputSidePacket(s,e.length,o,n),this.i._free(s)})})}addBoolVectorToInputSidePacket(e,t){v(this,t,r=>{let n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let o of e)this.i._addBoolVectorEntry(n,o);this.i._addBoolVectorToInputSidePacket(n,r)})}addDoubleVectorToInputSidePacket(e,t){v(this,t,r=>{let n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let o of e)this.i._addDoubleVectorEntry(n,o);this.i._addDoubleVectorToInputSidePacket(n,r)})}addFloatVectorToInputSidePacket(e,t){v(this,t,r=>{let n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let o of e)this.i._addFloatVectorEntry(n,o);this.i._addFloatVectorToInputSidePacket(n,r)})}addIntVectorToInputSidePacket(e,t){v(this,t,r=>{let n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let o of e)this.i._addIntVectorEntry(n,o);this.i._addIntVectorToInputSidePacket(n,r)})}addUintVectorToInputSidePacket(e,t){v(this,t,r=>{let n=this.i._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let o of e)this.i._addUintVectorEntry(n,o);this.i._addUintVectorToInputSidePacket(n,r)})}addStringVectorToInputSidePacket(e,t){v(this,t,r=>{let n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let o of e)v(this,o,s=>{this.i._addStringVectorEntry(n,s)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(e,t){qe(this,e,t),v(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){lt(this,e,t),v(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){qe(this,e,t),v(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){lt(this,e,t),v(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){qe(this,e,t),v(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){lt(this,e,t),v(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){qe(this,e,t),v(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){lt(this,e,t),v(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){qe(this,e,t),v(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){lt(this,e,t),v(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){qe(this,e,t),v(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){lt(this,e,t),v(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){qe(this,e,t),v(this,e,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(e,t,r){lt(this,e,t),v(this,e,n=>{this.i._attachProtoVectorListener(n,r||!1)})}attachAudioListener(e,t,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),qe(this,e,(n,o)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),t(n,o)}),v(this,e,n=>{this.i._attachAudioListener(n,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Ia{get fa(){return this.i}ra(e,t,r){v(this,t,n=>{let[o,s]=va(this,e,n);this.fa._addBoundTextureAsImageToStream(n,o,s,r)})}V(e,t){qe(this,e,t),v(this,e,r=>{this.fa._attachImageListener(r)})}da(e,t){lt(this,e,t),v(this,e,r=>{this.fa._attachImageVectorListener(r)})}})),Ia,Be=class extends O2{};async function M(e,t,r){return async function(n,o,s,a){return I2(n,o,s,a)}(e,r.canvas??(Sc()?void 0:document.createElement("canvas")),t,r)}function Uc(e,t,r,n){if(e.U){let s=new nc;if(r?.regionOfInterest){if(!e.qa)throw Error("This task doesn't support region-of-interest.");var o=r.regionOfInterest;if(o.left>=o.right||o.top>=o.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(o.left<0||o.top<0||o.right>1||o.bottom>1)throw Error("Expected RectF values to be in [0,1].");y(s,1,(o.left+o.right)/2),y(s,2,(o.top+o.bottom)/2),y(s,4,o.right-o.left),y(s,3,o.bottom-o.top)}else y(s,1,.5),y(s,2,.5),y(s,4,1),y(s,3,1);if(r?.rotationDegrees){if(r?.rotationDegrees%90!=0)throw Error("Expected rotation to be a multiple of 90\xB0.");if(y(s,5,-Math.PI*r.rotationDegrees/180),r?.rotationDegrees%180!=0){let[a,i]=Cc(t);r=te(s,3)*i/a,o=te(s,4)*a/i,y(s,4,r),y(s,3,o)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,n)}e.g.ra(t,e.ba,n??performance.now()),e.finishProcessing()}function De(e,t,r){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Uc(e,t,r,e.B+1)}function rt(e,t,r,n){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Uc(e,t,r,n)}function zt(e,t,r,n){var o=t.data;let s=t.width,a=s*(t=t.height);if((o instanceof Uint8Array||o instanceof Float32Array)&&o.length!==a)throw Error("Unsupported channel count: "+o.length/a);return e=new ae([o],r,!1,e.g.i.canvas,e.P,s,t),n?e.clone():e}var Ee=class extends Vr{constructor(e,t,r,n){super(e),this.g=e,this.ba=t,this.U=r,this.qa=n,this.P=new nr}l(e,t=!0){if("runningMode"in e&&Er(this.baseOptions,2,!!e.runningMode&&e.runningMode!=="IMAGE"),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Ee.prototype.close=Ee.prototype.close;var Ie=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},T(e=this.h=new bn,0,1,t=new $),y(this.h,2,.5),y(this.h,3,.3)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&y(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&y(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}D(e,t){return this.j={detections:[]},De(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect_in"),P(e,"detections");let t=new ke;Xe(t,x2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect_in"),F(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(n,o)=>{for(let s of n)n=ec(s),this.j.detections.push(wc(n));m(this,o)}),this.g.attachEmptyPacketListener("detections",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ie.prototype.detectForVideo=Ie.prototype.F,Ie.prototype.detect=Ie.prototype.D,Ie.prototype.setOptions=Ie.prototype.o,Ie.createFromModelPath=async function(e,t){return M(Ie,e,{baseOptions:{modelAssetPath:t}})},Ie.createFromModelBuffer=function(e,t){return M(Ie,e,{baseOptions:{modelAssetBuffer:t}})},Ie.createFromOptions=function(e,t){return M(Ie,e,t)};var fs=ze([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),ps=ze([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),ms=ze([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Oc=ze([474,475],[475,476],[476,477],[477,474]),gs=ze([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),xs=ze([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Pc=ze([469,470],[470,471],[471,472],[472,469]),ys=ze([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Bc=[...fs,...ps,...ms,...gs,...xs,...ys],Dc=ze([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function Ma(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Q=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,T(e=this.h=new cc,0,1,t=new $),this.v=new ic,T(this.h,0,3,this.v),this.s=new bn,T(this.h,0,2,this.s),tt(this.s,4,1),y(this.s,2,.5),y(this.v,2,.5),y(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numFaces"in e&&tt(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&y(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&y(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&y(this.v,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}D(e,t){return Ma(this),De(this,e,t),this.j}F(e,t,r){return Ma(this),rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"face_landmarks");let t=new ke;Xe(t,v2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("face_landmarks",(n,o)=>{for(let s of n)n=kr(s),this.j.faceLandmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{m(this,n)}),this.outputFaceBlendshapes&&(P(e,"blendshapes"),F(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,o)=>{if(this.outputFaceBlendshapes)for(let s of n)n=En(s),this.j.faceBlendshapes.push(us(n.g()??[]));m(this,o)}),this.g.attachEmptyPacketListener("blendshapes",n=>{m(this,n)})),this.outputFacialTransformationMatrixes&&(P(e,"face_geometry"),F(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,o)=>{if(this.outputFacialTransformationMatrixes)for(let s of n)(n=O(y2(s),u2,2))&&this.j.facialTransformationMatrixes.push({rows:je(Oe(n,1),0)??0,columns:je(Oe(n,2),0)??0,data:Ct(n,3,At,St()).slice()??[]});m(this,o)}),this.g.attachEmptyPacketListener("face_geometry",n=>{m(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Q.prototype.detectForVideo=Q.prototype.F,Q.prototype.detect=Q.prototype.D,Q.prototype.setOptions=Q.prototype.o,Q.createFromModelPath=function(e,t){return M(Q,e,{baseOptions:{modelAssetPath:t}})},Q.createFromModelBuffer=function(e,t){return M(Q,e,{baseOptions:{modelAssetBuffer:t}})},Q.createFromOptions=function(e,t){return M(Q,e,t)},Q.FACE_LANDMARKS_LIPS=fs,Q.FACE_LANDMARKS_LEFT_EYE=ps,Q.FACE_LANDMARKS_LEFT_EYEBROW=ms,Q.FACE_LANDMARKS_LEFT_IRIS=Oc,Q.FACE_LANDMARKS_RIGHT_EYE=gs,Q.FACE_LANDMARKS_RIGHT_EYEBROW=xs,Q.FACE_LANDMARKS_RIGHT_IRIS=Pc,Q.FACE_LANDMARKS_FACE_OVAL=ys,Q.FACE_LANDMARKS_CONTOURS=Bc,Q.FACE_LANDMARKS_TESSELATION=Dc;var Je=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!0),T(e=this.j=new hc,0,1,t=new $)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){return super.l(e)}Oa(e,t,r){let n=typeof t!="function"?t:{};if(this.h=typeof t=="function"?t:r,De(this,e,n??{}),!this.h)return this.s}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"stylized_image");let t=new ke;Xe(t,E2,this.j);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"STYLIZED_IMAGE:stylized_image"),r.o(t),Le(e,r),this.g.V("stylized_image",(n,o)=>{var s=!this.h,a=n.data,i=n.width;let c=i*(n=n.height);if(a instanceof Uint8Array)if(a.length===3*c){let l=new Uint8ClampedArray(4*c);for(let h=0;h<c;++h)l[4*h]=a[3*h],l[4*h+1]=a[3*h+1],l[4*h+2]=a[3*h+2],l[4*h+3]=255;a=new ImageData(l,i,n)}else{if(a.length!==4*c)throw Error("Unsupported channel count: "+a.length/c);a=new ImageData(new Uint8ClampedArray(a.buffer,a.byteOffset,a.length),i,n)}else if(!(a instanceof WebGLTexture))throw Error(`Unsupported format: ${a.constructor.name}`);i=new he([a],!1,!1,this.g.i.canvas,this.P,i,n),this.s=s=s?i.clone():i,this.h&&this.h(s),m(this,o)}),this.g.attachEmptyPacketListener("stylized_image",n=>{this.s=null,this.h&&this.h(null),m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Je.prototype.stylize=Je.prototype.Oa,Je.prototype.setOptions=Je.prototype.o,Je.createFromModelPath=function(e,t){return M(Je,e,{baseOptions:{modelAssetPath:t}})},Je.createFromModelBuffer=function(e,t){return M(Je,e,{baseOptions:{modelAssetBuffer:t}})},Je.createFromOptions=function(e,t){return M(Je,e,t)};var vs=ze([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function Fa(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Ua(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function Oa(e,t=!0){let r=[];for(let o of e){var n=En(o);e=[];for(let s of n.g())n=t&&Oe(s,1)!=null?je(Oe(s,1),0):-1,e.push({score:te(s,2)??0,index:n,categoryName:et(s,3)??"",displayName:et(s,4)??""});r.push(e)}return r}var Te=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],T(e=this.j=new fc,0,1,t=new $),this.s=new ss,T(this.j,0,2,this.s),this.C=new os,T(this.s,0,3,this.C),this.v=new dc,T(this.s,0,2,this.v),this.h=new b2,T(this.j,0,3,this.h),y(this.v,2,.5),y(this.s,4,.5),y(this.C,2,.5)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){if(tt(this.v,3,e.numHands??1),"minHandDetectionConfidence"in e&&y(this.v,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&y(this.s,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&y(this.C,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Ut,r=t,n=co(e.cannedGesturesClassifierOptions,O(this.h,Ut,3)?.h());T(r,0,2,n),T(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&O(this.h,Ut,3)?.g();return e.customGesturesClassifierOptions?(T(r=t=new Ut,0,2,n=co(e.customGesturesClassifierOptions,O(this.h,Ut,4)?.h())),T(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&O(this.h,Ut,4)?.g(),this.l(e)}Ja(e,t){return Fa(this),De(this,e,t),Ua(this)}Ka(e,t,r){return Fa(this),rt(this,e,r,t),Ua(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"hand_gestures"),P(e,"hand_landmarks"),P(e,"world_hand_landmarks"),P(e,"handedness");let t=new ke;Xe(t,T2,this.j);let r=new xe;Ce(r,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"HAND_GESTURES:hand_gestures"),F(r,"LANDMARKS:hand_landmarks"),F(r,"WORLD_LANDMARKS:world_hand_landmarks"),F(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,o)=>{for(let s of n){n=kr(s);let a=[];for(let i of ct(n,rc,1))a.push({x:te(i,1)??0,y:te(i,2)??0,z:te(i,3)??0,visibility:te(i,4)??0});this.landmarks.push(a)}m(this,o)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,o)=>{for(let s of n){n=Nt(s);let a=[];for(let i of ct(n,tc,1))a.push({x:te(i,1)??0,y:te(i,2)??0,z:te(i,3)??0,visibility:te(i,4)??0});this.worldLandmarks.push(a)}m(this,o)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,o)=>{this.gestures.push(...Oa(n,!1)),m(this,o)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{m(this,n)}),this.g.attachProtoVectorListener("handedness",(n,o)=>{this.handedness.push(...Oa(n)),m(this,o)}),this.g.attachEmptyPacketListener("handedness",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Pa(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Te.prototype.recognizeForVideo=Te.prototype.Ka,Te.prototype.recognize=Te.prototype.Ja,Te.prototype.setOptions=Te.prototype.o,Te.createFromModelPath=function(e,t){return M(Te,e,{baseOptions:{modelAssetPath:t}})},Te.createFromModelBuffer=function(e,t){return M(Te,e,{baseOptions:{modelAssetBuffer:t}})},Te.createFromOptions=function(e,t){return M(Te,e,t)},Te.HAND_CONNECTIONS=vs;var _e=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],T(e=this.h=new ss,0,1,t=new $),this.s=new os,T(this.h,0,3,this.s),this.j=new dc,T(this.h,0,2,this.j),tt(this.j,3,1),y(this.j,2,.5),y(this.s,2,.5),y(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numHands"in e&&tt(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&y(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&y(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&y(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}D(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],De(this,e,t),Pa(this)}F(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],rt(this,e,r,t),Pa(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"hand_landmarks"),P(e,"world_hand_landmarks"),P(e,"handedness");let t=new ke;Xe(t,_2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"LANDMARKS:hand_landmarks"),F(r,"WORLD_LANDMARKS:world_hand_landmarks"),F(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,o)=>{for(let s of n)n=kr(s),this.landmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,o)=>{for(let s of n)n=Nt(s),this.worldLandmarks.push(xr(n));m(this,o)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("handedness",(n,o)=>{var s=this.handedness,a=s.push;let i=[];for(let c of n){n=En(c);let l=[];for(let h of n.g())l.push({score:te(h,2)??0,index:je(Oe(h,1),0)??-1,categoryName:et(h,3)??"",displayName:et(h,4)??""});i.push(l)}a.call(s,...i),m(this,o)}),this.g.attachEmptyPacketListener("handedness",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};_e.prototype.detectForVideo=_e.prototype.F,_e.prototype.detect=_e.prototype.D,_e.prototype.setOptions=_e.prototype.o,_e.createFromModelPath=function(e,t){return M(_e,e,{baseOptions:{modelAssetPath:t}})},_e.createFromModelBuffer=function(e,t){return M(_e,e,{baseOptions:{modelAssetBuffer:t}})},_e.createFromOptions=function(e,t){return M(_e,e,t)},_e.HAND_CONNECTIONS=vs;var Nc=ze([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function Ba(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Da(e){try{if(!e.C)return e.h;e.C(e.h)}finally{An(e)}}function Br(e,t){e=kr(e),t.push(Tn(e))}var K=class extends Ee{constructor(e,t){super(new Be(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,T(e=this.j=new yc,0,1,t=new $),this.K=new os,T(this.j,0,2,this.K),this.aa=new A2,T(this.j,0,3,this.aa),this.s=new bn,T(this.j,0,4,this.s),this.I=new ic,T(this.j,0,5,this.I),this.v=new gc,T(this.j,0,6,this.v),this.L=new xc,T(this.j,0,7,this.L),y(this.s,2,.5),y(this.s,3,.3),y(this.I,2,.5),y(this.v,2,.5),y(this.v,3,.3),y(this.L,2,.5),y(this.K,2,.5)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&y(this.s,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&y(this.s,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&y(this.I,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&y(this.v,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&y(this.v,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&y(this.L,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&y(this.K,2,e.minHandLandmarksConfidence??.5),this.l(e)}D(e,t,r){let n=typeof t!="function"?t:{};return this.C=typeof t=="function"?t:r,Ba(this),De(this,e,n),Da(this)}F(e,t,r,n){let o=typeof r!="function"?r:{};return this.C=typeof r=="function"?r:n,Ba(this),rt(this,e,o,t),Da(this)}m(){var e=new be;Y(e,"input_frames_image"),P(e,"pose_landmarks"),P(e,"pose_world_landmarks"),P(e,"face_landmarks"),P(e,"left_hand_landmarks"),P(e,"left_hand_world_landmarks"),P(e,"right_hand_landmarks"),P(e,"right_hand_world_landmarks");let t=new ke,r=new na;to(r,1,Jt("type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),""),function(o,s){if(s!=null)if(Array.isArray(s))X(o,2,cn(s,Mo,void 0,void 0,!1));else{if(!(typeof s=="string"||s instanceof at||_r(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");to(o,2,_o(s,!1),Mt())}}(r,this.j.g());let n=new xe;Ce(n,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),$r(n,8,na,r),H(n,"IMAGE:input_frames_image"),F(n,"POSE_LANDMARKS:pose_landmarks"),F(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),F(n,"FACE_LANDMARKS:face_landmarks"),F(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),F(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),F(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),F(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(t),Le(e,n),_n(this,e),this.g.attachProtoListener("pose_landmarks",(o,s)=>{Br(o,this.h.poseLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("pose_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("pose_world_landmarks",(o,s)=>{var a=this.h.poseWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",o=>{m(this,o)}),this.outputPoseSegmentationMasks&&(F(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Xt(this,"pose_segmentation_mask"),this.g.V("pose_segmentation_mask",(o,s)=>{this.h.poseSegmentationMasks=[zt(this,o,!0,!this.C)],m(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",o=>{this.h.poseSegmentationMasks=[],m(this,o)})),this.g.attachProtoListener("face_landmarks",(o,s)=>{Br(o,this.h.faceLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",o=>{m(this,o)}),this.outputFaceBlendshapes&&(P(e,"extra_blendshapes"),F(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(o,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(o=En(o),a.push(us(o.g()??[]))),m(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",o=>{m(this,o)})),this.g.attachProtoListener("left_hand_landmarks",(o,s)=>{Br(o,this.h.leftHandLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("left_hand_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("left_hand_world_landmarks",(o,s)=>{var a=this.h.leftHandWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("right_hand_landmarks",(o,s)=>{Br(o,this.h.rightHandLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("right_hand_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("right_hand_world_landmarks",(o,s)=>{var a=this.h.rightHandWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",o=>{m(this,o)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};K.prototype.detectForVideo=K.prototype.F,K.prototype.detect=K.prototype.D,K.prototype.setOptions=K.prototype.o,K.createFromModelPath=function(e,t){return M(K,e,{baseOptions:{modelAssetPath:t}})},K.createFromModelBuffer=function(e,t){return M(K,e,{baseOptions:{modelAssetBuffer:t}})},K.createFromOptions=function(e,t){return M(K,e,t)},K.HAND_CONNECTIONS=vs,K.POSE_CONNECTIONS=Nc,K.FACE_LANDMARKS_LIPS=fs,K.FACE_LANDMARKS_LEFT_EYE=ps,K.FACE_LANDMARKS_LEFT_EYEBROW=ms,K.FACE_LANDMARKS_LEFT_IRIS=Oc,K.FACE_LANDMARKS_RIGHT_EYE=gs,K.FACE_LANDMARKS_RIGHT_EYEBROW=xs,K.FACE_LANDMARKS_RIGHT_IRIS=Pc,K.FACE_LANDMARKS_FACE_OVAL=ys,K.FACE_LANDMARKS_CONTOURS=Bc,K.FACE_LANDMARKS_TESSELATION=Dc;var Me=class extends Ee{constructor(e,t){super(new Be(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},T(e=this.h=new vc,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return T(this.h,0,2,co(e,O(this.h,ts,2))),this.l(e)}ta(e,t){return this.j={classifications:[]},De(this,e,t),this.j}ua(e,t,r){return this.j={classifications:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"input_image"),Y(e,"norm_rect"),P(e,"classifications");let t=new ke;Xe(t,R2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),H(r,"IMAGE:input_image"),H(r,"NORM_RECT:norm_rect"),F(r,"CLASSIFICATIONS:classifications"),r.o(t),Le(e,r),this.g.attachProtoListener("classifications",(n,o)=>{this.j=function(s){let a={classifications:ct(s,l2,1).map(i=>us(O(i,Qi,4)?.g()??[],je(Oe(i,2),0),et(i,3)))};return zr(vt(s,2))!=null&&(a.timestampMs=je(zr(vt(s,2)),0)),a}(d2(n)),m(this,o)}),this.g.attachEmptyPacketListener("classifications",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Me.prototype.classifyForVideo=Me.prototype.ua,Me.prototype.classify=Me.prototype.ta,Me.prototype.setOptions=Me.prototype.o,Me.createFromModelPath=function(e,t){return M(Me,e,{baseOptions:{modelAssetPath:t}})},Me.createFromModelBuffer=function(e,t){return M(Me,e,{baseOptions:{modelAssetBuffer:t}})},Me.createFromOptions=function(e,t){return M(Me,e,t)};var Ae=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!0),this.h=new Ec,this.embeddings={embeddings:[]},T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){var t=this.h,r=O(this.h,da,2);return r=r?r.clone():new da,e.l2Normalize!==void 0?Er(r,1,e.l2Normalize):"l2Normalize"in e&&X(r,1),e.quantize!==void 0?Er(r,2,e.quantize):"quantize"in e&&X(r,2),T(t,0,2,r),this.l(e)}Aa(e,t){return De(this,e,t),this.embeddings}Ba(e,t,r){return rt(this,e,r,t),this.embeddings}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"embeddings_out");let t=new ke;Xe(t,w2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"EMBEDDINGS:embeddings_out"),r.o(t),Le(e,r),this.g.attachProtoListener("embeddings_out",(n,o)=>{n=m2(n),this.embeddings=function(s){return{embeddings:ct(s,p2,1).map(a=>{let i={headIndex:je(Oe(a,3),0)??-1,headName:et(a,4)??""};if(xi(a,la,Vn(a,1))!==void 0)a=Ct(a=O(a,la,Vn(a,1)),1,At,St()),i.floatEmbedding=a.slice();else{let c=new Uint8Array(0);i.quantizedEmbedding=O(a,f2,Vn(a,2))?.pa()?.h()??c}return i}),timestampMs:je(zr(vt(s,2)),0)}}(n),m(this,o)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ae.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=xa(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=xa(ga(e.quantizedEmbedding),ga(t.quantizedEmbedding))}return e},Ae.prototype.embedForVideo=Ae.prototype.Ba,Ae.prototype.embed=Ae.prototype.Aa,Ae.prototype.setOptions=Ae.prototype.o,Ae.createFromModelPath=function(e,t){return M(Ae,e,{baseOptions:{modelAssetPath:t}})},Ae.createFromModelBuffer=function(e,t){return M(Ae,e,{baseOptions:{modelAssetBuffer:t}})},Ae.createFromOptions=function(e,t){return M(Ae,e,t)};var fo=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){this.confidenceMasks?.forEach(e=>{e.close()}),this.categoryMask?.close()}};function Na(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function Ga(e){try{let t=new fo(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{An(e)}}fo.prototype.close=fo.prototype.close;var de=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new cs,this.v=new bc,T(this.h,0,3,this.v),T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?X(this.h,2,Jt(e.displayNamesLocale)):"displayNamesLocale"in e&&X(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}J(){(function(e){let t=ct(e.ea(),xe,1).filter(r=>et(r,1).includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.s=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(O(t[0],ke,7)?.l()?.g()??new Map).forEach((r,n)=>{e.s[Number(n)]=et(r,1)})})(this)}segment(e,t,r){let n=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,Na(this),De(this,e,n),Ga(this)}Ma(e,t,r,n){let o=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,Na(this),rt(this,e,o,t),Ga(this)}Ea(){return this.s}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect");let t=new ke;Xe(t,_c,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),r.o(t),Le(e,r),_n(this,e),this.outputConfidenceMasks&&(P(e,"confidence_masks"),F(r,"CONFIDENCE_MASKS:confidence_masks"),Xt(this,"confidence_masks"),this.g.da("confidence_masks",(n,o)=>{this.confidenceMasks=n.map(s=>zt(this,s,!0,!this.j)),m(this,o)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],m(this,n)})),this.outputCategoryMask&&(P(e,"category_mask"),F(r,"CATEGORY_MASK:category_mask"),Xt(this,"category_mask"),this.g.V("category_mask",(n,o)=>{this.categoryMask=zt(this,n,!1,!this.j),m(this,o)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,m(this,n)})),P(e,"quality_scores"),F(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,o)=>{this.qualityScores=n,m(this,o)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};de.prototype.getLabels=de.prototype.Ea,de.prototype.segmentForVideo=de.prototype.Ma,de.prototype.segment=de.prototype.segment,de.prototype.setOptions=de.prototype.o,de.createFromModelPath=function(e,t){return M(de,e,{baseOptions:{modelAssetPath:t}})},de.createFromModelBuffer=function(e,t){return M(de,e,{baseOptions:{modelAssetBuffer:t}})},de.createFromOptions=function(e,t){return M(de,e,t)};var po=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){this.confidenceMasks?.forEach(e=>{e.close()}),this.categoryMask?.close()}};po.prototype.close=po.prototype.close;var P2=class extends g{constructor(e){super(e)}},Ot=[0,ee,-2],en=[0,ot,-3,q,ot,-1],Va=[0,en],ja=[0,en,ee,-1],Kn=class extends g{constructor(e){super(e)}},Wa=[0,ot,-1,q],B2=class extends g{constructor(){super()}},Xa=class extends g{constructor(e){super(e)}},mo=[1,2,3,4,5,6,7,8,9,10,14,15],Gc=class extends g{constructor(){super()}};Gc.prototype.g=vn([0,ie,[0,mo,N,en,N,[0,en,Ot],N,Va,N,[0,Va,Ot],N,Wa,N,[0,ot,-3,q,We],N,[0,ot,-3,q],N,[0,D,ot,-2,q,ee,q,-1,2,ot,Ot],N,ja,N,[0,ja,Ot],ot,Ot,D,N,[0,ot,-3,q,Ot,-1],N,[0,ie,Wa]],D,[0,D,ee,-1,q]]);var Qe=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new cs,this.s=new bc,T(this.h,0,3,this.s),T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,r,n){let o=typeof r!="function"?r:{};this.j=typeof r=="function"?r:n,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.B+1,n=new Gc;let s=new Xa;var a=new P2;if(tt(a,1,255),T(s,0,12,a),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var i=new Kn;Er(i,3,!0),y(i,1,t.keypoint.x),y(i,2,t.keypoint.y),mr(s,5,mo,i)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(i of(a=new B2,t.scribble))Er(t=new Kn,3,!0),y(t,1,i.x),y(t,2,i.y),$r(a,1,Kn,t);mr(s,15,mo,a)}$r(n,1,Xa,s),this.g.addProtoToStream(n.g(),"drishti.RenderData","roi_in",r),De(this,e,o);e:{try{let l=new po(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var c=l;break e}this.j(l)}finally{An(this)}c=void 0}return c}m(){var e=new be;Y(e,"image_in"),Y(e,"roi_in"),Y(e,"norm_rect_in");let t=new ke;Xe(t,_c,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),H(r,"IMAGE:image_in"),H(r,"ROI:roi_in"),H(r,"NORM_RECT:norm_rect_in"),r.o(t),Le(e,r),_n(this,e),this.outputConfidenceMasks&&(P(e,"confidence_masks"),F(r,"CONFIDENCE_MASKS:confidence_masks"),Xt(this,"confidence_masks"),this.g.da("confidence_masks",(n,o)=>{this.confidenceMasks=n.map(s=>zt(this,s,!0,!this.j)),m(this,o)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],m(this,n)})),this.outputCategoryMask&&(P(e,"category_mask"),F(r,"CATEGORY_MASK:category_mask"),Xt(this,"category_mask"),this.g.V("category_mask",(n,o)=>{this.categoryMask=zt(this,n,!1,!this.j),m(this,o)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,m(this,n)})),P(e,"quality_scores"),F(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,o)=>{this.qualityScores=n,m(this,o)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Qe.prototype.segment=Qe.prototype.segment,Qe.prototype.setOptions=Qe.prototype.o,Qe.createFromModelPath=function(e,t){return M(Qe,e,{baseOptions:{modelAssetPath:t}})},Qe.createFromModelBuffer=function(e,t){return M(Qe,e,{baseOptions:{modelAssetBuffer:t}})},Qe.createFromOptions=function(e,t){return M(Qe,e,t)};var Fe=class extends Ee{constructor(e,t){super(new Be(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},T(e=this.h=new Ac,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?X(this.h,2,Jt(e.displayNamesLocale)):"displayNamesLocale"in e&&X(this.h,2),e.maxResults!==void 0?tt(this.h,3,e.maxResults):"maxResults"in e&&X(this.h,3),e.scoreThreshold!==void 0?y(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&X(this.h,4),e.categoryAllowlist!==void 0?qr(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&X(this.h,5),e.categoryDenylist!==void 0?qr(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&X(this.h,6),this.l(e)}D(e,t){return this.j={detections:[]},De(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"input_frame_gpu"),Y(e,"norm_rect"),P(e,"detections");let t=new ke;Xe(t,S2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.ObjectDetectorGraph"),H(r,"IMAGE:input_frame_gpu"),H(r,"NORM_RECT:norm_rect"),F(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(n,o)=>{for(let s of n)n=ec(s),this.j.detections.push(wc(n));m(this,o)}),this.g.attachEmptyPacketListener("detections",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Fe.prototype.detectForVideo=Fe.prototype.F,Fe.prototype.detect=Fe.prototype.D,Fe.prototype.setOptions=Fe.prototype.o,Fe.createFromModelPath=async function(e,t){return M(Fe,e,{baseOptions:{modelAssetPath:t}})},Fe.createFromModelBuffer=function(e,t){return M(Fe,e,{baseOptions:{modelAssetBuffer:t}})},Fe.createFromOptions=function(e,t){return M(Fe,e,t)};var go=class{constructor(e,t,r){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=r}close(){this.segmentationMasks?.forEach(e=>{e.close()})}};function Ha(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function Ya(e){try{let t=new go(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.s)return t;e.s(t)}finally{An(e)}}go.prototype.close=go.prototype.close;var Re=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,T(e=this.h=new Rc,0,1,t=new $),this.v=new xc,T(this.h,0,3,this.v),this.j=new gc,T(this.h,0,2,this.j),tt(this.j,4,1),y(this.j,2,.5),y(this.v,2,.5),y(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numPoses"in e&&tt(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&y(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&y(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&y(this.v,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}D(e,t,r){let n=typeof t!="function"?t:{};return this.s=typeof t=="function"?t:r,Ha(this),De(this,e,n),Ya(this)}F(e,t,r,n){let o=typeof r!="function"?r:{};return this.s=typeof r=="function"?r:n,Ha(this),rt(this,e,o,t),Ya(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"normalized_landmarks"),P(e,"world_landmarks"),P(e,"segmentation_masks");let t=new ke;Xe(t,C2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"NORM_LANDMARKS:normalized_landmarks"),F(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),Le(e,r),_n(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(n,o)=>{this.landmarks=[];for(let s of n)n=kr(s),this.landmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],m(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,o)=>{this.worldLandmarks=[];for(let s of n)n=Nt(s),this.worldLandmarks.push(xr(n));m(this,o)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],m(this,n)}),this.outputSegmentationMasks&&(F(r,"SEGMENTATION_MASK:segmentation_masks"),Xt(this,"segmentation_masks"),this.g.da("segmentation_masks",(n,o)=>{this.segmentationMasks=n.map(s=>zt(this,s,!0,!this.s)),m(this,o)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],m(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Re.prototype.detectForVideo=Re.prototype.F,Re.prototype.detect=Re.prototype.D,Re.prototype.setOptions=Re.prototype.o,Re.createFromModelPath=function(e,t){return M(Re,e,{baseOptions:{modelAssetPath:t}})},Re.createFromModelBuffer=function(e,t){return M(Re,e,{baseOptions:{modelAssetBuffer:t}})},Re.createFromOptions=function(e,t){return M(Re,e,t)},Re.POSE_CONNECTIONS=Nc;var _=(e,t="AssertError")=>{if(!e)throw new Error(t,{cause:e});return e};var Es=e=>e;var bs=(e,...t)=>{let r=t.reduce((n,o)=>s=>o(n(s)),Es);return(...n)=>r(e(...n))};var N2="utils/memoize/noValue",Ll=Symbol(N2);var G2=e=>`(${e})`;var Vc=e=>G2(`?:${e}`),V2=e=>`${Vc(e)}?`,j2=e=>`${Vc(e)}*`;var W2=e=>`^${e}`,X2=e=>`${e}$`,H2=e=>typeof e=="function",Y2=e=>t=>H2(t)?t(e):t;var z2=()=>e=>e,kn=(e,t=z2)=>r=>n=>bs(Y2(n),t(n),e)(r);var Fl=kn(e=>V2(e)),Ul=kn(e=>j2(e));var Ol=kn(e=>W2(e)),Pl=kn(e=>X2(e));var z={Closed:"closed",Closing:"closing",Destroyed:"destroyed",Destroying:"destroying",Error:"Error",Idle:"idle",New:"new",Opened:"opened",Opening:"opening",Processing:"processing",Updated:"updated",Updating:"updating"},jc={None:"none",Blur:"blur",Overlay:"overlay"},Wc={WebGL:"webgl",WebGPU:"webgpu"},C={ContextCreationError:"ContextCreationError",ContextLost:"ContextLost",ContextRestored:"ContextRestored",Error:"Error",ProcessorRestarted:"ProcessorRestarted",SamplingError:"SamplingError"};var K2=e=>!!(typeof e=="string"&&Object.values(C).includes(e)),Sn=e=>K2(e)?e:C.Error,Cn=e=>e instanceof Error?e.message:String(e),Ln=e=>{let t=new Set(Object.keys(e));return r=>{for(let n in r)t.has(n)&&typeof e[n]==typeof r[n]&&(e[n]=r[n])}},Xc=e=>{let t=new Map(e),r=new Set,n=async a=>{let c=await(await fetch(a)).blob();return await createImageBitmap(c)},o=async a=>{let i=t.get(a);if(!i){if(r.has(a))return null;r.add(a);let c=await n(a);return t.set(a,c),r.delete(a),c}return i},s=a=>(t.get(a)?.close(),t.delete(a));return{tryFetchingImage:o,setImage:(a,i)=>{t.has(a)&&s(a),t.set(a,i)},getImage:a=>t.get(a)??null,removeImage:s,clear:()=>{for(let a of t.values())a.close();t.clear()}}},In=(e,t)=>r=>Math.min(Math.max(r,e),t);var Hc=(e,t,r,n)=>{if(!e||!t||!r||!n||e*n===r*t)return{sx:0,sy:0,sw:e,sh:t,dx:0,dy:0,dw:r,dh:n};let o=e/t,s=r/n;if(o>s){let l=Math.ceil(e*s)/o,h=Math.abs(e-l);return{sx:Math.ceil(h/2),sy:0,sw:l,sh:t,dx:0,dy:0,dw:r,dh:n}}let a=Math.ceil(t*o)/s,i=Math.abs(t-a);return{sx:0,sy:Math.ceil(i/2),sw:e,sh:a,dx:0,dy:0,dw:r,dh:n}},or=e=>{let t={};return new Proxy(t,{get(r,n,o){return r[n]||(r[n]=e[n]?.(t)),Reflect.get(r,n,o)}})},Yc=(e,t,r)=>{let n=a=>{a.preventDefault(),r?.(),t.contextLost(a.statusMessage)},o=a=>{t.contextRestored(a.statusMessage)},s=a=>{t.contextCreationError(a.statusMessage)};return e.addEventListener("webglcontextlost",n),e.addEventListener("webglcontextrestored",o),e.addEventListener("webglcontextcreationerror",s),()=>{e.removeEventListener("webglcontextlost",n),e.removeEventListener("webglcontextrestored",o),e.removeEventListener("webglcontextcreationerror",s)}};var zc=(e,t,r)=>{let n=navigator.gpu.getPreferredCanvasFormat(),o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");o.configure({device:t,format:n});let s;return{render:a=>(_(!r(),C.ContextLost),s=t.createTexture({label:"Video Frame to Texture",format:"rgba8unorm",size:[a.width,a.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT}),t.queue.copyExternalImageToTexture({source:a.frame,flipY:!1},{texture:s},{width:a.width,height:a.height}),t.queue.submit([]),s),release:()=>{s?.destroy()}}};var Ts="@group(0)@binding(0)var mySampler:sampler;@group(0)@binding(1)var bgTexture:texture_2d<f32>;@group(0)@binding(2)var personTexture:texture_2d<f32>;@group(0)@binding(3)var maskTexture:texture_2d<f32>;struct VertexOutput{@builtin(position)Position:vec4f,@location(0)fragUV:vec2f,}@vertex fn vert_main(@builtin(vertex_index)VertexIndex:u32)->VertexOutput{const pos=array(vec2(1.0,1.0),vec2(1.0,-1.0),vec2(-1.0,-1.0),vec2(1.0,1.0),vec2(-1.0,-1.0),vec2(-1.0,1.0),);const uv=array(vec2(1.0,0.0),vec2(1.0,1.0),vec2(0.0,1.0),vec2(1.0,0.0),vec2(0.0,1.0),vec2(0.0,0.0),);var output:VertexOutput;output.Position=vec4(pos[VertexIndex],0.0,1.0);output.fragUV=uv[VertexIndex];return output;}@fragment fn frag_main(@location(0)fragUV:vec2f)->@location(0)vec4f{let bg=textureSample(bgTexture,mySampler,fragUV);let person=textureSample(personTexture,mySampler,fragUV);let mask=textureSample(maskTexture,mySampler,fragUV);var alpha=mask.r;if(alpha<0.5){alpha=0;}return mix(bg,person,alpha);}";var sr=[0,0,0,0];var Kc=(e,t,r,n)=>{let o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");return o.configure({device:t,format:r,alphaMode:"premultiplied"}),{render:(s,a,i)=>{_(!n(),C.ContextLost);let c=t.createRenderPipeline({label:"blender pipeline",layout:"auto",vertex:{module:t.createShaderModule({label:"blender vertex",code:Ts})},fragment:{module:t.createShaderModule({label:"blender fragment",code:Ts}),targets:[{format:r}]}}),l=t.createCommandEncoder({label:"blender encoder"}),h=l.beginRenderPass({label:"blender renderPass",colorAttachments:[{view:o.getCurrentTexture().createView(),clearValue:sr,loadOp:"clear",storeOp:"store"}]});h.setPipeline(c);let f=t.createSampler({addressModeU:"repeat",addressModeV:"repeat",magFilter:"nearest"}),d=t.createBindGroup({layout:c.getBindGroupLayout(0),entries:[{binding:0,resource:f},{binding:1,resource:a.createView()},{binding:2,resource:s.createView()},{binding:3,resource:i.createView()}]});h.setBindGroup(0,d),h.draw(6),h.end();let b=l.finish();t.queue.submit([b])},release:()=>{}}};var _s=e=>e.features.has("bgra8unorm-storage"),$c=async e=>await e?.requestDevice({requiredFeatures:_s(e)?["bgra8unorm-storage"]:[]});var qc="@group(0)@binding(0)var u_sampler:sampler;@group(0)@binding(1)var u_frame:texture_2d<f32>;@group(0)@binding(2)var<uniform> flip:Flip;struct Flip{value:u32,}struct VertexOutput{@builtin(position)Position:vec4f,@location(0)fragUV:vec2f,}fn Downsample(uv:vec2<f32>,halfpixel:vec2<f32>)->vec4<f32>{var sum=textureSample(u_frame,u_sampler,uv)*4.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y+halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y-halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y-halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y+halfpixel.y));return sum/8.0;}fn Upsample(uv:vec2<f32>,halfpixel:vec2<f32>)->vec4<f32>{var sum=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x*2.0,uv.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x*2.0,uv.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x,uv.y+halfpixel.y*2.0));sum+=textureSample(u_frame,u_sampler,vec2(uv.x,uv.y-halfpixel.y*2.0));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y+halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y+halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y-halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y-halfpixel.y))*2.0;return sum/12.0;}@fragment fn frag_main(@location(0)v_texCoord:vec2<f32>)->@location(0)vec4<f32>{let texSize=vec2<f32>(textureDimensions(u_frame));let texel_size=1.0/texSize;let halfpixel=texel_size*0.5;var color:vec4<f32>;if(flip.value!=1u){color=Downsample(v_texCoord,halfpixel);}else{color=Upsample(v_texCoord,halfpixel);}return color;}@vertex fn vert_main(@builtin(vertex_index)VertexIndex:u32)->VertexOutput{const pos=array(vec2(1.0,1.0),vec2(1.0,-1.0),vec2(-1.0,-1.0),vec2(1.0,1.0),vec2(-1.0,-1.0),vec2(-1.0,1.0),);const uv=array(vec2(1.0,0.0),vec2(1.0,1.0),vec2(0.0,1.0),vec2(1.0,0.0),vec2(0.0,1.0),vec2(0.0,0.0),);var output:VertexOutput;output.Position=vec4(pos[VertexIndex],0.0,1.0);output.fragUV=uv[VertexIndex];return output;}";var $2=In(1,9),Jc=(e,t,r,n)=>{let o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");o.configure({device:t,format:r,alphaMode:"premultiplied"});let s=(k,S)=>t.createTexture({format:r,size:[k,S],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),a=k=>{let S=t.createBuffer({size:4,mappedAtCreation:!0,usage:GPUBufferUsage.UNIFORM});return new Uint32Array(S.getMappedRange())[0]=k,S.unmap(),S},i=t.createSampler({magFilter:"linear",minFilter:"linear"}),c=t.createShaderModule({code:qc}),l=t.createRenderPipeline({label:"dual blur render pipeline",layout:"auto",vertex:{module:c,entryPoint:"vert_main",buffers:[]},fragment:{module:c,entryPoint:"frag_main",targets:[{format:r}]},primitive:{topology:"triangle-list"}}),h=[],f=-1,d=-1;function b(k,S,p){let x=$2(k+1),E=!1;if(h.length!==x||f!==S||d!==p){for(let L of h)L.texture.destroy();h=[];for(let L=0;L<x;L++){let I=Math.max(Math.trunc(S/2**L),1),w=Math.max(Math.trunc(p/2**L),1);h.push({texture:s(I,w),width:I,height:w})}f=S,d=p,E=!0}return E}let R=a(0),A=a(1);return{render:(k,S)=>{_(!n(),C.ContextLost),b(S,e.width,e.height);let p=h[0];_(p),t.queue.copyExternalImageToTexture({source:k.frame,flipY:!1},{texture:p.texture},{width:p.width,height:p.height});for(let w=1;w<h.length;w++){let B=h[w-1];_(B);let U=h[w];_(U);let j=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:B.texture.createView()},{binding:2,resource:{buffer:R}}]}),W=t.createCommandEncoder(),le=W.beginRenderPass({colorAttachments:[{view:U.texture.createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});le.setPipeline(l),le.setBindGroup(0,j),le.draw(6),le.end(),t.queue.submit([W.finish()])}for(let w=h.length-2;w>=0;w--){let B=h[w+1];_(B);let U=h[w];_(U);let j=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:B.texture.createView()},{binding:2,resource:{buffer:A}}]}),W=t.createCommandEncoder(),le=W.beginRenderPass({colorAttachments:[{view:U.texture.createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});le.setPipeline(l),le.setBindGroup(0,j),le.draw(6),le.end(),t.queue.submit([W.finish()])}let x=h[0];_(x);let E=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:x.texture.createView()},{binding:2,resource:{buffer:A}}]}),L=t.createCommandEncoder(),I=L.beginRenderPass({colorAttachments:[{view:o.getCurrentTexture().createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});return I.setPipeline(l),I.setBindGroup(0,E),I.draw(6),I.end(),t.queue.submit([L.finish()]),x.texture},release:()=>{for(let k of h)k.texture.destroy();h=[],R.destroy(),A.destroy()}}};var Qc="@group(0)@binding(1)var mask:texture_2d<f32>;@group(0)@binding(2)var prevMask:texture_2d<f32>;@group(0)@binding(3)var outputTex:texture_storage_2d<rgba8unorm,write>;struct Params{maskCombineRatio:f32,foregroundThreshold:f32,}@group(0)@binding(4)var<uniform> params:Params;fn smoothingMask(prevMask:texture_2d<f32>,mask:texture_2d<f32>,uv:vec2<u32>,ratio:f32)->f32{let prevMaskValue=textureLoad(prevMask,uv,0u).r;let currMaskValue=textureLoad(mask,uv,0u).r;let c1=5.68842;let c2=-0.748699;let c3=-57.8051;let c4=291.309;let c5=-624.717;let t=currMaskValue-0.5;let x=t*t;let uncertainty=1.0-min(1.0,x*(c1+x*(c2+x*(c3+x*(c4+x*c5)))));return currMaskValue+(prevMaskValue-currMaskValue)*(uncertainty*ratio);}@compute @workgroup_size(32,1,1)fn main(@builtin(workgroup_id)WorkGroupID:vec3u,@builtin(local_invocation_id)LocalInvocationID:vec3u){let blockDim:u32=128;let baseIndex=vec2i(WorkGroupID.xy*vec2(blockDim,4)+LocalInvocationID.xy*vec2(4,1));for(var r=0;r<4;r++){for(var c=0;c<4;c++){var uv=baseIndex+vec2(c,r);let maskAlpha=smoothingMask(prevMask,mask,vec2<u32>(uv),params.maskCombineRatio);var backgroundMask=maskAlpha;if backgroundMask<params.foregroundThreshold{backgroundMask=0.0;}textureStore(outputTex,uv,vec4<f32>(backgroundMask,backgroundMask,backgroundMask,backgroundMask));}}}";var Zc=(e,t,r)=>{let n=t.createTexture({label:"Smoothed Mask Texture",format:"rgba8unorm",size:[e.width,e.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC}),o=t.createBuffer({size:2*4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),s=a=>{t.queue.writeBuffer(o,0,new Float32Array([a.maskCombineRatio,a.foregroundThreshold]))};return{render:(a,i,c)=>{if(_(!r(),C.ContextLost),!i)return a;let l=t.createComputePipeline({label:"smoothing mask pipeline",layout:"auto",compute:{module:t.createShaderModule({label:"smoothing mask compute",code:Qc})}});s(c);let h=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:1,resource:a.createView()},{binding:2,resource:i.createView()},{binding:3,resource:n.createView()},{binding:4,resource:{buffer:o}}]}),f=t.createCommandEncoder({label:"smoothing mask encoder"}),d=f.beginComputePass({label:" smoothing mask compute pass"});d.setPipeline(l),d.setBindGroup(0,h),d.dispatchWorkgroups(Math.ceil(e.width/128),Math.ceil(e.height/4)),d.end();let b=f.finish();return t.queue.submit([b]),n},release:()=>{n.destroy(),o.destroy()}}};var eu=(e,t)=>{let r;return{render:n=>{_(!t(),C.ContextLost);let o=e.createCommandEncoder({label:"texture to texture encoder"});return r=e.createTexture({size:{width:n.width,height:n.height,depthOrArrayLayers:n.depthOrArrayLayers},format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST}),o.copyTextureToTexture({texture:n},{texture:r},{width:r.width,height:r.height,depthOrArrayLayers:r.depthOrArrayLayers}),e.queue.submit([o.finish()]),r},release:()=>{r?.destroy()}}};var tu=(e,t=new OffscreenCanvas(768,432))=>{let r={videoFrameRenderer:()=>{if(!o.device)throw new Error("No device.");return zc(t,o.device,l)},backgroundImageRenderer:()=>{if(!o.device)throw new Error("No device.");return Kc(t,o.device,o.presentationFormat,l)},blurRenderer:()=>{if(!o.device)throw new Error("No device.");return Jc(t,o.device,o.presentationFormat,l)},maskSmoothingRenderer:()=>{if(!o.device)throw new Error("No device.");return Zc(t,o.device,l)},prevMaskRenderer:()=>{if(!o.device)throw new Error("No device.");return eu(o.device,l)},release:h=>()=>{for(let f of Object.keys(h))f!=="release"&&h[f]?.release()}},n=or(r),o={canvas:t,presentationFormat:"rgba8unorm",backend:"webgpu",deviceLost:!1,get videoFrameRenderer(){return n.videoFrameRenderer},get blendRenderer(){return n.backgroundImageRenderer},get blurRenderer(){return n.blurRenderer},get maskSmoothingRenderer(){return n.maskSmoothingRenderer},get prevMaskRenderer(){return n.prevMaskRenderer}},s=Ln(o),a=async()=>{if(!navigator.gpu)throw Error("WebGPU not supported.");let h=await navigator.gpu.requestAdapter();if(!h)throw Error("Couldn't request WebGPU adapter.");o.presentationFormat=_s(h)?navigator.gpu.getPreferredCanvasFormat():"rgba8unorm",o.device=await $c(h),o.device.lost.then(f=>{f.reason!=="destroyed"&&(o.deviceLost=!0,e.contextLost(f.message),e.contextRestored(f.message))})},i=(h,f,d)=>{d&&s(d);let b=o.videoFrameRenderer.render(f),R=o.videoFrameRenderer.render({frame:h,width:f.width,height:f.height,timestamp:f.timestamp}),A=o.maskSmoothingRenderer.render(R,o.prevMask,d);if(d.effects==="blur"){let k=o.blurRenderer.render(f,d.backgroundBlurAmount);o.blendRenderer.render(b,k,A)}else if(d.effects==="overlay"&&d.backgroundImage){let k=o.videoFrameRenderer.render({frame:d.backgroundImage,width:d.backgroundImage.width,height:d.backgroundImage.height,timestamp:f.timestamp});o.blendRenderer.render(b,k,A)}o.prevMask=o.prevMaskRenderer.render(A)},c=()=>{n.release(),o.deviceLost=!1,n=or(r)},l=()=>o.deviceLost;return{init:a,render:i,release:c,isContextLost:l}};var ue={projection:(e,t,r=-1)=>[2/e,0,0,0,2/t*r,0,-1,1*-r,1],translation:(e,t)=>[1,0,0,0,1,0,e,t,1],rotation:e=>{let t=Math.cos(e),r=Math.sin(e);return[t,-r,0,r,t,0,0,0,1]},scaling:(e,t)=>[e,0,0,0,t,0,0,0,1],multiply:(e,t)=>{let r=e[0],n=e[0*3+1],o=e[0*3+2],s=e[1*3+0],a=e[1*3+1],i=e[1*3+2],c=e[2*3+0],l=e[2*3+1],h=e[2*3+2],f=t[0*3+0],d=t[0*3+1],b=t[0*3+2],R=t[1*3+0],A=t[1*3+1],k=t[1*3+2],S=t[2*3+0],p=t[2*3+1],x=t[2*3+2];return[f*r+d*s+b*c,f*n+d*a+b*l,f*o+d*i+b*h,R*r+A*s+k*c,R*n+A*a+k*l,R*o+A*i+k*h,S*r+p*s+x*c,S*n+p*a+x*l,S*o+p*i+x*h]},translate:(e,t,r)=>ue.multiply(e,ue.translation(t,r)),rotate:(e,t)=>ue.multiply(e,ue.rotation(t)),scale:(e,t,r)=>ue.multiply(e,ue.scaling(t,r))};var Mn={VertexShader:WebGLRenderingContext.VERTEX_SHADER,FragmentShader:WebGLRenderingContext.FRAGMENT_SHADER},As={[Mn.VertexShader]:"VertexShader",[Mn.FragmentShader]:"FragmentShader"},q2=e=>typeof e=="string"?e.startsWith("#version 300 es"):!1,ru=e=>{if(!q2(e))throw new Error("Expecting GLSL ES 3.00 shader source")},J2=/ERROR:\s*\d+:(\d+)/gi;function su(e,t="",r=0){let n=[...t.matchAll(J2)],o=new Map(n.map((s,a)=>{if(!s[1]||s.index===void 0)return[0,t];let i=Number.parseInt(s[1],10),c=n[a+1],l=c?c.index:t.length,h=t.substring(s.index,l);return[i-1,h]}));return e.split(`
41
+ `}C(){let e=this.g;e.activeTexture(e.TEXTURE1),this.j=Tt(this,e),e.activeTexture(e.TEXTURE2),this.B=Tt(this,e)}m(){super.m();let e=this.g;this.K=ge(e.getUniformLocation(this.h,"defaultTexture"),"Uniform location"),this.L=ge(e.getUniformLocation(this.h,"overlayTexture"),"Uniform location"),this.I=ge(e.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();let e=this.g;e.uniform1i(this.I,0),e.uniform1i(this.K,1),e.uniform1i(this.L,2)}close(){this.j&&this.g.deleteTexture(this.j),this.B&&this.g.deleteTexture(this.B),super.close()}};function st(e,t){switch(t){case 0:return e.g.find(r=>r instanceof Uint8Array);case 1:return e.g.find(r=>r instanceof Float32Array);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function ho(e){var t=st(e,1);if(!t){if(t=st(e,0))t=new Float32Array(t).map(n=>n/255);else{t=new Float32Array(e.width*e.height);let n=Ht(e);var r=ds(e);if(Rn(r,n,Lc(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(e.width*e.height*4),n.readPixels(0,0,e.width,e.height,n.RGBA,n.FLOAT,r);for(let o=0,s=0;o<t.length;++o,s+=4)t[o]=r[s]}else n.readPixels(0,0,e.width,e.height,n.RED,n.FLOAT,t)}e.g.push(t)}return t}function Lc(e){let t=st(e,2);if(!t){let r=Ht(e);t=Mc(e);let n=ho(e),o=Ic(e);r.texImage2D(r.TEXTURE_2D,0,o,e.width,e.height,0,r.RED,r.FLOAT,n),lo(e)}return t}function Ht(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return e.h||(e.h=ge(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Ic(e){if(e=Ht(e),!Pr)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Pr=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Pr=e.R16F}return Pr}function ds(e){return e.l||(e.l=new nr),e.l}function Mc(e){let t=Ht(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=st(e,2);return r||(r=Tt(ds(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function lo(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Pr,ae=class{constructor(e,t,r,n,o,s,a){this.g=e,this.m=t,this.j=r,this.canvas=n,this.l=o,this.width=s,this.height=a,this.j&&--Aa===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Ga(){return!!st(this,0)}ka(){return!!st(this,1)}R(){return!!st(this,2)}ja(){return(t=st(e=this,0))||(t=ho(e),t=new Uint8Array(t.map(r=>255*r)),e.g.push(t)),t;var e,t}ia(){return ho(this)}N(){return Lc(this)}clone(){let e=[];for(let t of this.g){let r;if(t instanceof Uint8Array)r=new Uint8Array(t);else if(t instanceof Float32Array)r=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{let n=Ht(this),o=ds(this);n.activeTexture(n.TEXTURE1),r=Tt(o,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);let s=Ic(this);n.texImage2D(n.TEXTURE_2D,0,s,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),Rn(o,n,r),Sr(o,n,!1,()=>{Mc(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),lo(this)}),ls(o),lo(this)}}e.push(r)}return new ae(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Ht(this).deleteTexture(st(this,2)),Aa=-1}};ae.prototype.close=ae.prototype.close,ae.prototype.clone=ae.prototype.clone,ae.prototype.getAsWebGLTexture=ae.prototype.N,ae.prototype.getAsFloat32Array=ae.prototype.ia,ae.prototype.getAsUint8Array=ae.prototype.ja,ae.prototype.hasWebGLTexture=ae.prototype.R,ae.prototype.hasFloat32Array=ae.prototype.ka,ae.prototype.hasUint8Array=ae.prototype.Ga;var Aa=250,U2={color:"white",lineWidth:4,radius:6};function zn(e){return{...U2,fillColor:(e=e||{}).color,...e}}function nt(e,t){return e instanceof Function?e(t):e}function Ra(e,t,r){return Math.max(Math.min(t,r),Math.min(Math.max(t,r),e))}function lr(e){if(!e.l)throw Error("CPU rendering requested but CanvasRenderingContext2D not provided.");return e.l}function Tr(e){if(!e.j)throw Error("GPU rendering requested but WebGL2RenderingContext not provided.");return e.j}function wa(e,t,r){if(t.R())r(t.N());else{let n=t.ka()?t.ia():t.ja();e.m=e.m??new nr;let o=Tr(e);r((e=new ae([n],t.m,!1,o.canvas,e.m,t.width,t.height)).N()),e.close()}}function ka(e,t,r,n){let o=function(i){return i.g||(i.g=new M2),i.g}(e),s=Tr(e),a=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r;Sr(o,s,!0,()=>{(function(c,l,h,p){let d=c.g;if(d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,l),d.activeTexture(d.TEXTURE1),d.bindTexture(d.TEXTURE_2D,c.B),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,h),c.I&&function(g,A){if(g!==A)return!1;g=g.entries(),A=A.entries();for(let[S,w]of g){g=S;let f=w;var R=A.next();if(R.done)return!1;let[y,b]=R.value;if(R=b,g!==y||f[0]!==R[0]||f[1]!==R[1]||f[2]!==R[2]||f[3]!==R[3])return!1}return!!A.next().done}(c.I,p))d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j);else{c.I=p;let g=Array(1024).fill(0);p.forEach((A,R)=>{if(A.length!==4)throw Error(`Color at index ${R} is not a four-channel value.`);g[4*R]=A[0],g[4*R+1]=A[1],g[4*R+2]=A[2],g[4*R+3]=A[3]}),d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,256,1,0,d.RGBA,d.UNSIGNED_BYTE,new Uint8Array(g))}})(o,t,a,n),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.drawArrays(s.TRIANGLE_FAN,0,4);let i=o.g;i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE2),i.bindTexture(i.TEXTURE_2D,null)})}function Sa(e,t,r,n){let o=Tr(e),s=function(c){return c.h||(c.h=new F2),c.h}(e),a=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r,i=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n;Sr(s,o,!0,()=>{var c=s.g;c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,t),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,s.j),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,s.B),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLE_FAN,0,4),o.bindTexture(o.TEXTURE_2D,null),(c=s.g).activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,null)})}var me=class{constructor(e,t){e instanceof CanvasRenderingContext2D||e instanceof OffscreenCanvasRenderingContext2D?(this.l=e,this.j=t):this.j=e}za(e,t){if(e){var r=lr(this);t=zn(t),r.save();var n=r.canvas,o=0;for(let s of e)r.fillStyle=nt(t.fillColor,{index:o,from:s}),r.strokeStyle=nt(t.color,{index:o,from:s}),r.lineWidth=nt(t.lineWidth,{index:o,from:s}),(e=new Path2D).arc(s.x*n.width,s.y*n.height,nt(t.radius,{index:o,from:s}),0,2*Math.PI),r.fill(e),r.stroke(e),++o;r.restore()}}ya(e,t,r){if(e&&t){var n=lr(this);r=zn(r),n.save();var o=n.canvas,s=0;for(let a of t){n.beginPath(),t=e[a.start];let i=e[a.end];t&&i&&(n.strokeStyle=nt(r.color,{index:s,from:t,to:i}),n.lineWidth=nt(r.lineWidth,{index:s,from:t,to:i}),n.moveTo(t.x*o.width,t.y*o.height),n.lineTo(i.x*o.width,i.y*o.height)),++s,n.stroke()}n.restore()}}va(e,t){let r=lr(this);t=zn(t),r.save(),r.beginPath(),r.lineWidth=nt(t.lineWidth,{}),r.strokeStyle=nt(t.color,{}),r.fillStyle=nt(t.fillColor,{}),r.moveTo(e.originX,e.originY),r.lineTo(e.originX+e.width,e.originY),r.lineTo(e.originX+e.width,e.originY+e.height),r.lineTo(e.originX,e.originY+e.height),r.lineTo(e.originX,e.originY),r.stroke(),r.fill(),r.restore()}wa(e,t,r=[0,0,0,255]){this.l?function(n,o,s,a){let i=Tr(n);wa(n,o,c=>{ka(n,c,s,a),(c=lr(n)).drawImage(i.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,r,t):ka(this,e.N(),r,t)}xa(e,t,r){this.l?function(n,o,s,a){let i=Tr(n);wa(n,o,c=>{Sa(n,c,s,a),(c=lr(n)).drawImage(i.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,t,r):Sa(this,e.N(),t,r)}close(){this.g?.close(),this.g=void 0,this.h?.close(),this.h=void 0,this.m?.close(),this.m=void 0}};function Ze(e,t){switch(t){case 0:return e.g.find(r=>r instanceof ImageData);case 1:return e.g.find(r=>typeof ImageBitmap<"u"&&r instanceof ImageBitmap);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function Fc(e){var t=Ze(e,0);if(!t){t=Yt(e);let r=wn(e),n=new Uint8Array(e.width*e.height*4);Rn(r,t,jr(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,n),ls(r),t=new ImageData(new Uint8ClampedArray(n.buffer),e.width,e.height),e.g.push(t)}return t}function jr(e){let t=Ze(e,2);if(!t){let r=Yt(e);t=Wr(e);let n=Ze(e,1)||Fc(e);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,n),fr(e)}return t}function Yt(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");return e.h||(e.h=ge(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function wn(e){return e.l||(e.l=new nr),e.l}function Wr(e){let t=Yt(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=Ze(e,2);return r||(r=Tt(wn(e),t),e.g.push(r),e.m=!0),t.bindTexture(t.TEXTURE_2D,r),r}function fr(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Ca(e){let t=Yt(e);return Sr(wn(e),t,!0,()=>function(r,n){let o=r.canvas;if(o.width===r.width&&o.height===r.height)return n();let s=o.width,a=o.height;return o.width=r.width,o.height=r.height,r=n(),o.width=s,o.height=a,r}(e,()=>{if(t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),!(e.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return e.canvas.transferToImageBitmap()}))}me.prototype.close=me.prototype.close,me.prototype.drawConfidenceMask=me.prototype.xa,me.prototype.drawCategoryMask=me.prototype.wa,me.prototype.drawBoundingBox=me.prototype.va,me.prototype.drawConnectors=me.prototype.ya,me.prototype.drawLandmarks=me.prototype.za,me.lerp=function(e,t,r,n,o){return Ra(n*(1-(e-t)/(r-t))+o*(1-(r-e)/(r-t)),n,o)},me.clamp=Ra,za("DrawingUtils",me);var he=class{constructor(e,t,r,n,o,s,a){this.g=e,this.j=t,this.m=r,this.canvas=n,this.l=o,this.width=s,this.height=a,(this.j||this.m)&&--La===0&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Fa(){return!!Ze(this,0)}la(){return!!Ze(this,1)}R(){return!!Ze(this,2)}Da(){return Fc(this)}Ca(){var e=Ze(this,1);return e||(jr(this),Wr(this),e=Ca(this),fr(this),this.g.push(e),this.j=!0),e}N(){return jr(this)}clone(){let e=[];for(let t of this.g){let r;if(t instanceof ImageData)r=new ImageData(t.data,this.width,this.height);else if(t instanceof WebGLTexture){let n=Yt(this),o=wn(this);n.activeTexture(n.TEXTURE1),r=Tt(o,n),n.bindTexture(n.TEXTURE_2D,r),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,this.width,this.height,0,n.RGBA,n.UNSIGNED_BYTE,null),n.bindTexture(n.TEXTURE_2D,null),Rn(o,n,r),Sr(o,n,!1,()=>{Wr(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),fr(this)}),ls(o),fr(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);jr(this),Wr(this),r=Ca(this),fr(this)}e.push(r)}return new he(e,this.la(),this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Ze(this,1).close(),this.m&&Yt(this).deleteTexture(Ze(this,2)),La=-1}};he.prototype.close=he.prototype.close,he.prototype.clone=he.prototype.clone,he.prototype.getAsWebGLTexture=he.prototype.N,he.prototype.getAsImageBitmap=he.prototype.Ca,he.prototype.getAsImageData=he.prototype.Da,he.prototype.hasWebGLTexture=he.prototype.R,he.prototype.hasImageBitmap=he.prototype.la,he.prototype.hasImageData=he.prototype.Fa;var La=250;function ze(...e){return e.map(([t,r])=>({start:t,end:r}))}var O2=function(e){return class extends e{La(){this.i._registerModelResourcesGraphService()}}}((Ia=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:Sc()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){let t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){let r=e.length,n=this.i._malloc(r);this.i.HEAPU8.set(e,n),t?this.i._changeBinaryGraph(r,n):this.i._changeTextGraph(r,n),this.i._free(n)}configureAudio(e,t,r,n,o){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),E(this,n||"input_audio",s=>{E(this,o=o||"audio_header",a=>{this.i._configureAudio(s,a,e,t??0,r)})})}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ea(e){qe(this,"__graph_config__",t=>{e(t)}),E(this,"__graph_config__",t=>{this.i._getGraphConfig(t,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,n,o){let s=4*e.length;this.h!==s&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(s),this.h=s),this.i.HEAPF32.set(e,this.g/4),E(this,n,a=>{this.i._addAudioToInputStream(this.g,t,r,a,o)})}addGpuBufferToStream(e,t,r){E(this,t,n=>{let[o,s]=va(this,e,n);this.i._addBoundTextureToStream(n,o,s,r)})}addBoolToStream(e,t,r){E(this,t,n=>{this.i._addBoolToInputStream(e,n,r)})}addDoubleToStream(e,t,r){E(this,t,n=>{this.i._addDoubleToInputStream(e,n,r)})}addFloatToStream(e,t,r){E(this,t,n=>{this.i._addFloatToInputStream(e,n,r)})}addIntToStream(e,t,r){E(this,t,n=>{this.i._addIntToInputStream(e,n,r)})}addUintToStream(e,t,r){E(this,t,n=>{this.i._addUintToInputStream(e,n,r)})}addStringToStream(e,t,r){E(this,t,n=>{E(this,e,o=>{this.i._addStringToInputStream(o,n,r)})})}addStringRecordToStream(e,t,r){E(this,t,n=>{Ea(this,Object.keys(e),o=>{Ea(this,Object.values(e),s=>{this.i._addFlatHashMapToInputStream(o,s,Object.keys(e).length,n,r)})})})}addProtoToStream(e,t,r,n){E(this,r,o=>{E(this,t,s=>{let a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,s,o,n),this.i._free(a)})})}addEmptyPacketToStream(e,t){E(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateBoolVector(e.length);if(!o)throw Error("Unable to allocate new bool vector on heap.");for(let s of e)this.i._addBoolVectorEntry(o,s);this.i._addBoolVectorToInputStream(o,n,r)})}addDoubleVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateDoubleVector(e.length);if(!o)throw Error("Unable to allocate new double vector on heap.");for(let s of e)this.i._addDoubleVectorEntry(o,s);this.i._addDoubleVectorToInputStream(o,n,r)})}addFloatVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateFloatVector(e.length);if(!o)throw Error("Unable to allocate new float vector on heap.");for(let s of e)this.i._addFloatVectorEntry(o,s);this.i._addFloatVectorToInputStream(o,n,r)})}addIntVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateIntVector(e.length);if(!o)throw Error("Unable to allocate new int vector on heap.");for(let s of e)this.i._addIntVectorEntry(o,s);this.i._addIntVectorToInputStream(o,n,r)})}addUintVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateUintVector(e.length);if(!o)throw Error("Unable to allocate new unsigned int vector on heap.");for(let s of e)this.i._addUintVectorEntry(o,s);this.i._addUintVectorToInputStream(o,n,r)})}addStringVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateStringVector(e.length);if(!o)throw Error("Unable to allocate new string vector on heap.");for(let s of e)E(this,s,a=>{this.i._addStringVectorEntry(o,a)});this.i._addStringVectorToInputStream(o,n,r)})}addBoolToInputSidePacket(e,t){E(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){E(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){E(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){E(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){E(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){E(this,t,r=>{E(this,e,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(e,t,r){E(this,r,n=>{E(this,t,o=>{let s=this.i._malloc(e.length);this.i.HEAPU8.set(e,s),this.i._addProtoToInputSidePacket(s,e.length,o,n),this.i._free(s)})})}addBoolVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let o of e)this.i._addBoolVectorEntry(n,o);this.i._addBoolVectorToInputSidePacket(n,r)})}addDoubleVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let o of e)this.i._addDoubleVectorEntry(n,o);this.i._addDoubleVectorToInputSidePacket(n,r)})}addFloatVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let o of e)this.i._addFloatVectorEntry(n,o);this.i._addFloatVectorToInputSidePacket(n,r)})}addIntVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let o of e)this.i._addIntVectorEntry(n,o);this.i._addIntVectorToInputSidePacket(n,r)})}addUintVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let o of e)this.i._addUintVectorEntry(n,o);this.i._addUintVectorToInputSidePacket(n,r)})}addStringVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let o of e)E(this,o,s=>{this.i._addStringVectorEntry(n,s)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){qe(this,e,t),E(this,e,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(e,t,r){lt(this,e,t),E(this,e,n=>{this.i._attachProtoVectorListener(n,r||!1)})}attachAudioListener(e,t,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),qe(this,e,(n,o)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),t(n,o)}),E(this,e,n=>{this.i._attachAudioListener(n,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Ia{get fa(){return this.i}ra(e,t,r){E(this,t,n=>{let[o,s]=va(this,e,n);this.fa._addBoundTextureAsImageToStream(n,o,s,r)})}V(e,t){qe(this,e,t),E(this,e,r=>{this.fa._attachImageListener(r)})}da(e,t){lt(this,e,t),E(this,e,r=>{this.fa._attachImageVectorListener(r)})}})),Ia,Be=class extends O2{};async function M(e,t,r){return async function(n,o,s,a){return I2(n,o,s,a)}(e,r.canvas??(Sc()?void 0:document.createElement("canvas")),t,r)}function Uc(e,t,r,n){if(e.U){let s=new nc;if(r?.regionOfInterest){if(!e.qa)throw Error("This task doesn't support region-of-interest.");var o=r.regionOfInterest;if(o.left>=o.right||o.top>=o.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(o.left<0||o.top<0||o.right>1||o.bottom>1)throw Error("Expected RectF values to be in [0,1].");v(s,1,(o.left+o.right)/2),v(s,2,(o.top+o.bottom)/2),v(s,4,o.right-o.left),v(s,3,o.bottom-o.top)}else v(s,1,.5),v(s,2,.5),v(s,4,1),v(s,3,1);if(r?.rotationDegrees){if(r?.rotationDegrees%90!=0)throw Error("Expected rotation to be a multiple of 90\xB0.");if(v(s,5,-Math.PI*r.rotationDegrees/180),r?.rotationDegrees%180!=0){let[a,i]=Cc(t);r=te(s,3)*i/a,o=te(s,4)*a/i,v(s,4,r),v(s,3,o)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,n)}e.g.ra(t,e.ba,n??performance.now()),e.finishProcessing()}function De(e,t,r){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Uc(e,t,r,e.B+1)}function rt(e,t,r,n){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Uc(e,t,r,n)}function zt(e,t,r,n){var o=t.data;let s=t.width,a=s*(t=t.height);if((o instanceof Uint8Array||o instanceof Float32Array)&&o.length!==a)throw Error("Unsupported channel count: "+o.length/a);return e=new ae([o],r,!1,e.g.i.canvas,e.P,s,t),n?e.clone():e}var Ee=class extends Vr{constructor(e,t,r,n){super(e),this.g=e,this.ba=t,this.U=r,this.qa=n,this.P=new nr}l(e,t=!0){if("runningMode"in e&&Er(this.baseOptions,2,!!e.runningMode&&e.runningMode!=="IMAGE"),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Ee.prototype.close=Ee.prototype.close;var Ie=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},T(e=this.h=new bn,0,1,t=new $),v(this.h,2,.5),v(this.h,3,.3)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&v(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&v(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}D(e,t){return this.j={detections:[]},De(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect_in"),P(e,"detections");let t=new ke;Xe(t,x2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect_in"),F(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(n,o)=>{for(let s of n)n=ec(s),this.j.detections.push(wc(n));m(this,o)}),this.g.attachEmptyPacketListener("detections",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ie.prototype.detectForVideo=Ie.prototype.F,Ie.prototype.detect=Ie.prototype.D,Ie.prototype.setOptions=Ie.prototype.o,Ie.createFromModelPath=async function(e,t){return M(Ie,e,{baseOptions:{modelAssetPath:t}})},Ie.createFromModelBuffer=function(e,t){return M(Ie,e,{baseOptions:{modelAssetBuffer:t}})},Ie.createFromOptions=function(e,t){return M(Ie,e,t)};var fs=ze([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),ps=ze([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),ms=ze([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Oc=ze([474,475],[475,476],[476,477],[477,474]),gs=ze([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),xs=ze([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Pc=ze([469,470],[470,471],[471,472],[472,469]),ys=ze([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Bc=[...fs,...ps,...ms,...gs,...xs,...ys],Dc=ze([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function Ma(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Q=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,T(e=this.h=new cc,0,1,t=new $),this.v=new ic,T(this.h,0,3,this.v),this.s=new bn,T(this.h,0,2,this.s),tt(this.s,4,1),v(this.s,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numFaces"in e&&tt(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&v(this.v,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}D(e,t){return Ma(this),De(this,e,t),this.j}F(e,t,r){return Ma(this),rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"face_landmarks");let t=new ke;Xe(t,v2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("face_landmarks",(n,o)=>{for(let s of n)n=kr(s),this.j.faceLandmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{m(this,n)}),this.outputFaceBlendshapes&&(P(e,"blendshapes"),F(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,o)=>{if(this.outputFaceBlendshapes)for(let s of n)n=En(s),this.j.faceBlendshapes.push(us(n.g()??[]));m(this,o)}),this.g.attachEmptyPacketListener("blendshapes",n=>{m(this,n)})),this.outputFacialTransformationMatrixes&&(P(e,"face_geometry"),F(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,o)=>{if(this.outputFacialTransformationMatrixes)for(let s of n)(n=O(y2(s),u2,2))&&this.j.facialTransformationMatrixes.push({rows:je(Oe(n,1),0)??0,columns:je(Oe(n,2),0)??0,data:Ct(n,3,At,St()).slice()??[]});m(this,o)}),this.g.attachEmptyPacketListener("face_geometry",n=>{m(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Q.prototype.detectForVideo=Q.prototype.F,Q.prototype.detect=Q.prototype.D,Q.prototype.setOptions=Q.prototype.o,Q.createFromModelPath=function(e,t){return M(Q,e,{baseOptions:{modelAssetPath:t}})},Q.createFromModelBuffer=function(e,t){return M(Q,e,{baseOptions:{modelAssetBuffer:t}})},Q.createFromOptions=function(e,t){return M(Q,e,t)},Q.FACE_LANDMARKS_LIPS=fs,Q.FACE_LANDMARKS_LEFT_EYE=ps,Q.FACE_LANDMARKS_LEFT_EYEBROW=ms,Q.FACE_LANDMARKS_LEFT_IRIS=Oc,Q.FACE_LANDMARKS_RIGHT_EYE=gs,Q.FACE_LANDMARKS_RIGHT_EYEBROW=xs,Q.FACE_LANDMARKS_RIGHT_IRIS=Pc,Q.FACE_LANDMARKS_FACE_OVAL=ys,Q.FACE_LANDMARKS_CONTOURS=Bc,Q.FACE_LANDMARKS_TESSELATION=Dc;var Je=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!0),T(e=this.j=new hc,0,1,t=new $)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){return super.l(e)}Oa(e,t,r){let n=typeof t!="function"?t:{};if(this.h=typeof t=="function"?t:r,De(this,e,n??{}),!this.h)return this.s}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"stylized_image");let t=new ke;Xe(t,E2,this.j);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"STYLIZED_IMAGE:stylized_image"),r.o(t),Le(e,r),this.g.V("stylized_image",(n,o)=>{var s=!this.h,a=n.data,i=n.width;let c=i*(n=n.height);if(a instanceof Uint8Array)if(a.length===3*c){let l=new Uint8ClampedArray(4*c);for(let h=0;h<c;++h)l[4*h]=a[3*h],l[4*h+1]=a[3*h+1],l[4*h+2]=a[3*h+2],l[4*h+3]=255;a=new ImageData(l,i,n)}else{if(a.length!==4*c)throw Error("Unsupported channel count: "+a.length/c);a=new ImageData(new Uint8ClampedArray(a.buffer,a.byteOffset,a.length),i,n)}else if(!(a instanceof WebGLTexture))throw Error(`Unsupported format: ${a.constructor.name}`);i=new he([a],!1,!1,this.g.i.canvas,this.P,i,n),this.s=s=s?i.clone():i,this.h&&this.h(s),m(this,o)}),this.g.attachEmptyPacketListener("stylized_image",n=>{this.s=null,this.h&&this.h(null),m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Je.prototype.stylize=Je.prototype.Oa,Je.prototype.setOptions=Je.prototype.o,Je.createFromModelPath=function(e,t){return M(Je,e,{baseOptions:{modelAssetPath:t}})},Je.createFromModelBuffer=function(e,t){return M(Je,e,{baseOptions:{modelAssetBuffer:t}})},Je.createFromOptions=function(e,t){return M(Je,e,t)};var vs=ze([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function Fa(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Ua(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function Oa(e,t=!0){let r=[];for(let o of e){var n=En(o);e=[];for(let s of n.g())n=t&&Oe(s,1)!=null?je(Oe(s,1),0):-1,e.push({score:te(s,2)??0,index:n,categoryName:et(s,3)??"",displayName:et(s,4)??""});r.push(e)}return r}var Te=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],T(e=this.j=new fc,0,1,t=new $),this.s=new ss,T(this.j,0,2,this.s),this.C=new os,T(this.s,0,3,this.C),this.v=new dc,T(this.s,0,2,this.v),this.h=new b2,T(this.j,0,3,this.h),v(this.v,2,.5),v(this.s,4,.5),v(this.C,2,.5)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){if(tt(this.v,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.v,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.s,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.C,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Ut,r=t,n=co(e.cannedGesturesClassifierOptions,O(this.h,Ut,3)?.h());T(r,0,2,n),T(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&O(this.h,Ut,3)?.g();return e.customGesturesClassifierOptions?(T(r=t=new Ut,0,2,n=co(e.customGesturesClassifierOptions,O(this.h,Ut,4)?.h())),T(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&O(this.h,Ut,4)?.g(),this.l(e)}Ja(e,t){return Fa(this),De(this,e,t),Ua(this)}Ka(e,t,r){return Fa(this),rt(this,e,r,t),Ua(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"hand_gestures"),P(e,"hand_landmarks"),P(e,"world_hand_landmarks"),P(e,"handedness");let t=new ke;Xe(t,T2,this.j);let r=new xe;Ce(r,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"HAND_GESTURES:hand_gestures"),F(r,"LANDMARKS:hand_landmarks"),F(r,"WORLD_LANDMARKS:world_hand_landmarks"),F(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,o)=>{for(let s of n){n=kr(s);let a=[];for(let i of ct(n,rc,1))a.push({x:te(i,1)??0,y:te(i,2)??0,z:te(i,3)??0,visibility:te(i,4)??0});this.landmarks.push(a)}m(this,o)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,o)=>{for(let s of n){n=Nt(s);let a=[];for(let i of ct(n,tc,1))a.push({x:te(i,1)??0,y:te(i,2)??0,z:te(i,3)??0,visibility:te(i,4)??0});this.worldLandmarks.push(a)}m(this,o)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,o)=>{this.gestures.push(...Oa(n,!1)),m(this,o)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{m(this,n)}),this.g.attachProtoVectorListener("handedness",(n,o)=>{this.handedness.push(...Oa(n)),m(this,o)}),this.g.attachEmptyPacketListener("handedness",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Pa(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Te.prototype.recognizeForVideo=Te.prototype.Ka,Te.prototype.recognize=Te.prototype.Ja,Te.prototype.setOptions=Te.prototype.o,Te.createFromModelPath=function(e,t){return M(Te,e,{baseOptions:{modelAssetPath:t}})},Te.createFromModelBuffer=function(e,t){return M(Te,e,{baseOptions:{modelAssetBuffer:t}})},Te.createFromOptions=function(e,t){return M(Te,e,t)},Te.HAND_CONNECTIONS=vs;var _e=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],T(e=this.h=new ss,0,1,t=new $),this.s=new os,T(this.h,0,3,this.s),this.j=new dc,T(this.h,0,2,this.j),tt(this.j,3,1),v(this.j,2,.5),v(this.s,2,.5),v(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numHands"in e&&tt(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}D(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],De(this,e,t),Pa(this)}F(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],rt(this,e,r,t),Pa(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"hand_landmarks"),P(e,"world_hand_landmarks"),P(e,"handedness");let t=new ke;Xe(t,_2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"LANDMARKS:hand_landmarks"),F(r,"WORLD_LANDMARKS:world_hand_landmarks"),F(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,o)=>{for(let s of n)n=kr(s),this.landmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,o)=>{for(let s of n)n=Nt(s),this.worldLandmarks.push(xr(n));m(this,o)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("handedness",(n,o)=>{var s=this.handedness,a=s.push;let i=[];for(let c of n){n=En(c);let l=[];for(let h of n.g())l.push({score:te(h,2)??0,index:je(Oe(h,1),0)??-1,categoryName:et(h,3)??"",displayName:et(h,4)??""});i.push(l)}a.call(s,...i),m(this,o)}),this.g.attachEmptyPacketListener("handedness",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};_e.prototype.detectForVideo=_e.prototype.F,_e.prototype.detect=_e.prototype.D,_e.prototype.setOptions=_e.prototype.o,_e.createFromModelPath=function(e,t){return M(_e,e,{baseOptions:{modelAssetPath:t}})},_e.createFromModelBuffer=function(e,t){return M(_e,e,{baseOptions:{modelAssetBuffer:t}})},_e.createFromOptions=function(e,t){return M(_e,e,t)},_e.HAND_CONNECTIONS=vs;var Nc=ze([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function Ba(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Da(e){try{if(!e.C)return e.h;e.C(e.h)}finally{An(e)}}function Br(e,t){e=kr(e),t.push(Tn(e))}var K=class extends Ee{constructor(e,t){super(new Be(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,T(e=this.j=new yc,0,1,t=new $),this.K=new os,T(this.j,0,2,this.K),this.aa=new A2,T(this.j,0,3,this.aa),this.s=new bn,T(this.j,0,4,this.s),this.I=new ic,T(this.j,0,5,this.I),this.v=new gc,T(this.j,0,6,this.v),this.L=new xc,T(this.j,0,7,this.L),v(this.s,2,.5),v(this.s,3,.3),v(this.I,2,.5),v(this.v,2,.5),v(this.v,3,.3),v(this.L,2,.5),v(this.K,2,.5)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&v(this.s,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&v(this.I,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&v(this.v,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&v(this.v,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&v(this.L,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&v(this.K,2,e.minHandLandmarksConfidence??.5),this.l(e)}D(e,t,r){let n=typeof t!="function"?t:{};return this.C=typeof t=="function"?t:r,Ba(this),De(this,e,n),Da(this)}F(e,t,r,n){let o=typeof r!="function"?r:{};return this.C=typeof r=="function"?r:n,Ba(this),rt(this,e,o,t),Da(this)}m(){var e=new be;Y(e,"input_frames_image"),P(e,"pose_landmarks"),P(e,"pose_world_landmarks"),P(e,"face_landmarks"),P(e,"left_hand_landmarks"),P(e,"left_hand_world_landmarks"),P(e,"right_hand_landmarks"),P(e,"right_hand_world_landmarks");let t=new ke,r=new na;to(r,1,Jt("type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),""),function(o,s){if(s!=null)if(Array.isArray(s))X(o,2,cn(s,Mo,void 0,void 0,!1));else{if(!(typeof s=="string"||s instanceof at||_r(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");to(o,2,_o(s,!1),Mt())}}(r,this.j.g());let n=new xe;Ce(n,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),$r(n,8,na,r),H(n,"IMAGE:input_frames_image"),F(n,"POSE_LANDMARKS:pose_landmarks"),F(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),F(n,"FACE_LANDMARKS:face_landmarks"),F(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),F(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),F(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),F(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(t),Le(e,n),_n(this,e),this.g.attachProtoListener("pose_landmarks",(o,s)=>{Br(o,this.h.poseLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("pose_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("pose_world_landmarks",(o,s)=>{var a=this.h.poseWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",o=>{m(this,o)}),this.outputPoseSegmentationMasks&&(F(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Xt(this,"pose_segmentation_mask"),this.g.V("pose_segmentation_mask",(o,s)=>{this.h.poseSegmentationMasks=[zt(this,o,!0,!this.C)],m(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",o=>{this.h.poseSegmentationMasks=[],m(this,o)})),this.g.attachProtoListener("face_landmarks",(o,s)=>{Br(o,this.h.faceLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",o=>{m(this,o)}),this.outputFaceBlendshapes&&(P(e,"extra_blendshapes"),F(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(o,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(o=En(o),a.push(us(o.g()??[]))),m(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",o=>{m(this,o)})),this.g.attachProtoListener("left_hand_landmarks",(o,s)=>{Br(o,this.h.leftHandLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("left_hand_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("left_hand_world_landmarks",(o,s)=>{var a=this.h.leftHandWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("right_hand_landmarks",(o,s)=>{Br(o,this.h.rightHandLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("right_hand_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("right_hand_world_landmarks",(o,s)=>{var a=this.h.rightHandWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",o=>{m(this,o)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};K.prototype.detectForVideo=K.prototype.F,K.prototype.detect=K.prototype.D,K.prototype.setOptions=K.prototype.o,K.createFromModelPath=function(e,t){return M(K,e,{baseOptions:{modelAssetPath:t}})},K.createFromModelBuffer=function(e,t){return M(K,e,{baseOptions:{modelAssetBuffer:t}})},K.createFromOptions=function(e,t){return M(K,e,t)},K.HAND_CONNECTIONS=vs,K.POSE_CONNECTIONS=Nc,K.FACE_LANDMARKS_LIPS=fs,K.FACE_LANDMARKS_LEFT_EYE=ps,K.FACE_LANDMARKS_LEFT_EYEBROW=ms,K.FACE_LANDMARKS_LEFT_IRIS=Oc,K.FACE_LANDMARKS_RIGHT_EYE=gs,K.FACE_LANDMARKS_RIGHT_EYEBROW=xs,K.FACE_LANDMARKS_RIGHT_IRIS=Pc,K.FACE_LANDMARKS_FACE_OVAL=ys,K.FACE_LANDMARKS_CONTOURS=Bc,K.FACE_LANDMARKS_TESSELATION=Dc;var Me=class extends Ee{constructor(e,t){super(new Be(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},T(e=this.h=new vc,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return T(this.h,0,2,co(e,O(this.h,ts,2))),this.l(e)}ta(e,t){return this.j={classifications:[]},De(this,e,t),this.j}ua(e,t,r){return this.j={classifications:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"input_image"),Y(e,"norm_rect"),P(e,"classifications");let t=new ke;Xe(t,R2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),H(r,"IMAGE:input_image"),H(r,"NORM_RECT:norm_rect"),F(r,"CLASSIFICATIONS:classifications"),r.o(t),Le(e,r),this.g.attachProtoListener("classifications",(n,o)=>{this.j=function(s){let a={classifications:ct(s,l2,1).map(i=>us(O(i,Qi,4)?.g()??[],je(Oe(i,2),0),et(i,3)))};return zr(vt(s,2))!=null&&(a.timestampMs=je(zr(vt(s,2)),0)),a}(d2(n)),m(this,o)}),this.g.attachEmptyPacketListener("classifications",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Me.prototype.classifyForVideo=Me.prototype.ua,Me.prototype.classify=Me.prototype.ta,Me.prototype.setOptions=Me.prototype.o,Me.createFromModelPath=function(e,t){return M(Me,e,{baseOptions:{modelAssetPath:t}})},Me.createFromModelBuffer=function(e,t){return M(Me,e,{baseOptions:{modelAssetBuffer:t}})},Me.createFromOptions=function(e,t){return M(Me,e,t)};var Ae=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!0),this.h=new Ec,this.embeddings={embeddings:[]},T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){var t=this.h,r=O(this.h,da,2);return r=r?r.clone():new da,e.l2Normalize!==void 0?Er(r,1,e.l2Normalize):"l2Normalize"in e&&X(r,1),e.quantize!==void 0?Er(r,2,e.quantize):"quantize"in e&&X(r,2),T(t,0,2,r),this.l(e)}Aa(e,t){return De(this,e,t),this.embeddings}Ba(e,t,r){return rt(this,e,r,t),this.embeddings}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"embeddings_out");let t=new ke;Xe(t,w2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"EMBEDDINGS:embeddings_out"),r.o(t),Le(e,r),this.g.attachProtoListener("embeddings_out",(n,o)=>{n=m2(n),this.embeddings=function(s){return{embeddings:ct(s,p2,1).map(a=>{let i={headIndex:je(Oe(a,3),0)??-1,headName:et(a,4)??""};if(xi(a,la,Vn(a,1))!==void 0)a=Ct(a=O(a,la,Vn(a,1)),1,At,St()),i.floatEmbedding=a.slice();else{let c=new Uint8Array(0);i.quantizedEmbedding=O(a,f2,Vn(a,2))?.pa()?.h()??c}return i}),timestampMs:je(zr(vt(s,2)),0)}}(n),m(this,o)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ae.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=xa(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=xa(ga(e.quantizedEmbedding),ga(t.quantizedEmbedding))}return e},Ae.prototype.embedForVideo=Ae.prototype.Ba,Ae.prototype.embed=Ae.prototype.Aa,Ae.prototype.setOptions=Ae.prototype.o,Ae.createFromModelPath=function(e,t){return M(Ae,e,{baseOptions:{modelAssetPath:t}})},Ae.createFromModelBuffer=function(e,t){return M(Ae,e,{baseOptions:{modelAssetBuffer:t}})},Ae.createFromOptions=function(e,t){return M(Ae,e,t)};var fo=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){this.confidenceMasks?.forEach(e=>{e.close()}),this.categoryMask?.close()}};function Na(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function Ga(e){try{let t=new fo(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{An(e)}}fo.prototype.close=fo.prototype.close;var de=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new cs,this.v=new bc,T(this.h,0,3,this.v),T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?X(this.h,2,Jt(e.displayNamesLocale)):"displayNamesLocale"in e&&X(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}J(){(function(e){let t=ct(e.ea(),xe,1).filter(r=>et(r,1).includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.s=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(O(t[0],ke,7)?.l()?.g()??new Map).forEach((r,n)=>{e.s[Number(n)]=et(r,1)})})(this)}segment(e,t,r){let n=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,Na(this),De(this,e,n),Ga(this)}Ma(e,t,r,n){let o=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,Na(this),rt(this,e,o,t),Ga(this)}Ea(){return this.s}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect");let t=new ke;Xe(t,_c,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),r.o(t),Le(e,r),_n(this,e),this.outputConfidenceMasks&&(P(e,"confidence_masks"),F(r,"CONFIDENCE_MASKS:confidence_masks"),Xt(this,"confidence_masks"),this.g.da("confidence_masks",(n,o)=>{this.confidenceMasks=n.map(s=>zt(this,s,!0,!this.j)),m(this,o)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],m(this,n)})),this.outputCategoryMask&&(P(e,"category_mask"),F(r,"CATEGORY_MASK:category_mask"),Xt(this,"category_mask"),this.g.V("category_mask",(n,o)=>{this.categoryMask=zt(this,n,!1,!this.j),m(this,o)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,m(this,n)})),P(e,"quality_scores"),F(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,o)=>{this.qualityScores=n,m(this,o)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};de.prototype.getLabels=de.prototype.Ea,de.prototype.segmentForVideo=de.prototype.Ma,de.prototype.segment=de.prototype.segment,de.prototype.setOptions=de.prototype.o,de.createFromModelPath=function(e,t){return M(de,e,{baseOptions:{modelAssetPath:t}})},de.createFromModelBuffer=function(e,t){return M(de,e,{baseOptions:{modelAssetBuffer:t}})},de.createFromOptions=function(e,t){return M(de,e,t)};var po=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){this.confidenceMasks?.forEach(e=>{e.close()}),this.categoryMask?.close()}};po.prototype.close=po.prototype.close;var P2=class extends x{constructor(e){super(e)}},Ot=[0,ee,-2],en=[0,ot,-3,q,ot,-1],Va=[0,en],ja=[0,en,ee,-1],Kn=class extends x{constructor(e){super(e)}},Wa=[0,ot,-1,q],B2=class extends x{constructor(){super()}},Xa=class extends x{constructor(e){super(e)}},mo=[1,2,3,4,5,6,7,8,9,10,14,15],Gc=class extends x{constructor(){super()}};Gc.prototype.g=vn([0,ie,[0,mo,N,en,N,[0,en,Ot],N,Va,N,[0,Va,Ot],N,Wa,N,[0,ot,-3,q,We],N,[0,ot,-3,q],N,[0,D,ot,-2,q,ee,q,-1,2,ot,Ot],N,ja,N,[0,ja,Ot],ot,Ot,D,N,[0,ot,-3,q,Ot,-1],N,[0,ie,Wa]],D,[0,D,ee,-1,q]]);var Qe=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new cs,this.s=new bc,T(this.h,0,3,this.s),T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,r,n){let o=typeof r!="function"?r:{};this.j=typeof r=="function"?r:n,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.B+1,n=new Gc;let s=new Xa;var a=new P2;if(tt(a,1,255),T(s,0,12,a),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var i=new Kn;Er(i,3,!0),v(i,1,t.keypoint.x),v(i,2,t.keypoint.y),mr(s,5,mo,i)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(i of(a=new B2,t.scribble))Er(t=new Kn,3,!0),v(t,1,i.x),v(t,2,i.y),$r(a,1,Kn,t);mr(s,15,mo,a)}$r(n,1,Xa,s),this.g.addProtoToStream(n.g(),"drishti.RenderData","roi_in",r),De(this,e,o);e:{try{let l=new po(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var c=l;break e}this.j(l)}finally{An(this)}c=void 0}return c}m(){var e=new be;Y(e,"image_in"),Y(e,"roi_in"),Y(e,"norm_rect_in");let t=new ke;Xe(t,_c,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),H(r,"IMAGE:image_in"),H(r,"ROI:roi_in"),H(r,"NORM_RECT:norm_rect_in"),r.o(t),Le(e,r),_n(this,e),this.outputConfidenceMasks&&(P(e,"confidence_masks"),F(r,"CONFIDENCE_MASKS:confidence_masks"),Xt(this,"confidence_masks"),this.g.da("confidence_masks",(n,o)=>{this.confidenceMasks=n.map(s=>zt(this,s,!0,!this.j)),m(this,o)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],m(this,n)})),this.outputCategoryMask&&(P(e,"category_mask"),F(r,"CATEGORY_MASK:category_mask"),Xt(this,"category_mask"),this.g.V("category_mask",(n,o)=>{this.categoryMask=zt(this,n,!1,!this.j),m(this,o)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,m(this,n)})),P(e,"quality_scores"),F(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,o)=>{this.qualityScores=n,m(this,o)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Qe.prototype.segment=Qe.prototype.segment,Qe.prototype.setOptions=Qe.prototype.o,Qe.createFromModelPath=function(e,t){return M(Qe,e,{baseOptions:{modelAssetPath:t}})},Qe.createFromModelBuffer=function(e,t){return M(Qe,e,{baseOptions:{modelAssetBuffer:t}})},Qe.createFromOptions=function(e,t){return M(Qe,e,t)};var Fe=class extends Ee{constructor(e,t){super(new Be(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},T(e=this.h=new Ac,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?X(this.h,2,Jt(e.displayNamesLocale)):"displayNamesLocale"in e&&X(this.h,2),e.maxResults!==void 0?tt(this.h,3,e.maxResults):"maxResults"in e&&X(this.h,3),e.scoreThreshold!==void 0?v(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&X(this.h,4),e.categoryAllowlist!==void 0?qr(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&X(this.h,5),e.categoryDenylist!==void 0?qr(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&X(this.h,6),this.l(e)}D(e,t){return this.j={detections:[]},De(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"input_frame_gpu"),Y(e,"norm_rect"),P(e,"detections");let t=new ke;Xe(t,S2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.ObjectDetectorGraph"),H(r,"IMAGE:input_frame_gpu"),H(r,"NORM_RECT:norm_rect"),F(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(n,o)=>{for(let s of n)n=ec(s),this.j.detections.push(wc(n));m(this,o)}),this.g.attachEmptyPacketListener("detections",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Fe.prototype.detectForVideo=Fe.prototype.F,Fe.prototype.detect=Fe.prototype.D,Fe.prototype.setOptions=Fe.prototype.o,Fe.createFromModelPath=async function(e,t){return M(Fe,e,{baseOptions:{modelAssetPath:t}})},Fe.createFromModelBuffer=function(e,t){return M(Fe,e,{baseOptions:{modelAssetBuffer:t}})},Fe.createFromOptions=function(e,t){return M(Fe,e,t)};var go=class{constructor(e,t,r){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=r}close(){this.segmentationMasks?.forEach(e=>{e.close()})}};function Ha(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function Ya(e){try{let t=new go(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.s)return t;e.s(t)}finally{An(e)}}go.prototype.close=go.prototype.close;var Re=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,T(e=this.h=new Rc,0,1,t=new $),this.v=new xc,T(this.h,0,3,this.v),this.j=new gc,T(this.h,0,2,this.j),tt(this.j,4,1),v(this.j,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numPoses"in e&&tt(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&v(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&v(this.v,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}D(e,t,r){let n=typeof t!="function"?t:{};return this.s=typeof t=="function"?t:r,Ha(this),De(this,e,n),Ya(this)}F(e,t,r,n){let o=typeof r!="function"?r:{};return this.s=typeof r=="function"?r:n,Ha(this),rt(this,e,o,t),Ya(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"normalized_landmarks"),P(e,"world_landmarks"),P(e,"segmentation_masks");let t=new ke;Xe(t,C2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"NORM_LANDMARKS:normalized_landmarks"),F(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),Le(e,r),_n(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(n,o)=>{this.landmarks=[];for(let s of n)n=kr(s),this.landmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],m(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,o)=>{this.worldLandmarks=[];for(let s of n)n=Nt(s),this.worldLandmarks.push(xr(n));m(this,o)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],m(this,n)}),this.outputSegmentationMasks&&(F(r,"SEGMENTATION_MASK:segmentation_masks"),Xt(this,"segmentation_masks"),this.g.da("segmentation_masks",(n,o)=>{this.segmentationMasks=n.map(s=>zt(this,s,!0,!this.s)),m(this,o)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],m(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Re.prototype.detectForVideo=Re.prototype.F,Re.prototype.detect=Re.prototype.D,Re.prototype.setOptions=Re.prototype.o,Re.createFromModelPath=function(e,t){return M(Re,e,{baseOptions:{modelAssetPath:t}})},Re.createFromModelBuffer=function(e,t){return M(Re,e,{baseOptions:{modelAssetBuffer:t}})},Re.createFromOptions=function(e,t){return M(Re,e,t)},Re.POSE_CONNECTIONS=Nc;var _=(e,t="AssertError")=>{if(!e)throw new Error(t,{cause:e});return e};var Es=e=>e;var bs=(e,...t)=>{let r=t.reduce((n,o)=>s=>o(n(s)),Es);return(...n)=>r(e(...n))};var N2="utils/memoize/noValue",Ll=Symbol(N2);var G2=e=>`(${e})`;var Vc=e=>G2(`?:${e}`),V2=e=>`${Vc(e)}?`,j2=e=>`${Vc(e)}*`;var W2=e=>`^${e}`,X2=e=>`${e}$`,H2=e=>typeof e=="function",Y2=e=>t=>H2(t)?t(e):t;var z2=()=>e=>e,kn=(e,t=z2)=>r=>n=>bs(Y2(n),t(n),e)(r);var Fl=kn(e=>V2(e)),Ul=kn(e=>j2(e));var Ol=kn(e=>W2(e)),Pl=kn(e=>X2(e));var z={Closed:"closed",Closing:"closing",Destroyed:"destroyed",Destroying:"destroying",Error:"Error",Idle:"idle",New:"new",Opened:"opened",Opening:"opening",Processing:"processing",Updated:"updated",Updating:"updating"},jc={None:"none",Blur:"blur",Overlay:"overlay"},Wc={WebGL:"webgl",WebGPU:"webgpu"},C={ContextCreationError:"ContextCreationError",ContextLost:"ContextLost",ContextRestored:"ContextRestored",Error:"Error",ProcessorRestarted:"ProcessorRestarted",SamplingError:"SamplingError"};var K2=e=>!!(typeof e=="string"&&Object.values(C).includes(e)),Sn=e=>K2(e)?e:C.Error,Cn=e=>e instanceof Error?e.message:String(e),Ln=e=>{let t=new Set(Object.keys(e));return r=>{for(let n in r)t.has(n)&&typeof e[n]==typeof r[n]&&(e[n]=r[n])}},Xc=e=>{let t=new Map(e),r=new Set,n=async a=>{let c=await(await fetch(a)).blob();return await createImageBitmap(c)},o=async a=>{let i=t.get(a);if(!i){if(r.has(a))return null;r.add(a);let c=await n(a);return t.set(a,c),r.delete(a),c}return i},s=a=>(t.get(a)?.close(),t.delete(a));return{tryFetchingImage:o,setImage:(a,i)=>{t.has(a)&&s(a),t.set(a,i)},getImage:a=>t.get(a)??null,removeImage:s,clear:()=>{for(let a of t.values())a.close();t.clear()}}},In=(e,t)=>r=>Math.min(Math.max(r,e),t);var Hc=(e,t,r,n)=>{if(!e||!t||!r||!n||e*n===r*t)return{sx:0,sy:0,sw:e,sh:t,dx:0,dy:0,dw:r,dh:n};let o=e/t,s=r/n;if(o>s){let l=Math.ceil(e*s)/o,h=Math.abs(e-l);return{sx:Math.ceil(h/2),sy:0,sw:l,sh:t,dx:0,dy:0,dw:r,dh:n}}let a=Math.ceil(t*o)/s,i=Math.abs(t-a);return{sx:0,sy:Math.ceil(i/2),sw:e,sh:a,dx:0,dy:0,dw:r,dh:n}},or=e=>{let t={};return new Proxy(t,{get(r,n,o){return r[n]||(r[n]=e[n]?.(t)),Reflect.get(r,n,o)}})},Yc=(e,t,r)=>{let n=a=>{a.preventDefault(),r?.(),t.contextLost(a.statusMessage)},o=a=>{t.contextRestored(a.statusMessage)},s=a=>{t.contextCreationError(a.statusMessage)};return e.addEventListener("webglcontextlost",n),e.addEventListener("webglcontextrestored",o),e.addEventListener("webglcontextcreationerror",s),()=>{e.removeEventListener("webglcontextlost",n),e.removeEventListener("webglcontextrestored",o),e.removeEventListener("webglcontextcreationerror",s)}};var zc=(e,t,r)=>{let n=navigator.gpu.getPreferredCanvasFormat(),o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");o.configure({device:t,format:n});let s;return{render:a=>(_(!r(),C.ContextLost),s=t.createTexture({label:"Video Frame to Texture",format:"rgba8unorm",size:[a.width,a.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT}),t.queue.copyExternalImageToTexture({source:a.frame,flipY:!1},{texture:s},{width:a.width,height:a.height}),t.queue.submit([]),s),release:()=>{s?.destroy()}}};var Ts="@group(0)@binding(0)var mySampler:sampler;@group(0)@binding(1)var bgTexture:texture_2d<f32>;@group(0)@binding(2)var personTexture:texture_2d<f32>;@group(0)@binding(3)var maskTexture:texture_2d<f32>;struct VertexOutput{@builtin(position)Position:vec4f,@location(0)fragUV:vec2f,}@vertex fn vert_main(@builtin(vertex_index)VertexIndex:u32)->VertexOutput{const pos=array(vec2(1.0,1.0),vec2(1.0,-1.0),vec2(-1.0,-1.0),vec2(1.0,1.0),vec2(-1.0,-1.0),vec2(-1.0,1.0),);const uv=array(vec2(1.0,0.0),vec2(1.0,1.0),vec2(0.0,1.0),vec2(1.0,0.0),vec2(0.0,1.0),vec2(0.0,0.0),);var output:VertexOutput;output.Position=vec4(pos[VertexIndex],0.0,1.0);output.fragUV=uv[VertexIndex];return output;}@fragment fn frag_main(@location(0)fragUV:vec2f)->@location(0)vec4f{let bg=textureSample(bgTexture,mySampler,fragUV);let person=textureSample(personTexture,mySampler,fragUV);let mask=textureSample(maskTexture,mySampler,fragUV);var alpha=mask.r;if(alpha<0.5){alpha=0;}return mix(bg,person,alpha);}";var sr=[0,0,0,0];var Kc=(e,t,r,n)=>{let o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");return o.configure({device:t,format:r,alphaMode:"premultiplied"}),{render:(s,a,i)=>{_(!n(),C.ContextLost);let c=t.createRenderPipeline({label:"blender pipeline",layout:"auto",vertex:{module:t.createShaderModule({label:"blender vertex",code:Ts})},fragment:{module:t.createShaderModule({label:"blender fragment",code:Ts}),targets:[{format:r}]}}),l=t.createCommandEncoder({label:"blender encoder"}),h=l.beginRenderPass({label:"blender renderPass",colorAttachments:[{view:o.getCurrentTexture().createView(),clearValue:sr,loadOp:"clear",storeOp:"store"}]});h.setPipeline(c);let p=t.createSampler({addressModeU:"repeat",addressModeV:"repeat",magFilter:"nearest"}),d=t.createBindGroup({layout:c.getBindGroupLayout(0),entries:[{binding:0,resource:p},{binding:1,resource:a.createView()},{binding:2,resource:s.createView()},{binding:3,resource:i.createView()}]});h.setBindGroup(0,d),h.draw(6),h.end();let g=l.finish();t.queue.submit([g])},release:()=>{}}};var _s=e=>e.features.has("bgra8unorm-storage"),$c=async e=>await e?.requestDevice({requiredFeatures:_s(e)?["bgra8unorm-storage"]:[]});var qc="@group(0)@binding(0)var u_sampler:sampler;@group(0)@binding(1)var u_frame:texture_2d<f32>;@group(0)@binding(2)var<uniform> flip:Flip;struct Flip{value:u32,}struct VertexOutput{@builtin(position)Position:vec4f,@location(0)fragUV:vec2f,}fn Downsample(uv:vec2<f32>,halfpixel:vec2<f32>)->vec4<f32>{var sum=textureSample(u_frame,u_sampler,uv)*4.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y+halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y-halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y-halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y+halfpixel.y));return sum/8.0;}fn Upsample(uv:vec2<f32>,halfpixel:vec2<f32>)->vec4<f32>{var sum=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x*2.0,uv.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x*2.0,uv.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x,uv.y+halfpixel.y*2.0));sum+=textureSample(u_frame,u_sampler,vec2(uv.x,uv.y-halfpixel.y*2.0));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y+halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y+halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y-halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y-halfpixel.y))*2.0;return sum/12.0;}@fragment fn frag_main(@location(0)v_texCoord:vec2<f32>)->@location(0)vec4<f32>{let texSize=vec2<f32>(textureDimensions(u_frame));let texel_size=1.0/texSize;let halfpixel=texel_size*0.5;var color:vec4<f32>;if(flip.value!=1u){color=Downsample(v_texCoord,halfpixel);}else{color=Upsample(v_texCoord,halfpixel);}return color;}@vertex fn vert_main(@builtin(vertex_index)VertexIndex:u32)->VertexOutput{const pos=array(vec2(1.0,1.0),vec2(1.0,-1.0),vec2(-1.0,-1.0),vec2(1.0,1.0),vec2(-1.0,-1.0),vec2(-1.0,1.0),);const uv=array(vec2(1.0,0.0),vec2(1.0,1.0),vec2(0.0,1.0),vec2(1.0,0.0),vec2(0.0,1.0),vec2(0.0,0.0),);var output:VertexOutput;output.Position=vec4(pos[VertexIndex],0.0,1.0);output.fragUV=uv[VertexIndex];return output;}";var $2=In(1,9),Jc=(e,t,r,n)=>{let o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");o.configure({device:t,format:r,alphaMode:"premultiplied"});let s=(S,w)=>t.createTexture({format:r,size:[S,w],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),a=S=>{let w=t.createBuffer({size:4,mappedAtCreation:!0,usage:GPUBufferUsage.UNIFORM});return new Uint32Array(w.getMappedRange())[0]=S,w.unmap(),w},i=t.createSampler({magFilter:"linear",minFilter:"linear"}),c=t.createShaderModule({code:qc}),l=t.createRenderPipeline({label:"dual blur render pipeline",layout:"auto",vertex:{module:c,entryPoint:"vert_main",buffers:[]},fragment:{module:c,entryPoint:"frag_main",targets:[{format:r}]},primitive:{topology:"triangle-list"}}),h=[],p=-1,d=-1;function g(S,w,f){let y=$2(S+1),b=!1;if(h.length!==y||p!==w||d!==f){for(let L of h)L.texture.destroy();h=[];for(let L=0;L<y;L++){let I=Math.max(Math.trunc(w/2**L),1),k=Math.max(Math.trunc(f/2**L),1);h.push({texture:s(I,k),width:I,height:k})}p=w,d=f,b=!0}return b}let A=a(0),R=a(1);return{render:(S,w)=>{_(!n(),C.ContextLost),g(w,e.width,e.height);let f=h[0];_(f),t.queue.copyExternalImageToTexture({source:S.frame,flipY:!1},{texture:f.texture},{width:f.width,height:f.height});for(let k=1;k<h.length;k++){let B=h[k-1];_(B);let U=h[k];_(U);let j=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:B.texture.createView()},{binding:2,resource:{buffer:A}}]}),W=t.createCommandEncoder(),le=W.beginRenderPass({colorAttachments:[{view:U.texture.createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});le.setPipeline(l),le.setBindGroup(0,j),le.draw(6),le.end(),t.queue.submit([W.finish()])}for(let k=h.length-2;k>=0;k--){let B=h[k+1];_(B);let U=h[k];_(U);let j=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:B.texture.createView()},{binding:2,resource:{buffer:R}}]}),W=t.createCommandEncoder(),le=W.beginRenderPass({colorAttachments:[{view:U.texture.createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});le.setPipeline(l),le.setBindGroup(0,j),le.draw(6),le.end(),t.queue.submit([W.finish()])}let y=h[0];_(y);let b=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:y.texture.createView()},{binding:2,resource:{buffer:R}}]}),L=t.createCommandEncoder(),I=L.beginRenderPass({colorAttachments:[{view:o.getCurrentTexture().createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});return I.setPipeline(l),I.setBindGroup(0,b),I.draw(6),I.end(),t.queue.submit([L.finish()]),y.texture},release:()=>{for(let S of h)S.texture.destroy();h=[],A.destroy(),R.destroy()}}};var Qc="@group(0)@binding(1)var mask:texture_2d<f32>;@group(0)@binding(2)var prevMask:texture_2d<f32>;@group(0)@binding(3)var outputTex:texture_storage_2d<rgba8unorm,write>;struct Params{maskCombineRatio:f32,foregroundThreshold:f32,}@group(0)@binding(4)var<uniform> params:Params;fn smoothingMask(prevMask:texture_2d<f32>,mask:texture_2d<f32>,uv:vec2<u32>,ratio:f32)->f32{let prevMaskValue=textureLoad(prevMask,uv,0u).r;let currMaskValue=textureLoad(mask,uv,0u).r;let c1=5.68842;let c2=-0.748699;let c3=-57.8051;let c4=291.309;let c5=-624.717;let t=currMaskValue-0.5;let x=t*t;let uncertainty=1.0-min(1.0,x*(c1+x*(c2+x*(c3+x*(c4+x*c5)))));return currMaskValue+(prevMaskValue-currMaskValue)*(uncertainty*ratio);}@compute @workgroup_size(32,1,1)fn main(@builtin(workgroup_id)WorkGroupID:vec3u,@builtin(local_invocation_id)LocalInvocationID:vec3u){let blockDim:u32=128;let baseIndex=vec2i(WorkGroupID.xy*vec2(blockDim,4)+LocalInvocationID.xy*vec2(4,1));for(var r=0;r<4;r++){for(var c=0;c<4;c++){var uv=baseIndex+vec2(c,r);let maskAlpha=smoothingMask(prevMask,mask,vec2<u32>(uv),params.maskCombineRatio);var backgroundMask=maskAlpha;if backgroundMask<params.foregroundThreshold{backgroundMask=0.0;}textureStore(outputTex,uv,vec4<f32>(backgroundMask,backgroundMask,backgroundMask,backgroundMask));}}}";var Zc=(e,t,r)=>{let n=t.createTexture({label:"Smoothed Mask Texture",format:"rgba8unorm",size:[e.width,e.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC}),o=t.createBuffer({size:2*4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),s=a=>{t.queue.writeBuffer(o,0,new Float32Array([a.maskCombineRatio,a.foregroundThreshold]))};return{render:(a,i,c)=>{if(_(!r(),C.ContextLost),!i)return a;let l=t.createComputePipeline({label:"smoothing mask pipeline",layout:"auto",compute:{module:t.createShaderModule({label:"smoothing mask compute",code:Qc})}});s(c);let h=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:1,resource:a.createView()},{binding:2,resource:i.createView()},{binding:3,resource:n.createView()},{binding:4,resource:{buffer:o}}]}),p=t.createCommandEncoder({label:"smoothing mask encoder"}),d=p.beginComputePass({label:" smoothing mask compute pass"});d.setPipeline(l),d.setBindGroup(0,h),d.dispatchWorkgroups(Math.ceil(e.width/128),Math.ceil(e.height/4)),d.end();let g=p.finish();return t.queue.submit([g]),n},release:()=>{n.destroy(),o.destroy()}}};var eu=(e,t)=>{let r;return{render:n=>{_(!t(),C.ContextLost);let o=e.createCommandEncoder({label:"texture to texture encoder"});return r=e.createTexture({size:{width:n.width,height:n.height,depthOrArrayLayers:n.depthOrArrayLayers},format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST}),o.copyTextureToTexture({texture:n},{texture:r},{width:r.width,height:r.height,depthOrArrayLayers:r.depthOrArrayLayers}),e.queue.submit([o.finish()]),r},release:()=>{r?.destroy()}}};var tu=(e,t,r=new OffscreenCanvas(768,432))=>{let n={videoFrameRenderer:()=>{if(!s.device)throw new Error("No device.");return zc(r,s.device,h)},backgroundImageRenderer:()=>{if(!s.device)throw new Error("No device.");return Kc(r,s.device,s.presentationFormat,h)},blurRenderer:()=>{if(!s.device)throw new Error("No device.");return Jc(r,s.device,s.presentationFormat,h)},maskSmoothingRenderer:()=>{if(!s.device)throw new Error("No device.");return Zc(r,s.device,h)},prevMaskRenderer:()=>{if(!s.device)throw new Error("No device.");return eu(s.device,h)},release:p=>()=>{for(let d of Object.keys(p))d!=="release"&&p[d]?.release()}},o=or(n),s={canvas:r,presentationFormat:"rgba8unorm",backend:"webgpu",deviceLost:!1,get videoFrameRenderer(){return o.videoFrameRenderer},get blendRenderer(){return o.backgroundImageRenderer},get blurRenderer(){return o.blurRenderer},get maskSmoothingRenderer(){return o.maskSmoothingRenderer},get prevMaskRenderer(){return o.prevMaskRenderer}},a=Ln(s),i=async()=>{if(!navigator.gpu)throw Error("WebGPU not supported.");s.presentationFormat=_s(e)?navigator.gpu.getPreferredCanvasFormat():"rgba8unorm",s.device=await $c(e),s.device.lost.then(p=>{p.reason!=="destroyed"&&(s.deviceLost=!0,t.contextLost(p.message),t.contextRestored(p.message))})},c=(p,d,g)=>{g&&a(g);let A=s.videoFrameRenderer.render(d),R=s.videoFrameRenderer.render({frame:p,width:d.width,height:d.height,timestamp:d.timestamp}),S=s.maskSmoothingRenderer.render(R,s.prevMask,g);if(g.effects==="blur"){let w=s.blurRenderer.render(d,g.backgroundBlurAmount);s.blendRenderer.render(A,w,S)}else if(g.effects==="overlay"&&g.backgroundImage){let w=s.videoFrameRenderer.render({frame:g.backgroundImage,width:g.backgroundImage.width,height:g.backgroundImage.height,timestamp:d.timestamp});s.blendRenderer.render(A,w,S)}s.prevMask=s.prevMaskRenderer.render(S)},l=()=>{o.release(),s.deviceLost=!1,o=or(n)},h=()=>s.deviceLost;return{init:i,render:c,release:l,isContextLost:h}};var ue={projection:(e,t,r=-1)=>[2/e,0,0,0,2/t*r,0,-1,1*-r,1],translation:(e,t)=>[1,0,0,0,1,0,e,t,1],rotation:e=>{let t=Math.cos(e),r=Math.sin(e);return[t,-r,0,r,t,0,0,0,1]},scaling:(e,t)=>[e,0,0,0,t,0,0,0,1],multiply:(e,t)=>{let r=e[0],n=e[0*3+1],o=e[0*3+2],s=e[1*3+0],a=e[1*3+1],i=e[1*3+2],c=e[2*3+0],l=e[2*3+1],h=e[2*3+2],p=t[0*3+0],d=t[0*3+1],g=t[0*3+2],A=t[1*3+0],R=t[1*3+1],S=t[1*3+2],w=t[2*3+0],f=t[2*3+1],y=t[2*3+2];return[p*r+d*s+g*c,p*n+d*a+g*l,p*o+d*i+g*h,A*r+R*s+S*c,A*n+R*a+S*l,A*o+R*i+S*h,w*r+f*s+y*c,w*n+f*a+y*l,w*o+f*i+y*h]},translate:(e,t,r)=>ue.multiply(e,ue.translation(t,r)),rotate:(e,t)=>ue.multiply(e,ue.rotation(t)),scale:(e,t,r)=>ue.multiply(e,ue.scaling(t,r))};var Mn={VertexShader:WebGLRenderingContext.VERTEX_SHADER,FragmentShader:WebGLRenderingContext.FRAGMENT_SHADER},As={[Mn.VertexShader]:"VertexShader",[Mn.FragmentShader]:"FragmentShader"},q2=e=>typeof e=="string"?e.startsWith("#version 300 es"):!1,ru=e=>{if(!q2(e))throw new Error("Expecting GLSL ES 3.00 shader source")},J2=/ERROR:\s*\d+:(\d+)/gi;function su(e,t="",r=0){let n=[...t.matchAll(J2)],o=new Map(n.map((s,a)=>{if(!s[1]||s.index===void 0)return[0,t];let i=Number.parseInt(s[1],10),c=n[a+1],l=c?c.index:t.length,h=t.substring(s.index,l);return[i-1,h]}));return e.split(`
42
42
  `).map((s,a)=>{let i=o.get(a);return`${a+1+r}: ${s}${i?`
43
43
 
44
44
  ^^^ ${i}`:""}`}).join(`
@@ -79,7 +79,7 @@ out vec4 outColor;
79
79
  void main() {
80
80
  outColor = texture(u_texture, v_texCoord);
81
81
  }
82
- `;var Fn=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",texture:"u_texture"},vertexSrc:Ge,fragmentSrc:ar}),a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0);let l=Ke(t),h=Ke(t);t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.width,e.height,0,t.RGBA,t.UNSIGNED_BYTE,null);let f=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,f),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,h,0),{render:d=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,f),t.viewport(0,0,e.width,e.height),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.useProgram(r),t.bindVertexArray(a),t.uniform1i(o.texture,0);let b=ue.projection(1,1,1);return t.uniformMatrix3fv(o.matrix,!1,b),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,l),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,d.frame),t.generateMipmap(t.TEXTURE_2D),t.drawArrays(t.TRIANGLES,0,6),_(h),{texture:h,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteTexture(l),t.deleteTexture(h),t.deleteVertexArray(a),s()}}};var iu=`#version 300 es
82
+ `;var Fn=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",texture:"u_texture"},vertexSrc:Ge,fragmentSrc:ar}),a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0);let l=Ke(t),h=Ke(t);t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.width,e.height,0,t.RGBA,t.UNSIGNED_BYTE,null);let p=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,p),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,h,0),{render:d=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,p),t.viewport(0,0,e.width,e.height),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.useProgram(r),t.bindVertexArray(a),t.uniform1i(o.texture,0);let g=ue.projection(1,1,1);return t.uniformMatrix3fv(o.matrix,!1,g),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,l),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,d.frame),t.generateMipmap(t.TEXTURE_2D),t.drawArrays(t.TRIANGLES,0,6),_(h),{texture:h,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteTexture(l),t.deleteTexture(h),t.deleteVertexArray(a),s()}}};var iu=`#version 300 es
83
83
  precision mediump float;
84
84
 
85
85
  // our textures
@@ -123,7 +123,7 @@ void main() {
123
123
  }
124
124
  outColor = Upsample(u_frame, v_texCoord, halfpixel);
125
125
  }
126
- `;var e1=In(1,9),Rs=(e,t)=>{let{gl:r,program:n,attribLocations:o,uniformLocations:s,release:a}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",downsampling:"u_downsampling",frame:"u_frame"},vertexSrc:Ge,fragmentSrc:iu}),i=r.createVertexArray();r.bindVertexArray(i);let c=r.createBuffer();r.enableVertexAttribArray(o.position),r.bindBuffer(r.ARRAY_BUFFER,c),r.vertexAttribPointer(o.position,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),r.STATIC_DRAW);let l=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),r.STATIC_DRAW),r.enableVertexAttribArray(o.texCoord),r.vertexAttribPointer(o.texCoord,2,r.FLOAT,!1,0,0);let h=(R,A,k)=>{r.bindFramebuffer(r.FRAMEBUFFER,R),r.viewport(0,0,A,k)},f=R=>{let A=Ke(r);_(A);let k=Math.trunc(e.width/2**R),S=Math.trunc(e.height/2**R);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,k,S,0,r.RGBA,r.UNSIGNED_BYTE,null);let p=r.createFramebuffer();_(p),r.bindFramebuffer(r.FRAMEBUFFER,p);let x=r.COLOR_ATTACHMENT0;return r.framebufferTexture2D(r.FRAMEBUFFER,x,r.TEXTURE_2D,A,0),{texture:A,frameBuffer:p,width:k,height:S}},d=(R,A=0)=>{let k=Math.max(e1(A+R)-A,0);return Array.from({length:k}).map((S,p)=>f(A+p))},b=d(t+1);return{render:(R,A)=>{_(!r.isContextLost(),C.ContextLost),r.useProgram(n),r.bindVertexArray(i),r.activeTexture(r.TEXTURE0),r.uniform1i(s.frame,0),r.bindTexture(r.TEXTURE_2D,R.texture),r.uniform1i(s.downsampling,1);let k=A+1;if(k>b.length)for(let S of d(k-b.length,b.length))b.push(S);for(;k<b.length;){let S=b.pop();r.deleteTexture(S?.texture??null),r.deleteFramebuffer(S?.frameBuffer??null)}for(let S=1;S<k;S++){let{frameBuffer:p=null,texture:x=null,width:E=e.width,height:L=e.height}=b[S]??{};h(p,E,L);let I=ue.projection(1,1,1);r.uniformMatrix3fv(s.matrix,!1,I),r.drawArrays(r.TRIANGLES,0,6);let w=r.checkFramebufferStatus(r.FRAMEBUFFER),B=r.getError();if(_(B!==r.CONTEXT_LOST_WEBGL,C.ContextLost),_(!r.isContextLost(),C.ContextLost),w!==r.FRAMEBUFFER_COMPLETE||B!==r.NO_ERROR)throw new Error(C.SamplingError,{cause:`downsampling FrameBuffer Status: ${w}`});r.bindTexture(r.TEXTURE_2D,x)}r.uniform1i(s.downsampling,0);for(let S=A-1;S>=0;S--){let{frameBuffer:p=null,texture:x=null,width:E=e.width,height:L=e.height}=b[S]??{};h(p,E,L);let I=ue.projection(1,1,1);r.uniformMatrix3fv(s.matrix,!1,I),r.drawArrays(r.TRIANGLES,0,6);let w=r.checkFramebufferStatus(r.FRAMEBUFFER),B=r.getError();if(_(B!==r.CONTEXT_LOST_WEBGL,C.ContextLost),_(!r.isContextLost(),C.ContextLost),w!==r.FRAMEBUFFER_COMPLETE||B!==r.NO_ERROR)throw new Error(C.SamplingError,{cause:`Upsampling FrameBuffer Status: ${w}`});r.bindTexture(r.TEXTURE_2D,x)}return{texture:b[0]?.texture??R.texture,width:b[0]?.width??R.width,height:b[0]?.height??R.height}},release:()=>{for(let{frameBuffer:R,texture:A}of b)r.deleteTexture(A),r.deleteFramebuffer(R);r.deleteBuffer(c),r.deleteBuffer(l),r.deleteVertexArray(i),a()}}};var cu=`#version 300 es
126
+ `;var e1=In(1,9),Rs=(e,t)=>{let{gl:r,program:n,attribLocations:o,uniformLocations:s,release:a}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",downsampling:"u_downsampling",frame:"u_frame"},vertexSrc:Ge,fragmentSrc:iu}),i=r.createVertexArray();r.bindVertexArray(i);let c=r.createBuffer();r.enableVertexAttribArray(o.position),r.bindBuffer(r.ARRAY_BUFFER,c),r.vertexAttribPointer(o.position,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),r.STATIC_DRAW);let l=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),r.STATIC_DRAW),r.enableVertexAttribArray(o.texCoord),r.vertexAttribPointer(o.texCoord,2,r.FLOAT,!1,0,0);let h=(A,R,S)=>{r.bindFramebuffer(r.FRAMEBUFFER,A),r.viewport(0,0,R,S)},p=A=>{let R=Ke(r);_(R);let S=Math.trunc(e.width/2**A),w=Math.trunc(e.height/2**A);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,S,w,0,r.RGBA,r.UNSIGNED_BYTE,null);let f=r.createFramebuffer();_(f),r.bindFramebuffer(r.FRAMEBUFFER,f);let y=r.COLOR_ATTACHMENT0;return r.framebufferTexture2D(r.FRAMEBUFFER,y,r.TEXTURE_2D,R,0),{texture:R,frameBuffer:f,width:S,height:w}},d=(A,R=0)=>{let S=Math.max(e1(R+A)-R,0);return Array.from({length:S}).map((w,f)=>p(R+f))},g=d(t+1);return{render:(A,R)=>{_(!r.isContextLost(),C.ContextLost),r.useProgram(n),r.bindVertexArray(i),r.activeTexture(r.TEXTURE0),r.uniform1i(s.frame,0),r.bindTexture(r.TEXTURE_2D,A.texture),r.uniform1i(s.downsampling,1);let S=R+1;if(S>g.length)for(let w of d(S-g.length,g.length))g.push(w);for(;S<g.length;){let w=g.pop();r.deleteTexture(w?.texture??null),r.deleteFramebuffer(w?.frameBuffer??null)}for(let w=1;w<S;w++){let{frameBuffer:f=null,texture:y=null,width:b=e.width,height:L=e.height}=g[w]??{};h(f,b,L);let I=ue.projection(1,1,1);r.uniformMatrix3fv(s.matrix,!1,I),r.drawArrays(r.TRIANGLES,0,6);let k=r.checkFramebufferStatus(r.FRAMEBUFFER),B=r.getError();if(_(B!==r.CONTEXT_LOST_WEBGL,C.ContextLost),_(!r.isContextLost(),C.ContextLost),k!==r.FRAMEBUFFER_COMPLETE||B!==r.NO_ERROR)throw new Error(C.SamplingError,{cause:`downsampling FrameBuffer Status: ${k}`});r.bindTexture(r.TEXTURE_2D,y)}r.uniform1i(s.downsampling,0);for(let w=R-1;w>=0;w--){let{frameBuffer:f=null,texture:y=null,width:b=e.width,height:L=e.height}=g[w]??{};h(f,b,L);let I=ue.projection(1,1,1);r.uniformMatrix3fv(s.matrix,!1,I),r.drawArrays(r.TRIANGLES,0,6);let k=r.checkFramebufferStatus(r.FRAMEBUFFER),B=r.getError();if(_(B!==r.CONTEXT_LOST_WEBGL,C.ContextLost),_(!r.isContextLost(),C.ContextLost),k!==r.FRAMEBUFFER_COMPLETE||B!==r.NO_ERROR)throw new Error(C.SamplingError,{cause:`Upsampling FrameBuffer Status: ${k}`});r.bindTexture(r.TEXTURE_2D,y)}return{texture:g[0]?.texture??A.texture,width:g[0]?.width??A.width,height:g[0]?.height??A.height}},release:()=>{for(let{frameBuffer:A,texture:R}of g)r.deleteTexture(R),r.deleteFramebuffer(A);r.deleteBuffer(c),r.deleteBuffer(l),r.deleteVertexArray(i),a()}}};var cu=`#version 300 es
127
127
  precision mediump float;
128
128
 
129
129
  // our textures
@@ -143,7 +143,7 @@ void main() {
143
143
 
144
144
  outColor = mix(background, foreground, filteredMask);
145
145
  }
146
- `;var uu=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",frameBackground:"u_frame_background",frameForeground:"u_frame_foreground",mask:"u_mask"},vertexSrc:Ge,fragmentSrc:cu});t.enable(t.BLEND);let a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0);let l=Ke(t);t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.width,e.height,0,t.RGBA,t.UNSIGNED_BYTE,null);let h=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,h),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,l,0),{render:({mask:f,foreground:d,background:b})=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,h),t.viewport(0,0,e.width,e.height),t.useProgram(r),t.bindVertexArray(a),t.activeTexture(t.TEXTURE0),t.uniform1i(o.frameForeground,0),t.bindTexture(t.TEXTURE_2D,d.texture),t.activeTexture(t.TEXTURE1),t.uniform1i(o.frameBackground,1),t.bindTexture(t.TEXTURE_2D,b.texture),t.activeTexture(t.TEXTURE2),t.uniform1i(o.mask,2),t.bindTexture(t.TEXTURE_2D,f.texture);let R=ue.projection(1,1,1);return t.uniformMatrix3fv(o.matrix,!1,R),t.drawArrays(t.TRIANGLES,0,6),_(l),{texture:l,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteTexture(l),t.deleteFramebuffer(h),t.deleteVertexArray(a),s()}}};var Un=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",texture:"u_texture"},vertexSrc:Ge,fragmentSrc:ar}),a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0),{render:l=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,e.width,e.height),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.useProgram(r),t.bindVertexArray(a),t.uniform1i(o.texture,0);let h=ue.projection(1,1);t.uniformMatrix3fv(o.matrix,!1,h),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,l.texture),t.drawArrays(t.TRIANGLES,0,6)},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteVertexArray(a),s()}}};var hu=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",texture:"u_texture"},vertexSrc:Ge,fragmentSrc:ar}),a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0);let l=Ke(t);t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.width,e.height,0,t.RGBA,t.UNSIGNED_BYTE,null);let h=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,h),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,l,0),{render:f=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,h),t.viewport(0,0,e.width,e.height),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.useProgram(r),t.bindVertexArray(a),t.activeTexture(t.TEXTURE0),t.uniform1i(o.texture,0),t.bindTexture(t.TEXTURE_2D,f.texture);let d=ue.projection(1,1,1);return t.uniformMatrix3fv(o.matrix,!1,d),t.drawArrays(t.TRIANGLES,0,6),_(l),{texture:l,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteTexture(l),t.deleteVertexArray(a),s()}}};var lu=`#version 300 es
146
+ `;var uu=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",frameBackground:"u_frame_background",frameForeground:"u_frame_foreground",mask:"u_mask"},vertexSrc:Ge,fragmentSrc:cu});t.enable(t.BLEND);let a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0);let l=Ke(t);t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.width,e.height,0,t.RGBA,t.UNSIGNED_BYTE,null);let h=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,h),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,l,0),{render:({mask:p,foreground:d,background:g})=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,h),t.viewport(0,0,e.width,e.height),t.useProgram(r),t.bindVertexArray(a),t.activeTexture(t.TEXTURE0),t.uniform1i(o.frameForeground,0),t.bindTexture(t.TEXTURE_2D,d.texture),t.activeTexture(t.TEXTURE1),t.uniform1i(o.frameBackground,1),t.bindTexture(t.TEXTURE_2D,g.texture),t.activeTexture(t.TEXTURE2),t.uniform1i(o.mask,2),t.bindTexture(t.TEXTURE_2D,p.texture);let A=ue.projection(1,1,1);return t.uniformMatrix3fv(o.matrix,!1,A),t.drawArrays(t.TRIANGLES,0,6),_(l),{texture:l,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteTexture(l),t.deleteFramebuffer(h),t.deleteVertexArray(a),s()}}};var Un=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",texture:"u_texture"},vertexSrc:Ge,fragmentSrc:ar}),a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0),{render:l=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,e.width,e.height),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.useProgram(r),t.bindVertexArray(a),t.uniform1i(o.texture,0);let h=ue.projection(1,1);t.uniformMatrix3fv(o.matrix,!1,h),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,l.texture),t.drawArrays(t.TRIANGLES,0,6)},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteVertexArray(a),s()}}};var hu=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",texture:"u_texture"},vertexSrc:Ge,fragmentSrc:ar}),a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0);let l=Ke(t);t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.width,e.height,0,t.RGBA,t.UNSIGNED_BYTE,null);let h=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,h),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,l,0),{render:p=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,h),t.viewport(0,0,e.width,e.height),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.useProgram(r),t.bindVertexArray(a),t.activeTexture(t.TEXTURE0),t.uniform1i(o.texture,0),t.bindTexture(t.TEXTURE_2D,p.texture);let d=ue.projection(1,1,1);return t.uniformMatrix3fv(o.matrix,!1,d),t.drawArrays(t.TRIANGLES,0,6),_(l),{texture:l,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteTexture(l),t.deleteVertexArray(a),s()}}};var lu=`#version 300 es
147
147
  precision mediump float;
148
148
 
149
149
  // our textures
@@ -199,4 +199,4 @@ void main() {
199
199
 
200
200
  outColor = vec4(backgroundMask, backgroundMask, backgroundMask, backgroundMask);
201
201
  }
202
- `;var du=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",mask:"u_mask",maskCombineRatio:"u_mask_combine_ratio",foregroundThreshold:"u_foreground_threshold",prevMask:"u_mask_prev"},vertexSrc:Ge,fragmentSrc:lu}),a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0);let l=Ke(t);t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.width,e.height,0,t.RGBA,t.UNSIGNED_BYTE,null);let h=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,h),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,l,0),{render:({mask:f,prevMask:d},b)=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,h),t.viewport(0,0,e.width,e.height),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.useProgram(r),t.bindVertexArray(a),t.activeTexture(t.TEXTURE0),t.uniform1i(o.mask,0),t.bindTexture(t.TEXTURE_2D,f.texture),t.activeTexture(t.TEXTURE1),t.uniform1i(o.prevMask,1),t.bindTexture(t.TEXTURE_2D,d?.texture??f.texture);let R=ue.projection(1,1,1);return t.uniformMatrix3fv(o.matrix,!1,R),t.uniform1f(o.maskCombineRatio,b.maskCombineRatio),t.uniform1f(o.foregroundThreshold,b.foregroundThreshold),t.drawArrays(t.TRIANGLES,0,6),_(l),{texture:l,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteTexture(l),t.deleteFramebuffer(h),t.deleteVertexArray(a),s()}}};var fu=(e,t=new OffscreenCanvas(768,432))=>{let r={videoFrameRenderer:()=>Fn(t),maskRenderer:()=>Fn(t),canvasRenderer:()=>Un(t),backgroundImageRenderer:()=>Fn(t),blendRenderer:()=>uu(t),blurRenderer:()=>Rs(t,3),maskBlurRenderer:()=>Rs(t,3),textureRenderer:()=>hu(t),smoothingMaskRenderer:()=>du(t),release:h=>()=>{for(let f in h)f!=="release"&&h[f]?.release()}},n=or(r),o={canvas:t,gl:null,canvasContextEventsCleanup:()=>{},get videoFrameRenderer(){return n.videoFrameRenderer},get maskRenderer(){return n.maskRenderer},get canvasRenderer(){return n.canvasRenderer},get backgroundImageRenderer(){return n.backgroundImageRenderer},get blendRenderer(){return n.blendRenderer},get blurRenderer(){return n.blurRenderer},get maskBlurRenderer(){return n.maskBlurRenderer},get textureRenderer(){return n.textureRenderer},get smoothingMaskRenderer(){return n.smoothingMaskRenderer}},s=()=>{o.canvasContextEventsCleanup=Yc(t,{contextLost:e.contextLost,contextRestored:e.contextRestored,contextCreationError:e.contextCreationError},i),o.gl=t.getContext("webgl2",{premultipliedAlpha:!1,powerPreference:"high-performance"}),_(o.gl,C.ContextCreationError)},a=(h,f,d)=>{_(!o.gl?.isContextLost(),C.ContextLost);let b=o.maskRenderer.render({frame:h,width:h.width,height:h.height,timestamp:f.timestamp}),R=o.smoothingMaskRenderer.render({mask:b,prevMask:o.prevMask},d),A=o.videoFrameRenderer.render(f),k=A;d.effects==="blur"&&d.backgroundBlurAmount?k=o.blurRenderer.render(A,d.backgroundBlurAmount):d?.effects==="overlay"&&d.backgroundImage&&(k=o.backgroundImageRenderer.render({frame:d.backgroundImage,timestamp:performance.now(),width:d.backgroundImage.width,height:d.backgroundImage.height}));let S=o.blendRenderer.render({mask:R,foreground:A,background:k});o.canvasRenderer.render(S),o.prevMask=o.textureRenderer.render(R)},i=()=>{o.canvasContextEventsCleanup(),n.release(),n=or(r),o.prevMask=void 0};return{init:s,render:a,release:()=>{i()},isContextLost:()=>!!o.gl?.isContextLost()}};var t1={drawImageDataCanvas:"drawImageDataCanvas",maskCanvas:"maskCanvas",blurredMaskCanvas:"blurredMaskCanvas",blurredCanvas:"blurredCanvas",downScaledCanvas:"downScaledCanvas",backgroundImageCanvas:"backgroundImageCanvas",inputCanvas:"inputCanvas"},wt=(e,t)=>{let r=e.getContext("2d",t);if(!r)throw new Error("Cannot get CanvasRenderingContext2D");return r},r1=e=>{let t=wt(e);t.scale(-1,1),t.translate(-e.width,0)},Ss=e=>"VideoFrame"in globalThis&&e instanceof VideoFrame?{height:e.displayHeight,width:e.displayWidth}:"offsetHeight"in e&&typeof e.offsetHeight=="number"&&e.offsetHeight!==0&&"offsetWidth"in e&&typeof e.offsetWidth=="number"&&e.offsetWidth!==0?{height:e.offsetHeight,width:e.offsetWidth}:"videoHeight"in e&&typeof e.videoHeight=="number"&&e.videoHeight!==0&&"videoWidth"in e&&typeof e.videoWidth=="number"&&e.videoWidth!==0?{height:e.videoHeight,width:e.videoWidth}:"height"in e&&e.height!==0&&"width"in e&&e.width!==0?{height:e.height,width:e.width}:{height:0,width:0},$e=(e,t)=>new OffscreenCanvas(e,t);var n1=e=>{wt(e).clearRect(0,0,e.width,e.height)},Cs=(e,t)=>{let r={downScaleFactor:3},n=p=>$e(p==="downScaledCanvas"?Math.trunc(e/r.downScaleFactor):e,p==="downScaledCanvas"?Math.trunc(t/r.downScaleFactor):t),o=p=>{let x=r[p];if(!x){let E=n(p);return r[p]=E,E}return x},s=(p,x)=>{let E=o(x);return wt(E).putImageData(p,0,0),E},a=(p,x,E,L,I,w,B,U,j,W)=>{let le=x instanceof ImageData?s(x,"drawImageDataCanvas"):x;I===void 0||w===void 0?p.drawImage(le,E,L):B===void 0||U===void 0||j===void 0||W===void 0?p.drawImage(le,E,L,I,w):p.drawImage(le,E,L,I,w,B,U,j,W)},i=(p,x,E=e,L=t,I={})=>{let{height:w,width:B}=Ss(p),U=Hc(B,w,E,L),j=wt(x,I);a(j,p,U.sx,U.sy,U.sw,U.sh,U.dx,U.dy,U.dw,U.dh)},c=(p,x)=>{let E=o(x);return i(p,E),E},l=(p,x,E)=>{p.globalCompositeOperation=E,a(p,x,0,0)},h=(p,x,E)=>{let L=wt(p),I=0,w=5,B=1/(2*Math.PI*w*w),U=E<3?1:2;for(let j=-E;j<=E;j+=U)for(let W=-E;W<=E;W+=U){let le=B*Math.exp(-(W*W+j*j)/(2*w*w));I+=le}for(let j=-E;j<=E;j+=U)for(let W=-E;W<=E;W+=U)L.globalAlpha=B*Math.exp(-(W*W+j*j)/(2*w*w))/I*E,a(L,x,W,j);L.globalAlpha=1},f=({image:p,blurAmount:x,canvas:E,preserveOldDrawing:L=!0})=>{let{height:I,width:w}=Ss(p),B=wt(E);if(x<=0)return a(B,p,0,0,w,I);let U=o("downScaledCanvas"),j=wt(U);L||(j.clearRect(0,0,U.width,U.height),B.clearRect(0,0,w,I)),"filter"in B?(j.filter=`blur(${x}px)`,a(j,p,0,0,w,I,0,0,U.width,U.height),a(B,U,0,0,w,I)):h(E,p,x)},d=({image:p,blurAmount:x,offscreenCanvasName:E,preserveOldDrawing:L})=>{let I=o(E);return n1(I),x===0?i(p,I):f({image:p,blurAmount:x,canvas:I,preserveOldDrawing:L}),I},b=(p,x,E)=>{let L=Array.isArray(p)?p[0]?.canvas:p.canvas;if(!L)return o("maskCanvas");let I=d({image:L,offscreenCanvasName:"maskCanvas",blurAmount:0});return E===0?I:d({image:I,blurAmount:E,offscreenCanvasName:"blurredMaskCanvas",preserveOldDrawing:!1})},R=(p,x,E,L,I=.5,w=3,B=3,U=!1)=>{let j=d({image:E,blurAmount:w,offscreenCanvasName:"blurredCanvas"}),W=wt(p);if(Array.isArray(L)&&L.length===0)return a(W,j,0,0);let le=b(L,I,B);W.save(),U&&r1(p);let{height:mu,width:gu}=Ss(x);a(W,x,0,0,gu,mu),l(W,le,"destination-in"),l(W,j,"destination-over"),W.restore()};return{evaluateInput:p=>c(p,"inputCanvas"),renderImageToCanvas:i,drawBlurEffect:(p,x,E,L=.5,I=3,w=3,B=!1)=>R(p,x,x,E,L,I,w,B),drawOverlayEffect:(p,x,E,L,I=.5,w=0,B=3,U=!1)=>R(p,x,E,L,I,w,B,U),renderImageToOffScreenCanvas:c,renderImageDataToOffScreenCanvas:s,drawAndBlurImageOnOffScreenCanvas:d,reset:()=>{for(let p in t1){let x=p,E=r[x];E&&E instanceof OffscreenCanvas&&(r[x]=n(x))}}}};var pu=e=>typeof e=="string"?Object.values(Wc).includes(e):!1;var u={width:768,height:432,status:z.New,directOutput:!1,delegate:"GPU",modelAssetPath:"",renderOptions:{edgeBlurAmount:3,backgroundBlurAmount:3,foregroundThreshold:.5,maskCombineRatio:.5,effects:jc.None,backgroundImageUrl:"",backgroundImage:null,backend:"webgl"}},Ms=Ln(u.renderOptions),pe=(e,t)=>postMessage(e,t??[]),a1=e=>{if(u.status!==z.Error){u.status=z.Error;try{u.segmenter?.close()}catch(t){pe({type:"event",data:{type:C.ContextLost,message:`Failed to close segmenter ${t}`}})}u.segmenter=void 0}pe({type:"event",data:{type:C.ContextLost,message:e}})},i1=e=>{pe({type:"event",data:{type:C.ContextRestored,message:e}})},c1=e=>{u.status!==z.Error&&(u.status=z.Error),pe({type:"event",data:{type:C.ContextCreationError,message:e}})},u1=async()=>{u.renderer?.release();let t=navigator.gpu&&u.renderOptions?.backend==="webgpu"?tu:fu;u.renderer=t({contextLost:a1,contextRestored:i1,contextCreationError:c1},u.processCanvas),await u.renderer?.init()},h1=async()=>{_(u.visionInstance),u.segmenter=await de.createFromOptions(u.visionInstance,{outputCategoryMask:!1,outputConfidenceMasks:!0,runningMode:"VIDEO",canvas:u.segmenterCanvas,baseOptions:{modelAssetPath:u.modelAssetPath,delegate:u.delegate}})},Ls=async e=>{u.segmenterCanvas=e,u.segmenterTextureToCanvas=Un(u.segmenterCanvas),await h1()},Is=async e=>{u.processCanvas=e,await u1()},l1=async(e={})=>{try{u.status=z.Opening,e.processingWidth&&(u.width=e.processingWidth),e.processingHeight&&(u.height=e.processingHeight),e.renderOptions&&Ms(e.renderOptions),u.directOutput=!!e.output,u.output=e.output??$e(u.width,u.height);let{basePath:t,imageSegmenterOptions:r={}}=e;u.modelAssetPath=r.modelAsset?.path??u.modelAssetPath,u.delegate=r.delegate??u.delegate,u.visionInstance=await dt.forVisionTasks(t),u.backgroundImages=Xc(e.backgroundImage&&[[e.backgroundImage.key,e.backgroundImage.image]]),await Is(r.canvas??$e(u.width,u.height)),await Ls(r.segmenterCanvas??$e(u.width,u.height)),u.renderUtils=Cs(u.width,u.height),u.status=z.Opened,pe({type:"opened"})}catch(t){u.status=z.Error;let r=Cn(t);pe({type:"event",data:{type:Sn(r),message:r}})}},d1=(e,t)=>{try{u.videoFrame=e,_(u.segmenter),_(u.renderUtils),t&&Ms(t),_(!u.renderer?.isContextLost(),C.ContextLost);let r=u.status===z.Error||u.status===z.Opening||u.status===z.Updating||u.renderOptions.effects==="none"||u.renderOptions.effects==="blur"&&u.renderOptions.backgroundBlurAmount===0||u.renderOptions?.effects==="overlay"&&!u.renderOptions.backgroundImageUrl;if(r)return pe({type:"processed",data:e},[e.frame]),e.frame.close(),pe({type:"debug",data:{message:"skip processing",context:{name:"media worker",renderingOptions:u.renderOptions,status:u.status,contextLost:u.renderer?.isContextLost()}}});if(u.renderOptions?.effects==="overlay"&&u.renderOptions.backgroundImageUrl){let n=u.backgroundImages?.getImage(u.renderOptions.backgroundImageUrl);n?u.renderOptions.backgroundImage=n:(r=!0,u.backgroundImages?.tryFetchingImage(u.renderOptions.backgroundImageUrl).catch(o=>{u.status=z.Error,pe({type:"debug",data:{message:`failed to download ${u.renderOptions.backgroundImageUrl}`,context:{name:"media worker",error:o}}})}))}u.status=z.Processing,u.segmenter.segmentForVideo(u.renderUtils.renderImageToOffScreenCanvas(e.frame,"inputCanvas"),performance.now(),n=>{let{confidenceMasks:o}=n,s=o?.[0];if(!s)pe({type:"processed"});else{_(u.output),_(u.renderer),_(u.renderUtils),_(u.processCanvas),_(u.segmenterCanvas),_(u.segmenterTextureToCanvas),u.segmenterTextureToCanvas.render(au(s));let a=u.segmenterCanvas.transferToImageBitmap();u.renderer.render(a,e,u.renderOptions),u.renderUtils.renderImageToCanvas(u.processCanvas,u.output,u.width,u.height),e.frame.close();let i=u.directOutput?void 0:u.output.transferToImageBitmap();pe({type:"processed",data:i&&{frame:i,width:u.output.width,height:u.output.height,timestamp:performance.now()}},i?[i]:void 0)}n.close(),u.status=z.Idle})}catch(r){let n=Cn(r);return u.status=z.Error,pe({type:"event",data:{type:Sn(n),message:n,frame:e}},[e.frame]),e.frame.close()}},f1=async({backgroundImage:e,renderOptions:t,imageSegmenterOptions:r,processingHeight:n,processingWidth:o,output:s,restart:a})=>{if(u.status!==z.Updating)try{u.status=z.Updating,e&&u.backgroundImages?.setImage(e.key,e.image);let i=a;if(n&&n!==u.height&&(u.height=n,i=!0),o&&o!==u.width&&(u.width=o,i=!0),t?.backend&&!pu(t.backend)){u.status=z.Error,pe({type:"event",data:{type:"Error",message:"Render backend is not webgl or webgpu"}});return}let c=t?.backend&&t?.backend!==u.renderOptions.backend;t&&Ms(t),r&&(u.modelAssetPath=r.modelAsset?.path??u.modelAssetPath,u.delegate=r.delegate??u.delegate,r.canvas!==u.processCanvas&&await Is(r.canvas??$e(u.width,u.height)),r.segmenterCanvas!==u.segmenterCanvas&&await Ls(r?.segmenterCanvas??$e(u.width,u.height))),s!==void 0&&(u.output=s??$e(u.width,u.height),u.directOutput=!!s),(i||c)&&(s===void 0&&(u.output=$e(u.width,u.height)),u.renderUtils=Cs(u.width,u.height),await Is(r?.canvas??$e(u.width,u.height))),i&&await Ls(r?.segmenterCanvas??$e(u.width,u.height)),u.status=z.Updated,pe({type:"updated"})}catch(i){u.status=z.Error;let c=Cn(i);pe({type:"event",data:{type:Sn(c),message:c}})}};self.addEventListener("message",e=>{switch(e.data.type){case"open":{l1(e.data.data);break}case"update":{f1(e.data.data);break}case"process":{let{videoFrame:t,renderOptions:r}=e.data.data;d1(t,r);break}case"close":{u.status=z.Closing,u.renderer?.release(),u.segmenterTextureToCanvas?.release(),u.videoFrame?.frame.close(),u.segmenter?.close(),u.backgroundImages?.clear(),u.status=z.Closed;break}case"destroy":{u.status=z.Destroying,u.renderer=void 0,u.videoFrame=void 0,u.segmenter=void 0,u.backgroundImages=void 0,u.status=z.Destroyed;break}}});self.addEventListener("error",e=>{e.preventDefault(),pe({type:"event",data:{type:C.Error,message:`Uncaught Error event: ${e.error}`}})});
202
+ `;var du=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:o,release:s}=Ne(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",mask:"u_mask",maskCombineRatio:"u_mask_combine_ratio",foregroundThreshold:"u_foreground_threshold",prevMask:"u_mask_prev"},vertexSrc:Ge,fragmentSrc:lu}),a=t.createVertexArray();t.bindVertexArray(a);let i=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,i),t.vertexAttribPointer(n.position,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW);let c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(n.texCoord),t.vertexAttribPointer(n.texCoord,2,t.FLOAT,!1,0,0);let l=Ke(t);t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.width,e.height,0,t.RGBA,t.UNSIGNED_BYTE,null);let h=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,h),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,l,0),{render:({mask:p,prevMask:d},g)=>{_(!t.isContextLost(),C.ContextLost),t.bindFramebuffer(t.FRAMEBUFFER,h),t.viewport(0,0,e.width,e.height),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.useProgram(r),t.bindVertexArray(a),t.activeTexture(t.TEXTURE0),t.uniform1i(o.mask,0),t.bindTexture(t.TEXTURE_2D,p.texture),t.activeTexture(t.TEXTURE1),t.uniform1i(o.prevMask,1),t.bindTexture(t.TEXTURE_2D,d?.texture??p.texture);let A=ue.projection(1,1,1);return t.uniformMatrix3fv(o.matrix,!1,A),t.uniform1f(o.maskCombineRatio,g.maskCombineRatio),t.uniform1f(o.foregroundThreshold,g.foregroundThreshold),t.drawArrays(t.TRIANGLES,0,6),_(l),{texture:l,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(i),t.deleteBuffer(c),t.deleteTexture(l),t.deleteFramebuffer(h),t.deleteVertexArray(a),s()}}};var fu=(e,t=new OffscreenCanvas(768,432))=>{let r={videoFrameRenderer:()=>Fn(t),maskRenderer:()=>Fn(t),canvasRenderer:()=>Un(t),backgroundImageRenderer:()=>Fn(t),blendRenderer:()=>uu(t),blurRenderer:()=>Rs(t,3),maskBlurRenderer:()=>Rs(t,3),textureRenderer:()=>hu(t),smoothingMaskRenderer:()=>du(t),release:h=>()=>{for(let p in h)p!=="release"&&h[p]?.release()}},n=or(r),o={canvas:t,gl:null,canvasContextEventsCleanup:()=>{},get videoFrameRenderer(){return n.videoFrameRenderer},get maskRenderer(){return n.maskRenderer},get canvasRenderer(){return n.canvasRenderer},get backgroundImageRenderer(){return n.backgroundImageRenderer},get blendRenderer(){return n.blendRenderer},get blurRenderer(){return n.blurRenderer},get maskBlurRenderer(){return n.maskBlurRenderer},get textureRenderer(){return n.textureRenderer},get smoothingMaskRenderer(){return n.smoothingMaskRenderer}},s=()=>{o.canvasContextEventsCleanup=Yc(t,{contextLost:e.contextLost,contextRestored:e.contextRestored,contextCreationError:e.contextCreationError},i),o.gl=t.getContext("webgl2",{premultipliedAlpha:!1,powerPreference:"high-performance"}),_(o.gl,C.ContextCreationError)},a=(h,p,d)=>{_(!o.gl?.isContextLost(),C.ContextLost);let g=o.maskRenderer.render({frame:h,width:h.width,height:h.height,timestamp:p.timestamp}),A=o.smoothingMaskRenderer.render({mask:g,prevMask:o.prevMask},d),R=o.videoFrameRenderer.render(p),S=R;d.effects==="blur"&&d.backgroundBlurAmount?S=o.blurRenderer.render(R,d.backgroundBlurAmount):d?.effects==="overlay"&&d.backgroundImage&&(S=o.backgroundImageRenderer.render({frame:d.backgroundImage,timestamp:performance.now(),width:d.backgroundImage.width,height:d.backgroundImage.height}));let w=o.blendRenderer.render({mask:A,foreground:R,background:S});o.canvasRenderer.render(w),o.prevMask=o.textureRenderer.render(A)},i=()=>{o.canvasContextEventsCleanup(),n.release(),n=or(r),o.prevMask=void 0};return{init:s,render:a,release:()=>{i()},isContextLost:()=>!!o.gl?.isContextLost()}};var t1={drawImageDataCanvas:"drawImageDataCanvas",maskCanvas:"maskCanvas",blurredMaskCanvas:"blurredMaskCanvas",blurredCanvas:"blurredCanvas",downScaledCanvas:"downScaledCanvas",backgroundImageCanvas:"backgroundImageCanvas",inputCanvas:"inputCanvas"},wt=(e,t)=>{let r=e.getContext("2d",t);if(!r)throw new Error("Cannot get CanvasRenderingContext2D");return r},r1=e=>{let t=wt(e);t.scale(-1,1),t.translate(-e.width,0)},Ss=e=>"VideoFrame"in globalThis&&e instanceof VideoFrame?{height:e.displayHeight,width:e.displayWidth}:"offsetHeight"in e&&typeof e.offsetHeight=="number"&&e.offsetHeight!==0&&"offsetWidth"in e&&typeof e.offsetWidth=="number"&&e.offsetWidth!==0?{height:e.offsetHeight,width:e.offsetWidth}:"videoHeight"in e&&typeof e.videoHeight=="number"&&e.videoHeight!==0&&"videoWidth"in e&&typeof e.videoWidth=="number"&&e.videoWidth!==0?{height:e.videoHeight,width:e.videoWidth}:"height"in e&&e.height!==0&&"width"in e&&e.width!==0?{height:e.height,width:e.width}:{height:0,width:0},$e=(e,t)=>new OffscreenCanvas(e,t);var n1=e=>{wt(e).clearRect(0,0,e.width,e.height)},Cs=(e,t)=>{let r={downScaleFactor:3},n=f=>$e(f==="downScaledCanvas"?Math.trunc(e/r.downScaleFactor):e,f==="downScaledCanvas"?Math.trunc(t/r.downScaleFactor):t),o=f=>{let y=r[f];if(!y){let b=n(f);return r[f]=b,b}return y},s=(f,y)=>{let b=o(y);return wt(b).putImageData(f,0,0),b},a=(f,y,b,L,I,k,B,U,j,W)=>{let le=y instanceof ImageData?s(y,"drawImageDataCanvas"):y;I===void 0||k===void 0?f.drawImage(le,b,L):B===void 0||U===void 0||j===void 0||W===void 0?f.drawImage(le,b,L,I,k):f.drawImage(le,b,L,I,k,B,U,j,W)},i=(f,y,b=e,L=t,I={})=>{let{height:k,width:B}=Ss(f),U=Hc(B,k,b,L),j=wt(y,I);a(j,f,U.sx,U.sy,U.sw,U.sh,U.dx,U.dy,U.dw,U.dh)},c=(f,y)=>{let b=o(y);return i(f,b),b},l=(f,y,b)=>{f.globalCompositeOperation=b,a(f,y,0,0)},h=(f,y,b)=>{let L=wt(f),I=0,k=5,B=1/(2*Math.PI*k*k),U=b<3?1:2;for(let j=-b;j<=b;j+=U)for(let W=-b;W<=b;W+=U){let le=B*Math.exp(-(W*W+j*j)/(2*k*k));I+=le}for(let j=-b;j<=b;j+=U)for(let W=-b;W<=b;W+=U)L.globalAlpha=B*Math.exp(-(W*W+j*j)/(2*k*k))/I*b,a(L,y,W,j);L.globalAlpha=1},p=({image:f,blurAmount:y,canvas:b,preserveOldDrawing:L=!0})=>{let{height:I,width:k}=Ss(f),B=wt(b);if(y<=0)return a(B,f,0,0,k,I);let U=o("downScaledCanvas"),j=wt(U);L||(j.clearRect(0,0,U.width,U.height),B.clearRect(0,0,k,I)),"filter"in B?(j.filter=`blur(${y}px)`,a(j,f,0,0,k,I,0,0,U.width,U.height),a(B,U,0,0,k,I)):h(b,f,y)},d=({image:f,blurAmount:y,offscreenCanvasName:b,preserveOldDrawing:L})=>{let I=o(b);return n1(I),y===0?i(f,I):p({image:f,blurAmount:y,canvas:I,preserveOldDrawing:L}),I},g=(f,y,b)=>{let L=Array.isArray(f)?f[0]?.canvas:f.canvas;if(!L)return o("maskCanvas");let I=d({image:L,offscreenCanvasName:"maskCanvas",blurAmount:0});return b===0?I:d({image:I,blurAmount:b,offscreenCanvasName:"blurredMaskCanvas",preserveOldDrawing:!1})},A=(f,y,b,L,I=.5,k=3,B=3,U=!1)=>{let j=d({image:b,blurAmount:k,offscreenCanvasName:"blurredCanvas"}),W=wt(f);if(Array.isArray(L)&&L.length===0)return a(W,j,0,0);let le=g(L,I,B);W.save(),U&&r1(f);let{height:mu,width:gu}=Ss(y);a(W,y,0,0,gu,mu),l(W,le,"destination-in"),l(W,j,"destination-over"),W.restore()};return{evaluateInput:f=>c(f,"inputCanvas"),renderImageToCanvas:i,drawBlurEffect:(f,y,b,L=.5,I=3,k=3,B=!1)=>A(f,y,y,b,L,I,k,B),drawOverlayEffect:(f,y,b,L,I=.5,k=0,B=3,U=!1)=>A(f,y,b,L,I,k,B,U),renderImageToOffScreenCanvas:c,renderImageDataToOffScreenCanvas:s,drawAndBlurImageOnOffScreenCanvas:d,reset:()=>{for(let f in t1){let y=f,b=r[y];b&&b instanceof OffscreenCanvas&&(r[y]=n(y))}}}};var pu=e=>typeof e=="string"?Object.values(Wc).includes(e):!1;var u={width:768,height:432,status:z.New,directOutput:!1,delegate:"GPU",modelAssetPath:"",renderOptions:{edgeBlurAmount:3,backgroundBlurAmount:3,foregroundThreshold:.5,maskCombineRatio:.5,effects:jc.None,backgroundImageUrl:"",backgroundImage:null,backend:"webgl"}},Ms=Ln(u.renderOptions),pe=(e,t)=>postMessage(e,t??[]),a1=e=>{if(u.status!==z.Error){u.status=z.Error;try{u.segmenter?.close()}catch(t){pe({type:"event",data:{type:C.ContextLost,message:`Failed to close segmenter ${t}`}})}u.segmenter=void 0}pe({type:"event",data:{type:C.ContextLost,message:e}})},i1=e=>{pe({type:"event",data:{type:C.ContextRestored,message:e}})},c1=e=>{u.status!==z.Error&&(u.status=z.Error),pe({type:"event",data:{type:C.ContextCreationError,message:e}})},u1=async()=>{u.renderer?.release(),u.renderer=void 0;let e=[{contextLost:a1,contextRestored:i1,contextCreationError:c1},u.processCanvas],t=()=>fu(...e);if(navigator.gpu&&u.renderOptions?.backend==="webgpu"){let n=await navigator.gpu.requestAdapter();n?u.renderer=tu(n,...e):u.renderer=t()}else u.renderer=t();await u.renderer?.init()},h1=async()=>{_(u.visionInstance),u.segmenter=await de.createFromOptions(u.visionInstance,{outputCategoryMask:!1,outputConfidenceMasks:!0,runningMode:"VIDEO",canvas:u.segmenterCanvas,baseOptions:{modelAssetPath:u.modelAssetPath,delegate:u.delegate}})},Ls=async e=>{u.segmenterCanvas=e,u.segmenterTextureToCanvas=Un(u.segmenterCanvas),await h1()},Is=async e=>{u.processCanvas=e,await u1()},l1=async(e={})=>{try{u.status=z.Opening,e.processingWidth&&(u.width=e.processingWidth),e.processingHeight&&(u.height=e.processingHeight),e.renderOptions&&Ms(e.renderOptions),u.directOutput=!!e.output,u.output=e.output??$e(u.width,u.height);let{basePath:t,imageSegmenterOptions:r={}}=e;u.modelAssetPath=r.modelAsset?.path??u.modelAssetPath,u.delegate=r.delegate??u.delegate,u.visionInstance=await dt.forVisionTasks(t),u.backgroundImages=Xc(e.backgroundImage&&[[e.backgroundImage.key,e.backgroundImage.image]]),await Is(r.canvas??$e(u.width,u.height)),await Ls(r.segmenterCanvas??$e(u.width,u.height)),u.renderUtils=Cs(u.width,u.height),u.status=z.Opened,pe({type:"opened"})}catch(t){u.status=z.Error;let r=Cn(t);pe({type:"event",data:{type:Sn(r),message:r}})}},d1=(e,t)=>{try{u.videoFrame=e,_(u.segmenter),_(u.renderUtils),t&&Ms(t),_(!u.renderer?.isContextLost(),C.ContextLost);let r=u.status===z.Error||u.status===z.Opening||u.status===z.Updating||u.renderOptions.effects==="none"||u.renderOptions.effects==="blur"&&u.renderOptions.backgroundBlurAmount===0||u.renderOptions?.effects==="overlay"&&!u.renderOptions.backgroundImageUrl;if(r)return pe({type:"processed",data:e},[e.frame]),e.frame.close(),pe({type:"debug",data:{message:"skip processing",context:{name:"media worker",renderingOptions:u.renderOptions,status:u.status,contextLost:u.renderer?.isContextLost()}}});if(u.renderOptions?.effects==="overlay"&&u.renderOptions.backgroundImageUrl){let n=u.backgroundImages?.getImage(u.renderOptions.backgroundImageUrl);n?u.renderOptions.backgroundImage=n:(r=!0,u.backgroundImages?.tryFetchingImage(u.renderOptions.backgroundImageUrl).catch(o=>{u.status=z.Error,pe({type:"debug",data:{message:`failed to download ${u.renderOptions.backgroundImageUrl}`,context:{name:"media worker",error:o}}})}))}u.status=z.Processing,u.segmenter.segmentForVideo(u.renderUtils.renderImageToOffScreenCanvas(e.frame,"inputCanvas"),performance.now(),n=>{let{confidenceMasks:o}=n,s=o?.[0];if(!s)pe({type:"processed"});else{_(u.output),_(u.renderer),_(u.renderUtils),_(u.processCanvas),_(u.segmenterCanvas),_(u.segmenterTextureToCanvas),u.segmenterTextureToCanvas.render(au(s));let a=u.segmenterCanvas.transferToImageBitmap();u.renderer.render(a,e,u.renderOptions),u.renderUtils.renderImageToCanvas(u.processCanvas,u.output,u.width,u.height),e.frame.close();let i=u.directOutput?void 0:u.output.transferToImageBitmap();pe({type:"processed",data:i&&{frame:i,width:u.output.width,height:u.output.height,timestamp:performance.now()}},i?[i]:void 0)}n.close(),u.status=z.Idle})}catch(r){let n=Cn(r);return u.status=z.Error,pe({type:"event",data:{type:Sn(n),message:n,frame:e}},[e.frame]),e.frame.close()}},f1=async({backgroundImage:e,renderOptions:t,imageSegmenterOptions:r,processingHeight:n,processingWidth:o,output:s,restart:a})=>{if(u.status!==z.Updating)try{u.status=z.Updating,e&&u.backgroundImages?.setImage(e.key,e.image);let i=a;if(n&&n!==u.height&&(u.height=n,i=!0),o&&o!==u.width&&(u.width=o,i=!0),t?.backend&&!pu(t.backend)){u.status=z.Error,pe({type:"event",data:{type:"Error",message:"Render backend is not webgl or webgpu"}});return}let c=t?.backend&&t?.backend!==u.renderOptions.backend;t&&Ms(t),r&&(u.modelAssetPath=r.modelAsset?.path??u.modelAssetPath,u.delegate=r.delegate??u.delegate,r.canvas!==u.processCanvas&&await Is(r.canvas??$e(u.width,u.height)),r.segmenterCanvas!==u.segmenterCanvas&&await Ls(r?.segmenterCanvas??$e(u.width,u.height))),s!==void 0&&(u.output=s??$e(u.width,u.height),u.directOutput=!!s),(i||c)&&(s===void 0&&(u.output=$e(u.width,u.height)),u.renderUtils=Cs(u.width,u.height),await Is(r?.canvas??$e(u.width,u.height))),i&&await Ls(r?.segmenterCanvas??$e(u.width,u.height)),u.status=z.Updated,pe({type:"updated"})}catch(i){u.status=z.Error;let c=Cn(i);pe({type:"event",data:{type:Sn(c),message:c}})}};self.addEventListener("message",e=>{switch(e.data.type){case"open":{l1(e.data.data);break}case"update":{f1(e.data.data);break}case"process":{let{videoFrame:t,renderOptions:r}=e.data.data;d1(t,r);break}case"close":{u.status=z.Closing,u.renderer?.release(),u.segmenterTextureToCanvas?.release(),u.videoFrame?.frame.close(),u.segmenter?.close(),u.backgroundImages?.clear(),u.status=z.Closed;break}case"destroy":{u.status=z.Destroying,u.renderer=void 0,u.videoFrame=void 0,u.segmenter=void 0,u.backgroundImages=void 0,u.status=z.Destroyed;break}}});self.addEventListener("error",e=>{e.preventDefault(),pe({type:"event",data:{type:C.Error,message:`Uncaught Error event: ${e.error}`}})});