@pexip/media-processor 17.4.0 → 18.0.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/common/backends/webgl/blender.d.ts +11 -0
  3. package/dist/common/backends/webgl/blender.js +104 -0
  4. package/dist/common/backends/webgl/blur.d.ts +5 -0
  5. package/dist/common/backends/webgl/blur.js +153 -0
  6. package/dist/common/backends/webgl/canvas.d.ts +5 -0
  7. package/dist/common/backends/webgl/canvas.js +77 -0
  8. package/dist/common/backends/webgl/renderer.d.ts +8 -0
  9. package/dist/common/backends/webgl/renderer.js +126 -0
  10. package/dist/common/backends/webgl/shaders/blendFragmentShader.d.ts +1 -0
  11. package/dist/common/backends/webgl/shaders/blendFragmentShader.js +63 -0
  12. package/dist/common/backends/webgl/shaders/dualFilterBlurFragmentShader.d.ts +1 -0
  13. package/dist/common/backends/webgl/shaders/dualFilterBlurFragmentShader.js +45 -0
  14. package/dist/common/backends/webgl/shaders/textureFragmentShader.d.ts +1 -0
  15. package/dist/common/backends/webgl/shaders/textureFragmentShader.js +16 -0
  16. package/dist/common/backends/webgl/shaders/vertexShader.d.ts +1 -0
  17. package/dist/common/backends/webgl/shaders/vertexShader.js +19 -0
  18. package/dist/common/backends/webgl/texture.d.ts +6 -0
  19. package/dist/common/backends/webgl/texture.js +94 -0
  20. package/dist/common/backends/webgl/types.d.ts +5 -0
  21. package/dist/common/backends/webgl/types.js +1 -0
  22. package/dist/common/backends/webgl/webgl.mock.js +8 -0
  23. package/dist/common/backends/webgl/webglUtils.d.ts +80 -0
  24. package/dist/common/backends/webgl/webglUtils.js +194 -0
  25. package/dist/common/canvasRenderUtils.d.ts +62 -0
  26. package/dist/{main/video → common}/canvasRenderUtils.js +100 -61
  27. package/dist/common/constants.d.ts +27 -0
  28. package/dist/common/constants.js +23 -0
  29. package/dist/common/index.d.ts +9 -0
  30. package/dist/common/index.js +9 -0
  31. package/dist/common/m3.d.ts +17 -0
  32. package/dist/common/m3.js +69 -0
  33. package/dist/common/tsconfig.tsbuildinfo +1 -0
  34. package/dist/common/types/media.d.ts +22 -0
  35. package/dist/common/types/media.js +1 -0
  36. package/dist/common/types/messageEvents.d.ts +31 -0
  37. package/dist/common/types/messageEvents.js +1 -0
  38. package/dist/common/types/processor.d.ts +15 -0
  39. package/dist/common/types/processor.js +1 -0
  40. package/dist/common/types/render.d.ts +38 -0
  41. package/dist/common/types/render.js +1 -0
  42. package/dist/common/types/segmentation.d.ts +99 -0
  43. package/dist/common/types/segmentation.js +4 -0
  44. package/dist/common/types/utils.d.ts +19 -0
  45. package/dist/common/types/utils.js +1 -0
  46. package/dist/common/utils.d.ts +35 -0
  47. package/dist/common/utils.js +129 -0
  48. package/dist/main/benchUtils.d.ts +3 -2
  49. package/dist/main/benchUtils.js +7 -6
  50. package/dist/main/index.d.ts +2 -0
  51. package/dist/main/index.js +2 -0
  52. package/dist/main/process.d.ts +1 -11
  53. package/dist/main/process.js +0 -20
  54. package/dist/main/tsconfig.tsbuildinfo +1 -1
  55. package/dist/main/types.d.ts +2 -2
  56. package/dist/main/video/canvasTransform.d.ts +14 -5
  57. package/dist/main/video/canvasTransform.js +101 -86
  58. package/dist/main/video/constants.d.ts +0 -6
  59. package/dist/main/video/constants.js +0 -6
  60. package/dist/main/video/index.d.ts +2 -2
  61. package/dist/main/video/index.js +2 -2
  62. package/dist/main/video/load.d.ts +0 -14
  63. package/dist/main/video/load.js +0 -8
  64. package/dist/main/video/segmenters/mediapipe.d.ts +9 -11
  65. package/dist/main/video/segmenters/mediapipe.js +127 -77
  66. package/dist/main/video/typeGuards.d.ts +0 -1
  67. package/dist/main/video/typeGuards.js +2 -8
  68. package/dist/main/video/types.d.ts +19 -61
  69. package/dist/main/video/types.js +1 -20
  70. package/dist/main/video/utils.d.ts +5 -12
  71. package/dist/main/video/utils.js +5 -152
  72. package/dist/main/video/video.js +1 -0
  73. package/dist/main/video/videoStreamTrackProcessor.js +7 -4
  74. package/dist/workers/global.d.js +0 -0
  75. package/dist/workers/mediaWorker.d.ts +1 -0
  76. package/dist/workers/mediaWorker.js +188 -0
  77. package/dist/workers/tsconfig.tsbuildinfo +1 -1
  78. package/package.json +21 -13
  79. package/dist/main/video/canvasRenderUtils.d.ts +0 -27
  80. package/dist/main/video/segmenters/index.d.ts +0 -1
  81. package/dist/main/video/segmenters/index.js +0 -1
  82. package/dist/workers/index.js +0 -1
  83. /package/dist/{workers/index.d.ts → common/backends/webgl/webgl.mock.d.ts} +0 -0
@@ -0,0 +1,188 @@
1
+ var jn=typeof self<"u"?self:{};function $o(e){e:{for(var t=["CLOSURE_FLAGS"],r=jn,n=0;n<t.length;n++)if((r=r[t[n]])==null){t=null;break e}t=r}return(e=t&&t[e])!=null&&e}function gt(){throw Error("Invalid UTF8")}function Ys(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var gr,hn,m2=typeof TextDecoder<"u",g2,y2=typeof TextEncoder<"u";function qo(e){if(y2)e=(g2||(g2=new TextEncoder)).encode(e);else{let r=0,n=new Uint8Array(3*e.length);for(let s=0;s<e.length;s++){var t=e.charCodeAt(s);if(128>t)n[r++]=t;else{if(2048>t)n[r++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&s<e.length){let o=e.charCodeAt(++s);if(56320<=o&&57343>=o){t=1024*(t-55296)+o-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}s--}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 tr,Jo=$o(610401301),v2=$o(188588736),Ks=jn.navigator;function vn(e){return!!Jo&&!!tr&&tr.brands.some(({brand:t})=>t&&t.indexOf(e)!=-1)}function Ce(e){var t;return(t=jn.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function rt(){return!!Jo&&!!tr&&0<tr.brands.length}function ln(){return rt()?vn("Chromium"):(Ce("Chrome")||Ce("CriOS"))&&!(!rt()&&Ce("Edge"))||Ce("Silk")}tr=Ks&&Ks.userAgentData||null;var _2=!rt()&&(Ce("Trident")||Ce("MSIE"));!Ce("Android")||ln(),ln(),Ce("Safari")&&(ln()||!rt()&&Ce("Coast")||!rt()&&Ce("Opera")||!rt()&&Ce("Edge")||(rt()?vn("Microsoft Edge"):Ce("Edg/"))||rt()&&vn("Opera"));var Zo={},zt=null;function E2(e){var 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);var n=new Uint8Array(r),s=0;return function(o,i){function a(b){for(;c<o.length;){var A=o.charAt(c++),x=zt[A];if(x!=null)return x;if(!/^[\s\xa0]*$/.test(A))throw Error("Unknown base64 encoding at char: "+A)}return b}Qo();for(var c=0;;){var u=a(-1),f=a(0),h=a(64),m=a(64);if(m===64&&u===-1)break;i(u<<2|f>>4),h!=64&&(i(f<<4&240|h>>2),m!=64&&i(h<<6&192|m))}}(e,function(o){n[s++]=o}),s!==r?n.subarray(0,s):n}function Qo(){if(!zt){zt={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=e.concat(t[r].split(""));Zo[r]=n;for(var s=0;s<n.length;s++){var o=n[s];zt[o]===void 0&&(zt[o]=s)}}}}var ei=typeof Uint8Array<"u",ti=!_2&&typeof btoa=="function";function $s(e){if(!ti){var t;t===void 0&&(t=0),Qo(),t=Zo[t];var r=Array(Math.floor(e.length/3)),n=t[64]||"";let c=0,u=0;for(;c<e.length-2;c+=3){var s=e[c],o=e[c+1],i=e[c+2],a=t[s>>2];s=t[(3&s)<<4|o>>4],o=t[(15&o)<<2|i>>6],i=t[63&i],r[u++]=a+s+o+i}switch(a=0,i=n,e.length-c){case 2:i=t[(15&(a=e[c+1]))<<2]||n;case 1:e=e[c],r[u]=t[e>>2]+t[(3&e)<<4|a>>4]+i+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 qs=/[-_.]/g,T2={"-":"+",_:"/",".":"="};function b2(e){return T2[e]||""}function ri(e){if(!ti)return E2(e);qs.test(e)&&(e=e.replace(qs,b2)),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 ir(e){return ei&&e!=null&&e instanceof Uint8Array}var x2;function Gr(){return x2||(x2=new Uint8Array(0))}var St={},A2;function ni(e){if(e!==St)throw Error("illegal external caller")}function bt(){return A2||(A2=new Qe(null,St))}function Xn(e){ni(St);var t=e.g;return(t=t==null||ir(t)?t:typeof t=="string"?ri(t):null)==null?t:e.g=t}var Qe=class{constructor(e,t){if(ni(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}h(){let e=Xn(this);return e?new Uint8Array(e):Gr()}};function si(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function Wn(){return Error("Failed to read varint, encoding is invalid.")}function oi(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function Hn(e){if(typeof e=="string")return{buffer:ri(e),N:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),N:!1};if(e.constructor===Uint8Array)return{buffer:e,N:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),N:!1};if(e.constructor===Qe)return{buffer:Xn(e)||Gr(),N:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),N:!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 zn(){return typeof BigInt=="function"}var w2=typeof Uint8Array.prototype.slice=="function",ii,B=0,ee=0;function _t(e){let t=0>e,r=(e=Math.abs(e))>>>0;if(e=Math.floor((e-r)/4294967296),t){let[n,s]=$n(r,e);e=s,r=n}B=r>>>0,ee=e>>>0}function Yn(e){let t=ii||(ii=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),ee=0,B=t.getUint32(0,!0)}function _n(e,t){return 4294967296*t+(e>>>0)}function Kn(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),e=_n(e,t),r?-e:e}function Cr(e,t){if(e>>>=0,2097151>=(t>>>=0))var r=""+(4294967296*t+e);else zn()?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,1e7<=e&&(r+=Math.floor(e/1e7),e%=1e7),1e7<=r&&(t+=Math.floor(r/1e7),r%=1e7),r=t+Js(r)+Js(e));return r}function Js(e){return e=String(e),"0000000".slice(e.length)+e}function ai(){var e=B,t=ee;if(2147483648&t)if(zn())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,n]=$n(e,t);e="-"+Cr(r,n)}else e=Cr(e,t);return e}function Vr(e){if(16>e.length)_t(Number(e));else if(zn())e=BigInt(e),B=Number(e&BigInt(4294967295))>>>0,ee=Number(e>>BigInt(32)&BigInt(4294967295));else{let t=+(e[0]==="-");ee=B=0;let r=e.length;for(let n=t,s=(r-t)%6+t;s<=r;n=s,s+=6){let o=Number(e.slice(n,s));ee*=1e6,B=1e6*B+o,4294967296<=B&&(ee+=Math.trunc(B/4294967296),ee>>>=0,B>>>=0)}if(t){let[n,s]=$n(B,ee);B=n,ee=s}}}function $n(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function qn(e,t){let r,n=0,s=0,o=0,i=e.h,a=e.g;do r=i[a++],n|=(127&r)<<o,o+=7;while(32>o&&128&r);for(32<o&&(s|=(127&r)>>4),o=3;32>o&&128&r;o+=7)r=i[a++],s|=(127&r)<<o;if(Et(e,a),128>r)return t(n>>>0,s>>>0);throw Wn()}function Jn(e){let t=0,r=e.g,n=r+10,s=e.h;for(;r<n;){let o=s[r++];if(t|=o,(128&o)==0)return Et(e,r),!!(127&t)}throw Wn()}function st(e){let t=e.h,r=e.g,n=t[r++],s=127&n;if(128&n&&(n=t[r++],s|=(127&n)<<7,128&n&&(n=t[r++],s|=(127&n)<<14,128&n&&(n=t[r++],s|=(127&n)<<21,128&n&&(n=t[r++],s|=n<<28,128&n&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw Wn();return Et(e,r),s}function ot(e){return st(e)>>>0}function En(e){var t=e.h;let r=e.g,n=t[r],s=t[r+1],o=t[r+2];return t=t[r+3],Et(e,e.g+4),(n<<0|s<<8|o<<16|t<<24)>>>0}function Tn(e){var t=En(e);e=2*(t>>31)+1;let r=t>>>23&255;return t&=8388607,r==255?t?NaN:1/0*e:r==0?e*Math.pow(2,-149)*t:e*Math.pow(2,r-150)*(t+Math.pow(2,23))}function R2(e){return st(e)}function fn(e,t,{ca:r=!1}={}){e.ca=r,t&&(t=Hn(t),e.h=t.buffer,e.m=t.N,e.j=0,e.l=e.h.length,e.g=e.j)}function Et(e,t){if(e.g=t,t>e.l)throw oi(e.l,t)}function ci(e,t){if(0>t)throw Error(`Tried to read a negative byte length: ${t}`);let r=e.g,n=r+t;if(n>e.l)throw oi(t,e.l-r);return e.g=n,r}function ui(e,t){if(t==0)return bt();var r=ci(e,t);return e.ca&&e.m?r=e.h.subarray(r,r+t):(e=e.h,r=r===(t=r+t)?Gr():w2?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?bt():new Qe(r,St)}var Zs=[];function hi(e){var t=e.g;if(t.g==t.l)return!1;e.l=e.g.g;var r=ot(e.g);if(t=r>>>3,!(0<=(r&=7)&&5>=r))throw si(r,e.l);if(1>t)throw Error(`Invalid field number: ${t} (at position ${e.l})`);return e.m=t,e.h=r,!0}function br(e){switch(e.h){case 0:e.h!=0?br(e):Jn(e.g);break;case 1:Et(e=e.g,e.g+8);break;case 2:if(e.h!=2)br(e);else{var t=ot(e.g);Et(e=e.g,e.g+t)}break;case 5:Et(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!hi(e))throw Error("Unmatched start-group tag: stream EOF");if(e.h==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}br(e)}break;default:throw si(e.h,e.l)}}function ar(e,t,r){let n=e.g.l,s=ot(e.g),o=e.g.g+s,i=o-n;if(0>=i&&(e.g.l=o,r(t,e,void 0,void 0,void 0),i=o-e.g.g),i)throw Error(`Message parsing ended unexpectedly. Expected to read ${s} bytes, instead read ${s-i} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=o,e.g.l=n,t}function Zn(e){var t=ot(e.g),r=ci(e=e.g,t);if(e=e.h,m2){var n,s=e;(n=hn)||(n=hn=new TextDecoder("utf-8",{fatal:!0})),t=r+t,s=r===0&&t===s.length?s:s.subarray(r,t);try{var o=n.decode(s)}catch(a){if(gr===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),gr=!0}catch{gr=!1}}throw!gr&&(hn=void 0),a}}else{t=(o=r)+t,r=[];let a,c=null;for(;o<t;){var i=e[o++];128>i?r.push(i):224>i?o>=t?gt():(a=e[o++],194>i||(192&a)!=128?(o--,gt()):r.push((31&i)<<6|63&a)):240>i?o>=t-1?gt():(a=e[o++],(192&a)!=128||i===224&&160>a||i===237&&160<=a||(192&(n=e[o++]))!=128?(o--,gt()):r.push((15&i)<<12|(63&a)<<6|63&n)):244>=i?o>=t-2?gt():(a=e[o++],(192&a)!=128||a-144+(i<<28)>>30||(192&(n=e[o++]))!=128||(192&(s=e[o++]))!=128?(o--,gt()):(i=(7&i)<<18|(63&a)<<12|(63&n)<<6|63&s,i-=65536,r.push(55296+(i>>10&1023),56320+(1023&i)))):gt(),8192<=r.length&&(c=Ys(c,r),r.length=0)}o=Ys(c,r)}return o}function li(e){let t=ot(e.g);return ui(e.g,t)}function jr(e,t,r){var n=ot(e.g);for(n=e.g.g+n;e.g.g<n;)r.push(t(e.g))}var yr=[];function Qs(e){return e?/^\d+$/.test(e)?(Vr(e),new eo(B,ee)):null:k2||(k2=new eo(0,0))}var eo=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}},k2;function to(e){return e?/^-?\d+$/.test(e)?(Vr(e),new ro(B,ee)):null:S2||(S2=new ro(0,0))}var ro=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}},S2;function Fr(e,t,r){for(;0<r||127<t;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function cr(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function Xr(e,t){if(0<=t)cr(e,t);else{for(let r=0;9>r;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function rr(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 Ct(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function Ie(e,t,r){cr(e.g,8*t+r)}function Qn(e,t){return Ie(e,t,2),t=e.g.end(),Ct(e,t),t.push(e.h),t}function es(e,t){var r=t.pop();for(r=e.h+e.g.length()-r;127<r;)t.push(127&r|128),r>>>=7,e.h++;t.push(r),e.h++}function Wr(e,t,r){Ie(e,t,2),cr(e.g,r.length),Ct(e,e.g.end()),Ct(e,r)}function bn(e,t,r,n){r!=null&&(t=Qn(e,t),n(r,e),es(e,t))}var it=class{constructor(t,r,n,s){this.g=t,this.h=r,this.l=n,this.pa=s}};function be(e){return Array.prototype.slice.call(e)}function fi(e){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol():e}var je=fi(),no=fi("0di"),ts=je?(e,t)=>{e[je]|=t}:(e,t)=>{e.g!==void 0?e.g|=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}})},Lr=je?(e,t)=>{e[je]&=~t}:(e,t)=>{e.g!==void 0&&(e.g&=~t)};function ie(e,t,r){return r?e|t:e&~t}var $=je?e=>0|e[je]:e=>0|e.g,I=je?e=>e[je]:e=>e.g,K=je?(e,t)=>(e[je]=t,e):(e,t)=>(e.g!==void 0?e.g=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}}),e);function Ut(e){return ts(e,34),e}function C2(e,t){K(t,-14591&(0|e))}function xn(e,t){K(t,-14557&(34|e))}function di(e){return(e=e>>14&1023)===0?536870912:e}var rs,ur={},pi={};function so(e){return!(!e||typeof e!="object"||e.Ja!==pi)}function ns(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function ss(e,t,r){if(e!=null){if(typeof e=="string")e=e?new Qe(e,St):bt();else if(e.constructor!==Qe)if(ir(e))e=e.length?new Qe(r?e:new Uint8Array(e),St):bt();else{if(!t)throw Error();e=void 0}}return e}function Mr(e,t,r){if(!Array.isArray(e)||e.length)return!1;let n=$(e);return!!(1&n)||!(!t||!(Array.isArray(t)?t.includes(r):t.has(r)))&&(K(e,1|n),!0)}var oo=[];function ze(e){if(2&e)throw Error()}K(oo,55),rs=Object.freeze(oo);var Ir=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)}},nt,F2;function mi(e,t){(t=nt?t[nt]:void 0)&&(e[nt]=be(t))}function An(e){return(e=Error(e)).__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity="warning",e}function ht(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function gi(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}Object.freeze(new class{}),Object.freeze(new class{});var L2=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Hr(e){let t=typeof e;return t==="number"?Number.isFinite(e):t==="string"&&L2.test(e)}function Bt(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 M2(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 io(e){return e[0]!=="-"&&(20>e.length||e.length===20&&184467>Number(e.substring(0,6)))}function yi(e){return e[0]==="-"?20>e.length||e.length===20&&-922337<Number(e.substring(0,7)):19>e.length||e.length===19&&922337>Number(e.substring(0,6))}function os(e){return e=Math.trunc(e),Number.isSafeInteger(e)||(_t(e),e=Kn(B,ee)),e}function is(e){var t=Math.trunc(Number(e));return Number.isSafeInteger(t)?String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),yi(e)||(Vr(e),e=ai()),e)}function Or(e){return e==null?e:Hr(e)?typeof e=="number"?os(e):is(e):void 0}function hr(e){if(typeof e!="string")throw Error();return e}function Nt(e){if(e!=null&&typeof e!="string")throw Error();return e}function nr(e){return e==null||typeof e=="string"?e:void 0}function as(e,t,r,n){if(e!=null&&typeof e=="object"&&e.X===ur)return e;if(!Array.isArray(e))return r?2&n?(e=t[no])?t=e:(Ut((e=new t).u),t=t[no]=e):t=new t:t=void 0,t;let s=r=$(e);return s===0&&(s|=32&n),s|=2&n,s!==r&&K(e,s),new t(e)}function I2(e,t,r){if(t){var n=!!n;if(!Hr(t=e))throw An("int64");typeof t=="string"?n=is(t):n?(n=Math.trunc(t),Number.isSafeInteger(n)?n=String(n):yi(t=String(n))?n=t:(_t(n),n=ai())):n=os(t)}else n=Or(e);return typeof(r=(e=n)==null?r?0:void 0:e)=="string"&&(n=+r,Number.isSafeInteger(n))?n:r}var Pr,cs,O2;function Dr(e){switch(typeof e){case"boolean":return cs||(cs=[0,void 0,!0]);case"number":return 0<e?void 0:e===0?O2||(O2=[0,void 0]):[-e,void 0];case"string":return[0,e];case"object":return e}}function Tt(e,t){return vi(e,t[0],t[1])}function vi(e,t,r){if(e==null&&(e=Pr),Pr=void 0,e==null){var n=96;r?(e=[r],n|=512):e=[],t&&(n=-16760833&n|(1023&t)<<14)}else{if(!Array.isArray(e)||2048&(n=$(e)))throw Error();if(64&n)return e;if(n|=64,r&&(n|=512,r!==e[0]))throw Error();e:{let s=(r=e).length;if(s){let o=s-1;if(ns(r[o])){if(1024<=(t=o-(+!!(512&(n|=256))-1)))throw Error();n=-16760833&n|(1023&t)<<14;break e}}if(t){if(1024<(t=Math.max(t,s-(+!!(512&n)-1))))throw Error();n=-16760833&n|(1023&t)<<14}}}return K(e,n),e}var P2={},D2=function(){try{return new class extends Map{constructor(){super()}},!1}catch{return!0}}(),Kt=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()}},U2=D2?(Object.setPrototypeOf(Kt.prototype,Map.prototype),Object.defineProperties(Kt.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Kt):class extends Map{constructor(){super()}};function ao(e){return e}function dn(e){if(2&e.L)throw Error("Cannot mutate an immutable Map")}var Le=class extends U2{constructor(e,t,r=ao,n=ao){super();let s=$(e);s|=64,K(e,s),this.L=s,this.U=t,this.S=r,this.Z=this.U?B2:n;for(let o=0;o<e.length;o++){let i=e[o],a=r(i[0],!1,!0),c=i[1];t?c===void 0&&(c=null):c=n(i[1],!1,!0,void 0,void 0,s),super.set(a,c)}}oa(e=co){if(this.size!==0)return this.Y(e)}Y(e=co){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(){dn(this),super.clear()}delete(e){return dn(this),super.delete(this.S(e,!0,!1))}entries(){var e=this.na();return new Ir(e,N2,this)}keys(){return this.Ia()}values(){var e=this.na();return new Ir(e,Le.prototype.get,this)}forEach(e,t){super.forEach((r,n)=>{e.call(t,this.get(n),n,this)})}set(e,t){return dn(this),(e=this.S(e,!0,!1))==null?this:t==null?(super.delete(e),this):super.set(e,this.Z(t,!0,!0,this.U,!1,this.L))}Oa(e){let t=this.S(e[0],!1,!0);e=e[1],e=this.U?e===void 0?null:e:this.Z(e,!1,!0,void 0,!1,this.L),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.U;return r?((r=this.Z(t,!1,!0,r,this.ta,this.L))!==t&&super.set(e,r),r):t}}na(){return Array.from(super.keys())}Ia(){return super.keys()}[Symbol.iterator](){return this.entries()}};function B2(e,t,r,n,s,o){return e=as(e,n,r,o),s&&(e=Yr(e)),e}function co(e){return e}function N2(e){return[e,this.get(e)]}var G2;function uo(){return G2||(G2=new Le(Ut([]),void 0,void 0,void 0,P2))}function us(e,t,r,n,s){if(e!=null){if(Array.isArray(e))e=Mr(e,void 0,0)?void 0:s&&2&$(e)?e:zr(e,t,r,n!==void 0,s);else if(ns(e)){let o={};for(let i in e)o[i]=us(e[i],t,r,n,s);e=o}else e=t(e,n);return e}}function zr(e,t,r,n,s){let o=n||r?$(e):0;n=n?!!(32&o):void 0;let i=be(e);for(let a=0;a<i.length;a++)i[a]=us(i[a],t,r,n,s);return r&&(mi(i,e),r(o,i)),i}function V2(e){return us(e,hs,void 0,void 0,!1)}function hs(e){return e.X===ur?e.toJSON():e instanceof Le?e.oa(V2):function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(Mr(t,void 0,0))return}else{if(ir(t))return $s(t);if(t instanceof Qe){let r=t.g;return r==null?"":typeof r=="string"?r:t.g=$s(r)}if(t instanceof Le)return t.oa()}}return t}(e)}function wn(e,t,r=xn){if(e!=null){if(ei&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var n=$(e);return 2&n?e:(t&&(t=n===0||!!(32&n)&&!(64&n||!(16&n))),t?K(e,-12293&(34|n)):zr(e,wn,4&n?xn:r,!0,!0))}return e.X===ur?(r=e.u,e=2&(n=I(r))?e:ls(e,r,n,!0)):e instanceof Le&&!(2&e.L)&&(r=Ut(e.Y(wn)),e=new Le(r,e.U,e.S,e.Z)),e}}function ls(e,t,r,n){return e=e.constructor,Pr=t=_i(t,r,n),t=new e(t),Pr=void 0,t}function _i(e,t,r){let n=r||2&t?xn:C2,s=!!(32&t);return e=function(o,i,a){let c=be(o);var u=c.length;let f=256&i?c[u-1]:void 0;for(u+=f?-1:0,i=512&i?1:0;i<u;i++)c[i]=a(c[i]);if(f){i=c[i]={};for(let h in f)i[h]=a(f[h])}return mi(c,o),c}(e,t,o=>wn(o,s,n)),ts(e,32|(r?2:0)),e}function Yr(e){let t=e.u,r=I(t);return 2&r?ls(e,t,r,!1):e}function Ft(e,t){return Ye(e=e.u,I(e),t)}function Ye(e,t,r,n){if(r===-1)return null;if(r>=di(t)){if(256&t)return e[e.length-1][r]}else{var s=e.length;if(n&&256&t&&(n=e[s-1][r])!=null)return n;if((t=r+(+!!(512&t)-1))<s)return e[t]}}function D(e,t,r,n){let s=e.u,o=I(s);return ze(o),N(s,o,t,r,n),e}function N(e,t,r,n,s){let o=di(t);if(r>=o||s){let i=t;if(256&t)s=e[e.length-1];else{if(n==null)return i;s=e[o+(+!!(512&t)-1)]={},i|=256}return s[r]=n,r<o&&(e[r+(+!!(512&t)-1)]=void 0),i!==t&&K(e,i),i}return e[r+(+!!(512&t)-1)]=n,256&t&&r in(e=e[e.length-1])&&delete e[r],t}function Gt(e,t,r,n,s){var o=2&t;let i=Ye(e,t,r,s);Array.isArray(i)||(i=rs);let a=!(2&n);n=!(1&n);let c=!!(32&t),u=$(i);return u!==0||!c||o||a?1&u||(u|=1,K(i,u)):(u|=33,K(i,u)),o?(e=!1,2&u||(Ut(i),e=!!(4&u)),(n||e)&&Object.freeze(i)):(o=!!(2&u)||!!(2048&u),n&&o?(i=be(i),n=1,c&&!a&&(n|=32),K(i,n),N(e,t,r,i,s)):a&&32&u&&!o&&Lr(i,32)),i}function xr(e,t){e=e.u;let r=I(e),n=Ye(e,r,t),s=ht(n);return s!=null&&s!==n&&N(e,r,t,s),s}function Ei(e){e=e.u;let t=I(e),r=Ye(e,t,1),n=ss(r,!0,!!(34&t));return n!=null&&n!==r&&N(e,t,1,n),n}function Rt(e,t,r){e=e.u;let n=I(e),s=2&n?1:2,o=Ti(e,n,t);var i=$(o);if(!(4&i)){(4&i||Object.isFrozen(o))&&(o=be(o),i=xt(i,n,!1),n=N(e,n,t,o));var a=0;let c=0;for(;a<o.length;a++){let u=r(o[a]);u!=null&&(o[c++]=u)}c<a&&(o.length=c),i=ie(i=bi(i,n,!1),20,!0),i=ie(i,4096,!1),i=ie(i,8192,!1),K(o,i),2&i&&Object.freeze(o)}return $t(i)||(r=i,(i=(a=s===1)?ie(i,2,!0):ie(i,32,!1))!==r&&K(o,i),a&&Object.freeze(o)),s===2&&$t(i)&&(o=be(o),i=xt(i,n,!1),K(o,i),N(e,n,t,o)),o}function Ti(e,t,r){return e=Ye(e,t,r),Array.isArray(e)?e:rs}function bi(e,t,r){return e===0&&(e=xt(e,t,r)),ie(e,1,!0)}function $t(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function xi(e){e=be(e);for(let t=0;t<e.length;t++){let r=e[t]=be(e[t]);Array.isArray(r[1])&&(r[1]=Ut(r[1]))}return e}function Ur(e,t,r){{let i=e.u,a=I(i);if(ze(a),r==null)N(i,a,t);else{var n,s=e=$(r),o=!!(2&e)||Object.isFrozen(r);if((n=!o)&&(n=!1),!(4&e))for(e=21,o&&(r=be(r),s=0,e=xt(e,a,!0)),o=0;o<r.length;o++)r[o]=hr(r[o]);n&&(r=be(r),s=0,e=xt(e,a,!0)),e!==s&&K(r,e),N(i,a,t,r)}}}function Rn(e,t,r,n){e=e.u;let s=I(e);ze(s),N(e,s,t,(n==="0"?Number(r)===0:r===n)?void 0:r)}function lr(e,t,r,n){let s=I(e);ze(s),e=Gt(e,s,t,2),n=r(n,!!(4&(t=$(e)))&&!!(4096&t)),e.push(n)}function j2(e){return e}function pn(e,t){return fs(e=e.u,I(e),aa)===t?t:-1}function fs(e,t,r){let n=0;for(let s=0;s<r.length;s++){let o=r[s];Ye(e,t,o)!=null&&(n!==0&&(t=N(e,t,n)),n=o)}return n}function ds(e,t,r,n){let s=I(e);ze(s);let o=Ye(e,s,r,n),i;if(o!=null&&o.X===ur)return(t=Yr(o))!==o&&N(e,s,r,t,n),t.u;if(Array.isArray(o)){let a=$(o);i=2&a?_i(o,a,!1):o,i=Tt(i,t)}else i=Tt(void 0,t);return i!==o&&N(e,s,r,i,n),i}function Ai(e,t,r,n){e=e.u;let s=I(e),o=Ye(e,s,r,n);return(t=as(o,t,!1,s))!==o&&t!=null&&N(e,s,r,t,n),t}function C(e,t,r,n=!1){if((t=Ai(e,t,r,n))==null)return t;e=e.u;let s=I(e);if(!(2&s)){let o=Yr(t);o!==t&&N(e,s,r,t=o,n)}return t}function wi(e,t,r,n,s,o){var i=!!(2&t),a=i?1:2;let c=a===1;a=a===2,s=!!s,o&&(o=!i),i=Ti(e,t,n);var u=$(i);let f=!!(4&u);if(!f){var h=i,m=t;let b=!!(2&(u=bi(u,t,s)));b&&(m=ie(m,2,!0));let A=!b,x=!0,O=0,d=0;for(;O<h.length;O++){let l=as(h[O],r,!1,m);if(l instanceof r){if(!b){let g=!!(2&$(l.u));A&&(A=!g),x&&(x=g)}h[d++]=l}}d<O&&(h.length=d),u=ie(u,4,!0),u=ie(u,16,x),u=ie(u,8,A),K(h,u),b&&Object.freeze(h)}if(r=!!(8&u)||c&&!i.length,o&&!r){for($t(u)&&(i=be(i),u=xt(u,t,s),t=N(e,t,n,i)),o=i,r=u,h=0;h<o.length;h++)(u=o[h])!==(m=Yr(u))&&(o[h]=m);r=ie(r,8,!0),r=ie(r,16,!o.length),K(o,r),u=r}return $t(u)||(o=u,c?u=ie(u,!i.length||16&u&&(!f||32&u)?2:2048,!0):s||(u=ie(u,32,!1)),u!==o&&K(i,u),c&&Object.freeze(i)),a&&$t(u)&&(i=be(i),u=xt(u,t,s),K(i,u),N(e,t,n,i)),i}function tt(e,t,r){e=e.u;let n=I(e);return wi(e,n,t,r,!1,!(2&n))}function _(e,t,r,n,s){return n==null&&(n=void 0),D(e,r,n,s)}function qt(e,t,r,n){n==null&&(n=void 0),e=e.u;let s=I(e);ze(s),(r=fs(e,s,r))&&r!==t&&n!=null&&(s=N(e,s,r)),N(e,s,t,n)}function xt(e,t,r){return e=ie(e,2,!!(2&t)),e=ie(e,32,!!(32&t)&&r),ie(e,2048,!1)}function Br(e,t,r,n){e=e.u;let s=I(e);ze(s),t=wi(e,s,r,t,!0),r=n??new r,t.push(r),2&$(r.u)?Lr(t,8):Lr(t,16)}function Fe(e,t){return Bt(Ft(e,t))}function Me(e,t){return nr(Ft(e,t))}function Xe(e){return e??0}function J(e,t){return Xe(xr(e,t))}function sr(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}`);D(e,t,r)}function We(e,t,r){if(r!=null){if(typeof r!="number"||!Number.isFinite(r))throw An("int32");r|=0}D(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}`);D(e,t,r)}function De(e,t,r){t.g?t.m(e,t.g,t.h,r,!0):t.m(e,t.h,r,!0)}Le.prototype.toJSON=void 0,Le.prototype.Ja=pi;var y=class{constructor(e,t){this.u=vi(e,t)}toJSON(){return Ri(this,zr(this.u,hs,void 0,void 0,!1),!0)}l(){var e=Y1;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 ls(this,e,I(e),!1)}N(){return!!(2&$(this.u))}};function Ri(e,t,r){var n=v2?void 0:e.constructor.A;let s=I(r?e.u:t);if(!(e=t.length))return t;let o,i;if(ns(r=t[e-1])){e:{var a=r;let f={},h=!1;for(var c in a){let m=a[c];if(Array.isArray(m)){let b=m;(Mr(m,n,+c)||so(m)&&m.size===0)&&(m=null),m!=b&&(h=!0)}m!=null?f[c]=m:h=!0}if(h){for(var u in f){a=f;break e}a=null}}a!=r&&(o=!0),e--}for(c=+!!(512&s)-1;0<e&&(r=t[u=e-1],u-=c,r==null||Mr(r,n,u)||so(r)&&r.size===0);e--)i=!0;return(o||i)&&(t=Array.prototype.slice.call(t,0,e),a&&t.push(a)),t}function ki(e){return Array.isArray(e)?e[0]instanceof it?e:[Q2,e]:[e,void 0]}function Vt(e,t){if(Array.isArray(t)){var r=$(t);if(4&r)return t;for(var n=0,s=0;n<t.length;n++){let o=e(t[n]);o!=null&&(t[s++]=o)}return s<n&&(t.length=s),K(t,-12289&(5|r)),2&r&&Object.freeze(t),t}}y.prototype.X=ur,y.prototype.toString=function(){return Ri(this,this.u,!1).toString()};var ho=Symbol();function ps(e){let t=e[ho];if(!t){let r=Ci(e),n=gs(e),s=n.l;t=s?(o,i)=>s(o,i,n):(o,i)=>{for(;hi(i)&&i.h!=4;){var a=i.m,c=n[a];if(!c){var u=n.ea;u&&(u=u[a])&&(c=n[a]=X2(u))}c&&c(i,o,a)||(a=(c=i).l,br(c),c.ia?c=void 0:(u=c.g.g-a,c.g.g=a,c=ui(c.g,u)),a=o,c&&(nt||(nt=Symbol()),(u=a[nt])?u.push(c):a[nt]=[c]))}r===Si||r===Ar||r.j||(o[F2||(F2=Symbol())]=r)},e[ho]=t}return t}function X2(e){let t=(e=ki(e))[0].g;if(e=e[1]){let r=ps(e),n=gs(e).T;return(s,o,i)=>t(s,o,i,n,r)}return t}var Jt=class{},Si,Ar,Zt=Symbol();function W2(e,t,r){let n=r[1],s;if(n){let o=n[Zt];s=o?o.T:Dr(n[0]),e[t]=o??n}s&&s===cs?(e.g||(e.g=new Set)).add(t):r[0]&&(e.h||(e.h=new Set)).add(t)}function lo(e,t){return[e.l,!t||0<t[0]?void 0:t]}function Ci(e){var t=e[Zt];if(t)return t;if(!(t=ms(e,e[Zt]=new Jt,lo,lo,W2)).ea&&!t.h&&!t.g){let r=!0;for(let n in t)isNaN(n)||(r=!1);r?(Dr(e[0])===cs?Ar?t=Ar:((t=new Jt).T=Dr(!0),t=Ar=t):t=Si||(Si=new Jt),t=e[Zt]=t):t.j=!0}return t}function H2(e,t,r){e[t]=r}function ms(e,t,r,n,s=H2){t.T=Dr(e[0]);let o=0;var i=e[++o];i&&i.constructor===Object&&(t.ea=i,typeof(i=e[++o])=="function"&&(t.l=i,t.m=e[++o],i=e[++o]));let a={};for(;Array.isArray(i)&&typeof i[0]=="number"&&0<i[0];){for(var c=0;c<i.length;c++)a[i[c]]=i;i=e[++o]}for(c=1;i!==void 0;){let h;typeof i=="number"&&(c+=i,i=e[++o]);var u=void 0;if(i instanceof it?h=i:(h=e1,o--),h.pa){i=e[++o],u=e;var f=o;typeof i=="function"&&(i=i(),u[f]=i),u=i}for(f=c+1,typeof(i=e[++o])=="number"&&0>i&&(f-=i,i=e[++o]);c<f;c++){let m=a[c];s(t,c,u?n(h,u,m):r(h,m))}}return t}var fo=Symbol();function Fi(e){let t=e[fo];if(!t){let r=Kr(e);t=(n,s)=>Mi(n,s,r),e[fo]=t}return t}var kn=Symbol();function z2(e){return e.h}function Y2(e,t){let r,n,s=e.h;return(o,i,a)=>s(o,i,a,n||(n=Kr(t).T),r||(r=Fi(t)))}function Kr(e){let t=e[kn];return t||(t=ms(e,e[kn]={},z2,Y2),Li(e),t)}var Sn=Symbol();function K2(e,t){let r=e.g;return t?(n,s,o)=>r(n,s,o,t):r}function $2(e,t,r){let n=e.g,s,o;return(i,a,c)=>n(i,a,c,o||(o=gs(t).T),s||(s=ps(t)),r)}function gs(e){let t=e[Sn];return t||(Ci(e),t=ms(e,e[Sn]={},K2,$2),Li(e),t)}function Li(e){Sn in e&&Zt in e&&kn in e&&(e.length=0)}function po(e,t){var r=e[t];if(r)return r;if((r=e.ea)&&(r=r[t])){var n=(r=ki(r))[0].h;if(r=r[1]){let s=Fi(r),o=Kr(r).T;r=(r=e.m)?r(o,s):(i,a,c)=>n(i,a,c,o,s)}else r=n;return e[t]=r}}function Mi(e,t,r){for(var n=I(e),s=+!!(512&n)-1,o=e.length,i=512&n?1:0,a=o+(256&n?-1:0);i<a;i++){let c=e[i];if(c==null)continue;let u=i-s,f=po(r,u);f&&f(t,c,u)}if(256&n){n=e[o-1];for(let c in n)s=+c,Number.isNaN(s)||(o=n[c])!=null&&(a=po(r,s))&&a(t,o,s)}if(e=nt?e[nt]:void 0)for(Ct(t,t.g.end()),r=0;r<e.length;r++)Ct(t,Xn(e[r])||Gr())}function me(e,t){return new it(e,t,!1,!1)}function jt(e,t){return new it(e,t,!0,!1)}function $r(e,t){return new it(e,t,!1,!0)}function ge(e,t,r){N(e,I(e),t,r)}var q2=$r(function(e,t,r,n,s){return e.h===2&&(e=ar(e,Tt([void 0,void 0],n),s),ze(n=I(t)),(s=Ye(t,n,r))instanceof Le?2&s.L?((s=s.Y()).push(e),N(t,n,r,s)):s.Oa(e):Array.isArray(s)?(2&$(s)&&N(t,n,r,s=xi(s)),s.push(e)):N(t,n,r,[e]),!0)},function(e,t,r,n,s){if(t instanceof Le)t.forEach((o,i)=>{bn(e,r,Tt([i,o],n),s)});else if(Array.isArray(t))for(let o=0;o<t.length;o++){let i=t[o];Array.isArray(i)&&bn(e,r,Tt(i,n),s)}});function Ii(e,t,r){e:if(t!=null){if(Hr(t)){if(typeof t=="string"){t=is(t);break e}if(typeof t=="number"){t=os(t);break e}}t=void 0}t!=null&&(typeof t=="string"&&to(t),t!=null&&(Ie(e,r,0),typeof t=="number"?(e=e.g,_t(t),Fr(e,B,ee)):(r=to(t),Fr(e.g,r.h,r.g))))}function Oi(e,t,r){(t=Bt(t))!=null&&t!=null&&(Ie(e,r,0),Xr(e.g,t))}function Pi(e,t,r){(t=gi(t))!=null&&(Ie(e,r,0),e.g.g.push(t?1:0))}function Di(e,t,r){(t=nr(t))!=null&&Wr(e,r,qo(t))}function qr(e,t,r,n,s){bn(e,r,t instanceof y?t.u:Array.isArray(t)?Tt(t,n):void 0,s)}function Ui(e,t,r){(t=t==null||typeof t=="string"||ir(t)||t instanceof Qe?t:void 0)!=null&&Wr(e,r,Hn(t).buffer)}function Bi(e,t,r){return(e.h===5||e.h===2)&&(t=Gt(t,I(t),r,2,!1),e.h==2?jr(e,Tn,t):t.push(Tn(e.g)),!0)}var ne,et=me(function(e,t,r){if(e.h!==1)return!1;var n=e.g;e=En(n);let s=En(n);n=2*(s>>31)+1;let o=s>>>20&2047;return e=4294967296*(1048575&s)+e,ge(t,r,o==2047?e?NaN:1/0*n:o==0?n*Math.pow(2,-1074)*e:n*Math.pow(2,o-1075)*(e+4503599627370496)),!0},function(e,t,r){(t=ht(t))!=null&&(Ie(e,r,1),e=e.g,(r=ii||(ii=new DataView(new ArrayBuffer(8)))).setFloat64(0,+t,!0),B=r.getUint32(0,!0),ee=r.getUint32(4,!0),rr(e,B),rr(e,ee))}),se=me(function(e,t,r){return e.h===5&&(ge(t,r,Tn(e.g)),!0)},function(e,t,r){(t=ht(t))!=null&&(Ie(e,r,5),e=e.g,Yn(t),rr(e,B))}),J2=jt(Bi,function(e,t,r){if((t=Vt(ht,t))!=null)for(let i=0;i<t.length;i++){var n=e,s=r,o=t[i];o!=null&&(Ie(n,s,5),n=n.g,Yn(o),rr(n,B))}}),ys=jt(Bi,function(e,t,r){if((t=Vt(ht,t))!=null&&t.length){Ie(e,r,2),cr(e.g,4*t.length);for(let n=0;n<t.length;n++)r=e.g,Yn(t[n]),rr(r,B)}}),at=me(function(e,t,r){return e.h===0&&(ge(t,r,qn(e.g,Kn)),!0)},Ii),mn=me(function(e,t,r){return e.h===0&&(ge(t,r,(e=qn(e.g,Kn))===0?void 0:e),!0)},Ii),Z2=me(function(e,t,r){return e.h===0&&(ge(t,r,qn(e.g,_n)),!0)},function(e,t,r){e:if(t!=null){if(Hr(t)){if(typeof t=="string"){var n=Math.trunc(Number(t));Number.isSafeInteger(n)&&0<=n?t=String(n):((n=t.indexOf("."))!==-1&&(t=t.substring(0,n)),io(t)||(Vr(t),t=Cr(B,ee)));break e}if(typeof t=="number"){t=0<=(t=Math.trunc(t))&&Number.isSafeInteger(t)?t:function(s){if(0>s){_t(s);let o=Cr(B,ee);return s=Number(o),Number.isSafeInteger(s)?s:o}return io(String(s))?s:(_t(s),_n(B,ee))}(t);break e}}t=void 0}t!=null&&(typeof t=="string"&&Qs(t),t!=null&&(Ie(e,r,0),typeof t=="number"?(e=e.g,_t(t),Fr(e,B,ee)):(r=Qs(t),Fr(e.g,r.h,r.g))))}),q=me(function(e,t,r){return e.h===0&&(ge(t,r,st(e.g)),!0)},Oi),vs=jt(function(e,t,r){return(e.h===0||e.h===2)&&(t=Gt(t,I(t),r,2,!1),e.h==2?jr(e,st,t):t.push(st(e.g)),!0)},function(e,t,r){if((t=Vt(Bt,t))!=null&&t.length){r=Qn(e,r);for(let n=0;n<t.length;n++)Xr(e.g,t[n]);es(e,r)}}),Lt=me(function(e,t,r){return e.h===0&&(ge(t,r,(e=st(e.g))===0?void 0:e),!0)},Oi),te=me(function(e,t,r){return e.h===0&&(ge(t,r,Jn(e.g)),!0)},Pi),Qt=me(function(e,t,r){return e.h===0&&(ge(t,r,(e=Jn(e.g))===!1?void 0:e),!0)},Pi),ue=jt(function(e,t,r){return e.h===2&&(lr(t,r,j2,e=Zn(e)),!0)},function(e,t,r){if((t=Vt(nr,t))!=null)for(let i=0;i<t.length;i++){var n=e,s=r,o=t[i];o!=null&&Wr(n,s,qo(o))}}),ct=me(function(e,t,r){return e.h===2&&(ge(t,r,(e=Zn(e))===""?void 0:e),!0)},Di),V=me(function(e,t,r){return e.h===2&&(ge(t,r,Zn(e)),!0)},Di),Q2=$r(function(e,t,r,n,s){return e.h===2&&(ar(e,ds(t,n,r,!0),s),!0)},qr),e1=$r(function(e,t,r,n,s){return e.h===2&&(ar(e,ds(t,n,r),s),!0)},qr);ne=new it(function(e,t,r,n,s){if(e.h!==2)return!1;n=Tt(void 0,n);let o=I(t);ze(o);let i=Gt(t,o,r,3);return o=I(t),4&$(i)&&(i=be(i),K(i,-2079&(1|$(i))),N(t,o,r,i)),i.push(n),ar(e,n,s),!0},function(e,t,r,n,s){if(Array.isArray(t))for(let o=0;o<t.length;o++)qr(e,t[o],r,n,s)},!0,!0);var W=$r(function(e,t,r,n,s,o){if(e.h!==2)return!1;let i=I(t);return ze(i),(o=fs(t,i,o))&&r!==o&&N(t,i,o),ar(e,t=ds(t,n,r),s),!0},qr),Ni=me(function(e,t,r){return e.h===2&&(ge(t,r,li(e)),!0)},Ui),t1=jt(function(e,t,r){return(e.h===0||e.h===2)&&(t=Gt(t,I(t),r,2,!1),e.h==2?jr(e,ot,t):t.push(ot(e.g)),!0)},function(e,t,r){if((t=Vt(M2,t))!=null)for(let i=0;i<t.length;i++){var n=e,s=r,o=t[i];o!=null&&(Ie(n,s,0),cr(n.g,o))}}),He=me(function(e,t,r){return e.h===0&&(ge(t,r,st(e.g)),!0)},function(e,t,r){(t=Bt(t))!=null&&(t=parseInt(t,10),Ie(e,r,0),Xr(e.g,t))}),r1=jt(function(e,t,r){return(e.h===0||e.h===2)&&(t=Gt(t,I(t),r,2,!1),e.h==2?jr(e,R2,t):t.push(st(e.g)),!0)},function(e,t,r){if((t=Vt(Bt,t))!=null&&t.length){r=Qn(e,r);for(let n=0;n<t.length;n++)Xr(e.g,t[n]);es(e,r)}}),Cn=class{constructor(t,r){this.h=t,this.g=r,this.l=C,this.m=_,this.defaultValue=void 0}};function Ue(e,t){return new Cn(e,t)}function lt(e,t){return(r,n)=>{e:{if(yr.length){let o=yr.pop();o.o(n),fn(o.g,r,n),r=o}else r=new class{constructor(o,i){if(Zs.length){let a=Zs.pop();fn(a,o,i),o=a}else o=new class{constructor(a,c){this.h=null,this.m=!1,this.g=this.l=this.j=0,fn(this,a,c)}clear(){this.h=null,this.m=!1,this.g=this.l=this.j=0,this.ca=!1}}(o,i);this.g=o,this.l=this.g.g,this.h=this.m=-1,this.o(i)}o({ia:o=!1}={}){this.ia=o}}(r,n);try{let o=new e,i=o.u;ps(t)(i,r);var s=o;break e}finally{r.g.clear(),r.m=-1,r.h=-1,100>yr.length&&yr.push(r)}s=void 0}return s}}function Jr(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 i=this.g;return this.g=[],i}}}};Mi(this.u,t,Kr(e)),Ct(t,t.g.end());let r=new Uint8Array(t.h),n=t.l,s=n.length,o=0;for(let i=0;i<s;i++){let a=n[i];r.set(a,o),o+=a.length}return t.l=[r],r}}var mo=class extends y{constructor(e){super(e)}},Gi=[0,ct,me(function(e,t,r){return e.h===2&&(ge(t,r,(e=li(e))===bt()?void 0:e),!0)},function(e,t,r){if(t!=null){if(t instanceof y){let n=t.Qa;return void(n&&(t=n(t),t!=null&&Wr(e,r,Hn(t).buffer)))}if(Array.isArray(t))return}Ui(e,t,r)})],n1=[0,V],Vi=[0,q,He,te,-1,vs,He,-1],s1=[0,te,-1],ji=class extends y{constructor(){super()}};ji.A=[6];var Xi=[0,te,V,te,He,-1,r1,V,-1,s1,He],Wi=[0,V,-2],go=class extends y{constructor(){super()}},Hi=[0],zi=[0,q,te,-3],xe=class extends y{constructor(e){super(e,2)}},H={},o1=[-2,H,te];H[336783863]=[0,V,te,-1,q,[0,[1,2,3,4,5],W,Hi,W,Xi,W,Wi,W,zi,W,Vi],n1];var i1=[0,ct,Qt],Yi=[0,mn,-1,Qt,-3,mn,vs,ct,Lt,mn,-1,Qt,Lt,Qt,-2,ct],fr=[-1,{}],Ki=[0,V,1,fr],$i=[0,V,ue,fr];function Ae(e,t){Rn(e,2,Nt(t),"")}function U(e,t){lr(e.u,3,hr,t)}function k(e,t){lr(e.u,4,hr,t)}var ce=class extends y{constructor(e){super(e,500)}o(e){return _(this,0,7,e)}};ce.A=[3,4,5,6,8,13,17,1005];var a1=[-500,ct,-1,ue,-3,o1,ne,Gi,Lt,-1,Ki,$i,ne,i1,ct,Yi,Lt,ue,987,ue],c1=[0,ct,-1,fr],u1=[-500,V,-1,[-1,{}],998,V],h1=[-500,V,ue,-1,[-2,{},te],997,ue,-1],l1=[-500,V,ue,fr,998,ue];function we(e,t){Br(e,1,ce,t)}function G(e,t){lr(e.u,10,hr,t)}function L(e,t){lr(e.u,15,hr,t)}var le=class extends y{constructor(e){super(e,500)}o(e){return _(this,0,1001,e)}};le.A=[1,6,7,9,10,15,16,17,14,1002];var qi=[-500,ne,a1,4,ne,u1,ne,h1,Lt,ne,l1,ue,Lt,Ki,$i,ne,c1,ue,-2,Yi,ct,-1,Qt,979,fr,ne,Gi],f1=lt(le,qi);le.prototype.g=Jr(qi);var d1=[0,ne,[0,q,-2]],p1=class extends y{constructor(e){super(e)}},m1=[0,q,se,V,-1],_s=class extends y{constructor(e){super(e)}g(){return tt(this,p1,1)}};_s.A=[1];var Ji=[0,ne,m1],Zr=lt(_s,Ji),g1=[0,q,se],y1=[0,q,-1,d1],v1=class extends y{constructor(e){super(e)}},_1=[0,q,-3],E1=[0,se,-3],T1=class extends y{constructor(e){super(e)}},b1=[0,se,-1,V,se],wr=class extends y{constructor(e){super(e)}h(){return C(this,v1,2)}g(){return tt(this,T1,5)}};wr.A=[5];var x1=[0,He,_1,E1,y1,ne,b1],Zi=class extends y{constructor(e){super(e)}};Zi.A=[1,2,3,8,9];var Qi=lt(Zi,[0,ue,vs,ys,x1,V,-1,at,ne,g1,ue,at]),ea=class extends y{constructor(e){super(e)}},A1=[0,se,-4],ta=class extends y{constructor(e){super(e)}};ta.A=[1];var kt=lt(ta,[0,ne,A1]),ra=class extends y{constructor(e){super(e)}},w1=[0,se,-4],na=class extends y{constructor(e){super(e)}};na.A=[1];var dr=lt(na,[0,ne,w1]),sa=class extends y{constructor(e){super(e)}};sa.A=[3];var R1=[0,q,-1,ys,He],oa=class extends y{constructor(){super()}};oa.prototype.g=Jr([0,se,-4,at]);var k1=class extends y{constructor(e){super(e)}},S1=[0,1,q,V,Ji],ia=class extends y{constructor(e){super(e)}};ia.A=[1];var C1=lt(ia,[0,ne,S1,at]),Fn=class extends y{constructor(e){super(e)}};Fn.A=[1];var F1=class extends y{constructor(e){super(e)}qa(){let e=Ei(this);return e??bt()}},L1=class extends y{constructor(e){super(e)}},aa=[1,2],M1=[0,aa,W,[0,ys],W,[0,Ni],q,V],ca=class extends y{constructor(e){super(e)}};ca.A=[1];var I1=lt(ca,[0,ne,M1,at]),Qr=class extends y{constructor(e){super(e)}};Qr.A=[4,5];var ua=[0,V,q,se,ue,-1],yo=class extends y{constructor(e){super(e)}},O1=[0,te,-1],vo=class extends y{constructor(e){super(e)}},Rr=[1,2,3,4,5],Nr=class extends y{constructor(e){super(e)}g(){return Ei(this)!=null}h(){return Me(this,2)!=null}},ha=[0,Ni,V,[0,q,at,-1],[0,Z2,at]],z=class extends y{constructor(e){super(e)}g(){return gi(Ft(this,2))??!1}},Z=[0,ha,te,[0,Rr,W,zi,W,Xi,W,Vi,W,Hi,W,Wi],He],en=class extends y{constructor(e){super(e)}},Es=[0,Z,se,-1,q],P1=Ue(502141897,en);H[502141897]=Es;var la=[0,ha];H[512499200]=la;var fa=[0,la];H[515723506]=fa;var D1=lt(class extends y{constructor(e){super(e)}},[0,[0,He,-1,J2,t1],R1]),da=[0,Z];H[508981768]=da;var pa=class extends y{constructor(e){super(e)}},Ts=[0,Z,se,da,te],ma=class extends y{constructor(e){super(e)}},ga=[0,Z,Es,Ts,se,fa];H[508968149]=Ts;var U1=Ue(508968150,ma);H[508968150]=ga;var ya=class extends y{constructor(e){super(e)}},B1=Ue(513916220,ya);H[513916220]=[0,Z,ga,q];var wt=class extends y{constructor(e){super(e)}h(){return C(this,Qr,2)}g(){D(this,2)}},va=[0,Z,ua];H[478825465]=va;var _a=[0,Z];H[478825422]=_a;var N1=class extends y{constructor(e){super(e)}},Ea=[0,Z,_a,va,-1],Ta=class extends y{constructor(e){super(e)}},ba=[0,Z,se,q],bs=class extends y{constructor(e){super(e)}},xs=[0,Z,se],As=class extends y{constructor(e){super(e)}},xa=[0,Z,ba,xs,se],Aa=class extends y{constructor(e){super(e)}},G1=[0,Z,xa,Ea];H[463370452]=Ea,H[464864288]=ba,H[474472470]=xs;var V1=Ue(462713202,As);H[462713202]=xa;var j1=Ue(479097054,Aa);H[479097054]=G1;var X1=class extends y{constructor(e){super(e)}},W1=[0,Z],wa=class extends y{constructor(e){super(e)}},ws=[0,Z,se,-1,q];H[514774813]=ws;var Ra=class extends y{constructor(e){super(e)}},Rs=[0,Z,se,te];H[518928384]=Rs;var ka=class extends y{constructor(){super()}};ka.prototype.g=Jr([0,Z,xs,W1,Es,Ts,ws,Rs]);var Sa=class extends y{constructor(e){super(e)}},H1=Ue(456383383,Sa);H[456383383]=[0,Z,ua];var Ca=class extends y{constructor(e){super(e)}},z1=Ue(476348187,Ca);H[476348187]=[0,Z,O1];var Fa=class extends y{constructor(e){super(e)}},La=[0,He,-1],Ln=class extends y{constructor(e){super(e)}};Ln.A=[3];var Y1=Ue(458105876,class extends y{constructor(e){super(e)}g(){var e=this.u;let t=I(e);var r=2&t;return e=function(n,s,o){var i=Ln;let a=2&s,c=!1;if(o==null){if(a)return uo();o=[]}else if(o.constructor===Le){if(!(2&o.L)||a)return o;o=o.Y()}else Array.isArray(o)?c=!!(2&$(o)):o=[];if(a){if(!o.length)return uo();c||(c=!0,Ut(o))}else c&&(c=!1,o=xi(o));return c||(64&$(o)?Lr(o,32):32&s&&ts(o,32)),N(n,s,2,i=new Le(o,i,I2,void 0),!1),i}(e,t,Ye(e,t,2)),e==null||!r&&Ln&&(e.ta=!0),r=e}});H[458105876]=[0,La,q2,[!0,at,[0,V,-1,ue]]];var ks=class extends y{constructor(e){super(e)}},Ma=Ue(458105758,ks);H[458105758]=[0,Z,V,La];var Ss=class extends y{constructor(e){super(e)}};Ss.A=[5,6];var K1=Ue(443442058,Ss);H[443442058]=[0,Z,V,q,se,ue,-1];var Ia=class extends y{constructor(e){super(e)}},$1=Ue(516587230,Ia);function Mn(e,t){return t=t?t.clone():new Qr,e.displayNamesLocale!==void 0?D(t,1,Nt(e.displayNamesLocale)):e.displayNamesLocale===void 0&&D(t,1),e.maxResults!==void 0?We(t,2,e.maxResults):"maxResults"in e&&D(t,2),e.scoreThreshold!==void 0?v(t,3,e.scoreThreshold):"scoreThreshold"in e&&D(t,3),e.categoryAllowlist!==void 0?Ur(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&D(t,4),e.categoryDenylist!==void 0?Ur(t,5,e.categoryDenylist):"categoryDenylist"in e&&D(t,5),t}function Cs(e,t=-1,r=""){return{categories:e.map(n=>({index:Xe(Fe(n,1))??-1,score:J(n,2)??0,categoryName:Me(n,3)??""??"",displayName:Me(n,4)??""??""})),headIndex:t,headName:r}}function Oa(e){var t=Rt(e,3,ht),r=Rt(e,2,Bt),n=Rt(e,1,nr),s=Rt(e,9,nr);let o={categories:[],keypoints:[]};for(let i=0;i<t.length;i++)o.categories.push({score:t[i],index:r[i]??-1,categoryName:n[i]??"",displayName:s[i]??""});if((t=C(e,wr,4)?.h())&&(o.boundingBox={originX:Fe(t,1)??0,originY:Fe(t,2)??0,width:Fe(t,3)??0,height:Fe(t,4)??0,angle:0}),C(e,wr,4)?.g().length)for(let i of C(e,wr,4).g())o.keypoints.push({x:xr(i,1)??0,y:xr(i,2)??0,score:xr(i,4)??0,label:Me(i,3)??""});return o}function tn(e){let t=[];for(let r of tt(e,ra,1))t.push({x:J(r,1)??0,y:J(r,2)??0,z:J(r,3)??0,visibility:J(r,4)??0});return t}function er(e){let t=[];for(let r of tt(e,ea,1))t.push({x:J(r,1)??0,y:J(r,2)??0,z:J(r,3)??0,visibility:J(r,4)??0});return t}function _o(e){return Array.from(e,t=>127<t?t-256:t)}function Eo(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,s=0;for(let o=0;o<e.length;o++)r+=e[o]*t[o],n+=e[o]*e[o],s+=t[o]*t[o];if(0>=n||0>=s)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(n*s)}var vr;H[516587230]=[0,Z,ws,Rs,se];var q1=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 Pa(){if(vr===void 0)try{await WebAssembly.instantiate(q1),vr=!0}catch{vr=!1}return vr}async function _r(e,t=""){let r=await Pa()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var vt=class{};function Da(){let e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")}async function To(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",s=>{n(s)},!1),document.body.appendChild(t)})}importScripts(e.toString())}function Ua(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 T(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 bo(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,s]=Ua(t);return!e.l||n===e.i.canvas.width&&s===e.i.canvas.height||(e.i.canvas.width=n,e.i.canvas.height=s),[n,s]}function xo(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 s=0;s<t.length;s++)n[s]=e.i.stringToNewUTF8(t[s]);t=e.i._malloc(4*n.length),e.i.HEAPU32.set(n,t>>2),r(t);for(let s of n)e.i._free(s);e.i._free(t)}function qe(e,t,r){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=r}function yt(e,t,r){let n=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(s,o,i)=>{o?(r(n,i),n=[]):n.push(s)}}vt.forVisionTasks=function(e){return _r("vision",e)},vt.forTextTasks=function(e){return _r("text",e)},vt.forGenAiTasks=function(e){return _r("genai",e)},vt.forAudioTasks=function(e){return _r("audio",e)},vt.isSimdSupported=function(){return Pa()};async function J1(e,t,r,n){return e=await(async(s,o,i,a,c)=>{if(o&&await To(o),!self.ModuleFactory||i&&(await To(i),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&c&&((o=self.Module).locateFile=c.locateFile,c.mainScriptUrlOrBlob&&(o.mainScriptUrlOrBlob=c.mainScriptUrlOrBlob)),c=await self.ModuleFactory(self.Module||c),self.ModuleFactory=self.Module=void 0,new s(c,a)})(e,r.wasmLoaderPath,r.assetLoaderPath,t,{locateFile:s=>s.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&s.endsWith(".data")?r.assetBinaryPath.toString():s}),await e.o(n),e}function Ao(e,t){let r=C(e.baseOptions,Nr,1)||new Nr;typeof t=="string"?(D(r,2,Nt(t)),D(r,1)):t instanceof Uint8Array&&(D(r,1,ss(t,!1,!1)),D(r,2)),_(e.baseOptions,0,1,r)}function wo(e){try{let t=e.H.length;if(t===1)throw Error(e.H[0].message);if(1<t)throw Error("Encountered multiple errors: "+e.H.map(r=>r.message).join(", "))}finally{e.H=[]}}function p(e,t){e.C=Math.max(e.C,t)}function rn(e,t){e.B=new ce,Ae(e.B,"PassThroughCalculator"),U(e.B,"free_memory"),k(e.B,"free_memory_unused_out"),G(t,"free_memory"),we(t,e.B)}function Mt(e,t){U(e.B,t),k(e.B,t+"_unused_out")}function nn(e){e.g.addBoolToStream(!0,"free_memory",e.C)}var In=class{constructor(e){this.g=e,this.H=[],this.C=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(!(C(this.baseOptions,Nr,1)?.g()||C(this.baseOptions,Nr,1)?.h()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(n,s){let o=C(n.baseOptions,vo,3);if(!o){var i=o=new vo,a=new go;qt(i,4,Rr,a)}"delegate"in s&&(s.delegate==="GPU"?(s=o,i=new ji,qt(s,2,Rr,i)):(s=o,i=new go,qt(s,4,Rr,i))),_(n.baseOptions,0,3,o)}(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),Ao(this,"/model.dat"),this.m(),this.K()});Ao(this,r.modelAssetBuffer)}return this.m(),this.K(),Promise.resolve()}K(){}fa(){let e;if(this.g.fa(t=>{e=f1(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.Ma(),this.g.setGraph(e,t),this.B=void 0,wo(this)}finishProcessing(){this.g.finishProcessing(),wo(this)}close(){this.B=void 0,this.g.closeGraph()}};function he(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}In.prototype.close=In.prototype.close;var On=class{constructor(t,r,n,s){this.g=t,this.h=r,this.m=n,this.l=s}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}};function Ro(e,t,r){let n=e.g;if(r=he(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 ko(e,t){let r=e.g,n=he(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);let s=he(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,s),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 o=he(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,o),r.enableVertexAttribArray(e.O),r.vertexAttribPointer(e.O,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 On(r,n,s,o)}function Fs(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function pr(e,t,r,n){return Fs(e,t),e.h||(e.m(),e.D()),r?(e.s||(e.s=ko(e,!0)),r=e.s):(e.v||(e.v=ko(e,!1)),r=e.v),t.useProgram(e.h),r.bind(),e.l(),e=n(),r.g.bindVertexArray(null),e}function ut(e,t,r){return Fs(e,t),e=he(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 sn(e,t,r){Fs(e,t),e.B||(e.B=he(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.B),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0)}function Ls(e){e.g?.bindFramebuffer(e.g.FRAMEBUFFER,null)}var Xt=class{H(){return`
2
+ precision mediump float;
3
+ varying vec2 vTex;
4
+ uniform sampler2D inputTexture;
5
+ void main() {
6
+ gl_FragColor = texture2D(inputTexture, vTex);
7
+ }
8
+ `}m(){let e=this.g;if(this.h=he(e.createProgram(),"Failed to create WebGL program"),this.ba=Ro(this,`
9
+ attribute vec2 aVertex;
10
+ attribute vec2 aTex;
11
+ varying vec2 vTex;
12
+ void main(void) {
13
+ gl_Position = vec4(aVertex, 0.0, 1.0);
14
+ vTex = aTex;
15
+ }`,e.VERTEX_SHADER),this.aa=Ro(this,this.H(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.P=e.getAttribLocation(this.h,"aVertex"),this.O=e.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){let e=this.g;e.deleteProgram(this.h),e.deleteShader(this.ba),e.deleteShader(this.aa)}this.B&&this.g.deleteFramebuffer(this.B),this.v&&this.v.close(),this.s&&this.s.close()}},Z1=class extends Xt{H(){return`
16
+ precision mediump float;
17
+ uniform sampler2D backgroundTexture;
18
+ uniform sampler2D maskTexture;
19
+ uniform sampler2D colorMappingTexture;
20
+ varying vec2 vTex;
21
+ void main() {
22
+ vec4 backgroundColor = texture2D(backgroundTexture, vTex);
23
+ float category = texture2D(maskTexture, vTex).r;
24
+ vec4 categoryColor = texture2D(colorMappingTexture, vec2(category, 0.0));
25
+ gl_FragColor = mix(backgroundColor, categoryColor, categoryColor.a);
26
+ }
27
+ `}D(){let e=this.g;e.activeTexture(e.TEXTURE1),this.C=ut(this,e,e.LINEAR),e.activeTexture(e.TEXTURE2),this.j=ut(this,e,e.NEAREST)}m(){super.m();let e=this.g;this.K=he(e.getUniformLocation(this.h,"backgroundTexture"),"Uniform location"),this.V=he(e.getUniformLocation(this.h,"colorMappingTexture"),"Uniform location"),this.J=he(e.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();let e=this.g;e.uniform1i(this.J,0),e.uniform1i(this.K,1),e.uniform1i(this.V,2)}close(){this.C&&this.g.deleteTexture(this.C),this.j&&this.g.deleteTexture(this.j),super.close()}},Q1=class extends Xt{H(){return`
28
+ precision mediump float;
29
+ uniform sampler2D maskTexture;
30
+ uniform sampler2D defaultTexture;
31
+ uniform sampler2D overlayTexture;
32
+ varying vec2 vTex;
33
+ void main() {
34
+ float confidence = texture2D(maskTexture, vTex).r;
35
+ vec4 defaultColor = texture2D(defaultTexture, vTex);
36
+ vec4 overlayColor = texture2D(overlayTexture, vTex);
37
+ // Apply the alpha from the overlay and merge in the default color
38
+ overlayColor = mix(defaultColor, overlayColor, overlayColor.a);
39
+ gl_FragColor = mix(defaultColor, overlayColor, confidence);
40
+ }
41
+ `}D(){let e=this.g;e.activeTexture(e.TEXTURE1),this.j=ut(this,e),e.activeTexture(e.TEXTURE2),this.C=ut(this,e)}m(){super.m();let e=this.g;this.J=he(e.getUniformLocation(this.h,"defaultTexture"),"Uniform location"),this.K=he(e.getUniformLocation(this.h,"overlayTexture"),"Uniform location"),this.I=he(e.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();let e=this.g;e.uniform1i(this.I,0),e.uniform1i(this.J,1),e.uniform1i(this.K,2)}close(){this.j&&this.g.deleteTexture(this.j),this.C&&this.g.deleteTexture(this.C),super.close()}};function Ze(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 Pn(e){var t=Ze(e,1);if(!t){if(t=Ze(e,0))t=new Float32Array(t).map(n=>n/255);else{t=new Float32Array(e.width*e.height);let n=It(e);var r=Ms(e);if(sn(r,n,Ba(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"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 s=0,o=0;s<t.length;++s,o+=4)t[s]=r[o]}else n.readPixels(0,0,e.width,e.height,n.RED,n.FLOAT,t)}e.g.push(t)}return t}function Ba(e){let t=Ze(e,2);if(!t){let r=It(e);t=Ga(e);let n=Pn(e),s=Na(e);r.texImage2D(r.TEXTURE_2D,0,s,e.width,e.height,0,r.RED,r.FLOAT,n),Dn(e)}return t}function It(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=he(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Na(e){if(e=It(e),!Er)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Er=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Er=e.R16F}return Er}function Ms(e){return e.l||(e.l=new Xt),e.l}function Ga(e){let t=It(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=Ze(e,2);return r||(r=ut(Ms(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Dn(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Er,re=class{constructor(e,t,r,n,s,o,i){this.g=e,this.m=t,this.j=r,this.canvas=n,this.l=s,this.width=o,this.height=i,this.j&&--So===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Ha(){return!!Ze(this,0)}la(){return!!Ze(this,1)}R(){return!!Ze(this,2)}ka(){return(t=Ze(e=this,0))||(t=Pn(e),t=new Uint8Array(t.map(r=>255*r)),e.g.push(t)),t;var e,t}ja(){return Pn(this)}M(){return Ba(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=It(this),s=Ms(this);n.activeTexture(n.TEXTURE1),r=ut(s,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);let o=Na(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),sn(s,n,r),pr(s,n,!1,()=>{Ga(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),Dn(this)}),Ls(s),Dn(this)}}e.push(r)}return new re(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&It(this).deleteTexture(Ze(this,2)),So=-1}};re.prototype.close=re.prototype.close,re.prototype.clone=re.prototype.clone,re.prototype.getAsWebGLTexture=re.prototype.M,re.prototype.getAsFloat32Array=re.prototype.ja,re.prototype.getAsUint8Array=re.prototype.ka,re.prototype.hasWebGLTexture=re.prototype.R,re.prototype.hasFloat32Array=re.prototype.la,re.prototype.hasUint8Array=re.prototype.Ha;var So=250,ec={color:"white",lineWidth:4,radius:6};function gn(e){return{...ec,fillColor:(e=e||{}).color,...e}}function Je(e,t){return e instanceof Function?e(t):e}function Co(e,t,r){return Math.max(Math.min(t,r),Math.min(Math.max(t,r),e))}function Ht(e){if(!e.l)throw Error("CPU rendering requested but CanvasRenderingContext2D not provided.");return e.l}function or(e){if(!e.j)throw Error("GPU rendering requested but WebGL2RenderingContext not provided.");return e.j}function Fo(e,t,r){if(t.R())r(t.M());else{let n=t.la()?t.ja():t.ka();e.m=e.m??new Xt;let s=or(e);r((e=new re([n],t.m,!1,s.canvas,e.m,t.width,t.height)).M()),e.close()}}function Lo(e,t,r,n){let s=function(a){return a.g||(a.g=new Z1),a.g}(e),o=or(e),i=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r;pr(s,o,!0,()=>{(function(c,u,f,h){let m=c.g;if(m.activeTexture(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,u),m.activeTexture(m.TEXTURE1),m.bindTexture(m.TEXTURE_2D,c.C),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,f),c.I&&function(b,A){if(b!==A)return!1;b=b.entries(),A=A.entries();for(let[O,d]of b){b=O;let l=d;var x=A.next();if(x.done)return!1;let[g,S]=x.value;if(x=S,b!==g||l[0]!==x[0]||l[1]!==x[1]||l[2]!==x[2]||l[3]!==x[3])return!1}return!!A.next().done}(c.I,h))m.activeTexture(m.TEXTURE2),m.bindTexture(m.TEXTURE_2D,c.j);else{c.I=h;let b=Array(1024).fill(0);h.forEach((A,x)=>{if(A.length!==4)throw Error(`Color at index ${x} is not a four-channel value.`);b[4*x]=A[0],b[4*x+1]=A[1],b[4*x+2]=A[2],b[4*x+3]=A[3]}),m.activeTexture(m.TEXTURE2),m.bindTexture(m.TEXTURE_2D,c.j),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,256,1,0,m.RGBA,m.UNSIGNED_BYTE,new Uint8Array(b))}})(s,t,i,n),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLE_FAN,0,4);let a=s.g;a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,null),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,null),a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,null)})}function Mo(e,t,r,n){let s=or(e),o=function(c){return c.h||(c.h=new Q1),c.h}(e),i=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r,a=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n;pr(o,s,!0,()=>{var c=o.g;c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,t),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,o.j),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,o.C),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.drawArrays(s.TRIANGLE_FAN,0,4),s.bindTexture(s.TEXTURE_2D,null),(c=o.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 de=class{constructor(e,t){e instanceof CanvasRenderingContext2D||e instanceof OffscreenCanvasRenderingContext2D?(this.l=e,this.j=t):this.j=e}Aa(e,t){if(e){var r=Ht(this);t=gn(t),r.save();var n=r.canvas,s=0;for(let o of e)r.fillStyle=Je(t.fillColor,{index:s,from:o}),r.strokeStyle=Je(t.color,{index:s,from:o}),r.lineWidth=Je(t.lineWidth,{index:s,from:o}),(e=new Path2D).arc(o.x*n.width,o.y*n.height,Je(t.radius,{index:s,from:o}),0,2*Math.PI),r.fill(e),r.stroke(e),++s;r.restore()}}za(e,t,r){if(e&&t){var n=Ht(this);r=gn(r),n.save();var s=n.canvas,o=0;for(let i of t){n.beginPath(),t=e[i.start];let a=e[i.end];t&&a&&(n.strokeStyle=Je(r.color,{index:o,from:t,to:a}),n.lineWidth=Je(r.lineWidth,{index:o,from:t,to:a}),n.moveTo(t.x*s.width,t.y*s.height),n.lineTo(a.x*s.width,a.y*s.height)),++o,n.stroke()}n.restore()}}wa(e,t){let r=Ht(this);t=gn(t),r.save(),r.beginPath(),r.lineWidth=Je(t.lineWidth,{}),r.strokeStyle=Je(t.color,{}),r.fillStyle=Je(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()}xa(e,t,r=[0,0,0,255]){this.l?function(n,s,o,i){let a=or(n);Fo(n,s,c=>{Lo(n,c,o,i),(c=Ht(n)).drawImage(a.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,r,t):Lo(this,e.M(),r,t)}ya(e,t,r){this.l?function(n,s,o,i){let a=or(n);Fo(n,s,c=>{Mo(n,c,o,i),(c=Ht(n)).drawImage(a.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,t,r):Mo(this,e.M(),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 Ve(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 Va(e){var t=Ve(e,0);if(!t){t=Ot(e);let r=on(e),n=new Uint8Array(e.width*e.height*4);sn(r,t,kr(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 kr(e){let t=Ve(e,2);if(!t){let r=Ot(e);t=Sr(e);let n=Ve(e,1)||Va(e);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,n),Yt(e)}return t}function Ot(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=he(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function on(e){return e.l||(e.l=new Xt),e.l}function Sr(e){let t=Ot(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=Ve(e,2);return r||(r=ut(on(e),t),e.g.push(r),e.m=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Yt(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Io(e){let t=Ot(e);return pr(on(e),t,!0,()=>function(r,n){let s=r.canvas;if(s.width===r.width&&s.height===r.height)return n();let o=s.width,i=s.height;return s.width=r.width,s.height=r.height,r=n(),s.width=o,s.height=i,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()}))}de.prototype.close=de.prototype.close,de.prototype.drawConfidenceMask=de.prototype.ya,de.prototype.drawCategoryMask=de.prototype.xa,de.prototype.drawBoundingBox=de.prototype.wa,de.prototype.drawConnectors=de.prototype.za,de.prototype.drawLandmarks=de.prototype.Aa,de.lerp=function(e,t,r,n,s){return Co(n*(1-(e-t)/(r-t))+s*(1-(r-e)/(r-t)),n,s)},de.clamp=Co;var oe=class{constructor(e,t,r,n,s,o,i){this.g=e,this.j=t,this.m=r,this.canvas=n,this.l=s,this.width=o,this.height=i,(this.j||this.m)&&--Oo===0&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Ga(){return!!Ve(this,0)}ma(){return!!Ve(this,1)}R(){return!!Ve(this,2)}Ea(){return Va(this)}Da(){var e=Ve(this,1);return e||(kr(this),Sr(this),e=Io(this),Yt(this),this.g.push(e),this.j=!0),e}M(){return kr(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=Ot(this),s=on(this);n.activeTexture(n.TEXTURE1),r=ut(s,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),sn(s,n,r),pr(s,n,!1,()=>{Sr(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),Yt(this)}),Ls(s),Yt(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);kr(this),Sr(this),r=Io(this),Yt(this)}e.push(r)}return new oe(e,this.ma(),this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Ve(this,1).close(),this.m&&Ot(this).deleteTexture(Ve(this,2)),Oo=-1}};oe.prototype.close=oe.prototype.close,oe.prototype.clone=oe.prototype.clone,oe.prototype.getAsWebGLTexture=oe.prototype.M,oe.prototype.getAsImageBitmap=oe.prototype.Da,oe.prototype.getAsImageData=oe.prototype.Ea,oe.prototype.hasWebGLTexture=oe.prototype.R,oe.prototype.hasImageBitmap=oe.prototype.ma,oe.prototype.hasImageData=oe.prototype.Ga;var Oo=250;function Be(...e){return e.map(([t,r])=>({start:t,end:r}))}var tc=function(e){return class extends e{Ma(){this.i._registerModelResourcesGraphService()}}}((Po=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:typeof OffscreenCanvas>"u"||Da()?(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas")):this.i.canvas=new OffscreenCanvas(1,1)}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,s){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),T(this,n||"input_audio",o=>{T(this,s=s||"audio_header",i=>{this.i._configureAudio(o,i,e,t,r)})})}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}fa(e){qe(this,"__graph_config__",t=>{e(t)}),T(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,s){let o=4*e.length;this.h!==o&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(o),this.h=o),this.i.HEAPF32.set(e,this.g/4),T(this,n,i=>{this.i._addAudioToInputStream(this.g,t,r,i,s)})}addGpuBufferToStream(e,t,r){T(this,t,n=>{let[s,o]=bo(this,e,n);this.i._addBoundTextureToStream(n,s,o,r)})}addBoolToStream(e,t,r){T(this,t,n=>{this.i._addBoolToInputStream(e,n,r)})}addDoubleToStream(e,t,r){T(this,t,n=>{this.i._addDoubleToInputStream(e,n,r)})}addFloatToStream(e,t,r){T(this,t,n=>{this.i._addFloatToInputStream(e,n,r)})}addIntToStream(e,t,r){T(this,t,n=>{this.i._addIntToInputStream(e,n,r)})}addStringToStream(e,t,r){T(this,t,n=>{T(this,e,s=>{this.i._addStringToInputStream(s,n,r)})})}addStringRecordToStream(e,t,r){T(this,t,n=>{xo(this,Object.keys(e),s=>{xo(this,Object.values(e),o=>{this.i._addFlatHashMapToInputStream(s,o,Object.keys(e).length,n,r)})})})}addProtoToStream(e,t,r,n){T(this,r,s=>{T(this,t,o=>{let i=this.i._malloc(e.length);this.i.HEAPU8.set(e,i),this.i._addProtoToInputStream(i,e.length,o,s,n),this.i._free(i)})})}addEmptyPacketToStream(e,t){T(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){T(this,t,n=>{let s=this.i._allocateBoolVector(e.length);if(!s)throw Error("Unable to allocate new bool vector on heap.");for(let o of e)this.i._addBoolVectorEntry(s,o);this.i._addBoolVectorToInputStream(s,n,r)})}addDoubleVectorToStream(e,t,r){T(this,t,n=>{let s=this.i._allocateDoubleVector(e.length);if(!s)throw Error("Unable to allocate new double vector on heap.");for(let o of e)this.i._addDoubleVectorEntry(s,o);this.i._addDoubleVectorToInputStream(s,n,r)})}addFloatVectorToStream(e,t,r){T(this,t,n=>{let s=this.i._allocateFloatVector(e.length);if(!s)throw Error("Unable to allocate new float vector on heap.");for(let o of e)this.i._addFloatVectorEntry(s,o);this.i._addFloatVectorToInputStream(s,n,r)})}addIntVectorToStream(e,t,r){T(this,t,n=>{let s=this.i._allocateIntVector(e.length);if(!s)throw Error("Unable to allocate new int vector on heap.");for(let o of e)this.i._addIntVectorEntry(s,o);this.i._addIntVectorToInputStream(s,n,r)})}addStringVectorToStream(e,t,r){T(this,t,n=>{let s=this.i._allocateStringVector(e.length);if(!s)throw Error("Unable to allocate new string vector on heap.");for(let o of e)T(this,o,i=>{this.i._addStringVectorEntry(s,i)});this.i._addStringVectorToInputStream(s,n,r)})}addBoolToInputSidePacket(e,t){T(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){T(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){T(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){T(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){T(this,t,r=>{T(this,e,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(e,t,r){T(this,r,n=>{T(this,t,s=>{let o=this.i._malloc(e.length);this.i.HEAPU8.set(e,o),this.i._addProtoToInputSidePacket(o,e.length,s,n),this.i._free(o)})})}addBoolVectorToInputSidePacket(e,t){T(this,t,r=>{let n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let s of e)this.i._addBoolVectorEntry(n,s);this.i._addBoolVectorToInputSidePacket(n,r)})}addDoubleVectorToInputSidePacket(e,t){T(this,t,r=>{let n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let s of e)this.i._addDoubleVectorEntry(n,s);this.i._addDoubleVectorToInputSidePacket(n,r)})}addFloatVectorToInputSidePacket(e,t){T(this,t,r=>{let n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let s of e)this.i._addFloatVectorEntry(n,s);this.i._addFloatVectorToInputSidePacket(n,r)})}addIntVectorToInputSidePacket(e,t){T(this,t,r=>{let n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let s of e)this.i._addIntVectorEntry(n,s);this.i._addIntVectorToInputSidePacket(n,r)})}addStringVectorToInputSidePacket(e,t){T(this,t,r=>{let n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let s of e)T(this,s,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(e,t){qe(this,e,t),T(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){yt(this,e,t),T(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){qe(this,e,t),T(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){yt(this,e,t),T(this,e,r=>{this.i._attachIntVectorListener(r)})}attachDoubleListener(e,t){qe(this,e,t),T(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){yt(this,e,t),T(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){qe(this,e,t),T(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){yt(this,e,t),T(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){qe(this,e,t),T(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){yt(this,e,t),T(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){qe(this,e,t),T(this,e,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(e,t,r){yt(this,e,t),T(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,s)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),t(n,s)}),T(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 Po{get ha(){return this.i}sa(e,t,r){T(this,t,n=>{let[s,o]=bo(this,e,n);this.ha._addBoundTextureAsImageToStream(n,s,o,r)})}W(e,t){qe(this,e,t),T(this,e,r=>{this.ha._attachImageListener(r)})}da(e,t){yt(this,e,t),T(this,e,r=>{this.ha._attachImageVectorListener(r)})}})),Po,Oe=class extends tc{};async function w(e,t,r){return async function(n,s,o,i){return J1(n,s,o,i)}(e,r.canvas??(typeof OffscreenCanvas>"u"||Da()?document.createElement("canvas"):void 0),t,r)}function ja(e,t,r,n){if(e.V){let o=new oa;if(r?.regionOfInterest){if(!e.ra)throw Error("This task doesn't support region-of-interest.");var s=r.regionOfInterest;if(s.left>=s.right||s.top>=s.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>s.left||0>s.top||1<s.right||1<s.bottom)throw Error("Expected RectF values to be in [0,1].");v(o,1,(s.left+s.right)/2),v(o,2,(s.top+s.bottom)/2),v(o,4,s.right-s.left),v(o,3,s.bottom-s.top)}else v(o,1,.5),v(o,2,.5),v(o,4,1),v(o,3,1);if(r?.rotationDegrees){if(r?.rotationDegrees%90!=0)throw Error("Expected rotation to be a multiple of 90\xB0.");if(v(o,5,-Math.PI*r.rotationDegrees/180),r?.rotationDegrees%180!=0){let[i,a]=Ua(t);r=J(o,3)*a/i,s=J(o,4)*i/a,v(o,4,r),v(o,3,s)}}e.g.addProtoToStream(o.g(),"mediapipe.NormalizedRect",e.V,n)}e.g.sa(t,e.ba,n??performance.now()),e.finishProcessing()}function Pe(e,t,r){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");ja(e,t,r,e.C+1)}function Ke(e,t,r,n){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");ja(e,t,r,n)}function Pt(e,t,r,n){var s=t.data;let o=t.width,i=o*(t=t.height);if((s instanceof Uint8Array||s instanceof Float32Array)&&s.length!==i)throw Error("Unsupported channel count: "+s.length/i);return e=new re([s],r,!1,e.g.i.canvas,e.O,o,t),n?e.clone():e}var pe=class extends In{constructor(e,t,r,n){super(e),this.g=e,this.ba=t,this.V=r,this.ra=n,this.O=new Xt}l(e,t=!0){if("runningMode"in e&&sr(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.O.close(),super.close()}};pe.prototype.close=pe.prototype.close;var Re=class extends pe{constructor(e,t){super(new Oe(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},_(e=this.h=new en,0,1,t=new z),v(this.h,2,.5),v(this.h,3,.3)}get baseOptions(){return C(this.h,z,1)}set baseOptions(e){_(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)}F(e,t){return this.j={detections:[]},Pe(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},Ke(this,e,r,t),this.j}m(){var e=new le;G(e,"image_in"),G(e,"norm_rect_in"),L(e,"detections");let t=new xe;De(t,P1,this.h);let r=new ce;Ae(r,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),U(r,"IMAGE:image_in"),U(r,"NORM_RECT:norm_rect_in"),k(r,"DETECTIONS:detections"),r.o(t),we(e,r),this.g.attachProtoVectorListener("detections",(n,s)=>{for(let o of n)n=Qi(o),this.j.detections.push(Oa(n));p(this,s)}),this.g.attachEmptyPacketListener("detections",n=>{p(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Re.prototype.detectForVideo=Re.prototype.G,Re.prototype.detect=Re.prototype.F,Re.prototype.setOptions=Re.prototype.o,Re.createFromModelPath=async function(e,t){return w(Re,e,{baseOptions:{modelAssetPath:t}})},Re.createFromModelBuffer=function(e,t){return w(Re,e,{baseOptions:{modelAssetBuffer:t}})},Re.createFromOptions=function(e,t){return w(Re,e,t)};var Is=Be([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]),Os=Be([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]),Ps=Be([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Xa=Be([474,475],[475,476],[476,477],[477,474]),Ds=Be([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]),Us=Be([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Wa=Be([469,470],[470,471],[471,472],[472,469]),Bs=Be([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]),Ha=[...Is,...Os,...Ps,...Ds,...Us,...Bs],za=Be([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 Do(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Y=class extends pe{constructor(e,t){super(new Oe(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,_(e=this.h=new ma,0,1,t=new z),this.v=new pa,_(this.h,0,3,this.v),this.s=new en,_(this.h,0,2,this.s),We(this.s,4,1),v(this.s,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return C(this.h,z,1)}set baseOptions(e){_(this.h,0,1,e)}o(e){return"numFaces"in e&&We(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)}F(e,t){return Do(this),Pe(this,e,t),this.j}G(e,t,r){return Do(this),Ke(this,e,r,t),this.j}m(){var e=new le;G(e,"image_in"),G(e,"norm_rect"),L(e,"face_landmarks");let t=new xe;De(t,U1,this.h);let r=new ce;Ae(r,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),U(r,"IMAGE:image_in"),U(r,"NORM_RECT:norm_rect"),k(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),we(e,r),this.g.attachProtoVectorListener("face_landmarks",(n,s)=>{for(let o of n)n=dr(o),this.j.faceLandmarks.push(tn(n));p(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{p(this,n)}),this.outputFaceBlendshapes&&(L(e,"blendshapes"),k(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,s)=>{if(this.outputFaceBlendshapes)for(let o of n)n=Zr(o),this.j.faceBlendshapes.push(Cs(n.g()??[]));p(this,s)}),this.g.attachEmptyPacketListener("blendshapes",n=>{p(this,n)})),this.outputFacialTransformationMatrixes&&(L(e,"face_geometry"),k(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,s)=>{if(this.outputFacialTransformationMatrixes)for(let o of n)(n=C(D1(o),sa,2))&&this.j.facialTransformationMatrixes.push({rows:Xe(Fe(n,1))??0,columns:Xe(Fe(n,2))??0,data:Rt(n,3,ht).slice()??[]});p(this,s)}),this.g.attachEmptyPacketListener("face_geometry",n=>{p(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Y.prototype.detectForVideo=Y.prototype.G,Y.prototype.detect=Y.prototype.F,Y.prototype.setOptions=Y.prototype.o,Y.createFromModelPath=function(e,t){return w(Y,e,{baseOptions:{modelAssetPath:t}})},Y.createFromModelBuffer=function(e,t){return w(Y,e,{baseOptions:{modelAssetBuffer:t}})},Y.createFromOptions=function(e,t){return w(Y,e,t)},Y.FACE_LANDMARKS_LIPS=Is,Y.FACE_LANDMARKS_LEFT_EYE=Os,Y.FACE_LANDMARKS_LEFT_EYEBROW=Ps,Y.FACE_LANDMARKS_LEFT_IRIS=Xa,Y.FACE_LANDMARKS_RIGHT_EYE=Ds,Y.FACE_LANDMARKS_RIGHT_EYEBROW=Us,Y.FACE_LANDMARKS_RIGHT_IRIS=Wa,Y.FACE_LANDMARKS_FACE_OVAL=Bs,Y.FACE_LANDMARKS_CONTOURS=Ha,Y.FACE_LANDMARKS_TESSELATION=za;var Ne=class extends pe{constructor(e,t){super(new Oe(e,t),"image_in","norm_rect",!0),_(e=this.j=new ya,0,1,t=new z)}get baseOptions(){return C(this.j,z,1)}set baseOptions(e){_(this.j,0,1,e)}o(e){return super.l(e)}Pa(e,t,r){let n=typeof t!="function"?t:{};if(this.h=typeof t=="function"?t:r,Pe(this,e,n??{}),!this.h)return this.s}m(){var e=new le;G(e,"image_in"),G(e,"norm_rect"),L(e,"stylized_image");let t=new xe;De(t,B1,this.j);let r=new ce;Ae(r,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),U(r,"IMAGE:image_in"),U(r,"NORM_RECT:norm_rect"),k(r,"STYLIZED_IMAGE:stylized_image"),r.o(t),we(e,r),this.g.W("stylized_image",(n,s)=>{var o=!this.h,i=n.data,a=n.width;let c=a*(n=n.height);if(i instanceof Uint8Array)if(i.length===3*c){let u=new Uint8ClampedArray(4*c);for(let f=0;f<c;++f)u[4*f]=i[3*f],u[4*f+1]=i[3*f+1],u[4*f+2]=i[3*f+2],u[4*f+3]=255;i=new ImageData(u,a,n)}else{if(i.length!==4*c)throw Error("Unsupported channel count: "+i.length/c);i=new ImageData(new Uint8ClampedArray(i.buffer,i.byteOffset,i.length),a,n)}else if(!(i instanceof WebGLTexture))throw Error(`Unsupported format: ${i.constructor.name}`);a=new oe([i],!1,!1,this.g.i.canvas,this.O,a,n),this.s=o=o?a.clone():a,this.h&&this.h(o),p(this,s)}),this.g.attachEmptyPacketListener("stylized_image",n=>{this.s=null,this.h&&this.h(null),p(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ne.prototype.stylize=Ne.prototype.Pa,Ne.prototype.setOptions=Ne.prototype.o,Ne.createFromModelPath=function(e,t){return w(Ne,e,{baseOptions:{modelAssetPath:t}})},Ne.createFromModelBuffer=function(e,t){return w(Ne,e,{baseOptions:{modelAssetBuffer:t}})},Ne.createFromOptions=function(e,t){return w(Ne,e,t)};var Ns=Be([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 Uo(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Bo(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 No(e,t=!0){let r=[];for(let s of e){var n=Zr(s);e=[];for(let o of n.g())n=t&&Fe(o,1)!=null?Xe(Fe(o,1)):-1,e.push({score:J(o,2)??0,index:n,categoryName:Me(o,3)??""??"",displayName:Me(o,4)??""??""});r.push(e)}return r}var ve=class extends pe{constructor(e,t){super(new Oe(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],_(e=this.j=new Aa,0,1,t=new z),this.s=new As,_(this.j,0,2,this.s),this.D=new bs,_(this.s,0,3,this.D),this.v=new Ta,_(this.s,0,2,this.v),this.h=new N1,_(this.j,0,3,this.h),v(this.v,2,.5),v(this.s,4,.5),v(this.D,2,.5)}get baseOptions(){return C(this.j,z,1)}set baseOptions(e){_(this.j,0,1,e)}o(e){if(We(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.D,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new wt,r=t,n=Mn(e.cannedGesturesClassifierOptions,C(this.h,wt,3)?.h());_(r,0,2,n),_(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&C(this.h,wt,3)?.g();return e.customGesturesClassifierOptions?(_(r=t=new wt,0,2,n=Mn(e.customGesturesClassifierOptions,C(this.h,wt,4)?.h())),_(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&C(this.h,wt,4)?.g(),this.l(e)}Ka(e,t){return Uo(this),Pe(this,e,t),Bo(this)}La(e,t,r){return Uo(this),Ke(this,e,r,t),Bo(this)}m(){var e=new le;G(e,"image_in"),G(e,"norm_rect"),L(e,"hand_gestures"),L(e,"hand_landmarks"),L(e,"world_hand_landmarks"),L(e,"handedness");let t=new xe;De(t,j1,this.j);let r=new ce;Ae(r,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),U(r,"IMAGE:image_in"),U(r,"NORM_RECT:norm_rect"),k(r,"HAND_GESTURES:hand_gestures"),k(r,"LANDMARKS:hand_landmarks"),k(r,"WORLD_LANDMARKS:world_hand_landmarks"),k(r,"HANDEDNESS:handedness"),r.o(t),we(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,s)=>{for(let o of n){n=dr(o);let i=[];for(let a of tt(n,ra,1))i.push({x:J(a,1)??0,y:J(a,2)??0,z:J(a,3)??0,visibility:J(a,4)??0});this.landmarks.push(i)}p(this,s)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{p(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,s)=>{for(let o of n){n=kt(o);let i=[];for(let a of tt(n,ea,1))i.push({x:J(a,1)??0,y:J(a,2)??0,z:J(a,3)??0,visibility:J(a,4)??0});this.worldLandmarks.push(i)}p(this,s)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{p(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,s)=>{this.gestures.push(...No(n,!1)),p(this,s)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{p(this,n)}),this.g.attachProtoVectorListener("handedness",(n,s)=>{this.handedness.push(...No(n)),p(this,s)}),this.g.attachEmptyPacketListener("handedness",n=>{p(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Go(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}ve.prototype.recognizeForVideo=ve.prototype.La,ve.prototype.recognize=ve.prototype.Ka,ve.prototype.setOptions=ve.prototype.o,ve.createFromModelPath=function(e,t){return w(ve,e,{baseOptions:{modelAssetPath:t}})},ve.createFromModelBuffer=function(e,t){return w(ve,e,{baseOptions:{modelAssetBuffer:t}})},ve.createFromOptions=function(e,t){return w(ve,e,t)},ve.HAND_CONNECTIONS=Ns;var _e=class extends pe{constructor(e,t){super(new Oe(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],_(e=this.h=new As,0,1,t=new z),this.s=new bs,_(this.h,0,3,this.s),this.j=new Ta,_(this.h,0,2,this.j),We(this.j,3,1),v(this.j,2,.5),v(this.s,2,.5),v(this.h,4,.5)}get baseOptions(){return C(this.h,z,1)}set baseOptions(e){_(this.h,0,1,e)}o(e){return"numHands"in e&&We(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)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Pe(this,e,t),Go(this)}G(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Ke(this,e,r,t),Go(this)}m(){var e=new le;G(e,"image_in"),G(e,"norm_rect"),L(e,"hand_landmarks"),L(e,"world_hand_landmarks"),L(e,"handedness");let t=new xe;De(t,V1,this.h);let r=new ce;Ae(r,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),U(r,"IMAGE:image_in"),U(r,"NORM_RECT:norm_rect"),k(r,"LANDMARKS:hand_landmarks"),k(r,"WORLD_LANDMARKS:world_hand_landmarks"),k(r,"HANDEDNESS:handedness"),r.o(t),we(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,s)=>{for(let o of n)n=dr(o),this.landmarks.push(tn(n));p(this,s)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{p(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,s)=>{for(let o of n)n=kt(o),this.worldLandmarks.push(er(n));p(this,s)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{p(this,n)}),this.g.attachProtoVectorListener("handedness",(n,s)=>{var o=this.handedness,i=o.push;let a=[];for(let c of n){n=Zr(c);let u=[];for(let f of n.g())u.push({score:J(f,2)??0,index:Xe(Fe(f,1))??-1,categoryName:Me(f,3)??""??"",displayName:Me(f,4)??""??""});a.push(u)}i.call(o,...a),p(this,s)}),this.g.attachEmptyPacketListener("handedness",n=>{p(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};_e.prototype.detectForVideo=_e.prototype.G,_e.prototype.detect=_e.prototype.F,_e.prototype.setOptions=_e.prototype.o,_e.createFromModelPath=function(e,t){return w(_e,e,{baseOptions:{modelAssetPath:t}})},_e.createFromModelBuffer=function(e,t){return w(_e,e,{baseOptions:{modelAssetBuffer:t}})},_e.createFromOptions=function(e,t){return w(_e,e,t)},_e.HAND_CONNECTIONS=Ns;var Ya=Be([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 Vo(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function jo(e){try{if(!e.D)return e.h;e.D(e.h)}finally{nn(e)}}function Tr(e,t){e=dr(e),t.push(tn(e))}var X=class extends pe{constructor(e,t){super(new Oe(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,_(e=this.j=new ka,0,1,t=new z),this.I=new bs,_(this.j,0,2,this.I),this.aa=new X1,_(this.j,0,3,this.aa),this.s=new en,_(this.j,0,4,this.s),this.P=new pa,_(this.j,0,5,this.P),this.v=new wa,_(this.j,0,6,this.v),this.J=new Ra,_(this.j,0,7,this.J),v(this.s,2,.5),v(this.s,3,.3),v(this.P,2,.5),v(this.v,2,.5),v(this.v,3,.3),v(this.J,2,.5),v(this.I,2,.5)}get baseOptions(){return C(this.j,z,1)}set baseOptions(e){_(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.P,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.J,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&v(this.I,2,e.minHandLandmarksConfidence??.5),this.l(e)}F(e,t,r){let n=typeof t!="function"?t:{};return this.D=typeof t=="function"?t:r,Vo(this),Pe(this,e,n),jo(this)}G(e,t,r,n){let s=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,Vo(this),Ke(this,e,s,t),jo(this)}m(){var e=new le;G(e,"input_frames_image"),L(e,"pose_landmarks"),L(e,"pose_world_landmarks"),L(e,"face_landmarks"),L(e,"left_hand_landmarks"),L(e,"left_hand_world_landmarks"),L(e,"right_hand_landmarks"),L(e,"right_hand_world_landmarks");let t=new xe,r=new mo;Rn(r,1,Nt("type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),""),function(s,o){if(o!=null)if(Array.isArray(o))D(s,2,zr(o,hs,void 0,void 0,!1));else{if(!(typeof o=="string"||o instanceof Qe||ir(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Rn(s,2,ss(o,!1,!1),bt())}}(r,this.j.g());let n=new ce;Ae(n,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),Br(n,8,mo,r),U(n,"IMAGE:input_frames_image"),k(n,"POSE_LANDMARKS:pose_landmarks"),k(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),k(n,"FACE_LANDMARKS:face_landmarks"),k(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),k(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),k(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),k(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(t),we(e,n),rn(this,e),this.g.attachProtoListener("pose_landmarks",(s,o)=>{Tr(s,this.h.poseLandmarks),p(this,o)}),this.g.attachEmptyPacketListener("pose_landmarks",s=>{p(this,s)}),this.g.attachProtoListener("pose_world_landmarks",(s,o)=>{var i=this.h.poseWorldLandmarks;s=kt(s),i.push(er(s)),p(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",s=>{p(this,s)}),this.outputPoseSegmentationMasks&&(k(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Mt(this,"pose_segmentation_mask"),this.g.W("pose_segmentation_mask",(s,o)=>{this.h.poseSegmentationMasks=[Pt(this,s,!0,!this.D)],p(this,o)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",s=>{this.h.poseSegmentationMasks=[],p(this,s)})),this.g.attachProtoListener("face_landmarks",(s,o)=>{Tr(s,this.h.faceLandmarks),p(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",s=>{p(this,s)}),this.outputFaceBlendshapes&&(L(e,"extra_blendshapes"),k(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(s,o)=>{var i=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(s=Zr(s),i.push(Cs(s.g()??[]))),p(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",s=>{p(this,s)})),this.g.attachProtoListener("left_hand_landmarks",(s,o)=>{Tr(s,this.h.leftHandLandmarks),p(this,o)}),this.g.attachEmptyPacketListener("left_hand_landmarks",s=>{p(this,s)}),this.g.attachProtoListener("left_hand_world_landmarks",(s,o)=>{var i=this.h.leftHandWorldLandmarks;s=kt(s),i.push(er(s)),p(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",s=>{p(this,s)}),this.g.attachProtoListener("right_hand_landmarks",(s,o)=>{Tr(s,this.h.rightHandLandmarks),p(this,o)}),this.g.attachEmptyPacketListener("right_hand_landmarks",s=>{p(this,s)}),this.g.attachProtoListener("right_hand_world_landmarks",(s,o)=>{var i=this.h.rightHandWorldLandmarks;s=kt(s),i.push(er(s)),p(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",s=>{p(this,s)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};X.prototype.detectForVideo=X.prototype.G,X.prototype.detect=X.prototype.F,X.prototype.setOptions=X.prototype.o,X.createFromModelPath=function(e,t){return w(X,e,{baseOptions:{modelAssetPath:t}})},X.createFromModelBuffer=function(e,t){return w(X,e,{baseOptions:{modelAssetBuffer:t}})},X.createFromOptions=function(e,t){return w(X,e,t)},X.HAND_CONNECTIONS=Ns,X.POSE_CONNECTIONS=Ya,X.FACE_LANDMARKS_LIPS=Is,X.FACE_LANDMARKS_LEFT_EYE=Os,X.FACE_LANDMARKS_LEFT_EYEBROW=Ps,X.FACE_LANDMARKS_LEFT_IRIS=Xa,X.FACE_LANDMARKS_RIGHT_EYE=Ds,X.FACE_LANDMARKS_RIGHT_EYEBROW=Us,X.FACE_LANDMARKS_RIGHT_IRIS=Wa,X.FACE_LANDMARKS_FACE_OVAL=Bs,X.FACE_LANDMARKS_CONTOURS=Ha,X.FACE_LANDMARKS_TESSELATION=za;var ke=class extends pe{constructor(e,t){super(new Oe(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},_(e=this.h=new Sa,0,1,t=new z)}get baseOptions(){return C(this.h,z,1)}set baseOptions(e){_(this.h,0,1,e)}o(e){return _(this.h,0,2,Mn(e,C(this.h,Qr,2))),this.l(e)}ua(e,t){return this.j={classifications:[]},Pe(this,e,t),this.j}va(e,t,r){return this.j={classifications:[]},Ke(this,e,r,t),this.j}m(){var e=new le;G(e,"input_image"),G(e,"norm_rect"),L(e,"classifications");let t=new xe;De(t,H1,this.h);let r=new ce;Ae(r,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),U(r,"IMAGE:input_image"),U(r,"NORM_RECT:norm_rect"),k(r,"CLASSIFICATIONS:classifications"),r.o(t),we(e,r),this.g.attachProtoListener("classifications",(n,s)=>{this.j=function(o){let i={classifications:tt(o,k1,1).map(a=>Cs(C(a,_s,4)?.g()??[],Xe(Fe(a,2)),Me(a,3)??""))};return Or(Ft(o,2))!=null&&(i.timestampMs=Xe(Or(Ft(o,2)))),i}(C1(n)),p(this,s)}),this.g.attachEmptyPacketListener("classifications",n=>{p(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ke.prototype.classifyForVideo=ke.prototype.va,ke.prototype.classify=ke.prototype.ua,ke.prototype.setOptions=ke.prototype.o,ke.createFromModelPath=function(e,t){return w(ke,e,{baseOptions:{modelAssetPath:t}})},ke.createFromModelBuffer=function(e,t){return w(ke,e,{baseOptions:{modelAssetBuffer:t}})},ke.createFromOptions=function(e,t){return w(ke,e,t)};var Ee=class extends pe{constructor(e,t){super(new Oe(e,t),"image_in","norm_rect",!0),this.h=new Ca,this.embeddings={embeddings:[]},_(e=this.h,0,1,t=new z)}get baseOptions(){return C(this.h,z,1)}set baseOptions(e){_(this.h,0,1,e)}o(e){var t=this.h,r=C(this.h,yo,2);return r=r?r.clone():new yo,e.l2Normalize!==void 0?sr(r,1,e.l2Normalize):"l2Normalize"in e&&D(r,1),e.quantize!==void 0?sr(r,2,e.quantize):"quantize"in e&&D(r,2),_(t,0,2,r),this.l(e)}Ba(e,t){return Pe(this,e,t),this.embeddings}Ca(e,t,r){return Ke(this,e,r,t),this.embeddings}m(){var e=new le;G(e,"image_in"),G(e,"norm_rect"),L(e,"embeddings_out");let t=new xe;De(t,z1,this.h);let r=new ce;Ae(r,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),U(r,"IMAGE:image_in"),U(r,"NORM_RECT:norm_rect"),k(r,"EMBEDDINGS:embeddings_out"),r.o(t),we(e,r),this.g.attachProtoListener("embeddings_out",(n,s)=>{n=I1(n),this.embeddings=function(o){return{embeddings:tt(o,L1,1).map(i=>{let a={headIndex:Xe(Fe(i,3))??-1,headName:Me(i,4)??""??""};if(Ai(i,Fn,pn(i,1))!==void 0)i=Rt(i=C(i,Fn,pn(i,1)),1,ht),a.floatEmbedding=i.slice();else{let c=new Uint8Array(0);a.quantizedEmbedding=C(i,F1,pn(i,2))?.qa()?.h()??c}return a}),timestampMs:Xe(Or(Ft(o,2)))}}(n),p(this,s)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{p(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ee.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Eo(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Eo(_o(e.quantizedEmbedding),_o(t.quantizedEmbedding))}return e},Ee.prototype.embedForVideo=Ee.prototype.Ca,Ee.prototype.embed=Ee.prototype.Ba,Ee.prototype.setOptions=Ee.prototype.o,Ee.createFromModelPath=function(e,t){return w(Ee,e,{baseOptions:{modelAssetPath:t}})},Ee.createFromModelBuffer=function(e,t){return w(Ee,e,{baseOptions:{modelAssetBuffer:t}})},Ee.createFromOptions=function(e,t){return w(Ee,e,t)};var Un=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 Xo(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function Wo(e){try{let t=new Un(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{nn(e)}}Un.prototype.close=Un.prototype.close;var ae=class extends pe{constructor(e,t){super(new Oe(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ks,this.v=new Fa,_(this.h,0,3,this.v),_(e=this.h,0,1,t=new z)}get baseOptions(){return C(this.h,z,1)}set baseOptions(e){_(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?D(this.h,2,Nt(e.displayNamesLocale)):"displayNamesLocale"in e&&D(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}K(){(function(e){let t=tt(e.fa(),ce,1).filter(r=>(Me(r,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.s=[],1<t.length)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(C(t[0],xe,7)?.l()?.g()??new Map).forEach((r,n)=>{e.s[Number(n)]=Me(r,1)??""})})(this)}ga(e,t,r){let n=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,Xo(this),Pe(this,e,n),Wo(this)}Na(e,t,r,n){let s=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,Xo(this),Ke(this,e,s,t),Wo(this)}Fa(){return this.s}m(){var e=new le;G(e,"image_in"),G(e,"norm_rect");let t=new xe;De(t,Ma,this.h);let r=new ce;Ae(r,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),U(r,"IMAGE:image_in"),U(r,"NORM_RECT:norm_rect"),r.o(t),we(e,r),rn(this,e),this.outputConfidenceMasks&&(L(e,"confidence_masks"),k(r,"CONFIDENCE_MASKS:confidence_masks"),Mt(this,"confidence_masks"),this.g.da("confidence_masks",(n,s)=>{this.confidenceMasks=n.map(o=>Pt(this,o,!0,!this.j)),p(this,s)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],p(this,n)})),this.outputCategoryMask&&(L(e,"category_mask"),k(r,"CATEGORY_MASK:category_mask"),Mt(this,"category_mask"),this.g.W("category_mask",(n,s)=>{this.categoryMask=Pt(this,n,!1,!this.j),p(this,s)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,p(this,n)})),L(e,"quality_scores"),k(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,s)=>{this.qualityScores=n,p(this,s)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,p(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ae.prototype.getLabels=ae.prototype.Fa,ae.prototype.segmentForVideo=ae.prototype.Na,ae.prototype.segment=ae.prototype.ga,ae.prototype.setOptions=ae.prototype.o,ae.createFromModelPath=function(e,t){return w(ae,e,{baseOptions:{modelAssetPath:t}})},ae.createFromModelBuffer=function(e,t){return w(ae,e,{baseOptions:{modelAssetBuffer:t}})},ae.createFromOptions=function(e,t){return w(ae,e,t)};var Bn=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){this.confidenceMasks?.forEach(e=>{e.close()}),this.categoryMask?.close()}};Bn.prototype.close=Bn.prototype.close;var rc=class extends y{constructor(e){super(e)}},Dt=[0,q,-2],nc=[0,et,-3,te],an=[0,et,-3,te,et,-1],Ka=[0,an],sc=[0,Ka,Dt],oc=[0,an,Dt],$a=[0,an,q,-1],ic=[0,$a,Dt],ac=[0,et,-3,te,Dt,-1],cc=[0,et,-3,te,He],yn=class extends y{constructor(e){super(e)}},Ho=[0,et,-1,te],qa=class extends y{constructor(){super()}};qa.A=[1];var zo=class extends y{constructor(e){super(e)}},Nn=[1,2,3,4,5,6,7,8,9,10,14,15],uc=[0,Nn,W,an,W,oc,W,Ka,W,sc,W,Ho,W,cc,W,nc,W,[0,V,et,-2,te,q,te,-1,2,et,Dt],W,$a,W,ic,et,Dt,V,W,ac,W,[0,ne,Ho]],hc=[0,V,q,-1,te],Gn=class extends y{constructor(){super()}};Gn.A=[1],Gn.prototype.g=Jr([0,ne,uc,V,hc]);var Ge=class extends pe{constructor(e,t){super(new Oe(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ks,this.s=new Fa,_(this.h,0,3,this.s),_(e=this.h,0,1,t=new z)}get baseOptions(){return C(this.h,z,1)}set baseOptions(e){_(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)}ga(e,t,r,n){let s=typeof r!="function"?r:{};this.j=typeof r=="function"?r:n,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.C+1,n=new Gn;let o=new zo;var i=new rc;if(We(i,1,255),_(o,0,12,i),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var a=new yn;sr(a,3,!0),v(a,1,t.keypoint.x),v(a,2,t.keypoint.y),qt(o,5,Nn,a)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(a of(i=new qa,t.scribble))sr(t=new yn,3,!0),v(t,1,a.x),v(t,2,a.y),Br(i,1,yn,t);qt(o,15,Nn,i)}Br(n,1,zo,o),this.g.addProtoToStream(n.g(),"drishti.RenderData","roi_in",r),Pe(this,e,s);e:{try{let u=new Bn(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var c=u;break e}this.j(u)}finally{nn(this)}c=void 0}return c}m(){var e=new le;G(e,"image_in"),G(e,"roi_in"),G(e,"norm_rect_in");let t=new xe;De(t,Ma,this.h);let r=new ce;Ae(r,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),U(r,"IMAGE:image_in"),U(r,"ROI:roi_in"),U(r,"NORM_RECT:norm_rect_in"),r.o(t),we(e,r),rn(this,e),this.outputConfidenceMasks&&(L(e,"confidence_masks"),k(r,"CONFIDENCE_MASKS:confidence_masks"),Mt(this,"confidence_masks"),this.g.da("confidence_masks",(n,s)=>{this.confidenceMasks=n.map(o=>Pt(this,o,!0,!this.j)),p(this,s)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],p(this,n)})),this.outputCategoryMask&&(L(e,"category_mask"),k(r,"CATEGORY_MASK:category_mask"),Mt(this,"category_mask"),this.g.W("category_mask",(n,s)=>{this.categoryMask=Pt(this,n,!1,!this.j),p(this,s)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,p(this,n)})),L(e,"quality_scores"),k(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,s)=>{this.qualityScores=n,p(this,s)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,p(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ge.prototype.segment=Ge.prototype.ga,Ge.prototype.setOptions=Ge.prototype.o,Ge.createFromModelPath=function(e,t){return w(Ge,e,{baseOptions:{modelAssetPath:t}})},Ge.createFromModelBuffer=function(e,t){return w(Ge,e,{baseOptions:{modelAssetBuffer:t}})},Ge.createFromOptions=function(e,t){return w(Ge,e,t)};var Se=class extends pe{constructor(e,t){super(new Oe(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},_(e=this.h=new Ss,0,1,t=new z)}get baseOptions(){return C(this.h,z,1)}set baseOptions(e){_(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?D(this.h,2,Nt(e.displayNamesLocale)):"displayNamesLocale"in e&&D(this.h,2),e.maxResults!==void 0?We(this.h,3,e.maxResults):"maxResults"in e&&D(this.h,3),e.scoreThreshold!==void 0?v(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&D(this.h,4),e.categoryAllowlist!==void 0?Ur(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&D(this.h,5),e.categoryDenylist!==void 0?Ur(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&D(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},Pe(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},Ke(this,e,r,t),this.j}m(){var e=new le;G(e,"input_frame_gpu"),G(e,"norm_rect"),L(e,"detections");let t=new xe;De(t,K1,this.h);let r=new ce;Ae(r,"mediapipe.tasks.vision.ObjectDetectorGraph"),U(r,"IMAGE:input_frame_gpu"),U(r,"NORM_RECT:norm_rect"),k(r,"DETECTIONS:detections"),r.o(t),we(e,r),this.g.attachProtoVectorListener("detections",(n,s)=>{for(let o of n)n=Qi(o),this.j.detections.push(Oa(n));p(this,s)}),this.g.attachEmptyPacketListener("detections",n=>{p(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Se.prototype.detectForVideo=Se.prototype.G,Se.prototype.detect=Se.prototype.F,Se.prototype.setOptions=Se.prototype.o,Se.createFromModelPath=async function(e,t){return w(Se,e,{baseOptions:{modelAssetPath:t}})},Se.createFromModelBuffer=function(e,t){return w(Se,e,{baseOptions:{modelAssetBuffer:t}})},Se.createFromOptions=function(e,t){return w(Se,e,t)};var Vn=class{constructor(e,t,r){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=r}close(){this.segmentationMasks?.forEach(e=>{e.close()})}};function Yo(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function Ko(e){try{let t=new Vn(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.s)return t;e.s(t)}finally{nn(e)}}Vn.prototype.close=Vn.prototype.close;var Te=class extends pe{constructor(e,t){super(new Oe(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,_(e=this.h=new Ia,0,1,t=new z),this.v=new Ra,_(this.h,0,3,this.v),this.j=new wa,_(this.h,0,2,this.j),We(this.j,4,1),v(this.j,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return C(this.h,z,1)}set baseOptions(e){_(this.h,0,1,e)}o(e){return"numPoses"in e&&We(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)}F(e,t,r){let n=typeof t!="function"?t:{};return this.s=typeof t=="function"?t:r,Yo(this),Pe(this,e,n),Ko(this)}G(e,t,r,n){let s=typeof r!="function"?r:{};return this.s=typeof r=="function"?r:n,Yo(this),Ke(this,e,s,t),Ko(this)}m(){var e=new le;G(e,"image_in"),G(e,"norm_rect"),L(e,"normalized_landmarks"),L(e,"world_landmarks"),L(e,"segmentation_masks");let t=new xe;De(t,$1,this.h);let r=new ce;Ae(r,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),U(r,"IMAGE:image_in"),U(r,"NORM_RECT:norm_rect"),k(r,"NORM_LANDMARKS:normalized_landmarks"),k(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),we(e,r),rn(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(n,s)=>{this.landmarks=[];for(let o of n)n=dr(o),this.landmarks.push(tn(n));p(this,s)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],p(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,s)=>{this.worldLandmarks=[];for(let o of n)n=kt(o),this.worldLandmarks.push(er(n));p(this,s)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],p(this,n)}),this.outputSegmentationMasks&&(k(r,"SEGMENTATION_MASK:segmentation_masks"),Mt(this,"segmentation_masks"),this.g.da("segmentation_masks",(n,s)=>{this.segmentationMasks=n.map(o=>Pt(this,o,!0,!this.s)),p(this,s)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],p(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Te.prototype.detectForVideo=Te.prototype.G,Te.prototype.detect=Te.prototype.F,Te.prototype.setOptions=Te.prototype.o,Te.createFromModelPath=function(e,t){return w(Te,e,{baseOptions:{modelAssetPath:t}})},Te.createFromModelBuffer=function(e,t){return w(Te,e,{baseOptions:{modelAssetBuffer:t}})},Te.createFromOptions=function(e,t){return w(Te,e,t)},Te.POSE_CONNECTIONS=Ya;var $e={New:"new",Error:"Error",Opened:"opened",Opening:"opening",Processing:"processing",Idle:"idle",Closing:"closing",Closed:"closed",Destroying:"destroying",Destroyed:"destroyed"},Ja={None:"none",Blur:"blur",Overlay:"overlay"};var ye=(e,t="AssertError")=>{if(e==null)throw new Error(t,{cause:e});return e};var Za=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])}},Qa=e=>{let t=new Map(e),r=new Set,n=async i=>{let c=await(await fetch(i)).blob();return await createImageBitmap(c)},s=async i=>{let a=t.get(i);if(!a){if(r.has(i))return null;r.add(i);let c=await n(i);return t.set(i,c),r.delete(i),c}return a},o=i=>(t.get(i)?.close(),t.delete(i));return{tryFetchingImage:s,setImage:(i,a)=>{t.has(i)&&o(i),t.set(i,a)},getImage:i=>t.get(i)??null,removeImage:o,clear:()=>{t.forEach(i=>i.close()),t.clear()}}},e2=(e,t)=>r=>Math.min(Math.max(r,e),t);var t2=(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 s=e/t,o=r/n;if(s>o){let u=Math.ceil(e*o)/s,f=Math.abs(e-u);return{sx:Math.ceil(f/2),sy:0,sw:u,sh:t,dx:0,dy:0,dw:r,dh:n}}let i=Math.ceil(t*s)/o,a=Math.abs(t-i);return{sx:0,sy:Math.ceil(a/2),sw:e,sh:i,dx:0,dy:0,dw:r,dh:n}};var ft=(e,t)=>{let r=e.getContext("2d",t);if(!r)throw new Error("Cannot get CanvasRenderingContext2D");return r},lc=e=>{let t=ft(e);t.scale(-1,1),t.translate(-e.width,0)},Gs=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},mr=(e,t)=>new OffscreenCanvas(e,t);var fc=e=>{ft(e).clearRect(0,0,e.width,e.height)},r2=(e,t)=>{let r={downScaleFactor:3},n=d=>{let l=r[d];if(!l){let g=mr(d==="downScaledCanvas"?Math.trunc(e/r.downScaleFactor):e,d==="downScaledCanvas"?Math.trunc(t/r.downScaleFactor):t);return r[d]=g,g}return l},s=(d,l)=>{let g=n(l);return ft(g).putImageData(d,0,0),g},o=(d,l,g,S,R,M,P,F,j,Q)=>{let mt=l instanceof ImageData?s(l,"drawImageDataCanvas"):l;R===void 0||M===void 0?d.drawImage(mt,g,S):P===void 0||F===void 0||j===void 0||Q===void 0?d.drawImage(mt,g,S,R,M):d.drawImage(mt,g,S,R,M,P,F,j,Q)},i=(d,l,g=e,S=t,R={})=>{let{height:M,width:P}=Gs(d),F=t2(P,M,g,S),j=ft(l,R);o(j,d,F.sx,F.sy,F.sw,F.sh,F.dx,F.dy,F.dw,F.dh)},a=(d,l)=>{let g=n(l);return i(d,g),g},c=(d,l,g)=>{d.globalCompositeOperation=g,o(d,l,0,0)},u=(d,l,g)=>{let S=ft(d),R=0,M=5,P=1/(2*Math.PI*M*M),F=g<3?1:2;for(let j=-g;j<=g;j+=F)for(let Q=-g;Q<=g;Q+=F){let mt=P*Math.exp(-(Q*Q+j*j)/(2*M*M));R+=mt}for(let j=-g;j<=g;j+=F)for(let Q=-g;Q<=g;Q+=F)S.globalAlpha=P*Math.exp(-(Q*Q+j*j)/(2*M*M))/R*g,o(S,l,Q,j);S.globalAlpha=1},f=({image:d,blurAmount:l,canvas:g,preserveOldDrawing:S=!0})=>{let{height:R,width:M}=Gs(d),P=ft(g);if(l<=0)return o(P,d,0,0,M,R);let F=n("downScaledCanvas"),j=ft(F);S||(j.clearRect(0,0,F.width,F.height),P.clearRect(0,0,M,R)),"filter"in P?(j.filter=`blur(${l}px)`,o(j,d,0,0,M,R,0,0,F.width,F.height),o(P,F,0,0,M,R)):u(g,d,l)},h=({image:d,blurAmount:l,offscreenCanvasName:g,preserveOldDrawing:S})=>{let R=n(g);return fc(R),l===0?i(d,R):f({image:d,blurAmount:l,canvas:R,preserveOldDrawing:S}),R},m=(d,l,g)=>{let S=Array.isArray(d)?d[0]?.canvas:d.canvas;if(!S)return n("maskCanvas");let R=h({image:S,offscreenCanvasName:"maskCanvas",blurAmount:0});return g===0?R:h({image:R,blurAmount:g,offscreenCanvasName:"blurredMaskCanvas",preserveOldDrawing:!1})},b=(d,l,g,S,R=.5,M=3,P=3,F=!1)=>{let j=h({image:g,blurAmount:M,offscreenCanvasName:"blurredCanvas"}),Q=ft(d);if(Array.isArray(S)&&S.length===0)return o(Q,j,0,0);let mt=m(S,R,P);Q.save(),F&&lc(d);let{height:d2,width:p2}=Gs(l);o(Q,l,0,0,p2,d2),c(Q,mt,"destination-in"),c(Q,j,"destination-over"),Q.restore()};return{evaluateInput:d=>a(d,"inputCanvas"),renderImageToCanvas:i,drawBlurEffect:(d,l,g,S=.5,R=3,M=3,P=!1)=>b(d,l,l,g,S,R,M,P),drawOverlayEffect:(d,l,g,S,R=.5,M=0,P=3,F=!1)=>b(d,l,g,S,R,M,P,F),renderImageToOffScreenCanvas:a,renderImageDataToOffScreenCanvas:s,drawAndBlurImageOnOffScreenCanvas:h}};var cn={VertexShader:WebGLRenderingContext.VERTEX_SHADER,FragmentShader:WebGLRenderingContext.FRAGMENT_SHADER},Vs={[cn.VertexShader]:"VertexShader",[cn.FragmentShader]:"FragmentShader"},dc=e=>typeof e=="string"?e.startsWith("#version 300 es"):!1,n2=e=>{if(!dc(e))throw new Error("Expecting GLSL ES 3.00 shader source")},pc=/ERROR:\s*\d+:(\d+)/gi;function i2(e,t="",r=0){let n=[...t.matchAll(pc)],s=new Map(n.map((o,i)=>{if(!o[1]||o.index===void 0)return[0,t];let a=parseInt(o[1],10),c=n[i+1],u=c?c.index:t.length,f=t.substring(o.index,u);return[a-1,f]}));return e.split(`
42
+ `).map((o,i)=>{let a=s.get(i);return`${i+1+r}: ${o}${a?`
43
+
44
+ ^^^ ${a}`:""}`}).join(`
45
+ `)}var s2=(e,t,r)=>{let n=e.createShader(t);if(!n)throw new Error(`Unable to create ${Vs[t]}`);if(e.shaderSource(n,r),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){let o=e.getShaderInfoLog(n);e.deleteShader(n);let i=`Error compiling ${Vs[t]}: ${o??""}
46
+ ${o?i2(r,o):"no error message available"}`;throw new Error(i)}return n},mc=(e,t,r,n)=>{let s=e.createProgram();if(!s)throw new Error("Unable to create WebGL program");if(t.forEach(function(i){e.attachShader(s,i)}),r?.forEach(function(i,a){let c=n?.[a]??a;e.bindAttribLocation(s,c,i)}),e.linkProgram(s),!e.getProgramParameter(s,e.LINK_STATUS)){let i=e.getProgramInfoLog(s);throw e.deleteProgram(s),new Error(`Error in program linking: ${i??""}
47
+ ${t.map(a=>{let c=i2(e.getShaderSource(a)??""),u=e.getShaderParameter(a,e.SHADER_TYPE);return`${Vs[u]}:
48
+ ${c}`}).join(`
49
+ `)}`)}return[s,()=>{t.forEach(i=>{e.detachShader(s,i),e.deleteShader(i)}),e.deleteProgram(s)}]},gc=(e,[t,r],n,s)=>mc(e,[s2(e,cn.VertexShader,t),s2(e,cn.FragmentShader,r)],n,s),At=e=>{let t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),t},o2=(e,t,r)=>Object.keys(r).reduce((n,s)=>{let i=r[s];return i?{...n,[s]:i.startsWith("u_")?e.getUniformLocation(t,i):e.getAttribLocation(t,i)}:n},{}),dt=(e,{attribs:t,uniforms:r,vertexSrc:n,fragmentSrc:s})=>{let o=e.getContext("webgl2",{premultipliedAlpha:!1});if(!o)throw new Error("WebGL2 is not supported");o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),n2(n),n2(s);let[i,a]=gc(o,[n,s]);return{gl:o,program:i,attribLocations:o2(o,i,t),uniformLocations:o2(o,i,r),release:a}},js=e=>({texture:e.getAsWebGLTexture(),width:e.width,height:e.height});var fe={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],s=e[0*3+2],o=e[1*3+0],i=e[1*3+1],a=e[1*3+2],c=e[2*3+0],u=e[2*3+1],f=e[2*3+2],h=t[0*3+0],m=t[0*3+1],b=t[0*3+2],A=t[1*3+0],x=t[1*3+1],O=t[1*3+2],d=t[2*3+0],l=t[2*3+1],g=t[2*3+2];return[h*r+m*o+b*c,h*n+m*i+b*u,h*s+m*a+b*f,A*r+x*o+O*c,A*n+x*i+O*u,A*s+x*a+O*f,d*r+l*o+g*c,d*n+l*i+g*u,d*s+l*a+g*f]},translate:(e,t,r)=>fe.multiply(e,fe.translation(t,r)),rotate:(e,t)=>fe.multiply(e,fe.rotation(t)),scale:(e,t,r)=>fe.multiply(e,fe.scaling(t,r))};var pt=`#version 300 es
50
+ // an attribute is an input (in) to a vertex shader.
51
+ // It will receive data from a buffer
52
+ in vec2 a_position;
53
+ in vec2 a_texCoord;
54
+
55
+ // Used to pass in the resolution of the canvas
56
+ uniform mat3 u_matrix;
57
+
58
+ // Used to pass the texture coordinates to the fragment shader
59
+ out vec2 v_texCoord;
60
+
61
+ void main() {
62
+ gl_Position = vec4((u_matrix * vec3(a_position, 1)).xy, 0, 1);
63
+
64
+ // pass the texCoord to the fragment shader
65
+ v_texCoord = a_texCoord;
66
+ }
67
+ `;var un=`#version 300 es
68
+ precision mediump float;
69
+
70
+ // Passed in from the vertex shader.
71
+ in vec2 v_texCoord;
72
+
73
+ // The texture.
74
+ uniform sampler2D u_texture;
75
+
76
+ // we need to declare an output for the fragment shader
77
+ out vec4 outColor;
78
+
79
+ void main() {
80
+ outColor = texture(u_texture, v_texCoord);
81
+ }
82
+ `;var Xs=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:s,release:o}=dt(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",texture:"u_texture"},vertexSrc:pt,fragmentSrc:un}),i=t.createVertexArray();t.bindVertexArray(i);let a=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,a),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 u=At(t),f=At(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,f,0),{render:m=>{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(i),t.uniform1i(s.texture,0);let b=fe.projection(1,1,1);return t.uniformMatrix3fv(s.matrix,!1,b),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,u),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,m.frame),t.generateMipmap(t.TEXTURE_2D),t.drawArrays(t.TRIANGLES,0,6),ye(f),{texture:f,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(a),t.deleteBuffer(c),t.deleteTexture(u),t.deleteTexture(f),t.deleteVertexArray(i),o()}}};var a2=`#version 300 es
83
+ precision mediump float;
84
+
85
+ // our textures
86
+ uniform sampler2D u_frame;
87
+
88
+ // control flags
89
+ uniform int u_downsampling;
90
+
91
+ in vec2 v_texCoord;
92
+
93
+ // we need to declare an output for the fragment shader
94
+ out vec4 outColor;
95
+
96
+ vec4 Downsample(sampler2D image, vec2 uv, vec2 halfpixel) {
97
+ vec4 sum = texture(image, uv) * 4.0;
98
+ sum += texture(image, uv - halfpixel.xy);
99
+ sum += texture(image, uv + halfpixel.xy);
100
+ sum += texture(image, uv + vec2(halfpixel.x, -halfpixel.y));
101
+ sum += texture(image, uv - vec2(halfpixel.x, -halfpixel.y));
102
+ return sum / 8.0;
103
+ }
104
+
105
+ vec4 Upsample(sampler2D image, vec2 uv, vec2 halfpixel) {
106
+ vec4 sum = texture(image, uv + vec2(-halfpixel.x * 2.0, 0.0));
107
+ sum += texture(image, uv + vec2(-halfpixel.x, halfpixel.y)) * 2.0;
108
+ sum += texture(image, uv + vec2(0.0, halfpixel.y * 2.0));
109
+ sum += texture(image, uv + vec2(halfpixel.x, halfpixel.y)) * 2.0;
110
+ sum += texture(image, uv + vec2(halfpixel.x * 2.0, 0.0));
111
+ sum += texture(image, uv + vec2(halfpixel.x, -halfpixel.y)) * 2.0;
112
+ sum += texture(image, uv + vec2(0.0, -halfpixel.y * 2.0));
113
+ sum += texture(image, uv + vec2(-halfpixel.x, -halfpixel.y)) * 2.0;
114
+ return sum / 12.0;
115
+ }
116
+
117
+ void main() {
118
+ vec2 halfpixel = 0.5 / vec2(textureSize(u_frame, 0));
119
+
120
+ if (u_downsampling == 1) {
121
+ outColor = Downsample(u_frame, v_texCoord, halfpixel);
122
+ return;
123
+ }
124
+ outColor = Upsample(u_frame, v_texCoord, halfpixel);
125
+ }
126
+ `;var yc=e2(1,9),Ws=(e,t)=>{let{gl:r,program:n,attribLocations:s,uniformLocations:o,release:i}=dt(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",downsampling:"u_downsampling",frame:"u_frame"},vertexSrc:pt,fragmentSrc:a2}),a=r.createVertexArray();r.bindVertexArray(a);let c=r.createBuffer();r.enableVertexAttribArray(s.position),r.bindBuffer(r.ARRAY_BUFFER,c),r.vertexAttribPointer(s.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 u=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,u),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),r.STATIC_DRAW),r.enableVertexAttribArray(s.texCoord),r.vertexAttribPointer(s.texCoord,2,r.FLOAT,!1,0,0);let f=(A,x,O)=>{r.bindFramebuffer(r.FRAMEBUFFER,A),r.viewport(0,0,x,O)},h=A=>{let x=At(r);ye(x);let O=Math.trunc(e.width/Math.pow(2,A)),d=Math.trunc(e.height/Math.pow(2,A));r.texImage2D(r.TEXTURE_2D,0,r.RGBA,O,d,0,r.RGBA,r.UNSIGNED_BYTE,null);let l=r.createFramebuffer();ye(l),r.bindFramebuffer(r.FRAMEBUFFER,l);let g=r.COLOR_ATTACHMENT0;return r.framebufferTexture2D(r.FRAMEBUFFER,g,r.TEXTURE_2D,x,0),{texture:x,frameBuffer:l,width:O,height:d}},m=(A,x=0)=>{let O=Math.max(yc(x+A)-x,0);return Array.from({length:O}).map((d,l)=>h(x+l))},b=m(t+1);return{render:(A,x)=>{r.useProgram(n),r.bindVertexArray(a),r.activeTexture(r.TEXTURE0),r.uniform1i(o.frame,0),r.bindTexture(r.TEXTURE_2D,A.texture),r.uniform1i(o.downsampling,1);let O=x+1;for(O>b.length&&m(O-b.length,b.length).forEach(d=>b.push(d));O<b.length;){let d=b.pop();r.deleteTexture(d?.texture??null),r.deleteFramebuffer(d?.frameBuffer??null)}for(let d=1;d<O;d++){let{frameBuffer:l=null,texture:g=null,width:S=e.width,height:R=e.height}=b[d]??{};f(l,S,R);let M=fe.projection(1,1,1);r.uniformMatrix3fv(o.matrix,!1,M),r.drawArrays(r.TRIANGLES,0,6);let P=r.checkFramebufferStatus(r.FRAMEBUFFER);if(P!==r.FRAMEBUFFER_COMPLETE)throw new Error(`downsampling FrameBuffer Status: ${P}`);r.bindTexture(r.TEXTURE_2D,g)}r.uniform1i(o.downsampling,0);for(let d=x-1;d>=0;d--){let{frameBuffer:l=null,texture:g=null,width:S=e.width,height:R=e.height}=b[d]??{};f(l,S,R);let M=fe.projection(1,1,1);r.uniformMatrix3fv(o.matrix,!1,M),r.drawArrays(r.TRIANGLES,0,6);let P=r.checkFramebufferStatus(r.FRAMEBUFFER);if(P!==r.FRAMEBUFFER_COMPLETE)throw new Error(`Upsampling FrameBuffer Status: ${P}`);r.bindTexture(r.TEXTURE_2D,g)}return{texture:b[0]?.texture??A.texture,width:b[0]?.width??A.width,height:b[0]?.height??A.height}},release:()=>{b.forEach(({frameBuffer:A,texture:x})=>{r.deleteTexture(x),r.deleteFramebuffer(A)}),r.deleteBuffer(c),r.deleteBuffer(u),r.deleteVertexArray(a),i()}}};var c2=`#version 300 es
127
+ precision mediump float;
128
+
129
+ // our textures
130
+ uniform sampler2D u_mask;
131
+ uniform sampler2D u_mask_prev;
132
+ uniform sampler2D u_frame_foreground;
133
+ uniform sampler2D u_frame_background;
134
+
135
+ // control flags
136
+ uniform float u_mask_combine_ratio;
137
+ uniform float u_foreground_threshold;
138
+
139
+ in vec2 v_texCoord;
140
+
141
+ // we need to declare an output for the fragment shader
142
+ out vec4 outColor;
143
+
144
+ // Source: https://github.com/google/mediapipe/blob/8750c3dca1bc00fbe47acf501b7c9c61f3f3bd3f/mediapipe/calculators/image/segmentation_smoothing_calculator.cc#L377
145
+ float SmoothingMask(sampler2D prevMask, sampler2D currMask, vec2 uv, float ratio) {
146
+ float prevMaskValue = texture(prevMask, uv).r;
147
+ float newMaskValue = texture(currMask, uv).r;
148
+
149
+ /*
150
+ * Assume p := newMaskValue
151
+ * H(p) := 1 + (p * log(p) + (1-p) * log(1-p)) / log(2)
152
+ * uncertainty alpha(p) =
153
+ * Clamp(1 - (1 - H(p)) * (1 - H(p)), 0, 1) [squaring the
154
+ * uncertainty]
155
+ *
156
+ * The following polynomial approximates uncertainty alpha as a
157
+ * function of (p + 0.5):
158
+ */
159
+ const float c1 = 5.68842;
160
+ const float c2 = -0.748699;
161
+ const float c3 = -57.8051;
162
+ const float c4 = 291.309;
163
+ const float c5 = -624.717;
164
+ float t = newMaskValue - 0.5;
165
+ float x = t * t;
166
+
167
+ float uncertainty =
168
+ 1.0 - min(1.0, x * (c1 + x * (c2 + x * (c3 + x * (c4 + x * c5)))));
169
+
170
+ float outputValue = newMaskValue + (prevMaskValue - newMaskValue) *
171
+ (uncertainty * ratio);
172
+ return outputValue;
173
+ }
174
+
175
+ void main() {
176
+ vec2 halfpixel = 0.5 / vec2(textureSize(u_frame_background, 0));
177
+
178
+ vec4 background = texture(u_frame_background, v_texCoord);
179
+ vec4 foreground = texture(u_frame_foreground, v_texCoord);
180
+ float maskAlpha = SmoothingMask(u_mask_prev, u_mask, v_texCoord, u_mask_combine_ratio);
181
+ float filteredMask = maskAlpha;
182
+ if (maskAlpha < u_foreground_threshold) {
183
+ filteredMask = 0.0;
184
+ }
185
+
186
+ outColor = mix(background, foreground, filteredMask);
187
+ }
188
+ `;var u2=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:s,release:o}=dt(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",frameBackground:"u_frame_background",frameForeground:"u_frame_foreground",mask:"u_mask",maskCombineRatio:"u_mask_combine_ratio",foregroundThreshold:"u_foreground_threshold",prevMask:"u_mask_prev"},vertexSrc:pt,fragmentSrc:c2});t.enable(t.BLEND);let i=t.createVertexArray();t.bindVertexArray(i);let a=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,a),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 u=At(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,u,0),{render:({mask:h,prevMask:m,foreground:b,background:A},x)=>{t.bindFramebuffer(t.FRAMEBUFFER,f),t.viewport(0,0,e.width,e.height),t.useProgram(r),t.bindVertexArray(i),t.activeTexture(t.TEXTURE0),t.uniform1i(s.frameForeground,0),t.bindTexture(t.TEXTURE_2D,b.texture),t.activeTexture(t.TEXTURE1),t.uniform1i(s.frameBackground,1),t.bindTexture(t.TEXTURE_2D,A.texture),t.activeTexture(t.TEXTURE2),t.uniform1i(s.mask,2),t.bindTexture(t.TEXTURE_2D,h.texture),t.activeTexture(t.TEXTURE3),t.uniform1i(s.prevMask,3),t.bindTexture(t.TEXTURE_2D,m?.texture??h.texture);let O=fe.projection(1,1,1);return t.uniformMatrix3fv(s.matrix,!1,O),t.uniform1f(s.maskCombineRatio,x.maskCombineRatio),t.uniform1f(s.foregroundThreshold,x.foregroundThreshold),t.drawArrays(t.TRIANGLES,0,6),ye(u),{texture:u,width:e.width,height:e.height}},release:()=>{t.deleteBuffer(a),t.deleteBuffer(c),t.deleteTexture(u),t.deleteFramebuffer(f),t.deleteVertexArray(i),o()}}};var h2=e=>{let{gl:t,program:r,attribLocations:n,uniformLocations:s,release:o}=dt(e,{attribs:{position:"a_position",texCoord:"a_texCoord"},uniforms:{matrix:"u_matrix",texture:"u_texture"},vertexSrc:pt,fragmentSrc:un}),i=t.createVertexArray();t.bindVertexArray(i);let a=t.createBuffer();t.enableVertexAttribArray(n.position),t.bindBuffer(t.ARRAY_BUFFER,a),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:u=>{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(i),t.uniform1i(s.texture,0);let f=fe.projection(1,1);t.uniformMatrix3fv(s.matrix,!1,f),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,u.texture),t.drawArrays(t.TRIANGLES,0,6)},release:()=>{t.deleteBuffer(a),t.deleteBuffer(c),t.deleteVertexArray(i),o()}}};var l2=e=>{let t={};return new Proxy(t,{get(r,n,s){return r[n]||(r[n]=e[n]?.(t)),Reflect.get(r,n,s)}})},f2=(e=new OffscreenCanvas(768,432),{backgroundBlurAmount:t=3,backgroundImageUrl:r="",edgeBlurAmount:n=3,effects:s=Ja.None,foregroundThreshold:o=.5,maskCombineRatio:i=.5,onError:a,backgroundImageInits:c}={})=>{let u={videoFrameRenderer:()=>Xs(e),canvasRenderer:()=>h2(e),backgroundImageRenderer:()=>Xs(e),blendRenderer:()=>u2(e),blurRenderer:()=>Ws(e,h.backgroundBlurAmount),maskBlurRenderer:()=>Ws(e,h.edgeBlurAmount),release:l=>()=>Object.keys(l).forEach(g=>g!=="release"&&l[g]?.release())},f=l2(u),h={backgroundBlurAmount:t,backgroundImageUrl:r,edgeBlurAmount:n,effects:s,foregroundThreshold:o,maskCombineRatio:i,canvas:e,backgroundImages:Qa(c),get videoFrameRenderer(){return f.videoFrameRenderer},get canvasRenderer(){return f.canvasRenderer},get backgroundImageRenderer(){return f.backgroundImageRenderer},get blendRenderer(){return f.blendRenderer},get blurRenderer(){return f.blurRenderer},get maskBlurRenderer(){return f.maskBlurRenderer}},m=Za(h),b=l=>{l.backgroundImage&&h.backgroundImages.setImage(l.backgroundImage.key,l.backgroundImage.image),m(l)},A=l=>{if(l instanceof Error)return a?.(l);throw l};return{init:l=>{l&&b(l)},render:(l,g,S)=>{S&&m(S);let R=h.videoFrameRenderer.render(g),M=R;if(h.effects==="blur"&&h.backgroundBlurAmount)M=h.blurRenderer.render(R,h.backgroundBlurAmount);else if(h?.effects==="overlay"&&h.backgroundImageUrl){let F=h.backgroundImages.getImage(h.backgroundImageUrl);F?M=h.backgroundImageRenderer.render({frame:F,timestamp:performance.now(),width:F.width,height:F.height}):h.backgroundImages.tryFetchingImage(h.backgroundImageUrl).catch(j=>{A(new Error(`FailedToLoadBackgroundImage: ${h.backgroundImageUrl}`,{cause:j}))})}let P=h.blendRenderer.render({prevMask:h.prevMask&&js(h.prevMask),mask:js(l),foreground:R,background:M},h);h.canvasRenderer.render(P),h.prevMask?.close(),h.prevMask=l.clone()},release:()=>{f.release(),f=l2(u),h.backgroundImages.clear(),h.prevMask?.close(),h.prevMask=void 0},update:b}};var E={width:768,height:432,status:$e.New,directOutput:!1};self.document={};var Wt=(e,t)=>postMessage(e,t??[]),bc=async(e={})=>{try{E.status=$e.Opening,e.processingWidth&&(E.width=e.processingWidth),e.processingHeight&&(E.height=e.processingHeight),E.directOutput=!!e.output,E.output=e.output??mr(E.width,E.height);let{basePath:t,imageSegmenterOptions:r={}}=e;E.processCanvas=r.canvas??mr(E.width,E.height),E.renderer=f2(E.processCanvas,{...e.renderOptions,backgroundImageInits:e.backgroundImage&&[[e.backgroundImage.key,e.backgroundImage.image]],onError:o=>{Wt({type:"error",error:o})}}),E.renderer.init();let n=await vt.forVisionTasks(t),s=await ae.createFromOptions(n,{outputCategoryMask:!1,outputConfidenceMasks:!0,runningMode:"VIDEO",canvas:E.processCanvas,baseOptions:{modelAssetPath:r.modelAsset?.path,delegate:r.delegate}});E.renderUtils=r2(E.width,E.height),E.segmenter=s,E.status=$e.Opened,Wt({type:"opened"})}catch(t){if(E.status=$e.Error,t instanceof Error)return Wt({type:"error",error:t});throw t}};self.addEventListener("message",e=>{switch(e.data.type){case"open":{bc(e.data.data);break}case"update":{let{renderOptions:t,backgroundImage:r,output:n}=e.data.data;(t||r)&&E.renderer?.update({...t,backgroundImage:r}),n!==void 0&&(E.output=n??mr(E.width,E.height),E.directOutput=!!n);break}case"process":{E.status=$e.Processing;let{videoFrame:t,imageSegmenterOptions:r,renderOptions:n}=e.data.data;E.videoFrame=t,ye(E.segmenter),(r?.delegate||r?.canvas)&&E.segmenter.setOptions({canvas:r.canvas,baseOptions:{delegate:r.delegate}}).catch(s=>{E.status=$e.Error,s instanceof Error&&Wt({type:"error",error:s})}),ye(E.renderUtils),E.segmenter.segmentForVideo(E.renderUtils.renderImageToOffScreenCanvas(t.frame,"inputCanvas"),t.timestamp,s=>{let{confidenceMasks:o}=s,i=o?.[0];if(!i)Wt({type:"processed"});else{ye(E.output),ye(E.renderer),ye(E.renderUtils),ye(E.processCanvas),E.renderer.render(i,t,n),E.renderUtils.renderImageToCanvas(E.processCanvas,E.output,E.width,E.height),t.frame.close();let a=E.directOutput?void 0:E.output.transferToImageBitmap();Wt({type:"processed",data:a&&{frame:a,width:E.output.width,height:E.output.height,timestamp:performance.now()}},a?[a]:void 0)}E.status=$e.Idle});break}case"close":{E.status=$e.Closing,E.renderer?.release(),E.videoFrame?.frame.close(),E.segmenter?.close(),E.status=$e.Closed;break}case"destroy":break}});