@vonage/ml-transformers 7.0.0-alpha.1 → 7.0.0-alpha.3

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 (27) hide show
  1. package/dist/assets/processor-worker-CR7IjkAn.js.map +1 -0
  2. package/dist/ml-transformers.es.js +3371 -22011
  3. package/dist/ml-transformers.es.js.map +1 -1
  4. package/dist/ml-transformers.min.js +1 -1
  5. package/dist/ml-transformers.static.js +3371 -22011
  6. package/dist/ml-transformers.umd.js +32 -151
  7. package/dist/ml-transformers.umd.js.map +1 -1
  8. package/dist/types/lib/main.d.ts +3 -121
  9. package/dist/types/lib/src/renderers/canvas2d/renderers/canvas2d-renderer.d.ts +0 -2
  10. package/dist/types/lib/src/renderers/webgl/pipelines/improve-segmentation-mask.d.ts +0 -12
  11. package/dist/types/lib/src/renderers/webgl/programs/blur/blur.d.ts +0 -3
  12. package/dist/types/lib/src/transformers/background-transformer.d.ts +2 -2
  13. package/dist/types/lib/src/types.d.ts +0 -56
  14. package/dist/types/lib/src/utils/webgl.d.ts +1 -16
  15. package/package.json +4 -11
  16. package/dist/assets/processor-worker-Ct1XXlKJ.js.map +0 -1
  17. package/dist/types/lib/src/renderers/webgl/programs/expend/expend.d.ts +0 -5
  18. package/dist/types/lib/src/renderers/webgl/programs/flickering/flickering.d.ts +0 -5
  19. package/dist/types/lib/src/renderers/webgl/programs/highpass/highpass.d.ts +0 -5
  20. package/dist/types/lib/src/renderers/webgl/programs/minimum-surface/minimum-surface.d.ts +0 -5
  21. package/dist/types/lib/src/renderers/webgl/programs/power/power.d.ts +0 -5
  22. package/dist/types/lib/src/renderers/webgl/programs/refine-mask/refine-mask.d.ts +0 -5
  23. package/dist/types/lib/src/renderers/webgl/programs/smooth/smooth.d.ts +0 -5
  24. package/dist/types/lib/src/renderers/webgl/programs/track/track.d.ts +0 -5
  25. package/dist/types/lib/src/renderers/webgl/webgl-pipeline-program-double-buffer.d.ts +0 -15
  26. package/dist/types/lib/src/utils/error.d.ts +0 -1
  27. package/dist/types/lib/src/utils/mediapipe.d.ts +0 -11
@@ -1 +1 @@
1
- var ho,po;async function gu(){return new Promise(async(t,e)=>{await qs()||Zs()?t():e("Your browser does not support the MediaStreamTrack API for Insertable Streams of Media.")})}function Zs(){return void 0!==self.MediaStreamTrackProcessor&&void 0!==self.MediaStreamTrackGenerator&&(!(self.MediaStreamTrackProcessor.hasOwnProperty("__POLYFILLED")||self.MediaStreamTrackGenerator.hasOwnProperty("__POLYFILLED"))||mu())}function mu(){return 0===[self.ReadableStream,self.WritableStream,self.MediaStream,self.OffscreenCanvas,self.VideoFrame,self.AudioContext,self.AudioWorkletNode].filter(t=>void 0===t).length}function qs(){return new Promise(t=>{new Worker(`data:text/javascript,(${function(){self.postMessage(typeof MediaStreamTrackProcessor<"u"&&typeof VideoTrackGenerator<"u")}.toString()})()`).onmessage=({data:e})=>t(e)})}self.MediaStreamTrackProcessor||(self.MediaStreamTrackProcessor=((ho=class{constructor(t){const e=t.track??t;"video"==e.kind?this.readable=new ReadableStream({async start(t){e.addEventListener("ended",()=>t.close(),{once:!0}),this.video=document.createElement("video"),this.video.srcObject=new MediaStream([e]),await Promise.all([this.video.play(),new Promise(t=>this.video.onloadedmetadata=t)]),this.track=e,this.canvas=new OffscreenCanvas(this.video.videoWidth,this.video.videoHeight),this.ctx=this.canvas.getContext("2d",{desynchronized:!0}),this.t1=performance.now()},async pull(t){if("ended"==e.readyState)return t.close();const r=e.getSettings().frameRate||30;for(;performance.now()-this.t1<1e3/r;)if(await new Promise(t=>requestAnimationFrame(t)),"ended"==e.readyState)return t.close();this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,this.t1=performance.now(),this.ctx.drawImage(this.video,0,0),t.enqueue(new VideoFrame(this.canvas,{timestamp:this.t1}))}}):"audio"==e.kind&&(this.readable=new ReadableStream({async start(t){e.addEventListener("ended",()=>t.close(),{once:!0}),this.ac=new AudioContext,this.arrays=[],await this.ac.audioWorklet.addModule(`data:text/javascript,(${function(){registerProcessor("mstp-shim",class extends AudioWorkletProcessor{process(t){return this.port.postMessage(t),!0}})}.toString()})()`),this.node=new AudioWorkletNode(this.ac,"mstp-shim"),this.ac.createMediaStreamSource(new MediaStream([e])).connect(this.node),this.node.port.addEventListener("message",({data:t})=>t[0][0]&&this.arrays.push(t))},async pull(t){if("ended"==e.readyState)return t.close();for(;!this.arrays.length;)if(await new Promise(t=>this.node.port.onmessage=t),"ended"==e.readyState)return t.close();const[r]=this.arrays.shift(),n=new Float32Array(r.reduce((t,e)=>t+e.length,0));r.reduce((t,e)=>(n.set(e,t),t+e.length),0),t.enqueue(new AudioData({format:"f32-planar",sampleRate:this.ac.sampleRate,numberOfFrames:r[0].length,numberOfChannels:r.length,timestamp:1e6*this.ac.currentTime|0,data:n,transfer:[n.buffer]}))}}))}}).__POLYFILLED=!0,ho)),self.MediaStreamTrackGenerator||(self.MediaStreamTrackGenerator=((po=class{constructor({kind:t}){if("video"==t){const t=document.createElement("canvas"),e=t.getContext("2d",{desynchronized:!0}),r=t.captureStream().getVideoTracks()[0];return r.writable=new WritableStream({write(r){t.width=r.displayWidth,t.height=r.displayHeight,e.drawImage(r,0,0,t.width,t.height),r.close()}}),r}if("audio"==t){const t=new AudioContext,e=t.createMediaStreamDestination(),[r]=e.stream.getAudioTracks();return r.writable=new WritableStream({async start(n){return this.arrays=[],await t.audioWorklet.addModule(`data:text/javascript,(${function(){registerProcessor("mstg-shim",class extends AudioWorkletProcessor{constructor(){super(),this.arrays=[],this.arrayOffset=0,this.port.onmessage=({data:t})=>this.arrays.push(t),this.emptyArray=new Float32Array(0)}process(t,[[e]]){for(let t=0;t<e.length;t++)(!this.array||this.arrayOffset>=this.array.length)&&(this.array=this.arrays.shift()||this.emptyArray,this.arrayOffset=0),e[t]=this.array[this.arrayOffset++]||0;return!0}})}.toString()})()`),this.node=new AudioWorkletNode(t,"mstg-shim"),this.node.connect(e),r},write(t){const e=new Float32Array(t.numberOfFrames*t.numberOfChannels);t.copyTo(e,{planeIndex:0}),this.node.port.postMessage(e,[e.buffer]),t.close()}}),r}}}).__POLYFILLED=!0,po));const nn=new WeakMap,yn=new WeakMap,Zr=new WeakMap,Ei=Symbol("anyProducer"),ys=Promise.resolve(),Ai=Symbol("listenerAdded"),Ti=Symbol("listenerRemoved");let Si=!1,go=!1;const Ri=t=>"string"==typeof t||"symbol"==typeof t||"number"==typeof t;function Rn(t){if(!Ri(t))throw new TypeError("`eventName` must be a string, symbol, or number")}function si(t){if("function"!=typeof t)throw new TypeError("listener must be a function")}function Fn(t,e){const r=yn.get(t);if(r.has(e))return r.get(e)}function $n(t,e){const r=Ri(e)?e:Ei,n=Zr.get(t);if(n.has(r))return n.get(r)}function yu(t,e,r){const n=Zr.get(t);if(n.has(e))for(const t of n.get(e))t.enqueue(r);if(n.has(Ei)){const t=Promise.all([e,r]);for(const e of n.get(Ei))e.enqueue(t)}}function vs(t,e){e=Array.isArray(e)?e:[e];let r=!1,n=()=>{},i=[];const o={enqueue(t){i.push(t),n()},finish(){r=!0,n()}};for(const r of e){let e=$n(t,r);e||(e=new Set,Zr.get(t).set(r,e)),e.add(o)}return{async next(){return i?0===i.length?r?(i=void 0,this.next()):(await new Promise(t=>{n=t}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(r){i=void 0;for(const r of e){const e=$n(t,r);e&&(e.delete(o),0===e.size&&Zr.get(t).delete(r))}return n(),arguments.length>0?{done:!0,value:await r}:{done:!0}},[Symbol.asyncIterator](){return this}}}function bs(t){if(void 0===t)return ws;if(!Array.isArray(t))throw new TypeError("`methodNames` must be an array of strings");for(const e of t)if(!ws.includes(e))throw"string"!=typeof e?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return t}const Un=t=>t===Ai||t===Ti;function ai(t,e,r){if(Un(e))try{Si=!0,t.emit(e,r)}finally{Si=!1}}class tn{static mixin(t,e){return e=bs(e),r=>{if("function"!=typeof r)throw new TypeError("`target` must be function");for(const t of e)if(void 0!==r.prototype[t])throw new Error(`The property \`${t}\` already exists on \`target\``);Object.defineProperty(r.prototype,t,{enumerable:!1,get:function(){return Object.defineProperty(this,t,{enumerable:!1,value:new tn}),this[t]}});const n=e=>function(...r){return this[t][e](...r)};for(const t of e)Object.defineProperty(r.prototype,t,{enumerable:!1,value:n(t)});return r}}static get isDebugEnabled(){if("object"!=typeof globalThis.process?.env)return go;const{env:t}=globalThis.process??{env:{}};return"emittery"===t.DEBUG||"*"===t.DEBUG||go}static set isDebugEnabled(t){go=t}constructor(t={}){nn.set(this,new Set),yn.set(this,new Map),Zr.set(this,new Map),Zr.get(this).set(Ei,new Set),this.debug=t.debug??{},void 0===this.debug.enabled&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,e,r,n)=>{try{n=JSON.stringify(n)}catch{n=`Object with the following keys failed to stringify: ${Object.keys(n).join(",")}`}("symbol"==typeof r||"number"==typeof r)&&(r=r.toString());const i=new Date,o=`${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}.${i.getMilliseconds()}`;console.log(`[${o}][emittery:${t}][${e}] Event Name: ${r}\n\tdata: ${n}`)})}logIfDebugEnabled(t,e,r){(tn.isDebugEnabled||this.debug.enabled)&&this.debug.logger(t,this.debug.name,e,r)}on(t,e,{signal:r}={}){si(e),t=Array.isArray(t)?t:[t];for(const r of t){Rn(r);let t=Fn(this,r);t||(t=new Set,yn.get(this).set(r,t)),t.add(e),this.logIfDebugEnabled("subscribe",r,void 0),Un(r)||ai(this,Ai,{eventName:r,listener:e})}const n=()=>{this.off(t,e),r?.removeEventListener("abort",n)};return r?.addEventListener("abort",n,{once:!0}),r?.aborted&&n(),n}off(t,e){si(e),t=Array.isArray(t)?t:[t];for(const r of t){Rn(r);const t=Fn(this,r);t&&(t.delete(e),0===t.size&&yn.get(this).delete(r)),this.logIfDebugEnabled("unsubscribe",r,void 0),Un(r)||ai(this,Ti,{eventName:r,listener:e})}}once(t,e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("predicate must be a function");let r;const n=new Promise(n=>{r=this.on(t,t=>{e&&!e(t)||(r(),n(t))})});return n.off=r,n}events(t){t=Array.isArray(t)?t:[t];for(const e of t)Rn(e);return vs(this,t)}async emit(t,e){if(Rn(t),Un(t)&&!Si)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",t,e),yu(this,t,e);const r=Fn(this,t)??new Set,n=nn.get(this),i=[...r],o=Un(t)?[]:[...n];await ys,await Promise.all([...i.map(async t=>{if(r.has(t))return t(e)}),...o.map(async r=>{if(n.has(r))return r(t,e)})])}async emitSerial(t,e){if(Rn(t),Un(t)&&!Si)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",t,e);const r=Fn(this,t)??new Set,n=nn.get(this),i=[...r],o=[...n];await ys;for(const t of i)r.has(t)&&await t(e);for(const r of o)n.has(r)&&await r(t,e)}onAny(t,{signal:e}={}){si(t),this.logIfDebugEnabled("subscribeAny",void 0,void 0),nn.get(this).add(t),ai(this,Ai,{listener:t});const r=()=>{this.offAny(t),e?.removeEventListener("abort",r)};return e?.addEventListener("abort",r,{once:!0}),e?.aborted&&r(),r}anyEvent(){return vs(this)}offAny(t){si(t),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),ai(this,Ti,{listener:t}),nn.get(this).delete(t)}clearListeners(t){t=Array.isArray(t)?t:[t];for(const e of t)if(this.logIfDebugEnabled("clear",e,void 0),Ri(e)){const t=Fn(this,e);t&&t.clear();const r=$n(this,e);if(r){for(const t of r)t.finish();r.clear()}}else{nn.get(this).clear();for(const[t,e]of yn.get(this).entries())e.clear(),yn.get(this).delete(t);for(const[t,e]of Zr.get(this).entries()){for(const t of e)t.finish();e.clear(),Zr.get(this).delete(t)}}}listenerCount(t){t=Array.isArray(t)?t:[t];let e=0;for(const r of t)if(Ri(r))e+=nn.get(this).size+(Fn(this,r)?.size??0)+($n(this,r)?.size??0)+($n(this)?.size??0);else{void 0!==r&&Rn(r),e+=nn.get(this).size;for(const t of yn.get(this).values())e+=t.size;for(const t of Zr.get(this).values())e+=t.size}return e}bindMethods(t,e){if("object"!=typeof t||null===t)throw new TypeError("`target` must be an object");e=bs(e);for(const r of e){if(void 0!==t[r])throw new Error(`The property \`${r}\` already exists on \`target\``);Object.defineProperty(t,r,{enumerable:!1,value:this[r].bind(this)})}}}const ws=Object.getOwnPropertyNames(tn.prototype).filter(t=>"constructor"!==t);Object.defineProperty(tn,"listenerAdded",{value:Ai,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(tn,"listenerRemoved",{value:Ti,writable:!1,enumerable:!0,configurable:!1});var vu=Object.defineProperty,bu=(t,e,r)=>e in t?vu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wu=(t,e,r)=>(bu(t,e+"",r),r);const xu="hlg.tokbox.com/prod/logging/vcp_webrtc",_u="https://",Eu=1e4;let ui;const Au=new Uint8Array(16);function Tu(){if(!ui&&(ui=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ui))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ui(Au)}const Ur=[];for(let t=0;t<256;++t)Ur.push((t+256).toString(16).slice(1));function Su(t,e=0){return(Ur[t[e+0]]+Ur[t[e+1]]+Ur[t[e+2]]+Ur[t[e+3]]+"-"+Ur[t[e+4]]+Ur[t[e+5]]+"-"+Ur[t[e+6]]+Ur[t[e+7]]+"-"+Ur[t[e+8]]+Ur[t[e+9]]+"-"+Ur[t[e+10]]+Ur[t[e+11]]+Ur[t[e+12]]+Ur[t[e+13]]+Ur[t[e+14]]+Ur[t[e+15]]).toLowerCase()}const Ru=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),xs={randomUUID:Ru};function Fu(t,e,r){if(xs.randomUUID&&!t)return xs.randomUUID();const n=(t=t||{}).random||(t.rng||Tu)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,Su(n)}function Bo(t,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let r=globalThis.vonage.workerizer;return r[t]||(r[t]=e),r[t]}const un=Bo("globals",{});var wn=(t=>(t.INIT="INIT",t.FORWARD="FORWARD",t.TERMINATE="TERMINATE",t.GLOBALS_SYNC="GLOBALS_SYNC",t))(wn||{});function ea(t){return[ImageBitmap,ReadableStream,WritableStream].some(e=>t instanceof e)}let Ou=0;function Iu(t,e,r,n,i){const o=Ou++;return t.postMessage({id:o,type:e,functionName:r,args:n},n.filter(t=>ea(t))),new Promise(t=>{i?.set(o,t)})}function qn(t,e){const{id:r,type:n}=t,i=Array.isArray(e)?e:[e];postMessage({id:r,type:n,result:e},i.filter(t=>ea(t)))}const _s=Bo("workerized",{});function ta(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function ku(){if(ta())qn({type:wn.GLOBALS_SYNC},un);else{const t=[];for(const e in _s){const{worker:r,resolvers:n}=_s[e].workerContext;r&&t.push(Iu(r,wn.GLOBALS_SYNC,"",[un],n))}await Promise.all(t)}}function Fi(t,e){if(Array.isArray(e))e.splice(0,e.length);else if("object"==typeof e)for(const t in e)delete e[t];for(const r in t)Array.isArray(t[r])?(e[r]=[],Fi(t[r],e[r])):"object"==typeof t[r]?(e[r]={},Fi(t[r],e[r])):e[r]=t[r]}async function Pu(t,e){const{functionName:r,args:n}=t;if(!e.instance)throw"instance not initialized";if(!r)throw"missing function name to call";if(!e.instance[r])throw`undefined function [${r}] in class ${e.instance.constructor.workerId}`;qn(t,await e.instance[r](...n??[]))}const Cu=Bo("registeredWorkers",{});function Mu(t,e){if(!t.args)throw"Missing className while initializing worker";const[r,n]=t.args,i=Cu[r];if(!i)throw`unknown worker class ${r}`;e.instance=new i(t.args.slice(1)),Fi(n,un),qn(t,void 0!==typeof e.instance)}async function Lu(t,e){const{args:r}=t;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...r??[])),qn(t,n)}function ju(t){if(!t.args)throw"Missing globals while syncing";Fi(t.args[0],un),qn(t,{})}function Uu(){const t={};onmessage=async e=>{const r=e.data;switch(r.type){case wn.INIT:Mu(r,t);break;case wn.FORWARD:Pu(r,t);break;case wn.TERMINATE:Lu(r,t);break;case wn.GLOBALS_SYNC:ju(r)}}}function Bu(t,e){return un[t]||(un[t]=e),[()=>un[t],async e=>{un[t]=e,await ku()}]}function Nu(t,e){return Bu(t,e)}ta()&&Uu();const[Du,Gu]=Nu("metadata");function Wu(t){Gu(t)}function wi(){return Du()}let No=class{constructor(t,e){wu(this,"uuid"),this.config=t,this.uuid=e??Fu()}async send(t){var e,r,n;const{appId:i,sourceType:o}=null!=(e=wi())?e:{};if(!i||!o)return"metadata missing";const a=new AbortController,s=setTimeout(()=>a.abort(),Eu);return await(null!=(n=null==(r=this.config)?void 0:r.fetch)?n:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(t)),signal:a.signal}),clearTimeout(s),"success"}getUrl(){var t;let e=null!=(t=wi().proxyUrl)?t:_u;return e+=("/"===e.at(-1)?"":"/")+xu,e}getHeaders(){return{"Content-Type":"application/json"}}buildReport(t){const e=wi();return{guid:this.uuid,...t,applicationId:e.appId,timestamp:Date.now(),proxyUrl:e.proxyUrl,source:e.sourceType}}};const xi="3.0.0-alpha.2",Eo=class{};Eo.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},Eo.errors={transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer",readable_null:"Readable is null",writable_null:"Writable is null"};let xn=Eo;function zu(t){return"object"==typeof t&&null!==t&&"message"in t&&"string"==typeof t.message}function Hu(t){if(zu(t))return t;try{return new Error(JSON.stringify(t))}catch{return new Error(String(t))}}function mo(t){return Hu(t).message}class Vu{constructor(t,e){this.config=t,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new No(t,e)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:t,frameFromSourceCount:e}=this;return e/((Date.now()-t)/1e3)}async onFrameTransformed(t={},e=!1){0===this.startAt&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:r,frameTransformedCount:n,frameFromSourceCount:i}=this,o=Date.now(),a=(o-r)/1e3,s=n/a,u=i/a;return e||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:u,transformedFps:s,framesTransformed:n,...t})):"success"}}var $u=(t=>(t.FPS_DROP="fps_drop",t))($u||{}),Yu=(t=>(t.start="start",t.transform="transform",t.flush="flush",t))(Yu||{}),Ao=(t=>(t.pipeline_ended="pipeline_ended",t.pipeline_ended_with_error="pipeline_ended_with_error",t.pipeline_started="pipeline_started",t.pipeline_started_with_error="pipeline_started_with_error",t.pipeline_restarted="pipeline_restarted",t.pipeline_restarted_with_error="pipeline_restarted_with_error",t))(Ao||{});const Xu=500,Ku=.8;class Qu extends tn{constructor(t,e){super(),this.reporter_=new No,this.reporterQos_=new Vu({loggingIntervalFrameCount:Xu,report:{version:xi}}),this.index_=e,this.transformer_=t,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in t&&(this.transformerType_=t.getTransformerType()),this.report({variation:"Create"})}setTrackExpectedRate(t){this.trackExpectedRate_=t}async start(t){if(this.controller_=t,this.transformer_&&"function"==typeof this.transformer_.start)try{await this.transformer_.start(t)}catch(t){this.report({message:xn.errors.transformer_start,variation:"Error",error:mo(t)});const e={eventMetaData:{transformerIndex:this.index_},error:t,function:"start"};this.emit("error",e)}}async transform(t,e){if(0===this.mediaTransformerQosReportStartTimestamp_&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),t instanceof VideoFrame&&(this.videoHeight_=t?.displayHeight??0,this.videoWidth_=t?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),t.close(),this.flush(e),e.terminate();else{try{await(this.transformer_.transform?.(t,e)),this.reportQos()}catch(t){this.report({message:xn.errors.transformer_transform,variation:"Error",error:mo(t)});const e={eventMetaData:{transformerIndex:this.index_},error:t,function:"transform"};this.emit("error",e)}if(-1!=this.trackExpectedRate_&&this.trackExpectedRate_*Ku>this.reporterQos_.fps){const t={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",t)}}}async flush(t){if(this.transformer_&&"function"==typeof this.transformer_.flush&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(t)}catch(t){this.report({message:xn.errors.transformer_flush,variation:"Error",error:mo(t)});const e={eventMetaData:{transformerIndex:this.index_},error:t,function:"flush"};this.emit("error",e)}}this.reportQos(!0),this.report({variation:"Delete"})}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),this.shouldStop_=!0}report(t){this.reporter_.send({version:xi,action:"MediaTransformer",transformerType:this.transformerType_,...t})}reportQos(t=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:xi,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},t)}}class Ju extends tn{constructor(t){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let e=0;e<t.length;e++){let r=new Qu(t[e],e);r.on("error",t=>{this.emit("error",t)}),r.on("warn",t=>{this.emit("warn",t)}),this.transformers_.push(r)}}setTrackExpectedRate(t){this.trackExpectedRate_=t;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(t,e){if(this.transformers_&&0!==this.transformers_.length){try{let r=t;for(let e of this.transformers_)t=t.pipeThrough(new TransformStream(e));t.pipeTo(e).then(async()=>{console.log("[Pipeline] Setup."),await e.abort(),await r.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async n=>{t.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(t=>{console.error("[Pipeline] Error from stream transform:",t)}),await e.abort(n),await r.cancel(n),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{return this.emit("pipelineInfo","pipeline_started_with_error"),void this.destroy()}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}else console.log("[Pipeline] No transformers.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let t of this.transformers_)t.stop()}}class ra extends tn{constructor(){super(),this.reporter_=new No,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(t){this.trackExpectedRate_=t,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(t,e){if(this.isTrack(t)){if("video"===t.kind){const e=new MediaStreamTrackProcessor({track:t}),r=new VideoTrackGenerator;return this.readable_=e.readable,this.writable_=r.writable,await this.transformInternal(),r.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}return this.readable_=t,this.writable_=e,this.transformInternal()}transformInternal(){return new Promise(async(t,e)=>{if(!this.transformers_||0===this.transformers_.length)return this.report({message:xn.errors.transformer_none,variation:"Error"}),void e("[MediaProcessor] Need to set transformers.");if(!this.readable_)return this.report({variation:"Error",message:xn.errors.readable_null}),void e("[MediaProcessor] Readable is null.");if(!this.writable_)return this.report({variation:"Error",message:xn.errors.writable_null}),void e("[MediaProcessor] Writable is null.");let r=!1;this.pipeline_&&(r=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Ju(this.transformers_),this.pipeline_.on("warn",t=>{this.emit("warn",t)}),this.pipeline_.on("error",t=>{this.emit("error",t)}),this.pipeline_.on("pipelineInfo",t=>{r&&("pipeline_started"===t?t=Ao.pipeline_restarted:"pipeline_started_with_error"===t&&(t=Ao.pipeline_restarted_with_error)),this.emit("pipelineInfo",t)}),-1!=this.trackExpectedRate_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{t()}).catch(t=>{e(t)})})}setTransformers(t){return this.report({variation:"Update",message:xn.updates.transformer_new}),this.transformers_=t,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async t=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),t()})}report(t){this.reporter_.send({version:xi,action:"MediaProcessor",...t})}isTrack(t){return"kind"in t}}class Zu{constructor(){this.processor_=null,this.generator_=null}init(t){return new Promise((e,r)=>{try{this.processor_=new MediaStreamTrackProcessor(t)}catch(t){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${t}`),r(t)}try{"audio"===t.kind?this.generator_=new MediaStreamTrackGenerator({kind:"audio"}):"video"===t.kind?this.generator_=new MediaStreamTrackGenerator({kind:"video"}):r("kind not supported")}catch(t){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${t}`),r(t)}e()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class qu{constructor(t){this.mediaProcessor_=t}async setTrack(t){if(!(this.mediaProcessor_ instanceof ra)&&await qs()){if("audio"===t.kind)throw Error("Cannot process audio tracks inside a web worker when passing a track to transform");return await this.mediaProcessor_.transform(t)}if(Zs()){const e=new Zu;return await e.init(t),await this.mediaProcessor_.transform(e.getReadable(),e.getWriteable()),e.getProccesorTrack()}throw Error("MediaStreamTrack API for Insertable Streams of Media is not supported")}destroy(){return new Promise((t,e)=>{this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>{t()}).catch(t=>{e(t)}):e("no processor")})}}var _i=(t=>(t.Low="Low",t.High="High",t))(_i||{}),ec=(t=>(t.BackgroundBlur="BackgroundBlur",t.VirtualBackground="VirtualBackground",t.VideoBackground="VideoBackground",t.SilhouetteBlur="SilhouetteBlur",t))(ec||{}),To=(t=>(t.FAST="FAST",t.PRECISE="PRECISE",t))(To||{}),Oi=(t=>(t.CANVAS="CANVAS",t.WEBGL="WEBGL",t))(Oi||{});const tc=async()=>WebAssembly.validate(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 G3(){const{wasm:t,insertableStreams:e,simd:r,webgl:n}=await rc();if(!t.supported)throw t.message;if(!e.supported)throw e.message;if(!r.supported)throw r.message;if(!n.supported)throw n.message}async function rc(){const t={wasm:{supported:"object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate,message:"Your browser does not support WebAssembly features."},simd:{supported:await tc(),message:"Your browser does not support simd features."},insertableStreams:{supported:!0},gpu:{message:"Your browser does not support gpu features.",supported:!0},webgl:nc(),performance:na()};try{await gu()}catch(e){t.insertableStreams.supported=!1,t.insertableStreams.message=e}return t}function nc(){if(!OffscreenCanvas)return{supported:!1,message:"Your browser does not support offscreen canvas"};const t=new OffscreenCanvas(0,0).getContext("webgl2");if(!t)return{supported:!1,message:"Your browser does not support webgl 2"};{const e=t?.getExtension("WEBGL_lose_context");e&&e.loseContext()}return{supported:!0}}function na(){const t=new OffscreenCanvas(0,0).getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(!t)return{supported:!1,message:"Your hardware does not perform good enough to run the library efficiently"};{const e=t?.getExtension("WEBGL_lose_context");e&&e.loseContext()}return{supported:!0}}const Ii={};(function(){var t;function e(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var r="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,r){return t==Array.prototype||t==Object.prototype||(t[e]=r.value),t};var n=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var e=0;e<t.length;++e){var r=t[e];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);function i(t,e){if(e)t:{var i=n;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];if(!(a in i))break t;i=i[a]}(e=e(o=i[t=t[t.length-1]]))!=o&&null!=e&&r(i,t,{configurable:!0,writable:!0,value:e})}}function o(t){return(t={next:t})[Symbol.iterator]=function(){return this},t}function a(t){var r=typeof Symbol<"u"&&Symbol.iterator&&t[Symbol.iterator];return r?r.call(t):{next:e(t)}}function s(t){if(!(t instanceof Array)){t=a(t);for(var e,r=[];!(e=t.next()).done;)r.push(e.value);t=r}return t}i("Symbol",function(t){function e(t,e){this.g=t,r(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;e.prototype.toString=function(){return this.g};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",i=0;return function t(r){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(n+(r||"")+"_"+i++,r)}}),i("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var i="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),a=0;a<i.length;a++){var s=n[i[a]];"function"==typeof s&&"function"!=typeof s.prototype[t]&&r(s.prototype,t,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return t});var u,c="function"==typeof Object.create?Object.create:function(t){function e(){}return e.prototype=t,new e};if("function"==typeof Object.setPrototypeOf)u=Object.setPrototypeOf;else{var l;t:{var f={};try{f.__proto__={a:!0},l=f.a;break t}catch{}l=!1}u=l?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var h=u;function d(t,e){if(t.prototype=c(e.prototype),t.prototype.constructor=t,h)h(t,e);else for(var r in e)if("prototype"!=r)if(Object.defineProperties){var n=Object.getOwnPropertyDescriptor(e,r);n&&Object.defineProperty(t,r,n)}else t[r]=e[r];t.ea=e.prototype}function g(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function p(t){if(t.l)throw new TypeError("Generator is already running");t.l=!0}function m(t,e){t.j={U:e,V:!0},t.g=t.m||t.s}function y(t,e,r){return t.g=r,{value:e}}function v(t){this.g=new g,this.h=t}function b(t,e,r,n){try{var i=e.call(t.g.i,r);if(!(i instanceof Object))throw new TypeError("Iterator result "+i+" is not an object");if(!i.done)return t.g.l=!1,i;var o=i.value}catch(e){return t.g.i=null,m(t.g,e),w(t)}return t.g.i=null,n.call(t.g,o),w(t)}function w(t){for(;t.g.g;)try{var e=t.h(t.g);if(e)return t.g.l=!1,{value:e.value,done:!1}}catch(e){t.g.h=void 0,m(t.g,e)}if(t.g.l=!1,t.g.j){if(e=t.g.j,t.g.j=null,e.V)throw e.U;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function x(t){this.next=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.next,e,t.g.o):(t.g.o(e),e=w(t)),e},this.throw=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.throw,e,t.g.o):(m(t.g,e),e=w(t)),e},this.return=function(e){return function(t,e){p(t.g);var r=t.g.i;return r?b(t,"return"in r?r.return:function(t){return{value:t,done:!0}},e,t.g.return):(t.g.return(e),w(t))}(t,e)},this[Symbol.iterator]=function(){return this}}function A(t,e){return e=new x(new v(e)),h&&t.prototype&&h(e,t.prototype),e}g.prototype.o=function(t){this.h=t},g.prototype.return=function(t){this.j={return:t},this.g=this.s};var _="function"==typeof Object.assign?Object.assign:function(t,e){for(var r=1;r<arguments.length;r++){var n=arguments[r];if(n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};i("Object.assign",function(t){return t||_}),i("Promise",function(t){function e(t){this.h=0,this.i=void 0,this.g=[],this.o=!1;var e=this.j();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function r(){this.g=null}function i(t){return t instanceof e?t:new e(function(e){e(t)})}if(t)return t;r.prototype.h=function(t){if(null==this.g){this.g=[];var e=this;this.i(function(){e.l()})}this.g.push(t)};var o=n.setTimeout;r.prototype.i=function(t){o(t,0)},r.prototype.l=function(){for(;this.g&&this.g.length;){var t=this.g;this.g=[];for(var e=0;e<t.length;++e){var r=t[e];t[e]=null;try{r()}catch(t){this.j(t)}}}this.g=null},r.prototype.j=function(t){this.i(function(){throw t})},e.prototype.j=function(){function t(t){return function(n){r||(r=!0,t.call(e,n))}}var e=this,r=!1;return{resolve:t(this.C),reject:t(this.l)}},e.prototype.C=function(t){if(t===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.F(t);else{t:switch(typeof t){case"object":var r=null!=t;break t;case"function":r=!0;break t;default:r=!1}r?this.u(t):this.m(t)}},e.prototype.u=function(t){var e=void 0;try{e=t.then}catch(t){return void this.l(t)}"function"==typeof e?this.G(e,t):this.m(t)},e.prototype.l=function(t){this.s(2,t)},e.prototype.m=function(t){this.s(1,t)},e.prototype.s=function(t,e){if(0!=this.h)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.h);this.h=t,this.i=e,2===this.h&&this.D(),this.A()},e.prototype.D=function(){var t=this;o(function(){if(t.B()){var e=n.console;typeof e<"u"&&e.error(t.i)}},1)},e.prototype.B=function(){if(this.o)return!1;var t=n.CustomEvent,e=n.Event,r=n.dispatchEvent;return typeof r>"u"||("function"==typeof t?t=new t("unhandledrejection",{cancelable:!0}):"function"==typeof e?t=new e("unhandledrejection",{cancelable:!0}):(t=n.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,t),t.promise=this,t.reason=this.i,r(t))},e.prototype.A=function(){if(null!=this.g){for(var t=0;t<this.g.length;++t)s.h(this.g[t]);this.g=null}};var s=new r;return e.prototype.F=function(t){var e=this.j();t.J(e.resolve,e.reject)},e.prototype.G=function(t,e){var r=this.j();try{t.call(e,r.resolve,r.reject)}catch(t){r.reject(t)}},e.prototype.then=function(t,r){function n(t,e){return"function"==typeof t?function(e){try{i(t(e))}catch(t){o(t)}}:e}var i,o,a=new e(function(t,e){i=t,o=e});return this.J(n(t,i),n(r,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.J=function(t,e){function r(){switch(n.h){case 1:t(n.i);break;case 2:e(n.i);break;default:throw Error("Unexpected state: "+n.h)}}var n=this;null==this.g?s.h(r):this.g.push(r),this.o=!0},e.resolve=i,e.reject=function(t){return new e(function(e,r){r(t)})},e.race=function(t){return new e(function(e,r){for(var n=a(t),o=n.next();!o.done;o=n.next())i(o.value).J(e,r)})},e.all=function(t){var r=a(t),n=r.next();return n.done?i([]):new e(function(t,e){function o(e){return function(r){a[e]=r,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,i(n.value).J(o(a.length-1),e),n=r.next()}while(!n.done)})},e}),i("Object.is",function(t){return t||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}}),i("Array.prototype.includes",function(t){return t||function(t,e){var r=this;r instanceof String&&(r=String(r));var n=r.length;for(0>(e=e||0)&&(e=Math.max(e+n,0));e<n;e++){var i=r[e];if(i===t||Object.is(i,t))return!0}return!1}}),i("String.prototype.includes",function(t){return t||function(t,e){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(t,e||0)}}),i("Array.prototype.keys",function(t){return t||function(){return function(t,e){t instanceof String&&(t+="");var r=0,n=!1,i={next:function(){if(!n&&r<t.length){var i=r++;return{value:e(i,t[i]),done:!1}}return n=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,function(t){return t})}});var E=this||self;function T(t,e){t=t.split(".");var r,n=E;t[0]in n||typeof n.execScript>"u"||n.execScript("var "+t[0]);for(;t.length&&(r=t.shift());)t.length||void 0===e?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=e}function k(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}var S,F,O=typeof TextDecoder<"u",R=typeof TextEncoder<"u";function I(t){if(R)t=(F||(F=new TextEncoder)).encode(t);else{var e=void 0;e=void 0!==e&&e;for(var r=0,n=new Uint8Array(3*t.length),i=0;i<t.length;i++){var o=t.charCodeAt(i);if(128>o)n[r++]=o;else{if(2048>o)n[r++]=o>>6|192;else{if(55296<=o&&57343>=o){if(56319>=o&&i<t.length){var a=t.charCodeAt(++i);if(56320<=a&&57343>=a){o=1024*(o-55296)+a-56320+65536,n[r++]=o>>18|240,n[r++]=o>>12&63|128,n[r++]=o>>6&63|128,n[r++]=63&o|128;continue}i--}if(e)throw Error("Found an unpaired surrogate");o=65533}n[r++]=o>>12|224,n[r++]=o>>6&63|128}n[r++]=63&o|128}}t=n.subarray(0,r)}return t}var P={},j=null;function C(t,e){void 0===e&&(e=0),L(),e=P[e];for(var r=Array(Math.floor(t.length/3)),n=e[64]||"",i=0,o=0;i<t.length-2;i+=3){var a=t[i],s=t[i+1],u=t[i+2],c=e[a>>2];a=e[(3&a)<<4|s>>4],s=e[(15&s)<<2|u>>6],u=e[63&u],r[o++]=c+a+s+u}switch(c=0,u=n,t.length-i){case 2:u=e[(15&(c=t[i+1]))<<2]||n;case 1:t=t[i],r[o]=e[t>>2]+e[(3&t)<<4|c>>4]+u+n}return r.join("")}function M(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){var r=t.charAt(n++),i=j[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}L();for(var n=0;;){var i=r(-1),o=r(0),a=r(64),s=r(64);if(64===s&&-1===i)break;e(i<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,function(t){n[i++]=t}),n.subarray(0,i)}function L(){if(!j){j={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));P[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===j[o]&&(j[o]=i)}}}}var B,U="function"==typeof Uint8Array.prototype.slice;function N(t,e,r){return e===r?B||(B=new Uint8Array(0)):U?t.slice(e,r):new Uint8Array(t.subarray(e,r))}var D=0;function z(t,e){e=void 0!==(e=void 0===e?{}:e).v&&e.v,this.h=null,this.g=this.i=this.j=0,this.l=!1,this.v=e,t&&G(this,t)}function G(t,e){e=e.constructor===Uint8Array?e:e.constructor===ArrayBuffer||e.constructor===Array?new Uint8Array(e):e.constructor===String?M(e):e instanceof Uint8Array?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t.h=e,t.j=0,t.i=t.h.length,t.g=t.j}function W(t){var e=t.h,r=e[t.g],n=127&r;return 128>r?(t.g+=1,n):(n|=(127&(r=e[t.g+1]))<<7,128>r?(t.g+=2,n):(n|=(127&(r=e[t.g+2]))<<14,128>r?(t.g+=3,n):(n|=(127&(r=e[t.g+3]))<<21,128>r?(t.g+=4,n):(n|=(15&(r=e[t.g+4]))<<28,128>r?(t.g+=5,n>>>0):(t.g+=5,128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&t.g++,n)))))}function H(t){var e=t.h[t.g],r=t.h[t.g+1],n=t.h[t.g+2],i=t.h[t.g+3];return t.g+=4,t=2*((r=(e|r<<8|n<<16|i<<24)>>>0)>>31)+1,e=r>>>23&255,r&=8388607,255==e?r?NaN:1/0*t:0==e?t*Math.pow(2,-149)*r:t*Math.pow(2,e-150)*(r+Math.pow(2,23))}z.prototype.reset=function(){this.g=this.j};var V=[];function $(){this.g=new Uint8Array(64),this.h=0}function Y(t,e){for(;127<e;)t.push(127&e|128),e>>>=7;t.push(e)}function X(t){var e={},r=void 0!==e.N&&e.N;this.o={v:void 0!==e.v&&e.v},this.N=r,e=this.o,V.length?(r=V.pop(),e&&(r.v=e.v),t&&G(r,t),t=r):t=new z(t,e),this.g=t,this.m=this.g.g,this.h=this.i=this.l=-1,this.j=!1}function q(t){var e=t.g;if((e=e.g==e.i)||(e=t.j)||(e=(e=t.g).l||0>e.g||e.g>e.i),e)return!1;t.m=t.g.g;var r=7&(e=W(t.g));return 0!=r&&5!=r&&1!=r&&2!=r&&3!=r&&4!=r?(t.j=!0,!1):(t.i=e,t.l=e>>>3,t.h=r,!0)}function K(t){switch(t.h){case 0:if(0!=t.h)K(t);else{for(t=t.g;128&t.h[t.g];)t.g++;t.g++}break;case 1:1!=t.h?K(t):(t=t.g).g+=8;break;case 2:if(2!=t.h)K(t);else{var e=W(t.g);(t=t.g).g+=e}break;case 5:5!=t.h?K(t):(t=t.g).g+=4;break;case 3:for(e=t.l;;){if(!q(t)){t.j=!0;break}if(4==t.h){t.l!=e&&(t.j=!0);break}K(t)}break;default:t.j=!0}}function Q(t,e,r){var n=t.g.i,i=W(t.g);return i=t.g.g+i,t.g.i=i,r(e,t),t.g.g=i,t.g.i=n,e}function J(t){var e,r=W(t.g),n=(t=t.g).g;if(t.g+=r,t=t.h,O)(e=S)||(e=S=new TextDecoder("utf-8",{fatal:!1})),e=e.decode(t.subarray(n,n+r));else{r=n+r;for(var i,o,a,s=[],u=null;n<r;)128>(i=t[n++])?s.push(i):224>i?n>=r?s.push(65533):(o=t[n++],194>i||128!=(192&o)?(n--,s.push(65533)):s.push((31&i)<<6|63&o)):240>i?n>=r-1?s.push(65533):128!=(192&(o=t[n++]))||224===i&&160>o||237===i&&160<=o||128!=(192&(e=t[n++]))?(n--,s.push(65533)):s.push((15&i)<<12|(63&o)<<6|63&e):244>=i?n>=r-2?s.push(65533):128!=(192&(o=t[n++]))||o-144+(i<<28)>>30||128!=(192&(e=t[n++]))||128!=(192&(a=t[n++]))?(n--,s.push(65533)):(i=(7&i)<<18|(63&o)<<12|(63&e)<<6|63&a,i-=65536,s.push(55296+(i>>10&1023),56320+(1023&i))):s.push(65533),8192<=s.length&&(u=k(u,s),s.length=0);e=k(u,s)}return e}function Z(){this.h=[],this.i=0,this.g=new $}function tt(t,e){0!==e.length&&(t.h.push(e),t.i+=e.length)}function et(t){var e=t.i+t.g.length();if(0===e)return new Uint8Array(0);e=new Uint8Array(e);for(var r=t.h,n=r.length,i=0,o=0;o<n;o++){var a=r[o];0!==a.length&&(e.set(a,i),i+=a.length)}return 0!==(n=(r=t.g).h)&&(e.set(r.g.subarray(0,n),i),r.h=0),t.h=[e],e}function rt(t,e,r){if(null!=r){Y(t.g,8*e+5),t=t.g;var n=r;0===(n=(r=0>n?1:0)?-n:n)?0<1/n?D=0:D=2147483648:isNaN(n)?D=2147483647:34028234663852886e22<n?D=(r<<31|2139095040)>>>0:11754943508222875e-54>n?(n=Math.round(n/Math.pow(2,-149)),D=(r<<31|n)>>>0):(e=Math.floor(Math.log(n)/Math.LN2),n*=Math.pow(2,-e),n=8388607&Math.round(8388608*n),D=(r<<31|e+127<<23|n)>>>0),r=D,t.push(r>>>0&255),t.push(r>>>8&255),t.push(r>>>16&255),t.push(r>>>24&255)}}$.prototype.push=function(t){if(!(this.h+1<this.g.length)){var e=this.g;this.g=new Uint8Array(Math.ceil(1+2*this.g.length)),this.g.set(e)}this.g[this.h++]=t},$.prototype.length=function(){return this.h},$.prototype.end=function(){var t=this.g,e=this.h;return this.h=0,N(t,0,e)},X.prototype.reset=function(){this.g.reset(),this.h=this.l=-1};var nt="function"==typeof Uint8Array;function it(t,e,r){if(null!=t)return"object"==typeof t?nt&&t instanceof Uint8Array?r(t):ot(t,e,r):e(t)}function ot(t,e,r){if(Array.isArray(t)){for(var n=Array(t.length),i=0;i<t.length;i++)n[i]=it(t[i],e,r);return Array.isArray(t)&&t.W&&ct(n),n}for(i in n={},t)n[i]=it(t[i],e,r);return n}function at(t){return"number"==typeof t?isFinite(t)?t:String(t):t}var st,ut={W:{value:!0,configurable:!0}};function ct(t){return Array.isArray(t)&&!Object.isFrozen(t)&&Object.defineProperties(t,ut),t}function lt(t,e,r){var n=st;if(st=null,t||(t=n),n=this.constructor.ca,t||(t=n?[n]:[]),this.j=n?0:-1,this.i=null,this.g=t,t=(n=this.g.length)-1,n&&null!==(n=this.g[t])&&"object"==typeof n&&n.constructor===Object?(this.l=t-this.j,this.h=n):void 0!==e&&-1<e?(this.l=Math.max(e,t+1-this.j),this.h=null):this.l=Number.MAX_VALUE,r)for(e=0;e<r.length;e++)(t=r[e])<this.l?(t+=this.j,(n=this.g[t])?ct(n):this.g[t]=ft):(ht(this),(n=this.h[t])?ct(n):this.h[t]=ft)}var ft=Object.freeze(ct([]));function ht(t){var e=t.l+t.j;t.g[e]||(t.h=t.g[e]={})}function dt(t,e,r){return-1===e?null:void 0!==r&&r||e>=t.l?t.h?t.h[e]:void 0:t.g[e+t.j]}function gt(t){var e=void 0!==e&&e,r=dt(t,1,e);return null==r&&(r=ft),r===ft&&mt(t,1,r=ct([]),e),r}function pt(t,e,r){return(t=null==(t=dt(t,e))?t:+t)??(void 0===r?0:r)}function mt(t,e,r,n){void 0!==n&&n||e>=t.l?(ht(t),t.h[e]=r):t.g[e+t.j]=r}function yt(t,e){t.i||(t.i={});var r=t.i[1];if(!r){var n=gt(t);r=[];for(var i=0;i<n.length;i++)r[i]=new e(n[i]);t.i[1]=r}return r}function vt(t,e,r,n){var i=yt(t,r);e=e||new r,t=gt(t),null!=n?(i.splice(n,0,e),t.splice(n,0,bt(e))):(i.push(e),t.push(bt(e)))}function bt(t,e){if(t.i)for(var r in t.i){var n=t.i[r];if(Array.isArray(n))for(var i=0;i<n.length;i++)n[i]&&bt(n[i]);else n&&bt(n)}return t.g}function wt(t,e){return(t=dt(t,e))??0}function xt(t,e){return(t=dt(t,e))??""}function At(t,e){if(t=t.m){tt(e,e.g.end());for(var r=0;r<t.length;r++)tt(e,t[r])}}function _t(t,e){if(4==e.h)return!1;var r=e.m;return K(e),e.N||(e=N(e.g.h,r,e.g.g),(r=t.m)?r.push(e):t.m=[e]),!0}function Et(t,e){var r=void 0;return new(r||(r=Promise))(function(n,i){function o(t){try{s(e.next(t))}catch(t){i(t)}}function a(t){try{s(e.throw(t))}catch(t){i(t)}}function s(t){t.done?n(t.value):new r(function(e){e(t.value)}).then(o,a)}s((e=e.apply(t,void 0)).next())})}function Tt(t){lt.call(this,t)}function kt(t,e){for(;q(e);)switch(e.i){case 8:var r=W(e.g);mt(t,1,r);break;case 21:mt(t,2,r=H(e.g));break;case 26:mt(t,3,r=J(e));break;case 34:mt(t,4,r=J(e));break;default:if(!_t(t,e))return t}return t}function St(t){lt.call(this,t,-1,Ft)}lt.prototype.toJSON=function(){return ot(bt(this),at,C)},lt.prototype.toString=function(){return bt(this).toString()},d(Tt,lt),d(St,lt),St.prototype.addClassification=function(t,e){vt(this,t,Tt,e)};var Ft=[1];function Ot(t){lt.call(this,t)}function Rt(t,e){for(;q(e);)switch(e.i){case 13:var r=H(e.g);mt(t,1,r);break;case 21:mt(t,2,r=H(e.g));break;case 29:mt(t,3,r=H(e.g));break;case 37:mt(t,4,r=H(e.g));break;case 45:mt(t,5,r=H(e.g));break;default:if(!_t(t,e))return t}return t}function It(t){lt.call(this,t,-1,Pt)}d(Ot,lt),d(It,lt);var Pt=[1];function jt(t){lt.call(this,t)}function Ct(t,e,r){if(r=t.createShader(0===r?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+t.getShaderInfoLog(r));return r}function Mt(t){return yt(t,Tt).map(function(t){return{index:wt(t,1),Y:pt(t,2),label:null!=dt(t,3)?xt(t,3):void 0,displayName:null!=dt(t,4)?xt(t,4):void 0}})}function Lt(t){return{x:pt(t,1),y:pt(t,2),z:pt(t,3),visibility:null!=dt(t,4)?pt(t,4):void 0}}function Bt(t,e){this.h=t,this.g=e,this.l=0}function Ut(t,e,r){return function(t,e){var r=t.g;if(void 0===t.m){var n=Ct(r,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",0),i=Ct(r,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=r.createProgram();if(r.attachShader(o,n),r.attachShader(o,i),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+r.getProgramInfoLog(o));n=t.m=o,r.useProgram(n),i=r.getUniformLocation(n,"sampler0"),t.j={I:r.getAttribLocation(n,"aVertex"),H:r.getAttribLocation(n,"aTex"),da:i},t.s=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.enableVertexAttribArray(t.j.I),r.vertexAttribPointer(t.j.I,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),t.o=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.enableVertexAttribArray(t.j.H),r.vertexAttribPointer(t.j.H,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.uniform1i(i,0)}n=t.j,r.useProgram(t.m),r.canvas.width=e.width,r.canvas.height=e.height,r.viewport(0,0,e.width,e.height),r.activeTexture(r.TEXTURE0),t.h.bindTexture2d(e.glName),r.enableVertexAttribArray(n.I),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.vertexAttribPointer(n.I,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(n.H),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.vertexAttribPointer(n.H,2,r.FLOAT,!1,0,0),r.bindFramebuffer(r.DRAW_FRAMEBUFFER?r.DRAW_FRAMEBUFFER:r.FRAMEBUFFER,null),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.colorMask(!0,!0,!0,!0),r.drawArrays(r.TRIANGLE_FAN,0,4),r.disableVertexAttribArray(n.I),r.disableVertexAttribArray(n.H),r.bindBuffer(r.ARRAY_BUFFER,null),t.h.bindTexture2d(0)}(t,e),"function"==typeof t.g.canvas.transferToImageBitmap?Promise.resolve(t.g.canvas.transferToImageBitmap()):r?Promise.resolve(t.g.canvas):"function"==typeof createImageBitmap?createImageBitmap(t.g.canvas):(void 0===t.i&&(t.i=document.createElement("canvas")),new Promise(function(e){t.i.height=t.g.canvas.height,t.i.width=t.g.canvas.width,t.i.getContext("2d",{}).drawImage(t.g.canvas,0,0,t.g.canvas.width,t.g.canvas.height),e(t.i)}))}function Nt(t){this.g=t}d(jt,lt);var Dt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function zt(t,e){return e+t}function Gt(t,e){window[t]=e}function Wt(t){if(this.g=t,this.listeners={},this.j={},this.F={},this.m={},this.s={},this.G=this.o=this.R=!0,this.C=Promise.resolve(),this.P="",this.B={},this.locateFile=t&&t.locateFile||zt,"object"==typeof window)var e=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(!(typeof location<"u"))throw Error("solutions can only be loaded on a web page or in a web worker");e=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.S=e,t.options)for(var r=(e=a(Object.keys(t.options))).next();!r.done;r=e.next()){r=r.value;var n=t.options[r].default;void 0!==n&&(this.j[r]="function"==typeof n?n():n)}}function Ht(t){return Et(t,function t(){var e,r,n,i,o,a,u,c,l,f,h,d=this;return A(t,function(t){switch(t.g){case 1:return e=d,d.R?(r=function(t,e){return void 0===t.g.files?[]:"function"==typeof t.g.files?t.g.files(e):t.g.files}(d,d.j),y(t,function(){return Et(this,function t(){return A(t,function(t){switch(t.g){case 1:return t.m=2,y(t,WebAssembly.instantiate(Dt),4);case 4:t.g=3,t.m=0;break;case 2:return t.m=0,t.j=null,t.return(!1);case 3:return t.return(!0)}})})}(),2)):t.return();case 2:if(n=t.h,"object"==typeof window)return Gt("createMediapipeSolutionsWasm",{locateFile:d.locateFile}),Gt("createMediapipeSolutionsPackedAssets",{locateFile:d.locateFile}),a=r.filter(function(t){return void 0!==t.data}),u=r.filter(function(t){return void 0===t.data}),c=Promise.all(a.map(function(t){var r=Vt(e,t.url);if(void 0!==t.path){var n=t.path;r=r.then(function(t){return e.overrideFile(n,t),Promise.resolve(t)})}return r})),l=Promise.all(u.map(function(t){return void 0===t.simd||t.simd&&n||!t.simd&&!n?function(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(t){e.addEventListener("load",function(){t()},!1),e.addEventListener("error",function(){t()},!1),document.body.appendChild(e)})}(e.locateFile(t.url,e.S)):Promise.resolve()})).then(function(){return Et(e,function t(){var e,r,n=this;return A(t,function(t){if(1==t.g)return e=window.createMediapipeSolutionsWasm,r=window.createMediapipeSolutionsPackedAssets,y(t,e(r),2);n.h=t.h,t.g=0})})}),f=Et(e,function t(){var e=this;return A(t,function(t){return e.g.graph&&e.g.graph.url?t=y(t,Vt(e,e.g.graph.url),0):(t.g=0,t=void 0),t})}),y(t,Promise.all([l,c,f]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return i=r.filter(function(t){return void 0===t.simd||t.simd&&n||!t.simd&&!n}).map(function(t){return e.locateFile(t.url,e.S)}),importScripts.apply(null,s(i)),y(t,createMediapipeSolutionsWasm(Module),6);case 6:d.h=t.h,d.l=new OffscreenCanvas(1,1),d.h.canvas=d.l,o=d.h.GL.createContext(d.l,{antialias:!1,alpha:!1,ba:typeof WebGL2RenderingContext<"u"?2:1}),d.h.GL.makeContextCurrent(o),t.g=4;break;case 7:if(d.l=document.createElement("canvas"),!(h=d.l.getContext("webgl2",{}))&&!(h=d.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),t.return();d.D=h,d.h.canvas=d.l,d.h.createContext(d.l,!0,!0,{});case 4:d.i=new d.h.SolutionWasm,d.R=!1,t.g=0}})})}function Vt(t,e){return Et(t,function t(){var r,n,i=this;return A(t,function(t){return e in i.F?t.return(i.F[e]):(r=i.locateFile(e,""),n=fetch(r).then(function(t){return t.arrayBuffer()}),i.F[e]=n,t.return(n))})})}function $t(t,e,r){return Et(t,function t(){var n,i,o,s,u,c,l,f,h,d,g,p,m,v,b=this;return A(t,function(t){switch(t.g){case 1:if(!r)return t.return(e);for(n={},i=0,o=a(Object.keys(r)),s=o.next();!s.done;s=o.next())u=s.value,"string"!=typeof(c=r[u])&&"texture"===c.type&&void 0!==e[c.stream]&&++i;1<i&&(b.G=!1),l=a(Object.keys(r)),s=l.next();case 2:if(s.done){t.g=4;break}if(f=s.value,"string"==typeof(h=r[f]))return m=n,v=f,y(t,function(t,e,r){return Et(t,function t(){var n,i=this;return A(t,function(t){return"number"==typeof r||r instanceof Uint8Array||r instanceof i.h.Uint8BlobList?t.return(r):r instanceof i.h.Texture2dDataOut?((n=i.s[e])||(n=new Bt(i.h,i.D),i.s[e]=n),t.return(Ut(n,r,i.G))):t.return(void 0)})})}(b,f,e[h]),14);if(d=e[h.stream],"detection_list"===h.type){if(d){for(var w=d.getRectList(),x=d.getLandmarksList(),_=d.getClassificationsList(),E=[],T=0;T<w.size();++T){var k=w.get(T);t:{var S=new jt;for(k=new X(k);q(k);)switch(k.i){case 13:var F=H(k.g);mt(S,1,F);break;case 21:mt(S,2,F=H(k.g));break;case 29:mt(S,3,F=H(k.g));break;case 37:mt(S,4,F=H(k.g));break;case 45:mt(S,5,F=H(k.g));break;case 48:for(var O=k.g,R=128,I=0,P=F=0;4>P&&128<=R;P++)I|=(127&(R=O.h[O.g++]))<<7*P;if(128<=R&&(I|=(127&(R=O.h[O.g++]))<<28,F|=(127&R)>>4),128<=R)for(P=0;5>P&&128<=R;P++)F|=(127&(R=O.h[O.g++]))<<7*P+3;128>R?(O=I>>>0,(F=2147483648&(R=F>>>0))&&(R=~R>>>0,0==(O=1+~O>>>0)&&(R=R+1>>>0)),O=4294967296*R+(O>>>0),F=F?-O:O):(O.l=!0,F=void 0),mt(S,6,F);break;default:if(!_t(S,k))break t}}S={Z:pt(S,1),$:pt(S,2),height:pt(S,3),width:pt(S,4),rotation:pt(S,5,0),X:wt(S,6)},F=x.get(T);t:for(k=new It,F=new X(F);q(F);)if(10===F.i)vt(k,O=Q(F,new Ot,Rt),Ot,void 0);else if(!_t(k,F))break t;k=yt(k,Ot).map(Lt),O=_.get(T);t:for(F=new St,O=new X(O);q(O);)if(10===O.i)F.addClassification(Q(O,new Tt,kt));else if(!_t(F,O))break t;S={T:S,O:k,M:Mt(F)},E.push(S)}w=E}else w=[];n[f]=w,t.g=7;break}if("proto_list"===h.type){if(d){for(w=Array(d.size()),x=0;x<d.size();x++)w[x]=d.get(x);d.delete()}else w=[];n[f]=w,t.g=7;break}if(void 0===d){t.g=3;break}if("float_list"===h.type){n[f]=d,t.g=7;break}if("proto"===h.type){n[f]=d,t.g=7;break}if("texture"!==h.type)throw Error("Unknown output config type: '"+h.type+"'");return(g=b.s[f])||(g=new Bt(b.h,b.D),b.s[f]=g),y(t,Ut(g,d,b.G),13);case 13:p=t.h,n[f]=p;case 7:h.transform&&n[f]&&(n[f]=h.transform(n[f])),t.g=3;break;case 14:m[v]=t.h;case 3:s=l.next(),t.g=2;break;case 4:return t.return(n)}})})}function Yt(t,e){for(var r=e.name||"$",n=[].concat(s(e.wants)),i=new t.h.StringList,o=a(e.wants),u=o.next();!u.done;u=o.next())i.push_back(u.value);o=t.h.PacketListener.implement({onResults:function(i){for(var o={},a=0;a<e.wants.length;++a)o[n[a]]=i.get(a);var s=t.listeners[r];s&&(t.C=$t(t,o,e.outs).then(function(r){r=s(r);for(var i=0;i<e.wants.length;++i){var a=o[n[i]];"object"==typeof a&&a.hasOwnProperty&&a.hasOwnProperty("delete")&&a.delete()}r&&(t.C=r)}))}}),t.i.attachMultiListener(i,o),i.delete()}function Xt(t){return void 0===t&&(t=0),1===t?"selfie_segmentation_landscape.tflite":"selfie_segmentation.tflite"}function qt(t){var e=this;t=t||{},this.g=new Wt({locateFile:t.locateFile,files:function(t){return[{simd:!0,url:"selfie_segmentation_solution_simd_wasm_bin.js"},{simd:!1,url:"selfie_segmentation_solution_wasm_bin.js"},{data:!0,url:Xt(t.modelSelection)}]},graph:{url:"selfie_segmentation.binarypb"},listeners:[{wants:["segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"},segmentationMask:{type:"texture",stream:"segmentation_mask"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelSelection:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelSelection",fieldName:"int_value"},onChange:function(t){return Et(e,function e(){var r,n,i,o=this;return A(e,function(e){return 1==e.g?(r=Xt(t),n="third_party/mediapipe/modules/selfie_segmentation/"+r,y(e,Vt(o.g,r),2)):(i=e.h,o.g.overrideFile(n,i),e.return(!0))})})}}}})}(t=Wt.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},t.reset=function(){return Et(this,function t(){var e=this;return A(t,function(t){e.i&&(e.i.reset(),e.m={},e.s={}),t.g=0})})},t.setOptions=function(t,e){var r=this;if(e=e||this.g.options){for(var n=[],i=[],o={},s=a(Object.keys(t)),u=s.next();!u.done;o={K:o.K,L:o.L},u=s.next()){var c=u.value;c in this.j&&this.j[c]===t[c]||(this.j[c]=t[c],void 0!==(u=e[c])&&(u.onChange&&(o.K=u.onChange,o.L=t[c],n.push(function(t){return function(){return Et(r,function e(){var r=this;return A(e,function(e){if(1==e.g)return y(e,t.K(t.L),2);!0===e.h&&(r.o=!0),e.g=0})})}}(o))),u.graphOptionXref&&(c={valueNumber:1===u.type?t[c]:0,valueBoolean:0===u.type&&t[c],valueString:2===u.type?t[c]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),c),i.push(u))))}(0!==n.length||0!==i.length)&&(this.o=!0,this.A=(void 0===this.A?[]:this.A).concat(i),this.u=(void 0===this.u?[]:this.u).concat(n))}},t.initialize=function(){return Et(this,function t(){var e=this;return A(t,function(t){return 1==t.g?y(t,Ht(e),2):3!=t.g?y(t,function(t){return Et(t,function t(){var e,r,n,i,o,s,u,c,l=this;return A(t,function(t){if(1==t.g)return l.g.graph&&l.g.graph.url&&l.P===l.g.graph.url?t.return():(l.o=!0,l.g.graph&&l.g.graph.url?(l.P=l.g.graph.url,y(t,Vt(l,l.g.graph.url),3)):void(t.g=2));for(2!=t.g&&(e=t.h,l.i.loadGraph(e)),r=a(Object.keys(l.B)),n=r.next();!n.done;n=r.next())i=n.value,l.i.overrideFile(i,l.B[i]);if(l.B={},l.g.listeners)for(o=a(l.g.listeners),s=o.next();!s.done;s=o.next())u=s.value,Yt(l,u);c=l.j,l.j={},l.setOptions(c),t.g=0})})}(e),3):y(t,function(t){return Et(t,function t(){var e,r,n,i,o,s,u=this;return A(t,function(t){switch(t.g){case 1:if(!u.o)return t.return();if(!u.u){t.g=2;break}e=a(u.u),r=e.next();case 3:if(r.done){t.g=5;break}return y(t,(0,r.value)(),4);case 4:r=e.next(),t.g=3;break;case 5:u.u=void 0;case 2:if(u.A){for(n=new u.h.GraphOptionChangeRequestList,i=a(u.A),o=i.next();!o.done;o=i.next())s=o.value,n.push_back(s);u.i.changeOptions(n),n.delete(),u.A=void 0}u.o=!1,t.g=0}})})}(e),0)})})},t.overrideFile=function(t,e){this.i?this.i.overrideFile(t,e):this.B[t]=e},t.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},t.send=function(t,e){return Et(this,function r(){var n,i,o,s,u,c,l,f,h,d=this;return A(r,function(r){switch(r.g){case 1:return d.g.inputs?(n=1e3*(e??performance.now()),y(r,d.C,2)):r.return();case 2:return y(r,d.initialize(),3);case 3:for(i=new d.h.PacketDataList,o=a(Object.keys(t)),s=o.next();!s.done;s=o.next())if(u=s.value,c=d.g.inputs[u]){t:{var g=d,p=t[u];switch(c.type){case"video":var m=g.m[c.stream];if(m||(m=new Bt(g.h,g.D),g.m[c.stream]=m),0===(g=m).l&&(g.l=g.h.createTexture()),typeof HTMLVideoElement<"u"&&p instanceof HTMLVideoElement){var v=p.videoWidth;m=p.videoHeight}else typeof HTMLImageElement<"u"&&p instanceof HTMLImageElement?(v=p.naturalWidth,m=p.naturalHeight):(v=p.width,m=p.height);m={glName:g.l,width:v,height:m},(v=g.g).canvas.width=m.width,v.canvas.height=m.height,v.activeTexture(v.TEXTURE0),g.h.bindTexture2d(g.l),v.texImage2D(v.TEXTURE_2D,0,v.RGBA,v.RGBA,v.UNSIGNED_BYTE,p),g.h.bindTexture2d(0),g=m;break t;case"detections":for((m=g.m[c.stream])||(m=new Nt(g.h),g.m[c.stream]=m),(g=m).data||(g.data=new g.g.DetectionListData),g.data.reset(p.length),m=0;m<p.length;++m){v=p[m];var b=g.data,w=b.setBoundingBox,x=m,A=v.T,_=new jt;mt(_,1,A.Z),mt(_,2,A.$),mt(_,3,A.height),mt(_,4,A.width),mt(_,5,A.rotation),mt(_,6,A.X);var E=A=new Z;rt(E,1,dt(_,1)),rt(E,2,dt(_,2)),rt(E,3,dt(_,3)),rt(E,4,dt(_,4)),rt(E,5,dt(_,5));var T=dt(_,6);if(null!=T&&null!=T){Y(E.g,48);var k=E.g,S=T;T=0>S;var F=(S=Math.abs(S))>>>0;for(S=Math.floor((S-F)/4294967296),S>>>=0,T&&(S=~S>>>0,4294967295<(F=(~F>>>0)+1)&&(F=0,4294967295<++S&&(S=0))),T=D=F,F=S;0<F||127<T;)k.push(127&T|128),T=(T>>>7|F<<25)>>>0,F>>>=7;k.push(T)}if(At(_,E),A=et(A),w.call(b,x,A),v.O)for(b=0;b<v.O.length;++b)E=!!(_=v.O[b]).visibility,x=(w=g.data).addNormalizedLandmark,A=m,_=Object.assign(Object.assign({},_),{visibility:E?_.visibility:0}),mt(E=new Ot,1,_.x),mt(E,2,_.y),mt(E,3,_.z),_.visibility&&mt(E,4,_.visibility),rt(k=_=new Z,1,dt(E,1)),rt(k,2,dt(E,2)),rt(k,3,dt(E,3)),rt(k,4,dt(E,4)),rt(k,5,dt(E,5)),At(E,k),_=et(_),x.call(w,A,_);if(v.M)for(b=0;b<v.M.length;++b){if(x=(w=g.data).addClassification,A=m,_=v.M[b],mt(E=new Tt,2,_.Y),_.index&&mt(E,1,_.index),_.label&&mt(E,3,_.label),_.displayName&&mt(E,4,_.displayName),k=_=new Z,null!=(F=dt(E,1))&&null!=F)if(Y(k.g,8),T=k.g,0<=F)Y(T,F);else{for(S=0;9>S;S++)T.push(127&F|128),F>>=7;T.push(1)}rt(k,2,dt(E,2)),null!=(T=dt(E,3))&&(T=I(T),Y(k.g,26),Y(k.g,T.length),tt(k,k.g.end()),tt(k,T)),null!=(T=dt(E,4))&&(T=I(T),Y(k.g,34),Y(k.g,T.length),tt(k,k.g.end()),tt(k,T)),At(E,k),_=et(_),x.call(w,A,_)}}g=g.data;break t;default:g={}}}switch(l=g,f=c.stream,c.type){case"video":i.pushTexture2d(Object.assign(Object.assign({},l),{stream:f,timestamp:n}));break;case"detections":(h=l).stream=f,h.timestamp=n,i.pushDetectionList(h);break;default:throw Error("Unknown input config type: '"+c.type+"'")}}return d.i.send(i),y(r,d.C,4);case 4:i.delete(),r.g=0}})})},t.onResults=function(t,e){this.listeners[e||"$"]=t},T("Solution",Wt),T("OptionType",{BOOL:0,NUMBER:1,aa:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(t=qt.prototype).close=function(){return this.g.close(),Promise.resolve()},t.onResults=function(t){this.g.onResults(t)},t.initialize=function(){return Et(this,function t(){var e=this;return A(t,function(t){return y(t,e.g.initialize(),0)})})},t.reset=function(){this.g.reset()},t.send=function(t){return Et(this,function e(){var r=this;return A(e,function(e){return y(e,r.g.send(t),0)})})},t.setOptions=function(t){this.g.setOptions(t)},T("SelfieSegmentation",qt),T("VERSION","0.1.1632777926")}).call(Ii);const ki={};(function(){var t;function e(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var r="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,r){return t==Array.prototype||t==Object.prototype||(t[e]=r.value),t};var n=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var e=0;e<t.length;++e){var r=t[e];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);function i(t,e){if(e)t:{var i=n;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];if(!(a in i))break t;i=i[a]}(e=e(o=i[t=t[t.length-1]]))!=o&&null!=e&&r(i,t,{configurable:!0,writable:!0,value:e})}}function o(t){return(t={next:t})[Symbol.iterator]=function(){return this},t}function a(t){var r=typeof Symbol<"u"&&Symbol.iterator&&t[Symbol.iterator];return r?r.call(t):{next:e(t)}}function s(t){if(!(t instanceof Array)){t=a(t);for(var e,r=[];!(e=t.next()).done;)r.push(e.value);t=r}return t}i("Symbol",function(t){function e(t,e){this.g=t,r(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;e.prototype.toString=function(){return this.g};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",i=0;return function t(r){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(n+(r||"")+"_"+i++,r)}}),i("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var i="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),a=0;a<i.length;a++){var s=n[i[a]];"function"==typeof s&&"function"!=typeof s.prototype[t]&&r(s.prototype,t,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return t});var u,c="function"==typeof Object.create?Object.create:function(t){function e(){}return e.prototype=t,new e};if("function"==typeof Object.setPrototypeOf)u=Object.setPrototypeOf;else{var l;t:{var f={};try{f.__proto__={a:!0},l=f.a;break t}catch{}l=!1}u=l?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var h=u;function d(t,e){if(t.prototype=c(e.prototype),t.prototype.constructor=t,h)h(t,e);else for(var r in e)if("prototype"!=r)if(Object.defineProperties){var n=Object.getOwnPropertyDescriptor(e,r);n&&Object.defineProperty(t,r,n)}else t[r]=e[r];t.ra=e.prototype}function g(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.u=this.o=0,this.j=null}function p(t){if(t.l)throw new TypeError("Generator is already running");t.l=!0}function m(t,e){t.j={fa:e,ga:!0},t.g=t.o||t.u}function y(t,e,r){return t.g=r,{value:e}}function v(t){this.g=new g,this.h=t}function b(t,e,r,n){try{var i=e.call(t.g.i,r);if(!(i instanceof Object))throw new TypeError("Iterator result "+i+" is not an object");if(!i.done)return t.g.l=!1,i;var o=i.value}catch(e){return t.g.i=null,m(t.g,e),w(t)}return t.g.i=null,n.call(t.g,o),w(t)}function w(t){for(;t.g.g;)try{var e=t.h(t.g);if(e)return t.g.l=!1,{value:e.value,done:!1}}catch(e){t.g.h=void 0,m(t.g,e)}if(t.g.l=!1,t.g.j){if(e=t.g.j,t.g.j=null,e.ga)throw e.fa;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function x(t){this.next=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.next,e,t.g.s):(t.g.s(e),e=w(t)),e},this.throw=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.throw,e,t.g.s):(m(t.g,e),e=w(t)),e},this.return=function(e){return function(t,e){p(t.g);var r=t.g.i;return r?b(t,"return"in r?r.return:function(t){return{value:t,done:!0}},e,t.g.return):(t.g.return(e),w(t))}(t,e)},this[Symbol.iterator]=function(){return this}}function A(t){return function(t){function e(e){return t.next(e)}function r(e){return t.throw(e)}return new Promise(function(n,i){!function t(o){o.done?n(o.value):Promise.resolve(o.value).then(e,r).then(t,i)}(t.next())})}(new x(new v(t)))}g.prototype.s=function(t){this.h=t},g.prototype.return=function(t){this.j={return:t},this.g=this.u},i("Promise",function(t){function e(t){this.h=0,this.i=void 0,this.g=[],this.s=!1;var e=this.j();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function r(){this.g=null}function i(t){return t instanceof e?t:new e(function(e){e(t)})}if(t)return t;r.prototype.h=function(t){if(null==this.g){this.g=[];var e=this;this.i(function(){e.l()})}this.g.push(t)};var o=n.setTimeout;r.prototype.i=function(t){o(t,0)},r.prototype.l=function(){for(;this.g&&this.g.length;){var t=this.g;this.g=[];for(var e=0;e<t.length;++e){var r=t[e];t[e]=null;try{r()}catch(t){this.j(t)}}}this.g=null},r.prototype.j=function(t){this.i(function(){throw t})},e.prototype.j=function(){function t(t){return function(n){r||(r=!0,t.call(e,n))}}var e=this,r=!1;return{resolve:t(this.D),reject:t(this.l)}},e.prototype.D=function(t){if(t===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.H(t);else{t:switch(typeof t){case"object":var r=null!=t;break t;case"function":r=!0;break t;default:r=!1}r?this.A(t):this.o(t)}},e.prototype.A=function(t){var e=void 0;try{e=t.then}catch(t){return void this.l(t)}"function"==typeof e?this.I(e,t):this.o(t)},e.prototype.l=function(t){this.u(2,t)},e.prototype.o=function(t){this.u(1,t)},e.prototype.u=function(t,e){if(0!=this.h)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.h);this.h=t,this.i=e,2===this.h&&this.G(),this.B()},e.prototype.G=function(){var t=this;o(function(){if(t.C()){var e=n.console;typeof e<"u"&&e.error(t.i)}},1)},e.prototype.C=function(){if(this.s)return!1;var t=n.CustomEvent,e=n.Event,r=n.dispatchEvent;return typeof r>"u"||("function"==typeof t?t=new t("unhandledrejection",{cancelable:!0}):"function"==typeof e?t=new e("unhandledrejection",{cancelable:!0}):(t=n.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,t),t.promise=this,t.reason=this.i,r(t))},e.prototype.B=function(){if(null!=this.g){for(var t=0;t<this.g.length;++t)s.h(this.g[t]);this.g=null}};var s=new r;return e.prototype.H=function(t){var e=this.j();t.M(e.resolve,e.reject)},e.prototype.I=function(t,e){var r=this.j();try{t.call(e,r.resolve,r.reject)}catch(t){r.reject(t)}},e.prototype.then=function(t,r){function n(t,e){return"function"==typeof t?function(e){try{i(t(e))}catch(t){o(t)}}:e}var i,o,a=new e(function(t,e){i=t,o=e});return this.M(n(t,i),n(r,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.M=function(t,e){function r(){switch(n.h){case 1:t(n.i);break;case 2:e(n.i);break;default:throw Error("Unexpected state: "+n.h)}}var n=this;null==this.g?s.h(r):this.g.push(r),this.s=!0},e.resolve=i,e.reject=function(t){return new e(function(e,r){r(t)})},e.race=function(t){return new e(function(e,r){for(var n=a(t),o=n.next();!o.done;o=n.next())i(o.value).M(e,r)})},e.all=function(t){var r=a(t),n=r.next();return n.done?i([]):new e(function(t,e){function o(e){return function(r){a[e]=r,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,i(n.value).M(o(a.length-1),e),n=r.next()}while(!n.done)})},e});var _="function"==typeof Object.assign?Object.assign:function(t,e){for(var r=1;r<arguments.length;r++){var n=arguments[r];if(n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};i("Object.assign",function(t){return t||_}),i("Object.is",function(t){return t||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}}),i("Array.prototype.includes",function(t){return t||function(t,e){var r=this;r instanceof String&&(r=String(r));var n=r.length;for(0>(e=e||0)&&(e=Math.max(e+n,0));e<n;e++){var i=r[e];if(i===t||Object.is(i,t))return!0}return!1}}),i("String.prototype.includes",function(t){return t||function(t,e){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(t,e||0)}}),i("Array.prototype.keys",function(t){return t||function(){return function(t,e){t instanceof String&&(t+="");var r=0,n=!1,i={next:function(){if(!n&&r<t.length){var i=r++;return{value:e(i,t[i]),done:!1}}return n=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,function(t){return t})}});var E=this||self;function T(t,e){t=t.split(".");var r,n=E;t[0]in n||typeof n.execScript>"u"||n.execScript("var "+t[0]);for(;t.length&&(r=t.shift());)t.length||void 0===e?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=e}function k(){throw Error("Invalid UTF8")}function S(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}var F,O,R=typeof TextDecoder<"u",I=typeof TextEncoder<"u",P={},j=null;function C(t){var e;void 0===e&&(e=0),L(),e=P[e];for(var r=Array(Math.floor(t.length/3)),n=e[64]||"",i=0,o=0;i<t.length-2;i+=3){var a=t[i],s=t[i+1],u=t[i+2],c=e[a>>2];a=e[(3&a)<<4|s>>4],s=e[(15&s)<<2|u>>6],u=e[63&u],r[o++]=c+a+s+u}switch(c=0,u=n,t.length-i){case 2:u=e[(15&(c=t[i+1]))<<2]||n;case 1:t=t[i],r[o]=e[t>>2]+e[(3&t)<<4|c>>4]+u+n}return r.join("")}function M(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){var r=t.charAt(n++),i=j[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}L();for(var n=0;;){var i=r(-1),o=r(0),a=r(64),s=r(64);if(64===s&&-1===i)break;e(i<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function L(){if(!j){j={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));P[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===j[o]&&(j[o]=i)}}}}var B,U="function"==typeof Uint8Array;function N(t){return U&&null!=t&&t instanceof Uint8Array}function D(t){if(this.L=t,null!==t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}var z="function"==typeof Uint8Array.prototype.slice,G=0;function W(t,e){return Error("Invalid wire type: "+t+" (at position "+e+")")}function H(){return Error("Failed to read varint, encoding is invalid.")}function V(t,e){e=void 0!==(e=void 0===e?{}:e).v&&e.v,this.h=null,this.g=this.i=this.j=0,this.v=e,t&&$(this,t)}function $(t,e){t.h=function(t,e){if(t.constructor===Uint8Array)return t;if(t.constructor===ArrayBuffer)return new Uint8Array(t);if(t.constructor===Array)return new Uint8Array(t);if(t.constructor===String)return M(t);if(t.constructor===D)return!e&&(e=t.L)&&e.constructor===Uint8Array?e:(e=null==(e=t.L)||N(e)?e:"string"==typeof e?M(e):null,(t=t.L=e)?new Uint8Array(t):B||(B=new Uint8Array(0)));if(t instanceof Uint8Array)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}(e,t.v),t.j=0,t.i=t.h.length,t.g=t.j}function Y(t){if(t.g>t.i)throw Error("Tried to read past the end of the data "+t.g+" > "+t.i)}function X(t){var e=t.h,r=e[t.g],n=127&r;if(128>r)return t.g+=1,Y(t),n;if(n|=(127&(r=e[t.g+1]))<<7,128>r)return t.g+=2,Y(t),n;if(n|=(127&(r=e[t.g+2]))<<14,128>r)return t.g+=3,Y(t),n;if(n|=(127&(r=e[t.g+3]))<<21,128>r)return t.g+=4,Y(t),n;if(r=e[t.g+4],t.g+=5,n|=(15&r)<<28,128>r)return Y(t),n;if(128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++])throw H();return Y(t),n}V.prototype.reset=function(){this.g=this.j};var q=[];function K(){this.g=[]}function Q(t,e){for(;127<e;)t.g.push(127&e|128),e>>>=7;t.g.push(e)}function J(t){var e={},r=void 0!==e.W&&e.W;this.l={v:void 0!==e.v&&e.v},this.W=r,e=this.l,q.length?(r=q.pop(),e&&(r.v=e.v),t&&$(r,t),t=r):t=new V(t,e),this.g=t,this.j=this.g.g,this.h=this.i=-1}function Z(t){var e=t.g;if(e.g==e.i)return!1;t.j=t.g.g;var r=X(t.g)>>>0;if(e=r>>>3,!(0<=(r&=7)&&5>=r))throw W(r,t.j);if(1>e)throw Error("Invalid field number: "+e+" (at position "+t.j+")");return t.i=e,t.h=r,!0}function tt(t){switch(t.h){case 0:if(0!=t.h)tt(t);else t:{for(var e=(t=t.g).g,r=e+10;e<r;)if(!(128&t.h[e++])){t.g=e,Y(t);break t}throw H()}break;case 1:(t=t.g).g+=8,Y(t);break;case 2:2!=t.h?tt(t):(e=X(t.g)>>>0,(t=t.g).g+=e,Y(t));break;case 5:(t=t.g).g+=4,Y(t);break;case 3:for(e=t.i;;){if(!Z(t))throw Error("Unmatched start-group tag: stream EOF");if(4==t.h){if(t.i!=e)throw Error("Unmatched end-group tag");break}tt(t)}break;default:throw W(t.h,t.j)}}K.prototype.length=function(){return this.g.length},K.prototype.end=function(){var t=this.g;return this.g=[],t},J.prototype.reset=function(){this.g.reset(),this.j=this.g.g,this.h=this.i=-1};var et=[];function rt(){this.i=[],this.h=0,this.g=new K}function nt(t,e){0!==e.length&&(t.i.push(e),t.h+=e.length)}var it="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol(void 0):void 0;function ot(t,e){Object.isFrozen(t)||(it?t[it]|=e:void 0!==t.N?t.N|=e:Object.defineProperties(t,{N:{value:e,configurable:!0,writable:!0,enumerable:!1}}))}function at(t){return(it?t[it]:t.N)??0}function st(t){return ot(t,1),t}function ut(t){return!!Array.isArray(t)&&!!(2&at(t))}function ct(t){if(!Array.isArray(t))throw Error("cannot mark non-array as immutable");ot(t,2)}function lt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}var ft=Object.freeze(st([]));function ht(t){if(ut(t.m))throw Error("Cannot mutate an immutable Message")}var dt,gt=typeof Symbol<"u"&&typeof Symbol.hasInstance<"u";function pt(t){return{value:t,configurable:!1,writable:!1,enumerable:!1}}function mt(t,e,r){return-1===e?null:e>=t.i?t.g?t.g[e]:void 0:void 0!==r&&r&&t.g&&null!=(r=t.g[e])?r:t.m[e+t.h]}function yt(t,e,r,n){n=void 0!==n&&n,ht(t),e<t.i&&!n?t.m[e+t.h]=r:(t.g||(t.g=t.m[t.i+t.h]={}))[e]=r}function vt(t,e,r,n){r=void 0===r||r;var i=mt(t,e,n=void 0!==n&&n);return null==i&&(i=ft),ut(t.m)?r&&(ct(i),Object.freeze(i)):(i===ft||ut(i))&&yt(t,e,i=st(i.slice()),n),i}function bt(t,e,r){return(t=null==(t=mt(t,e))?t:+t)??(void 0===r?0:r)}function wt(t,e,r,n){t.j||(t.j={});var i=ut(t.m),o=t.j[r];if(!o){n=vt(t,r,!0,void 0!==n&&n),o=[],i=i||ut(n);for(var a=0;a<n.length;a++)o[a]=new e(n[a]),i&&ct(o[a].m);i&&(ct(o),Object.freeze(o)),t.j[r]=o}return o}function xt(t,e,r,n,i){var o=void 0!==o&&o;return ht(t),o=wt(t,r,e,o),r=n||new r,t=vt(t,e),null!=i?(o.splice(i,0,r),t.splice(i,0,r.m)):(o.push(r),t.push(r.m)),r}function At(t,e){return(t=mt(t,e))??0}function _t(t,e){return(t=mt(t,e))??""}function Et(t){var e=St;return kt(t,e=void 0===e?Ft:e)}function Tt(t,e){if(null!=t){if(Array.isArray(t))t=kt(t,e);else if(lt(t)){var r,n={};for(r in t)n[r]=Tt(t[r],e);t=n}else t=e(t);return t}}function kt(t,e){for(var r=t.slice(),n=0;n<r.length;n++)r[n]=Tt(r[n],e);return Array.isArray(t)&&1&at(t)&&st(r),r}function St(t){return t&&"object"==typeof t&&t.toJSON?t.toJSON():(t=function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"object":if(t&&!Array.isArray(t)){if(N(t))return C(t);if(t instanceof D){var e=t.L;return e=null==e||"string"==typeof e?e:U&&e instanceof Uint8Array?C(e):null,(t.L=e)||""}}}return t}(t),Array.isArray(t)?Et(t):t)}function Ft(t){return N(t)?new Uint8Array(t):t}function Ot(t,e,r){t||(t=dt),dt=null;var n=this.constructor.h;if(t||(t=n?[n]:[]),this.h=(n?0:-1)-(this.constructor.g||0),this.j=void 0,this.m=t,t=(n=this.m.length)-1,n&&lt(n=this.m[t])?(this.i=t-this.h,this.g=n):void 0!==e&&-1<e?(this.i=Math.max(e,t+1-this.h),this.g=void 0):this.i=Number.MAX_VALUE,r)for(e=0;e<r.length;e++)if((t=r[e])<this.i)t+=this.h,(n=this.m[t])?Array.isArray(n)&&st(n):this.m[t]=ft;else{var i=(n=this.g||(this.g=this.m[this.i+this.h]={}))[t];i?Array.isArray(i)&&st(i):n[t]=ft}}function Rt(){Ot.apply(this,arguments)}if(Ot.prototype.toJSON=function(){return Et(this.m)},Ot.prototype.toString=function(){return this.m.toString()},d(Rt,Ot),gt){var It={};Object.defineProperties(Rt,(It[Symbol.hasInstance]=pt(function(){throw Error("Cannot perform instanceof checks for MutableMessage")}),It))}function Pt(t,e,r){if(r){var n,i={};for(n in r){var o=r[n],a=o.ja;a||(i.F=o.pa||o.ha.P,o.ba?(i.U=Nt(o.ba),a=function(t){return function(e,r,n){return t.F(e,r,n,t.U)}}(i)):o.da?(i.T=Dt(o.X.g,o.da),a=function(t){return function(e,r,n){return t.F(e,r,n,t.T)}}(i)):a=i.F,o.ja=a),a(e,t,o.X),i={F:i.F,U:i.U,T:i.T}}}!function(t,e){if(e=e.ca){nt(t,t.g.end());for(var r=0;r<e.length;r++)nt(t,e[r])}}(e,t)}var jt=Symbol();function Ct(t,e,r){return t[jt]||(t[jt]=function(t,n){return e(t,n,r)})}function Mt(t){var e=t[jt];if(!e){var r=Jt(t);e=function(t,e){return Zt(t,e,r)},t[jt]=e}return e}function Lt(t){var e=function(t){var e=t.ba;return e?Mt(e):(e=t.oa)?Ct(t.X.g,e,t.da):void 0}(t),r=t.X,n=t.ha.O;return e?function(t,i){return n(t,i,r,e)}:function(t,e){return n(t,e,r)}}function Bt(t,e,r,n,i,o){var a=0;for((t=t()).length&&"number"!=typeof t[0]&&(r(e,t[0]),a++);a<t.length;){r=t[a++];for(var s=a+1;s<t.length&&"number"!=typeof t[s];)s++;var u=t[a++];switch(s-=a){case 0:n(e,r,u);break;case 1:n(e,r,u,t[a++]);break;case 2:i(e,r,u,t[a++],t[a++]);break;case 3:s=t[a++];var c=t[a++],l=t[a++];Array.isArray(l)?i(e,r,u,s,c,l):o(e,r,u,s,c,l);break;case 4:o(e,r,u,t[a++],t[a++],t[a++],t[a++]);break;default:throw Error("unexpected number of binary field arguments: "+s)}}return e}var Ut=Symbol();function Nt(t){var e=t[Ut];if(!e){var r=$t(t);e=function(t,e){return ee(t,e,r)},t[Ut]=e}return e}function Dt(t,e){var r=t[Ut];return r||(r=function(t,r){return Pt(t,r,e)},t[Ut]=r),r}var zt=Symbol();function Gt(t,e){t.push(e)}function Wt(t,e,r){t.push(e,r.P)}function Ht(t,e,r,n,i){var o=Nt(i),a=r.P;t.push(e,function(t,e,r){return a(t,e,r,n,o)})}function Vt(t,e,r,n,i,o){var a=Dt(n,o),s=r.P;t.push(e,function(t,e,r){return s(t,e,r,n,a)})}function $t(t){return t[zt]||Bt(t,t[zt]=[],Gt,Wt,Ht,Vt)}var Yt=Symbol();function Xt(t,e){t[0]=e}function qt(t,e,r,n){var i=r.O;t[e]=n?function(t,e,r){return i(t,e,r,n)}:i}function Kt(t,e,r,n,i,o){var a=r.O,s=Mt(i);t[e]=function(t,e,r){return a(t,e,r,n,s,o)}}function Qt(t,e,r,n,i,o,a){var s=r.O,u=Ct(n,i,o);t[e]=function(t,e,r){return s(t,e,r,n,u,a)}}function Jt(t){return t[Yt]||Bt(t,t[Yt]={},Xt,qt,Kt,Qt)}function Zt(t,e,r){for(;Z(e)&&4!=e.h;){var n=e.i,i=r[n];if(!i){var o=r[0];o&&(o=o[n])&&(i=r[n]=Lt(o))}if(!(i&&i(e,t,n)||(i=e,n=t,o=i.j,tt(i),i.W))){var a=i.g.h;i=o===(i=i.g.g)?B||(B=new Uint8Array(0)):z?a.slice(o,i):new Uint8Array(a.subarray(o,i)),(o=n.ca)?o.push(i):n.ca=[i]}}return t}function te(t,e,r){if(et.length){var n=et.pop();t&&($(n.g,t),n.i=-1,n.h=-1),t=n}else t=new J(t);try{return Zt(new e,t,Jt(r))}finally{(e=t.g).h=null,e.j=0,e.i=0,e.g=0,e.v=!1,t.i=-1,t.h=-1,100>et.length&&et.push(t)}}function ee(t,e,r){for(var n=r.length,i=n%2==1,o=i?1:0;o<n;o+=2)(0,r[o+1])(e,t,r[o]);Pt(t,e,i?r[0]:void 0)}function re(t,e){var r=new rt;ee(t,r,$t(e)),nt(r,r.g.end()),t=new Uint8Array(r.h);for(var n=(e=r.i).length,i=0,o=0;o<n;o++){var a=e[o];t.set(a,i),i+=a.length}return r.i=[t],t}function ne(t,e){return{O:t,P:e}}var ie=ne(function(t,e,r){if(5!==t.h)return!1;var n=(t=t.g).h[t.g],i=t.h[t.g+1],o=t.h[t.g+2],a=t.h[t.g+3];return t.g+=4,Y(t),t=2*((i=(n|i<<8|o<<16|a<<24)>>>0)>>31)+1,n=i>>>23&255,i&=8388607,yt(e,r,255==n?i?NaN:1/0*t:0==n?t*Math.pow(2,-149)*i:t*Math.pow(2,n-150)*(i+Math.pow(2,23))),!0},function(t,e,r){if(null!=(e=mt(e,r))){Q(t.g,8*r+5),t=t.g;var n=e;0===(n=(r=0>n?1:0)?-n:n)?0<1/n?G=0:G=2147483648:isNaN(n)?G=2147483647:34028234663852886e22<n?G=(r<<31|2139095040)>>>0:11754943508222875e-54>n?(n=Math.round(n/Math.pow(2,-149)),G=(r<<31|n)>>>0):(e=Math.floor(Math.log(n)/Math.LN2),n*=Math.pow(2,-e),16777216<=(n=Math.round(8388608*n))&&++e,G=(r<<31|e+127<<23|8388607&n)>>>0),r=G,t.g.push(r>>>0&255),t.g.push(r>>>8&255),t.g.push(r>>>16&255),t.g.push(r>>>24&255)}}),oe=ne(function(t,e,r){if(0!==t.h)return!1;for(var n=t.g,i=128,o=0,a=t=0;4>a&&128<=i;a++)i=n.h[n.g++],Y(n),o|=(127&i)<<7*a;if(128<=i&&(i=n.h[n.g++],Y(n),o|=(127&i)<<28,t|=(127&i)>>4),128<=i)for(a=0;5>a&&128<=i;a++)i=n.h[n.g++],Y(n),t|=(127&i)<<7*a+3;if(!(128>i))throw H();return n=o>>>0,(t=2147483648&(i=t>>>0))&&(i=~i>>>0,0==(n=1+~n>>>0)&&(i=i+1>>>0)),n=4294967296*i+(n>>>0),yt(e,r,t?-n:n),!0},function(t,e,r){if(null!=(e=mt(e,r))&&null!=e){Q(t.g,8*r),t=t.g;var n=e;for(r=0>n,e=(n=Math.abs(n))>>>0,n=Math.floor((n-e)/4294967296),n>>>=0,r&&(n=~n>>>0,4294967295<(e=(~e>>>0)+1)&&(e=0,4294967295<++n&&(n=0))),r=G=e,e=n;0<e||127<r;)t.g.push(127&r|128),r=(r>>>7|e<<25)>>>0,e>>>=7;t.g.push(r)}}),ae=ne(function(t,e,r){return 0===t.h&&(yt(e,r,X(t.g)),!0)},function(t,e,r){if(null!=(e=mt(e,r))&&null!=e)if(Q(t.g,8*r),t=t.g,0<=(r=e))Q(t,r);else{for(e=0;9>e;e++)t.g.push(127&r|128),r>>=7;t.g.push(1)}}),se=ne(function(t,e,r){if(2!==t.h)return!1;var n,i=X(t.g)>>>0,o=(t=t.g).g;if(t.g+=i,Y(t),t=t.h,R)(n=F)||(n=F=new TextDecoder("utf-8",{fatal:!0})),n=n.decode(t.subarray(o,o+i));else{i=o+i;for(var a,s,u,c=[],l=null;o<i;)128>(a=t[o++])?c.push(a):224>a?o>=i?k():(s=t[o++],194>a||128!=(192&s)?(o--,k()):c.push((31&a)<<6|63&s)):240>a?o>=i-1?k():128!=(192&(s=t[o++]))||224===a&&160>s||237===a&&160<=s||128!=(192&(n=t[o++]))?(o--,k()):c.push((15&a)<<12|(63&s)<<6|63&n):244>=a?o>=i-2?k():128!=(192&(s=t[o++]))||s-144+(a<<28)>>30||128!=(192&(n=t[o++]))||128!=(192&(u=t[o++]))?(o--,k()):(a=(7&a)<<18|(63&s)<<12|(63&n)<<6|63&u,a-=65536,c.push(55296+(a>>10&1023),56320+(1023&a))):k(),8192<=c.length&&(l=S(l,c),c.length=0);n=S(l,c)}return yt(e,r,n),!0},function(t,e,r){if(null!=(e=mt(e,r))){var n=!1;if(n=void 0!==n&&n,I){if(n&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(e))throw Error("Found an unpaired surrogate");e=(O||(O=new TextEncoder)).encode(e)}else{for(var i=0,o=new Uint8Array(3*e.length),a=0;a<e.length;a++){var s=e.charCodeAt(a);if(128>s)o[i++]=s;else{if(2048>s)o[i++]=s>>6|192;else{if(55296<=s&&57343>=s){if(56319>=s&&a<e.length){var u=e.charCodeAt(++a);if(56320<=u&&57343>=u){s=1024*(s-55296)+u-56320+65536,o[i++]=s>>18|240,o[i++]=s>>12&63|128,o[i++]=s>>6&63|128,o[i++]=63&s|128;continue}a--}if(n)throw Error("Found an unpaired surrogate");s=65533}o[i++]=s>>12|224,o[i++]=s>>6&63|128}o[i++]=63&s|128}}e=o.subarray(0,i)}Q(t.g,8*r+2),Q(t.g,e.length),nt(t,t.g.end()),nt(t,e)}}),ue=ne(function(t,e,r,n,i){if(2!==t.h)return!1;e=xt(e,r,n),r=t.g.i,n=X(t.g)>>>0;var o=t.g.g+n,a=o-r;if(0>=a&&(t.g.i=o,i(e,t),a=o-t.g.g),a)throw Error("Message parsing ended unexpectedly. Expected to read "+n+" bytes, instead read "+(n-a)+" bytes, either the data ended unexpectedly or the message misreported its own length");return t.g.g=o,t.g.i=r,!0},function(t,e,r,n,i){if(null!=(e=wt(e,n,r)))for(n=0;n<e.length;n++){var o=t;Q(o.g,8*r+2);var a=o.g.end();nt(o,a),a.push(o.h),o=a,i(e[n],t),a=t;var s=o.pop();for(s=a.h+a.g.length()-s;127<s;)o.push(127&s|128),s>>>=7,a.h++;o.push(s),a.h++}});function ce(){Rt.apply(this,arguments)}if(d(ce,Rt),gt){var le={};Object.defineProperties(ce,(le[Symbol.hasInstance]=pt(Object[Symbol.hasInstance]),le))}function fe(t){ce.call(this,t)}function he(){return[1,ae,2,ie,3,se,4,se]}function de(t){ce.call(this,t,-1,pe)}function ge(){return[1,ue,fe,he]}d(fe,ce),d(de,ce),de.prototype.addClassification=function(t,e){return xt(this,1,fe,t,e),this};var pe=[1];function me(t){ce.call(this,t)}function ye(){return[1,ie,2,ie,3,ie,4,ie,5,ie]}function ve(t){ce.call(this,t,-1,we)}function be(){return[1,ue,me,ye]}d(me,ce),d(ve,ce);var we=[1];function xe(t){ce.call(this,t)}function Ae(){return[1,ie,2,ie,3,ie,4,ie,5,ie,6,oe]}function _e(t,e,r){if(r=t.createShader(0===r?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+t.getShaderInfoLog(r));return r}function Ee(t){return wt(t,fe,1).map(function(t){return{index:At(t,1),score:bt(t,2),label:null!=mt(t,3)?_t(t,3):void 0,displayName:null!=mt(t,4)?_t(t,4):void 0}})}function Te(t){return{x:bt(t,1),y:bt(t,2),z:bt(t,3),visibility:null!=mt(t,4)?bt(t,4):void 0}}function ke(t){return t.map(function(t){return wt(te(t,ve,be),me,1).map(Te)})}function Se(t,e){this.h=t,this.g=e,this.l=0}function Fe(t,e,r){return function(t,e){var r=t.g;if(void 0===t.o){var n=_e(r,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",0),i=_e(r,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=r.createProgram();if(r.attachShader(o,n),r.attachShader(o,i),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+r.getProgramInfoLog(o));n=t.o=o,r.useProgram(n),i=r.getUniformLocation(n,"sampler0"),t.j={K:r.getAttribLocation(n,"aVertex"),J:r.getAttribLocation(n,"aTex"),qa:i},t.u=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.u),r.enableVertexAttribArray(t.j.K),r.vertexAttribPointer(t.j.K,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),t.s=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.enableVertexAttribArray(t.j.J),r.vertexAttribPointer(t.j.J,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.uniform1i(i,0)}n=t.j,r.useProgram(t.o),r.canvas.width=e.width,r.canvas.height=e.height,r.viewport(0,0,e.width,e.height),r.activeTexture(r.TEXTURE0),t.h.bindTexture2d(e.glName),r.enableVertexAttribArray(n.K),r.bindBuffer(r.ARRAY_BUFFER,t.u),r.vertexAttribPointer(n.K,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(n.J),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.vertexAttribPointer(n.J,2,r.FLOAT,!1,0,0),r.bindFramebuffer(r.DRAW_FRAMEBUFFER?r.DRAW_FRAMEBUFFER:r.FRAMEBUFFER,null),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.colorMask(!0,!0,!0,!0),r.drawArrays(r.TRIANGLE_FAN,0,4),r.disableVertexAttribArray(n.K),r.disableVertexAttribArray(n.J),r.bindBuffer(r.ARRAY_BUFFER,null),t.h.bindTexture2d(0)}(t,e),"function"==typeof t.g.canvas.transferToImageBitmap?Promise.resolve(t.g.canvas.transferToImageBitmap()):r?Promise.resolve(t.g.canvas):"function"==typeof createImageBitmap?createImageBitmap(t.g.canvas):(void 0===t.i&&(t.i=document.createElement("canvas")),new Promise(function(e){t.i.height=t.g.canvas.height,t.i.width=t.g.canvas.width,t.i.getContext("2d",{}).drawImage(t.g.canvas,0,0,t.g.canvas.width,t.g.canvas.height),e(t.i)}))}function Oe(t){this.g=t}d(xe,ce);var Re=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Ie(t,e){return e+t}function Pe(t,e){window[t]=e}function je(t){if(this.g=t,this.listeners={},this.j={},this.H={},this.o={},this.u={},this.I=this.s=this.$=!0,this.D=Promise.resolve(),this.Z="",this.C={},this.locateFile=t&&t.locateFile||Ie,"object"==typeof window)var e=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(!(typeof location<"u"))throw Error("solutions can only be loaded on a web page or in a web worker");e=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.aa=e,t.options)for(var r=(e=a(Object.keys(t.options))).next();!r.done;r=e.next()){r=r.value;var n=t.options[r].default;void 0!==n&&(this.j[r]="function"==typeof n?n():n)}}function Ce(t){var e,r,n,i,o,a,u,c,l,f,h;return A(function(d){switch(d.g){case 1:return t.$?(e=void 0===t.g.files?[]:"function"==typeof t.g.files?t.g.files(t.j):t.g.files,y(d,A(function(t){switch(t.g){case 1:return t.o=2,y(t,WebAssembly.instantiate(Re),4);case 4:t.g=3,t.o=0;break;case 2:return t.o=0,t.j=null,t.return(!1);case 3:return t.return(!0)}}),2)):d.return();case 2:if(r=d.h,"object"==typeof window)return Pe("createMediapipeSolutionsWasm",{locateFile:t.locateFile}),Pe("createMediapipeSolutionsPackedAssets",{locateFile:t.locateFile}),a=e.filter(function(t){return void 0!==t.data}),u=e.filter(function(t){return void 0===t.data}),c=Promise.all(a.map(function(e){var r=Me(t,e.url);if(void 0!==e.path){var n=e.path;r=r.then(function(e){return t.overrideFile(n,e),Promise.resolve(e)})}return r})),l=Promise.all(u.map(function(e){return void 0===e.simd||e.simd&&r||!e.simd&&!r?function(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(t){e.addEventListener("load",function(){t()},!1),e.addEventListener("error",function(){t()},!1),document.body.appendChild(e)})}(t.locateFile(e.url,t.aa)):Promise.resolve()})).then(function(){var e,r,n;return A(function(i){if(1==i.g)return e=window.createMediapipeSolutionsWasm,r=window.createMediapipeSolutionsPackedAssets,n=t,y(i,e(r),2);n.h=i.h,i.g=0})}),f=A(function(e){return t.g.graph&&t.g.graph.url?e=y(e,Me(t,t.g.graph.url),0):(e.g=0,e=void 0),e}),y(d,Promise.all([l,c,f]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return n=e.filter(function(t){return void 0===t.simd||t.simd&&r||!t.simd&&!r}).map(function(e){return t.locateFile(e.url,t.aa)}),importScripts.apply(null,s(n)),i=t,y(d,createMediapipeSolutionsWasm(Module),6);case 6:i.h=d.h,t.l=new OffscreenCanvas(1,1),t.h.canvas=t.l,o=t.h.GL.createContext(t.l,{antialias:!1,alpha:!1,na:typeof WebGL2RenderingContext<"u"?2:1}),t.h.GL.makeContextCurrent(o),d.g=4;break;case 7:if(t.l=document.createElement("canvas"),!(h=t.l.getContext("webgl2",{}))&&!(h=t.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),d.return();t.G=h,t.h.canvas=t.l,t.h.createContext(t.l,!0,!0,{});case 4:t.i=new t.h.SolutionWasm,t.$=!1,d.g=0}})}function Me(t,e){var r,n;return A(function(i){return e in t.H?i.return(t.H[e]):(r=t.locateFile(e,""),n=fetch(r).then(function(t){return t.arrayBuffer()}),t.H[e]=n,i.return(n))})}function Le(t,e,r){var n,i,o,s,u,c,l,f,h,d,g,p,m,v;return A(function(b){switch(b.g){case 1:if(!r)return b.return(e);for(n={},i=0,o=a(Object.keys(r)),s=o.next();!s.done;s=o.next())u=s.value,"string"!=typeof(c=r[u])&&"texture"===c.type&&void 0!==e[c.stream]&&++i;1<i&&(t.I=!1),l=a(Object.keys(r)),s=l.next();case 2:if(s.done){b.g=4;break}if(f=s.value,"string"==typeof(h=r[f]))return m=n,v=f,y(b,function(t,e,r){var n;return A(function(i){return"number"==typeof r||r instanceof Uint8Array||r instanceof t.h.Uint8BlobList?i.return(r):r instanceof t.h.Texture2dDataOut?((n=t.u[e])||(n=new Se(t.h,t.G),t.u[e]=n),i.return(Fe(n,r,t.I))):i.return(void 0)})}(t,f,e[h]),14);if(d=e[h.stream],"detection_list"===h.type){if(d){for(var w=d.getRectList(),x=d.getLandmarksList(),_=d.getClassificationsList(),E=[],T=0;T<w.size();++T){var k=te(w.get(T),xe,Ae);k={ea:{ka:bt(k,1),la:bt(k,2),height:bt(k,3),width:bt(k,4),rotation:bt(k,5,0),ia:At(k,6)},Y:wt(te(x.get(T),ve,be),me,1).map(Te),V:Ee(te(_.get(T),de,ge))},E.push(k)}w=E}else w=[];n[f]=w,b.g=7;break}if("proto_list"===h.type){if(d){for(w=Array(d.size()),x=0;x<d.size();x++)w[x]=d.get(x);d.delete()}else w=[];n[f]=w,b.g=7;break}if(void 0===d){b.g=3;break}if("float_list"===h.type){n[f]=d,b.g=7;break}if("proto"===h.type){n[f]=d,b.g=7;break}if("texture"!==h.type)throw Error("Unknown output config type: '"+h.type+"'");return(g=t.u[f])||(g=new Se(t.h,t.G),t.u[f]=g),y(b,Fe(g,d,t.I),13);case 13:p=b.h,n[f]=p;case 7:h.transform&&n[f]&&(n[f]=h.transform(n[f])),b.g=3;break;case 14:m[v]=b.h;case 3:s=l.next(),b.g=2;break;case 4:return b.return(n)}})}function Be(t,e){for(var r=e.name||"$",n=[].concat(s(e.wants)),i=new t.h.StringList,o=a(e.wants),u=o.next();!u.done;u=o.next())i.push_back(u.value);o=t.h.PacketListener.implement({onResults:function(i){for(var o={},a=0;a<e.wants.length;++a)o[n[a]]=i.get(a);var s=t.listeners[r];s&&(t.D=Le(t,o,e.outs).then(function(r){r=s(r);for(var i=0;i<e.wants.length;++i){var a=o[n[i]];"object"==typeof a&&a.hasOwnProperty&&a.hasOwnProperty("delete")&&a.delete()}r&&(t.D=r)}))}}),t.i.attachMultiListener(i,o),i.delete()}function Ue(t){return void 0===t&&(t=0),1===t?"hand_landmark_full.tflite":"hand_landmark_lite.tflite"}function Ne(t){var e=this;t=t||{},this.g=new je({locateFile:t.locateFile,files:function(t){return[{url:"hands_solution_packed_assets_loader.js"},{simd:!1,url:"hands_solution_wasm_bin.js"},{simd:!0,url:"hands_solution_simd_wasm_bin.js"},{data:!0,url:Ue(t.modelComplexity)}]},graph:{url:"hands.binarypb"},inputs:{image:{type:"video",stream:"input_frames_gpu"}},listeners:[{wants:["multi_hand_landmarks","multi_hand_world_landmarks","image_transformed","multi_handedness"],outs:{image:"image_transformed",multiHandLandmarks:{type:"proto_list",stream:"multi_hand_landmarks",transform:ke},multiHandWorldLandmarks:{type:"proto_list",stream:"multi_hand_world_landmarks",transform:ke},multiHandedness:{type:"proto_list",stream:"multi_handedness",transform:function(t){return t.map(function(t){return Ee(te(t,de,ge))[0]})}}}}],options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"object"==typeof window&&void 0!==window.navigator&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},maxNumHands:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculator",fieldName:"int_value"}},modelComplexity:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelComplexity",fieldName:"int_value"},onChange:function(t){var r,n,i;return A(function(o){return 1==o.g?(r=Ue(t),n="third_party/mediapipe/modules/hand_landmark/"+r,y(o,Me(e.g,r),2)):(i=o.h,e.g.overrideFile(n,i),o.return(!0))})}},minDetectionConfidence:{type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"handlandmarktrackinggpu__palmdetectiongpu__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"handlandmarktrackinggpu__handlandmarkgpu__ThresholdingCalculator",fieldName:"threshold"}}}})}(t=je.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},t.reset=function(){var t=this;return A(function(e){t.i&&(t.i.reset(),t.o={},t.u={}),e.g=0})},t.setOptions=function(t,e){var r=this;if(e=e||this.g.options){for(var n=[],i=[],o={},s=a(Object.keys(t)),u=s.next();!u.done;o={R:o.R,S:o.S},u=s.next()){var c=u.value;c in this.j&&this.j[c]===t[c]||(this.j[c]=t[c],void 0!==(u=e[c])&&(u.onChange&&(o.R=u.onChange,o.S=t[c],n.push(function(t){return function(){return A(function(e){if(1==e.g)return y(e,t.R(t.S),2);!0===e.h&&(r.s=!0),e.g=0})}}(o))),u.graphOptionXref&&(c={valueNumber:1===u.type?t[c]:0,valueBoolean:0===u.type&&t[c],valueString:2===u.type?t[c]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),c),i.push(u))))}(0!==n.length||0!==i.length)&&(this.s=!0,this.B=(void 0===this.B?[]:this.B).concat(i),this.A=(void 0===this.A?[]:this.A).concat(n))}},t.initialize=function(){var t=this;return A(function(e){return 1==e.g?y(e,Ce(t),2):3!=e.g?y(e,function(t){var e,r,n,i,o,s,u,c;return A(function(l){if(1==l.g)return t.g.graph&&t.g.graph.url&&t.Z===t.g.graph.url?l.return():(t.s=!0,t.g.graph&&t.g.graph.url?(t.Z=t.g.graph.url,y(l,Me(t,t.g.graph.url),3)):void(l.g=2));for(2!=l.g&&(e=l.h,t.i.loadGraph(e)),r=a(Object.keys(t.C)),n=r.next();!n.done;n=r.next())i=n.value,t.i.overrideFile(i,t.C[i]);if(t.C={},t.g.listeners)for(o=a(t.g.listeners),s=o.next();!s.done;s=o.next())u=s.value,Be(t,u);c=t.j,t.j={},t.setOptions(c),l.g=0})}(t),3):y(e,function(t){var e,r,n,i,o,s;return A(function(u){switch(u.g){case 1:if(!t.s)return u.return();if(!t.A){u.g=2;break}e=a(t.A),r=e.next();case 3:if(r.done){u.g=5;break}return y(u,(0,r.value)(),4);case 4:r=e.next(),u.g=3;break;case 5:t.A=void 0;case 2:if(t.B){for(n=new t.h.GraphOptionChangeRequestList,i=a(t.B),o=i.next();!o.done;o=i.next())s=o.value,n.push_back(s);t.i.changeOptions(n),n.delete(),t.B=void 0}t.s=!1,u.g=0}})}(t),0)})},t.overrideFile=function(t,e){this.i?this.i.overrideFile(t,e):this.C[t]=e},t.clearOverriddenFiles=function(){this.C={},this.i&&this.i.clearOverriddenFiles()},t.send=function(t,e){var r,n,i,o,s,u,c,l,f,h=this;return A(function(d){switch(d.g){case 1:return h.g.inputs?(r=1e3*(e??performance.now()),y(d,h.D,2)):d.return();case 2:return y(d,h.initialize(),3);case 3:for(n=new h.h.PacketDataList,i=a(Object.keys(t)),o=i.next();!o.done;o=i.next())if(s=o.value,u=h.g.inputs[s]){t:{var g=t[s];switch(u.type){case"video":var p=h.o[u.stream];if(p||(p=new Se(h.h,h.G),h.o[u.stream]=p),0===p.l&&(p.l=p.h.createTexture()),typeof HTMLVideoElement<"u"&&g instanceof HTMLVideoElement)var m=g.videoWidth,v=g.videoHeight;else typeof HTMLImageElement<"u"&&g instanceof HTMLImageElement?(m=g.naturalWidth,v=g.naturalHeight):(m=g.width,v=g.height);v={glName:p.l,width:m,height:v},(m=p.g).canvas.width=v.width,m.canvas.height=v.height,m.activeTexture(m.TEXTURE0),p.h.bindTexture2d(p.l),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,g),p.h.bindTexture2d(0),p=v;break t;case"detections":for((p=h.o[u.stream])||(p=new Oe(h.h),h.o[u.stream]=p),p.data||(p.data=new p.g.DetectionListData),p.data.reset(g.length),v=0;v<g.length;++v){m=g[v];var b=p.data,w=b.setBoundingBox,x=v,A=m.ea,_=new xe;if(yt(_,1,A.ka),yt(_,2,A.la),yt(_,3,A.height),yt(_,4,A.width),yt(_,5,A.rotation),yt(_,6,A.ia),A=re(_,Ae),w.call(b,x,A),m.Y)for(b=0;b<m.Y.length;++b){var E=!!(_=m.Y[b]).visibility;x=(w=p.data).addNormalizedLandmark,A=v,_=Object.assign(Object.assign({},_),{visibility:E?_.visibility:0}),yt(E=new me,1,_.x),yt(E,2,_.y),yt(E,3,_.z),_.visibility&&yt(E,4,_.visibility),_=re(E,ye),x.call(w,A,_)}if(m.V)for(b=0;b<m.V.length;++b)x=(w=p.data).addClassification,A=v,_=m.V[b],yt(E=new fe,2,_.score),_.index&&yt(E,1,_.index),_.label&&yt(E,3,_.label),_.displayName&&yt(E,4,_.displayName),_=re(E,he),x.call(w,A,_)}p=p.data;break t;default:p={}}}switch(c=p,l=u.stream,u.type){case"video":n.pushTexture2d(Object.assign(Object.assign({},c),{stream:l,timestamp:r}));break;case"detections":(f=c).stream=l,f.timestamp=r,n.pushDetectionList(f);break;default:throw Error("Unknown input config type: '"+u.type+"'")}}return h.i.send(n),y(d,h.D,4);case 4:n.delete(),d.g=0}})},t.onResults=function(t,e){this.listeners[e||"$"]=t},T("Solution",je),T("OptionType",{BOOL:0,NUMBER:1,ma:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(t=Ne.prototype).close=function(){return this.g.close(),Promise.resolve()},t.onResults=function(t){this.g.onResults(t)},t.initialize=function(){var t=this;return A(function(e){return y(e,t.g.initialize(),0)})},t.reset=function(){this.g.reset()},t.send=function(t){var e=this;return A(function(r){return y(r,e.g.send(t),0)})},t.setOptions=function(t){this.g.setOptions(t)},T("Hands",Ne),T("HAND_CONNECTIONS",[[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]]),T("VERSION","0.4.1646424915")}).call(ki);var Pi={};(function(){var t;function e(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var r="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,r){return t==Array.prototype||t==Object.prototype||(t[e]=r.value),t};var n=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var e=0;e<t.length;++e){var r=t[e];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);function i(t,e){if(e)t:{var i=n;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];if(!(a in i))break t;i=i[a]}(e=e(o=i[t=t[t.length-1]]))!=o&&null!=e&&r(i,t,{configurable:!0,writable:!0,value:e})}}function o(t){return(t={next:t})[Symbol.iterator]=function(){return this},t}function a(t){var r=typeof Symbol<"u"&&Symbol.iterator&&t[Symbol.iterator];return r?r.call(t):{next:e(t)}}function s(t){if(!(t instanceof Array)){t=a(t);for(var e,r=[];!(e=t.next()).done;)r.push(e.value);t=r}return t}i("Symbol",function(t){function e(t,e){this.g=t,r(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;e.prototype.toString=function(){return this.g};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",i=0;return function t(r){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(n+(r||"")+"_"+i++,r)}}),i("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var i="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),a=0;a<i.length;a++){var s=n[i[a]];"function"==typeof s&&"function"!=typeof s.prototype[t]&&r(s.prototype,t,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return t});var u,c="function"==typeof Object.create?Object.create:function(t){function e(){}return e.prototype=t,new e};if("function"==typeof Object.setPrototypeOf)u=Object.setPrototypeOf;else{var l;t:{var f={};try{f.__proto__={a:!0},l=f.a;break t}catch{}l=!1}u=l?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var h=u;function d(t,e){if(t.prototype=c(e.prototype),t.prototype.constructor=t,h)h(t,e);else for(var r in e)if("prototype"!=r)if(Object.defineProperties){var n=Object.getOwnPropertyDescriptor(e,r);n&&Object.defineProperty(t,r,n)}else t[r]=e[r];t.da=e.prototype}function g(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function p(t){if(t.l)throw new TypeError("Generator is already running");t.l=!0}function m(t,e){t.j={U:e,V:!0},t.g=t.m||t.s}function y(t,e,r){return t.g=r,{value:e}}function v(t){this.g=new g,this.h=t}function b(t,e,r,n){try{var i=e.call(t.g.i,r);if(!(i instanceof Object))throw new TypeError("Iterator result "+i+" is not an object");if(!i.done)return t.g.l=!1,i;var o=i.value}catch(e){return t.g.i=null,m(t.g,e),w(t)}return t.g.i=null,n.call(t.g,o),w(t)}function w(t){for(;t.g.g;)try{var e=t.h(t.g);if(e)return t.g.l=!1,{value:e.value,done:!1}}catch(e){t.g.h=void 0,m(t.g,e)}if(t.g.l=!1,t.g.j){if(e=t.g.j,t.g.j=null,e.V)throw e.U;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function x(t){this.next=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.next,e,t.g.o):(t.g.o(e),e=w(t)),e},this.throw=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.throw,e,t.g.o):(m(t.g,e),e=w(t)),e},this.return=function(e){return function(t,e){p(t.g);var r=t.g.i;return r?b(t,"return"in r?r.return:function(t){return{value:t,done:!0}},e,t.g.return):(t.g.return(e),w(t))}(t,e)},this[Symbol.iterator]=function(){return this}}function A(t){return function(t){function e(e){return t.next(e)}function r(e){return t.throw(e)}return new Promise(function(n,i){!function t(o){o.done?n(o.value):Promise.resolve(o.value).then(e,r).then(t,i)}(t.next())})}(new x(new v(t)))}g.prototype.o=function(t){this.h=t},g.prototype.return=function(t){this.j={return:t},this.g=this.s},i("Promise",function(t){function e(t){this.h=0,this.i=void 0,this.g=[],this.o=!1;var e=this.j();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function r(){this.g=null}function i(t){return t instanceof e?t:new e(function(e){e(t)})}if(t)return t;r.prototype.h=function(t){if(null==this.g){this.g=[];var e=this;this.i(function(){e.l()})}this.g.push(t)};var o=n.setTimeout;r.prototype.i=function(t){o(t,0)},r.prototype.l=function(){for(;this.g&&this.g.length;){var t=this.g;this.g=[];for(var e=0;e<t.length;++e){var r=t[e];t[e]=null;try{r()}catch(t){this.j(t)}}}this.g=null},r.prototype.j=function(t){this.i(function(){throw t})},e.prototype.j=function(){function t(t){return function(n){r||(r=!0,t.call(e,n))}}var e=this,r=!1;return{resolve:t(this.C),reject:t(this.l)}},e.prototype.C=function(t){if(t===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.F(t);else{t:switch(typeof t){case"object":var r=null!=t;break t;case"function":r=!0;break t;default:r=!1}r?this.v(t):this.m(t)}},e.prototype.v=function(t){var e=void 0;try{e=t.then}catch(t){return void this.l(t)}"function"==typeof e?this.G(e,t):this.m(t)},e.prototype.l=function(t){this.s(2,t)},e.prototype.m=function(t){this.s(1,t)},e.prototype.s=function(t,e){if(0!=this.h)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.h);this.h=t,this.i=e,2===this.h&&this.D(),this.A()},e.prototype.D=function(){var t=this;o(function(){if(t.B()){var e=n.console;typeof e<"u"&&e.error(t.i)}},1)},e.prototype.B=function(){if(this.o)return!1;var t=n.CustomEvent,e=n.Event,r=n.dispatchEvent;return typeof r>"u"||("function"==typeof t?t=new t("unhandledrejection",{cancelable:!0}):"function"==typeof e?t=new e("unhandledrejection",{cancelable:!0}):(t=n.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,t),t.promise=this,t.reason=this.i,r(t))},e.prototype.A=function(){if(null!=this.g){for(var t=0;t<this.g.length;++t)s.h(this.g[t]);this.g=null}};var s=new r;return e.prototype.F=function(t){var e=this.j();t.J(e.resolve,e.reject)},e.prototype.G=function(t,e){var r=this.j();try{t.call(e,r.resolve,r.reject)}catch(t){r.reject(t)}},e.prototype.then=function(t,r){function n(t,e){return"function"==typeof t?function(e){try{i(t(e))}catch(t){o(t)}}:e}var i,o,a=new e(function(t,e){i=t,o=e});return this.J(n(t,i),n(r,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.J=function(t,e){function r(){switch(n.h){case 1:t(n.i);break;case 2:e(n.i);break;default:throw Error("Unexpected state: "+n.h)}}var n=this;null==this.g?s.h(r):this.g.push(r),this.o=!0},e.resolve=i,e.reject=function(t){return new e(function(e,r){r(t)})},e.race=function(t){return new e(function(e,r){for(var n=a(t),o=n.next();!o.done;o=n.next())i(o.value).J(e,r)})},e.all=function(t){var r=a(t),n=r.next();return n.done?i([]):new e(function(t,e){function o(e){return function(r){a[e]=r,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,i(n.value).J(o(a.length-1),e),n=r.next()}while(!n.done)})},e});var _="function"==typeof Object.assign?Object.assign:function(t,e){for(var r=1;r<arguments.length;r++){var n=arguments[r];if(n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};i("Object.assign",function(t){return t||_}),i("Object.is",function(t){return t||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}}),i("Array.prototype.includes",function(t){return t||function(t,e){var r=this;r instanceof String&&(r=String(r));var n=r.length;for(0>(e=e||0)&&(e=Math.max(e+n,0));e<n;e++){var i=r[e];if(i===t||Object.is(i,t))return!0}return!1}}),i("String.prototype.includes",function(t){return t||function(t,e){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(t,e||0)}}),i("Array.prototype.keys",function(t){return t||function(){return function(t,e){t instanceof String&&(t+="");var r=0,n=!1,i={next:function(){if(!n&&r<t.length){var i=r++;return{value:e(i,t[i]),done:!1}}return n=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,function(t){return t})}});var E=this||self;function T(t,e){t=t.split(".");var r,n=E;t[0]in n||typeof n.execScript>"u"||n.execScript("var "+t[0]);for(;t.length&&(r=t.shift());)t.length||void 0===e?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=e}function k(t){!function(t){E.setTimeout(function(){throw t},0)}(t)}function S(t,e){k(Error("Invalid wire type: "+t+" (at position "+e+")"))}function F(){k(Error("Failed to read varint, encoding is invalid."))}function O(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}var R,I,P=typeof TextDecoder<"u",j=typeof TextEncoder<"u";function C(t){if(j)t=(I||(I=new TextEncoder)).encode(t);else{var e=void 0;e=void 0!==e&&e;for(var r=0,n=new Uint8Array(3*t.length),i=0;i<t.length;i++){var o=t.charCodeAt(i);if(128>o)n[r++]=o;else{if(2048>o)n[r++]=o>>6|192;else{if(55296<=o&&57343>=o){if(56319>=o&&i<t.length){var a=t.charCodeAt(++i);if(56320<=a&&57343>=a){o=1024*(o-55296)+a-56320+65536,n[r++]=o>>18|240,n[r++]=o>>12&63|128,n[r++]=o>>6&63|128,n[r++]=63&o|128;continue}i--}if(e)throw Error("Found an unpaired surrogate");o=65533}n[r++]=o>>12|224,n[r++]=o>>6&63|128}n[r++]=63&o|128}}t=n.subarray(0,r)}return t}var M={},L=null;function B(t){var e;void 0===e&&(e=0),N(),e=M[e];for(var r=Array(Math.floor(t.length/3)),n=e[64]||"",i=0,o=0;i<t.length-2;i+=3){var a=t[i],s=t[i+1],u=t[i+2],c=e[a>>2];a=e[(3&a)<<4|s>>4],s=e[(15&s)<<2|u>>6],u=e[63&u],r[o++]=c+a+s+u}switch(c=0,u=n,t.length-i){case 2:u=e[(15&(c=t[i+1]))<<2]||n;case 1:t=t[i],r[o]=e[t>>2]+e[(3&t)<<4|c>>4]+u+n}return r.join("")}function U(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){var r=t.charAt(n++),i=L[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}N();for(var n=0;;){var i=r(-1),o=r(0),a=r(64),s=r(64);if(64===s&&-1===i)break;e(i<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,function(t){n[i++]=t}),n.subarray(0,i)}function N(){if(!L){L={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));M[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===L[o]&&(L[o]=i)}}}}var D,z="function"==typeof Uint8Array;function G(t){if(this.g=t,null!==t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}G.prototype.toJSON=function(){if(null==this.g)var t="";else t=this.g,t=this.g=null==t||"string"==typeof t?t:z&&t instanceof Uint8Array?B(t):null;return t};var W="function"==typeof Uint8Array.prototype.slice;function H(t,e,r){return e===r?D||(D=new Uint8Array(0)):W?t.slice(e,r):new Uint8Array(t.subarray(e,r))}var V=0;function $(t,e){e=void 0!==(e=void 0===e?{}:e).u&&e.u,this.h=null,this.g=this.i=this.m=0,this.l=!1,this.u=e,t&&Y(this,t)}function Y(t,e){t.h=function(t){if(t.constructor===Uint8Array)return t;if(t.constructor===ArrayBuffer)return new Uint8Array(t);if(t.constructor===Array)return new Uint8Array(t);if(t.constructor===String)return U(t);if(t.constructor===G){if(null==t.g)var e=D||(D=new Uint8Array(0));else{e=Uint8Array;var r=t.g;r=null==r||z&&null!=r&&r instanceof Uint8Array?r:"string"==typeof r?U(r):null,e=new e(t=t.g=r)}return e}if(t instanceof Uint8Array)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}(e),t.m=0,t.i=t.h.length,t.g=t.m}function X(t){for(var e=128,r=0,n=0,i=0;4>i&&128<=e;i++)r|=(127&(e=t.h[t.g++]))<<7*i;if(128<=e&&(r|=(127&(e=t.h[t.g++]))<<28,n|=(127&e)>>4),128<=e)for(i=0;5>i&&128<=e;i++)n|=(127&(e=t.h[t.g++]))<<7*i+3;if(128>e)return t=r>>>0,(n=2147483648&(e=n>>>0))&&(e=~e>>>0,0==(t=1+~t>>>0)&&(e=e+1>>>0)),t=4294967296*e+(t>>>0),n?-t:t;t.l=!0,F()}function q(t){t.g>t.i&&(t.l=!0,k(Error("Tried to read past the end of the data "+t.g+" > "+t.i)))}$.prototype.reset=function(){this.g=this.m},$.prototype.j=function(){var t=this.h,e=t[this.g],r=127&e;return 128>e?(this.g+=1,q(this),r):(r|=(127&(e=t[this.g+1]))<<7,128>e?(this.g+=2,q(this),r):(r|=(127&(e=t[this.g+2]))<<14,128>e?(this.g+=3,q(this),r):(r|=(127&(e=t[this.g+3]))<<21,128>e?(this.g+=4,q(this),r):(r|=(15&(e=t[this.g+4]))<<28,128>e?(this.g+=5,q(this),r>>>0):(this.g+=5,128<=t[this.g++]&&128<=t[this.g++]&&128<=t[this.g++]&&128<=t[this.g++]&&128<=t[this.g++]?(this.l=!0,F(),r):(q(this),r))))))},$.prototype.o=function(){var t=this.h[this.g],e=this.h[this.g+1],r=this.h[this.g+2],n=this.h[this.g+3];return this.g+=4,q(this),t=2*((r=(t|e<<8|r<<16|n<<24)>>>0)>>31)+1,e=r>>>23&255,r&=8388607,255==e?r?NaN:1/0*t:0==e?t*Math.pow(2,-149)*r:t*Math.pow(2,e-150)*(r+Math.pow(2,23))};var K=[];function Q(){this.g=new Uint8Array(64),this.h=0}function J(t,e){if(!(t.h+1<t.g.length)){var r=t.g;t.g=new Uint8Array(Math.ceil(1+2*t.g.length)),t.g.set(r)}t.g[t.h++]=e}function Z(t,e){for(;127<e;)J(t,127&e|128),e>>>=7;J(t,e)}function tt(t){var e={},r=void 0!==e.N&&e.N;this.m={u:void 0!==e.u&&e.u},this.N=r,e=this.m,K.length?(r=K.pop(),e&&(r.u=e.u),t&&Y(r,t),t=r):t=new $(t,e),this.g=t,this.l=this.g.g,this.h=this.i=-1,this.j=!1}function et(t){var e=t.g;if((e=e.g==e.i)||(e=t.j)||(e=(e=t.g).l||0>e.g||e.g>e.i),e)return!1;t.l=t.g.g;var r=t.g.j();return e=r>>>3,0<=(r&=7)&&5>=r?(t.i=e,t.h=r,!0):(t.j=!0,S(r,t.l),!1)}function rt(t){switch(t.h){case 0:if(0!=t.h)rt(t);else t:{for(var e=(t=t.g).g,r=0;10>r;r++){if(!(128&t.h[e])){t.g=e+1,q(t);break t}e++}t.l=!0,F()}break;case 1:(t=t.g).g+=8,q(t);break;case 2:2!=t.h?rt(t):(e=t.g.j(),(t=t.g).g+=e,q(t));break;case 5:(t=t.g).g+=4,q(t);break;case 3:for(e=t.i;;){if(!et(t)){t.j=!0,k(Error("Unmatched start-group tag: stream EOF"));break}if(4==t.h){t.i!=e&&(t.j=!0,k(Error("Unmatched end-group tag")));break}rt(t)}break;default:t.j=!0,S(t.h,t.l)}}function nt(t,e,r){t.N||(t=H(t.g.h,r,t.g.g),(r=e.o)?r.push(t):e.o=[t])}function it(t,e,r){var n=t.g.i,i=t.g.j(),o=t.g.g+i;if(t.g.i=o,r(e,t),0!==(r=o-t.g.g))throw Error("Message parsing ended unexpectedly. Expected to read "+i+" bytes, instead read "+(i-r)+" bytes, either the data ended unexpectedly or the message misreported its own length");return t.g.g=o,t.g.i=n,e}function ot(t,e,r){var n=t.g.j();for(n=t.g.g+n;t.g.g<n;)r.push(e.call(t.g))}Q.prototype.length=function(){return this.h},Q.prototype.end=function(){var t=this.g,e=this.h;return this.h=0,H(t,0,e)},tt.prototype.reset=function(){this.g.reset(),this.h=this.i=-1};var at=[];function st(){this.h=[],this.i=0,this.g=new Q}function ut(t,e){0!==e.length&&(t.h.push(e),t.i+=e.length)}function ct(t,e,r){Z(t.g,8*e+2),Z(t.g,r.length),ut(t,t.g.end()),ut(t,r)}var lt,ft="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol(void 0):void 0;function ht(t,e){Object.isFrozen(t)||(ft?t[ft]|=e:void 0!==t.g?t.g|=e:Object.defineProperties(t,{g:{value:e,configurable:!0,writable:!0,enumerable:!1}}))}function dt(t){return t?(ft?t[ft]:t.g)??0:0}function gt(t){return Array.isArray(t)&&ht(t,1),t}function pt(t){if(!Array.isArray(t))throw Error("cannot mark non-array as immutable");ht(t,2)}function mt(t){return null!==t&&"object"==typeof t&&t.constructor===Object}function yt(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"object":return z&&null!=t&&t instanceof Uint8Array?B(t):t;default:return t}}function vt(t,e){if(null!=t)return Array.isArray(t)||mt(t)?bt(t,e):e(t)}function bt(t,e){if(Array.isArray(t)){for(var r=Array(t.length),n=0;n<t.length;n++)r[n]=vt(t[n],e);return 1&dt(t)&&gt(r),r}for(n in r={},t)r[n]=vt(t[n],e);return r}function wt(t,e,r){var n=lt;if(lt=null,t||(t=n),n=this.constructor.ba,t||(t=n?[n]:[]),this.j=(n?0:-1)-(this.constructor.$||0),this.m=this.g=null,this.h=t,t=(n=this.h.length)-1,n&&mt(n=this.h[t])?(this.l=t-this.j,this.i=n):void 0!==e&&-1<e?(this.l=Math.max(e,t+1-this.j),this.i=null):this.l=Number.MAX_VALUE,r)for(e=0;e<r.length;e++)(t=r[e])<this.l?(t+=this.j,(n=this.h[t])?gt(n):this.h[t]=At):(_t(this),(n=this.i[t])?gt(n):this.i[t]=At)}var xt,At=Object.freeze(gt([]));function _t(t){var e=t.l+t.j;t.h[e]||(t.i=t.h[e]={})}function Et(t,e,r){return-1===e?null:void 0!==r&&r||e>=t.l?t.i?t.i[e]:void 0:t.h[e+t.j]}function Tt(t,e,r){r=void 0===r||r;var n=void 0!==n&&n,i=Et(t,e,n);return null==i&&(i=At),i===At?Ot(t,e,i=gt([]),n):r&&Array.isArray(i)&&2&dt(i)&&Ot(t,e,i=i.slice(),n),i}function kt(t){var e=Tt(t,3,!1);if(t.m||(t.m={}),!t.m[3]){for(var r=0;r<e.length;r++)e[r]=+e[r];t.m[3]=!0}return e}function St(t,e,r){return(t=Et(t,e))??r}function Ft(t,e,r){return(t=null==(t=Et(t,e))?t:+t)??(void 0===r?0:r)}function Ot(t,e,r,n){void 0!==n&&n||e>=t.l?(_t(t),t.i[e]=r):t.h[e+t.j]=r}function Rt(t,e,r){if(-1===r)return null;t.g||(t.g={});var n=t.g[r];if(n)return n;var i=Et(t,r,!1);return null==i?n:(e=new e(i),t.g[r]=e)}function It(t,e,r){t.g||(t.g={});var n=t.g[r];if(!n){var i=Tt(t,r,!1);n=[];for(var o=!!Array.isArray(i)&&!!(2&dt(i)),a=0;a<i.length;a++)n[a]=new e(i[a]),o&&pt(n[a].h);o&&(pt(n),Object.freeze(n)),t.g[r]=n}return n}function Pt(t,e,r,n,i){var o=It(t,n,e);r=r||new n,t=Tt(t,e),null!=i?(o.splice(i,0,r),t.splice(i,0,jt(r))):(o.push(r),t.push(jt(r)))}function jt(t){if(t.g)for(var e in t.g){var r=t.g[e];if(Array.isArray(r))for(var n=0;n<r.length;n++)r[n]&&jt(r[n]);else r&&jt(r)}return t.h}function Ct(t,e){if(t=t.o){ut(e,e.g.end());for(var r=0;r<t.length;r++)ut(e,t[r])}}function Mt(t){var e=t[0];switch(t.length){case 2:var r=t[1];return function(t,n,i){return e(t,n,i,r)};case 3:var n=t[1],i=t[2];return function(t,r,o){return e(t,r,o,n,i)};case 4:var o=t[1],a=t[2],s=t[3];return function(t,r,n){return e(t,r,n,o,a,s)};default:throw Error("unsupported number of parameters, expected [2-4], got "+t.length)}}function Lt(t,e,r){for(;et(e)&&4!=e.h;){var n=e.i,i=r[n];if(i){if(Array.isArray(i)&&(i=r[n]=Mt(i)),!i(e,t,n)){i=t;var o=(n=e).l;rt(n),nt(n,i,o)}}else i=t,o=(n=e).l,rt(n),nt(n,i,o)}return t}function Bt(t,e){var r=new st;if(e(t,r),0===(t=r.i+r.g.length()))r=new Uint8Array(0);else{t=new Uint8Array(t);for(var n=r.h,i=n.length,o=e=0;o<i;o++){var a=n[o];0!==a.length&&(t.set(a,e),e+=a.length)}0!==(i=(n=r.g).h)&&(t.set(n.g.subarray(0,i),e),n.h=0),r.h=[t],r=t}return r}function Ut(t,e,r){if(at.length){var n=at.pop();t&&(Y(n.g,t),n.i=-1,n.h=-1),t=n}else t=new tt(t);try{return r(new e,t)}finally{(e=t.g).h=null,e.m=0,e.i=0,e.g=0,e.l=!1,e.u=!1,t.i=-1,t.h=-1,t.j=!1,100>at.length&&at.push(t)}}function Nt(t,e,r){if(null!=(e=Et(e,r))){Z(t.g,8*r+5),t=t.g;var n=e;0===(n=(r=0>n?1:0)?-n:n)?0<1/n?V=0:V=2147483648:isNaN(n)?V=2147483647:34028234663852886e22<n?V=(r<<31|2139095040)>>>0:11754943508222875e-54>n?(n=Math.round(n/Math.pow(2,-149)),V=(r<<31|n)>>>0):(e=Math.floor(Math.log(n)/Math.LN2),n*=Math.pow(2,-e),16777216<=(n=Math.round(8388608*n))&&++e,V=(r<<31|e+127<<23|8388607&n)>>>0),J(t,(r=V)>>>0&255),J(t,r>>>8&255),J(t,r>>>16&255),J(t,r>>>24&255)}}function Dt(t,e,r){return 5===t.h&&(Ot(e,r,t.g.o()),!0)}function zt(t,e,r){return(5===t.h||2===t.h)&&(e=Tt(e,r),2==t.h?ot(t,$.prototype.o,e):e.push(t.g.o()),!0)}function Gt(t,e,r){return 0===t.h&&(Ot(e,r,X(t.g)),!0)}function Wt(t,e,r){return 0===t.h&&(Ot(e,r,t.g.j()),!0)}function Ht(t,e,r){if(2!==t.h)return!1;var n,i=t.g.j(),o=(t=t.g).g;if(t.g+=i,q(t),t=t.h,P)(n=R)||(n=R=new TextDecoder("utf-8",{fatal:!1})),n=n.decode(t.subarray(o,o+i));else{i=o+i;for(var a,s,u,c=[],l=null;o<i;)128>(a=t[o++])?c.push(a):224>a?o>=i?c.push(65533):(s=t[o++],194>a||128!=(192&s)?(o--,c.push(65533)):c.push((31&a)<<6|63&s)):240>a?o>=i-1?c.push(65533):128!=(192&(s=t[o++]))||224===a&&160>s||237===a&&160<=s||128!=(192&(n=t[o++]))?(o--,c.push(65533)):c.push((15&a)<<12|(63&s)<<6|63&n):244>=a?o>=i-2?c.push(65533):128!=(192&(s=t[o++]))||s-144+(a<<28)>>30||128!=(192&(n=t[o++]))||128!=(192&(u=t[o++]))?(o--,c.push(65533)):(a=(7&a)<<18|(63&s)<<12|(63&n)<<6|63&u,a-=65536,c.push(55296+(a>>10&1023),56320+(1023&a))):c.push(65533),8192<=c.length&&(l=O(l,c),c.length=0);n=O(l,c)}return Ot(e,r,n),!0}function Vt(t,e,r,n,i){if(2!==t.h)return!1;t=it(t,new n,i);var o=void 0!==o&&o;return e.g||(e.g={}),n=t&&jt(t),e.g[r]=t,Ot(e,r,n,o),!0}function $t(t,e,r,n,i){return 2===t.h&&(Pt(e,r,t=it(t,new n,i),n,void 0),!0)}function Yt(t,e,r){return(0===t.h||2===t.h)&&(e=Tt(e,r),2==t.h?ot(t,$.prototype.j,e):e.push(t.g.j()),!0)}function Xt(t,e,r){return 0===t.h&&(Ot(e,r,X(t.g)),!0)}function qt(t){wt.call(this,t,-1,Zt)}function Kt(t,e){return Lt(t,e,xt||(xt={1:Wt,2:Wt,3:zt,4:Xt}))}wt.prototype.toJSON=function(){return bt(jt(this),yt)},wt.prototype.toString=function(){return jt(this).toString()},d(qt,wt),qt.prototype.getRows=function(){return Et(this,1)},qt.prototype.getCols=function(){return Et(this,2)},qt.prototype.getPackedDataList=function(){return kt(this)},qt.prototype.getLayout=function(){return St(this,4,0)};var Qt,Jt,Zt=[3];function te(t){wt.call(this,t)}function ee(t,e){var r=Et(t,1);if(null!=r&&null!=r){Z(e.g,8);var n=e.g;if(0<=r)Z(n,r);else{for(var i=0;9>i;i++)J(n,127&r|128),r>>=7;J(n,1)}}Nt(e,t,2),null!=(n=Et(t,3))&&ct(e,3,C(n)),null!=(n=Et(t,4))&&ct(e,4,C(n)),Ct(t,e)}function re(t,e){return Lt(t,e,Qt||(Qt={1:Wt,2:Dt,3:Ht,4:Ht}))}function ne(t){wt.call(this,t,-1,se)}function ie(t,e){return Lt(t,e,Jt||(Jt={1:[$t,te,re]}))}d(te,wt),d(ne,wt),ne.prototype.addClassification=function(t,e){return Pt(this,1,t,te,e),this};var oe,ae,se=[1];function ue(t){wt.call(this,t)}function ce(t,e){Nt(e,t,1),Nt(e,t,2),Nt(e,t,3),Nt(e,t,4),Nt(e,t,5),Ct(t,e)}function le(t,e){return Lt(t,e,oe||(oe={1:Dt,2:Dt,3:Dt,4:Dt,5:Dt}))}function fe(t){wt.call(this,t,-1,pe)}function he(t,e){return Lt(t,e,ae||(ae={1:[$t,ue,le]}))}d(ue,wt),d(fe,wt);var de,ge,pe=[1];function me(t){wt.call(this,t)}function ye(t,e){Nt(e,t,1),Nt(e,t,2),Nt(e,t,3),Nt(e,t,4),Nt(e,t,5);var r=Et(t,6);if(null!=r&&null!=r){Z(e.g,48);var n=e.g,i=r;r=0>i;var o=(i=Math.abs(i))>>>0;for(i=Math.floor((i-o)/4294967296),i>>>=0,r&&(i=~i>>>0,4294967295<(o=(~o>>>0)+1)&&(o=0,4294967295<++i&&(i=0))),r=V=o,o=i;0<o||127<r;)J(n,127&r|128),r=(r>>>7|o<<25)>>>0,o>>>=7;J(n,r)}Ct(t,e)}function ve(t,e){return Lt(t,e,de||(de={1:Dt,2:Dt,3:Dt,4:Dt,5:Dt,6:Gt}))}function be(t){wt.call(this,t,-1,Ae)}function we(t,e){return Lt(t,e,ge||(ge={1:Xt,2:Xt,3:zt,4:Yt}))}d(me,wt),d(be,wt),be.prototype.getVertexType=function(){return St(this,1,0)},be.prototype.getPrimitiveType=function(){return St(this,2,0)},be.prototype.getVertexBufferList=function(){return kt(this)},be.prototype.getIndexBufferList=function(){return Tt(this,4)};var xe,Ae=[3,4];function _e(t){wt.call(this,t)}function Ee(t,e){return Lt(t,e,xe||(xe={1:[Vt,be,we],2:[Vt,qt,Kt]}))}d(_e,wt),_e.prototype.getMesh=function(){return Rt(this,be,1)},_e.prototype.getPoseTransformMatrix=function(){return Rt(this,qt,2)};var Te=[[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]],ke=[[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]],Se=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Fe=[[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]],Oe=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Re=[[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]],Ie=[].concat(s(Te),s(ke),s(Se),s(Fe),s(Oe),s(Re));function Pe(t,e,r){if(r=t.createShader(0===r?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+t.getShaderInfoLog(r));return r}function je(t){return It(t,te,1).map(function(t){return{index:St(t,1,0),score:Ft(t,2),label:null!=Et(t,3)?St(t,3,""):void 0,displayName:null!=Et(t,4)?St(t,4,""):void 0}})}function Ce(t){return{x:Ft(t,1),y:Ft(t,2),z:Ft(t,3),visibility:null!=Et(t,4)?Ft(t,4):void 0}}function Me(t){return It(Ut(t,fe,he),ue,1).map(Ce)}function Le(t,e){this.h=t,this.g=e,this.l=0}function Be(t,e,r){return function(t,e){var r=t.g;if(void 0===t.m){var n=Pe(r,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",0),i=Pe(r,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=r.createProgram();if(r.attachShader(o,n),r.attachShader(o,i),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+r.getProgramInfoLog(o));n=t.m=o,r.useProgram(n),i=r.getUniformLocation(n,"sampler0"),t.j={I:r.getAttribLocation(n,"aVertex"),H:r.getAttribLocation(n,"aTex"),ca:i},t.s=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.enableVertexAttribArray(t.j.I),r.vertexAttribPointer(t.j.I,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),t.o=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.enableVertexAttribArray(t.j.H),r.vertexAttribPointer(t.j.H,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.uniform1i(i,0)}n=t.j,r.useProgram(t.m),r.canvas.width=e.width,r.canvas.height=e.height,r.viewport(0,0,e.width,e.height),r.activeTexture(r.TEXTURE0),t.h.bindTexture2d(e.glName),r.enableVertexAttribArray(n.I),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.vertexAttribPointer(n.I,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(n.H),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.vertexAttribPointer(n.H,2,r.FLOAT,!1,0,0),r.bindFramebuffer(r.DRAW_FRAMEBUFFER?r.DRAW_FRAMEBUFFER:r.FRAMEBUFFER,null),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.colorMask(!0,!0,!0,!0),r.drawArrays(r.TRIANGLE_FAN,0,4),r.disableVertexAttribArray(n.I),r.disableVertexAttribArray(n.H),r.bindBuffer(r.ARRAY_BUFFER,null),t.h.bindTexture2d(0)}(t,e),"function"==typeof t.g.canvas.transferToImageBitmap?Promise.resolve(t.g.canvas.transferToImageBitmap()):r?Promise.resolve(t.g.canvas):"function"==typeof createImageBitmap?createImageBitmap(t.g.canvas):(void 0===t.i&&(t.i=document.createElement("canvas")),new Promise(function(e){t.i.height=t.g.canvas.height,t.i.width=t.g.canvas.width,t.i.getContext("2d",{}).drawImage(t.g.canvas,0,0,t.g.canvas.width,t.g.canvas.height),e(t.i)}))}function Ue(t){this.g=t}var Ne=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function De(t,e){return e+t}function ze(t,e){window[t]=e}function Ge(t){if(this.g=t,this.listeners={},this.j={},this.F={},this.m={},this.s={},this.G=this.o=this.R=!0,this.C=Promise.resolve(),this.P="",this.B={},this.locateFile=t&&t.locateFile||De,"object"==typeof window)var e=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(!(typeof location<"u"))throw Error("solutions can only be loaded on a web page or in a web worker");e=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.S=e,t.options)for(var r=(e=a(Object.keys(t.options))).next();!r.done;r=e.next()){r=r.value;var n=t.options[r].default;void 0!==n&&(this.j[r]="function"==typeof n?n():n)}}function We(t){var e,r,n,i,o,a,u,c,l,f,h;return A(function(d){switch(d.g){case 1:return t.R?(e=void 0===t.g.files?[]:"function"==typeof t.g.files?t.g.files(t.j):t.g.files,y(d,A(function(t){switch(t.g){case 1:return t.m=2,y(t,WebAssembly.instantiate(Ne),4);case 4:t.g=3,t.m=0;break;case 2:return t.m=0,t.j=null,t.return(!1);case 3:return t.return(!0)}}),2)):d.return();case 2:if(r=d.h,"object"==typeof window)return ze("createMediapipeSolutionsWasm",{locateFile:t.locateFile}),ze("createMediapipeSolutionsPackedAssets",{locateFile:t.locateFile}),a=e.filter(function(t){return void 0!==t.data}),u=e.filter(function(t){return void 0===t.data}),c=Promise.all(a.map(function(e){var r=He(t,e.url);if(void 0!==e.path){var n=e.path;r=r.then(function(e){return t.overrideFile(n,e),Promise.resolve(e)})}return r})),l=Promise.all(u.map(function(e){return void 0===e.simd||e.simd&&r||!e.simd&&!r?function(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(t){e.addEventListener("load",function(){t()},!1),e.addEventListener("error",function(){t()},!1),document.body.appendChild(e)})}(t.locateFile(e.url,t.S)):Promise.resolve()})).then(function(){var e,r,n;return A(function(i){if(1==i.g)return e=window.createMediapipeSolutionsWasm,r=window.createMediapipeSolutionsPackedAssets,n=t,y(i,e(r),2);n.h=i.h,i.g=0})}),f=A(function(e){return t.g.graph&&t.g.graph.url?e=y(e,He(t,t.g.graph.url),0):(e.g=0,e=void 0),e}),y(d,Promise.all([l,c,f]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return n=e.filter(function(t){return void 0===t.simd||t.simd&&r||!t.simd&&!r}).map(function(e){return t.locateFile(e.url,t.S)}),importScripts.apply(null,s(n)),i=t,y(d,createMediapipeSolutionsWasm(Module),6);case 6:i.h=d.h,t.l=new OffscreenCanvas(1,1),t.h.canvas=t.l,o=t.h.GL.createContext(t.l,{antialias:!1,alpha:!1,aa:typeof WebGL2RenderingContext<"u"?2:1}),t.h.GL.makeContextCurrent(o),d.g=4;break;case 7:if(t.l=document.createElement("canvas"),!(h=t.l.getContext("webgl2",{}))&&!(h=t.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),d.return();t.D=h,t.h.canvas=t.l,t.h.createContext(t.l,!0,!0,{});case 4:t.i=new t.h.SolutionWasm,t.R=!1,d.g=0}})}function He(t,e){var r,n;return A(function(i){return e in t.F?i.return(t.F[e]):(r=t.locateFile(e,""),n=fetch(r).then(function(t){return t.arrayBuffer()}),t.F[e]=n,i.return(n))})}function Ve(t,e,r){var n,i,o,s,u,c,l,f,h,d,g,p,m,v;return A(function(b){switch(b.g){case 1:if(!r)return b.return(e);for(n={},i=0,o=a(Object.keys(r)),s=o.next();!s.done;s=o.next())u=s.value,"string"!=typeof(c=r[u])&&"texture"===c.type&&void 0!==e[c.stream]&&++i;1<i&&(t.G=!1),l=a(Object.keys(r)),s=l.next();case 2:if(s.done){b.g=4;break}if(f=s.value,"string"==typeof(h=r[f]))return m=n,v=f,y(b,function(t,e,r){var n;return A(function(i){return"number"==typeof r||r instanceof Uint8Array||r instanceof t.h.Uint8BlobList?i.return(r):r instanceof t.h.Texture2dDataOut?((n=t.s[e])||(n=new Le(t.h,t.D),t.s[e]=n),i.return(Be(n,r,t.G))):i.return(void 0)})}(t,f,e[h]),14);if(d=e[h.stream],"detection_list"===h.type){if(d){for(var w=d.getRectList(),x=d.getLandmarksList(),_=d.getClassificationsList(),E=[],T=0;T<w.size();++T){var k=Ut(w.get(T),me,ve);k={T:{X:Ft(k,1),Y:Ft(k,2),height:Ft(k,3),width:Ft(k,4),rotation:Ft(k,5,0),W:St(k,6,0)},O:Me(x.get(T)),M:je(Ut(_.get(T),ne,ie))},E.push(k)}w=E}else w=[];n[f]=w,b.g=7;break}if("proto_list"===h.type){if(d){for(w=Array(d.size()),x=0;x<d.size();x++)w[x]=d.get(x);d.delete()}else w=[];n[f]=w,b.g=7;break}if(void 0===d){b.g=3;break}if("float_list"===h.type){n[f]=d,b.g=7;break}if("proto"===h.type){n[f]=d,b.g=7;break}if("texture"!==h.type)throw Error("Unknown output config type: '"+h.type+"'");return(g=t.s[f])||(g=new Le(t.h,t.D),t.s[f]=g),y(b,Be(g,d,t.G),13);case 13:p=b.h,n[f]=p;case 7:h.transform&&n[f]&&(n[f]=h.transform(n[f])),b.g=3;break;case 14:m[v]=b.h;case 3:s=l.next(),b.g=2;break;case 4:return b.return(n)}})}function $e(t,e){for(var r=e.name||"$",n=[].concat(s(e.wants)),i=new t.h.StringList,o=a(e.wants),u=o.next();!u.done;u=o.next())i.push_back(u.value);o=t.h.PacketListener.implement({onResults:function(i){for(var o={},a=0;a<e.wants.length;++a)o[n[a]]=i.get(a);var s=t.listeners[r];s&&(t.C=Ve(t,o,e.outs).then(function(r){r=s(r);for(var i=0;i<e.wants.length;++i){var a=o[n[i]];"object"==typeof a&&a.hasOwnProperty&&a.hasOwnProperty("delete")&&a.delete()}r&&(t.C=r)}))}}),t.i.attachMultiListener(i,o),i.delete()}function Ye(t){return t.map(Xe)}function Xe(t){var e=(t=Ut(t,_e,Ee)).getMesh();if(!e)return t;var r=new Float32Array(e.getVertexBufferList());e.getVertexBufferList=function(){return r};var n=new Uint32Array(e.getIndexBufferList());return e.getIndexBufferList=function(){return n},t}function qe(t){var e=this;t=t||{},this.g=new Ge({locateFile:t.locateFile,files:[{url:"holistic_solution_packed_assets_loader.js"},{simd:!1,url:"holistic_solution_wasm_bin.js"},{simd:!0,url:"holistic_solution_simd_wasm_bin.js"}],graph:{url:"holistic.binarypb"},inputs:{image:{type:"video",stream:"input_frames_gpu"}},listeners:[{wants:"left_hand_landmarks right_hand_landmarks face_landmarks pose_landmarks world_landmarks segmentation_mask image_transformed multi_face_geometry".split(" "),outs:{image:{type:"texture",stream:"image_transformed"},leftHandLandmarks:{type:"proto",stream:"left_hand_landmarks",transform:Me},rightHandLandmarks:{type:"proto",stream:"right_hand_landmarks",transform:Me},faceLandmarks:{type:"proto",stream:"face_landmarks",transform:Me},poseLandmarks:{type:"proto",stream:"pose_landmarks",transform:Me},ea:{type:"proto",stream:"world_landmarks",transform:Me},segmentationMask:{type:"texture",stream:"segmentation_mask"},multiFaceGeometry:{type:"proto_list",stream:"multi_face_geometry",transform:Ye}}}],options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document},enableFaceGeometry:{type:0,graphOptionXref:{calculatorName:"EnableFaceGeometryConstant",calculatorType:"ConstantSidePacketCalculator",fieldName:"bool_value"}},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelComplexity:{type:1,default:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelComplexity",fieldName:"int_value"},onChange:function(t){var r,n,i,o;return A(function(a){if(1==a.g){switch(r="",t){case 1:r="pose_landmark_full.tflite";break;case 2:r="pose_landmark_heavy.tflite";break;default:r="pose_landmark_lite.tflite"}return n="third_party/mediapipe/modules/pose_landmark/"+r,i=e.g.locateFile(r,""),y(a,fetch(i),3)}return 2!=a.g?y(a,a.h.arrayBuffer(),2):(o=a.h,e.g.overrideFile(n,o),y(a,e.g.reset(),0))})}},smoothLandmarks:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorSmoothLandmarks",fieldName:"bool_value"}},enableSegmentation:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorEnableSegmentation",fieldName:"bool_value"}},smoothSegmentation:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorSmoothSegmentation",fieldName:"bool_value"}},refineFaceLandmarks:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorRefineFaceLandmarks",fieldName:"bool_value"}},minDetectionConfidence:{type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"holisticlandmarkgpu__poselandmarkgpu__posedetectiongpu__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"holisticlandmarkgpu__poselandmarkgpu__poselandmarkbyroigpu__tensorstoposelandmarksandsegmentation__ThresholdingCalculator",fieldName:"threshold"}},cameraNear:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"near"}},cameraFar:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"far"}},cameraVerticalFovDegrees:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"vertical_fov_degrees"}}}})}(t=Ge.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},t.reset=function(){var t=this;return A(function(e){t.i&&(t.i.reset(),t.m={},t.s={}),e.g=0})},t.setOptions=function(t,e){var r=this;if(e=e||this.g.options){for(var n=[],i=[],o={},s=a(Object.keys(t)),u=s.next();!u.done;o={K:o.K,L:o.L},u=s.next()){var c=u.value;c in this.j&&this.j[c]===t[c]||(this.j[c]=t[c],void 0!==(u=e[c])&&(u.onChange&&(o.K=u.onChange,o.L=t[c],n.push(function(t){return function(){return A(function(e){if(1==e.g)return y(e,t.K(t.L),2);!0===e.h&&(r.o=!0),e.g=0})}}(o))),u.graphOptionXref&&(c={valueNumber:1===u.type?t[c]:0,valueBoolean:0===u.type&&t[c],valueString:2===u.type?t[c]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),c),i.push(u))))}(0!==n.length||0!==i.length)&&(this.o=!0,this.A=(void 0===this.A?[]:this.A).concat(i),this.v=(void 0===this.v?[]:this.v).concat(n))}},t.initialize=function(){var t=this;return A(function(e){return 1==e.g?y(e,We(t),2):3!=e.g?y(e,function(t){var e,r,n,i,o,s,u,c;return A(function(l){if(1==l.g)return t.g.graph&&t.g.graph.url&&t.P===t.g.graph.url?l.return():(t.o=!0,t.g.graph&&t.g.graph.url?(t.P=t.g.graph.url,y(l,He(t,t.g.graph.url),3)):void(l.g=2));for(2!=l.g&&(e=l.h,t.i.loadGraph(e)),r=a(Object.keys(t.B)),n=r.next();!n.done;n=r.next())i=n.value,t.i.overrideFile(i,t.B[i]);if(t.B={},t.g.listeners)for(o=a(t.g.listeners),s=o.next();!s.done;s=o.next())u=s.value,$e(t,u);c=t.j,t.j={},t.setOptions(c),l.g=0})}(t),3):y(e,function(t){var e,r,n,i,o,s;return A(function(u){switch(u.g){case 1:if(!t.o)return u.return();if(!t.v){u.g=2;break}e=a(t.v),r=e.next();case 3:if(r.done){u.g=5;break}return y(u,(0,r.value)(),4);case 4:r=e.next(),u.g=3;break;case 5:t.v=void 0;case 2:if(t.A){for(n=new t.h.GraphOptionChangeRequestList,i=a(t.A),o=i.next();!o.done;o=i.next())s=o.value,n.push_back(s);t.i.changeOptions(n),n.delete(),t.A=void 0}t.o=!1,u.g=0}})}(t),0)})},t.overrideFile=function(t,e){this.i?this.i.overrideFile(t,e):this.B[t]=e},t.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},t.send=function(t,e){var r,n,i,o,s,u,c,l,f,h=this;return A(function(d){switch(d.g){case 1:return h.g.inputs?(r=1e3*(e??performance.now()),y(d,h.C,2)):d.return();case 2:return y(d,h.initialize(),3);case 3:for(n=new h.h.PacketDataList,i=a(Object.keys(t)),o=i.next();!o.done;o=i.next())if(s=o.value,u=h.g.inputs[s]){t:{var g=t[s];switch(u.type){case"video":var p=h.m[u.stream];if(p||(p=new Le(h.h,h.D),h.m[u.stream]=p),0===p.l&&(p.l=p.h.createTexture()),typeof HTMLVideoElement<"u"&&g instanceof HTMLVideoElement)var m=g.videoWidth,v=g.videoHeight;else typeof HTMLImageElement<"u"&&g instanceof HTMLImageElement?(m=g.naturalWidth,v=g.naturalHeight):(m=g.width,v=g.height);v={glName:p.l,width:m,height:v},(m=p.g).canvas.width=v.width,m.canvas.height=v.height,m.activeTexture(m.TEXTURE0),p.h.bindTexture2d(p.l),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,g),p.h.bindTexture2d(0),p=v;break t;case"detections":for((p=h.m[u.stream])||(p=new Ue(h.h),h.m[u.stream]=p),p.data||(p.data=new p.g.DetectionListData),p.data.reset(g.length),v=0;v<g.length;++v){m=g[v];var b=p.data,w=b.setBoundingBox,x=v,A=m.T,_=new me;if(Ot(_,1,A.X),Ot(_,2,A.Y),Ot(_,3,A.height),Ot(_,4,A.width),Ot(_,5,A.rotation),Ot(_,6,A.W),A=Bt(_,ye),w.call(b,x,A),m.O)for(b=0;b<m.O.length;++b){var E=!!(_=m.O[b]).visibility;x=(w=p.data).addNormalizedLandmark,A=v,_=Object.assign(Object.assign({},_),{visibility:E?_.visibility:0}),Ot(E=new ue,1,_.x),Ot(E,2,_.y),Ot(E,3,_.z),_.visibility&&Ot(E,4,_.visibility),_=Bt(E,ce),x.call(w,A,_)}if(m.M)for(b=0;b<m.M.length;++b)x=(w=p.data).addClassification,A=v,_=m.M[b],Ot(E=new te,2,_.score),_.index&&Ot(E,1,_.index),_.label&&Ot(E,3,_.label),_.displayName&&Ot(E,4,_.displayName),_=Bt(E,ee),x.call(w,A,_)}p=p.data;break t;default:p={}}}switch(c=p,l=u.stream,u.type){case"video":n.pushTexture2d(Object.assign(Object.assign({},c),{stream:l,timestamp:r}));break;case"detections":(f=c).stream=l,f.timestamp=r,n.pushDetectionList(f);break;default:throw Error("Unknown input config type: '"+u.type+"'")}}return h.i.send(n),y(d,h.C,4);case 4:n.delete(),d.g=0}})},t.onResults=function(t,e){this.listeners[e||"$"]=t},T("Solution",Ge),T("OptionType",{BOOL:0,NUMBER:1,Z:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(t=qe.prototype).close=function(){return this.g.close(),Promise.resolve()},t.onResults=function(t){this.g.onResults(t)},t.initialize=function(){var t=this;return A(function(e){return y(e,t.g.initialize(),0)})},t.reset=function(){this.g.reset()},t.send=function(t){var e=this;return A(function(r){return y(r,e.g.send(t),0)})},t.setOptions=function(t){this.g.setOptions(t)},T("Holistic",qe),T("FACE_GEOMETRY",{Layout:{COLUMN_MAJOR:0,ROW_MAJOR:1,0:"COLUMN_MAJOR",1:"ROW_MAJOR"},PrimitiveType:{TRIANGLE:0,0:"TRIANGLE"},VertexType:{VERTEX_PT:0,0:"VERTEX_PT"},DEFAULT_CAMERA_PARAMS:{verticalFovDegrees:63,near:1,far:1e4}}),T("FACEMESH_LIPS",Te),T("FACEMESH_LEFT_EYE",ke),T("FACEMESH_LEFT_EYEBROW",Se),T("FACEMESH_LEFT_IRIS",[[474,475],[475,476],[476,477],[477,474]]),T("FACEMESH_RIGHT_EYE",Fe),T("FACEMESH_RIGHT_EYEBROW",Oe),T("FACEMESH_RIGHT_IRIS",[[469,470],[470,471],[471,472],[472,469]]),T("FACEMESH_FACE_OVAL",Re),T("FACEMESH_CONTOURS",Ie),T("FACEMESH_TESSELATION",[[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]]),T("HAND_CONNECTIONS",[[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]]),T("POSE_CONNECTIONS",[[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]]),T("POSE_LANDMARKS",{NOSE:0,LEFT_EYE_INNER:1,LEFT_EYE:2,LEFT_EYE_OUTER:3,RIGHT_EYE_INNER:4,RIGHT_EYE:5,RIGHT_EYE_OUTER:6,LEFT_EAR:7,RIGHT_EAR:8,LEFT_RIGHT:9,RIGHT_LEFT:10,LEFT_SHOULDER:11,RIGHT_SHOULDER:12,LEFT_ELBOW:13,RIGHT_ELBOW:14,LEFT_WRIST:15,RIGHT_WRIST:16,LEFT_PINKY:17,RIGHT_PINKY:18,LEFT_INDEX:19,RIGHT_INDEX:20,LEFT_THUMB:21,RIGHT_THUMB:22,LEFT_HIP:23,RIGHT_HIP:24,LEFT_KNEE:25,RIGHT_KNEE:26,LEFT_ANKLE:27,RIGHT_ANKLE:28,LEFT_HEEL:29,RIGHT_HEEL:30,LEFT_FOOT_INDEX:31,RIGHT_FOOT_INDEX:32}),T("POSE_LANDMARKS_LEFT",{LEFT_EYE_INNER:1,LEFT_EYE:2,LEFT_EYE_OUTER:3,LEFT_EAR:7,LEFT_RIGHT:9,LEFT_SHOULDER:11,LEFT_ELBOW:13,LEFT_WRIST:15,LEFT_PINKY:17,LEFT_INDEX:19,LEFT_THUMB:21,LEFT_HIP:23,LEFT_KNEE:25,LEFT_ANKLE:27,LEFT_HEEL:29,LEFT_FOOT_INDEX:31}),T("POSE_LANDMARKS_RIGHT",{RIGHT_EYE_INNER:4,RIGHT_EYE:5,RIGHT_EYE_OUTER:6,RIGHT_EAR:8,RIGHT_LEFT:10,RIGHT_SHOULDER:12,RIGHT_ELBOW:14,RIGHT_WRIST:16,RIGHT_PINKY:18,RIGHT_INDEX:20,RIGHT_THUMB:22,RIGHT_HIP:24,RIGHT_KNEE:26,RIGHT_ANKLE:28,RIGHT_HEEL:30,RIGHT_FOOT_INDEX:32}),T("POSE_LANDMARKS_NEUTRAL",{NOSE:0}),T("matrixDataToMatrix",function(t){for(var e=t.getCols(),r=t.getRows(),n=t.getPackedDataList(),i=[],o=0;o<r;o++)i.push(Array(e));for(o=0;o<r;o++)for(var a=0;a<e;a++){var s=1===t.getLayout()?o*e+a:a*r+o;i[o][a]=n[s]}return i}),T("VERSION","0.5.1635989137")}).call(Pi);const Ci={};(function(){var t;function e(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var r="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,r){return t==Array.prototype||t==Object.prototype||(t[e]=r.value),t};var n=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var e=0;e<t.length;++e){var r=t[e];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);function i(t,e){if(e)t:{var i=n;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];if(!(a in i))break t;i=i[a]}(e=e(o=i[t=t[t.length-1]]))!=o&&null!=e&&r(i,t,{configurable:!0,writable:!0,value:e})}}function o(t){return(t={next:t})[Symbol.iterator]=function(){return this},t}function a(t){var r=typeof Symbol<"u"&&Symbol.iterator&&t[Symbol.iterator];return r?r.call(t):{next:e(t)}}function s(t){if(!(t instanceof Array)){t=a(t);for(var e,r=[];!(e=t.next()).done;)r.push(e.value);t=r}return t}i("Symbol",function(t){function e(t,e){this.g=t,r(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;e.prototype.toString=function(){return this.g};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",i=0;return function t(r){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(n+(r||"")+"_"+i++,r)}}),i("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var i="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),a=0;a<i.length;a++){var s=n[i[a]];"function"==typeof s&&"function"!=typeof s.prototype[t]&&r(s.prototype,t,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return t});var u,c="function"==typeof Object.create?Object.create:function(t){function e(){}return e.prototype=t,new e};if("function"==typeof Object.setPrototypeOf)u=Object.setPrototypeOf;else{var l;t:{var f={};try{f.__proto__={a:!0},l=f.a;break t}catch{}l=!1}u=l?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var h=u;function d(t,e){if(t.prototype=c(e.prototype),t.prototype.constructor=t,h)h(t,e);else for(var r in e)if("prototype"!=r)if(Object.defineProperties){var n=Object.getOwnPropertyDescriptor(e,r);n&&Object.defineProperty(t,r,n)}else t[r]=e[r];t.na=e.prototype}function g(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.u=this.o=0,this.j=null}function p(t){if(t.l)throw new TypeError("Generator is already running");t.l=!0}function m(t,e){t.j={da:e,ea:!0},t.g=t.o||t.u}function y(t,e,r){return t.g=r,{value:e}}function v(t){this.g=new g,this.h=t}function b(t,e,r,n){try{var i=e.call(t.g.i,r);if(!(i instanceof Object))throw new TypeError("Iterator result "+i+" is not an object");if(!i.done)return t.g.l=!1,i;var o=i.value}catch(e){return t.g.i=null,m(t.g,e),w(t)}return t.g.i=null,n.call(t.g,o),w(t)}function w(t){for(;t.g.g;)try{var e=t.h(t.g);if(e)return t.g.l=!1,{value:e.value,done:!1}}catch(e){t.g.h=void 0,m(t.g,e)}if(t.g.l=!1,t.g.j){if(e=t.g.j,t.g.j=null,e.ea)throw e.da;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function x(t){this.next=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.next,e,t.g.s):(t.g.s(e),e=w(t)),e},this.throw=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.throw,e,t.g.s):(m(t.g,e),e=w(t)),e},this.return=function(e){return function(t,e){p(t.g);var r=t.g.i;return r?b(t,"return"in r?r.return:function(t){return{value:t,done:!0}},e,t.g.return):(t.g.return(e),w(t))}(t,e)},this[Symbol.iterator]=function(){return this}}function A(t){return function(t){function e(e){return t.next(e)}function r(e){return t.throw(e)}return new Promise(function(n,i){!function t(o){o.done?n(o.value):Promise.resolve(o.value).then(e,r).then(t,i)}(t.next())})}(new x(new v(t)))}g.prototype.s=function(t){this.h=t},g.prototype.return=function(t){this.j={return:t},this.g=this.u},i("Promise",function(t){function e(t){this.h=0,this.i=void 0,this.g=[],this.s=!1;var e=this.j();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function r(){this.g=null}function i(t){return t instanceof e?t:new e(function(e){e(t)})}if(t)return t;r.prototype.h=function(t){if(null==this.g){this.g=[];var e=this;this.i(function(){e.l()})}this.g.push(t)};var o=n.setTimeout;r.prototype.i=function(t){o(t,0)},r.prototype.l=function(){for(;this.g&&this.g.length;){var t=this.g;this.g=[];for(var e=0;e<t.length;++e){var r=t[e];t[e]=null;try{r()}catch(t){this.j(t)}}}this.g=null},r.prototype.j=function(t){this.i(function(){throw t})},e.prototype.j=function(){function t(t){return function(n){r||(r=!0,t.call(e,n))}}var e=this,r=!1;return{resolve:t(this.D),reject:t(this.l)}},e.prototype.D=function(t){if(t===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.H(t);else{t:switch(typeof t){case"object":var r=null!=t;break t;case"function":r=!0;break t;default:r=!1}r?this.A(t):this.o(t)}},e.prototype.A=function(t){var e=void 0;try{e=t.then}catch(t){return void this.l(t)}"function"==typeof e?this.I(e,t):this.o(t)},e.prototype.l=function(t){this.u(2,t)},e.prototype.o=function(t){this.u(1,t)},e.prototype.u=function(t,e){if(0!=this.h)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.h);this.h=t,this.i=e,2===this.h&&this.G(),this.B()},e.prototype.G=function(){var t=this;o(function(){if(t.C()){var e=n.console;typeof e<"u"&&e.error(t.i)}},1)},e.prototype.C=function(){if(this.s)return!1;var t=n.CustomEvent,e=n.Event,r=n.dispatchEvent;return typeof r>"u"||("function"==typeof t?t=new t("unhandledrejection",{cancelable:!0}):"function"==typeof e?t=new e("unhandledrejection",{cancelable:!0}):(t=n.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,t),t.promise=this,t.reason=this.i,r(t))},e.prototype.B=function(){if(null!=this.g){for(var t=0;t<this.g.length;++t)s.h(this.g[t]);this.g=null}};var s=new r;return e.prototype.H=function(t){var e=this.j();t.M(e.resolve,e.reject)},e.prototype.I=function(t,e){var r=this.j();try{t.call(e,r.resolve,r.reject)}catch(t){r.reject(t)}},e.prototype.then=function(t,r){function n(t,e){return"function"==typeof t?function(e){try{i(t(e))}catch(t){o(t)}}:e}var i,o,a=new e(function(t,e){i=t,o=e});return this.M(n(t,i),n(r,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.M=function(t,e){function r(){switch(n.h){case 1:t(n.i);break;case 2:e(n.i);break;default:throw Error("Unexpected state: "+n.h)}}var n=this;null==this.g?s.h(r):this.g.push(r),this.s=!0},e.resolve=i,e.reject=function(t){return new e(function(e,r){r(t)})},e.race=function(t){return new e(function(e,r){for(var n=a(t),o=n.next();!o.done;o=n.next())i(o.value).M(e,r)})},e.all=function(t){var r=a(t),n=r.next();return n.done?i([]):new e(function(t,e){function o(e){return function(r){a[e]=r,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,i(n.value).M(o(a.length-1),e),n=r.next()}while(!n.done)})},e});var _="function"==typeof Object.assign?Object.assign:function(t,e){for(var r=1;r<arguments.length;r++){var n=arguments[r];if(n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};i("Object.assign",function(t){return t||_}),i("Object.is",function(t){return t||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}}),i("Array.prototype.includes",function(t){return t||function(t,e){var r=this;r instanceof String&&(r=String(r));var n=r.length;for(0>(e=e||0)&&(e=Math.max(e+n,0));e<n;e++){var i=r[e];if(i===t||Object.is(i,t))return!0}return!1}}),i("String.prototype.includes",function(t){return t||function(t,e){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(t,e||0)}}),i("Array.prototype.keys",function(t){return t||function(){return function(t,e){t instanceof String&&(t+="");var r=0,n=!1,i={next:function(){if(!n&&r<t.length){var i=r++;return{value:e(i,t[i]),done:!1}}return n=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,function(t){return t})}});var E=this||self;function T(t,e){t=t.split(".");var r,n=E;t[0]in n||typeof n.execScript>"u"||n.execScript("var "+t[0]);for(;t.length&&(r=t.shift());)t.length||void 0===e?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=e}function k(){throw Error("Invalid UTF8")}function S(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}var F,O,R=typeof TextDecoder<"u",I=typeof TextEncoder<"u",P={},j=null;function C(t){var e;void 0===e&&(e=0),L(),e=P[e];for(var r=Array(Math.floor(t.length/3)),n=e[64]||"",i=0,o=0;i<t.length-2;i+=3){var a=t[i],s=t[i+1],u=t[i+2],c=e[a>>2];a=e[(3&a)<<4|s>>4],s=e[(15&s)<<2|u>>6],u=e[63&u],r[o++]=c+a+s+u}switch(c=0,u=n,t.length-i){case 2:u=e[(15&(c=t[i+1]))<<2]||n;case 1:t=t[i],r[o]=e[t>>2]+e[(3&t)<<4|c>>4]+u+n}return r.join("")}function M(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){var r=t.charAt(n++),i=j[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}L();for(var n=0;;){var i=r(-1),o=r(0),a=r(64),s=r(64);if(64===s&&-1===i)break;e(i<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function L(){if(!j){j={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));P[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===j[o]&&(j[o]=i)}}}}var B,U="function"==typeof Uint8Array;function N(t){return U&&null!=t&&t instanceof Uint8Array}function D(t){if(this.L=t,null!==t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}var z="function"==typeof Uint8Array.prototype.slice,G=0;function W(t,e){return Error("Invalid wire type: "+t+" (at position "+e+")")}function H(){return Error("Failed to read varint, encoding is invalid.")}function V(t,e){e=void 0!==(e=void 0===e?{}:e).v&&e.v,this.h=null,this.g=this.i=this.j=0,this.v=e,t&&$(this,t)}function $(t,e){t.h=function(t,e){if(t.constructor===Uint8Array)return t;if(t.constructor===ArrayBuffer)return new Uint8Array(t);if(t.constructor===Array)return new Uint8Array(t);if(t.constructor===String)return M(t);if(t.constructor===D)return!e&&(e=t.L)&&e.constructor===Uint8Array?e:(e=null==(e=t.L)||N(e)?e:"string"==typeof e?M(e):null,(t=t.L=e)?new Uint8Array(t):B||(B=new Uint8Array(0)));if(t instanceof Uint8Array)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}(e,t.v),t.j=0,t.i=t.h.length,t.g=t.j}function Y(t){if(t.g>t.i)throw Error("Tried to read past the end of the data "+t.g+" > "+t.i)}function X(t){var e=t.h,r=e[t.g],n=127&r;if(128>r)return t.g+=1,Y(t),n;if(n|=(127&(r=e[t.g+1]))<<7,128>r)return t.g+=2,Y(t),n;if(n|=(127&(r=e[t.g+2]))<<14,128>r)return t.g+=3,Y(t),n;if(n|=(127&(r=e[t.g+3]))<<21,128>r)return t.g+=4,Y(t),n;if(r=e[t.g+4],t.g+=5,n|=(15&r)<<28,128>r)return Y(t),n;if(128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++])throw H();return Y(t),n}V.prototype.reset=function(){this.g=this.j};var q=[];function K(){this.g=[]}function Q(t,e){for(;127<e;)t.g.push(127&e|128),e>>>=7;t.g.push(e)}function J(t){var e={},r=void 0!==e.W&&e.W;this.l={v:void 0!==e.v&&e.v},this.W=r,e=this.l,q.length?(r=q.pop(),e&&(r.v=e.v),t&&$(r,t),t=r):t=new V(t,e),this.g=t,this.j=this.g.g,this.h=this.i=-1}function Z(t){var e=t.g;if(e.g==e.i)return!1;t.j=t.g.g;var r=X(t.g)>>>0;if(e=r>>>3,!(0<=(r&=7)&&5>=r))throw W(r,t.j);if(1>e)throw Error("Invalid field number: "+e+" (at position "+t.j+")");return t.i=e,t.h=r,!0}function tt(t){switch(t.h){case 0:if(0!=t.h)tt(t);else t:{for(var e=(t=t.g).g,r=e+10;e<r;)if(!(128&t.h[e++])){t.g=e,Y(t);break t}throw H()}break;case 1:(t=t.g).g+=8,Y(t);break;case 2:2!=t.h?tt(t):(e=X(t.g)>>>0,(t=t.g).g+=e,Y(t));break;case 5:(t=t.g).g+=4,Y(t);break;case 3:for(e=t.i;;){if(!Z(t))throw Error("Unmatched start-group tag: stream EOF");if(4==t.h){if(t.i!=e)throw Error("Unmatched end-group tag");break}tt(t)}break;default:throw W(t.h,t.j)}}K.prototype.length=function(){return this.g.length},K.prototype.end=function(){var t=this.g;return this.g=[],t},J.prototype.reset=function(){this.g.reset(),this.j=this.g.g,this.h=this.i=-1};var et=[];function rt(){this.i=[],this.h=0,this.g=new K}function nt(t,e){0!==e.length&&(t.i.push(e),t.h+=e.length)}var it="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol(void 0):void 0;function ot(t,e){Object.isFrozen(t)||(it?t[it]|=e:void 0!==t.N?t.N|=e:Object.defineProperties(t,{N:{value:e,configurable:!0,writable:!0,enumerable:!1}}))}function at(t){return(it?t[it]:t.N)??0}function st(t){return ot(t,1),t}function ut(t){return!!Array.isArray(t)&&!!(2&at(t))}function ct(t){if(!Array.isArray(t))throw Error("cannot mark non-array as immutable");ot(t,2)}function lt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}var ft=Object.freeze(st([]));function ht(t){if(ut(t.m))throw Error("Cannot mutate an immutable Message")}var dt,gt=typeof Symbol<"u"&&typeof Symbol.hasInstance<"u";function pt(t){return{value:t,configurable:!1,writable:!1,enumerable:!1}}function mt(t,e,r){return-1===e?null:e>=t.i?t.g?t.g[e]:void 0:void 0!==r&&r&&t.g&&null!=(r=t.g[e])?r:t.m[e+t.h]}function yt(t,e,r,n){n=void 0!==n&&n,ht(t),e<t.i&&!n?t.m[e+t.h]=r:(t.g||(t.g=t.m[t.i+t.h]={}))[e]=r}function vt(t,e,r,n){r=void 0===r||r;var i=mt(t,e,n=void 0!==n&&n);return null==i&&(i=ft),ut(t.m)?r&&(ct(i),Object.freeze(i)):(i===ft||ut(i))&&yt(t,e,i=st(i.slice()),n),i}function bt(t,e,r){return(t=null==(t=mt(t,e))?t:+t)??(void 0===r?0:r)}function wt(t,e,r,n){t.j||(t.j={});var i=ut(t.m),o=t.j[r];if(!o){n=vt(t,r,!0,void 0!==n&&n),o=[],i=i||ut(n);for(var a=0;a<n.length;a++)o[a]=new e(n[a]),i&&ct(o[a].m);i&&(ct(o),Object.freeze(o)),t.j[r]=o}return o}function xt(t,e,r,n,i){var o=void 0!==o&&o;return ht(t),o=wt(t,r,e,o),r=n||new r,t=vt(t,e),null!=i?(o.splice(i,0,r),t.splice(i,0,r.m)):(o.push(r),t.push(r.m)),r}function At(t,e){return(t=mt(t,e))??0}function _t(t,e){return(t=mt(t,e))??""}function Et(t){var e=St;return kt(t,e=void 0===e?Ft:e)}function Tt(t,e){if(null!=t){if(Array.isArray(t))t=kt(t,e);else if(lt(t)){var r,n={};for(r in t)n[r]=Tt(t[r],e);t=n}else t=e(t);return t}}function kt(t,e){for(var r=t.slice(),n=0;n<r.length;n++)r[n]=Tt(r[n],e);return Array.isArray(t)&&1&at(t)&&st(r),r}function St(t){return t&&"object"==typeof t&&t.toJSON?t.toJSON():(t=function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"object":if(t&&!Array.isArray(t)){if(N(t))return C(t);if(t instanceof D){var e=t.L;return e=null==e||"string"==typeof e?e:U&&e instanceof Uint8Array?C(e):null,(t.L=e)||""}}}return t}(t),Array.isArray(t)?Et(t):t)}function Ft(t){return N(t)?new Uint8Array(t):t}function Ot(t,e,r){t||(t=dt),dt=null;var n=this.constructor.h;if(t||(t=n?[n]:[]),this.h=(n?0:-1)-(this.constructor.g||0),this.j=void 0,this.m=t,t=(n=this.m.length)-1,n&&lt(n=this.m[t])?(this.i=t-this.h,this.g=n):void 0!==e&&-1<e?(this.i=Math.max(e,t+1-this.h),this.g=void 0):this.i=Number.MAX_VALUE,r)for(e=0;e<r.length;e++)if((t=r[e])<this.i)t+=this.h,(n=this.m[t])?Array.isArray(n)&&st(n):this.m[t]=ft;else{var i=(n=this.g||(this.g=this.m[this.i+this.h]={}))[t];i?Array.isArray(i)&&st(i):n[t]=ft}}function Rt(){Ot.apply(this,arguments)}if(Ot.prototype.toJSON=function(){return Et(this.m)},Ot.prototype.toString=function(){return this.m.toString()},d(Rt,Ot),gt){var It={};Object.defineProperties(Rt,(It[Symbol.hasInstance]=pt(function(){throw Error("Cannot perform instanceof checks for MutableMessage")}),It))}function Pt(t,e,r){if(r){var n,i={};for(n in r){var o=r[n],a=o.ha;a||(i.F=o.la||o.fa.P,o.aa?(i.U=Nt(o.aa),a=function(t){return function(e,r,n){return t.F(e,r,n,t.U)}}(i)):o.ca?(i.T=Dt(o.X.g,o.ca),a=function(t){return function(e,r,n){return t.F(e,r,n,t.T)}}(i)):a=i.F,o.ha=a),a(e,t,o.X),i={F:i.F,U:i.U,T:i.T}}}!function(t,e){if(e=e.ba){nt(t,t.g.end());for(var r=0;r<e.length;r++)nt(t,e[r])}}(e,t)}var jt=Symbol();function Ct(t,e,r){return t[jt]||(t[jt]=function(t,n){return e(t,n,r)})}function Mt(t){var e=t[jt];if(!e){var r=Jt(t);e=function(t,e){return Zt(t,e,r)},t[jt]=e}return e}function Lt(t){var e=function(t){var e=t.aa;return e?Mt(e):(e=t.ka)?Ct(t.X.g,e,t.ca):void 0}(t),r=t.X,n=t.fa.O;return e?function(t,i){return n(t,i,r,e)}:function(t,e){return n(t,e,r)}}function Bt(t,e,r,n,i,o){var a=0;for((t=t()).length&&"number"!=typeof t[0]&&(r(e,t[0]),a++);a<t.length;){r=t[a++];for(var s=a+1;s<t.length&&"number"!=typeof t[s];)s++;var u=t[a++];switch(s-=a){case 0:n(e,r,u);break;case 1:n(e,r,u,t[a++]);break;case 2:i(e,r,u,t[a++],t[a++]);break;case 3:s=t[a++];var c=t[a++],l=t[a++];Array.isArray(l)?i(e,r,u,s,c,l):o(e,r,u,s,c,l);break;case 4:o(e,r,u,t[a++],t[a++],t[a++],t[a++]);break;default:throw Error("unexpected number of binary field arguments: "+s)}}return e}var Ut=Symbol();function Nt(t){var e=t[Ut];if(!e){var r=$t(t);e=function(t,e){return ee(t,e,r)},t[Ut]=e}return e}function Dt(t,e){var r=t[Ut];return r||(r=function(t,r){return Pt(t,r,e)},t[Ut]=r),r}var zt=Symbol();function Gt(t,e){t.push(e)}function Wt(t,e,r){t.push(e,r.P)}function Ht(t,e,r,n,i){var o=Nt(i),a=r.P;t.push(e,function(t,e,r){return a(t,e,r,n,o)})}function Vt(t,e,r,n,i,o){var a=Dt(n,o),s=r.P;t.push(e,function(t,e,r){return s(t,e,r,n,a)})}function $t(t){return t[zt]||Bt(t,t[zt]=[],Gt,Wt,Ht,Vt)}var Yt=Symbol();function Xt(t,e){t[0]=e}function qt(t,e,r,n){var i=r.O;t[e]=n?function(t,e,r){return i(t,e,r,n)}:i}function Kt(t,e,r,n,i,o){var a=r.O,s=Mt(i);t[e]=function(t,e,r){return a(t,e,r,n,s,o)}}function Qt(t,e,r,n,i,o,a){var s=r.O,u=Ct(n,i,o);t[e]=function(t,e,r){return s(t,e,r,n,u,a)}}function Jt(t){return t[Yt]||Bt(t,t[Yt]={},Xt,qt,Kt,Qt)}function Zt(t,e,r){for(;Z(e)&&4!=e.h;){var n=e.i,i=r[n];if(!i){var o=r[0];o&&(o=o[n])&&(i=r[n]=Lt(o))}if(!(i&&i(e,t,n)||(i=e,n=t,o=i.j,tt(i),i.W))){var a=i.g.h;i=o===(i=i.g.g)?B||(B=new Uint8Array(0)):z?a.slice(o,i):new Uint8Array(a.subarray(o,i)),(o=n.ba)?o.push(i):n.ba=[i]}}return t}function te(t,e,r){if(et.length){var n=et.pop();t&&($(n.g,t),n.i=-1,n.h=-1),t=n}else t=new J(t);try{return Zt(new e,t,Jt(r))}finally{(e=t.g).h=null,e.j=0,e.i=0,e.g=0,e.v=!1,t.i=-1,t.h=-1,100>et.length&&et.push(t)}}function ee(t,e,r){for(var n=r.length,i=n%2==1,o=i?1:0;o<n;o+=2)(0,r[o+1])(e,t,r[o]);Pt(t,e,i?r[0]:void 0)}function re(t,e){var r=new rt;ee(t,r,$t(e)),nt(r,r.g.end()),t=new Uint8Array(r.h);for(var n=(e=r.i).length,i=0,o=0;o<n;o++){var a=e[o];t.set(a,i),i+=a.length}return r.i=[t],t}function ne(t,e){return{O:t,P:e}}var ie=ne(function(t,e,r){if(5!==t.h)return!1;var n=(t=t.g).h[t.g],i=t.h[t.g+1],o=t.h[t.g+2],a=t.h[t.g+3];return t.g+=4,Y(t),t=2*((i=(n|i<<8|o<<16|a<<24)>>>0)>>31)+1,n=i>>>23&255,i&=8388607,yt(e,r,255==n?i?NaN:1/0*t:0==n?t*Math.pow(2,-149)*i:t*Math.pow(2,n-150)*(i+Math.pow(2,23))),!0},function(t,e,r){if(null!=(e=mt(e,r))){Q(t.g,8*r+5),t=t.g;var n=e;0===(n=(r=0>n?1:0)?-n:n)?0<1/n?G=0:G=2147483648:isNaN(n)?G=2147483647:34028234663852886e22<n?G=(r<<31|2139095040)>>>0:11754943508222875e-54>n?(n=Math.round(n/Math.pow(2,-149)),G=(r<<31|n)>>>0):(e=Math.floor(Math.log(n)/Math.LN2),n*=Math.pow(2,-e),16777216<=(n=Math.round(8388608*n))&&++e,G=(r<<31|e+127<<23|8388607&n)>>>0),r=G,t.g.push(r>>>0&255),t.g.push(r>>>8&255),t.g.push(r>>>16&255),t.g.push(r>>>24&255)}}),oe=ne(function(t,e,r){if(0!==t.h)return!1;for(var n=t.g,i=128,o=0,a=t=0;4>a&&128<=i;a++)i=n.h[n.g++],Y(n),o|=(127&i)<<7*a;if(128<=i&&(i=n.h[n.g++],Y(n),o|=(127&i)<<28,t|=(127&i)>>4),128<=i)for(a=0;5>a&&128<=i;a++)i=n.h[n.g++],Y(n),t|=(127&i)<<7*a+3;if(!(128>i))throw H();return n=o>>>0,(t=2147483648&(i=t>>>0))&&(i=~i>>>0,0==(n=1+~n>>>0)&&(i=i+1>>>0)),n=4294967296*i+(n>>>0),yt(e,r,t?-n:n),!0},function(t,e,r){if(null!=(e=mt(e,r))&&null!=e){Q(t.g,8*r),t=t.g;var n=e;for(r=0>n,e=(n=Math.abs(n))>>>0,n=Math.floor((n-e)/4294967296),n>>>=0,r&&(n=~n>>>0,4294967295<(e=(~e>>>0)+1)&&(e=0,4294967295<++n&&(n=0))),r=G=e,e=n;0<e||127<r;)t.g.push(127&r|128),r=(r>>>7|e<<25)>>>0,e>>>=7;t.g.push(r)}}),ae=ne(function(t,e,r){return 0===t.h&&(yt(e,r,X(t.g)),!0)},function(t,e,r){if(null!=(e=mt(e,r))&&null!=e)if(Q(t.g,8*r),t=t.g,0<=(r=e))Q(t,r);else{for(e=0;9>e;e++)t.g.push(127&r|128),r>>=7;t.g.push(1)}}),se=ne(function(t,e,r){if(2!==t.h)return!1;var n,i=X(t.g)>>>0,o=(t=t.g).g;if(t.g+=i,Y(t),t=t.h,R)(n=F)||(n=F=new TextDecoder("utf-8",{fatal:!0})),n=n.decode(t.subarray(o,o+i));else{i=o+i;for(var a,s,u,c=[],l=null;o<i;)128>(a=t[o++])?c.push(a):224>a?o>=i?k():(s=t[o++],194>a||128!=(192&s)?(o--,k()):c.push((31&a)<<6|63&s)):240>a?o>=i-1?k():128!=(192&(s=t[o++]))||224===a&&160>s||237===a&&160<=s||128!=(192&(n=t[o++]))?(o--,k()):c.push((15&a)<<12|(63&s)<<6|63&n):244>=a?o>=i-2?k():128!=(192&(s=t[o++]))||s-144+(a<<28)>>30||128!=(192&(n=t[o++]))||128!=(192&(u=t[o++]))?(o--,k()):(a=(7&a)<<18|(63&s)<<12|(63&n)<<6|63&u,a-=65536,c.push(55296+(a>>10&1023),56320+(1023&a))):k(),8192<=c.length&&(l=S(l,c),c.length=0);n=S(l,c)}return yt(e,r,n),!0},function(t,e,r){if(null!=(e=mt(e,r))){var n=!1;if(n=void 0!==n&&n,I){if(n&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(e))throw Error("Found an unpaired surrogate");e=(O||(O=new TextEncoder)).encode(e)}else{for(var i=0,o=new Uint8Array(3*e.length),a=0;a<e.length;a++){var s=e.charCodeAt(a);if(128>s)o[i++]=s;else{if(2048>s)o[i++]=s>>6|192;else{if(55296<=s&&57343>=s){if(56319>=s&&a<e.length){var u=e.charCodeAt(++a);if(56320<=u&&57343>=u){s=1024*(s-55296)+u-56320+65536,o[i++]=s>>18|240,o[i++]=s>>12&63|128,o[i++]=s>>6&63|128,o[i++]=63&s|128;continue}a--}if(n)throw Error("Found an unpaired surrogate");s=65533}o[i++]=s>>12|224,o[i++]=s>>6&63|128}o[i++]=63&s|128}}e=o.subarray(0,i)}Q(t.g,8*r+2),Q(t.g,e.length),nt(t,t.g.end()),nt(t,e)}}),ue=ne(function(t,e,r,n,i){if(2!==t.h)return!1;e=xt(e,r,n),r=t.g.i,n=X(t.g)>>>0;var o=t.g.g+n,a=o-r;if(0>=a&&(t.g.i=o,i(e,t),a=o-t.g.g),a)throw Error("Message parsing ended unexpectedly. Expected to read "+n+" bytes, instead read "+(n-a)+" bytes, either the data ended unexpectedly or the message misreported its own length");return t.g.g=o,t.g.i=r,!0},function(t,e,r,n,i){if(null!=(e=wt(e,n,r)))for(n=0;n<e.length;n++){var o=t;Q(o.g,8*r+2);var a=o.g.end();nt(o,a),a.push(o.h),o=a,i(e[n],t),a=t;var s=o.pop();for(s=a.h+a.g.length()-s;127<s;)o.push(127&s|128),s>>>=7,a.h++;o.push(s),a.h++}});function ce(){Rt.apply(this,arguments)}if(d(ce,Rt),gt){var le={};Object.defineProperties(ce,(le[Symbol.hasInstance]=pt(Object[Symbol.hasInstance]),le))}function fe(t){ce.call(this,t)}function he(){return[1,ae,2,ie,3,se,4,se]}function de(t){ce.call(this,t,-1,pe)}function ge(){return[1,ue,fe,he]}d(fe,ce),d(de,ce),de.prototype.addClassification=function(t,e){return xt(this,1,fe,t,e),this};var pe=[1];function me(t){ce.call(this,t)}function ye(){return[1,ie,2,ie,3,ie,4,ie,5,ie]}function ve(t){ce.call(this,t,-1,we)}function be(){return[1,ue,me,ye]}d(me,ce),d(ve,ce);var we=[1];function xe(t){ce.call(this,t)}function Ae(){return[1,ie,2,ie,3,ie,4,ie,5,ie,6,oe]}d(xe,ce);var _e=[[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]],Ee=[[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]],Te=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],ke=[[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]],Se=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],Fe=[[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]],Oe=[].concat(s(_e),s(Ee),s(Te),s(ke),s(Se),s(Fe));function Re(t,e,r){if(r=t.createShader(0===r?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+t.getShaderInfoLog(r));return r}function Ie(t){return wt(t,fe,1).map(function(t){return{index:At(t,1),ga:bt(t,2),label:null!=mt(t,3)?_t(t,3):void 0,displayName:null!=mt(t,4)?_t(t,4):void 0}})}function Pe(t){return{x:bt(t,1),y:bt(t,2),z:bt(t,3),visibility:null!=mt(t,4)?bt(t,4):void 0}}function je(t,e){this.h=t,this.g=e,this.l=0}function Ce(t,e,r){return function(t,e){var r=t.g;if(void 0===t.o){var n=Re(r,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",0),i=Re(r,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=r.createProgram();if(r.attachShader(o,n),r.attachShader(o,i),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+r.getProgramInfoLog(o));n=t.o=o,r.useProgram(n),i=r.getUniformLocation(n,"sampler0"),t.j={K:r.getAttribLocation(n,"aVertex"),J:r.getAttribLocation(n,"aTex"),ma:i},t.u=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.u),r.enableVertexAttribArray(t.j.K),r.vertexAttribPointer(t.j.K,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),t.s=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.enableVertexAttribArray(t.j.J),r.vertexAttribPointer(t.j.J,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.uniform1i(i,0)}n=t.j,r.useProgram(t.o),r.canvas.width=e.width,r.canvas.height=e.height,r.viewport(0,0,e.width,e.height),r.activeTexture(r.TEXTURE0),t.h.bindTexture2d(e.glName),r.enableVertexAttribArray(n.K),r.bindBuffer(r.ARRAY_BUFFER,t.u),r.vertexAttribPointer(n.K,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(n.J),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.vertexAttribPointer(n.J,2,r.FLOAT,!1,0,0),r.bindFramebuffer(r.DRAW_FRAMEBUFFER?r.DRAW_FRAMEBUFFER:r.FRAMEBUFFER,null),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.colorMask(!0,!0,!0,!0),r.drawArrays(r.TRIANGLE_FAN,0,4),r.disableVertexAttribArray(n.K),r.disableVertexAttribArray(n.J),r.bindBuffer(r.ARRAY_BUFFER,null),t.h.bindTexture2d(0)}(t,e),"function"==typeof t.g.canvas.transferToImageBitmap?Promise.resolve(t.g.canvas.transferToImageBitmap()):r?Promise.resolve(t.g.canvas):"function"==typeof createImageBitmap?createImageBitmap(t.g.canvas):(void 0===t.i&&(t.i=document.createElement("canvas")),new Promise(function(e){t.i.height=t.g.canvas.height,t.i.width=t.g.canvas.width,t.i.getContext("2d",{}).drawImage(t.g.canvas,0,0,t.g.canvas.width,t.g.canvas.height),e(t.i)}))}function Me(t){this.g=t}var Le=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Be(t,e){return e+t}function Ue(t,e){window[t]=e}function Ne(t){if(this.g=t,this.listeners={},this.j={},this.H={},this.o={},this.u={},this.I=this.s=this.Z=!0,this.D=Promise.resolve(),this.Y="",this.C={},this.locateFile=t&&t.locateFile||Be,"object"==typeof window)var e=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(!(typeof location<"u"))throw Error("solutions can only be loaded on a web page or in a web worker");e=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.$=e,t.options)for(var r=(e=a(Object.keys(t.options))).next();!r.done;r=e.next()){r=r.value;var n=t.options[r].default;void 0!==n&&(this.j[r]="function"==typeof n?n():n)}}function De(t){var e,r,n,i,o,a,u,c,l,f,h;return A(function(d){switch(d.g){case 1:return t.Z?(e=void 0===t.g.files?[]:"function"==typeof t.g.files?t.g.files(t.j):t.g.files,y(d,A(function(t){switch(t.g){case 1:return t.o=2,y(t,WebAssembly.instantiate(Le),4);case 4:t.g=3,t.o=0;break;case 2:return t.o=0,t.j=null,t.return(!1);case 3:return t.return(!0)}}),2)):d.return();case 2:if(r=d.h,"object"==typeof window)return Ue("createMediapipeSolutionsWasm",{locateFile:t.locateFile}),Ue("createMediapipeSolutionsPackedAssets",{locateFile:t.locateFile}),a=e.filter(function(t){return void 0!==t.data}),u=e.filter(function(t){return void 0===t.data}),c=Promise.all(a.map(function(e){var r=ze(t,e.url);if(void 0!==e.path){var n=e.path;r=r.then(function(e){return t.overrideFile(n,e),Promise.resolve(e)})}return r})),l=Promise.all(u.map(function(e){return void 0===e.simd||e.simd&&r||!e.simd&&!r?function(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(t){e.addEventListener("load",function(){t()},!1),e.addEventListener("error",function(){t()},!1),document.body.appendChild(e)})}(t.locateFile(e.url,t.$)):Promise.resolve()})).then(function(){var e,r,n;return A(function(i){if(1==i.g)return e=window.createMediapipeSolutionsWasm,r=window.createMediapipeSolutionsPackedAssets,n=t,y(i,e(r),2);n.h=i.h,i.g=0})}),f=A(function(e){return t.g.graph&&t.g.graph.url?e=y(e,ze(t,t.g.graph.url),0):(e.g=0,e=void 0),e}),y(d,Promise.all([l,c,f]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return n=e.filter(function(t){return void 0===t.simd||t.simd&&r||!t.simd&&!r}).map(function(e){return t.locateFile(e.url,t.$)}),importScripts.apply(null,s(n)),i=t,y(d,createMediapipeSolutionsWasm(Module),6);case 6:i.h=d.h,t.l=new OffscreenCanvas(1,1),t.h.canvas=t.l,o=t.h.GL.createContext(t.l,{antialias:!1,alpha:!1,ja:typeof WebGL2RenderingContext<"u"?2:1}),t.h.GL.makeContextCurrent(o),d.g=4;break;case 7:if(t.l=document.createElement("canvas"),!(h=t.l.getContext("webgl2",{}))&&!(h=t.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),d.return();t.G=h,t.h.canvas=t.l,t.h.createContext(t.l,!0,!0,{});case 4:t.i=new t.h.SolutionWasm,t.Z=!1,d.g=0}})}function ze(t,e){var r,n;return A(function(i){return e in t.H?i.return(t.H[e]):(r=t.locateFile(e,""),n=fetch(r).then(function(t){return t.arrayBuffer()}),t.H[e]=n,i.return(n))})}function Ge(t,e,r){var n,i,o,s,u,c,l,f,h,d,g,p,m,v;return A(function(b){switch(b.g){case 1:if(!r)return b.return(e);for(n={},i=0,o=a(Object.keys(r)),s=o.next();!s.done;s=o.next())u=s.value,"string"!=typeof(c=r[u])&&"texture"===c.type&&void 0!==e[c.stream]&&++i;1<i&&(t.I=!1),l=a(Object.keys(r)),s=l.next();case 2:if(s.done){b.g=4;break}if(f=s.value,"string"==typeof(h=r[f]))return m=n,v=f,y(b,function(t,e,r){var n;return A(function(i){return"number"==typeof r||r instanceof Uint8Array||r instanceof t.h.Uint8BlobList?i.return(r):r instanceof t.h.Texture2dDataOut?((n=t.u[e])||(n=new je(t.h,t.G),t.u[e]=n),i.return(Ce(n,r,t.I))):i.return(void 0)})}(t,f,e[h]),14);if(d=e[h.stream],"detection_list"===h.type){if(d){for(var w=d.getRectList(),x=d.getLandmarksList(),_=d.getClassificationsList(),E=[],T=0;T<w.size();++T){var k=te(w.get(T),xe,Ae);k={boundingBox:{xCenter:bt(k,1),yCenter:bt(k,2),height:bt(k,3),width:bt(k,4),rotation:bt(k,5,0),rectId:At(k,6)},landmarks:wt(te(x.get(T),ve,be),me,1).map(Pe),V:Ie(te(_.get(T),de,ge))},E.push(k)}w=E}else w=[];n[f]=w,b.g=7;break}if("proto_list"===h.type){if(d){for(w=Array(d.size()),x=0;x<d.size();x++)w[x]=d.get(x);d.delete()}else w=[];n[f]=w,b.g=7;break}if(void 0===d){b.g=3;break}if("float_list"===h.type){n[f]=d,b.g=7;break}if("proto"===h.type){n[f]=d,b.g=7;break}if("texture"!==h.type)throw Error("Unknown output config type: '"+h.type+"'");return(g=t.u[f])||(g=new je(t.h,t.G),t.u[f]=g),y(b,Ce(g,d,t.I),13);case 13:p=b.h,n[f]=p;case 7:h.transform&&n[f]&&(n[f]=h.transform(n[f])),b.g=3;break;case 14:m[v]=b.h;case 3:s=l.next(),b.g=2;break;case 4:return b.return(n)}})}function We(t,e){for(var r=e.name||"$",n=[].concat(s(e.wants)),i=new t.h.StringList,o=a(e.wants),u=o.next();!u.done;u=o.next())i.push_back(u.value);o=t.h.PacketListener.implement({onResults:function(i){for(var o={},a=0;a<e.wants.length;++a)o[n[a]]=i.get(a);var s=t.listeners[r];s&&(t.D=Ge(t,o,e.outs).then(function(r){r=s(r);for(var i=0;i<e.wants.length;++i){var a=o[n[i]];"object"==typeof a&&a.hasOwnProperty&&a.hasOwnProperty("delete")&&a.delete()}r&&(t.D=r)}))}}),t.i.attachMultiListener(i,o),i.delete()}function He(t){var e=this;t=t||{};var r={url:"face_detection_short.binarypb"},n={type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}};this.g=new Ne({locateFile:t.locateFile,files:[{data:!0,url:"face_detection_short.binarypb"},{data:!0,url:"face_detection_short_range.tflite"},{simd:!0,url:"face_detection_solution_simd_wasm_bin.js"},{simd:!1,url:"face_detection_solution_wasm_bin.js"}],graph:r,listeners:[{wants:["detections","image_transformed"],outs:{image:"image_transformed",detections:{type:"detection_list",stream:"detections"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"object"==typeof window&&void 0!==window.navigator&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},model:{type:0,onChange:function(t){var i,o,s,u,c;return A(function(l){switch(l.g){case 1:i=a("short"===t?["face_detection_short_range.tflite"]:["face_detection_full_range_sparse.tflite"]),o=i.next();case 2:if(o.done){l.g=4;break}return s=o.value,u="third_party/mediapipe/modules/face_detection/"+s,y(l,ze(e.g,s),5);case 5:c=l.h,e.g.overrideFile(u,c),o=i.next(),l.g=2;break;case 4:return r.url="short"===t?"face_detection_short.binarypb":"face_detection_full.binarypb",n.graphOptionXref.calculatorName="short"===t?"facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator":"facedetectionfullrangegpu__facedetectionfullrangecommon__TensorsToDetectionsCalculator",l.return(!0)}})}},minDetectionConfidence:n}})}(t=Ne.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},t.reset=function(){var t=this;return A(function(e){t.i&&(t.i.reset(),t.o={},t.u={}),e.g=0})},t.setOptions=function(t,e){var r=this;if(e=e||this.g.options){for(var n=[],i=[],o={},s=a(Object.keys(t)),u=s.next();!u.done;o={R:o.R,S:o.S},u=s.next()){var c=u.value;c in this.j&&this.j[c]===t[c]||(this.j[c]=t[c],void 0!==(u=e[c])&&(u.onChange&&(o.R=u.onChange,o.S=t[c],n.push(function(t){return function(){return A(function(e){if(1==e.g)return y(e,t.R(t.S),2);!0===e.h&&(r.s=!0),e.g=0})}}(o))),u.graphOptionXref&&(c={valueNumber:1===u.type?t[c]:0,valueBoolean:0===u.type&&t[c],valueString:2===u.type?t[c]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),c),i.push(u))))}(0!==n.length||0!==i.length)&&(this.s=!0,this.B=(void 0===this.B?[]:this.B).concat(i),this.A=(void 0===this.A?[]:this.A).concat(n))}},t.initialize=function(){var t=this;return A(function(e){return 1==e.g?y(e,De(t),2):3!=e.g?y(e,function(t){var e,r,n,i,o,s,u,c;return A(function(l){if(1==l.g)return t.g.graph&&t.g.graph.url&&t.Y===t.g.graph.url?l.return():(t.s=!0,t.g.graph&&t.g.graph.url?(t.Y=t.g.graph.url,y(l,ze(t,t.g.graph.url),3)):void(l.g=2));for(2!=l.g&&(e=l.h,t.i.loadGraph(e)),r=a(Object.keys(t.C)),n=r.next();!n.done;n=r.next())i=n.value,t.i.overrideFile(i,t.C[i]);if(t.C={},t.g.listeners)for(o=a(t.g.listeners),s=o.next();!s.done;s=o.next())u=s.value,We(t,u);c=t.j,t.j={},t.setOptions(c),l.g=0})}(t),3):y(e,function(t){var e,r,n,i,o,s;return A(function(u){switch(u.g){case 1:if(!t.s)return u.return();if(!t.A){u.g=2;break}e=a(t.A),r=e.next();case 3:if(r.done){u.g=5;break}return y(u,(0,r.value)(),4);case 4:r=e.next(),u.g=3;break;case 5:t.A=void 0;case 2:if(t.B){for(n=new t.h.GraphOptionChangeRequestList,i=a(t.B),o=i.next();!o.done;o=i.next())s=o.value,n.push_back(s);t.i.changeOptions(n),n.delete(),t.B=void 0}t.s=!1,u.g=0}})}(t),0)})},t.overrideFile=function(t,e){this.i?this.i.overrideFile(t,e):this.C[t]=e},t.clearOverriddenFiles=function(){this.C={},this.i&&this.i.clearOverriddenFiles()},t.send=function(t,e){var r,n,i,o,s,u,c,l,f,h=this;return A(function(d){switch(d.g){case 1:return h.g.inputs?(r=1e3*(e??performance.now()),y(d,h.D,2)):d.return();case 2:return y(d,h.initialize(),3);case 3:for(n=new h.h.PacketDataList,i=a(Object.keys(t)),o=i.next();!o.done;o=i.next())if(s=o.value,u=h.g.inputs[s]){t:{var g=t[s];switch(u.type){case"video":var p=h.o[u.stream];if(p||(p=new je(h.h,h.G),h.o[u.stream]=p),0===p.l&&(p.l=p.h.createTexture()),typeof HTMLVideoElement<"u"&&g instanceof HTMLVideoElement)var m=g.videoWidth,v=g.videoHeight;else typeof HTMLImageElement<"u"&&g instanceof HTMLImageElement?(m=g.naturalWidth,v=g.naturalHeight):(m=g.width,v=g.height);v={glName:p.l,width:m,height:v},(m=p.g).canvas.width=v.width,m.canvas.height=v.height,m.activeTexture(m.TEXTURE0),p.h.bindTexture2d(p.l),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,g),p.h.bindTexture2d(0),p=v;break t;case"detections":for((p=h.o[u.stream])||(p=new Me(h.h),h.o[u.stream]=p),p.data||(p.data=new p.g.DetectionListData),p.data.reset(g.length),v=0;v<g.length;++v){m=g[v];var b=p.data,w=b.setBoundingBox,x=v,A=m.boundingBox,_=new xe;if(yt(_,1,A.xCenter),yt(_,2,A.yCenter),yt(_,3,A.height),yt(_,4,A.width),yt(_,5,A.rotation),yt(_,6,A.rectId),A=re(_,Ae),w.call(b,x,A),m.landmarks)for(b=0;b<m.landmarks.length;++b){var E=!!(_=m.landmarks[b]).visibility;x=(w=p.data).addNormalizedLandmark,A=v,_=Object.assign(Object.assign({},_),{visibility:E?_.visibility:0}),yt(E=new me,1,_.x),yt(E,2,_.y),yt(E,3,_.z),_.visibility&&yt(E,4,_.visibility),_=re(E,ye),x.call(w,A,_)}if(m.V)for(b=0;b<m.V.length;++b)x=(w=p.data).addClassification,A=v,_=m.V[b],yt(E=new fe,2,_.ga),_.index&&yt(E,1,_.index),_.label&&yt(E,3,_.label),_.displayName&&yt(E,4,_.displayName),_=re(E,he),x.call(w,A,_)}p=p.data;break t;default:p={}}}switch(c=p,l=u.stream,u.type){case"video":n.pushTexture2d(Object.assign(Object.assign({},c),{stream:l,timestamp:r}));break;case"detections":(f=c).stream=l,f.timestamp=r,n.pushDetectionList(f);break;default:throw Error("Unknown input config type: '"+u.type+"'")}}return h.i.send(n),y(d,h.D,4);case 4:n.delete(),d.g=0}})},t.onResults=function(t,e){this.listeners[e||"$"]=t},T("Solution",Ne),T("OptionType",{BOOL:0,NUMBER:1,ia:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(t=He.prototype).close=function(){return this.g.close(),Promise.resolve()},t.onResults=function(t){this.g.onResults(t)},t.initialize=function(){var t=this;return A(function(e){return y(e,t.g.initialize(),0)})},t.reset=function(){this.g.reset()},t.send=function(t){var e=this;return A(function(r){return y(r,e.g.send(t),0)})},t.setOptions=function(t){this.g.setOptions(t)},T("FaceDetection",He),T("FACEDETECTION_LIPS",_e),T("FACEDETECTION_LEFT_EYE",Ee),T("FACEDETECTION_LEFT_EYEBROW",Te),T("FACEDETECTION_RIGHT_EYE",ke),T("FACEDETECTION_RIGHT_EYEBROW",Se),T("FACEDETECTION_FACE_OVAL",Fe),T("FACEDETECTION_CONTOURS",Oe),T("FACEDETECTION_TESSELATION",[[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]]),T("VERSION","0.4.1646425229")}).call(Ci);const Mi={};(function(){var t;function e(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var r="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,r){return t==Array.prototype||t==Object.prototype||(t[e]=r.value),t};var n=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var e=0;e<t.length;++e){var r=t[e];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);function i(t,e){if(e)t:{var i=n;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];if(!(a in i))break t;i=i[a]}(e=e(o=i[t=t[t.length-1]]))!=o&&null!=e&&r(i,t,{configurable:!0,writable:!0,value:e})}}function o(t){return(t={next:t})[Symbol.iterator]=function(){return this},t}function a(t){var r=typeof Symbol<"u"&&Symbol.iterator&&t[Symbol.iterator];return r?r.call(t):{next:e(t)}}function s(t){if(!(t instanceof Array)){t=a(t);for(var e,r=[];!(e=t.next()).done;)r.push(e.value);t=r}return t}i("Symbol",function(t){function e(t,e){this.g=t,r(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;e.prototype.toString=function(){return this.g};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",i=0;return function t(r){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(n+(r||"")+"_"+i++,r)}}),i("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var i="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),a=0;a<i.length;a++){var s=n[i[a]];"function"==typeof s&&"function"!=typeof s.prototype[t]&&r(s.prototype,t,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return t});var u,c="function"==typeof Object.create?Object.create:function(t){function e(){}return e.prototype=t,new e};if("function"==typeof Object.setPrototypeOf)u=Object.setPrototypeOf;else{var l;t:{var f={};try{f.__proto__={a:!0},l=f.a;break t}catch{}l=!1}u=l?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var h=u;function d(t,e){if(t.prototype=c(e.prototype),t.prototype.constructor=t,h)h(t,e);else for(var r in e)if("prototype"!=r)if(Object.defineProperties){var n=Object.getOwnPropertyDescriptor(e,r);n&&Object.defineProperty(t,r,n)}else t[r]=e[r];t.ea=e.prototype}function g(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function p(t){if(t.l)throw new TypeError("Generator is already running");t.l=!0}function m(t,e){t.j={U:e,V:!0},t.g=t.m||t.s}function y(t,e,r){return t.g=r,{value:e}}function v(t){this.g=new g,this.h=t}function b(t,e,r,n){try{var i=e.call(t.g.i,r);if(!(i instanceof Object))throw new TypeError("Iterator result "+i+" is not an object");if(!i.done)return t.g.l=!1,i;var o=i.value}catch(e){return t.g.i=null,m(t.g,e),w(t)}return t.g.i=null,n.call(t.g,o),w(t)}function w(t){for(;t.g.g;)try{var e=t.h(t.g);if(e)return t.g.l=!1,{value:e.value,done:!1}}catch(e){t.g.h=void 0,m(t.g,e)}if(t.g.l=!1,t.g.j){if(e=t.g.j,t.g.j=null,e.V)throw e.U;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function x(t){this.next=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.next,e,t.g.o):(t.g.o(e),e=w(t)),e},this.throw=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.throw,e,t.g.o):(m(t.g,e),e=w(t)),e},this.return=function(e){return function(t,e){p(t.g);var r=t.g.i;return r?b(t,"return"in r?r.return:function(t){return{value:t,done:!0}},e,t.g.return):(t.g.return(e),w(t))}(t,e)},this[Symbol.iterator]=function(){return this}}function A(t,e){return e=new x(new v(e)),h&&t.prototype&&h(e,t.prototype),e}g.prototype.o=function(t){this.h=t},g.prototype.return=function(t){this.j={return:t},this.g=this.s};var _="function"==typeof Object.assign?Object.assign:function(t,e){for(var r=1;r<arguments.length;r++){var n=arguments[r];if(n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};i("Object.assign",function(t){return t||_}),i("Promise",function(t){function e(t){this.h=0,this.i=void 0,this.g=[],this.o=!1;var e=this.j();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function r(){this.g=null}function i(t){return t instanceof e?t:new e(function(e){e(t)})}if(t)return t;r.prototype.h=function(t){if(null==this.g){this.g=[];var e=this;this.i(function(){e.l()})}this.g.push(t)};var o=n.setTimeout;r.prototype.i=function(t){o(t,0)},r.prototype.l=function(){for(;this.g&&this.g.length;){var t=this.g;this.g=[];for(var e=0;e<t.length;++e){var r=t[e];t[e]=null;try{r()}catch(t){this.j(t)}}}this.g=null},r.prototype.j=function(t){this.i(function(){throw t})},e.prototype.j=function(){function t(t){return function(n){r||(r=!0,t.call(e,n))}}var e=this,r=!1;return{resolve:t(this.C),reject:t(this.l)}},e.prototype.C=function(t){if(t===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.F(t);else{t:switch(typeof t){case"object":var r=null!=t;break t;case"function":r=!0;break t;default:r=!1}r?this.u(t):this.m(t)}},e.prototype.u=function(t){var e=void 0;try{e=t.then}catch(t){return void this.l(t)}"function"==typeof e?this.G(e,t):this.m(t)},e.prototype.l=function(t){this.s(2,t)},e.prototype.m=function(t){this.s(1,t)},e.prototype.s=function(t,e){if(0!=this.h)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.h);this.h=t,this.i=e,2===this.h&&this.D(),this.A()},e.prototype.D=function(){var t=this;o(function(){if(t.B()){var e=n.console;typeof e<"u"&&e.error(t.i)}},1)},e.prototype.B=function(){if(this.o)return!1;var t=n.CustomEvent,e=n.Event,r=n.dispatchEvent;return typeof r>"u"||("function"==typeof t?t=new t("unhandledrejection",{cancelable:!0}):"function"==typeof e?t=new e("unhandledrejection",{cancelable:!0}):(t=n.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,t),t.promise=this,t.reason=this.i,r(t))},e.prototype.A=function(){if(null!=this.g){for(var t=0;t<this.g.length;++t)s.h(this.g[t]);this.g=null}};var s=new r;return e.prototype.F=function(t){var e=this.j();t.J(e.resolve,e.reject)},e.prototype.G=function(t,e){var r=this.j();try{t.call(e,r.resolve,r.reject)}catch(t){r.reject(t)}},e.prototype.then=function(t,r){function n(t,e){return"function"==typeof t?function(e){try{i(t(e))}catch(t){o(t)}}:e}var i,o,a=new e(function(t,e){i=t,o=e});return this.J(n(t,i),n(r,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.J=function(t,e){function r(){switch(n.h){case 1:t(n.i);break;case 2:e(n.i);break;default:throw Error("Unexpected state: "+n.h)}}var n=this;null==this.g?s.h(r):this.g.push(r),this.o=!0},e.resolve=i,e.reject=function(t){return new e(function(e,r){r(t)})},e.race=function(t){return new e(function(e,r){for(var n=a(t),o=n.next();!o.done;o=n.next())i(o.value).J(e,r)})},e.all=function(t){var r=a(t),n=r.next();return n.done?i([]):new e(function(t,e){function o(e){return function(r){a[e]=r,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,i(n.value).J(o(a.length-1),e),n=r.next()}while(!n.done)})},e}),i("Object.is",function(t){return t||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}}),i("Array.prototype.includes",function(t){return t||function(t,e){var r=this;r instanceof String&&(r=String(r));var n=r.length;for(0>(e=e||0)&&(e=Math.max(e+n,0));e<n;e++){var i=r[e];if(i===t||Object.is(i,t))return!0}return!1}}),i("String.prototype.includes",function(t){return t||function(t,e){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(t,e||0)}}),i("Array.prototype.keys",function(t){return t||function(){return function(t,e){t instanceof String&&(t+="");var r=0,n=!1,i={next:function(){if(!n&&r<t.length){var i=r++;return{value:e(i,t[i]),done:!1}}return n=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,function(t){return t})}});var E=this||self;function T(t,e){t=t.split(".");var r,n=E;t[0]in n||typeof n.execScript>"u"||n.execScript("var "+t[0]);for(;t.length&&(r=t.shift());)t.length||void 0===e?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=e}function k(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}var S,F,O=typeof TextDecoder<"u",R=typeof TextEncoder<"u";function I(t){if(R)t=(F||(F=new TextEncoder)).encode(t);else{var e=void 0;e=void 0!==e&&e;for(var r=0,n=new Uint8Array(3*t.length),i=0;i<t.length;i++){var o=t.charCodeAt(i);if(128>o)n[r++]=o;else{if(2048>o)n[r++]=o>>6|192;else{if(55296<=o&&57343>=o){if(56319>=o&&i<t.length){var a=t.charCodeAt(++i);if(56320<=a&&57343>=a){o=1024*(o-55296)+a-56320+65536,n[r++]=o>>18|240,n[r++]=o>>12&63|128,n[r++]=o>>6&63|128,n[r++]=63&o|128;continue}i--}if(e)throw Error("Found an unpaired surrogate");o=65533}n[r++]=o>>12|224,n[r++]=o>>6&63|128}n[r++]=63&o|128}}t=n.subarray(0,r)}return t}var P={},j=null;function C(t,e){void 0===e&&(e=0),L(),e=P[e];for(var r=Array(Math.floor(t.length/3)),n=e[64]||"",i=0,o=0;i<t.length-2;i+=3){var a=t[i],s=t[i+1],u=t[i+2],c=e[a>>2];a=e[(3&a)<<4|s>>4],s=e[(15&s)<<2|u>>6],u=e[63&u],r[o++]=c+a+s+u}switch(c=0,u=n,t.length-i){case 2:u=e[(15&(c=t[i+1]))<<2]||n;case 1:t=t[i],r[o]=e[t>>2]+e[(3&t)<<4|c>>4]+u+n}return r.join("")}function M(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){var r=t.charAt(n++),i=j[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}L();for(var n=0;;){var i=r(-1),o=r(0),a=r(64),s=r(64);if(64===s&&-1===i)break;e(i<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,function(t){n[i++]=t}),n.subarray(0,i)}function L(){if(!j){j={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));P[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===j[o]&&(j[o]=i)}}}}var B,U="function"==typeof Uint8Array.prototype.slice;function N(t,e,r){return e===r?B||(B=new Uint8Array(0)):U?t.slice(e,r):new Uint8Array(t.subarray(e,r))}var D=0;function z(t,e){e=void 0!==(e=void 0===e?{}:e).v&&e.v,this.h=null,this.g=this.j=this.l=0,this.m=!1,this.v=e,t&&G(this,t)}function G(t,e){e=e.constructor===Uint8Array?e:e.constructor===ArrayBuffer||e.constructor===Array?new Uint8Array(e):e.constructor===String?M(e):e instanceof Uint8Array?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t.h=e,t.l=0,t.j=t.h.length,t.g=t.l}function W(t){for(var e=128,r=0,n=0,i=0;4>i&&128<=e;i++)r|=(127&(e=t.h[t.g++]))<<7*i;if(128<=e&&(r|=(127&(e=t.h[t.g++]))<<28,n|=(127&e)>>4),128<=e)for(i=0;5>i&&128<=e;i++)n|=(127&(e=t.h[t.g++]))<<7*i+3;if(128>e)return t=r>>>0,(n=2147483648&(e=n>>>0))&&(e=~e>>>0,0==(t=1+~t>>>0)&&(e=e+1>>>0)),t=4294967296*e+(t>>>0),n?-t:t;t.m=!0}z.prototype.reset=function(){this.g=this.l},z.prototype.i=function(){var t=this.h,e=t[this.g],r=127&e;return 128>e?(this.g+=1,r):(r|=(127&(e=t[this.g+1]))<<7,128>e?(this.g+=2,r):(r|=(127&(e=t[this.g+2]))<<14,128>e?(this.g+=3,r):(r|=(127&(e=t[this.g+3]))<<21,128>e?(this.g+=4,r):(r|=(15&(e=t[this.g+4]))<<28,128>e?(this.g+=5,r>>>0):(this.g+=5,128<=t[this.g++]&&128<=t[this.g++]&&128<=t[this.g++]&&128<=t[this.g++]&&this.g++,r)))))},z.prototype.o=function(){var t=this.h[this.g],e=this.h[this.g+1],r=this.h[this.g+2],n=this.h[this.g+3];return this.g+=4,t=2*((r=(t|e<<8|r<<16|n<<24)>>>0)>>31)+1,e=r>>>23&255,r&=8388607,255==e?r?NaN:1/0*t:0==e?t*Math.pow(2,-149)*r:t*Math.pow(2,e-150)*(r+Math.pow(2,23))};var H=[];function V(){this.g=new Uint8Array(64),this.h=0}function $(t,e){for(;127<e;)t.push(127&e|128),e>>>=7;t.push(e)}function Y(t){var e={},r=void 0!==e.N&&e.N;this.o={v:void 0!==e.v&&e.v},this.N=r,e=this.o,H.length?(r=H.pop(),e&&(r.v=e.v),t&&G(r,t),t=r):t=new z(t,e),this.g=t,this.m=this.g.g,this.h=this.i=this.l=-1,this.j=!1}function X(t){var e=t.g;if((e=e.g==e.j)||(e=t.j)||(e=(e=t.g).m||0>e.g||e.g>e.j),e)return!1;t.m=t.g.g;var r=7&(e=t.g.i());return 0!=r&&5!=r&&1!=r&&2!=r&&3!=r&&4!=r?(t.j=!0,!1):(t.i=e,t.l=e>>>3,t.h=r,!0)}function q(t){switch(t.h){case 0:if(0!=t.h)q(t);else{for(t=t.g;128&t.h[t.g];)t.g++;t.g++}break;case 1:1!=t.h?q(t):(t=t.g).g+=8;break;case 2:if(2!=t.h)q(t);else{var e=t.g.i();(t=t.g).g+=e}break;case 5:5!=t.h?q(t):(t=t.g).g+=4;break;case 3:for(e=t.l;;){if(!X(t)){t.j=!0;break}if(4==t.h){t.l!=e&&(t.j=!0);break}q(t)}break;default:t.j=!0}}function K(t,e,r){var n=t.g.j,i=t.g.i(),o=t.g.g+i;if(t.g.j=o,r(e,t),0!==(r=o-t.g.g))throw Error("Message parsing ended unexpectedly. Expected to read "+i+" bytes, instead read "+(i-r)+" bytes, either the data ended unexpectedly or the message misreported its own length");return t.g.g=o,t.g.j=n,e}function Q(t){return t.g.o()}function J(t){var e,r=t.g.i(),n=(t=t.g).g;if(t.g+=r,t=t.h,O)(e=S)||(e=S=new TextDecoder("utf-8",{fatal:!1})),e=e.decode(t.subarray(n,n+r));else{r=n+r;for(var i,o,a,s=[],u=null;n<r;)128>(i=t[n++])?s.push(i):224>i?n>=r?s.push(65533):(o=t[n++],194>i||128!=(192&o)?(n--,s.push(65533)):s.push((31&i)<<6|63&o)):240>i?n>=r-1?s.push(65533):128!=(192&(o=t[n++]))||224===i&&160>o||237===i&&160<=o||128!=(192&(e=t[n++]))?(n--,s.push(65533)):s.push((15&i)<<12|(63&o)<<6|63&e):244>=i?n>=r-2?s.push(65533):128!=(192&(o=t[n++]))||o-144+(i<<28)>>30||128!=(192&(e=t[n++]))||128!=(192&(a=t[n++]))?(n--,s.push(65533)):(i=(7&i)<<18|(63&o)<<12|(63&e)<<6|63&a,i-=65536,s.push(55296+(i>>10&1023),56320+(1023&i))):s.push(65533),8192<=s.length&&(u=k(u,s),s.length=0);e=k(u,s)}return e}function Z(t,e,r){var n=t.g.i();for(n=t.g.g+n;t.g.g<n;)r.push(e.call(t.g))}function tt(t,e){2==t.h?Z(t,z.prototype.o,e):e.push(Q(t))}function et(){this.h=[],this.i=0,this.g=new V}function rt(t,e){0!==e.length&&(t.h.push(e),t.i+=e.length)}function nt(t){var e=t.i+t.g.length();if(0===e)return new Uint8Array(0);e=new Uint8Array(e);for(var r=t.h,n=r.length,i=0,o=0;o<n;o++){var a=r[o];0!==a.length&&(e.set(a,i),i+=a.length)}return 0!==(n=(r=t.g).h)&&(e.set(r.g.subarray(0,n),i),r.h=0),t.h=[e],e}function it(t,e,r){if(null!=r){$(t.g,8*e+5),t=t.g;var n=r;0===(n=(r=0>n?1:0)?-n:n)?0<1/n?D=0:D=2147483648:isNaN(n)?D=2147483647:34028234663852886e22<n?D=(r<<31|2139095040)>>>0:11754943508222875e-54>n?(n=Math.round(n/Math.pow(2,-149)),D=(r<<31|n)>>>0):(e=Math.floor(Math.log(n)/Math.LN2),n*=Math.pow(2,-e),16777216<=(n=Math.round(8388608*n))&&++e,D=(r<<31|e+127<<23|8388607&n)>>>0),r=D,t.push(r>>>0&255),t.push(r>>>8&255),t.push(r>>>16&255),t.push(r>>>24&255)}}V.prototype.push=function(t){if(!(this.h+1<this.g.length)){var e=this.g;this.g=new Uint8Array(Math.ceil(1+2*this.g.length)),this.g.set(e)}this.g[this.h++]=t},V.prototype.length=function(){return this.h},V.prototype.end=function(){var t=this.g,e=this.h;return this.h=0,N(t,0,e)},Y.prototype.reset=function(){this.g.reset(),this.h=this.l=-1};var ot="function"==typeof Uint8Array;function at(t,e,r){if(null!=t)return"object"==typeof t?ot&&t instanceof Uint8Array?r(t):st(t,e,r):e(t)}function st(t,e,r){if(Array.isArray(t)){for(var n=Array(t.length),i=0;i<t.length;i++)n[i]=at(t[i],e,r);return Array.isArray(t)&&t.W&&ft(n),n}for(i in n={},t)n[i]=at(t[i],e,r);return n}function ut(t){return"number"==typeof t?isFinite(t)?t:String(t):t}var ct,lt={W:{value:!0,configurable:!0}};function ft(t){return Array.isArray(t)&&!Object.isFrozen(t)&&Object.defineProperties(t,lt),t}function ht(t,e,r){var n=ct;if(ct=null,t||(t=n),n=this.constructor.ca,t||(t=n?[n]:[]),this.j=n?0:-1,this.m=this.g=null,this.h=t,t=(n=this.h.length)-1,!n||(null===(n=this.h[t])||"object"!=typeof n||Array.isArray(n)||ot&&n instanceof Uint8Array)?void 0!==e&&-1<e?(this.l=Math.max(e,t+1-this.j),this.i=null):this.l=Number.MAX_VALUE:(this.l=t-this.j,this.i=n),r)for(e=0;e<r.length;e++)(t=r[e])<this.l?(t+=this.j,(n=this.h[t])?ft(n):this.h[t]=dt):(gt(this),(n=this.i[t])?ft(n):this.i[t]=dt)}var dt=Object.freeze(ft([]));function gt(t){var e=t.l+t.j;t.h[e]||(t.i=t.h[e]={})}function pt(t,e,r){return-1===e?null:void 0!==r&&r||e>=t.l?t.i?t.i[e]:void 0:t.h[e+t.j]}function mt(t,e){var r=void 0!==r&&r,n=pt(t,e,r);return null==n&&(n=dt),n===dt&&wt(t,e,n=ft([]),r),n}function yt(t){var e=mt(t,3);if(t.m||(t.m={}),!t.m[3]){for(var r=0;r<e.length;r++)e[r]=+e[r];t.m[3]=!0}return e}function vt(t,e,r){return(t=pt(t,e))??r}function bt(t,e,r){return(t=null==(t=pt(t,e))?t:+t)??(void 0===r?0:r)}function wt(t,e,r,n){void 0!==n&&n||e>=t.l?(gt(t),t.i[e]=r):t.h[e+t.j]=r}function xt(t,e,r){if(-1===r)return null;if(t.g||(t.g={}),!t.g[r]){var n=pt(t,r,!1);n&&(t.g[r]=new e(n))}return t.g[r]}function At(t,e){t.g||(t.g={});var r=t.g[1];if(!r){var n=mt(t,1);r=[];for(var i=0;i<n.length;i++)r[i]=new e(n[i]);t.g[1]=r}return r}function _t(t,e,r){var n=void 0!==n&&n;t.g||(t.g={});var i=r&&Tt(r);t.g[e]=r,wt(t,e,i,n)}function Et(t,e,r,n){var i=At(t,r);e=e||new r,t=mt(t,1),null!=n?(i.splice(n,0,e),t.splice(n,0,Tt(e))):(i.push(e),t.push(Tt(e)))}function Tt(t,e){if(t.g)for(var r in t.g){var n=t.g[r];if(Array.isArray(n))for(var i=0;i<n.length;i++)n[i]&&Tt(n[i]);else n&&Tt(n)}return t.h}function kt(t,e){if(t=t.o){rt(e,e.g.end());for(var r=0;r<t.length;r++)rt(e,t[r])}}function St(t,e){if(4==e.h)return!1;var r=e.m;return q(e),e.N||(e=N(e.g.h,r,e.g.g),(r=t.o)?r.push(e):t.o=[e]),!0}function Ft(t){ht.call(this,t,-1,Rt)}function Ot(t,e){for(;X(e);)switch(e.i){case 8:var r=e.g.i();wt(t,1,r);break;case 16:wt(t,2,r=e.g.i());break;case 29:case 26:tt(e,t.getPackedDataList());break;case 32:wt(t,4,r=W(e.g));break;default:if(!St(t,e))return t}return t}ht.prototype.toJSON=function(){return st(Tt(this),ut,C)},ht.prototype.toString=function(){return Tt(this).toString()},d(Ft,ht),Ft.prototype.getRows=function(){return pt(this,1)},Ft.prototype.getCols=function(){return pt(this,2)},Ft.prototype.getPackedDataList=function(){return yt(this)},Ft.prototype.getLayout=function(){return vt(this,4,0)};var Rt=[3];function It(t,e){var r=void 0;return new(r||(r=Promise))(function(n,i){function o(t){try{s(e.next(t))}catch(t){i(t)}}function a(t){try{s(e.throw(t))}catch(t){i(t)}}function s(t){t.done?n(t.value):new r(function(e){e(t.value)}).then(o,a)}s((e=e.apply(t,void 0)).next())})}function Pt(t){ht.call(this,t)}function jt(t,e){for(;X(e);)switch(e.i){case 8:var r=e.g.i();wt(t,1,r);break;case 21:wt(t,2,r=Q(e));break;case 26:wt(t,3,r=J(e));break;case 34:wt(t,4,r=J(e));break;default:if(!St(t,e))return t}return t}function Ct(t){ht.call(this,t,-1,Mt)}d(Pt,ht),d(Ct,ht),Ct.prototype.addClassification=function(t,e){return Et(this,t,Pt,e),this};var Mt=[1];function Lt(t){ht.call(this,t)}function Bt(t,e){for(;X(e);)switch(e.i){case 13:var r=Q(e);wt(t,1,r);break;case 21:wt(t,2,r=Q(e));break;case 29:wt(t,3,r=Q(e));break;case 37:wt(t,4,r=Q(e));break;case 45:wt(t,5,r=Q(e));break;default:if(!St(t,e))return t}return t}function Ut(t){ht.call(this,t,-1,Dt)}function Nt(t){t:{var e=new Ut;for(t=new Y(t);X(t);)if(10===t.i){Et(e,K(t,new Lt,Bt),Lt,void 0)}else if(!St(e,t))break t}return e}d(Lt,ht),d(Ut,ht);var Dt=[1];function zt(t){ht.call(this,t)}function Gt(t){ht.call(this,t,-1,Ht)}function Wt(t,e){for(;X(e);)switch(e.i){case 8:var r=W(e.g);wt(t,1,r);break;case 16:wt(t,2,r=W(e.g));break;case 29:case 26:tt(e,t.getVertexBufferList());break;case 32:case 34:r=e;var n=t.getIndexBufferList();2==r.h?Z(r,z.prototype.i,n):n.push(r.g.i());break;default:if(!St(t,e))return t}return t}d(zt,ht),d(Gt,ht),Gt.prototype.getVertexType=function(){return vt(this,1,0)},Gt.prototype.getPrimitiveType=function(){return vt(this,2,0)},Gt.prototype.getVertexBufferList=function(){return yt(this)},Gt.prototype.getIndexBufferList=function(){return mt(this,4)};var Ht=[3,4];function Vt(t){ht.call(this,t)}function $t(t,e,r){if(r=t.createShader(0===r?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+t.getShaderInfoLog(r));return r}function Yt(t){return At(t,Pt).map(function(t){return{index:vt(t,1,0),Y:bt(t,2),label:null!=pt(t,3)?vt(t,3,""):void 0,displayName:null!=pt(t,4)?vt(t,4,""):void 0}})}function Xt(t){return{x:bt(t,1),y:bt(t,2),z:bt(t,3),visibility:null!=pt(t,4)?bt(t,4):void 0}}function qt(t,e){this.h=t,this.g=e,this.l=0}function Kt(t,e,r){return function(t,e){var r=t.g;if(void 0===t.m){var n=$t(r,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",0),i=$t(r,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=r.createProgram();if(r.attachShader(o,n),r.attachShader(o,i),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+r.getProgramInfoLog(o));n=t.m=o,r.useProgram(n),i=r.getUniformLocation(n,"sampler0"),t.j={I:r.getAttribLocation(n,"aVertex"),H:r.getAttribLocation(n,"aTex"),da:i},t.s=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.enableVertexAttribArray(t.j.I),r.vertexAttribPointer(t.j.I,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),t.o=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.enableVertexAttribArray(t.j.H),r.vertexAttribPointer(t.j.H,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.uniform1i(i,0)}n=t.j,r.useProgram(t.m),r.canvas.width=e.width,r.canvas.height=e.height,r.viewport(0,0,e.width,e.height),r.activeTexture(r.TEXTURE0),t.h.bindTexture2d(e.glName),r.enableVertexAttribArray(n.I),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.vertexAttribPointer(n.I,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(n.H),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.vertexAttribPointer(n.H,2,r.FLOAT,!1,0,0),r.bindFramebuffer(r.DRAW_FRAMEBUFFER?r.DRAW_FRAMEBUFFER:r.FRAMEBUFFER,null),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.colorMask(!0,!0,!0,!0),r.drawArrays(r.TRIANGLE_FAN,0,4),r.disableVertexAttribArray(n.I),r.disableVertexAttribArray(n.H),r.bindBuffer(r.ARRAY_BUFFER,null),t.h.bindTexture2d(0)}(t,e),"function"==typeof t.g.canvas.transferToImageBitmap?Promise.resolve(t.g.canvas.transferToImageBitmap()):r?Promise.resolve(t.g.canvas):"function"==typeof createImageBitmap?createImageBitmap(t.g.canvas):(void 0===t.i&&(t.i=document.createElement("canvas")),new Promise(function(e){t.i.height=t.g.canvas.height,t.i.width=t.g.canvas.width,t.i.getContext("2d",{}).drawImage(t.g.canvas,0,0,t.g.canvas.width,t.g.canvas.height),e(t.i)}))}function Qt(t){this.g=t}d(Vt,ht),Vt.prototype.getMesh=function(){return xt(this,Gt,1)},Vt.prototype.getPoseTransformMatrix=function(){return xt(this,Ft,2)};var Jt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Zt(t,e){return e+t}function te(t,e){window[t]=e}function ee(t){if(this.g=t,this.listeners={},this.j={},this.F={},this.m={},this.s={},this.G=this.o=this.R=!0,this.C=Promise.resolve(),this.P="",this.B={},this.locateFile=t&&t.locateFile||Zt,"object"==typeof window)var e=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(!(typeof location<"u"))throw Error("solutions can only be loaded on a web page or in a web worker");e=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.S=e,t.options)for(var r=(e=a(Object.keys(t.options))).next();!r.done;r=e.next()){r=r.value;var n=t.options[r].default;void 0!==n&&(this.j[r]="function"==typeof n?n():n)}}function re(t){return It(t,function t(){var e,r,n,i,o,a,u,c,l,f,h,d=this;return A(t,function(t){switch(t.g){case 1:return e=d,d.R?(r=function(t,e){return void 0===t.g.files?[]:"function"==typeof t.g.files?t.g.files(e):t.g.files}(d,d.j),y(t,function(){return It(this,function t(){return A(t,function(t){switch(t.g){case 1:return t.m=2,y(t,WebAssembly.instantiate(Jt),4);case 4:t.g=3,t.m=0;break;case 2:return t.m=0,t.j=null,t.return(!1);case 3:return t.return(!0)}})})}(),2)):t.return();case 2:if(n=t.h,"object"==typeof window)return te("createMediapipeSolutionsWasm",{locateFile:d.locateFile}),te("createMediapipeSolutionsPackedAssets",{locateFile:d.locateFile}),a=r.filter(function(t){return void 0!==t.data}),u=r.filter(function(t){return void 0===t.data}),c=Promise.all(a.map(function(t){var r=ne(e,t.url);if(void 0!==t.path){var n=t.path;r=r.then(function(t){return e.overrideFile(n,t),Promise.resolve(t)})}return r})),l=Promise.all(u.map(function(t){return void 0===t.simd||t.simd&&n||!t.simd&&!n?function(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(t){e.addEventListener("load",function(){t()},!1),e.addEventListener("error",function(){t()},!1),document.body.appendChild(e)})}(e.locateFile(t.url,e.S)):Promise.resolve()})).then(function(){return It(e,function t(){var e,r,n=this;return A(t,function(t){if(1==t.g)return e=window.createMediapipeSolutionsWasm,r=window.createMediapipeSolutionsPackedAssets,y(t,e(r),2);n.h=t.h,t.g=0})})}),f=It(e,function t(){var e=this;return A(t,function(t){return e.g.graph&&e.g.graph.url?t=y(t,ne(e,e.g.graph.url),0):(t.g=0,t=void 0),t})}),y(t,Promise.all([l,c,f]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return i=r.filter(function(t){return void 0===t.simd||t.simd&&n||!t.simd&&!n}).map(function(t){return e.locateFile(t.url,e.S)}),importScripts.apply(null,s(i)),y(t,createMediapipeSolutionsWasm(Module),6);case 6:d.h=t.h,d.l=new OffscreenCanvas(1,1),d.h.canvas=d.l,o=d.h.GL.createContext(d.l,{antialias:!1,alpha:!1,ba:typeof WebGL2RenderingContext<"u"?2:1}),d.h.GL.makeContextCurrent(o),t.g=4;break;case 7:if(d.l=document.createElement("canvas"),!(h=d.l.getContext("webgl2",{}))&&!(h=d.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),t.return();d.D=h,d.h.canvas=d.l,d.h.createContext(d.l,!0,!0,{});case 4:d.i=new d.h.SolutionWasm,d.R=!1,t.g=0}})})}function ne(t,e){return It(t,function t(){var r,n,i=this;return A(t,function(t){return e in i.F?t.return(i.F[e]):(r=i.locateFile(e,""),n=fetch(r).then(function(t){return t.arrayBuffer()}),i.F[e]=n,t.return(n))})})}function ie(t,e,r){return It(t,function t(){var n,i,o,s,u,c,l,f,h,d,g,p,m,v,b=this;return A(t,function(t){switch(t.g){case 1:if(!r)return t.return(e);for(n={},i=0,o=a(Object.keys(r)),s=o.next();!s.done;s=o.next())u=s.value,"string"!=typeof(c=r[u])&&"texture"===c.type&&void 0!==e[c.stream]&&++i;1<i&&(b.G=!1),l=a(Object.keys(r)),s=l.next();case 2:if(s.done){t.g=4;break}if(f=s.value,"string"==typeof(h=r[f]))return m=n,v=f,y(t,function(t,e,r){return It(t,function t(){var n,i=this;return A(t,function(t){return"number"==typeof r||r instanceof Uint8Array||r instanceof i.h.Uint8BlobList?t.return(r):r instanceof i.h.Texture2dDataOut?((n=i.s[e])||(n=new qt(i.h,i.D),i.s[e]=n),t.return(Kt(n,r,i.G))):t.return(void 0)})})}(b,f,e[h]),14);if(d=e[h.stream],"detection_list"===h.type){if(d){for(var w=d.getRectList(),x=d.getLandmarksList(),_=d.getClassificationsList(),E=[],T=0;T<w.size();++T){var k=w.get(T);t:{var S=new zt;for(k=new Y(k);X(k);)switch(k.i){case 13:var F=Q(k);wt(S,1,F);break;case 21:wt(S,2,F=Q(k));break;case 29:wt(S,3,F=Q(k));break;case 37:wt(S,4,F=Q(k));break;case 45:wt(S,5,F=Q(k));break;case 48:wt(S,6,F=W(k.g));break;default:if(!St(S,k))break t}}S={Z:bt(S,1),$:bt(S,2),height:bt(S,3),width:bt(S,4),rotation:bt(S,5,0),X:vt(S,6,0)},k=At(Nt(x.get(T)),Lt).map(Xt);var O=_.get(T);t:for(F=new Ct,O=new Y(O);X(O);)if(10===O.i)F.addClassification(K(O,new Pt,jt));else if(!St(F,O))break t;S={T:S,O:k,M:Yt(F)},E.push(S)}w=E}else w=[];n[f]=w,t.g=7;break}if("proto_list"===h.type){if(d){for(w=Array(d.size()),x=0;x<d.size();x++)w[x]=d.get(x);d.delete()}else w=[];n[f]=w,t.g=7;break}if(void 0===d){t.g=3;break}if("float_list"===h.type){n[f]=d,t.g=7;break}if("proto"===h.type){n[f]=d,t.g=7;break}if("texture"!==h.type)throw Error("Unknown output config type: '"+h.type+"'");return(g=b.s[f])||(g=new qt(b.h,b.D),b.s[f]=g),y(t,Kt(g,d,b.G),13);case 13:p=t.h,n[f]=p;case 7:h.transform&&n[f]&&(n[f]=h.transform(n[f])),t.g=3;break;case 14:m[v]=t.h;case 3:s=l.next(),t.g=2;break;case 4:return t.return(n)}})})}function oe(t,e){for(var r=e.name||"$",n=[].concat(s(e.wants)),i=new t.h.StringList,o=a(e.wants),u=o.next();!u.done;u=o.next())i.push_back(u.value);o=t.h.PacketListener.implement({onResults:function(i){for(var o={},a=0;a<e.wants.length;++a)o[n[a]]=i.get(a);var s=t.listeners[r];s&&(t.C=ie(t,o,e.outs).then(function(r){r=s(r);for(var i=0;i<e.wants.length;++i){var a=o[n[i]];"object"==typeof a&&a.hasOwnProperty&&a.hasOwnProperty("delete")&&a.delete()}r&&(t.C=r)}))}}),t.i.attachMultiListener(i,o),i.delete()}function ae(t){t=function(t){t:{var e=new Vt;for(t=new Y(t);X(t);)switch(t.i){case 10:var r=K(t,new Gt,Wt);_t(e,1,r);break;case 18:_t(e,2,r=K(t,new Ft,Ot));break;default:if(!St(e,t))break t}}return e}(t);var e=t.getMesh();if(!e)return t;var r=new Float32Array(e.getVertexBufferList());e.getVertexBufferList=function(){return r};var n=new Uint32Array(e.getIndexBufferList());return e.getIndexBufferList=function(){return n},t}(t=ee.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},t.reset=function(){return It(this,function t(){var e=this;return A(t,function(t){e.i&&(e.i.reset(),e.m={},e.s={}),t.g=0})})},t.setOptions=function(t,e){var r=this;if(e=e||this.g.options){for(var n=[],i=[],o={},s=a(Object.keys(t)),u=s.next();!u.done;o={K:o.K,L:o.L},u=s.next()){var c=u.value;c in this.j&&this.j[c]===t[c]||(this.j[c]=t[c],void 0!==(u=e[c])&&(u.onChange&&(o.K=u.onChange,o.L=t[c],n.push(function(t){return function(){return It(r,function e(){var r=this;return A(e,function(e){if(1==e.g)return y(e,t.K(t.L),2);!0===e.h&&(r.o=!0),e.g=0})})}}(o))),u.graphOptionXref&&(c={valueNumber:1===u.type?t[c]:0,valueBoolean:0===u.type&&t[c],valueString:2===u.type?t[c]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),c),i.push(u))))}(0!==n.length||0!==i.length)&&(this.o=!0,this.A=(void 0===this.A?[]:this.A).concat(i),this.u=(void 0===this.u?[]:this.u).concat(n))}},t.initialize=function(){return It(this,function t(){var e=this;return A(t,function(t){return 1==t.g?y(t,re(e),2):3!=t.g?y(t,function(t){return It(t,function t(){var e,r,n,i,o,s,u,c,l=this;return A(t,function(t){if(1==t.g)return l.g.graph&&l.g.graph.url&&l.P===l.g.graph.url?t.return():(l.o=!0,l.g.graph&&l.g.graph.url?(l.P=l.g.graph.url,y(t,ne(l,l.g.graph.url),3)):void(t.g=2));for(2!=t.g&&(e=t.h,l.i.loadGraph(e)),r=a(Object.keys(l.B)),n=r.next();!n.done;n=r.next())i=n.value,l.i.overrideFile(i,l.B[i]);if(l.B={},l.g.listeners)for(o=a(l.g.listeners),s=o.next();!s.done;s=o.next())u=s.value,oe(l,u);c=l.j,l.j={},l.setOptions(c),t.g=0})})}(e),3):y(t,function(t){return It(t,function t(){var e,r,n,i,o,s,u=this;return A(t,function(t){switch(t.g){case 1:if(!u.o)return t.return();if(!u.u){t.g=2;break}e=a(u.u),r=e.next();case 3:if(r.done){t.g=5;break}return y(t,(0,r.value)(),4);case 4:r=e.next(),t.g=3;break;case 5:u.u=void 0;case 2:if(u.A){for(n=new u.h.GraphOptionChangeRequestList,i=a(u.A),o=i.next();!o.done;o=i.next())s=o.value,n.push_back(s);u.i.changeOptions(n),n.delete(),u.A=void 0}u.o=!1,t.g=0}})})}(e),0)})})},t.overrideFile=function(t,e){this.i?this.i.overrideFile(t,e):this.B[t]=e},t.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},t.send=function(t,e){return It(this,function r(){var n,i,o,s,u,c,l,f,h,d=this;return A(r,function(r){switch(r.g){case 1:return d.g.inputs?(n=1e3*(e??performance.now()),y(r,d.C,2)):r.return();case 2:return y(r,d.initialize(),3);case 3:for(i=new d.h.PacketDataList,o=a(Object.keys(t)),s=o.next();!s.done;s=o.next())if(u=s.value,c=d.g.inputs[u]){t:{var g=d,p=t[u];switch(c.type){case"video":var m=g.m[c.stream];if(m||(m=new qt(g.h,g.D),g.m[c.stream]=m),0===(g=m).l&&(g.l=g.h.createTexture()),typeof HTMLVideoElement<"u"&&p instanceof HTMLVideoElement){var v=p.videoWidth;m=p.videoHeight}else typeof HTMLImageElement<"u"&&p instanceof HTMLImageElement?(v=p.naturalWidth,m=p.naturalHeight):(v=p.width,m=p.height);m={glName:g.l,width:v,height:m},(v=g.g).canvas.width=m.width,v.canvas.height=m.height,v.activeTexture(v.TEXTURE0),g.h.bindTexture2d(g.l),v.texImage2D(v.TEXTURE_2D,0,v.RGBA,v.RGBA,v.UNSIGNED_BYTE,p),g.h.bindTexture2d(0),g=m;break t;case"detections":for((m=g.m[c.stream])||(m=new Qt(g.h),g.m[c.stream]=m),(g=m).data||(g.data=new g.g.DetectionListData),g.data.reset(p.length),m=0;m<p.length;++m){v=p[m];var b=g.data,w=b.setBoundingBox,x=m,A=v.T,_=new zt;wt(_,1,A.Z),wt(_,2,A.$),wt(_,3,A.height),wt(_,4,A.width),wt(_,5,A.rotation),wt(_,6,A.X);var E=A=new et;it(E,1,pt(_,1)),it(E,2,pt(_,2)),it(E,3,pt(_,3)),it(E,4,pt(_,4)),it(E,5,pt(_,5));var T=pt(_,6);if(null!=T&&null!=T){$(E.g,48);var k=E.g,S=T;T=0>S;var F=(S=Math.abs(S))>>>0;for(S=Math.floor((S-F)/4294967296),S>>>=0,T&&(S=~S>>>0,4294967295<(F=(~F>>>0)+1)&&(F=0,4294967295<++S&&(S=0))),T=D=F,F=S;0<F||127<T;)k.push(127&T|128),T=(T>>>7|F<<25)>>>0,F>>>=7;k.push(T)}if(kt(_,E),A=nt(A),w.call(b,x,A),v.O)for(b=0;b<v.O.length;++b)E=!!(_=v.O[b]).visibility,x=(w=g.data).addNormalizedLandmark,A=m,_=Object.assign(Object.assign({},_),{visibility:E?_.visibility:0}),wt(E=new Lt,1,_.x),wt(E,2,_.y),wt(E,3,_.z),_.visibility&&wt(E,4,_.visibility),it(k=_=new et,1,pt(E,1)),it(k,2,pt(E,2)),it(k,3,pt(E,3)),it(k,4,pt(E,4)),it(k,5,pt(E,5)),kt(E,k),_=nt(_),x.call(w,A,_);if(v.M)for(b=0;b<v.M.length;++b){if(x=(w=g.data).addClassification,A=m,_=v.M[b],wt(E=new Pt,2,_.Y),_.index&&wt(E,1,_.index),_.label&&wt(E,3,_.label),_.displayName&&wt(E,4,_.displayName),k=_=new et,null!=(F=pt(E,1))&&null!=F)if($(k.g,8),T=k.g,0<=F)$(T,F);else{for(S=0;9>S;S++)T.push(127&F|128),F>>=7;T.push(1)}it(k,2,pt(E,2)),null!=(T=pt(E,3))&&(T=I(T),$(k.g,26),$(k.g,T.length),rt(k,k.g.end()),rt(k,T)),null!=(T=pt(E,4))&&(T=I(T),$(k.g,34),$(k.g,T.length),rt(k,k.g.end()),rt(k,T)),kt(E,k),_=nt(_),x.call(w,A,_)}}g=g.data;break t;default:g={}}}switch(l=g,f=c.stream,c.type){case"video":i.pushTexture2d(Object.assign(Object.assign({},l),{stream:f,timestamp:n}));break;case"detections":(h=l).stream=f,h.timestamp=n,i.pushDetectionList(h);break;default:throw Error("Unknown input config type: '"+c.type+"'")}}return d.i.send(i),y(r,d.C,4);case 4:i.delete(),r.g=0}})})},t.onResults=function(t,e){this.listeners[e||"$"]=t},T("Solution",ee),T("OptionType",{BOOL:0,NUMBER:1,aa:2,0:"BOOL",1:"NUMBER",2:"STRING"});var se={files:[{url:"face_mesh_solution_packed_assets_loader.js"},{simd:!0,url:"face_mesh_solution_simd_wasm_bin.js"},{simd:!1,url:"face_mesh_solution_wasm_bin.js"}],graph:{url:"face_mesh.binarypb"},listeners:[{wants:["multi_face_geometry","image_transformed","multi_face_landmarks"],outs:{image:"image_transformed",multiFaceGeometry:{type:"proto_list",stream:"multi_face_geometry",transform:function(t){return t.map(ae)}},multiFaceLandmarks:{type:"proto_list",stream:"multi_face_landmarks",transform:function(t){return t.map(function(t){return At(Nt(t),Lt).map(Xt)})}}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document},enableFaceGeometry:{type:0,graphOptionXref:{calculatorName:"EnableFaceGeometryConstant",calculatorType:"ConstantSidePacketCalculator",fieldName:"bool_value"}},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},maxNumFaces:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorNumFaces",fieldName:"int_value"}},refineLandmarks:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorRefineLandmarks",fieldName:"bool_value"}},minDetectionConfidence:{type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"facelandmarkfrontgpu__facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"facelandmarkfrontgpu__facelandmarkgpu__ThresholdingCalculator",fieldName:"threshold"}},cameraNear:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"near"}},cameraFar:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"far"}},cameraVerticalFovDegrees:{type:1,graphOptionXref:{calculatorType:"FaceGeometryEnvGeneratorCalculator",fieldName:"vertical_fov_degrees"}}}},ue=[[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]],ce=[[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]],le=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],fe=[[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]],he=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],de=[[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]],ge=[].concat(s(ue),s(ce),s(le),s(fe),s(he),s(de));function pe(t){t=t||{},t=Object.assign(Object.assign({},se),t),this.g=new ee(t)}(t=pe.prototype).close=function(){return this.g.close(),Promise.resolve()},t.onResults=function(t){this.g.onResults(t)},t.initialize=function(){return It(this,function t(){var e=this;return A(t,function(t){return y(t,e.g.initialize(),0)})})},t.reset=function(){this.g.reset()},t.send=function(t){return It(this,function e(){var r=this;return A(e,function(e){return y(e,r.g.send(t),0)})})},t.setOptions=function(t){this.g.setOptions(t)},T("FACE_GEOMETRY",{Layout:{COLUMN_MAJOR:0,ROW_MAJOR:1,0:"COLUMN_MAJOR",1:"ROW_MAJOR"},PrimitiveType:{TRIANGLE:0,0:"TRIANGLE"},VertexType:{VERTEX_PT:0,0:"VERTEX_PT"},DEFAULT_CAMERA_PARAMS:{verticalFovDegrees:63,near:1,far:1e4}}),T("FaceMesh",pe),T("FACEMESH_LIPS",ue),T("FACEMESH_LEFT_EYE",ce),T("FACEMESH_LEFT_EYEBROW",le),T("FACEMESH_LEFT_IRIS",[[474,475],[475,476],[476,477],[477,474]]),T("FACEMESH_RIGHT_EYE",fe),T("FACEMESH_RIGHT_EYEBROW",he),T("FACEMESH_RIGHT_IRIS",[[469,470],[470,471],[471,472],[472,469]]),T("FACEMESH_FACE_OVAL",de),T("FACEMESH_CONTOURS",ge),T("FACEMESH_TESSELATION",[[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]]),T("matrixDataToMatrix",function(t){for(var e=t.getCols(),r=t.getRows(),n=t.getPackedDataList(),i=[],o=0;o<r;o++)i.push(Array(e));for(o=0;o<r;o++)for(var a=0;a<e;a++){var s=1===t.getLayout()?o*e+a:a*r+o;i[o][a]=n[s]}return i}),T("VERSION","0.4.1633559619")}).call(Mi);const Li={};(function(){var t;function e(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var r="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,r){return t==Array.prototype||t==Object.prototype||(t[e]=r.value),t};var n=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var e=0;e<t.length;++e){var r=t[e];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);function i(t,e){if(e)t:{var i=n;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];if(!(a in i))break t;i=i[a]}(e=e(o=i[t=t[t.length-1]]))!=o&&null!=e&&r(i,t,{configurable:!0,writable:!0,value:e})}}function o(t){return(t={next:t})[Symbol.iterator]=function(){return this},t}function a(t){var r=typeof Symbol<"u"&&Symbol.iterator&&t[Symbol.iterator];return r?r.call(t):{next:e(t)}}function s(t){if(!(t instanceof Array)){t=a(t);for(var e,r=[];!(e=t.next()).done;)r.push(e.value);t=r}return t}i("Symbol",function(t){function e(t,e){this.g=t,r(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;e.prototype.toString=function(){return this.g};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",i=0;return function t(r){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(n+(r||"")+"_"+i++,r)}}),i("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var i="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),a=0;a<i.length;a++){var s=n[i[a]];"function"==typeof s&&"function"!=typeof s.prototype[t]&&r(s.prototype,t,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return t});var u,c="function"==typeof Object.create?Object.create:function(t){function e(){}return e.prototype=t,new e};if("function"==typeof Object.setPrototypeOf)u=Object.setPrototypeOf;else{var l;t:{var f={};try{f.__proto__={a:!0},l=f.a;break t}catch{}l=!1}u=l?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var h=u;function d(t,e){if(t.prototype=c(e.prototype),t.prototype.constructor=t,h)h(t,e);else for(var r in e)if("prototype"!=r)if(Object.defineProperties){var n=Object.getOwnPropertyDescriptor(e,r);n&&Object.defineProperty(t,r,n)}else t[r]=e[r];t.ka=e.prototype}function g(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function p(t){if(t.l)throw new TypeError("Generator is already running");t.l=!0}function m(t,e){t.j={V:e,X:!0},t.g=t.m||t.s}function y(t,e,r){return t.g=r,{value:e}}function v(t){this.g=new g,this.h=t}function b(t,e,r,n){try{var i=e.call(t.g.i,r);if(!(i instanceof Object))throw new TypeError("Iterator result "+i+" is not an object");if(!i.done)return t.g.l=!1,i;var o=i.value}catch(e){return t.g.i=null,m(t.g,e),w(t)}return t.g.i=null,n.call(t.g,o),w(t)}function w(t){for(;t.g.g;)try{var e=t.h(t.g);if(e)return t.g.l=!1,{value:e.value,done:!1}}catch(e){t.g.h=void 0,m(t.g,e)}if(t.g.l=!1,t.g.j){if(e=t.g.j,t.g.j=null,e.X)throw e.V;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function x(t){this.next=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.next,e,t.g.o):(t.g.o(e),e=w(t)),e},this.throw=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.throw,e,t.g.o):(m(t.g,e),e=w(t)),e},this.return=function(e){return function(t,e){p(t.g);var r=t.g.i;return r?b(t,"return"in r?r.return:function(t){return{value:t,done:!0}},e,t.g.return):(t.g.return(e),w(t))}(t,e)},this[Symbol.iterator]=function(){return this}}function A(t){return function(t){function e(e){return t.next(e)}function r(e){return t.throw(e)}return new Promise(function(n,i){!function t(o){o.done?n(o.value):Promise.resolve(o.value).then(e,r).then(t,i)}(t.next())})}(new x(new v(t)))}g.prototype.o=function(t){this.h=t},g.prototype.return=function(t){this.j={return:t},this.g=this.s},i("Promise",function(t){function e(t){this.h=0,this.i=void 0,this.g=[],this.o=!1;var e=this.j();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function r(){this.g=null}function i(t){return t instanceof e?t:new e(function(e){e(t)})}if(t)return t;r.prototype.h=function(t){if(null==this.g){this.g=[];var e=this;this.i(function(){e.l()})}this.g.push(t)};var o=n.setTimeout;r.prototype.i=function(t){o(t,0)},r.prototype.l=function(){for(;this.g&&this.g.length;){var t=this.g;this.g=[];for(var e=0;e<t.length;++e){var r=t[e];t[e]=null;try{r()}catch(t){this.j(t)}}}this.g=null},r.prototype.j=function(t){this.i(function(){throw t})},e.prototype.j=function(){function t(t){return function(n){r||(r=!0,t.call(e,n))}}var e=this,r=!1;return{resolve:t(this.D),reject:t(this.l)}},e.prototype.D=function(t){if(t===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.G(t);else{t:switch(typeof t){case"object":var r=null!=t;break t;case"function":r=!0;break t;default:r=!1}r?this.A(t):this.m(t)}},e.prototype.A=function(t){var e=void 0;try{e=t.then}catch(t){return void this.l(t)}"function"==typeof e?this.H(e,t):this.m(t)},e.prototype.l=function(t){this.s(2,t)},e.prototype.m=function(t){this.s(1,t)},e.prototype.s=function(t,e){if(0!=this.h)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.h);this.h=t,this.i=e,2===this.h&&this.F(),this.B()},e.prototype.F=function(){var t=this;o(function(){if(t.C()){var e=n.console;typeof e<"u"&&e.error(t.i)}},1)},e.prototype.C=function(){if(this.o)return!1;var t=n.CustomEvent,e=n.Event,r=n.dispatchEvent;return typeof r>"u"||("function"==typeof t?t=new t("unhandledrejection",{cancelable:!0}):"function"==typeof e?t=new e("unhandledrejection",{cancelable:!0}):(t=n.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,t),t.promise=this,t.reason=this.i,r(t))},e.prototype.B=function(){if(null!=this.g){for(var t=0;t<this.g.length;++t)s.h(this.g[t]);this.g=null}};var s=new r;return e.prototype.G=function(t){var e=this.j();t.K(e.resolve,e.reject)},e.prototype.H=function(t,e){var r=this.j();try{t.call(e,r.resolve,r.reject)}catch(t){r.reject(t)}},e.prototype.then=function(t,r){function n(t,e){return"function"==typeof t?function(e){try{i(t(e))}catch(t){o(t)}}:e}var i,o,a=new e(function(t,e){i=t,o=e});return this.K(n(t,i),n(r,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.K=function(t,e){function r(){switch(n.h){case 1:t(n.i);break;case 2:e(n.i);break;default:throw Error("Unexpected state: "+n.h)}}var n=this;null==this.g?s.h(r):this.g.push(r),this.o=!0},e.resolve=i,e.reject=function(t){return new e(function(e,r){r(t)})},e.race=function(t){return new e(function(e,r){for(var n=a(t),o=n.next();!o.done;o=n.next())i(o.value).K(e,r)})},e.all=function(t){var r=a(t),n=r.next();return n.done?i([]):new e(function(t,e){function o(e){return function(r){a[e]=r,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,i(n.value).K(o(a.length-1),e),n=r.next()}while(!n.done)})},e});var _="function"==typeof Object.assign?Object.assign:function(t,e){for(var r=1;r<arguments.length;r++){var n=arguments[r];if(n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};i("Object.assign",function(t){return t||_}),i("Object.is",function(t){return t||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}}),i("Array.prototype.includes",function(t){return t||function(t,e){var r=this;r instanceof String&&(r=String(r));var n=r.length;for(0>(e=e||0)&&(e=Math.max(e+n,0));e<n;e++){var i=r[e];if(i===t||Object.is(i,t))return!0}return!1}}),i("String.prototype.includes",function(t){return t||function(t,e){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(t,e||0)}}),i("Array.prototype.keys",function(t){return t||function(){return function(t,e){t instanceof String&&(t+="");var r=0,n=!1,i={next:function(){if(!n&&r<t.length){var i=r++;return{value:e(i,t[i]),done:!1}}return n=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,function(t){return t})}});var E=this||self;function T(t,e){t=t.split(".");var r,n=E;t[0]in n||typeof n.execScript>"u"||n.execScript("var "+t[0]);for(;t.length&&(r=t.shift());)t.length||void 0===e?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=e}function k(t){throw t}function S(t,e){k(Error("Invalid wire type: "+t+" (at position "+e+")"))}function F(){k(Error("Failed to read varint, encoding is invalid."))}function O(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}var R,I,P=typeof TextDecoder<"u",j=typeof TextEncoder<"u";function C(t){if(j)t=(I||(I=new TextEncoder)).encode(t);else{var e=void 0;e=void 0!==e&&e;for(var r=0,n=new Uint8Array(3*t.length),i=0;i<t.length;i++){var o=t.charCodeAt(i);if(128>o)n[r++]=o;else{if(2048>o)n[r++]=o>>6|192;else{if(55296<=o&&57343>=o){if(56319>=o&&i<t.length){var a=t.charCodeAt(++i);if(56320<=a&&57343>=a){o=1024*(o-55296)+a-56320+65536,n[r++]=o>>18|240,n[r++]=o>>12&63|128,n[r++]=o>>6&63|128,n[r++]=63&o|128;continue}i--}if(e)throw Error("Found an unpaired surrogate");o=65533}n[r++]=o>>12|224,n[r++]=o>>6&63|128}n[r++]=63&o|128}}t=n.subarray(0,r)}return t}var M={},L=null;function B(t){var e;void 0===e&&(e=0),N(),e=M[e];for(var r=Array(Math.floor(t.length/3)),n=e[64]||"",i=0,o=0;i<t.length-2;i+=3){var a=t[i],s=t[i+1],u=t[i+2],c=e[a>>2];a=e[(3&a)<<4|s>>4],s=e[(15&s)<<2|u>>6],u=e[63&u],r[o++]=c+a+s+u}switch(c=0,u=n,t.length-i){case 2:u=e[(15&(c=t[i+1]))<<2]||n;case 1:t=t[i],r[o]=e[t>>2]+e[(3&t)<<4|c>>4]+u+n}return r.join("")}function U(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){var r=t.charAt(n++),i=L[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}N();for(var n=0;;){var i=r(-1),o=r(0),a=r(64),s=r(64);if(64===s&&-1===i)break;e(i<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,function(t){n[i++]=t}),n.subarray(0,i)}function N(){if(!L){L={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));M[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===L[o]&&(L[o]=i)}}}}var D,z="function"==typeof Uint8Array;function G(t){if(this.g=t,null!==t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}var W="function"==typeof Uint8Array.prototype.slice;function H(t,e,r){return e===r?D||(D=new Uint8Array(0)):W?t.slice(e,r):new Uint8Array(t.subarray(e,r))}var V=0;function $(t,e){e=void 0!==(e=void 0===e?{}:e).v&&e.v,this.h=null,this.g=this.i=this.l=0,this.j=!1,this.v=e,t&&Y(this,t)}function Y(t,e){t.h=function(t){if(t.constructor===Uint8Array)return t;if(t.constructor===ArrayBuffer)return new Uint8Array(t);if(t.constructor===Array)return new Uint8Array(t);if(t.constructor===String)return U(t);if(t.constructor===G){if(null==t.g)var e=D||(D=new Uint8Array(0));else{e=Uint8Array;var r=t.g;r=null==r||z&&null!=r&&r instanceof Uint8Array?r:"string"==typeof r?U(r):null,e=new e(t=t.g=r)}return e}if(t instanceof Uint8Array)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}(e),t.l=0,t.i=t.h.length,t.g=t.l}function X(t){for(var e=128,r=0,n=0,i=0;4>i&&128<=e;i++)r|=(127&(e=t.h[t.g++]))<<7*i;if(128<=e&&(r|=(127&(e=t.h[t.g++]))<<28,n|=(127&e)>>4),128<=e)for(i=0;5>i&&128<=e;i++)n|=(127&(e=t.h[t.g++]))<<7*i+3;if(128>e)return t=r>>>0,(n=2147483648&(e=n>>>0))&&(e=~e>>>0,0==(t=1+~t>>>0)&&(e=e+1>>>0)),t=4294967296*e+(t>>>0),n?-t:t;t.j=!0,F()}function q(t){t.g>t.i&&(t.j=!0,k(Error("Tried to read past the end of the data "+t.g+" > "+t.i)))}function K(t){var e=t.h,r=e[t.g],n=127&r;return 128>r?(t.g+=1,q(t),n):(n|=(127&(r=e[t.g+1]))<<7,128>r?(t.g+=2,q(t),n):(n|=(127&(r=e[t.g+2]))<<14,128>r?(t.g+=3,q(t),n):(n|=(127&(r=e[t.g+3]))<<21,128>r?(t.g+=4,q(t),n):(n|=(15&(r=e[t.g+4]))<<28,128>r?(t.g+=5,q(t),n>>>0):(t.g+=5,128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]?(t.j=!0,F(),n):(q(t),n))))))}function Q(t){var e=t.h[t.g],r=t.h[t.g+1],n=t.h[t.g+2],i=t.h[t.g+3];return t.g+=4,q(t),(e|r<<8|n<<16|i<<24)>>>0}$.prototype.reset=function(){this.g=this.l},$.prototype.m=function(){var t=Q(this),e=2*(t>>31)+1,r=t>>>23&255;return t&=8388607,255==r?t?NaN:1/0*e:0==r?e*Math.pow(2,-149)*t:e*Math.pow(2,r-150)*(t+Math.pow(2,23))};var J=[];function Z(){this.g=new Uint8Array(64),this.h=0}function tt(t,e){if(!(t.h+1<t.g.length)){var r=t.g;t.g=new Uint8Array(Math.ceil(1+2*t.g.length)),t.g.set(r)}t.g[t.h++]=e}function et(t,e){for(;127<e;)tt(t,127&e|128),e>>>=7;tt(t,e)}function rt(t){var e={},r=void 0!==e.O&&e.O;this.m={v:void 0!==e.v&&e.v},this.O=r,e=this.m,J.length?(r=J.pop(),e&&(r.v=e.v),t&&Y(r,t),t=r):t=new $(t,e),this.g=t,this.l=this.g.g,this.h=this.i=-1,this.j=!1}function nt(t){var e=t.g;if((e=e.g==e.i)||(e=t.j)||(e=(e=t.g).j||0>e.g||e.g>e.i),e)return!1;t.l=t.g.g;var r=K(t.g);return e=r>>>3,0<=(r&=7)&&5>=r?(t.i=e,t.h=r,!0):(t.j=!0,S(r,t.l),!1)}function it(t){switch(t.h){case 0:if(0!=t.h)it(t);else t:{for(var e=(t=t.g).g,r=0;10>r;r++){if(!(128&t.h[e])){t.g=e+1,q(t);break t}e++}t.j=!0,F()}break;case 1:(t=t.g).g+=8,q(t);break;case 2:2!=t.h?it(t):(e=K(t.g),(t=t.g).g+=e,q(t));break;case 5:(t=t.g).g+=4,q(t);break;case 3:for(e=t.i;;){if(!nt(t)){t.j=!0,k(Error("Unmatched start-group tag: stream EOF"));break}if(4==t.h){t.i!=e&&(t.j=!0,k(Error("Unmatched end-group tag")));break}it(t)}break;default:t.j=!0,S(t.h,t.l)}}function ot(t,e,r){var n=t.g.i,i=K(t.g),o=t.g.g+i;if(t.g.i=o,r(e,t),0!==(r=o-t.g.g))throw Error("Message parsing ended unexpectedly. Expected to read "+i+" bytes, instead read "+(i-r)+" bytes, either the data ended unexpectedly or the message misreported its own length");return t.g.g=o,t.g.i=n,e}Z.prototype.length=function(){return this.h},Z.prototype.end=function(){var t=this.g,e=this.h;return this.h=0,H(t,0,e)},rt.prototype.reset=function(){this.g.reset(),this.h=this.i=-1};var at=[];function st(){this.h=[],this.i=0,this.g=new Z}function ut(t,e){0!==e.length&&(t.h.push(e),t.i+=e.length)}function ct(t,e,r){et(t.g,8*e+2),et(t.g,r.length),ut(t,t.g.end()),ut(t,r)}var lt,ft="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol(void 0):void 0;function ht(t){return Object.isFrozen(t)||(ft?t[ft]|=1:void 0!==t.g?t.g|=1:Object.defineProperties(t,{g:{value:1,configurable:!0,writable:!0,enumerable:!1}})),t}function dt(t){return null!==t&&"object"==typeof t&&t.constructor===Object}function gt(t,e){if(null!=t)return Array.isArray(t)||dt(t)?pt(t,e):e(t)}function pt(t,e){if(Array.isArray(t)){for(var r=Array(t.length),n=0;n<t.length;n++)r[n]=gt(t[n],e);var i;if(e=Array.isArray(t))e=1&((i=ft?t[ft]:t.g)??0);return e&&ht(r),r}for(r in i={},t)i[r]=gt(t[r],e);return i}function mt(t){return t=function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"object":if(z&&null!=t&&t instanceof Uint8Array)return B(t);if(t instanceof G){if(null==t.g)t="";else{var e=t.g;e=null==e||"string"==typeof e?e:z&&e instanceof Uint8Array?B(e):null,t=t.g=e}return t}}return t}(t),Array.isArray(t)?pt(t,mt):t}function yt(t,e,r){var n=lt;if(lt=null,t||(t=n),n=this.constructor.ha,t||(t=n?[n]:[]),this.i=(n?0:-1)-(this.constructor.fa||0),this.l=this.g=null,this.u=t,t=(n=this.u.length)-1,n&&dt(n=this.u[t])?(this.j=t-this.i,this.h=n):void 0!==e&&-1<e?(this.j=Math.max(e,t+1-this.i),this.h=null):this.j=Number.MAX_VALUE,r)for(e=0;e<r.length;e++)(t=r[e])<this.j?(t+=this.i,(n=this.u[t])?Array.isArray(n)&&ht(n):this.u[t]=vt):(bt(this),(n=this.h[t])?Array.isArray(n)&&ht(n):this.h[t]=vt)}var vt=Object.freeze(ht([]));function bt(t){var e=t.j+t.i;t.u[e]||(t.h=t.u[e]={})}function wt(t,e,r){return-1===e?null:void 0!==r&&r||e>=t.j?t.h?t.h[e]:void 0:t.u[e+t.i]}function xt(t,e,r){var n=wt(t,e,r=void 0!==r&&r);return null==n&&(n=vt),n===vt&&Et(t,e,n=ht(n.slice()),r),n}function At(t,e){var r=xt(t,e);if(t.l||(t.l={}),!t.l[e]){for(var n=0;n<r.length;n++)r[n]=+r[n];t.l[e]=!0}return r}function _t(t,e,r){return(t=null==(t=wt(t,e))?t:+t)??(void 0===r?0:r)}function Et(t,e,r,n){void 0!==n&&n||e>=t.j?(bt(t),t.h[e]=r):t.u[e+t.i]=r}function Tt(t,e,r,n){r!==n?Et(t,e,r):Et(t,e,void 0,!1)}function kt(t,e,r){if(-1===r)return null;t.g||(t.g={});var n=t.g[r];if(n)return n;var i=wt(t,r,!1);return null==i?n:(e=new e(i),t.g[r]=e)}function St(t,e,r){t.g||(t.g={});var n=t.g[r];if(!n){var i=xt(t,r,!1);n=[];for(var o=0;o<i.length;o++)n[o]=new e(i[o]);t.g[r]=n}return n}function Ft(t,e,r,n,i){var o=St(t,n,e);r=r||new n,t=xt(t,e),null!=i?(o.splice(i,0,r),t.splice(i,0,r.u)):(o.push(r),t.push(r.u))}function Ot(t,e){return(t=wt(t,e))??0}function Rt(t,e){return(t=wt(t,e))??""}function It(t,e){if(t=t.m){ut(e,e.g.end());for(var r=0;r<t.length;r++)ut(e,t[r])}}yt.prototype.toJSON=function(){return pt(this.u,mt)},yt.prototype.toString=function(){return this.u.toString()};var Pt=Symbol();function jt(t,e,r){return t[Pt]||(t[Pt]=function(t,n){return e(t,n,r)})}function Ct(t){var e=t[Pt];if(!e){var r=t[Bt]||(t[Bt]=t());e=function(t,e){return Ut(t,e,r)},t[Pt]=e}return e}function Mt(t){var e=function(t){var e=t.da;if(e)return Ct(e);if(e=t.ia){var r=t.Y;return delete t.Y,jt(t.W.g,e,r)}}(t),r=t.W,n=t.ea;return e?function(t,i){return n(t,i,r,e)}:function(t,e){return n(t,e,r)}}function Lt(t){var e=t[0];switch(t.length){case 2:var r=t[1];return function(t,n,i){return e(t,n,i,r)};case 3:var n=t[1],i=Ct(t[2]);return function(t,r,o){return e(t,r,o,n,i)};case 4:var o=t[1],a=t[3],s=Ct(t[2]);return function(t,r,n){return e(t,r,n,o,s,a)};case 5:var u=t[1],c=jt(u,t[3],t[4]);return function(t,r,n){return e(t,r,n,u,c)};case 6:var l=t[1],f=t[5],h=jt(l,t[3],t[4]);return function(t,r,n){return e(t,r,n,l,h,f)};default:throw Error("Unsupported number of parameters, expected [2-6], got "+t.length)}}var Bt=Symbol();function Ut(t,e,r){for(;nt(e)&&4!=e.h;){var n=e.i,i=r[n];if(i)Array.isArray(i)&&(i=r[n]=Lt(i));else{var o=r[0];o&&(o=o[n])&&(i=r[n]=Mt(o))}i&&i(e,t,n)||(n=t,o=(i=e).l,it(i),i.O||(i=H(i.g.h,o,i.g.g),(o=n.m)?o.push(i):n.m=[i]))}return t}function Nt(t,e){var r=new st;if(e(t,r),0===(t=r.i+r.g.length()))r=new Uint8Array(0);else{t=new Uint8Array(t);for(var n=r.h,i=n.length,o=e=0;o<i;o++){var a=n[o];0!==a.length&&(t.set(a,e),e+=a.length)}0!==(i=(n=r.g).h)&&(t.set(n.g.subarray(0,i),e),n.h=0),r.h=[t],r=t}return r}function Dt(t,e,r){if(at.length){var n=at.pop();t&&(Y(n.g,t),n.i=-1,n.h=-1),t=n}else t=new rt(t);try{return Ut(new e,t,r[Bt]||(r[Bt]=r()))}finally{(e=t.g).h=null,e.l=0,e.i=0,e.g=0,e.j=!1,e.v=!1,t.i=-1,t.h=-1,t.j=!1,100>at.length&&at.push(t)}}function zt(t,e,r){if(null!=(e=wt(e,r))){et(t.g,8*r+5),t=t.g;var n=e;0===(n=(r=0>n?1:0)?-n:n)?0<1/n?V=0:V=2147483648:isNaN(n)?V=2147483647:34028234663852886e22<n?V=(r<<31|2139095040)>>>0:11754943508222875e-54>n?(n=Math.round(n/Math.pow(2,-149)),V=(r<<31|n)>>>0):(e=Math.floor(Math.log(n)/Math.LN2),n*=Math.pow(2,-e),16777216<=(n=Math.round(8388608*n))&&++e,V=(r<<31|e+127<<23|8388607&n)>>>0),tt(t,(r=V)>>>0&255),tt(t,r>>>8&255),tt(t,r>>>16&255),tt(t,r>>>24&255)}}function Gt(t,e,r){if(1!==t.h)return!1;var n=t.g;t=Q(n);var i=Q(n);n=2*(i>>31)+1;var o=i>>>20&2047;return t=4294967296*(1048575&i)+t,Tt(e,r,2047==o?t?NaN:1/0*n:0==o?n*Math.pow(2,-1074)*t:n*Math.pow(2,o-1075)*(t+4503599627370496),0),!0}function Wt(t,e,r){return 5===t.h&&(Et(e,r,t.g.m()),!0)}function Ht(t,e,r){if(5!==t.h&&2!==t.h)return!1;if(e=xt(e,r),2==t.h){r=$.prototype.m;var n=K(t.g);for(n=t.g.g+n;t.g.g<n;)e.push(r.call(t.g))}else e.push(t.g.m());return!0}function Vt(t,e,r){return 5===t.h&&(Tt(e,r,t=t.g.m(),0),!0)}function $t(t,e,r){return 0===t.h&&(Et(e,r,X(t.g)),!0)}function Yt(t,e,r){return 0===t.h&&(Et(e,r,K(t.g)),!0)}function Xt(t,e,r){return 0===t.h&&(Tt(e,r,t=K(t.g),0),!0)}function qt(t,e,r){return 0===t.h&&(Tt(e,r,t=!!K(t.g),!1),!0)}function Kt(t,e,r){if(2!==t.h)return!1;var n,i=K(t.g),o=(t=t.g).g;if(t.g+=i,q(t),t=t.h,P)(n=R)||(n=R=new TextDecoder("utf-8",{fatal:!1})),n=n.decode(t.subarray(o,o+i));else{i=o+i;for(var a,s,u,c=[],l=null;o<i;)128>(a=t[o++])?c.push(a):224>a?o>=i?c.push(65533):(s=t[o++],194>a||128!=(192&s)?(o--,c.push(65533)):c.push((31&a)<<6|63&s)):240>a?o>=i-1?c.push(65533):128!=(192&(s=t[o++]))||224===a&&160>s||237===a&&160<=s||128!=(192&(n=t[o++]))?(o--,c.push(65533)):c.push((15&a)<<12|(63&s)<<6|63&n):244>=a?o>=i-2?c.push(65533):128!=(192&(s=t[o++]))||s-144+(a<<28)>>30||128!=(192&(n=t[o++]))||128!=(192&(u=t[o++]))?(o--,c.push(65533)):(a=(7&a)<<18|(63&s)<<12|(63&n)<<6|63&u,a-=65536,c.push(55296+(a>>10&1023),56320+(1023&a))):c.push(65533),8192<=c.length&&(l=O(l,c),c.length=0);n=O(l,c)}return Et(e,r,n),!0}function Qt(t,e,r,n,i){return 2===t.h&&(t=ot(t,new n,i),e.g||(e.g={}),n=t&&t.u,e.g[r]=t,Et(e,r,n,!1),!0)}function Jt(t,e,r,n,i){return 2===t.h&&(Ft(e,r,t=ot(t,new n,i),n,void 0),!0)}function Zt(t,e,r){return 0===t.h&&(Et(e,r,X(t.g)),!0)}function te(t){yt.call(this,t)}function ee(){return{1:Yt,2:Wt,3:Kt,4:Kt}}function re(t,e){var r=wt(t,1);if(null!=r&&null!=r){et(e.g,8);var n=e.g;if(0<=r)et(n,r);else{for(var i=0;9>i;i++)tt(n,127&r|128),r>>=7;tt(n,1)}}zt(e,t,2),null!=(n=wt(t,3))&&ct(e,3,C(n)),null!=(n=wt(t,4))&&ct(e,4,C(n)),It(t,e)}function ne(t){yt.call(this,t,-1,oe)}function ie(){return{1:[Jt,te,ee]}}d(te,yt),d(ne,yt),ne.prototype.addClassification=function(t,e){return Ft(this,1,t,te,e),this};var oe=[1];function ae(t){yt.call(this,t)}function se(){return{1:Wt,2:Wt,3:Wt,4:Wt,5:Wt}}function ue(t,e){zt(e,t,1),zt(e,t,2),zt(e,t,3),zt(e,t,4),zt(e,t,5),It(t,e)}function ce(t){yt.call(this,t,-1,fe)}function le(){return{1:[Jt,ae,se]}}d(ae,yt),d(ce,yt);var fe=[1];function he(t){yt.call(this,t)}function de(){return{1:Wt,2:Wt,3:Wt,4:Wt,5:Wt,6:$t}}function ge(t,e){zt(e,t,1),zt(e,t,2),zt(e,t,3),zt(e,t,4),zt(e,t,5);var r=wt(t,6);if(null!=r&&null!=r){et(e.g,48);var n=e.g,i=r;r=0>i;var o=(i=Math.abs(i))>>>0;for(i=Math.floor((i-o)/4294967296),i>>>=0,r&&(i=~i>>>0,4294967295<(o=(~o>>>0)+1)&&(o=0,4294967295<++i&&(i=0))),r=V=o,o=i;0<o||127<r;)tt(n,127&r|128),r=(r>>>7|o<<25)>>>0,o>>>=7;tt(n,r)}It(t,e)}function pe(t){yt.call(this,t,-1,be)}function me(){return{1:Zt,2:Zt,3:Ht,4:[Qt,ye,ve],5:Yt,6:Yt,7:Ht,8:Ht,9:Ht}}function ye(t){yt.call(this,t)}function ve(){return{1:Wt,2:Wt,3:Wt}}d(he,yt),d(pe,yt),d(ye,yt);var be=[3,7,8,9];function we(t){yt.call(this,t)}function xe(){return{1:Vt,2:Vt,3:Vt}}function Ae(t){yt.call(this,t)}function _e(){return{1:Vt,2:Vt,3:Vt}}function Ee(t){yt.call(this,t)}function Te(){return{1:Xt,2:[Qt,Ae,_e],3:[Qt,we,xe],4:qt}}function ke(t){yt.call(this,t,-1,Fe)}function Se(){return{1:Xt,2:[Jt,Ee,Te],3:Vt,4:Ht,5:Ht,6:Ht}}d(we,yt),d(Ae,yt),d(Ee,yt),d(ke,yt);var Fe=[2,4,5,6];function Oe(t){yt.call(this,t,-1,Ie)}function Re(){return{1:Xt,2:[Jt,ke,Se],3:[Qt,pe,me],4:Gt,5:Ht,6:Ht}}d(Oe,yt);var Ie=[2,5,6];function Pe(t,e,r){if(r=t.createShader(0===r?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+t.getShaderInfoLog(r));return r}function je(t){return St(t,te,1).map(function(t){return{index:Ot(t,1),$:_t(t,2),label:null!=wt(t,3)?Rt(t,3):void 0,displayName:null!=wt(t,4)?Rt(t,4):void 0}})}function Ce(t){return{x:_t(t,1),y:_t(t,2),z:_t(t,3),visibility:null!=wt(t,4)?_t(t,4):void 0}}function Me(t,e){this.h=t,this.g=e,this.l=0}function Le(t,e,r){return function(t,e){var r=t.g;if(void 0===t.m){var n=Pe(r,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",0),i=Pe(r,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=r.createProgram();if(r.attachShader(o,n),r.attachShader(o,i),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+r.getProgramInfoLog(o));n=t.m=o,r.useProgram(n),i=r.getUniformLocation(n,"sampler0"),t.j={J:r.getAttribLocation(n,"aVertex"),I:r.getAttribLocation(n,"aTex"),ja:i},t.s=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.enableVertexAttribArray(t.j.J),r.vertexAttribPointer(t.j.J,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),t.o=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.enableVertexAttribArray(t.j.I),r.vertexAttribPointer(t.j.I,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.uniform1i(i,0)}n=t.j,r.useProgram(t.m),r.canvas.width=e.width,r.canvas.height=e.height,r.viewport(0,0,e.width,e.height),r.activeTexture(r.TEXTURE0),t.h.bindTexture2d(e.glName),r.enableVertexAttribArray(n.J),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.vertexAttribPointer(n.J,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(n.I),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.vertexAttribPointer(n.I,2,r.FLOAT,!1,0,0),r.bindFramebuffer(r.DRAW_FRAMEBUFFER?r.DRAW_FRAMEBUFFER:r.FRAMEBUFFER,null),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.colorMask(!0,!0,!0,!0),r.drawArrays(r.TRIANGLE_FAN,0,4),r.disableVertexAttribArray(n.J),r.disableVertexAttribArray(n.I),r.bindBuffer(r.ARRAY_BUFFER,null),t.h.bindTexture2d(0)}(t,e),"function"==typeof t.g.canvas.transferToImageBitmap?Promise.resolve(t.g.canvas.transferToImageBitmap()):r?Promise.resolve(t.g.canvas):"function"==typeof createImageBitmap?createImageBitmap(t.g.canvas):(void 0===t.i&&(t.i=document.createElement("canvas")),new Promise(function(e){t.i.height=t.g.canvas.height,t.i.width=t.g.canvas.width,t.i.getContext("2d",{}).drawImage(t.g.canvas,0,0,t.g.canvas.width,t.g.canvas.height),e(t.i)}))}function Be(t){this.g=t}var Ue=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Ne(t,e){return e+t}function De(t,e){window[t]=e}function ze(t){if(this.g=t,this.listeners={},this.j={},this.G={},this.m={},this.s={},this.H=this.o=this.S=!0,this.D=Promise.resolve(),this.R="",this.C={},this.locateFile=t&&t.locateFile||Ne,"object"==typeof window)var e=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(!(typeof location<"u"))throw Error("solutions can only be loaded on a web page or in a web worker");e=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.T=e,t.options)for(var r=(e=a(Object.keys(t.options))).next();!r.done;r=e.next()){r=r.value;var n=t.options[r].default;void 0!==n&&(this.j[r]="function"==typeof n?n():n)}}function Ge(t){var e,r,n,i,o,a,u,c,l,f,h;return A(function(d){switch(d.g){case 1:return t.S?(e=void 0===t.g.files?[]:"function"==typeof t.g.files?t.g.files(t.j):t.g.files,y(d,A(function(t){switch(t.g){case 1:return t.m=2,y(t,WebAssembly.instantiate(Ue),4);case 4:t.g=3,t.m=0;break;case 2:return t.m=0,t.j=null,t.return(!1);case 3:return t.return(!0)}}),2)):d.return();case 2:if(r=d.h,"object"==typeof window)return De("createMediapipeSolutionsWasm",{locateFile:t.locateFile}),De("createMediapipeSolutionsPackedAssets",{locateFile:t.locateFile}),a=e.filter(function(t){return void 0!==t.data}),u=e.filter(function(t){return void 0===t.data}),c=Promise.all(a.map(function(e){var r=We(t,e.url);if(void 0!==e.path){var n=e.path;r=r.then(function(e){return t.overrideFile(n,e),Promise.resolve(e)})}return r})),l=Promise.all(u.map(function(e){return void 0===e.simd||e.simd&&r||!e.simd&&!r?function(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(t){e.addEventListener("load",function(){t()},!1),e.addEventListener("error",function(){t()},!1),document.body.appendChild(e)})}(t.locateFile(e.url,t.T)):Promise.resolve()})).then(function(){var e,r,n;return A(function(i){if(1==i.g)return e=window.createMediapipeSolutionsWasm,r=window.createMediapipeSolutionsPackedAssets,n=t,y(i,e(r),2);n.h=i.h,i.g=0})}),f=A(function(e){return t.g.graph&&t.g.graph.url?e=y(e,We(t,t.g.graph.url),0):(e.g=0,e=void 0),e}),y(d,Promise.all([l,c,f]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return n=e.filter(function(t){return void 0===t.simd||t.simd&&r||!t.simd&&!r}).map(function(e){return t.locateFile(e.url,t.T)}),importScripts.apply(null,s(n)),i=t,y(d,createMediapipeSolutionsWasm(Module),6);case 6:i.h=d.h,t.l=new OffscreenCanvas(1,1),t.h.canvas=t.l,o=t.h.GL.createContext(t.l,{antialias:!1,alpha:!1,ga:typeof WebGL2RenderingContext<"u"?2:1}),t.h.GL.makeContextCurrent(o),d.g=4;break;case 7:if(t.l=document.createElement("canvas"),!(h=t.l.getContext("webgl2",{}))&&!(h=t.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),d.return();t.F=h,t.h.canvas=t.l,t.h.createContext(t.l,!0,!0,{});case 4:t.i=new t.h.SolutionWasm,t.S=!1,d.g=0}})}function We(t,e){var r,n;return A(function(i){return e in t.G?i.return(t.G[e]):(r=t.locateFile(e,""),n=fetch(r).then(function(t){return t.arrayBuffer()}),t.G[e]=n,i.return(n))})}function He(t,e,r){var n,i,o,s,u,c,l,f,h,d,g,p,m,v;return A(function(b){switch(b.g){case 1:if(!r)return b.return(e);for(n={},i=0,o=a(Object.keys(r)),s=o.next();!s.done;s=o.next())u=s.value,"string"!=typeof(c=r[u])&&"texture"===c.type&&void 0!==e[c.stream]&&++i;1<i&&(t.H=!1),l=a(Object.keys(r)),s=l.next();case 2:if(s.done){b.g=4;break}if(f=s.value,"string"==typeof(h=r[f]))return m=n,v=f,y(b,function(t,e,r){var n;return A(function(i){return"number"==typeof r||r instanceof Uint8Array||r instanceof t.h.Uint8BlobList?i.return(r):r instanceof t.h.Texture2dDataOut?((n=t.s[e])||(n=new Me(t.h,t.F),t.s[e]=n),i.return(Le(n,r,t.H))):i.return(void 0)})}(t,f,e[h]),14);if(d=e[h.stream],"detection_list"===h.type){if(d){for(var w=d.getRectList(),x=d.getLandmarksList(),_=d.getClassificationsList(),E=[],T=0;T<w.size();++T){var k=Dt(w.get(T),he,de);k={U:{aa:_t(k,1),ba:_t(k,2),height:_t(k,3),width:_t(k,4),rotation:_t(k,5,0),Z:Ot(k,6)},P:St(Dt(x.get(T),ce,le),ae,1).map(Ce),N:je(Dt(_.get(T),ne,ie))},E.push(k)}w=E}else w=[];n[f]=w,b.g=7;break}if("proto_list"===h.type){if(d){for(w=Array(d.size()),x=0;x<d.size();x++)w[x]=d.get(x);d.delete()}else w=[];n[f]=w,b.g=7;break}if(void 0===d){b.g=3;break}if("float_list"===h.type){n[f]=d,b.g=7;break}if("proto"===h.type){n[f]=d,b.g=7;break}if("texture"!==h.type)throw Error("Unknown output config type: '"+h.type+"'");return(g=t.s[f])||(g=new Me(t.h,t.F),t.s[f]=g),y(b,Le(g,d,t.H),13);case 13:p=b.h,n[f]=p;case 7:h.transform&&n[f]&&(n[f]=h.transform(n[f])),b.g=3;break;case 14:m[v]=b.h;case 3:s=l.next(),b.g=2;break;case 4:return b.return(n)}})}function Ve(t,e){for(var r=e.name||"$",n=[].concat(s(e.wants)),i=new t.h.StringList,o=a(e.wants),u=o.next();!u.done;u=o.next())i.push_back(u.value);o=t.h.PacketListener.implement({onResults:function(i){for(var o={},a=0;a<e.wants.length;++a)o[n[a]]=i.get(a);var s=t.listeners[r];s&&(t.D=He(t,o,e.outs).then(function(r){r=s(r);for(var i=0;i<e.wants.length;++i){var a=o[n[i]];"object"==typeof a&&a.hasOwnProperty&&a.hasOwnProperty("delete")&&a.delete()}r&&(t.D=r)}))}}),t.i.attachMultiListener(i,o),i.delete()}function $e(t){var e=Ot(t,1),r=kt(t,we,3);return{id:e,point2d:r={x:_t(r,1),y:_t(r,2),depth:_t(r,3)},point3d:{x:_t(t=kt(t,Ae,2),1),y:_t(t,2),z:_t(t,3)}}}function Ye(t){var e=Dt(t,Oe,Re);t=[],e=St(e,ke,2);for(var r=0;r<e.length;r++)t.push({id:Ot(e[r],1),keypoints:St(e[r],Ee,2).map($e),visibility:_t(e[r],3),scale:At(e[r],6),translation:At(e[r],5),rotation:At(e[r],4)});return t}function Xe(t){switch(t){case"Camera":return"Camera";case"Chair":return"Chair";case"Cup":return"Coffee cup, Mug";default:return"Footwear"}}(t=ze.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},t.reset=function(){var t=this;return A(function(e){t.i&&(t.i.reset(),t.m={},t.s={}),e.g=0})},t.setOptions=function(t,e){var r=this;if(e=e||this.g.options){for(var n=[],i=[],o={},s=a(Object.keys(t)),u=s.next();!u.done;o={L:o.L,M:o.M},u=s.next()){var c=u.value;c in this.j&&this.j[c]===t[c]||(this.j[c]=t[c],void 0!==(u=e[c])&&(u.onChange&&(o.L=u.onChange,o.M=t[c],n.push(function(t){return function(){return A(function(e){if(1==e.g)return y(e,t.L(t.M),2);!0===e.h&&(r.o=!0),e.g=0})}}(o))),u.graphOptionXref&&(c={valueNumber:1===u.type?t[c]:0,valueBoolean:0===u.type&&t[c],valueString:2===u.type?t[c]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),c),i.push(u))))}(0!==n.length||0!==i.length)&&(this.o=!0,this.B=(void 0===this.B?[]:this.B).concat(i),this.A=(void 0===this.A?[]:this.A).concat(n))}},t.initialize=function(){var t=this;return A(function(e){return 1==e.g?y(e,Ge(t),2):3!=e.g?y(e,function(t){var e,r,n,i,o,s,u,c;return A(function(l){if(1==l.g)return t.g.graph&&t.g.graph.url&&t.R===t.g.graph.url?l.return():(t.o=!0,t.g.graph&&t.g.graph.url?(t.R=t.g.graph.url,y(l,We(t,t.g.graph.url),3)):void(l.g=2));for(2!=l.g&&(e=l.h,t.i.loadGraph(e)),r=a(Object.keys(t.C)),n=r.next();!n.done;n=r.next())i=n.value,t.i.overrideFile(i,t.C[i]);if(t.C={},t.g.listeners)for(o=a(t.g.listeners),s=o.next();!s.done;s=o.next())u=s.value,Ve(t,u);c=t.j,t.j={},t.setOptions(c),l.g=0})}(t),3):y(e,function(t){var e,r,n,i,o,s;return A(function(u){switch(u.g){case 1:if(!t.o)return u.return();if(!t.A){u.g=2;break}e=a(t.A),r=e.next();case 3:if(r.done){u.g=5;break}return y(u,(0,r.value)(),4);case 4:r=e.next(),u.g=3;break;case 5:t.A=void 0;case 2:if(t.B){for(n=new t.h.GraphOptionChangeRequestList,i=a(t.B),o=i.next();!o.done;o=i.next())s=o.value,n.push_back(s);t.i.changeOptions(n),n.delete(),t.B=void 0}t.o=!1,u.g=0}})}(t),0)})},t.overrideFile=function(t,e){this.i?this.i.overrideFile(t,e):this.C[t]=e},t.clearOverriddenFiles=function(){this.C={},this.i&&this.i.clearOverriddenFiles()},t.send=function(t,e){var r,n,i,o,s,u,c,l,f,h=this;return A(function(d){switch(d.g){case 1:return h.g.inputs?(r=1e3*(e??performance.now()),y(d,h.D,2)):d.return();case 2:return y(d,h.initialize(),3);case 3:for(n=new h.h.PacketDataList,i=a(Object.keys(t)),o=i.next();!o.done;o=i.next())if(s=o.value,u=h.g.inputs[s]){t:{var g=t[s];switch(u.type){case"video":var p=h.m[u.stream];if(p||(p=new Me(h.h,h.F),h.m[u.stream]=p),0===p.l&&(p.l=p.h.createTexture()),typeof HTMLVideoElement<"u"&&g instanceof HTMLVideoElement)var m=g.videoWidth,v=g.videoHeight;else typeof HTMLImageElement<"u"&&g instanceof HTMLImageElement?(m=g.naturalWidth,v=g.naturalHeight):(m=g.width,v=g.height);v={glName:p.l,width:m,height:v},(m=p.g).canvas.width=v.width,m.canvas.height=v.height,m.activeTexture(m.TEXTURE0),p.h.bindTexture2d(p.l),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,g),p.h.bindTexture2d(0),p=v;break t;case"detections":for((p=h.m[u.stream])||(p=new Be(h.h),h.m[u.stream]=p),p.data||(p.data=new p.g.DetectionListData),p.data.reset(g.length),v=0;v<g.length;++v){m=g[v];var b=p.data,w=b.setBoundingBox,x=v,A=m.U,_=new he;if(Et(_,1,A.aa),Et(_,2,A.ba),Et(_,3,A.height),Et(_,4,A.width),Et(_,5,A.rotation),Et(_,6,A.Z),A=Nt(_,ge),w.call(b,x,A),m.P)for(b=0;b<m.P.length;++b){var E=!!(_=m.P[b]).visibility;x=(w=p.data).addNormalizedLandmark,A=v,_=Object.assign(Object.assign({},_),{visibility:E?_.visibility:0}),Et(E=new ae,1,_.x),Et(E,2,_.y),Et(E,3,_.z),_.visibility&&Et(E,4,_.visibility),_=Nt(E,ue),x.call(w,A,_)}if(m.N)for(b=0;b<m.N.length;++b)x=(w=p.data).addClassification,A=v,_=m.N[b],Et(E=new te,2,_.$),_.index&&Et(E,1,_.index),_.label&&Et(E,3,_.label),_.displayName&&Et(E,4,_.displayName),_=Nt(E,re),x.call(w,A,_)}p=p.data;break t;default:p={}}}switch(c=p,l=u.stream,u.type){case"video":n.pushTexture2d(Object.assign(Object.assign({},c),{stream:l,timestamp:r}));break;case"detections":(f=c).stream=l,f.timestamp=r,n.pushDetectionList(f);break;default:throw Error("Unknown input config type: '"+u.type+"'")}}return h.i.send(n),y(d,h.D,4);case 4:n.delete(),d.g=0}})},t.onResults=function(t,e){this.listeners[e||"$"]=t},T("Solution",ze),T("OptionType",{BOOL:0,NUMBER:1,ca:2,0:"BOOL",1:"NUMBER",2:"STRING"});var qe={focalX:{type:1,graphOptionXref:{calculatorType:"Lift2DFrameAnnotationTo3DCalculator",fieldName:"normalized_focal_x"}},focalY:{type:1,graphOptionXref:{calculatorType:"Lift2DFrameAnnotationTo3DCalculator",fieldName:"normalized_focal_y"}},principalX:{type:1,graphOptionXref:{calculatorType:"Lift2DFrameAnnotationTo3DCalculator",fieldName:"normalized_principal_point_x"}},principalY:{type:1,graphOptionXref:{calculatorType:"Lift2DFrameAnnotationTo3DCalculator",fieldName:"normalized_principal_point_y"}},allowedLabels:{type:2,graphOptionXref:{calculatorName:"ConstantSidePacketCalculatorAllowedLabels",calculatorType:"ConstantSidePacketCalculator",fieldName:"string_value"}}};function Ke(t){var e=this;t=t||{},this.g=new ze({locateFile:t.locateFile,files:[{url:"objectron_solution_packed_assets_loader.js"},{simd:!1,url:"objectron_solution_wasm_bin.js"},{simd:!0,url:"objectron_solution_simd_wasm_bin.js"}],graph:{url:"objectron.binarypb"},inputs:{image:{type:"video",stream:"input_frames_gpu"}},listeners:[{wants:["lifted_objects","image_transformed"],outs:{image:"image_transformed",objectDetections:{type:"proto",stream:"lifted_objects",transform:Ye}}}],options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"object"==typeof window&&void 0!==window.navigator&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,default:!1,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},maxNumObjects:{type:1,default:5,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorMaxNumObjects",fieldName:"int_value"}},staticImageMode:{type:0,default:!0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"objectrongpusubgraph__ConstantSidePacketCalculator",fieldName:"bool_value"}},minDetectionConfidence:{type:1,default:.5,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"objectrongpusubgraph__objectdetectionoidv4subgraph__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,default:.99,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"objectrongpusubgraph__boxlandmarksubgraph__ThresholdingCalculator",fieldName:"threshold"}},modelName:{default:"Shoe",onChange:function(t){var r,n,i,o;return A(function(a){return 1==a.g?(r=t,e.g.setOptions({allowedLabels:Xe(r)},qe),n=function(t){switch(t){case"Camera":return"object_detection_3d_camera.tflite";case"Chair":return"object_detection_3d_chair.tflite";case"Cup":return"object_detection_3d_cup.tflite";default:return"object_detection_3d_sneakers.tflite"}}(r),i="object_detection_3d.tflite",y(a,We(e.g,n),2)):(o=a.h,e.g.overrideFile(i,o),a.return(!0))})}},focalLength:{default:[1,1],onChange:function(t){var r;return A(function(n){return r=t,e.h=r,e.g.setOptions({focalX:r[0],focalY:r[1]},qe),n.return(!0)})}},principalPoint:{default:[0,0],onChange:function(t){var r;return A(function(n){return r=t,e.i=r,e.g.setOptions({principalX:r[0],principalY:r[1]},qe),n.return(!0)})}},imageSize:{onChange:function(t){var r,n,i,o;return A(function(a){if(void 0===e.h||void 0===e.i)return console.error('"focalLength" and "principalPoint" must be set if setting image size'),a.return();n=[(r=t)[0]/2,r[1]/2],i=[e.h[0]/n[0],e.h[1]/n[1]],o=[e.i[0]/n[0],e.i[1]/n[1]],e.setOptions({focalLength:i,principalPoint:o}),a.g=0})}}}})}(t=Ke.prototype).close=function(){return this.g.close(),Promise.resolve()},t.onResults=function(t){this.g.onResults(t)},t.initialize=function(){var t=this;return A(function(e){return y(e,t.g.initialize(),0)})},t.reset=function(){this.g.reset()},t.send=function(t){var e=this;return A(function(r){return y(r,e.g.send(t),0)})},t.setOptions=function(t){this.g.setOptions(t)},T("Objectron",Ke),T("BOX_CONNECTIONS",[[1,2],[2,4],[4,3],[3,1],[5,6],[6,8],[8,7],[7,5],[1,5],[2,6],[3,7],[4,8]]),T("BOX_KEYPOINTS",{CENTER:0,BACK_BOTTOM_LEFT:1,FRONT_BOTTOM_LEFT:2,BACK_TOP_LEFT:3,FRONT_TOP_LEFT:4,BACK_BOTTOM_RIGHT:5,FRONT_BOTTOM_RIGHT:6,BACK_TOP_RIGHT:7,FRONT_TOP_RIGHT:8}),T("VERSION","0.4.1636596145")}).call(Li);const ji={};(function(){var t;function e(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}var r="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,r){return t==Array.prototype||t==Object.prototype||(t[e]=r.value),t};var n=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var e=0;e<t.length;++e){var r=t[e];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);function i(t,e){if(e)t:{var i=n;t=t.split(".");for(var o=0;o<t.length-1;o++){var a=t[o];if(!(a in i))break t;i=i[a]}(e=e(o=i[t=t[t.length-1]]))!=o&&null!=e&&r(i,t,{configurable:!0,writable:!0,value:e})}}function o(t){return(t={next:t})[Symbol.iterator]=function(){return this},t}function a(t){var r=typeof Symbol<"u"&&Symbol.iterator&&t[Symbol.iterator];return r?r.call(t):{next:e(t)}}function s(t){if(!(t instanceof Array)){t=a(t);for(var e,r=[];!(e=t.next()).done;)r.push(e.value);t=r}return t}i("Symbol",function(t){function e(t,e){this.g=t,r(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;e.prototype.toString=function(){return this.g};var n="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",i=0;return function t(r){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(n+(r||"")+"_"+i++,r)}}),i("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var i="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),a=0;a<i.length;a++){var s=n[i[a]];"function"==typeof s&&"function"!=typeof s.prototype[t]&&r(s.prototype,t,{configurable:!0,writable:!0,value:function(){return o(e(this))}})}return t});var u,c="function"==typeof Object.create?Object.create:function(t){function e(){}return e.prototype=t,new e};if("function"==typeof Object.setPrototypeOf)u=Object.setPrototypeOf;else{var l;t:{var f={};try{f.__proto__={a:!0},l=f.a;break t}catch{}l=!1}u=l?function(t,e){if(t.__proto__=e,t.__proto__!==e)throw new TypeError(t+" is not extensible");return t}:null}var h=u;function d(t,e){if(t.prototype=c(e.prototype),t.prototype.constructor=t,h)h(t,e);else for(var r in e)if("prototype"!=r)if(Object.defineProperties){var n=Object.getOwnPropertyDescriptor(e,r);n&&Object.defineProperty(t,r,n)}else t[r]=e[r];t.ea=e.prototype}function g(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function p(t){if(t.l)throw new TypeError("Generator is already running");t.l=!0}function m(t,e){t.j={U:e,V:!0},t.g=t.m||t.s}function y(t,e,r){return t.g=r,{value:e}}function v(t){this.g=new g,this.h=t}function b(t,e,r,n){try{var i=e.call(t.g.i,r);if(!(i instanceof Object))throw new TypeError("Iterator result "+i+" is not an object");if(!i.done)return t.g.l=!1,i;var o=i.value}catch(e){return t.g.i=null,m(t.g,e),w(t)}return t.g.i=null,n.call(t.g,o),w(t)}function w(t){for(;t.g.g;)try{var e=t.h(t.g);if(e)return t.g.l=!1,{value:e.value,done:!1}}catch(e){t.g.h=void 0,m(t.g,e)}if(t.g.l=!1,t.g.j){if(e=t.g.j,t.g.j=null,e.V)throw e.U;return{value:e.return,done:!0}}return{value:void 0,done:!0}}function x(t){this.next=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.next,e,t.g.o):(t.g.o(e),e=w(t)),e},this.throw=function(e){return p(t.g),t.g.i?e=b(t,t.g.i.throw,e,t.g.o):(m(t.g,e),e=w(t)),e},this.return=function(e){return function(t,e){p(t.g);var r=t.g.i;return r?b(t,"return"in r?r.return:function(t){return{value:t,done:!0}},e,t.g.return):(t.g.return(e),w(t))}(t,e)},this[Symbol.iterator]=function(){return this}}function A(t){return function(t){function e(e){return t.next(e)}function r(e){return t.throw(e)}return new Promise(function(n,i){!function t(o){o.done?n(o.value):Promise.resolve(o.value).then(e,r).then(t,i)}(t.next())})}(new x(new v(t)))}g.prototype.o=function(t){this.h=t},g.prototype.return=function(t){this.j={return:t},this.g=this.s},i("Promise",function(t){function e(t){this.h=0,this.i=void 0,this.g=[],this.o=!1;var e=this.j();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function r(){this.g=null}function i(t){return t instanceof e?t:new e(function(e){e(t)})}if(t)return t;r.prototype.h=function(t){if(null==this.g){this.g=[];var e=this;this.i(function(){e.l()})}this.g.push(t)};var o=n.setTimeout;r.prototype.i=function(t){o(t,0)},r.prototype.l=function(){for(;this.g&&this.g.length;){var t=this.g;this.g=[];for(var e=0;e<t.length;++e){var r=t[e];t[e]=null;try{r()}catch(t){this.j(t)}}}this.g=null},r.prototype.j=function(t){this.i(function(){throw t})},e.prototype.j=function(){function t(t){return function(n){r||(r=!0,t.call(e,n))}}var e=this,r=!1;return{resolve:t(this.C),reject:t(this.l)}},e.prototype.C=function(t){if(t===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof e)this.F(t);else{t:switch(typeof t){case"object":var r=null!=t;break t;case"function":r=!0;break t;default:r=!1}r?this.v(t):this.m(t)}},e.prototype.v=function(t){var e=void 0;try{e=t.then}catch(t){return void this.l(t)}"function"==typeof e?this.G(e,t):this.m(t)},e.prototype.l=function(t){this.s(2,t)},e.prototype.m=function(t){this.s(1,t)},e.prototype.s=function(t,e){if(0!=this.h)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.h);this.h=t,this.i=e,2===this.h&&this.D(),this.A()},e.prototype.D=function(){var t=this;o(function(){if(t.B()){var e=n.console;typeof e<"u"&&e.error(t.i)}},1)},e.prototype.B=function(){if(this.o)return!1;var t=n.CustomEvent,e=n.Event,r=n.dispatchEvent;return typeof r>"u"||("function"==typeof t?t=new t("unhandledrejection",{cancelable:!0}):"function"==typeof e?t=new e("unhandledrejection",{cancelable:!0}):(t=n.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,t),t.promise=this,t.reason=this.i,r(t))},e.prototype.A=function(){if(null!=this.g){for(var t=0;t<this.g.length;++t)s.h(this.g[t]);this.g=null}};var s=new r;return e.prototype.F=function(t){var e=this.j();t.J(e.resolve,e.reject)},e.prototype.G=function(t,e){var r=this.j();try{t.call(e,r.resolve,r.reject)}catch(t){r.reject(t)}},e.prototype.then=function(t,r){function n(t,e){return"function"==typeof t?function(e){try{i(t(e))}catch(t){o(t)}}:e}var i,o,a=new e(function(t,e){i=t,o=e});return this.J(n(t,i),n(r,o)),a},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype.J=function(t,e){function r(){switch(n.h){case 1:t(n.i);break;case 2:e(n.i);break;default:throw Error("Unexpected state: "+n.h)}}var n=this;null==this.g?s.h(r):this.g.push(r),this.o=!0},e.resolve=i,e.reject=function(t){return new e(function(e,r){r(t)})},e.race=function(t){return new e(function(e,r){for(var n=a(t),o=n.next();!o.done;o=n.next())i(o.value).J(e,r)})},e.all=function(t){var r=a(t),n=r.next();return n.done?i([]):new e(function(t,e){function o(e){return function(r){a[e]=r,0==--s&&t(a)}}var a=[],s=0;do{a.push(void 0),s++,i(n.value).J(o(a.length-1),e),n=r.next()}while(!n.done)})},e});var _="function"==typeof Object.assign?Object.assign:function(t,e){for(var r=1;r<arguments.length;r++){var n=arguments[r];if(n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};i("Object.assign",function(t){return t||_}),i("Object.is",function(t){return t||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}}),i("Array.prototype.includes",function(t){return t||function(t,e){var r=this;r instanceof String&&(r=String(r));var n=r.length;for(0>(e=e||0)&&(e=Math.max(e+n,0));e<n;e++){var i=r[e];if(i===t||Object.is(i,t))return!0}return!1}}),i("String.prototype.includes",function(t){return t||function(t,e){if(null==this)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(t instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return-1!==this.indexOf(t,e||0)}}),i("Array.prototype.keys",function(t){return t||function(){return function(t,e){t instanceof String&&(t+="");var r=0,n=!1,i={next:function(){if(!n&&r<t.length){var i=r++;return{value:e(i,t[i]),done:!1}}return n=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,function(t){return t})}});var E=this||self;function T(t,e){t=t.split(".");var r,n=E;t[0]in n||typeof n.execScript>"u"||n.execScript("var "+t[0]);for(;t.length&&(r=t.shift());)t.length||void 0===e?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=e}function k(t){!function(t){E.setTimeout(function(){throw t},0)}(t)}function S(t,e){k(Error("Invalid wire type: "+t+" (at position "+e+")"))}function F(){k(Error("Failed to read varint, encoding is invalid."))}function O(t,e){return e=String.fromCharCode.apply(null,e),null==t?e:t+e}var R,I,P=typeof TextDecoder<"u",j=typeof TextEncoder<"u";function C(t){if(j)t=(I||(I=new TextEncoder)).encode(t);else{var e=void 0;e=void 0!==e&&e;for(var r=0,n=new Uint8Array(3*t.length),i=0;i<t.length;i++){var o=t.charCodeAt(i);if(128>o)n[r++]=o;else{if(2048>o)n[r++]=o>>6|192;else{if(55296<=o&&57343>=o){if(56319>=o&&i<t.length){var a=t.charCodeAt(++i);if(56320<=a&&57343>=a){o=1024*(o-55296)+a-56320+65536,n[r++]=o>>18|240,n[r++]=o>>12&63|128,n[r++]=o>>6&63|128,n[r++]=63&o|128;continue}i--}if(e)throw Error("Found an unpaired surrogate");o=65533}n[r++]=o>>12|224,n[r++]=o>>6&63|128}n[r++]=63&o|128}}t=n.subarray(0,r)}return t}var M={},L=null;function B(t){var e;void 0===e&&(e=0),N(),e=M[e];for(var r=Array(Math.floor(t.length/3)),n=e[64]||"",i=0,o=0;i<t.length-2;i+=3){var a=t[i],s=t[i+1],u=t[i+2],c=e[a>>2];a=e[(3&a)<<4|s>>4],s=e[(15&s)<<2|u>>6],u=e[63&u],r[o++]=c+a+s+u}switch(c=0,u=n,t.length-i){case 2:u=e[(15&(c=t[i+1]))<<2]||n;case 1:t=t[i],r[o]=e[t>>2]+e[(3&t)<<4|c>>4]+u+n}return r.join("")}function U(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){var r=t.charAt(n++),i=L[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}N();for(var n=0;;){var i=r(-1),o=r(0),a=r(64),s=r(64);if(64===s&&-1===i)break;e(i<<2|o>>4),64!=a&&(e(o<<4&240|a>>2),64!=s&&e(a<<6&192|s))}}(t,function(t){n[i++]=t}),n.subarray(0,i)}function N(){if(!L){L={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;5>r;r++){var n=t.concat(e[r].split(""));M[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===L[o]&&(L[o]=i)}}}}var D,z="function"==typeof Uint8Array;function G(t){if(this.g=t,null!==t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}G.prototype.toJSON=function(){if(null==this.g)var t="";else t=this.g,t=this.g=null==t||"string"==typeof t?t:z&&t instanceof Uint8Array?B(t):null;return t};var W="function"==typeof Uint8Array.prototype.slice;function H(t,e,r){return e===r?D||(D=new Uint8Array(0)):W?t.slice(e,r):new Uint8Array(t.subarray(e,r))}var V=0;function $(t,e){e=void 0!==(e=void 0===e?{}:e).u&&e.u,this.h=null,this.g=this.i=this.l=0,this.j=!1,this.u=e,t&&Y(this,t)}function Y(t,e){t.h=function(t){if(t.constructor===Uint8Array)return t;if(t.constructor===ArrayBuffer)return new Uint8Array(t);if(t.constructor===Array)return new Uint8Array(t);if(t.constructor===String)return U(t);if(t.constructor===G){if(null==t.g)var e=D||(D=new Uint8Array(0));else{e=Uint8Array;var r=t.g;r=null==r||z&&null!=r&&r instanceof Uint8Array?r:"string"==typeof r?U(r):null,e=new e(t=t.g=r)}return e}if(t instanceof Uint8Array)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}(e),t.l=0,t.i=t.h.length,t.g=t.l}function X(t){t.g>t.i&&(t.j=!0,k(Error("Tried to read past the end of the data "+t.g+" > "+t.i)))}function q(t){var e=t.h,r=e[t.g],n=127&r;return 128>r?(t.g+=1,X(t),n):(n|=(127&(r=e[t.g+1]))<<7,128>r?(t.g+=2,X(t),n):(n|=(127&(r=e[t.g+2]))<<14,128>r?(t.g+=3,X(t),n):(n|=(127&(r=e[t.g+3]))<<21,128>r?(t.g+=4,X(t),n):(n|=(15&(r=e[t.g+4]))<<28,128>r?(t.g+=5,X(t),n>>>0):(t.g+=5,128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]&&128<=e[t.g++]?(t.j=!0,F(),n):(X(t),n))))))}$.prototype.reset=function(){this.g=this.l};var K=[];function Q(){this.g=new Uint8Array(64),this.h=0}function J(t,e){if(!(t.h+1<t.g.length)){var r=t.g;t.g=new Uint8Array(Math.ceil(1+2*t.g.length)),t.g.set(r)}t.g[t.h++]=e}function Z(t,e){for(;127<e;)J(t,127&e|128),e>>>=7;J(t,e)}function tt(t){var e={},r=void 0!==e.N&&e.N;this.m={u:void 0!==e.u&&e.u},this.N=r,e=this.m,K.length?(r=K.pop(),e&&(r.u=e.u),t&&Y(r,t),t=r):t=new $(t,e),this.g=t,this.l=this.g.g,this.h=this.i=-1,this.j=!1}function et(t){var e=t.g;if((e=e.g==e.i)||(e=t.j)||(e=(e=t.g).j||0>e.g||e.g>e.i),e)return!1;t.l=t.g.g;var r=q(t.g);return e=r>>>3,0<=(r&=7)&&5>=r?(t.i=e,t.h=r,!0):(t.j=!0,S(r,t.l),!1)}function rt(t){switch(t.h){case 0:if(0!=t.h)rt(t);else t:{for(var e=(t=t.g).g,r=0;10>r;r++){if(!(128&t.h[e])){t.g=e+1,X(t);break t}e++}t.j=!0,F()}break;case 1:(t=t.g).g+=8,X(t);break;case 2:2!=t.h?rt(t):(e=q(t.g),(t=t.g).g+=e,X(t));break;case 5:(t=t.g).g+=4,X(t);break;case 3:for(e=t.i;;){if(!et(t)){t.j=!0,k(Error("Unmatched start-group tag: stream EOF"));break}if(4==t.h){t.i!=e&&(t.j=!0,k(Error("Unmatched end-group tag")));break}rt(t)}break;default:t.j=!0,S(t.h,t.l)}}function nt(t,e,r){t.N||(t=H(t.g.h,r,t.g.g),(r=e.m)?r.push(t):e.m=[t])}Q.prototype.length=function(){return this.h},Q.prototype.end=function(){var t=this.g,e=this.h;return this.h=0,H(t,0,e)},tt.prototype.reset=function(){this.g.reset(),this.h=this.i=-1};var it=[];function ot(){this.h=[],this.i=0,this.g=new Q}function at(t,e){0!==e.length&&(t.h.push(e),t.i+=e.length)}function st(t,e,r){Z(t.g,8*e+2),Z(t.g,r.length),at(t,t.g.end()),at(t,r)}var ut,ct="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol(void 0):void 0;function lt(t,e){Object.isFrozen(t)||(ct?t[ct]|=e:void 0!==t.g?t.g|=e:Object.defineProperties(t,{g:{value:e,configurable:!0,writable:!0,enumerable:!1}}))}function ft(t){return t?(ct?t[ct]:t.g)??0:0}function ht(t){return Array.isArray(t)&&lt(t,1),t}function dt(t){if(!Array.isArray(t))throw Error("cannot mark non-array as immutable");lt(t,2)}function gt(t){return null!==t&&"object"==typeof t&&t.constructor===Object}function pt(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"object":return z&&null!=t&&t instanceof Uint8Array?B(t):t;default:return t}}function mt(t,e){if(null!=t)return Array.isArray(t)||gt(t)?yt(t,e):e(t)}function yt(t,e){if(Array.isArray(t)){for(var r=Array(t.length),n=0;n<t.length;n++)r[n]=mt(t[n],e);return 1&ft(t)&&ht(r),r}for(n in r={},t)r[n]=mt(t[n],e);return r}function vt(t,e,r){var n=ut;if(ut=null,t||(t=n),n=this.constructor.ca,t||(t=n?[n]:[]),this.j=(n?0:-1)-(this.constructor.aa||0),this.i=null,this.g=t,t=(n=this.g.length)-1,n&&gt(n=this.g[t])?(this.l=t-this.j,this.h=n):void 0!==e&&-1<e?(this.l=Math.max(e,t+1-this.j),this.h=null):this.l=Number.MAX_VALUE,r)for(e=0;e<r.length;e++)(t=r[e])<this.l?(t+=this.j,(n=this.g[t])?ht(n):this.g[t]=xt):(At(this),(n=this.h[t])?ht(n):this.h[t]=xt)}var bt,wt,xt=Object.freeze(ht([]));function At(t){var e=t.l+t.j;t.g[e]||(t.h=t.g[e]={})}function _t(t,e,r){return-1===e?null:void 0!==r&&r||e>=t.l?t.h?t.h[e]:void 0:t.g[e+t.j]}function Et(t,e,r){r=void 0===r||r;var n=void 0!==n&&n,i=_t(t,e,n);return null==i&&(i=xt),i===xt?kt(t,e,i=ht([]),n):r&&Array.isArray(i)&&2&ft(i)&&kt(t,e,i=i.slice(),n),i}function Tt(t,e,r){return(t=null==(t=_t(t,e))?t:+t)??(void 0===r?0:r)}function kt(t,e,r,n){void 0!==n&&n||e>=t.l?(At(t),t.h[e]=r):t.g[e+t.j]=r}function St(t,e,r){t.i||(t.i={});var n=t.i[r];if(!n){var i=Et(t,r,!1);n=[];for(var o=!!Array.isArray(i)&&!!(2&ft(i)),a=0;a<i.length;a++)n[a]=new e(i[a]),o&&dt(n[a].g);o&&(dt(n),Object.freeze(n)),t.i[r]=n}return n}function Ft(t,e,r,n,i){var o=St(t,n,e);r=r||new n,t=Et(t,e),null!=i?(o.splice(i,0,r),t.splice(i,0,Ot(r))):(o.push(r),t.push(Ot(r)))}function Ot(t){if(t.i)for(var e in t.i){var r=t.i[e];if(Array.isArray(r))for(var n=0;n<r.length;n++)r[n]&&Ot(r[n]);else r&&Ot(r)}return t.g}function Rt(t,e){return(t=_t(t,e))??0}function It(t,e){return(t=_t(t,e))??""}function Pt(t,e){if(t=t.m){at(e,e.g.end());for(var r=0;r<t.length;r++)at(e,t[r])}}function jt(t){var e=t[0];switch(t.length){case 2:var r=t[1];return function(t,n,i){return e(t,n,i,r)};case 3:var n=t[1],i=t[2];return function(t,r,o){return e(t,r,o,n,i)};case 4:var o=t[1],a=t[2],s=t[3];return function(t,r,n){return e(t,r,n,o,a,s)};default:throw Error("unsupported number of parameters, expected [2-4], got "+t.length)}}function Ct(t,e,r){for(;et(e)&&4!=e.h;){var n=e.i,i=r[n];if(i){if(Array.isArray(i)&&(i=r[n]=jt(i)),!i(e,t,n)){i=t;var o=(n=e).l;rt(n),nt(n,i,o)}}else i=t,o=(n=e).l,rt(n),nt(n,i,o)}return t}function Mt(t,e){var r=new ot;if(e(t,r),0===(t=r.i+r.g.length()))r=new Uint8Array(0);else{t=new Uint8Array(t);for(var n=r.h,i=n.length,o=e=0;o<i;o++){var a=n[o];0!==a.length&&(t.set(a,e),e+=a.length)}0!==(i=(n=r.g).h)&&(t.set(n.g.subarray(0,i),e),n.h=0),r.h=[t],r=t}return r}function Lt(t,e,r){if(it.length){var n=it.pop();t&&(Y(n.g,t),n.i=-1,n.h=-1),t=n}else t=new tt(t);try{return r(new e,t)}finally{(e=t.g).h=null,e.l=0,e.i=0,e.g=0,e.j=!1,e.u=!1,t.i=-1,t.h=-1,t.j=!1,100>it.length&&it.push(t)}}function Bt(t,e,r){if(null!=(e=_t(e,r))){Z(t.g,8*r+5),t=t.g;var n=e;0===(n=(r=0>n?1:0)?-n:n)?0<1/n?V=0:V=2147483648:isNaN(n)?V=2147483647:34028234663852886e22<n?V=(r<<31|2139095040)>>>0:11754943508222875e-54>n?(n=Math.round(n/Math.pow(2,-149)),V=(r<<31|n)>>>0):(e=Math.floor(Math.log(n)/Math.LN2),n*=Math.pow(2,-e),16777216<=(n=Math.round(8388608*n))&&++e,V=(r<<31|e+127<<23|8388607&n)>>>0),J(t,(r=V)>>>0&255),J(t,r>>>8&255),J(t,r>>>16&255),J(t,r>>>24&255)}}function Ut(t,e,r){if(5!==t.h)return!1;var n=(t=t.g).h[t.g],i=t.h[t.g+1],o=t.h[t.g+2],a=t.h[t.g+3];return t.g+=4,X(t),t=2*((i=(n|i<<8|o<<16|a<<24)>>>0)>>31)+1,n=i>>>23&255,i&=8388607,kt(e,r,255==n?i?NaN:1/0*t:0==n?t*Math.pow(2,-149)*i:t*Math.pow(2,n-150)*(i+Math.pow(2,23))),!0}function Nt(t,e,r){if(0!==t.h)return!1;for(var n=t.g,i=128,o=0,a=t=0;4>a&&128<=i;a++)o|=(127&(i=n.h[n.g++]))<<7*a;if(128<=i&&(o|=(127&(i=n.h[n.g++]))<<28,t|=(127&i)>>4),128<=i)for(a=0;5>a&&128<=i;a++)t|=(127&(i=n.h[n.g++]))<<7*a+3;return 128>i?(n=o>>>0,(t=2147483648&(i=t>>>0))&&(i=~i>>>0,0==(n=1+~n>>>0)&&(i=i+1>>>0)),n=4294967296*i+(n>>>0),t=t?-n:n):(n.j=!0,F(),t=void 0),kt(e,r,t),!0}function Dt(t,e,r){return 0===t.h&&(kt(e,r,q(t.g)),!0)}function zt(t,e,r){if(2!==t.h)return!1;var n,i=q(t.g),o=(t=t.g).g;if(t.g+=i,X(t),t=t.h,P)(n=R)||(n=R=new TextDecoder("utf-8",{fatal:!1})),n=n.decode(t.subarray(o,o+i));else{i=o+i;for(var a,s,u,c=[],l=null;o<i;)128>(a=t[o++])?c.push(a):224>a?o>=i?c.push(65533):(s=t[o++],194>a||128!=(192&s)?(o--,c.push(65533)):c.push((31&a)<<6|63&s)):240>a?o>=i-1?c.push(65533):128!=(192&(s=t[o++]))||224===a&&160>s||237===a&&160<=s||128!=(192&(n=t[o++]))?(o--,c.push(65533)):c.push((15&a)<<12|(63&s)<<6|63&n):244>=a?o>=i-2?c.push(65533):128!=(192&(s=t[o++]))||s-144+(a<<28)>>30||128!=(192&(n=t[o++]))||128!=(192&(u=t[o++]))?(o--,c.push(65533)):(a=(7&a)<<18|(63&s)<<12|(63&n)<<6|63&u,a-=65536,c.push(55296+(a>>10&1023),56320+(1023&a))):c.push(65533),8192<=c.length&&(l=O(l,c),c.length=0);n=O(l,c)}return kt(e,r,n),!0}function Gt(t,e,r,n,i){if(2!==t.h)return!1;var o=new n,a=t.g.i,s=q(t.g),u=t.g.g+s;if(t.g.i=u,i(o,t),0!==(i=u-t.g.g))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 t.g.g=u,t.g.i=a,Ft(e,r,o,n,void 0),!0}function Wt(t){vt.call(this,t)}function Ht(t,e){var r=_t(t,1);if(null!=r&&null!=r){Z(e.g,8);var n=e.g;if(0<=r)Z(n,r);else{for(var i=0;9>i;i++)J(n,127&r|128),r>>=7;J(n,1)}}Bt(e,t,2),null!=(n=_t(t,3))&&st(e,3,C(n)),null!=(n=_t(t,4))&&st(e,4,C(n)),Pt(t,e)}function Vt(t,e){return Ct(t,e,bt||(bt={1:Dt,2:Ut,3:zt,4:zt}))}function $t(t){vt.call(this,t,-1,Kt)}function Yt(t,e){return Ct(t,e,wt||(wt={1:[Gt,Wt,Vt]}))}vt.prototype.toJSON=function(){return yt(Ot(this),pt)},vt.prototype.toString=function(){return Ot(this).toString()},d(Wt,vt),d($t,vt),$t.prototype.addClassification=function(t,e){return Ft(this,1,t,Wt,e),this};var Xt,qt,Kt=[1];function Qt(t){vt.call(this,t)}function Jt(t,e){Bt(e,t,1),Bt(e,t,2),Bt(e,t,3),Bt(e,t,4),Bt(e,t,5),Pt(t,e)}function Zt(t,e){return Ct(t,e,Xt||(Xt={1:Ut,2:Ut,3:Ut,4:Ut,5:Ut}))}function te(t){vt.call(this,t,-1,ne)}function ee(t,e){return Ct(t,e,qt||(qt={1:[Gt,Qt,Zt]}))}d(Qt,vt),d(te,vt);var re,ne=[1];function ie(t){vt.call(this,t)}function oe(t,e){Bt(e,t,1),Bt(e,t,2),Bt(e,t,3),Bt(e,t,4),Bt(e,t,5);var r=_t(t,6);if(null!=r&&null!=r){Z(e.g,48);var n=e.g,i=r;r=0>i;var o=(i=Math.abs(i))>>>0;for(i=Math.floor((i-o)/4294967296),i>>>=0,r&&(i=~i>>>0,4294967295<(o=(~o>>>0)+1)&&(o=0,4294967295<++i&&(i=0))),r=V=o,o=i;0<o||127<r;)J(n,127&r|128),r=(r>>>7|o<<25)>>>0,o>>>=7;J(n,r)}Pt(t,e)}function ae(t,e){return Ct(t,e,re||(re={1:Ut,2:Ut,3:Ut,4:Ut,5:Ut,6:Nt}))}function se(t,e,r){if(r=t.createShader(0===r?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(r,e),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw Error("Could not compile WebGL shader.\n\n"+t.getShaderInfoLog(r));return r}function ue(t){return St(t,Wt,1).map(function(t){return{index:Rt(t,1),X:Tt(t,2),label:null!=_t(t,3)?It(t,3):void 0,displayName:null!=_t(t,4)?It(t,4):void 0}})}function ce(t){return{x:Tt(t,1),y:Tt(t,2),z:Tt(t,3),visibility:null!=_t(t,4)?Tt(t,4):void 0}}function le(t){return St(Lt(t,te,ee),Qt,1).map(ce)}function fe(t,e){this.h=t,this.g=e,this.l=0}function he(t,e,r){return function(t,e){var r=t.g;if(void 0===t.m){var n=se(r,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",0),i=se(r,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }",1),o=r.createProgram();if(r.attachShader(o,n),r.attachShader(o,i),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS))throw Error("Could not compile WebGL program.\n\n"+r.getProgramInfoLog(o));n=t.m=o,r.useProgram(n),i=r.getUniformLocation(n,"sampler0"),t.j={I:r.getAttribLocation(n,"aVertex"),H:r.getAttribLocation(n,"aTex"),da:i},t.s=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.enableVertexAttribArray(t.j.I),r.vertexAttribPointer(t.j.I,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),t.o=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.enableVertexAttribArray(t.j.H),r.vertexAttribPointer(t.j.H,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.uniform1i(i,0)}n=t.j,r.useProgram(t.m),r.canvas.width=e.width,r.canvas.height=e.height,r.viewport(0,0,e.width,e.height),r.activeTexture(r.TEXTURE0),t.h.bindTexture2d(e.glName),r.enableVertexAttribArray(n.I),r.bindBuffer(r.ARRAY_BUFFER,t.s),r.vertexAttribPointer(n.I,2,r.FLOAT,!1,0,0),r.enableVertexAttribArray(n.H),r.bindBuffer(r.ARRAY_BUFFER,t.o),r.vertexAttribPointer(n.H,2,r.FLOAT,!1,0,0),r.bindFramebuffer(r.DRAW_FRAMEBUFFER?r.DRAW_FRAMEBUFFER:r.FRAMEBUFFER,null),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.colorMask(!0,!0,!0,!0),r.drawArrays(r.TRIANGLE_FAN,0,4),r.disableVertexAttribArray(n.I),r.disableVertexAttribArray(n.H),r.bindBuffer(r.ARRAY_BUFFER,null),t.h.bindTexture2d(0)}(t,e),"function"==typeof t.g.canvas.transferToImageBitmap?Promise.resolve(t.g.canvas.transferToImageBitmap()):r?Promise.resolve(t.g.canvas):"function"==typeof createImageBitmap?createImageBitmap(t.g.canvas):(void 0===t.i&&(t.i=document.createElement("canvas")),new Promise(function(e){t.i.height=t.g.canvas.height,t.i.width=t.g.canvas.width,t.i.getContext("2d",{}).drawImage(t.g.canvas,0,0,t.g.canvas.width,t.g.canvas.height),e(t.i)}))}function de(t){this.g=t}d(ie,vt);var ge=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function pe(t,e){return e+t}function me(t,e){window[t]=e}function ye(t){if(this.g=t,this.listeners={},this.j={},this.F={},this.m={},this.s={},this.G=this.o=this.R=!0,this.C=Promise.resolve(),this.P="",this.B={},this.locateFile=t&&t.locateFile||pe,"object"==typeof window)var e=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(!(typeof location<"u"))throw Error("solutions can only be loaded on a web page or in a web worker");e=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.S=e,t.options)for(var r=(e=a(Object.keys(t.options))).next();!r.done;r=e.next()){r=r.value;var n=t.options[r].default;void 0!==n&&(this.j[r]="function"==typeof n?n():n)}}function ve(t){var e,r,n,i,o,a,u,c,l,f,h;return A(function(d){switch(d.g){case 1:return t.R?(e=void 0===t.g.files?[]:"function"==typeof t.g.files?t.g.files(t.j):t.g.files,y(d,A(function(t){switch(t.g){case 1:return t.m=2,y(t,WebAssembly.instantiate(ge),4);case 4:t.g=3,t.m=0;break;case 2:return t.m=0,t.j=null,t.return(!1);case 3:return t.return(!0)}}),2)):d.return();case 2:if(r=d.h,"object"==typeof window)return me("createMediapipeSolutionsWasm",{locateFile:t.locateFile}),me("createMediapipeSolutionsPackedAssets",{locateFile:t.locateFile}),a=e.filter(function(t){return void 0!==t.data}),u=e.filter(function(t){return void 0===t.data}),c=Promise.all(a.map(function(e){var r=be(t,e.url);if(void 0!==e.path){var n=e.path;r=r.then(function(e){return t.overrideFile(n,e),Promise.resolve(e)})}return r})),l=Promise.all(u.map(function(e){return void 0===e.simd||e.simd&&r||!e.simd&&!r?function(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(t){e.addEventListener("load",function(){t()},!1),e.addEventListener("error",function(){t()},!1),document.body.appendChild(e)})}(t.locateFile(e.url,t.S)):Promise.resolve()})).then(function(){var e,r,n;return A(function(i){if(1==i.g)return e=window.createMediapipeSolutionsWasm,r=window.createMediapipeSolutionsPackedAssets,n=t,y(i,e(r),2);n.h=i.h,i.g=0})}),f=A(function(e){return t.g.graph&&t.g.graph.url?e=y(e,be(t,t.g.graph.url),0):(e.g=0,e=void 0),e}),y(d,Promise.all([l,c,f]),7);if("function"!=typeof importScripts)throw Error("solutions can only be loaded on a web page or in a web worker");return n=e.filter(function(t){return void 0===t.simd||t.simd&&r||!t.simd&&!r}).map(function(e){return t.locateFile(e.url,t.S)}),importScripts.apply(null,s(n)),i=t,y(d,createMediapipeSolutionsWasm(Module),6);case 6:i.h=d.h,t.l=new OffscreenCanvas(1,1),t.h.canvas=t.l,o=t.h.GL.createContext(t.l,{antialias:!1,alpha:!1,ba:typeof WebGL2RenderingContext<"u"?2:1}),t.h.GL.makeContextCurrent(o),d.g=4;break;case 7:if(t.l=document.createElement("canvas"),!(h=t.l.getContext("webgl2",{}))&&!(h=t.l.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),d.return();t.D=h,t.h.canvas=t.l,t.h.createContext(t.l,!0,!0,{});case 4:t.i=new t.h.SolutionWasm,t.R=!1,d.g=0}})}function be(t,e){var r,n;return A(function(i){return e in t.F?i.return(t.F[e]):(r=t.locateFile(e,""),n=fetch(r).then(function(t){return t.arrayBuffer()}),t.F[e]=n,i.return(n))})}function we(t,e,r){var n,i,o,s,u,c,l,f,h,d,g,p,m,v;return A(function(b){switch(b.g){case 1:if(!r)return b.return(e);for(n={},i=0,o=a(Object.keys(r)),s=o.next();!s.done;s=o.next())u=s.value,"string"!=typeof(c=r[u])&&"texture"===c.type&&void 0!==e[c.stream]&&++i;1<i&&(t.G=!1),l=a(Object.keys(r)),s=l.next();case 2:if(s.done){b.g=4;break}if(f=s.value,"string"==typeof(h=r[f]))return m=n,v=f,y(b,function(t,e,r){var n;return A(function(i){return"number"==typeof r||r instanceof Uint8Array||r instanceof t.h.Uint8BlobList?i.return(r):r instanceof t.h.Texture2dDataOut?((n=t.s[e])||(n=new fe(t.h,t.D),t.s[e]=n),i.return(he(n,r,t.G))):i.return(void 0)})}(t,f,e[h]),14);if(d=e[h.stream],"detection_list"===h.type){if(d){for(var w=d.getRectList(),x=d.getLandmarksList(),_=d.getClassificationsList(),E=[],T=0;T<w.size();++T){var k=Lt(w.get(T),ie,ae);k={T:{Y:Tt(k,1),Z:Tt(k,2),height:Tt(k,3),width:Tt(k,4),rotation:Tt(k,5,0),W:Rt(k,6)},O:le(x.get(T)),M:ue(Lt(_.get(T),$t,Yt))},E.push(k)}w=E}else w=[];n[f]=w,b.g=7;break}if("proto_list"===h.type){if(d){for(w=Array(d.size()),x=0;x<d.size();x++)w[x]=d.get(x);d.delete()}else w=[];n[f]=w,b.g=7;break}if(void 0===d){b.g=3;break}if("float_list"===h.type){n[f]=d,b.g=7;break}if("proto"===h.type){n[f]=d,b.g=7;break}if("texture"!==h.type)throw Error("Unknown output config type: '"+h.type+"'");return(g=t.s[f])||(g=new fe(t.h,t.D),t.s[f]=g),y(b,he(g,d,t.G),13);case 13:p=b.h,n[f]=p;case 7:h.transform&&n[f]&&(n[f]=h.transform(n[f])),b.g=3;break;case 14:m[v]=b.h;case 3:s=l.next(),b.g=2;break;case 4:return b.return(n)}})}function xe(t,e){for(var r=e.name||"$",n=[].concat(s(e.wants)),i=new t.h.StringList,o=a(e.wants),u=o.next();!u.done;u=o.next())i.push_back(u.value);o=t.h.PacketListener.implement({onResults:function(i){for(var o={},a=0;a<e.wants.length;++a)o[n[a]]=i.get(a);var s=t.listeners[r];s&&(t.C=we(t,o,e.outs).then(function(r){r=s(r);for(var i=0;i<e.wants.length;++i){var a=o[n[i]];"object"==typeof a&&a.hasOwnProperty&&a.hasOwnProperty("delete")&&a.delete()}r&&(t.C=r)}))}}),t.i.attachMultiListener(i,o),i.delete()}function Ae(t){switch(void 0===t&&(t=0),t){case 1:return"pose_landmark_full.tflite";case 2:return"pose_landmark_heavy.tflite";default:return"pose_landmark_lite.tflite"}}function _e(t){var e=this;t=t||{},this.g=new ye({locateFile:t.locateFile,files:function(t){return[{url:"pose_solution_packed_assets_loader.js"},{simd:!1,url:"pose_solution_wasm_bin.js"},{simd:!0,url:"pose_solution_simd_wasm_bin.js"},{data:!0,url:Ae(t.modelComplexity)}]},graph:{url:"pose_web.binarypb"},listeners:[{wants:["pose_landmarks","world_landmarks","segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"},poseLandmarks:{type:"proto",stream:"pose_landmarks",transform:le},poseWorldLandmarks:{type:"proto",stream:"world_landmarks",transform:le},segmentationMask:{type:"texture",stream:"segmentation_mask"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelComplexity:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelComplexity",fieldName:"int_value"},onChange:function(t){var r,n,i;return A(function(o){return 1==o.g?(r=Ae(t),n="third_party/mediapipe/modules/pose_landmark/"+r,y(o,be(e.g,r),2)):(i=o.h,e.g.overrideFile(n,i),o.return(!0))})}},smoothLandmarks:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorSmoothLandmarks",fieldName:"bool_value"}},enableSegmentation:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorEnableSegmentation",fieldName:"bool_value"}},smoothSegmentation:{type:0,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorSmoothSegmentation",fieldName:"bool_value"}},minDetectionConfidence:{type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"poselandmarkgpu__posedetectiongpu__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}},minTrackingConfidence:{type:1,graphOptionXref:{calculatorType:"ThresholdingCalculator",calculatorName:"poselandmarkgpu__poselandmarkbyroigpu__tensorstoposelandmarksandsegmentation__ThresholdingCalculator",fieldName:"threshold"}}}})}(t=ye.prototype).close=function(){return this.i&&this.i.delete(),Promise.resolve()},t.reset=function(){var t=this;return A(function(e){t.i&&(t.i.reset(),t.m={},t.s={}),e.g=0})},t.setOptions=function(t,e){var r=this;if(e=e||this.g.options){for(var n=[],i=[],o={},s=a(Object.keys(t)),u=s.next();!u.done;o={K:o.K,L:o.L},u=s.next()){var c=u.value;c in this.j&&this.j[c]===t[c]||(this.j[c]=t[c],void 0!==(u=e[c])&&(u.onChange&&(o.K=u.onChange,o.L=t[c],n.push(function(t){return function(){return A(function(e){if(1==e.g)return y(e,t.K(t.L),2);!0===e.h&&(r.o=!0),e.g=0})}}(o))),u.graphOptionXref&&(c={valueNumber:1===u.type?t[c]:0,valueBoolean:0===u.type&&t[c],valueString:2===u.type?t[c]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),c),i.push(u))))}(0!==n.length||0!==i.length)&&(this.o=!0,this.A=(void 0===this.A?[]:this.A).concat(i),this.v=(void 0===this.v?[]:this.v).concat(n))}},t.initialize=function(){var t=this;return A(function(e){return 1==e.g?y(e,ve(t),2):3!=e.g?y(e,function(t){var e,r,n,i,o,s,u,c;return A(function(l){if(1==l.g)return t.g.graph&&t.g.graph.url&&t.P===t.g.graph.url?l.return():(t.o=!0,t.g.graph&&t.g.graph.url?(t.P=t.g.graph.url,y(l,be(t,t.g.graph.url),3)):void(l.g=2));for(2!=l.g&&(e=l.h,t.i.loadGraph(e)),r=a(Object.keys(t.B)),n=r.next();!n.done;n=r.next())i=n.value,t.i.overrideFile(i,t.B[i]);if(t.B={},t.g.listeners)for(o=a(t.g.listeners),s=o.next();!s.done;s=o.next())u=s.value,xe(t,u);c=t.j,t.j={},t.setOptions(c),l.g=0})}(t),3):y(e,function(t){var e,r,n,i,o,s;return A(function(u){switch(u.g){case 1:if(!t.o)return u.return();if(!t.v){u.g=2;break}e=a(t.v),r=e.next();case 3:if(r.done){u.g=5;break}return y(u,(0,r.value)(),4);case 4:r=e.next(),u.g=3;break;case 5:t.v=void 0;case 2:if(t.A){for(n=new t.h.GraphOptionChangeRequestList,i=a(t.A),o=i.next();!o.done;o=i.next())s=o.value,n.push_back(s);t.i.changeOptions(n),n.delete(),t.A=void 0}t.o=!1,u.g=0}})}(t),0)})},t.overrideFile=function(t,e){this.i?this.i.overrideFile(t,e):this.B[t]=e},t.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},t.send=function(t,e){var r,n,i,o,s,u,c,l,f,h=this;return A(function(d){switch(d.g){case 1:return h.g.inputs?(r=1e3*(e??performance.now()),y(d,h.C,2)):d.return();case 2:return y(d,h.initialize(),3);case 3:for(n=new h.h.PacketDataList,i=a(Object.keys(t)),o=i.next();!o.done;o=i.next())if(s=o.value,u=h.g.inputs[s]){t:{var g=t[s];switch(u.type){case"video":var p=h.m[u.stream];if(p||(p=new fe(h.h,h.D),h.m[u.stream]=p),0===p.l&&(p.l=p.h.createTexture()),typeof HTMLVideoElement<"u"&&g instanceof HTMLVideoElement)var m=g.videoWidth,v=g.videoHeight;else typeof HTMLImageElement<"u"&&g instanceof HTMLImageElement?(m=g.naturalWidth,v=g.naturalHeight):(m=g.width,v=g.height);v={glName:p.l,width:m,height:v},(m=p.g).canvas.width=v.width,m.canvas.height=v.height,m.activeTexture(m.TEXTURE0),p.h.bindTexture2d(p.l),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,g),p.h.bindTexture2d(0),p=v;break t;case"detections":for((p=h.m[u.stream])||(p=new de(h.h),h.m[u.stream]=p),p.data||(p.data=new p.g.DetectionListData),p.data.reset(g.length),v=0;v<g.length;++v){m=g[v];var b=p.data,w=b.setBoundingBox,x=v,A=m.T,_=new ie;if(kt(_,1,A.Y),kt(_,2,A.Z),kt(_,3,A.height),kt(_,4,A.width),kt(_,5,A.rotation),kt(_,6,A.W),A=Mt(_,oe),w.call(b,x,A),m.O)for(b=0;b<m.O.length;++b){var E=!!(_=m.O[b]).visibility;x=(w=p.data).addNormalizedLandmark,A=v,_=Object.assign(Object.assign({},_),{visibility:E?_.visibility:0}),kt(E=new Qt,1,_.x),kt(E,2,_.y),kt(E,3,_.z),_.visibility&&kt(E,4,_.visibility),_=Mt(E,Jt),x.call(w,A,_)}if(m.M)for(b=0;b<m.M.length;++b)x=(w=p.data).addClassification,A=v,_=m.M[b],kt(E=new Wt,2,_.X),_.index&&kt(E,1,_.index),_.label&&kt(E,3,_.label),_.displayName&&kt(E,4,_.displayName),_=Mt(E,Ht),x.call(w,A,_)}p=p.data;break t;default:p={}}}switch(c=p,l=u.stream,u.type){case"video":n.pushTexture2d(Object.assign(Object.assign({},c),{stream:l,timestamp:r}));break;case"detections":(f=c).stream=l,f.timestamp=r,n.pushDetectionList(f);break;default:throw Error("Unknown input config type: '"+u.type+"'")}}return h.i.send(n),y(d,h.C,4);case 4:n.delete(),d.g=0}})},t.onResults=function(t,e){this.listeners[e||"$"]=t},T("Solution",ye),T("OptionType",{BOOL:0,NUMBER:1,$:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(t=_e.prototype).reset=function(){this.g.reset()},t.close=function(){return this.g.close(),Promise.resolve()},t.onResults=function(t){this.g.onResults(t)},t.initialize=function(){var t=this;return A(function(e){return y(e,t.g.initialize(),0)})},t.send=function(t,e){var r=this;return A(function(n){return y(n,r.g.send(t,e),0)})},t.setOptions=function(t){this.g.setOptions(t)},T("Pose",_e),T("POSE_CONNECTIONS",[[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]]),T("POSE_LANDMARKS",{NOSE:0,LEFT_EYE_INNER:1,LEFT_EYE:2,LEFT_EYE_OUTER:3,RIGHT_EYE_INNER:4,RIGHT_EYE:5,RIGHT_EYE_OUTER:6,LEFT_EAR:7,RIGHT_EAR:8,LEFT_RIGHT:9,RIGHT_LEFT:10,LEFT_SHOULDER:11,RIGHT_SHOULDER:12,LEFT_ELBOW:13,RIGHT_ELBOW:14,LEFT_WRIST:15,RIGHT_WRIST:16,LEFT_PINKY:17,RIGHT_PINKY:18,LEFT_INDEX:19,RIGHT_INDEX:20,LEFT_THUMB:21,RIGHT_THUMB:22,LEFT_HIP:23,RIGHT_HIP:24,LEFT_KNEE:25,RIGHT_KNEE:26,LEFT_ANKLE:27,RIGHT_ANKLE:28,LEFT_HEEL:29,RIGHT_HEEL:30,LEFT_FOOT_INDEX:31,RIGHT_FOOT_INDEX:32}),T("POSE_LANDMARKS_LEFT",{LEFT_EYE_INNER:1,LEFT_EYE:2,LEFT_EYE_OUTER:3,LEFT_EAR:7,LEFT_RIGHT:9,LEFT_SHOULDER:11,LEFT_ELBOW:13,LEFT_WRIST:15,LEFT_PINKY:17,LEFT_INDEX:19,LEFT_THUMB:21,LEFT_HIP:23,LEFT_KNEE:25,LEFT_ANKLE:27,LEFT_HEEL:29,LEFT_FOOT_INDEX:31}),T("POSE_LANDMARKS_RIGHT",{RIGHT_EYE_INNER:4,RIGHT_EYE:5,RIGHT_EYE_OUTER:6,RIGHT_EAR:8,RIGHT_LEFT:10,RIGHT_SHOULDER:12,RIGHT_ELBOW:14,RIGHT_WRIST:16,RIGHT_PINKY:18,RIGHT_INDEX:20,RIGHT_THUMB:22,RIGHT_HIP:24,RIGHT_KNEE:26,RIGHT_ANKLE:28,RIGHT_HEEL:30,RIGHT_FOOT_INDEX:32}),T("POSE_LANDMARKS_NEUTRAL",{NOSE:0}),T("VERSION","0.5.1635988162")}).call(ji);const Jr=class t{constructor(){this.mediapipeMap_=new Map}getVersion(t){switch(t){case"face_detection":return Ci.VERSION;case"face_mesh":return Mi.VERSION;case"hands":return ki.VERSION;case"holistic":return Pi.VERSION;case"objectron":return Li.VERSION;case"selfie_segmentation":return Ii.VERSION;case"pose":return ji.VERSION;default:return""}}initialize(e){return new Promise(async(r,n)=>{if(0!=e.mediaPipeModelConfigArray.length){for(let r=0;r<e.mediaPipeModelConfigArray.length;r++){const i=e.mediaPipeModelConfigArray[r];if(this.mediapipeMap_.has(i.modelType))return void n("setting same type is not supported");if("function"!=typeof i.listener)return void n(`[${i.modelType}] ResultsListener must be provided`);let o;switch(i.modelType){case"face_mesh":o=new Mi.FaceMesh({locateFile:(e,r)=>(i.assetsUri||t.defaultAssetsBaseUrl+"face_mesh/"+this.getVersion("face_mesh"))+"/"+e});break;case"face_detection":o=new Ci.FaceDetection({locateFile:(e,r)=>(i.assetsUri||t.defaultAssetsBaseUrl+"face_detection/"+this.getVersion("face_detection"))+"/"+e});break;case"hands":o=new ki.Hands({locateFile:(e,r)=>(i.assetsUri||t.defaultAssetsBaseUrl+"hands/"+this.getVersion("hands"))+"/"+e});break;case"holistic":o=new Pi.Holistic({locateFile:(e,r)=>(i.assetsUri||t.defaultAssetsBaseUrl+"holistic/"+this.getVersion("holistic"))+"/"+e});break;case"objectron":o=new Li.Objectron({locateFile:(e,r)=>(i.assetsUri||t.defaultAssetsBaseUrl+"objectron/"+this.getVersion("objectron"))+"/"+e});break;case"selfie_segmentation":o=new Ii.SelfieSegmentation({locateFile:(e,r)=>(i.assetsUri||t.defaultAssetsBaseUrl+"selfie_segmentation/"+this.getVersion("selfie_segmentation"))+"/"+e});break;case"pose":o=new ji.Pose({locateFile:(e,r)=>(i.assetsUri||t.defaultAssetsBaseUrl+"pose/"+this.getVersion("pose"))+"/"+e});break;default:return void n("unknown model type")}o.onResults(i.listener),i.options&&o.setOptions(i.options);try{await o.initialize(),this.mediapipeMap_.set(i.modelType,o)}catch(t){return void n(t)}}r()}else n("no model was selected")})}close(t){return new Promise((e,r)=>{let n=[];if(t){let e=this.mediapipeMap_.get(t);if(!e)return void r("model not exit");this.mediapipeMap_.delete(t),n.push(e.close())}else{for(const[t,e]of this.mediapipeMap_.entries())n.push(e.close());this.mediapipeMap_.clear()}Promise.all(n).then(()=>{e()}).catch(t=>{r(t)})})}send(t,e){return new Promise((r,n)=>{let i=[];if(e){let r=this.mediapipeMap_.get(e);if(!r)return void n("model not exit");i.push(r.send({image:t}))}else for(const[e,r]of this.mediapipeMap_.entries())i.push(r.send({image:t}));Promise.all(i).then(()=>{r()}).catch(t=>{n(t)})})}reset(t){if(t){let e=this.mediapipeMap_.get(t);e&&"function"==typeof e.reset&&e.reset()}else for(const[t,e]of this.mediapipeMap_.entries())e&&"function"==typeof e.reset&&e.reset()}};Jr.defaultAssetsBaseUrl="https://d3opqjmqzxf057.cloudfront.net/ml/mediapipe/";let Es=Jr;const on=new WeakMap,vn=new WeakMap,qr=new WeakMap,Ui=Symbol("anyProducer"),As=Promise.resolve(),Bi=Symbol("listenerAdded"),Ni=Symbol("listenerRemoved");let Di=!1,yo=!1;const Gi=t=>"string"==typeof t||"symbol"==typeof t||"number"==typeof t;function On(t){if(!Gi(t))throw new TypeError("`eventName` must be a string, symbol, or number")}function ci(t){if("function"!=typeof t)throw new TypeError("listener must be a function")}function In(t,e){const r=vn.get(t);if(r.has(e))return r.get(e)}function Yn(t,e){const r=Gi(e)?e:Ui,n=qr.get(t);if(n.has(r))return n.get(r)}function ic(t,e,r){const n=qr.get(t);if(n.has(e))for(const t of n.get(e))t.enqueue(r);if(n.has(Ui)){const t=Promise.all([e,r]);for(const e of n.get(Ui))e.enqueue(t)}}function Ts(t,e){e=Array.isArray(e)?e:[e];let r=!1,n=()=>{},i=[];const o={enqueue(t){i.push(t),n()},finish(){r=!0,n()}};for(const r of e){let e=Yn(t,r);e||(e=new Set,qr.get(t).set(r,e)),e.add(o)}return{async next(){return i?0===i.length?r?(i=void 0,this.next()):(await new Promise(t=>{n=t}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(r){i=void 0;for(const r of e){const e=Yn(t,r);e&&(e.delete(o),0===e.size&&qr.get(t).delete(r))}return n(),arguments.length>0?{done:!0,value:await r}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Ss(t){if(void 0===t)return Rs;if(!Array.isArray(t))throw new TypeError("`methodNames` must be an array of strings");for(const e of t)if(!Rs.includes(e))throw"string"!=typeof e?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return t}const Bn=t=>t===Bi||t===Ni;function li(t,e,r){if(Bn(e))try{Di=!0,t.emit(e,r)}finally{Di=!1}}let ei=class t{static mixin(e,r){return r=Ss(r),n=>{if("function"!=typeof n)throw new TypeError("`target` must be function");for(const t of r)if(void 0!==n.prototype[t])throw new Error(`The property \`${t}\` already exists on \`target\``);Object.defineProperty(n.prototype,e,{enumerable:!1,get:function(){return Object.defineProperty(this,e,{enumerable:!1,value:new t}),this[e]}});const i=t=>function(...r){return this[e][t](...r)};for(const t of r)Object.defineProperty(n.prototype,t,{enumerable:!1,value:i(t)});return n}}static get isDebugEnabled(){if("object"!=typeof globalThis.process?.env)return yo;const{env:t}=globalThis.process??{env:{}};return"emittery"===t.DEBUG||"*"===t.DEBUG||yo}static set isDebugEnabled(t){yo=t}constructor(t={}){on.set(this,new Set),vn.set(this,new Map),qr.set(this,new Map),qr.get(this).set(Ui,new Set),this.debug=t.debug??{},void 0===this.debug.enabled&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,e,r,n)=>{try{n=JSON.stringify(n)}catch{n=`Object with the following keys failed to stringify: ${Object.keys(n).join(",")}`}("symbol"==typeof r||"number"==typeof r)&&(r=r.toString());const i=new Date,o=`${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}.${i.getMilliseconds()}`;console.log(`[${o}][emittery:${t}][${e}] Event Name: ${r}\n\tdata: ${n}`)})}logIfDebugEnabled(e,r,n){(t.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,r,n)}on(t,e,{signal:r}={}){ci(e),t=Array.isArray(t)?t:[t];for(const r of t){On(r);let t=In(this,r);t||(t=new Set,vn.get(this).set(r,t)),t.add(e),this.logIfDebugEnabled("subscribe",r,void 0),Bn(r)||li(this,Bi,{eventName:r,listener:e})}const n=()=>{this.off(t,e),r?.removeEventListener("abort",n)};return r?.addEventListener("abort",n,{once:!0}),r?.aborted&&n(),n}off(t,e){ci(e),t=Array.isArray(t)?t:[t];for(const r of t){On(r);const t=In(this,r);t&&(t.delete(e),0===t.size&&vn.get(this).delete(r)),this.logIfDebugEnabled("unsubscribe",r,void 0),Bn(r)||li(this,Ni,{eventName:r,listener:e})}}once(t,e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("predicate must be a function");let r;const n=new Promise(n=>{r=this.on(t,t=>{e&&!e(t)||(r(),n(t))})});return n.off=r,n}events(t){t=Array.isArray(t)?t:[t];for(const e of t)On(e);return Ts(this,t)}async emit(t,e){if(On(t),Bn(t)&&!Di)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",t,e),ic(this,t,e);const r=In(this,t)??new Set,n=on.get(this),i=[...r],o=Bn(t)?[]:[...n];await As,await Promise.all([...i.map(async t=>{if(r.has(t))return t(e)}),...o.map(async r=>{if(n.has(r))return r(t,e)})])}async emitSerial(t,e){if(On(t),Bn(t)&&!Di)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",t,e);const r=In(this,t)??new Set,n=on.get(this),i=[...r],o=[...n];await As;for(const t of i)r.has(t)&&await t(e);for(const r of o)n.has(r)&&await r(t,e)}onAny(t,{signal:e}={}){ci(t),this.logIfDebugEnabled("subscribeAny",void 0,void 0),on.get(this).add(t),li(this,Bi,{listener:t});const r=()=>{this.offAny(t),e?.removeEventListener("abort",r)};return e?.addEventListener("abort",r,{once:!0}),e?.aborted&&r(),r}anyEvent(){return Ts(this)}offAny(t){ci(t),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),li(this,Ni,{listener:t}),on.get(this).delete(t)}clearListeners(t){t=Array.isArray(t)?t:[t];for(const e of t)if(this.logIfDebugEnabled("clear",e,void 0),Gi(e)){const t=In(this,e);t&&t.clear();const r=Yn(this,e);if(r){for(const t of r)t.finish();r.clear()}}else{on.get(this).clear();for(const[t,e]of vn.get(this).entries())e.clear(),vn.get(this).delete(t);for(const[t,e]of qr.get(this).entries()){for(const t of e)t.finish();e.clear(),qr.get(this).delete(t)}}}listenerCount(t){t=Array.isArray(t)?t:[t];let e=0;for(const r of t)if(Gi(r))e+=on.get(this).size+(In(this,r)?.size??0)+(Yn(this,r)?.size??0)+(Yn(this)?.size??0);else{void 0!==r&&On(r),e+=on.get(this).size;for(const t of vn.get(this).values())e+=t.size;for(const t of qr.get(this).values())e+=t.size}return e}bindMethods(t,e){if("object"!=typeof t||null===t)throw new TypeError("`target` must be an object");e=Ss(e);for(const r of e){if(void 0!==t[r])throw new Error(`The property \`${r}\` already exists on \`target\``);Object.defineProperty(t,r,{enumerable:!1,value:this[r].bind(this)})}}};const Rs=Object.getOwnPropertyNames(ei.prototype).filter(t=>"constructor"!==t);function Do(t,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let r=globalThis.vonage.workerizer;return r[t]||(r[t]=e),r[t]}Object.defineProperty(ei,"listenerAdded",{value:Bi,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(ei,"listenerRemoved",{value:Ni,writable:!1,enumerable:!0,configurable:!1});const Gn=Do("globals",{});var Yr=(t=>(t.INIT="INIT",t.FORWARD="FORWARD",t.TERMINATE="TERMINATE",t.GLOBALS_SYNC="GLOBALS_SYNC",t.EVENT="EVENT",t))(Yr||{});function ia(t){return[ImageBitmap,ReadableStream,WritableStream].some(e=>t instanceof e)}let oc=0;function Wi(t,e,r,n,i){const o=oc++;return t.postMessage({id:o,type:e,functionName:r,args:n},n.filter(t=>ia(t))),new Promise(t=>{i?.set(o,t)})}function Wn(t,e){const{id:r,type:n}=t,i=Array.isArray(e)?e:[e];postMessage({id:r,type:n,result:e},i.filter(t=>ia(t)))}const zi=Do("workerized",{});function Go(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function sc(){if(Go())Wn({type:Yr.GLOBALS_SYNC},Gn);else{const t=[];for(const e in zi){const{worker:r,resolvers:n}=zi[e].workerContext;r&&t.push(Wi(r,Yr.GLOBALS_SYNC,"",[Gn],n))}await Promise.all(t)}}function Kn(t,e){if(Array.isArray(e))e.splice(0,e.length);else if("object"==typeof e)for(const t in e)delete e[t];for(const r in t)Array.isArray(t[r])?(e[r]=[],Kn(t[r],e[r])):"object"==typeof t[r]?(e[r]={},Kn(t[r],e[r])):e[r]=t[r]}async function ac(t,e,r,n){const i=new e;if(i.addEventListener("message",async({data:t})=>{var e,i,o,a,s,u,c;switch(t.type){case Yr.GLOBALS_SYNC:t.id?(null==(i=r.get(null!=(e=t.id)?e:-1))||i(t.result),r.delete(null!=(o=t.id)?o:-1)):(Kn(null!=(a=t.result)?a:{},Gn),await sc());break;case Yr.EVENT:const{result:l}=t,f=l;if(null==f?.name)throw"Missing event name";n(f.name,f.data);break;default:null==(u=r.get(null!=(s=t.id)?s:-1))||u(t.result),r.delete(null!=(c=t.id)?c:-1)}}),!await Wi(i,Yr.INIT,"",[t.workerId,Gn],r))throw"Failed to instantiate workerized class";return i}const sn=new WeakMap,bn=new WeakMap,en=new WeakMap,Hi=Symbol("anyProducer"),Fs=Promise.resolve(),Vi=Symbol("listenerAdded"),$i=Symbol("listenerRemoved");let Yi=!1,vo=!1;function kn(t){if("string"!=typeof t&&"symbol"!=typeof t&&"number"!=typeof t)throw new TypeError("`eventName` must be a string, symbol, or number")}function fi(t){if("function"!=typeof t)throw new TypeError("listener must be a function")}function Pn(t,e){const r=bn.get(t);if(r.has(e))return r.get(e)}function Xn(t,e){const r="string"==typeof e||"symbol"==typeof e||"number"==typeof e?e:Hi,n=en.get(t);if(n.has(r))return n.get(r)}function uc(t,e,r){const n=en.get(t);if(n.has(e))for(const t of n.get(e))t.enqueue(r);if(n.has(Hi)){const t=Promise.all([e,r]);for(const e of n.get(Hi))e.enqueue(t)}}function Os(t,e){e=Array.isArray(e)?e:[e];let r=!1,n=()=>{},i=[];const o={enqueue(t){i.push(t),n()},finish(){r=!0,n()}};for(const r of e){let e=Xn(t,r);e||(e=new Set,en.get(t).set(r,e)),e.add(o)}return{async next(){return i?0===i.length?r?(i=void 0,this.next()):(await new Promise(t=>{n=t}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(r){i=void 0;for(const r of e){const e=Xn(t,r);e&&(e.delete(o),0===e.size&&en.get(t).delete(r))}return n(),arguments.length>0?{done:!0,value:await r}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Is(t){if(void 0===t)return ks;if(!Array.isArray(t))throw new TypeError("`methodNames` must be an array of strings");for(const e of t)if(!ks.includes(e))throw"string"!=typeof e?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return t}const Nn=t=>t===Vi||t===$i;function hi(t,e,r){if(Nn(e))try{Yi=!0,t.emit(e,r)}finally{Yi=!1}}class An{static mixin(t,e){return e=Is(e),r=>{if("function"!=typeof r)throw new TypeError("`target` must be function");for(const t of e)if(void 0!==r.prototype[t])throw new Error(`The property \`${t}\` already exists on \`target\``);Object.defineProperty(r.prototype,t,{enumerable:!1,get:function(){return Object.defineProperty(this,t,{enumerable:!1,value:new An}),this[t]}});const n=e=>function(...r){return this[t][e](...r)};for(const t of e)Object.defineProperty(r.prototype,t,{enumerable:!1,value:n(t)});return r}}static get isDebugEnabled(){var t,e;if("object"!=typeof(null==(t=globalThis.process)?void 0:t.env))return vo;const{env:r}=null!=(e=globalThis.process)?e:{env:{}};return"emittery"===r.DEBUG||"*"===r.DEBUG||vo}static set isDebugEnabled(t){vo=t}constructor(t={}){var e;sn.set(this,new Set),bn.set(this,new Map),en.set(this,new Map),en.get(this).set(Hi,new Set),this.debug=null!=(e=t.debug)?e:{},void 0===this.debug.enabled&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,e,r,n)=>{try{n=JSON.stringify(n)}catch{n=`Object with the following keys failed to stringify: ${Object.keys(n).join(",")}`}("symbol"==typeof r||"number"==typeof r)&&(r=r.toString());const i=new Date,o=`${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}.${i.getMilliseconds()}`;console.log(`[${o}][emittery:${t}][${e}] Event Name: ${r}\n\tdata: ${n}`)})}logIfDebugEnabled(t,e,r){(An.isDebugEnabled||this.debug.enabled)&&this.debug.logger(t,this.debug.name,e,r)}on(t,e){fi(e),t=Array.isArray(t)?t:[t];for(const r of t){kn(r);let t=Pn(this,r);t||(t=new Set,bn.get(this).set(r,t)),t.add(e),this.logIfDebugEnabled("subscribe",r,void 0),Nn(r)||hi(this,Vi,{eventName:r,listener:e})}return this.off.bind(this,t,e)}off(t,e){fi(e),t=Array.isArray(t)?t:[t];for(const r of t){kn(r);const t=Pn(this,r);t&&(t.delete(e),0===t.size&&bn.get(this).delete(r)),this.logIfDebugEnabled("unsubscribe",r,void 0),Nn(r)||hi(this,$i,{eventName:r,listener:e})}}once(t){let e;const r=new Promise(r=>{e=this.on(t,t=>{e(),r(t)})});return r.off=e,r}events(t){t=Array.isArray(t)?t:[t];for(const e of t)kn(e);return Os(this,t)}async emit(t,e){var r;if(kn(t),Nn(t)&&!Yi)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",t,e),uc(this,t,e);const n=null!=(r=Pn(this,t))?r:new Set,i=sn.get(this),o=[...n],a=Nn(t)?[]:[...i];await Fs,await Promise.all([...o.map(async t=>{if(n.has(t))return t(e)}),...a.map(async r=>{if(i.has(r))return r(t,e)})])}async emitSerial(t,e){var r;if(kn(t),Nn(t)&&!Yi)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",t,e);const n=null!=(r=Pn(this,t))?r:new Set,i=sn.get(this),o=[...n],a=[...i];await Fs;for(const t of o)n.has(t)&&await t(e);for(const r of a)i.has(r)&&await r(t,e)}onAny(t){return fi(t),this.logIfDebugEnabled("subscribeAny",void 0,void 0),sn.get(this).add(t),hi(this,Vi,{listener:t}),this.offAny.bind(this,t)}anyEvent(){return Os(this)}offAny(t){fi(t),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),hi(this,$i,{listener:t}),sn.get(this).delete(t)}clearListeners(t){t=Array.isArray(t)?t:[t];for(const e of t)if(this.logIfDebugEnabled("clear",e,void 0),"string"==typeof e||"symbol"==typeof e||"number"==typeof e){const t=Pn(this,e);t&&t.clear();const r=Xn(this,e);if(r){for(const t of r)t.finish();r.clear()}}else{sn.get(this).clear();for(const[t,e]of bn.get(this).entries())e.clear(),bn.get(this).delete(t);for(const[t,e]of en.get(this).entries()){for(const t of e)t.finish();e.clear(),en.get(this).delete(t)}}}listenerCount(t){var e,r,n,i,o,a;t=Array.isArray(t)?t:[t];let s=0;for(const u of t)if("string"!=typeof u){typeof u<"u"&&kn(u),s+=sn.get(this).size;for(const t of bn.get(this).values())s+=t.size;for(const t of en.get(this).values())s+=t.size}else s+=sn.get(this).size+(null!=(r=null==(e=Pn(this,u))?void 0:e.size)?r:0)+(null!=(i=null==(n=Xn(this,u))?void 0:n.size)?i:0)+(null!=(a=null==(o=Xn(this))?void 0:o.size)?a:0);return s}bindMethods(t,e){if("object"!=typeof t||null===t)throw new TypeError("`target` must be an object");e=Is(e);for(const r of e){if(void 0!==t[r])throw new Error(`The property \`${r}\` already exists on \`target\``);Object.defineProperty(t,r,{enumerable:!1,value:this[r].bind(this)})}}}const ks=Object.getOwnPropertyNames(An.prototype).filter(t=>"constructor"!==t);function cc(t){return t.onAny&&t.emit}function lc(t){return t.prototype.onAny&&t.prototype.emit}Object.defineProperty(An,"listenerAdded",{value:Vi,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(An,"listenerRemoved",{value:$i,writable:!1,enumerable:!0,configurable:!1});let fc=0;async function hc(t,e,r){const n=lc(t)?new An:{},i=fc++;return Object.getOwnPropertyNames(t.prototype).forEach(t=>{n[t]=(...n)=>Wi(e,Yr.FORWARD,t,n,r)}),n.terminate=async(...t)=>{const o=await Wi(e,Yr.TERMINATE,"",t,r);return delete zi[i],e.terminate(),n.workerContext.worker=void 0,o},n.workerContext={id:i,worker:e,resolvers:r},zi[i]=n,n}async function dc(t,e){const r=new Map;let n;const i=await ac(t,e,r,(t,e)=>{n?.emit&&n?.emit(t,e)});return n=await hc(t,i,r),n}async function pc(t,e){const{functionName:r,args:n}=t;if(!e.instance)throw"instance not initialized";if(!r)throw"missing function name to call";if(!e.instance[r])throw`undefined function [${r}] in class ${e.instance.constructor.workerId}`;Wn(t,await e.instance[r](...n??[]))}const oa=Do("registeredWorkers",{});function gc(t,e){e.workerId=t,Go()&&(oa[e.workerId]=e)}function mc(t,e){if(!t.args)throw"Missing className while initializing worker";const[r,n]=t.args,i=oa[r];if(!i)throw`unknown worker class ${r}`;e.instance=new i(t.args.slice(1)),Kn(n,Gn),cc(e.instance)&&e.instance.onAny((t,e)=>{Wn({type:Yr.EVENT},{name:t,data:e})}),Wn(t,void 0!==typeof e.instance)}async function yc(t,e){const{args:r}=t;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...r??[])),Wn(t,n)}function vc(t){if(!t.args)throw"Missing globals while syncing";Kn(t.args[0],Gn),Wn(t,{})}function bc(){const t={};onmessage=async e=>{const r=e.data;switch(r.type){case Yr.INIT:mc(r,t);break;case Yr.FORWARD:pc(r,t);break;case Yr.TERMINATE:yc(r,t);break;case Yr.GLOBALS_SYNC:vc(r)}}}Go()&&bc();class Ps{static async createVideoReadable(t){return new Promise((e,r)=>{const n=document.createElement("video");let i=new AbortController,o=new AbortController;n.addEventListener("canplay",()=>{i.abort(),n.muted=!0,n.loop=!0,n.play().then(()=>{try{const t=n.captureStream(),r=new MediaStreamTrackProcessor(t.getVideoTracks()[0]);e(r.readable)}catch(t){r(t)}})},{once:!0,signal:o.signal}),n.addEventListener("error",t=>{o.abort(),r("loading error:"+t)},{once:!0,signal:i.signal}),n.crossOrigin="anonymous",n.src=t})}static async createImageCanvas(t){const e=await(await fetch(t)).blob();return await createImageBitmap(e)}}var wc=Object.defineProperty,xc=(t,e,r)=>e in t?wc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_c=(t,e,r)=>(xc(t,e+"",r),r);const Ec="hlg.tokbox.com/prod/logging/vcp_webrtc",Ac="https://",Tc=1e4;let di;const Sc=new Uint8Array(16);function Rc(){if(!di&&(di=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!di))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return di(Sc)}const Br=[];for(let t=0;t<256;++t)Br.push((t+256).toString(16).slice(1));function Fc(t,e=0){return(Br[t[e+0]]+Br[t[e+1]]+Br[t[e+2]]+Br[t[e+3]]+"-"+Br[t[e+4]]+Br[t[e+5]]+"-"+Br[t[e+6]]+Br[t[e+7]]+"-"+Br[t[e+8]]+Br[t[e+9]]+"-"+Br[t[e+10]]+Br[t[e+11]]+Br[t[e+12]]+Br[t[e+13]]+Br[t[e+14]]+Br[t[e+15]]).toLowerCase()}const Oc=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Cs={randomUUID:Oc};function Ic(t,e,r){if(Cs.randomUUID&&!e&&!t)return Cs.randomUUID();const n=(t=t||{}).random||(t.rng||Rc)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,Fc(n)}function Wo(t,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let r=globalThis.vonage.workerizer;return r[t]||(r[t]=e),r[t]}const cn=Wo("globals",{});var _n=(t=>(t.INIT="INIT",t.FORWARD="FORWARD",t.TERMINATE="TERMINATE",t.GLOBALS_SYNC="GLOBALS_SYNC",t))(_n||{});function sa(t){return[ImageBitmap,ReadableStream,WritableStream].some(e=>t instanceof e)}let kc=0;function Pc(t,e,r,n,i){const o=kc++;return t.postMessage({id:o,type:e,functionName:r,args:n},n.filter(t=>sa(t))),new Promise(t=>{i?.set(o,t)})}function ti(t,e){const{id:r,type:n}=t,i=Array.isArray(e)?e:[e];postMessage({id:r,type:n,result:e},i.filter(t=>sa(t)))}const Ms=Wo("workerized",{});function aa(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function Cc(){if(aa())ti({type:_n.GLOBALS_SYNC},cn);else{const t=[];for(const e in Ms){const{worker:r,resolvers:n}=Ms[e].workerContext;r&&t.push(Pc(r,_n.GLOBALS_SYNC,"",[cn],n))}await Promise.all(t)}}function Xi(t,e){if(Array.isArray(e))e.splice(0,e.length);else if("object"==typeof e)for(const t in e)delete e[t];for(const r in t)Array.isArray(t[r])?(e[r]=[],Xi(t[r],e[r])):"object"==typeof t[r]?(e[r]={},Xi(t[r],e[r])):e[r]=t[r]}async function Mc(t,e){const{functionName:r,args:n}=t;if(!e.instance)throw"instance not initialized";if(!r)throw"missing function name to call";if(!e.instance[r])throw`undefined function [${r}] in class ${e.instance.constructor.workerId}`;ti(t,await e.instance[r](...n??[]))}const Lc=Wo("registeredWorkers",{});function jc(t,e){if(!t.args)throw"Missing className while initializing worker";const[r,n]=t.args,i=Lc[r];if(!i)throw`unknown worker class ${r}`;e.instance=new i(t.args.slice(1)),Xi(n,cn),ti(t,void 0!==typeof e.instance)}async function Uc(t,e){const{args:r}=t;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...r??[])),ti(t,n)}function Bc(t){if(!t.args)throw"Missing globals while syncing";Xi(t.args[0],cn),ti(t,{})}function Nc(){const t={};onmessage=async e=>{const r=e.data;switch(r.type){case _n.INIT:jc(r,t);break;case _n.FORWARD:Mc(r,t);break;case _n.TERMINATE:Uc(r,t);break;case _n.GLOBALS_SYNC:Bc(r)}}}function Dc(t,e){return cn[t]||(cn[t]=e),[()=>cn[t],async e=>{cn[t]=e,await Cc()}]}function Gc(t,e){return Dc(t,e)}aa()&&Nc();const[Wc]=Gc("metadata");function bo(){return Wc()}class zc{constructor(t){_c(this,"uuid",Ic()),this.config=t}async send(t){var e,r,n;const{appId:i,sourceType:o}=null!=(e=bo())?e:{};if(!i||!o)return"metadata missing";const a=new AbortController,s=setTimeout(()=>a.abort(),Tc);return await(null!=(n=null==(r=this.config)?void 0:r.fetch)?n:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(t)),signal:a.signal}),clearTimeout(s),"success"}getUrl(){var t;let e=null!=(t=bo().proxyUrl)?t:Ac;return e+=("/"===e.at(-1)?"":"/")+Ec,e}getHeaders(){return{"Content-Type":"application/json"}}buildReport(t){const e=bo();return{guid:this.uuid,...t,applicationId:e.appId,timestamp:Date.now(),proxyUrl:e.proxyUrl,source:e.sourceType}}}const Hc="7.0.0-alpha.1";class zo{constructor(){const t=new OffscreenCanvas(0,0),e=t.getContext("2d",{willReadFrequently:!0});if(!e)throw"Fail to retrieve 2d context";this.canvas=t,this.context=e}setFlickeringOptions(t){}enablePostProcessing(){}disablePostProcessing(){}async profileWebgl(t){return[]}async render(t,e){return this.canvas}resizeCanvas(t){const{width:e,height:r}=t;this.canvas.width=e,this.canvas.height=r}renderSilhouette(t,e,r="none"){const{width:n,height:i}=t;this.context.save(),this.context.drawImage(e,0,0,e.width,e.height,0,0,n,i),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(e,0,0,e.width,e.height,0,0,n,i),this.context.globalCompositeOperation="source-in",this.context.filter=r,this.context.drawImage(t,0,0,n,i,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class Vc extends zo{constructor(t){super(),this.radius=t}async render(t,e){super.resizeCanvas(t);const r=await createImageBitmap(e);return this.renderSilhouette(t,r),this.context.save(),this.context.filter=`blur(${this.radius}px)`,this.context.globalCompositeOperation="destination-over",this.context.drawImage(t,0,0,t.width,t.height),this.context.restore(),super.render(t,e)}}class $c extends zo{constructor(t){super(),this.radius=t}async render(t,e){super.resizeCanvas(t);const r=await createImageBitmap(e);return this.renderSilhouette(t,r,`blur(${this.radius}px)`),this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(t,0,0,t.width,t.height),this.context.restore(),super.render(t,e)}}class Yc extends zo{setBackgroundImage(t){this.backgroundImage=t}async render(t,e){super.resizeCanvas(t);const r=await createImageBitmap(e);return this.renderSilhouette(t,r),this.backgroundImage&&(this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(this.backgroundImage,0,0,this.backgroundImage.width,this.backgroundImage.height,0,0,t.width,t.height),this.context.restore()),super.render(t,e)}}const Ho=5120,Qn=5121,Vo=5122,$o=5123,Yo=5124,Xo=5125,Ko=5126,Xc=32819,Kc=32820,Qc=33635,Jc=5131,Zc=33640,qc=35899,el=35902,tl=36269,rl=34042,ua={};{const t=ua;t[Ho]=Int8Array,t[Qn]=Uint8Array,t[Vo]=Int16Array,t[$o]=Uint16Array,t[Yo]=Int32Array,t[Xo]=Uint32Array,t[Ko]=Float32Array,t[Xc]=Uint16Array,t[Kc]=Uint16Array,t[Qc]=Uint16Array,t[Jc]=Uint16Array,t[Zc]=Uint32Array,t[qc]=Uint32Array,t[el]=Uint32Array,t[tl]=Uint32Array,t[rl]=Uint32Array}function Qo(t){if(t instanceof Int8Array)return Ho;if(t instanceof Uint8Array||t instanceof Uint8ClampedArray)return Qn;if(t instanceof Int16Array)return Vo;if(t instanceof Uint16Array)return $o;if(t instanceof Int32Array)return Yo;if(t instanceof Uint32Array)return Xo;if(t instanceof Float32Array)return Ko;throw new Error("unsupported typed array type")}function ca(t){if(t===Int8Array)return Ho;if(t===Uint8Array||t===Uint8ClampedArray)return Qn;if(t===Int16Array)return Vo;if(t===Uint16Array)return $o;if(t===Int32Array)return Yo;if(t===Uint32Array)return Xo;if(t===Float32Array)return Ko;throw new Error("unsupported typed array type")}function la(t){const e=ua[t];if(!e)throw new Error("unknown gl type");return e}const Ki=typeof SharedArrayBuffer<"u"?function(t){return t&&t.buffer&&(t.buffer instanceof ArrayBuffer||t.buffer instanceof SharedArrayBuffer)}:function(t){return t&&t.buffer&&t.buffer instanceof ArrayBuffer};function fa(...t){console.error(...t)}const Ls=new Map;function to(t,e){if(!t||"object"!=typeof t)return!1;let r=Ls.get(e);r||(r=new WeakMap,Ls.set(e,r));let n=r.get(t);if(void 0===n){const i=Object.prototype.toString.call(t);n=i.substring(8,i.length-1)===e,r.set(t,n)}return n}function nl(t,e){return typeof WebGLBuffer<"u"&&to(e,"WebGLBuffer")}function il(t,e){return typeof WebGLRenderbuffer<"u"&&to(e,"WebGLRenderbuffer")}function Jo(t,e){return typeof WebGLTexture<"u"&&to(e,"WebGLTexture")}function ol(t,e){return typeof WebGLSampler<"u"&&to(e,"WebGLSampler")}const ha=35044,En=34962,sl=34963,al=34660,ul=5120,cl=5121,ll=5122,fl=5123,hl=5124,dl=5125,da=5126,pa={attribPrefix:""};function pl(t,e,r,n,i){t.bindBuffer(e,r),t.bufferData(e,n,i||ha)}function ga(t,e,r,n){if(nl(t,e))return e;r=r||En;const i=t.createBuffer();return pl(t,r,i,e,n),i}function ma(t){return"indices"===t}function gl(t){return t===Int8Array||t===Uint8Array}function ml(t){return t.length?t:t.data}const yl=/coord|texture/i,vl=/color|colour/i;function bl(t,e){let r;if(r=yl.test(t)?2:vl.test(t)?4:3,e%r>0)throw new Error(`Can not guess numComponents for attribute '${t}'. Tried ${r} but ${e} values is not evenly divisible by ${r}. You should specify it.`);return r}function wl(t,e,r){return t.numComponents||t.size||bl(e,r||ml(t).length)}function ya(t,e){if(Ki(t))return t;if(Ki(t.data))return t.data;Array.isArray(t)&&(t={data:t});let r=t.type?Zo(t.type):void 0;return r||(r=ma(e)?Uint16Array:Float32Array),new r(t.data)}function xl(t){return"number"==typeof t?t:t?ca(t):da}function Zo(t){return"number"==typeof t?la(t):t||Float32Array}function _l(t,e){return{buffer:e.buffer,numValues:24,type:xl(e.type),arrayType:Zo(e.type)}}function El(t,e){const r=e.data||e,n=Zo(e.type),i=r*n.BYTES_PER_ELEMENT,o=t.createBuffer();return t.bindBuffer(En,o),t.bufferData(En,i,e.drawType||ha),{buffer:o,numValues:r,type:ca(n),arrayType:n}}function Al(t,e,r){const n=ya(e,r);return{arrayType:n.constructor,buffer:ga(t,n,void 0,e.drawType),type:Qo(n),numValues:0}}function Tl(t,e){const r={};return Object.keys(e).forEach(function(n){if(!ma(n)){const i=e[n],o=i.attrib||i.name||i.attribName||pa.attribPrefix+n;if(i.value){if(!Array.isArray(i.value)&&!Ki(i.value))throw new Error("array.value is not array or typedarray");r[o]={value:i.value}}else{let e;e=i.buffer&&i.buffer instanceof WebGLBuffer?_l:"number"==typeof i||"number"==typeof i.data?El:Al;const{buffer:a,type:s,numValues:u,arrayType:c}=e(t,i,n),l=void 0!==i.normalize?i.normalize:gl(c),f=wl(i,n,u);r[o]={buffer:a,numComponents:f,type:s,normalize:l,stride:i.stride||0,offset:i.offset||0,divisor:void 0===i.divisor?void 0:i.divisor,drawType:i.drawType}}}}),t.bindBuffer(En,null),r}function Sl(t,e){return e===ul||e===cl?1:e===ll||e===fl?2:e===hl||e===dl||e===da?4:0}const wo=["position","positions","a_position"];function Rl(t,e){let r,n;for(n=0;n<wo.length&&(r=wo[n],!(r in e)&&(r=pa.attribPrefix+r,!(r in e)));++n);n===wo.length&&(r=Object.keys(e)[0]);const i=e[r];if(!i.buffer)return 1;t.bindBuffer(En,i.buffer);const o=t.getBufferParameter(En,al);t.bindBuffer(En,null);const a=o/Sl(t,i.type),s=i.numComponents||i.size,u=a/s;if(u%1!=0)throw new Error(`numComponents ${s} not correct for length ${length}`);return u}function Fl(t,e,r){const n=Tl(t,e),i=Object.assign({},r||{});i.attribs=Object.assign({},r?r.attribs:{},n);const o=e.indices;if(o){const e=ya(o,"indices");i.indices=ga(t,e,sl),i.numElements=e.length,i.elementType=Qo(e)}else i.numElements||(i.numElements=Rl(t,i.attribs));return i}function ri(t){return!!t.texStorage2D}const va=function(){const t={},e={};return function(r,n){return function(r){const n=r.constructor.name;if(!t[n]){for(const t in r)if("number"==typeof r[t]){const n=e[r[t]];e[r[t]]=n?`${n} | ${t}`:t}t[n]=!0}}(r),e[n]||("number"==typeof n?`0x${n.toString(16)}`:n)}}(),fn={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},Jn=Ki,ba=function(){let t;return function(){return t=t||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),t}}(),js=6406,Qr=6407,vr=6408,Us=6409,Bs=6410,Hn=6402,Ns=34041,Qi=33071,Ol=9728,Il=9729,hn=3553,ln=34067,Tn=32879,Sn=35866,qo=34069,kl=34070,Pl=34071,Cl=34072,Ml=34073,Ll=34074,Ro=10241,Fo=10240,Ji=10242,Zi=10243,Ds=32882,jl=33082,Ul=33083,Bl=33084,Nl=33085,Dl=34892,Gl=34893,es=3317,wa=3314,xa=32878,_a=3316,Ea=3315,Aa=32877,Wl=37443,zl=37441,Hl=37440,Vl=33321,$l=36756,Yl=33325,Xl=33326,Kl=33330,Ql=33329,Jl=33338,Zl=33337,ql=33340,ef=33339,tf=33323,rf=36757,nf=33327,of=33328,sf=33336,af=33335,uf=33332,cf=33331,lf=33334,ff=33333,hf=32849,df=35905,pf=36194,gf=36758,mf=35898,yf=35901,vf=34843,bf=34837,wf=36221,xf=36239,_f=36215,Ef=36233,Af=36209,Tf=36227,Sf=32856,Rf=35907,Ff=36759,Of=32855,If=32854,kf=32857,Pf=34842,Cf=34836,Mf=36220,Lf=36238,jf=36975,Uf=36214,Bf=36232,Nf=36226,Df=36208,Gf=33189,Wf=33190,zf=36012,Hf=36013,Vf=35056,an=5120,dr=5121,pi=5122,Cn=5123,gi=5124,gn=5125,Gr=5126,Gs=32819,Ws=32820,zs=33635,Xr=5131,Vn=36193,xo=33640,$f=35899,Yf=35902,Xf=36269,Kf=34042,mi=33319,Mn=33320,yi=6403,Ln=36244,jn=36248,mn=36249;let _o;function ro(t){if(!_o){const t={};t[js]={textureFormat:js,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[dr,Xr,Vn,Gr]},t[Us]={textureFormat:Us,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[dr,Xr,Vn,Gr]},t[Bs]={textureFormat:Bs,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[dr,Xr,Vn,Gr]},t[Qr]={textureFormat:Qr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[dr,Xr,Vn,Gr,zs]},t[vr]={textureFormat:vr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[dr,Xr,Vn,Gr,Gs,Ws]},t[Hn]={textureFormat:Hn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[gn,Cn]},t[Vl]={textureFormat:yi,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[dr]},t[$l]={textureFormat:yi,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[an]},t[Yl]={textureFormat:yi,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[Gr,Xr]},t[Xl]={textureFormat:yi,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[Gr]},t[Kl]={textureFormat:Ln,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[dr]},t[Ql]={textureFormat:Ln,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[an]},t[uf]={textureFormat:Ln,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Cn]},t[cf]={textureFormat:Ln,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[pi]},t[lf]={textureFormat:Ln,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[gn]},t[ff]={textureFormat:Ln,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[gi]},t[tf]={textureFormat:mi,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[dr]},t[rf]={textureFormat:mi,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[an]},t[nf]={textureFormat:mi,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[Gr,Xr]},t[of]={textureFormat:mi,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[Gr]},t[sf]={textureFormat:Mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[dr]},t[af]={textureFormat:Mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[an]},t[Jl]={textureFormat:Mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Cn]},t[Zl]={textureFormat:Mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[pi]},t[ql]={textureFormat:Mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[gn]},t[ef]={textureFormat:Mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[gi]},t[hf]={textureFormat:Qr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[dr]},t[df]={textureFormat:Qr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[dr]},t[pf]={textureFormat:Qr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[dr,zs]},t[gf]={textureFormat:Qr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[an]},t[mf]={textureFormat:Qr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[Gr,Xr,$f]},t[yf]={textureFormat:Qr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[Gr,Xr,Yf]},t[vf]={textureFormat:Qr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[Gr,Xr]},t[bf]={textureFormat:Qr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[Gr]},t[wf]={textureFormat:jn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[dr]},t[xf]={textureFormat:jn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[an]},t[_f]={textureFormat:jn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Cn]},t[Ef]={textureFormat:jn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[pi]},t[Af]={textureFormat:jn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[gn]},t[Tf]={textureFormat:jn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[gi]},t[Sf]={textureFormat:vr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[dr]},t[Rf]={textureFormat:vr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[dr]},t[Ff]={textureFormat:vr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[an]},t[Of]={textureFormat:vr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[dr,Ws,xo]},t[If]={textureFormat:vr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[dr,Gs]},t[kf]={textureFormat:vr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[xo]},t[Pf]={textureFormat:vr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[Gr,Xr]},t[Cf]={textureFormat:vr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[Gr]},t[Mf]={textureFormat:mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[dr]},t[Lf]={textureFormat:mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[an]},t[jf]={textureFormat:mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[xo]},t[Uf]={textureFormat:mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Cn]},t[Bf]={textureFormat:mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[pi]},t[Nf]={textureFormat:mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[gi]},t[Df]={textureFormat:mn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[gn]},t[Gf]={textureFormat:Hn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Cn,gn]},t[Wf]={textureFormat:Hn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[gn]},t[zf]={textureFormat:Hn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Gr]},t[Vf]={textureFormat:Ns,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Kf]},t[Hf]={textureFormat:Ns,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Xf]},Object.keys(t).forEach(function(e){const r=t[e];r.bytesPerElementMap={},r.bytesPerElement.forEach(function(t,e){const n=r.type[e];r.bytesPerElementMap[n]=t})}),_o=t}return _o[t]}function Qf(t,e){const r=ro(t);if(!r)throw"unknown internal format";const n=r.bytesPerElementMap[e];if(void 0===n)throw"unknown internal format";return n}function ni(t){const e=ro(t);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function Hs(t){return!(t&t-1)}function Jf(t,e,r,n){if(!ri(t))return Hs(e)&&Hs(r);const i=ro(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function Zf(t){const e=ro(t);if(!e)throw"unknown internal format";return e.textureFilterable}function qf(t,e,r){return Jn(e)?Qo(e):r||dr}function vi(t,e,r,n,i){if(i%1!=0)throw"can't guess dimensions";if(r||n){if(n){if(!r&&(r=i/n)%1)throw"can't guess dimensions"}else if((n=i/r)%1)throw"can't guess dimensions"}else{const t=Math.sqrt(i/(e===ln?6:1));t%1==0?(r=t,n=t):(r=i,n=1)}return{width:r,height:n}}function zn(t,e){void 0!==e.colorspaceConversion&&t.pixelStorei(Wl,e.colorspaceConversion),void 0!==e.premultiplyAlpha&&t.pixelStorei(zl,e.premultiplyAlpha),void 0!==e.flipY&&t.pixelStorei(Hl,e.flipY)}function Ta(t){t.pixelStorei(es,4),ri(t)&&(t.pixelStorei(wa,0),t.pixelStorei(xa,0),t.pixelStorei(_a,0),t.pixelStorei(Ea,0),t.pixelStorei(Aa,0))}function e2(t,e,r,n){n.minMag&&(r.call(t,e,Ro,n.minMag),r.call(t,e,Fo,n.minMag)),n.min&&r.call(t,e,Ro,n.min),n.mag&&r.call(t,e,Fo,n.mag),n.wrap&&(r.call(t,e,Ji,n.wrap),r.call(t,e,Zi,n.wrap),(e===Tn||ol(t,e))&&r.call(t,e,Ds,n.wrap)),n.wrapR&&r.call(t,e,Ds,n.wrapR),n.wrapS&&r.call(t,e,Ji,n.wrapS),n.wrapT&&r.call(t,e,Zi,n.wrapT),void 0!==n.minLod&&r.call(t,e,jl,n.minLod),void 0!==n.maxLod&&r.call(t,e,Ul,n.maxLod),void 0!==n.baseLevel&&r.call(t,e,Bl,n.baseLevel),void 0!==n.maxLevel&&r.call(t,e,Nl,n.maxLevel),void 0!==n.compareFunc&&r.call(t,e,Gl,n.compareFunc),void 0!==n.compareMode&&r.call(t,e,Dl,n.compareMode)}function Sa(t,e,r){const n=r.target||hn;t.bindTexture(n,e),e2(t,n,t.texParameteri,r)}function t2(t){return Jn(t=t||fn.textureColor)?t:new Uint8Array([255*t[0],255*t[1],255*t[2],255*t[3]])}function Oo(t,e,r,n,i,o){o=o||vr;const a=(r=r||fn.textureOptions).target||hn;if(n=n||r.width,i=i||r.height,t.bindTexture(a,e),Jf(t,n,i,o))t.generateMipmap(a);else{const e=Zf(o)?Il:Ol;t.texParameteri(a,Ro,e),t.texParameteri(a,Fo,e),t.texParameteri(a,Ji,Qi),t.texParameteri(a,Zi,Qi)}}function Zn(t){return!0===t.auto||void 0===t.auto&&void 0===t.level}function Io(t,e){return(e=e||{}).cubeFaceOrder||[qo,kl,Pl,Cl,Ml,Ll]}function ko(t,e){const r=Io(t,e).map(function(t,e){return{face:t,ndx:e}});return r.sort(function(t,e){return t.face-e.face}),r}function Ra(t,e,r,n){const i=(n=n||fn.textureOptions).target||hn,o=n.level||0;let a=r.width,s=r.height;const u=n.internalFormat||n.format||vr,c=ni(u),l=n.format||c.format,f=n.type||c.type;if(zn(t,n),t.bindTexture(i,e),i===ln){const c=r.width,h=r.height;let d,g;if(c/6===h)d=h,g=[0,0,1,0,2,0,3,0,4,0,5,0];else if(h/6===c)d=c,g=[0,0,0,1,0,2,0,3,0,4,0,5];else if(c/3==h/2)d=c/3,g=[0,0,1,0,2,0,0,1,1,1,2,1];else{if(c/2!=h/3)throw"can't figure out cube map from element: "+(r.src?r.src:r.nodeName);d=c/2,g=[0,0,1,0,0,1,1,1,0,2,1,2]}const p=ba();p?(p.canvas.width=d,p.canvas.height=d,a=d,s=d,ko(t,n).forEach(function(e){const n=g[2*e.ndx+0]*d,i=g[2*e.ndx+1]*d;p.drawImage(r,n,i,d,d,0,0,d,d),t.texImage2D(e.face,o,u,l,f,p.canvas)}),p.canvas.width=1,p.canvas.height=1):typeof createImageBitmap<"u"&&(a=d,s=d,ko(t,n).forEach(function(c){const h=g[2*c.ndx+0]*d,p=g[2*c.ndx+1]*d;t.texImage2D(c.face,o,u,d,d,0,l,f,null),createImageBitmap(r,h,p,d,d,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(r){zn(t,n),t.bindTexture(i,e),t.texImage2D(c.face,o,u,l,f,r),Zn(n)&&Oo(t,e,n,a,s,u)})}))}else if(i===Tn||i===Sn){const e=Math.min(r.width,r.height),n=Math.max(r.width,r.height),a=n/e;if(a%1!=0)throw"can not compute 3D dimensions of element";const s=r.width===n?1:0,c=r.height===n?1:0;t.pixelStorei(es,1),t.pixelStorei(wa,r.width),t.pixelStorei(xa,0),t.pixelStorei(Aa,0),t.texImage3D(i,o,u,e,e,e,0,l,f,null);for(let n=0;n<a;++n){const a=n*e*s,u=n*e*c;t.pixelStorei(_a,a),t.pixelStorei(Ea,u),t.texSubImage3D(i,o,0,0,n,e,e,1,l,f,r)}Ta(t)}else t.texImage2D(i,o,u,l,f,r);Zn(n)&&Oo(t,e,n,a,s,u),Sa(t,e,n)}function ii(){}function r2(t){if(typeof document<"u"){const e=document.createElement("a");return e.href=t,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}{const e=new URL(location.href).origin;return new URL(t,location.href).origin===e}}function n2(t,e){return void 0!==e||r2(t)?e:"anonymous"}function i2(t,e,r){let n;if(r=r||ii,e=n2(t,e=void 0!==e?e:fn.crossOrigin),typeof Image<"u"){n=new Image,void 0!==e&&(n.crossOrigin=e);const i=function(){n.removeEventListener("error",o),n.removeEventListener("load",a),n=null},o=function(){const e="couldn't load image: "+t;fa(e),r(e,n),i()},a=function(){r(null,n),i()};return n.addEventListener("error",o),n.addEventListener("load",a),n.src=t,n}if(typeof ImageBitmap<"u"){let i,o;const a=function(){r(i,o)},s={};e&&(s.mode="cors"),fetch(t,s).then(function(t){if(!t.ok)throw t;return t.blob()}).then(function(t){return createImageBitmap(t,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(t){o=t,setTimeout(a)}).catch(function(t){i=t,setTimeout(a)}),n=null}return n}function Fa(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof ImageData<"u"&&t instanceof ImageData||typeof HTMLElement<"u"&&t instanceof HTMLElement}function ts(t,e,r){return Fa(t)?(setTimeout(function(){r(null,t)}),t):i2(t,e,r)}function rs(t,e,r){const n=(r=r||fn.textureOptions).target||hn;if(t.bindTexture(n,e),!1===r.color)return;const i=t2(r.color);if(n===ln)for(let e=0;e<6;++e)t.texImage2D(qo+e,0,vr,1,1,0,vr,dr,i);else n===Tn||n===Sn?t.texImage3D(n,0,vr,1,1,1,0,vr,dr,i):t.texImage2D(n,0,vr,1,1,0,vr,dr,i)}function o2(t,e,r,n){return n=n||ii,rs(t,e,r=r||fn.textureOptions),ts((r=Object.assign({},r)).src,r.crossOrigin,function(i,o){i?n(i,e,o):(Ra(t,e,o,r),n(null,e,o))})}function s2(t,e,r,n){n=n||ii;const i=r.src;if(6!==i.length)throw"there must be 6 urls for a cubemap";const o=r.level||0,a=r.internalFormat||r.format||vr,s=ni(a),u=r.format||s.format,c=r.type||dr,l=r.target||hn;if(l!==ln)throw"target must be TEXTURE_CUBE_MAP";rs(t,e,r),r=Object.assign({},r);let f=6;const h=[],d=Io(t,r);let g;g=i.map(function(i,s){return ts(i,r.crossOrigin,function(i){return function(s,d){--f,s?h.push(s):d.width!==d.height?h.push("cubemap face img is not a square: "+d.src):(zn(t,r),t.bindTexture(l,e),5===f?Io().forEach(function(e){t.texImage2D(e,o,a,u,c,d)}):t.texImage2D(i,o,a,u,c,d),Zn(r)&&t.generateMipmap(l)),0===f&&n(h.length?h:void 0,e,g)}}(d[s]))})}function a2(t,e,r,n){n=n||ii;const i=r.src,o=r.internalFormat||r.format||vr,a=ni(o),s=r.format||a.format,u=r.type||dr,c=r.target||Sn;if(c!==Tn&&c!==Sn)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";rs(t,e,r),r=Object.assign({},r);let l=i.length;const f=[];let h;const d=r.level||0;let g=r.width,p=r.height;const m=i.length;let y=!0;h=i.map(function(i,a){return ts(i,r.crossOrigin,function(i){return function(a,v){if(--l,a)f.push(a);else{if(zn(t,r),t.bindTexture(c,e),y){y=!1,g=r.width||v.width,p=r.height||v.height,t.texImage3D(c,d,o,g,p,m,0,s,u,null);for(let e=0;e<m;++e)t.texSubImage3D(c,d,0,0,e,g,p,1,s,u,v)}else{let e,r=v;(v.width!==g||v.height!==p)&&(e=ba(),r=e.canvas,e.canvas.width=g,e.canvas.height=p,e.drawImage(v,0,0,g,p)),t.texSubImage3D(c,d,0,0,i,g,p,1,s,u,r),e&&r===e.canvas&&(e.canvas.width=0,e.canvas.height=0)}Zn(r)&&t.generateMipmap(c)}0===l&&n(f.length?f:void 0,e,h)}}(a))})}function u2(t,e,r,n){const i=(n=n||fn.textureOptions).target||hn;t.bindTexture(i,e);let o=n.width,a=n.height,s=n.depth;const u=n.level||0,c=n.internalFormat||n.format||vr,l=ni(c),f=n.format||l.format,h=n.type||qf(t,r,l.type);if(Jn(r))r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));else{const t=la(h);r=new t(r)}const d=Qf(c,h),g=r.byteLength/d;if(g%1)throw"length wrong size for format: "+va(t,f);let p;if(i===Tn||i===Sn)if(o||a||s)!o||a&&s?!a||o&&s?(p=vi(t,i,o,a,g/s),o=p.width,a=p.height):(p=vi(t,i,o,s,g/a),o=p.width,s=p.height):(p=vi(t,i,a,s,g/o),a=p.width,s=p.height);else{const t=Math.cbrt(g);if(t%1!=0)throw"can't guess cube size of array of numElements: "+g;o=t,a=t,s=t}else p=vi(t,i,o,a,g),o=p.width,a=p.height;if(Ta(t),t.pixelStorei(es,n.unpackAlignment||1),zn(t,n),i===ln){const e=g/6*(d/r.BYTES_PER_ELEMENT);ko(t,n).forEach(n=>{const i=e*n.ndx,s=r.subarray(i,i+e);t.texImage2D(n.face,u,c,o,a,0,f,h,s)})}else i===Tn||i===Sn?t.texImage3D(i,u,c,o,a,s,0,f,h,r):t.texImage2D(i,u,c,o,a,0,f,h,r);return{width:o,height:a,depth:s,type:h}}function c2(t,e,r){const n=r.target||hn;t.bindTexture(n,e);const i=r.level||0,o=r.internalFormat||r.format||vr,a=ni(o),s=r.format||a.format,u=r.type||a.type;if(zn(t,r),n===ln)for(let e=0;e<6;++e)t.texImage2D(qo+e,i,o,r.width,r.height,0,s,u,null);else n===Tn||n===Sn?t.texImage3D(n,i,o,r.width,r.height,r.depth,0,s,u,null):t.texImage2D(n,i,o,r.width,r.height,0,s,u,null)}function Oa(t,e,r){r=r||ii,e=e||fn.textureOptions;const n=t.createTexture(),i=e.target||hn;let o=e.width||1,a=e.height||1;const s=e.internalFormat||vr;t.bindTexture(i,n),i===ln&&(t.texParameteri(i,Ji,Qi),t.texParameteri(i,Zi,Qi));let u=e.src;if(u)if("function"==typeof u&&(u=u(t,e)),"string"==typeof u)o2(t,n,e,r);else if(Jn(u)||Array.isArray(u)&&("number"==typeof u[0]||Array.isArray(u[0])||Jn(u[0]))){const r=u2(t,n,u,e);o=r.width,a=r.height}else Array.isArray(u)&&("string"==typeof u[0]||Fa(u[0]))?i===ln?s2(t,n,e,r):a2(t,n,e,r):(Ra(t,n,u,e),o=u.width,a=u.height);else c2(t,n,e);return Zn(e)&&Oo(t,n,e,o,a,s),Sa(t,n,e),n}const ns=fa;function Ia(t){return typeof document<"u"&&document.getElementById?document.getElementById(t):null}const qi=33984,no=34962,l2=34963,f2=35713,h2=35714,d2=35632,p2=35633,g2=35981,ka=35718,m2=35721,y2=35971,v2=35382,b2=35396,w2=35398,x2=35392,_2=35395,io=5126,Pa=35664,Ca=35665,Ma=35666,is=5124,La=35667,ja=35668,Ua=35669,Ba=35670,Na=35671,Da=35672,Ga=35673,Wa=35674,za=35675,Ha=35676,E2=35678,A2=35680,T2=35679,S2=35682,R2=35685,F2=35686,O2=35687,I2=35688,k2=35689,P2=35690,C2=36289,M2=36292,L2=36293,os=5125,Va=36294,$a=36295,Ya=36296,j2=36298,U2=36299,B2=36300,N2=36303,D2=36306,G2=36307,W2=36308,z2=36311,oo=3553,so=34067,ss=32879,ao=35866,gt={};function Xa(t,e){return gt[e].bindPoint}function H2(t,e){return function(r){t.uniform1f(e,r)}}function V2(t,e){return function(r){t.uniform1fv(e,r)}}function $2(t,e){return function(r){t.uniform2fv(e,r)}}function Y2(t,e){return function(r){t.uniform3fv(e,r)}}function X2(t,e){return function(r){t.uniform4fv(e,r)}}function Ka(t,e){return function(r){t.uniform1i(e,r)}}function Qa(t,e){return function(r){t.uniform1iv(e,r)}}function Ja(t,e){return function(r){t.uniform2iv(e,r)}}function Za(t,e){return function(r){t.uniform3iv(e,r)}}function qa(t,e){return function(r){t.uniform4iv(e,r)}}function K2(t,e){return function(r){t.uniform1ui(e,r)}}function Q2(t,e){return function(r){t.uniform1uiv(e,r)}}function J2(t,e){return function(r){t.uniform2uiv(e,r)}}function Z2(t,e){return function(r){t.uniform3uiv(e,r)}}function q2(t,e){return function(r){t.uniform4uiv(e,r)}}function e1(t,e){return function(r){t.uniformMatrix2fv(e,!1,r)}}function t1(t,e){return function(r){t.uniformMatrix3fv(e,!1,r)}}function r1(t,e){return function(r){t.uniformMatrix4fv(e,!1,r)}}function n1(t,e){return function(r){t.uniformMatrix2x3fv(e,!1,r)}}function i1(t,e){return function(r){t.uniformMatrix3x2fv(e,!1,r)}}function o1(t,e){return function(r){t.uniformMatrix2x4fv(e,!1,r)}}function s1(t,e){return function(r){t.uniformMatrix4x2fv(e,!1,r)}}function a1(t,e){return function(r){t.uniformMatrix3x4fv(e,!1,r)}}function u1(t,e){return function(r){t.uniformMatrix4x3fv(e,!1,r)}}function zr(t,e,r,n){const i=Xa(t,e);return ri(t)?function(e){let o,a;!e||Jo(t,e)?(o=e,a=null):(o=e.texture,a=e.sampler),t.uniform1i(n,r),t.activeTexture(qi+r),t.bindTexture(i,o),t.bindSampler(r,a)}:function(e){t.uniform1i(n,r),t.activeTexture(qi+r),t.bindTexture(i,e)}}function Hr(t,e,r,n,i){const o=Xa(t,e),a=new Int32Array(i);for(let t=0;t<i;++t)a[t]=r+t;return ri(t)?function(e){t.uniform1iv(n,a),e.forEach(function(e,n){let i,s;t.activeTexture(qi+a[n]),!e||Jo(t,e)?(i=e,s=null):(i=e.texture,s=e.sampler),t.bindSampler(r,s),t.bindTexture(o,i)})}:function(e){t.uniform1iv(n,a),e.forEach(function(e,r){t.activeTexture(qi+a[r]),t.bindTexture(o,e)})}}function uo(t,e){return function(r){if(r.value)switch(t.disableVertexAttribArray(e),r.value.length){case 4:t.vertexAttrib4fv(e,r.value);break;case 3:t.vertexAttrib3fv(e,r.value);break;case 2:t.vertexAttrib2fv(e,r.value);break;case 1:t.vertexAttrib1fv(e,r.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else t.bindBuffer(no,r.buffer),t.enableVertexAttribArray(e),t.vertexAttribPointer(e,r.numComponents||r.size,r.type||io,r.normalize||!1,r.stride||0,r.offset||0),t.vertexAttribDivisor&&t.vertexAttribDivisor(e,r.divisor||0)}}function dn(t,e){return function(r){if(r.value){if(t.disableVertexAttribArray(e),4!==r.value.length)throw new Error("The length of an integer constant value must be 4!");t.vertexAttrib4iv(e,r.value)}else t.bindBuffer(no,r.buffer),t.enableVertexAttribArray(e),t.vertexAttribIPointer(e,r.numComponents||r.size,r.type||is,r.stride||0,r.offset||0),t.vertexAttribDivisor&&t.vertexAttribDivisor(e,r.divisor||0)}}function co(t,e){return function(r){if(r.value){if(t.disableVertexAttribArray(e),4!==r.value.length)throw new Error("The length of an unsigned integer constant value must be 4!");t.vertexAttrib4uiv(e,r.value)}else t.bindBuffer(no,r.buffer),t.enableVertexAttribArray(e),t.vertexAttribIPointer(e,r.numComponents||r.size,r.type||os,r.stride||0,r.offset||0),t.vertexAttribDivisor&&t.vertexAttribDivisor(e,r.divisor||0)}}function as(t,e,r){const n=r.size,i=r.count;return function(r){t.bindBuffer(no,r.buffer);const o=r.size||r.numComponents||n,a=o/i,s=r.type||io,u=gt[s].size*o,c=r.normalize||!1,l=r.offset||0,f=u/i;for(let n=0;n<i;++n)t.enableVertexAttribArray(e+n),t.vertexAttribPointer(e+n,a,s,c,u,l+f*n),t.vertexAttribDivisor&&t.vertexAttribDivisor(e+n,r.divisor||0)}}gt[io]={Type:Float32Array,size:4,setter:H2,arraySetter:V2},gt[Pa]={Type:Float32Array,size:8,setter:$2,cols:2},gt[Ca]={Type:Float32Array,size:12,setter:Y2,cols:3},gt[Ma]={Type:Float32Array,size:16,setter:X2,cols:4},gt[is]={Type:Int32Array,size:4,setter:Ka,arraySetter:Qa},gt[La]={Type:Int32Array,size:8,setter:Ja,cols:2},gt[ja]={Type:Int32Array,size:12,setter:Za,cols:3},gt[Ua]={Type:Int32Array,size:16,setter:qa,cols:4},gt[os]={Type:Uint32Array,size:4,setter:K2,arraySetter:Q2},gt[Va]={Type:Uint32Array,size:8,setter:J2,cols:2},gt[$a]={Type:Uint32Array,size:12,setter:Z2,cols:3},gt[Ya]={Type:Uint32Array,size:16,setter:q2,cols:4},gt[Ba]={Type:Uint32Array,size:4,setter:Ka,arraySetter:Qa},gt[Na]={Type:Uint32Array,size:8,setter:Ja,cols:2},gt[Da]={Type:Uint32Array,size:12,setter:Za,cols:3},gt[Ga]={Type:Uint32Array,size:16,setter:qa,cols:4},gt[Wa]={Type:Float32Array,size:32,setter:e1,rows:2,cols:2},gt[za]={Type:Float32Array,size:48,setter:t1,rows:3,cols:3},gt[Ha]={Type:Float32Array,size:64,setter:r1,rows:4,cols:4},gt[R2]={Type:Float32Array,size:32,setter:n1,rows:2,cols:3},gt[F2]={Type:Float32Array,size:32,setter:o1,rows:2,cols:4},gt[O2]={Type:Float32Array,size:48,setter:i1,rows:3,cols:2},gt[I2]={Type:Float32Array,size:48,setter:a1,rows:3,cols:4},gt[k2]={Type:Float32Array,size:64,setter:s1,rows:4,cols:2},gt[P2]={Type:Float32Array,size:64,setter:u1,rows:4,cols:3},gt[E2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:oo},gt[A2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:so},gt[T2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:ss},gt[S2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:oo},gt[C2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:ao},gt[M2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:ao},gt[L2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:so},gt[j2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:oo},gt[U2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:ss},gt[B2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:so},gt[N2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:ao},gt[D2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:oo},gt[G2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:ss},gt[W2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:so},gt[z2]={Type:null,size:0,setter:zr,arraySetter:Hr,bindPoint:ao};const Ir={};Ir[io]={size:4,setter:uo},Ir[Pa]={size:8,setter:uo},Ir[Ca]={size:12,setter:uo},Ir[Ma]={size:16,setter:uo},Ir[is]={size:4,setter:dn},Ir[La]={size:8,setter:dn},Ir[ja]={size:12,setter:dn},Ir[Ua]={size:16,setter:dn},Ir[os]={size:4,setter:co},Ir[Va]={size:8,setter:co},Ir[$a]={size:12,setter:co},Ir[Ya]={size:16,setter:co},Ir[Ba]={size:4,setter:dn},Ir[Na]={size:8,setter:dn},Ir[Da]={size:12,setter:dn},Ir[Ga]={size:16,setter:dn},Ir[Wa]={size:4,setter:as,count:2},Ir[za]={size:9,setter:as,count:3},Ir[Ha]={size:16,setter:as,count:4};const c1=/ERROR:\s*\d+:(\d+)/gi;function l1(t,e="",r=0){const n=[...e.matchAll(c1)],i=new Map(n.map((t,r)=>{const i=parseInt(t[1]),o=n[r+1],a=o?o.index:e.length;return[i-1,e.substring(t.index,a)]}));return t.split("\n").map((t,e)=>{const n=i.get(e);return`${e+1+r}: ${t}${n?`\n\n^^^ ${n}`:""}`}).join("\n")}const Vs=/^[ \t]*\n/;function eu(t){let e=0;return Vs.test(t)&&(e=1,t=t.replace(Vs,"")),{lineOffset:e,shaderSource:t}}function f1(t,e){return t.errorCallback(e),t.callback&&setTimeout(()=>{t.callback(`${e}\n${t.errors.join("\n")}`)}),null}function h1(t,e,r,n){if(n=n||ns,!t.getShaderParameter(r,f2)){const i=t.getShaderInfoLog(r),{lineOffset:o,shaderSource:a}=eu(t.getShaderSource(r)),s=`${l1(a,i,o)}\nError compiling ${va(t,e)}: ${i}`;return n(s),s}return""}function us(t,e,r){let n,i,o;if("function"==typeof e&&(r=e,e=void 0),"function"==typeof t)r=t,t=void 0;else if(t&&!Array.isArray(t)){const e=t;r=e.errorCallback,t=e.attribLocations,n=e.transformFeedbackVaryings,i=e.transformFeedbackMode,o=e.callback}const a=r||ns,s=[],u={errorCallback(t,...e){s.push(t),a(t,...e)},transformFeedbackVaryings:n,transformFeedbackMode:i,callback:o,errors:s};{let r={};Array.isArray(t)?t.forEach(function(t,n){r[t]=e?e[n]:n}):r=t||{},u.attribLocations=r}return u}const d1=["VERTEX_SHADER","FRAGMENT_SHADER"];function p1(t,e){return e.indexOf("frag")>=0?d2:e.indexOf("vert")>=0?p2:void 0}function g1(t,e,r){const n=t.getAttachedShaders(e);for(const e of n)r.has(e)&&t.deleteShader(e);t.deleteProgram(e)}const m1=(t=0)=>new Promise(e=>setTimeout(e,t));function y1(t,e,r){const n=t.createProgram(),{attribLocations:i,transformFeedbackVaryings:o,transformFeedbackMode:a}=us(r);for(let r=0;r<e.length;++r){let i=e[r];if("string"==typeof i){const e=Ia(i),o=e?e.text:i;let a=t[d1[r]];e&&e.type&&(a=p1(t,e.type)||a),i=t.createShader(a),t.shaderSource(i,eu(o).shaderSource),t.compileShader(i),t.attachShader(n,i)}}Object.entries(i).forEach(([e,r])=>t.bindAttribLocation(n,r,e));{let e=o;e&&(e.attribs&&(e=e.attribs),Array.isArray(e)||(e=Object.keys(e)),t.transformFeedbackVaryings(n,e,a||g2))}return t.linkProgram(n),n}function v1(t,e,r,n,i){const o=us(r,n,i),a=new Set(e),s=y1(t,e,o);function u(t,e){const r=w1(t,e,o.errorCallback);return r&&g1(t,e,a),r}if(!o.callback)return u(t,s)?void 0:s;b1(t,s).then(()=>{const e=u(t,s);o.callback(e,e?void 0:s)})}async function b1(t,e){const r=t.getExtension("KHR_parallel_shader_compile"),n=r?(t,e)=>t.getProgramParameter(e,r.COMPLETION_STATUS_KHR):()=>!0;let i=0;do{await m1(i),i=1e3/60}while(!n(t,e))}function w1(t,e,r){if(r=r||ns,!t.getProgramParameter(e,h2)){const n=t.getProgramInfoLog(e);r(`Error in program linking: ${n}`);return`${n}\n${t.getAttachedShaders(e).map(e=>h1(t,t.getShaderParameter(e,t.SHADER_TYPE),e,r)).filter(t=>t).join("\n")}`}}function x1(t,e,r,n,i){return v1(t,e,r,n,i)}function tu(t){const e=t.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const _1=/(\.|\[|]|\w+)/g,E1=t=>t>="0"&&t<="9";function A1(t,e,r,n){const i=t.split(_1).filter(t=>""!==t);let o=0,a="";for(;;){const t=i[o++];a+=t;const s=E1(t[0]),u=s?parseInt(t):t;if(s&&(a+=i[o++]),o===i.length){r[u]=e;break}{const t=i[o++],e="["===t,s=r[u]||(e?[]:{});r[u]=s,r=s,n[a]=n[a]||function(t){return function(e){ru(t,e)}}(s),a+=t}}}function T1(t,e){let r=0;function n(e,n,i){const o=n.name.endsWith("[0]"),a=n.type,s=gt[a];if(!s)throw new Error(`unknown type: 0x${a.toString(16)}`);let u;if(s.bindPoint){const e=r;r+=n.size,u=o?s.arraySetter(t,a,e,i,n.size):s.setter(t,a,e,i,n.size)}else u=s.arraySetter&&o?s.arraySetter(t,i):s.setter(t,i);return u.location=i,u}const i={},o={},a=t.getProgramParameter(e,ka);for(let r=0;r<a;++r){const a=t.getActiveUniform(e,r);if(tu(a))continue;let s=a.name;s.endsWith("[0]")&&(s=s.substr(0,s.length-3));const u=t.getUniformLocation(e,a.name);if(u){const t=n(0,a,u);i[s]=t,A1(s,t,o,i)}}return i}function S1(t,e){const r={},n=t.getProgramParameter(e,y2);for(let i=0;i<n;++i){const n=t.getTransformFeedbackVarying(e,i);r[n.name]={index:i,type:n.type,size:n.size}}return r}function R1(t,e){const r=t.getProgramParameter(e,ka),n=[],i=[];for(let o=0;o<r;++o){i.push(o),n.push({});const r=t.getActiveUniform(e,o);n[o].name=r.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(r){const o=r[0],a=r[1];t.getActiveUniforms(e,i,t[o]).forEach(function(t,e){n[e][a]=t})});const o={},a=t.getProgramParameter(e,v2);for(let r=0;r<a;++r){const n=t.getActiveUniformBlockName(e,r),i={index:t.getUniformBlockIndex(e,n),usedByVertexShader:t.getActiveUniformBlockParameter(e,r,b2),usedByFragmentShader:t.getActiveUniformBlockParameter(e,r,w2),size:t.getActiveUniformBlockParameter(e,r,x2),uniformIndices:t.getActiveUniformBlockParameter(e,r,_2)};i.used=i.usedByVertexShader||i.usedByFragmentShader,o[n]=i}return{blockSpecs:o,uniformData:n}}function ru(t,e){for(const r in e){const n=t[r];"function"==typeof n?n(e[r]):ru(t[r],e[r])}}function nu(t,...e){const r=t.uniformSetters||t,n=e.length;for(let t=0;t<n;++t){const n=e[t];if(Array.isArray(n)){const t=n.length;for(let e=0;e<t;++e)nu(r,n[e])}else for(const t in n){const e=r[t];e&&e(n[t])}}}function F1(t,e){const r={},n=t.getProgramParameter(e,m2);for(let i=0;i<n;++i){const n=t.getActiveAttrib(e,i);if(tu(n))continue;const o=t.getAttribLocation(e,n.name),a=Ir[n.type],s=a.setter(t,o,a);s.location=o,r[n.name]=s}return r}function O1(t,e){for(const r in e){const n=t[r];n&&n(e[r])}}function I1(t,e,r){r.vertexArrayObject?t.bindVertexArray(r.vertexArrayObject):(O1(e.attribSetters||e,r.attribs),r.indices&&t.bindBuffer(l2,r.indices))}function $s(t,e){const r={program:e,uniformSetters:T1(t,e),attribSetters:F1(t,e)};return ri(t)&&(r.uniformBlockSpec=R1(t,e),r.transformFeedbackInfo=S1(t,e)),r}const k1=/\s|{|}|;/;function P1(t,e,r,n,i){const o=us(r,n,i),a=[];if(e=e.map(function(t){if(!k1.test(t)){const e=Ia(t);if(e)t=e.text;else{const e=`no element with id: ${t}`;o.errorCallback(e),a.push(e)}}return t}),a.length)return f1(o,"");const s=o.callback;s&&(o.callback=(e,r)=>{s(e,e?void 0:$s(t,r))});const u=x1(t,e,o);return u?$s(t,u):null}const C1=4,Ys=5123;function M1(t,e,r,n,i,o){r=void 0===r?4:r;const a=e.indices,s=e.elementType,u=void 0===n?e.numElements:n;i=void 0===i?0:i,s||a?void 0!==o?t.drawElementsInstanced(r,u,void 0===s?Ys:e.elementType,i,o):t.drawElements(r,u,void 0===s?Ys:e.elementType,i):void 0!==o?t.drawArraysInstanced(r,i,u,o):t.drawArrays(r,i,u)}const iu=36160,bi=36161,L1=3553,j1=5121,U1=6402,B1=6408,N1=33190,D1=36012,G1=35056,W1=36013,z1=32854,H1=32855,V1=36194,ou=33189,su=6401,au=36168,cs=34041,Po=36064,lo=36096,uu=36128,ls=33306,Co=33071,Mo=9729,$1=[{format:B1,type:j1,min:Mo,wrap:Co},{format:cs}],Kr={};function Y1(t,e){return Kr[t]||Kr[e]}Kr[cs]=ls,Kr[su]=uu,Kr[au]=uu,Kr[U1]=lo,Kr[ou]=lo,Kr[N1]=lo,Kr[D1]=lo,Kr[G1]=ls,Kr[W1]=ls;const pn={};function X1(t){return pn[t]}pn[z1]=!0,pn[H1]=!0,pn[V1]=!0,pn[cs]=!0,pn[ou]=!0,pn[su]=!0,pn[au]=!0;const K1=32;function Q1(t){return t>=Po&&t<36096}function Xs(t,e,r,n){const i=iu,o=t.createFramebuffer();t.bindFramebuffer(i,o),r=r||t.drawingBufferWidth,n=n||t.drawingBufferHeight;const a=[],s={framebuffer:o,attachments:[],width:r,height:n};return(e=e||$1).forEach(function(e,o){let u=e.attachment;const c=e.samples,l=e.format;let f=e.attachmentPoint||Y1(l,e.internalFormat);if(f||(f=Po+o),Q1(f)&&a.push(f),!u)if(void 0!==c||X1(l))u=t.createRenderbuffer(),t.bindRenderbuffer(bi,u),c>1?t.renderbufferStorageMultisample(bi,c,l,r,n):t.renderbufferStorage(bi,l,r,n);else{const i=Object.assign({},e);i.width=r,i.height=n,void 0===i.auto&&(i.auto=!1,i.min=i.min||i.minMag||Mo,i.mag=i.mag||i.minMag||Mo,i.wrapS=i.wrapS||i.wrap||Co,i.wrapT=i.wrapT||i.wrap||Co),u=Oa(t,i)}if(il(t,u))t.framebufferRenderbuffer(i,f,bi,u);else{if(!Jo(t,u))throw new Error("unknown attachment type");void 0!==e.layer?t.framebufferTextureLayer(i,f,u,e.level||0,e.layer):t.framebufferTexture2D(i,f,e.target||L1,u,e.level||0)}s.attachments.push(u)}),t.drawBuffers&&t.drawBuffers(a),s}function J1(t,e,r){r=r||iu,e?(t.bindFramebuffer(r,e.framebuffer),t.viewport(0,0,e.width,e.height)):(t.bindFramebuffer(r,null),t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight))}function Wr(t,e){return()=>e instanceof WebGLTexture?e:Oa(t,{src:e,wrap:t.CLAMP_TO_EDGE})}const Dn=2;class oi{constructor(t){this.id="_";const{context:e,width:r,height:n}=t;this.context=e,this.options=t;const i=this.buildDefines();this.programInfo=P1(this.context,[i+this.getVertexShader(),i+this.getFragmentShader()]),this.bufferInfo=Fl(this.context,this.getBuffers()),this.fbi=Xs(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],r,n),this.output=this.fbi.attachments[0]}resizeOutput(t,e){this.fbi=Xs(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],t,e),this.options.width=t,this.options.height=e,this.output=this.fbi.attachments[0]}getDefines(){return{}}getBuffers(){return{position:{numComponents:2,data:[-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]},texture_coord:{numComponents:2,data:[0,0,0,1,1,0,1,1,0,1,1,0]}}}buildDefines(){let t="";const e=this.getDefines();for(let r in e)t+=`#define ${r} ${e[r].toFixed(1)}\n`;return t}run(t){this.profiler?.pushContext(`[${this.id}] PROG : ${this.constructor.name}`),this.profiler?.pushContext(`[${this.id}] UNIFORMS`);for(const e in t)"function"==typeof t[e]&&(this.profiler?.pushContext(`[${this.id}] UNI : ${e}`),t[e]=t[e](),this.profiler?.popContext(`[${this.id}] UNI : ${e}`));this.profiler?.popContext(`[${this.id}] UNIFORMS`);const e=Date.now();let r=0;this.lastRun&&(r=(e-this.lastRun)/1e3),this.lastRun=e,this.context.viewport(0,0,this.context.canvas.width,this.context.canvas.height),this.context.useProgram(this.programInfo.program),I1(this.context,this.programInfo,this.bufferInfo),nu(this.programInfo,{delta:r,canvas:[this.context.canvas.width,this.context.canvas.height],...t}),J1(this.context,this.options.disableFramebuffer?null:this.fbi),M1(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(t){this.profiler=t}}const Z1="precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform sampler2D background;\nuniform sampler2D foreground;\nuniform sampler2D threshold;\n\nvoid main() {\n vec4 backgroundColor = texture2D(background, _texture_coord);\n vec4 foregroundColor = texture2D(foreground, _texture_coord);\n vec4 tresholdColor = texture2D(threshold, _texture_coord);\n gl_FragColor = foregroundColor * tresholdColor.a +\n backgroundColor * (1. - tresholdColor.a);\n}\n",q1="varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n _texture_coord.y = 1. - texture_coord.y;\n}\n";class fs extends oi{getFragmentShader(){return Z1}getVertexShader(){return q1}}class hs{constructor(){this.steps=[]}addStep(t){this.steps.push(t)}async run(){for(const t of this.steps)t.program.run(t.getUniforms())}resizeOutput(t,e){this.profiler?.pushContext(`PIP [${this.constructor.name}]`);for(const r of this.steps)r.preventResize||r.program.resizeOutput(t,e);this.profiler?.popContext(`PIP [${this.constructor.name}]`)}setProfiler(t){this.profiler=t;for(const e of this.steps)e.program.setProfiler(t)}setId(t){for(const e of this.steps)e.program.id=t}}class ds extends hs{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class cu extends ds{constructor(t){super(),this.context=t,this.preciseMaskEnabled=!0;const e={context:t,height:t.canvas.height,width:t.canvas.width},r=new fs({...e,disableFramebuffer:!0});this.addStep({program:r,getUniforms:()=>({background:Wr(t,this.inputBackgroundImage),foreground:Wr(t,this.inputImage),threshold:Wr(t,this.inputMask)})})}setData(t,e){this.inputImage=t,this.inputMask=e}}const e3="precision mediump float;\n\nvarying vec2 _texture_coord;\nuniform sampler2D texture;\n\nvoid main() { gl_FragColor = texture2D(texture, _texture_coord); }\n",t3="varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\nuniform bool invert_y;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n if (invert_y) {\n _texture_coord.y = 1. - texture_coord.y;\n }\n}\n";class r3 extends oi{getFragmentShader(){return e3}getVertexShader(){return t3}}class n3 extends hs{constructor(t,e,r){super(),this.context=t;const n={context:t,height:r,width:e};this.addStep({program:new r3({...n,disableFramebuffer:!0}),getUniforms:()=>({texture:Wr(t,this.inputImage),invert_y:!0})})}setData(t){this.inputImage=t}}async function lu(t){return new Promise(e=>{setTimeout(()=>{e()},t)})}const i3="precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n",o3="varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n";var ps=(t=>(t[t.LINEAR=0]="LINEAR",t[t.GAUSSIAN=1]="GAUSSIAN",t))(ps||{});class fu extends oi{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return i3+this.createLoopFunction()}getVertexShader(){return o3}createLoopFunction(){let t=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${t}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n\n for(int y=-${t}; y<${t+1}; ++y) {\n for(int x=-${t}; x<${t+1}; ++x) {\n float factor = 1.;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}getFactor(t,e){return this.options.type,this.getLinearFactor(t,e)}getLinearFactor(t,e){return 1}getGaussianFactor(t,e){const r=1/(2*Math.PI*Math.max(this.options.radius??1,1)**2),n=r*-(t**2+e**2);return r*Math.E**n}}const s3="#version 300 es\n// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts\n\nprecision highp float;\nuniform sampler2D input_frame;\nuniform sampler2D segmentation_mask;\nuniform sampler2D threshold;\nuniform vec2 texel_size;\nuniform float step;\nuniform float radius;\nuniform float offset;\nuniform float sigma_texel;\nuniform float sigma_color;\n\nin vec2 _texture_coord;\nout vec4 outColor;\n\nfloat gaussian(float x, float sigma) {\n float coeff = -0.5 / (sigma * sigma * 4.0 + 1.0e-6);\n return exp((x * x) * coeff);\n}\n\nvoid main() {\n vec2 centerCoord = _texture_coord;\n vec3 centerColor = texture(input_frame, centerCoord).rgb;\n float newVal = 0.0;\n float spaceWeight = 0.0;\n float colorWeight = 0.0;\n float totalWeight = 0.0;\n // Subsample kernel space.\n for (float i = -radius + offset; i <= radius; i += step) {\n for (float j = -radius + offset; j <= radius; j += step) {\n vec2 shift = vec2(j, i) * texel_size;\n vec2 coord = vec2(centerCoord + shift);\n vec3 frameColor = texture(input_frame, coord).rgb;\n float threshold = texture(threshold, coord).a;\n float outVal = texture(segmentation_mask, coord).a;\n\n spaceWeight = gaussian(distance(centerCoord, coord), sigma_texel);\n colorWeight = gaussian(distance(centerColor, frameColor), sigma_color);\n totalWeight += spaceWeight * colorWeight;\n newVal += spaceWeight * colorWeight * outVal * threshold;\n }\n }\n newVal /= totalWeight;\n outColor = vec4(vec3(0.), newVal);\n}",a3="#version 300 es\nin vec2 position;\nin vec2 texture_coord;\nout vec2 _texture_coord;\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n _texture_coord = texture_coord;\n}";class u3 extends oi{getFragmentShader(){return s3}getVertexShader(){return a3}}class c3 extends hs{constructor(t,e,r){super(),this.context=t;const n={context:t,height:r,width:e},i=new fu({...n,radius:1,type:ps.GAUSSIAN});this.jointBilateral=new u3(n),this.addStep({program:i,getUniforms:()=>({inputs:Wr(t,this.inputMask)})}),this.addStep({program:this.jointBilateral,getUniforms:()=>{const e=this.inputImage?.width??1,r=this.inputImage?.height??1;this.inputMask,this.inputMask;const n=Math.max(1,.66*Math.sqrt(3)),i=1/e,o=1/r;return{input_frame:Wr(t,this.inputImage),segmentation_mask:Wr(t,this.inputMask),texel_size:[i,o],step:n,radius:3,offset:n>1?.5*n:0,sigma_texel:3*Math.max(i,o),sigma_color:3}}}),this.output=this.jointBilateral.output}setData(t,e){this.previousInputImage=this.inputImage?this.inputImage:t,this.previousInputMask=this.inputMask?this.inputMask:e,this.inputImage=t,this.inputMask=e}resizeOutput(t,e){super.resizeOutput(t,e),this.output=this.jointBilateral.output}}var hu=(t=>(t.PUSH="PUSH",t.POP="POP",t))(hu||{});class l3{constructor(t){this.queries=[],this.context=t,this.extension=t.getExtension("EXT_disjoint_timer_query_webgl2")}start(){}stop(){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT)}pushContext(t){this.createQuery("PUSH",t)}popContext(t){this.createQuery("POP",t)}createQuery(t,e){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT),this.activeQuery=this.context.createQuery(),this.context.beginQuery(this.extension.TIME_ELAPSED_EXT,this.activeQuery),this.queries.push({name:e,action:t,query:this.activeQuery})}async getResolvedQueries(){const t=(await Promise.all([...this.queries].map(t=>this.resolveQuery(t)))).filter(t=>t);for(let e=1;e<t.length;++e)t[e].timestamp+=t[e-1].duration+t[e-1].timestamp;return t}async resolveQuery(t){if(await this.awaitQueryAvailable(t)){if(!this.context.getParameter(this.extension.GPU_DISJOINT_EXT))return{...t,duration:this.context.getQueryParameter(t.query,this.context.QUERY_RESULT),timestamp:0};console.log("Disjointed query",t)}else console.log("Unawaitable query",t)}async awaitQueryAvailable(t){for(let e=0;e<10;++e){if(this.context.getQueryParameter(t.query,this.context.QUERY_RESULT_AVAILABLE))return t;await lu(200)}}}class fo{constructor(){this.previousImageWidth=0,this.previousImageHeight=0,this.previousMaskWidth=2,this.previousMaskHeight=2,this.postProcessingEnabled=!0;const t=new OffscreenCanvas(0,0),e=t.getContext("webgl2");if(!e)throw"Fail to retrieve webgl2 context";this.canvas=t,this.context=e,this.improveMask=new c3(this.context,2,2)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(t){const e=new l3(this.context);return this.profiler=e,e.start(),await lu(t),this.profiler=void 0,e.stop(),e.getResolvedQueries()}async render(t,e){if(!this.pipeline)throw"missing pipeline";(this.previousImageHeight!==t.height||this.previousImageWidth!==t.width)&&this.resizeOutput(t.width,t.height),(this.previousMaskHeight!==e.height||this.previousMaskWidth!==e.width)&&(this.improveMask.resizeOutput(e.width,e.height),this.previousMaskWidth=e.width,this.previousMaskHeight=e.height);const r="renderer";this.profiler?.pushContext(r),this.improveMask.setProfiler(this.profiler),this.pipeline.setProfiler(this.profiler);const n=await createImageBitmap(e);let i=n;return this.postProcessingEnabled&&(this.improveMask.setData(t,n),this.improveMask.run(),i=this.improveMask.output),this.pipeline.setData(t,i),await this.pipeline.run(),this.profiler?.popContext(r),this.canvas}resizeOutput(t,e){this.canvas.width=t,this.canvas.height=e,this.pipeline?.resizeOutput(t,e),this.previousImageWidth=t,this.previousImageHeight=e}destroy(){const t=this.context?.getExtension("WEBGL_lose_context");t&&t.loseContext()}}class du extends fo{constructor(){super(),this.pipeline=new cu(this.context);const t=new OffscreenCanvas(0,0),e=t.getContext("webgl2");if(!e)throw"Fail to retrieve webgl context";this.backgroundImageResizerCanvas=t,this.backgroundImageResizerContext=e,this.backgroundImageResizer=new n3(this.backgroundImageResizerContext,0,0)}setBackgroundImage(t){this.backgroundImage=t,this.updateBackgroundImage()}updateBackgroundImage(){const{width:t,height:e}=this.canvas;this.backgroundImageResizer.resizeOutput(t,e),this.backgroundImageResizer.setData(this.backgroundImage),this.backgroundImageResizer.run(),this.pipeline.inputBackgroundImage=this.backgroundImageResizerCanvas}resizeOutput(t,e){super.resizeOutput(t,e),this.backgroundImageResizerCanvas.width=t,this.backgroundImageResizerCanvas.height=e,this.backgroundImageResizer.resizeOutput(t,e),this.updateBackgroundImage()}destroy(){const t=this.backgroundImageResizerContext?.getExtension("WEBGL_lose_context");t&&t.loseContext(),super.destroy()}}class f3 extends du{setBackgroundVideo(t){this.frameReader=t}async render(t,e){return await this.readNextVideoFrame(),super.render(t,e)}async readNextVideoFrame(){const t=await(this.frameReader?.read());if(t?.value){const e=await createImageBitmap(t.value);this.setBackgroundImage(e),t.value.close()}}}class Ks{blurBackground(t){return new Vc(t)}blurSilhouette(t){return new $c(t)}imageBackground(){return new Yc}videoBackground(){return new f3}}const h3="precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\nuniform sampler2D mask;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n",d3="varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n";class p3 extends oi{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return h3+this.createLoopFunction()}getVertexShader(){return d3}createLoopFunction(){let t=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${t}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n float maxLength = length(normalizedRadius);\n\n for(int y=-${t}; y<${t+1}; ++y) {\n for(int x=-${t}; x<${t+1}; ++x) {\n float factor = (1.- texture2D(mask, _texture_coord + diff).a) * (maxLength - length(diff)) / maxLength;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}const g3=10,m3=2,y3=8;class v3 extends ds{constructor(t,e){super(),this.context=t,this.radius=e;const r={context:t,height:t.canvas.height,width:t.canvas.width};this.blur=new p3({...r,radius:e,...this.getBlurTextureSize(t.canvas.width,t.canvas.height)});const n=new fs({...r,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:Wr(t,this.inputImage),mask:Wr(t,this.inputMask)})}),this.addStep({program:n,getUniforms:()=>({background:Wr(t,this.blur.output),foreground:Wr(t,this.inputImage),threshold:Wr(t,this.inputMask)})})}getBlurTextureSize(t,e){const r=this.radius>10?8:2;return{width:Math.max(2,t/r),height:Math.max(2,e/r)}}setData(t,e){this.inputImage=t,this.inputMask=e}resizeOutput(t,e){super.resizeOutput(t,e);const r=this.getBlurTextureSize(t,e);this.blur.resizeOutput(r.width,r.height)}}class b3 extends fo{constructor(t){super(),this.pipeline=new v3(this.context,t),this.disablePostProcessing()}}class w3 extends ds{constructor(t,e){super(),this.context=t;const r={context:t,height:t.canvas.height,width:t.canvas.width},n=new fu({...r,radius:e,type:ps.GAUSSIAN}),i=new fs({...r,disableFramebuffer:!0});this.addStep({program:n,getUniforms:()=>({texture:Wr(t,this.inputImage)})}),this.addStep({program:i,getUniforms:()=>({background:Wr(t,this.inputImage),foreground:Wr(t,n.output),threshold:Wr(t,this.inputMask)})})}setData(t,e){this.inputImage=t,this.inputMask=e}}class x3 extends fo{constructor(t){super(),this.pipeline=new w3(this.context,t),this.disablePostProcessing()}}class _3 extends cu{constructor(){super(...arguments),this.preciseMaskEnabled=!0}set reader(t){this.frameReader=t}async run(){this.frameReader&&(await this.readNextVideoFrame(),await super.run())}async readNextVideoFrame(){const t=await(this.frameReader?.read());t?.value&&(this.inputBackgroundImage=await createImageBitmap(t.value),t.value.close())}}class E3 extends fo{constructor(){super(),this.pipeline=new _3(this.context)}setBackgroundVideo(t){this.pipeline.reader=t}}class Qs{blurBackground(t){return new b3(t)}blurSilhouette(t){return new x3(t)}imageBackground(){return new du}videoBackground(){return new E3}}class A3{constructor(t){switch(t){case Oi.CANVAS:this.factory=new Ks;break;case Oi.WEBGL:this.factory=new Qs;break;default:const t=na();this.factory=t.supported?new Qs:new Ks}}blurBackground(t){return this.getFactory().blurBackground(t)}blurSilhouette(t){return this.getFactory().blurSilhouette(t)}imageBackground(){return this.getFactory().imageBackground()}videoBackground(){return this.getFactory().videoBackground()}getFactory(){if(!this.factory)throw"Factory is not initialized";return this.factory}}class T3{setBackgroundOptions(t){this.renderer&&this.renderer.destroy();const e=new A3(t.renderingOptions?.type);switch(t.transformerType){case"BackgroundBlur":this.renderer=e.blurBackground(this.getBlurSize(t.radius));break;case"SilhouetteBlur":this.renderer=e.blurSilhouette(this.getBlurSize(t.radius));break;case"VideoBackground":const r=e.videoBackground();this.backgroundVideo&&r.setBackgroundVideo(this.backgroundVideo),this.renderer=r;break;case"VirtualBackground":const n=e.imageBackground();this.backgroundImage&&n.setBackgroundImage(this.backgroundImage),this.renderer=n;break;default:throw`Unknown rendering type [${t.transformerType}]`}t.renderingOptions?.type===Oi.WEBGL&&(t.renderingOptions.selfieSegmentationType===To.PRECISE?this.renderer.enablePostProcessing():t.renderingOptions.selfieSegmentationType===To.FAST&&this.renderer.disablePostProcessing())}setVideoBGReadable(t){this.backgroundVideo=t.getReader();const e=this.renderer;e?.setBackgroundVideo&&e.setBackgroundVideo(this.backgroundVideo)}async setVirtualBGImage(t){const e=this.renderer;e?.setBackgroundImage&&e.setBackgroundImage(t),this.backgroundImage=t}async process(t,e){if(this.renderer)return this.renderer.render(t,e)}async resizeForeground(t,e){}getBlurSize(t=_i.Low){switch(t){case _i.Low:return 5;case _i.High:return 12}return t}async profile(t){return this.renderer?.profileWebgl(t)??[]}}var S3=function(){var t=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(e){var r,n,i=typeof(e=e||{})<"u"?e:{};i.ready=new Promise(function(t,e){r=t,n=e});var o,a={};for(o in i)i.hasOwnProperty(o)&&(a[o]=i[o]);var s="./this.program",u=function(t,e){throw e},c="";typeof document<"u"&&document.currentScript&&(c=document.currentScript.src),t&&(c=t),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var l,f=i.print||console.log.bind(console),h=i.printErr||console.warn.bind(console);for(o in a)a.hasOwnProperty(o)&&(i[o]=a[o]);a=null,i.arguments&&i.arguments,i.thisProgram&&(s=i.thisProgram),i.quit&&(u=i.quit),i.wasmBinary&&(l=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&P("no native wasm support detected");var d,g,p,m,y,v=!1,b=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function w(t,e,r){for(var n=e+r,i=e;t[i]&&!(i>=n);)++i;if(i-e>16&&t.subarray&&b)return b.decode(t.subarray(e,i));for(var o="";e<i;){var a=t[e++];if(128&a){var s=63&t[e++];if(192!=(224&a)){var u=63&t[e++];if((a=224==(240&a)?(15&a)<<12|s<<6|u:(7&a)<<18|s<<12|u<<6|63&t[e++])<65536)o+=String.fromCharCode(a);else{var c=a-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&a)<<6|s)}else o+=String.fromCharCode(a)}return o}function x(t,e){return t?w(m,t,e):""}function A(t,e){return t%e>0&&(t+=e-t%e),t}function _(t){g=t,i.HEAP8=p=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAP32=y=new Int32Array(t),i.HEAPU8=m=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAPU32=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}i.INITIAL_MEMORY;var E,T=[],k=[],S=[];function F(t){T.unshift(t)}function O(t){S.unshift(t)}var R=0,I=null;function P(t){i.onAbort&&i.onAbort(t),h(t="Aborted("+t+")"),v=!0,t+=". Build with -s ASSERTIONS=1 for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}i.preloadedImages={},i.preloadedAudios={};var j,C,M;function L(t){return t.startsWith("data:application/octet-stream;base64,")}function B(t){try{if(t==j&&l)return new Uint8Array(l);throw"both async and sync fetching of the wasm failed"}catch(t){P(t)}}function U(t){for(;t.length>0;){var e=t.shift();if("function"!=typeof e){var r=e.func;"number"==typeof r?void 0===e.arg?E.get(r)():E.get(r)(e.arg):r(void 0===e.arg?null:e.arg)}else e(i)}}L(j="tflite-simd.wasm")||(C=j,j=i.locateFile?i.locateFile(C,c):c+C),M=function(){return performance.now()};function N(t){try{return d.grow(t-g.byteLength+65535>>>16),_(d.buffer),1}catch{}}var D={};function z(){if(!z.strings){var t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:s||"./this.program"};for(var e in D)void 0===D[e]?delete t[e]:t[e]=D[e];var r=[];for(var e in t)r.push(e+"="+t[e]);z.strings=r}return z.strings}var G={mappings:{},buffers:[null,[],[]],printChar:function(t,e){var r=G.buffers[t];0===e||10===e?((1===t?f:h)(w(r,0)),r.length=0):r.push(e)},varargs:void 0,get:function(){return G.varargs+=4,y[G.varargs-4>>2]},getStr:function(t){return x(t)},get64:function(t,e){return t}};var W={a:function(t,e,r,n){P("Assertion failed: "+x(t)+", at: "+[e?x(e):"unknown filename",r,n?x(n):"unknown function"])},e:function(t,e){P("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},d:function(t,e){P("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},b:function(){P("")},n:function(t,e){var r;if(0===t)r=Date.now();else{if(1!==t&&4!==t)return function(t){y[V()>>2]=t}(28),-1;r=M()}return y[e>>2]=r/1e3|0,y[e+4>>2]=r%1e3*1e3*1e3|0,0},h:function(){return 2147483648},l:function(t,e,r){m.copyWithin(t,e,e+r)},m:function(t){var e=m.length,r=2147483648;if((t>>>=0)>r)return!1;for(var n=1;n<=4;n*=2){var i=e*(1+.2/n);if(i=Math.min(i,t+100663296),N(Math.min(r,A(Math.max(t,i),65536))))return!0}return!1},p:function(t){for(var e=M();M()-e<t;);},f:function(t,e){var r=0;return z().forEach(function(n,i){var o=e+r;y[t+4*i>>2]=o,function(t,e){for(var r=0;r<t.length;++r)p[0|e++]=t.charCodeAt(r);p[0|e]=0}(n,o),r+=n.length+1}),0},g:function(t,e){var r=z();y[t>>2]=r.length;var n=0;return r.forEach(function(t){n+=t.length+1}),y[e>>2]=n,0},j:function(t){!function(t){!function(t){u(t,new $(t))}(t)}(t)},i:function(t){return 0},k:function(t,e,r,n,i){},c:function(t,e,r,n){for(var i=0,o=0;o<r;o++){for(var a=y[e+8*o>>2],s=y[e+(8*o+4)>>2],u=0;u<s;u++)G.printChar(t,m[a+u]);i+=s}return y[n>>2]=i,0},o:function t(e,r){t.randomDevice||(t.randomDevice=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(1);return function(){return crypto.getRandomValues(t),t[0]}}return function(){P("randomDevice")}}());for(var n=0;n<r;n++)p[e+n|0]=t.randomDevice();return 0}};(function(){var t={a:W};function e(t,e){var r=t.exports;i.asm=r,_((d=i.asm.q).buffer),E=i.asm.E,function(t){k.unshift(t)}(i.asm.r),function(){if(R--,i.monitorRunDependencies&&i.monitorRunDependencies(R),0==R&&I){var t=I;I=null,t()}}()}function r(t){e(t.instance)}function o(e){return(l||"function"!=typeof fetch?Promise.resolve().then(function(){return B(j)}):fetch(j,{credentials:"same-origin"}).then(function(t){if(!t.ok)throw"failed to load wasm binary file at '"+j+"'";return t.arrayBuffer()}).catch(function(){return B(j)})).then(function(e){return WebAssembly.instantiate(e,t)}).then(function(t){return t}).then(e,function(t){h("failed to asynchronously prepare wasm: "+t),P(t)})}if(R++,i.monitorRunDependencies&&i.monitorRunDependencies(R),i.instantiateWasm)try{return i.instantiateWasm(t,e)}catch(t){return h("Module.instantiateWasm callback failed with error: "+t),!1}(l||"function"!=typeof WebAssembly.instantiateStreaming||L(j)||"function"!=typeof fetch?o(r):fetch(j,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,t).then(r,function(t){return h("wasm streaming compile failed: "+t),h("falling back to ArrayBuffer instantiation"),o(r)})})).catch(n)})(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.r).apply(null,arguments)},i._getModelBufferMemoryOffset=function(){return(i._getModelBufferMemoryOffset=i.asm.s).apply(null,arguments)},i._getInputMemoryOffset=function(){return(i._getInputMemoryOffset=i.asm.t).apply(null,arguments)},i._getInputHeight=function(){return(i._getInputHeight=i.asm.u).apply(null,arguments)},i._getInputWidth=function(){return(i._getInputWidth=i.asm.v).apply(null,arguments)},i._getInputChannelCount=function(){return(i._getInputChannelCount=i.asm.w).apply(null,arguments)},i._getOutputMemoryOffset=function(){return(i._getOutputMemoryOffset=i.asm.x).apply(null,arguments)},i._getOutputHeight=function(){return(i._getOutputHeight=i.asm.y).apply(null,arguments)},i._getOutputWidth=function(){return(i._getOutputWidth=i.asm.z).apply(null,arguments)},i._getOutputChannelCount=function(){return(i._getOutputChannelCount=i.asm.A).apply(null,arguments)},i._loadModel=function(){return(i._loadModel=i.asm.B).apply(null,arguments)},i._runInference=function(){return(i._runInference=i.asm.C).apply(null,arguments)},i._isGPUEnabled=function(){return(i._isGPUEnabled=i.asm.D).apply(null,arguments)};var H,V=i.___errno_location=function(){return(V=i.___errno_location=i.asm.F).apply(null,arguments)};function $(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function Y(t){function e(){H||(H=!0,i.calledRun=!0,!v&&(U(k),r(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)O(i.postRun.shift());U(S)}()))}R>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)F(i.preRun.shift());U(T)}(),R>0)||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),e()},1)):e())}if(I=function t(){H||Y(),H||(I=t)},i.run=Y,i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return Y(),e.ready}}();class R3{constructor(){this.isSIMDSupported=!1,this.isThreadsSupported=!1,this.inputWidth=0,this.inputHeight=0,this.inputChannelCount=0,this.inputMemoryOffset=0,this.outputWidth=0,this.outputHeight=0,this.outputChannelCount=0,this.outputMemoryOffset=0}}const F3="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",O3="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function I3(t=F3,e=O3){let r=new R3;return new Promise(function(n,i){(async function(){return S3({locateFile:function(e){return t+e}})})().then(t=>{if(null===t)throw console.error("loadTFLite null"),"loadTFLite null";(async function(t){return new Promise(async(n,i)=>{const o=t;if(typeof o>"u")return i("TFLite backend unavailable: wasmSimd");let a=e;console.log("TFLite modelUrl: "+a);try{const t=await(await fetch(a)).arrayBuffer();console.log("Model buffer size:",t.byteLength);const e=o._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",e),console.log("Loading model buffer..."),o.HEAPU8.set(new Uint8Array(t),e);const n=o._loadModel(t.byteLength);if(console.log("Load model result:",n),0!==n)return void i("Cannot load model");r.inputWidth=o._getInputWidth(),r.inputHeight=o._getInputHeight(),r.inputChannelCount=o._getInputChannelCount(),r.inputMemoryOffset=o._getInputMemoryOffset(),console.log("Input memory offset:",r.inputMemoryOffset),console.log("Input height:",r.inputHeight),console.log("Input width:",r.inputWidth),console.log("Input channels:",r.inputChannelCount),r.outputMemoryOffset=o._getOutputMemoryOffset(),r.outputWidth=o._getOutputWidth(),r.outputHeight=o._getOutputHeight(),r.outputChannelCount=o._getOutputChannelCount(),console.log("Output memory offset:",r.outputMemoryOffset),console.log("Output height:",r.outputHeight),console.log("Output width:",r.outputWidth),console.log("Output channels:",r.outputChannelCount),r.selectedTFLite=o}catch(t){return void i(t)}n()})})(t).then(t=>{n(r)}).catch(t=>{console.error("loadTFLiteModel error"),i("loadTFLiteModel error")})}).catch(t=>{console.error("loadTFLite error:",t),i("loadTFLite error:"+t)})})}const k3=.1,P3=.7,C3="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class M3{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=0,this.height=0,this.gpuDelegate=!0}async createImageSegmenter(){this.ImageSegmenter&&this.wasmFileset?this.imageSegmenter=await this.ImageSegmenter.createFromOptions(this.wasmFileset,{baseOptions:{modelAssetPath:this.modelAssetUriPath,delegate:this.gpuDelegate?"GPU":"CPU"},runningMode:"VIDEO",outputCategoryMask:!0,outputConfidenceMasks:!0}):console.warn("Mediapipe objects not loaded")}async loadMediapipeAssets(t,e){this.modelAssetUriPath=t||C3;const r=e?`${e}/task-vision.js`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/+esm",n=e?`${e}/wasm`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/wasm",{FilesetResolver:i,ImageSegmenter:o}=await import(r);this.ImageSegmenter=o,this.wasmFileset=await i.forVisionTasks(n)}async init(t,e,r){!1===r&&(this.gpuDelegate=!1),await this.loadMediapipeAssets(t,e),globalThis.document={},await this.createImageSegmenter()}async process(t){if(!this.imageSegmenter)return void console.warn("ImageSegmenter instance not available");(this.width!==t.width||this.height!==t.height)&&(this.canvas.width=this.width=t.width,this.canvas.height=this.height=t.height,this.mask&&(this.mask=new ImageData(this.width,this.height))),this.mask||(this.mask=new ImageData(this.width,this.height)),this.context.drawImage(t,0,0,t.width,t.height);const e=Date.now();let r;try{this.imageSegmenter?.segmentForVideo(this.context.getImageData(0,0,t.width,t.height),e,t=>{r=t.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{return void await this.createImageSegmenter()}if(!r)return;if(!this.previousConfidenceMask)return void(this.previousConfidenceMask=r.slice());const n=r.map((t,e)=>{const r=this.previousConfidenceMask?.[e];return void 0!==r?this.blend(r,t):t}),i=[255,0,0];for(let t=0;t<n?.length;t++){const e=1-n[t];e>k3?(e<P3?(this.mask.data[4*t]=i[0]*e,this.mask.data[4*t+3]=255*e):(this.mask.data[4*t]=i[0],this.mask.data[4*t+3]=255),this.mask.data[4*t+1]=i[1],this.mask.data[4*t+2]=i[2]):this.mask.data[4*t]=this.mask.data[4*t+1]=this.mask.data[4*t+2]=this.mask.data[4*t+3]=0}return this.previousConfidenceMask=n.slice(),this.mask}isGpuSupported(){return!0}blend(t,e){const r=e-.5,n=r*r;return e+.9*(1-Math.min(1,n*(5.68842+n*(n*(n*(291.309+-624.717*n)-57.8051)-.748699))))*(t-e)}}class L3{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.pixelCount=0,this.inputOffset=0,this.outputOffset=0}async init(t,e,r){await this.initWasm(e,t),this.infos&&(this.canvas.width=this.infos.inputWidth,this.canvas.height=this.infos.inputHeight,this.pixelCount=this.infos.inputWidth*this.infos.inputHeight,this.mask=new ImageData(this.infos.inputWidth,this.infos.inputHeight),this.inputOffset=this.infos.inputMemoryOffset/4,this.outputOffset=this.infos.outputMemoryOffset/4)}async initWasm(t,e){this.infos=await I3(t,e)}async process(t){if(!this.mask||!this.infos)return;const e=this.infos.inputWidth,r=this.infos.inputHeight;this.context.drawImage(t,0,0,t.width,t.height,0,0,e,r);const n=this.context.getImageData(0,0,e,r),i=this.infos.selectedTFLite.HEAPF32;for(let t=0;t<this.pixelCount;t++){const e=this.inputOffset+3*t;i[e]=n.data[4*t]/255,i[e+1]=n.data[4*t+1]/255,i[e+2]=n.data[4*t+2]/255}this.infos.selectedTFLite._runInference();for(let t=0;t<this.pixelCount;t++){const e=this.infos.selectedTFLite.HEAPF32[this.outputOffset+t];this.mask.data[4*t]=this.mask.data[4*t+3]=255*e}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class j3{constructor(){this.reporter=new zc,this.isEnabled=!0}async init(t,e){!0===e.segmentationOptions?.lightWeightEngine?this.selfieSegmentation=new L3:this.selfieSegmentation=new M3,await(this.selfieSegmentation?.init(e.modelAssetUriPath,e.mediapipeBaseAssetsUri,e.segmentationOptions?.gpuSupport)),this.backgroundFilter=new T3,this.report({variation:"Create"})}async transform(t,e){if(!this.isEnabled)return e.enqueue(t);let r;const n=t.timestamp??0,i=await createImageBitmap(t),o=await(this.selfieSegmentation?.process(i));o&&(r=await(this.backgroundFilter?.process(i,o))),r?(t.close(),e.enqueue(new VideoFrame(r,{timestamp:n,alpha:"discard"}))):e.enqueue(t)}async setBackgroundOptions(t){this.backgroundOptions=t,await(this.backgroundFilter?.setBackgroundOptions(t)),this.report({variation:"Update"})}async setVideoBGReadable(t){await(this.backgroundFilter?.setVideoBGReadable(t))}async setVirtualBGImage(t){await(this.backgroundFilter?.setVirtualBGImage(t))}async profile(t){return this.backgroundFilter?.profile(t)??[]}getTransformerType(){return this.backgroundOptions?.transformerType??"Undefined"}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}report(t){this.reporter.send({version:Hc,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...t})}}const gs=class{constructor(){this.backgroundTransformer=new j3,this.mediaProcessor=new ra,this.rate=30,this.eventsQueue=[],this.frameTransformLatencyMs=[]}async init(t,e){this.frameTransformLatencyMs=[],await this.backgroundTransformer.init(t,e),await this.mediaProcessor.setTransformers([this.backgroundTransformer]),this.mediaProcessor.setTrackExpectedRate(this.rate),this.mediaProcessor.onAny((t,e)=>{this.resolveOnMediaProcessor?(this.resolveOnMediaProcessor({name:t,data:e}),this.resolveOnMediaProcessor=void 0):this.eventsQueue.push({name:t,data:e})})}enable(){this.backgroundTransformer.enable()}disable(){this.backgroundTransformer.disable()}async onMediaProcessorEvent(){return await new Promise(t=>{this.eventsQueue.length>0?t(this.eventsQueue.shift()):this.resolveOnMediaProcessor=t})}async setTrackExpectedRate(t){this.rate=t,this.mediaProcessor.setTrackExpectedRate(t)}async transform(t,e){let r=this.mediaProcessor.transform(t,e),n=performance.now();return this.frameTransformLatencyMs.push(performance.now()-n),r}async setBackgroundOptions(t){await(this.backgroundTransformer?.setBackgroundOptions(t))}setVideoBGReadable(t){this.backgroundTransformer.setVideoBGReadable(t)}async setVirtualBGImage(t){await this.backgroundTransformer.setVirtualBGImage(t)}async terminate(){await this.mediaProcessor.destroy();const t=this.frameTransformLatencyMs.reduce((t,e)=>t+e,0)/this.frameTransformLatencyMs.length||0;console.log(`Transform latency average is: ${t} ms`)}setVonageMetadata(t){Wu(t)}async profile(t){return JSON.stringify(await this.backgroundTransformer.profile(t))}};gc("ProcessorWorker",gs);let Lo=gs;const pu='(function(){"use strict";function Vt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const jr=Vt("globals",{});var xe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r.EVENT="EVENT",r))(xe||{});function $i(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}function Me(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>$i(s)))}Vt("workerized",{});function Yr(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function qe(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],qe(r[t],e[t])):typeof r[t]=="object"?(e[t]={},qe(r[t],e[t])):e[t]=r[t]}const K=new WeakMap,ce=new WeakMap,j=new WeakMap,Ke=Symbol("anyProducer"),Xr=Promise.resolve(),Je=Symbol("listenerAdded"),Ze=Symbol("listenerRemoved");let et=!1,Ht=!1;function _e(r){if(typeof r!="string"&&typeof r!="symbol"&&typeof r!="number")throw new TypeError("`eventName` must be a string, symbol, or number")}function tt(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ee(r,e){const t=ce.get(r);if(t.has(e))return t.get(e)}function De(r,e){const t=typeof e=="string"||typeof e=="symbol"||typeof e=="number"?e:Ke,n=j.get(r);if(n.has(t))return n.get(t)}function Wi(r,e,t){const n=j.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(Ke)){const i=Promise.all([e,t]);for(const s of n.get(Ke))s.enqueue(i)}}function Qr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=De(r,o);a||(a=new Set,j.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=De(r,a);c&&(c.delete(s),c.size===0&&j.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function qr(r){if(r===void 0)return Kr;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!Kr.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const we=r=>r===Je||r===Ze;function rt(r,e,t){if(we(e))try{et=!0,r.emit(e,t)}finally{et=!1}}class ve{static mixin(e,t){return t=qr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new ve}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){var e,t;if(typeof((e=globalThis.process)==null?void 0:e.env)!="object")return Ht;const{env:n}=(t=globalThis.process)!=null?t:{env:{}};return n.DEBUG==="emittery"||n.DEBUG==="*"||Ht}static set isDebugEnabled(e){Ht=e}constructor(e={}){var t;K.set(this,new Set),ce.set(this,new Map),j.set(this,new Map),j.get(this).set(Ke,new Set),this.debug=(t=e.debug)!=null?t:{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(n,i,s,o)=>{try{o=JSON.stringify(o)}catch{o=`Object with the following keys failed to stringify: ${Object.keys(o).join(",")}`}(typeof s=="symbol"||typeof s=="number")&&(s=s.toString());const a=new Date,c=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()}.${a.getMilliseconds()}`;console.log(`[${c}][emittery:${n}][${i}] Event Name: ${s}\n\tdata: ${o}`)})}logIfDebugEnabled(e,t,n){(ve.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);let i=Ee(this,n);i||(i=new Set,ce.get(this).set(n,i)),i.add(t),this.logIfDebugEnabled("subscribe",n,void 0),we(n)||rt(this,Je,{eventName:n,listener:t})}return this.off.bind(this,e,t)}off(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);const i=Ee(this,n);i&&(i.delete(t),i.size===0&&ce.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),we(n)||rt(this,Ze,{eventName:n,listener:t})}}once(e){let t;const n=new Promise(i=>{t=this.on(e,s=>{t(),i(s)})});return n.off=t,n}events(e){e=Array.isArray(e)?e:[e];for(const t of e)_e(t);return Qr(this,e)}async emit(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Wi(this,e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=we(e)?[]:[...s];await Xr,await Promise.all([...o.map(async c=>{if(i.has(c))return c(t)}),...a.map(async c=>{if(s.has(c))return c(e,t)})])}async emitSerial(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=[...s];await Xr;for(const c of o)i.has(c)&&await c(t);for(const c of a)s.has(c)&&await c(e,t)}onAny(e){return tt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),K.get(this).add(e),rt(this,Je,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Qr(this)}offAny(e){tt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),rt(this,Ze,{listener:e}),K.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),typeof t=="string"||typeof t=="symbol"||typeof t=="number"){const n=Ee(this,t);n&&n.clear();const i=De(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{K.get(this).clear();for(const[n,i]of ce.get(this).entries())i.clear(),ce.get(this).delete(n);for(const[n,i]of j.get(this).entries()){for(const s of i)s.finish();i.clear(),j.get(this).delete(n)}}}listenerCount(e){var t,n,i,s,o,a;e=Array.isArray(e)?e:[e];let c=0;for(const u of e){if(typeof u=="string"){c+=K.get(this).size+((n=(t=Ee(this,u))==null?void 0:t.size)!=null?n:0)+((s=(i=De(this,u))==null?void 0:i.size)!=null?s:0)+((a=(o=De(this))==null?void 0:o.size)!=null?a:0);continue}typeof u<"u"&&_e(u),c+=K.get(this).size;for(const d of ce.get(this).values())c+=d.size;for(const d of j.get(this).values())c+=d.size}return c}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=qr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const Kr=Object.getOwnPropertyNames(ve.prototype).filter(r=>r!=="constructor");Object.defineProperty(ve,"listenerAdded",{value:Je,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(ve,"listenerRemoved",{value:Ze,writable:!1,enumerable:!0,configurable:!1});function Vi(r){return r.onAny&&r.emit}async function Hi(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Me(r,await e.instance[t](...n??[]))}const Jr=Vt("registeredWorkers",{});function ji(r,e){e.workerId=r,Yr()&&(Jr[e.workerId]=e)}function Yi(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Jr[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;qe(n,jr),Vi(e.instance)&&e.instance.onAny((s,o)=>{Me({type:xe.EVENT},{name:s,data:o})}),Me(r,typeof e.instance!==void 0)}async function Xi(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Me(r,n)}function Qi(r){if(!r.args)throw"Missing globals while syncing";qe(r.args[0],jr),Me(r,{})}function qi(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case xe.INIT:Yi(t,r);break;case xe.FORWARD:Hi(t,r);break;case xe.TERMINATE:Xi(t,r);break;case xe.GLOBALS_SYNC:Qi(t);break}}}Yr()&&qi();var jt;self.MediaStreamTrackProcessor||(self.MediaStreamTrackProcessor=(jt=class{constructor(r){const e=r.track??r;e.kind=="video"?this.readable=new ReadableStream({async start(t){e.addEventListener("ended",()=>t.close(),{once:!0}),this.video=document.createElement("video"),this.video.srcObject=new MediaStream([e]),await Promise.all([this.video.play(),new Promise(n=>this.video.onloadedmetadata=n)]),this.track=e,this.canvas=new OffscreenCanvas(this.video.videoWidth,this.video.videoHeight),this.ctx=this.canvas.getContext("2d",{desynchronized:!0}),this.t1=performance.now()},async pull(t){if(e.readyState=="ended")return t.close();const n=e.getSettings().frameRate||30;for(;performance.now()-this.t1<1e3/n;)if(await new Promise(i=>requestAnimationFrame(i)),e.readyState=="ended")return t.close();this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,this.t1=performance.now(),this.ctx.drawImage(this.video,0,0),t.enqueue(new VideoFrame(this.canvas,{timestamp:this.t1}))}}):e.kind=="audio"&&(this.readable=new ReadableStream({async start(t){e.addEventListener("ended",()=>t.close(),{once:!0}),this.ac=new AudioContext,this.arrays=[];function n(){registerProcessor("mstp-shim",class extends AudioWorkletProcessor{process(i){return this.port.postMessage(i),!0}})}await this.ac.audioWorklet.addModule(`data:text/javascript,(${n.toString()})()`),this.node=new AudioWorkletNode(this.ac,"mstp-shim"),this.ac.createMediaStreamSource(new MediaStream([e])).connect(this.node),this.node.port.addEventListener("message",({data:i})=>i[0][0]&&this.arrays.push(i))},async pull(t){if(e.readyState=="ended")return t.close();for(;!this.arrays.length;)if(await new Promise(s=>this.node.port.onmessage=s),e.readyState=="ended")return t.close();const[n]=this.arrays.shift(),i=new Float32Array(n.reduce((s,o)=>s+o.length,0));n.reduce((s,o)=>(i.set(o,s),s+o.length),0),t.enqueue(new AudioData({format:"f32-planar",sampleRate:this.ac.sampleRate,numberOfFrames:n[0].length,numberOfChannels:n.length,timestamp:this.ac.currentTime*1e6|0,data:i,transfer:[i.buffer]}))}}))}},jt.__POLYFILLED=!0,jt));var Yt;self.MediaStreamTrackGenerator||(self.MediaStreamTrackGenerator=(Yt=class{constructor({kind:r}){if(r=="video"){const e=document.createElement("canvas"),t=e.getContext("2d",{desynchronized:!0}),n=e.captureStream().getVideoTracks()[0];return n.writable=new WritableStream({write(i){e.width=i.displayWidth,e.height=i.displayHeight,t.drawImage(i,0,0,e.width,e.height),i.close()}}),n}else if(r=="audio"){const e=new AudioContext,t=e.createMediaStreamDestination(),[n]=t.stream.getAudioTracks();return n.writable=new WritableStream({async start(i){this.arrays=[];function s(){registerProcessor("mstg-shim",class extends AudioWorkletProcessor{constructor(){super(),this.arrays=[],this.arrayOffset=0,this.port.onmessage=({data:o})=>this.arrays.push(o),this.emptyArray=new Float32Array(0)}process(o,[[a]]){for(let c=0;c<a.length;c++)(!this.array||this.arrayOffset>=this.array.length)&&(this.array=this.arrays.shift()||this.emptyArray,this.arrayOffset=0),a[c]=this.array[this.arrayOffset++]||0;return!0}})}return await e.audioWorklet.addModule(`data:text/javascript,(${s.toString()})()`),this.node=new AudioWorkletNode(e,"mstg-shim"),this.node.connect(t),n},write(i){const s=new Float32Array(i.numberOfFrames*i.numberOfChannels);i.copyTo(s,{planeIndex:0}),this.node.port.postMessage(s,[s.buffer]),i.close()}}),n}}},Yt.__POLYFILLED=!0,Yt));const J=new WeakMap,ue=new WeakMap,Y=new WeakMap,nt=Symbol("anyProducer"),Zr=Promise.resolve(),it=Symbol("listenerAdded"),st=Symbol("listenerRemoved");let ot=!1,Xt=!1;const at=r=>typeof r=="string"||typeof r=="symbol"||typeof r=="number";function Te(r){if(!at(r))throw new TypeError("`eventName` must be a string, symbol, or number")}function ct(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ae(r,e){const t=ue.get(r);if(t.has(e))return t.get(e)}function Be(r,e){const t=at(e)?e:nt,n=Y.get(r);if(n.has(t))return n.get(t)}function Ki(r,e,t){const n=Y.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(nt)){const i=Promise.all([e,t]);for(const s of n.get(nt))s.enqueue(i)}}function en(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=Be(r,o);a||(a=new Set,Y.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=Be(r,a);c&&(c.delete(s),c.size===0&&Y.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function tn(r){if(r===void 0)return rn;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!rn.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const Se=r=>r===it||r===st;function ut(r,e,t){if(Se(e))try{ot=!0,r.emit(e,t)}finally{ot=!1}}class X{static mixin(e,t){return t=tn(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new X}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return Xt;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||Xt}static set isDebugEnabled(e){Xt=e}constructor(e={}){J.set(this,new Set),ue.set(this,new Map),Y.set(this,new Map),Y.get(this).set(nt,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,s)=>{try{s=JSON.stringify(s)}catch{s=`Object with the following keys failed to stringify: ${Object.keys(s).join(",")}`}(typeof i=="symbol"||typeof i=="number")&&(i=i.toString());const o=new Date,a=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${n}] Event Name: ${i}\n\tdata: ${s}`)})}logIfDebugEnabled(e,t,n){(X.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t,{signal:n}={}){ct(t),e=Array.isArray(e)?e:[e];for(const s of e){Te(s);let o=Ae(this,s);o||(o=new Set,ue.get(this).set(s,o)),o.add(t),this.logIfDebugEnabled("subscribe",s,void 0),Se(s)||ut(this,it,{eventName:s,listener:t})}const i=()=>{this.off(e,t),n?.removeEventListener("abort",i)};return n?.addEventListener("abort",i,{once:!0}),n?.aborted&&i(),i}off(e,t){ct(t),e=Array.isArray(e)?e:[e];for(const n of e){Te(n);const i=Ae(this,n);i&&(i.delete(t),i.size===0&&ue.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),Se(n)||ut(this,st,{eventName:n,listener:t})}}once(e,t){if(t!==void 0&&typeof t!="function")throw new TypeError("predicate must be a function");let n;const i=new Promise(s=>{n=this.on(e,o=>{t&&!t(o)||(n(),s(o))})});return i.off=n,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Te(t);return en(this,e)}async emit(e,t){if(Te(e),Se(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Ki(this,e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=Se(e)?[]:[...i];await Zr,await Promise.all([...s.map(async a=>{if(n.has(a))return a(t)}),...o.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(Te(e),Se(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=[...i];await Zr;for(const a of s)n.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){ct(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),J.get(this).add(e),ut(this,it,{listener:e});const n=()=>{this.offAny(e),t?.removeEventListener("abort",n)};return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),n}anyEvent(){return en(this)}offAny(e){ct(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),ut(this,st,{listener:e}),J.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),at(t)){const n=Ae(this,t);n&&n.clear();const i=Be(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{J.get(this).clear();for(const[n,i]of ue.get(this).entries())i.clear(),ue.get(this).delete(n);for(const[n,i]of Y.get(this).entries()){for(const s of i)s.finish();i.clear(),Y.get(this).delete(n)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const n of e){if(at(n)){t+=J.get(this).size+(Ae(this,n)?.size??0)+(Be(this,n)?.size??0)+(Be(this)?.size??0);continue}n!==void 0&&Te(n),t+=J.get(this).size;for(const i of ue.get(this).values())t+=i.size;for(const i of Y.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=tn(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const rn=Object.getOwnPropertyNames(X.prototype).filter(r=>r!=="constructor");Object.defineProperty(X,"listenerAdded",{value:it,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(X,"listenerRemoved",{value:st,writable:!1,enumerable:!0,configurable:!1});var Ji=Object.defineProperty,Zi=(r,e,t)=>e in r?Ji(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,es=(r,e,t)=>(Zi(r,e+"",t),t);const ts="hlg.tokbox.com/prod/logging/vcp_webrtc",rs="https://",ns=1e4;let ft;const is=new Uint8Array(16);function ss(){if(!ft&&(ft=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ft))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ft(is)}const F=[];for(let r=0;r<256;++r)F.push((r+256).toString(16).slice(1));function os(r,e=0){return(F[r[e+0]]+F[r[e+1]]+F[r[e+2]]+F[r[e+3]]+"-"+F[r[e+4]]+F[r[e+5]]+"-"+F[r[e+6]]+F[r[e+7]]+"-"+F[r[e+8]]+F[r[e+9]]+"-"+F[r[e+10]]+F[r[e+11]]+F[r[e+12]]+F[r[e+13]]+F[r[e+14]]+F[r[e+15]]).toLowerCase()}const as=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),nn={randomUUID:as};function cs(r,e,t){if(nn.randomUUID&&!r)return nn.randomUUID();r=r||{};const n=r.random||(r.rng||ss)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,os(n)}function Qt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Z=Qt("globals",{});var fe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(fe||{});function sn(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let us=0;function fs(r,e,t,n,i){const s=us++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>sn(o))),new Promise(o=>{i?.set(s,o)})}function Oe(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>sn(s)))}const on=Qt("workerized",{});function an(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function ls(){if(an())Oe({type:fe.GLOBALS_SYNC},Z);else{const r=[];for(const e in on){const{worker:t,resolvers:n}=on[e].workerContext;t&&r.push(fs(t,fe.GLOBALS_SYNC,"",[Z],n))}await Promise.all(r)}}function lt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],lt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},lt(r[t],e[t])):e[t]=r[t]}async function ds(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Oe(r,await e.instance[t](...n??[]))}const hs=Qt("registeredWorkers",{});function ms(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=hs[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;lt(n,Z),Oe(r,typeof e.instance!==void 0)}async function ps(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Oe(r,n)}function gs(r){if(!r.args)throw"Missing globals while syncing";lt(r.args[0],Z),Oe(r,{})}function ys(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case fe.INIT:ms(t,r);break;case fe.FORWARD:ds(t,r);break;case fe.TERMINATE:ps(t,r);break;case fe.GLOBALS_SYNC:gs(t);break}}}an()&&ys();function bs(r,e){return Z[r]||(Z[r]=e),[()=>Z[r],async t=>{Z[r]=t,await ls()}]}function xs(r,e){return bs(r,e)}const[_s,Es]=xs("metadata");function ws(r){Es(r)}function qt(){return _s()}let Kt=class{constructor(e,t){es(this,"uuid"),this.config=e,this.uuid=t??cs()}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=qt())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),ns);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=qt().proxyUrl)!=null?e:rs;return t+=(t.at(-1)==="/"?"":"/")+ts,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=qt();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}};const dt="3.0.0-alpha.2",Jt=class{};Jt.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},Jt.errors={transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer",readable_null:"Readable is null",writable_null:"Writable is null"};let le=Jt;function vs(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function Ts(r){if(vs(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function Zt(r){return Ts(r).message}class As{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new Kt(e,t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,n=(Date.now()-e)/1e3;return t/n}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:n,frameTransformedCount:i,frameFromSourceCount:s}=this,o=Date.now(),a=(o-n)/1e3,c=i/a,u=s/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:u,transformedFps:c,framesTransformed:i,...e})):"success"}}var er=(r=>(r.pipeline_ended="pipeline_ended",r.pipeline_ended_with_error="pipeline_ended_with_error",r.pipeline_started="pipeline_started",r.pipeline_started_with_error="pipeline_started_with_error",r.pipeline_restarted="pipeline_restarted",r.pipeline_restarted_with_error="pipeline_restarted_with_error",r))(er||{});const Ss=500,Is=.8;class Rs extends X{constructor(e,t){super(),this.reporter_=new Kt,this.reporterQos_=new As({loggingIntervalFrameCount:Ss,report:{version:dt}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e}async start(e){if(this.controller_=e,this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch(t){this.report({message:le.errors.transformer_start,variation:"Error",error:Zt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"start"};this.emit("error",n)}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(n){this.report({message:le.errors.transformer_transform,variation:"Error",error:Zt(n)});const i={eventMetaData:{transformerIndex:this.index_},error:n,function:"transform"};this.emit("error",i)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*Is>this.reporterQos_.fps){const n={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",n)}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:le.errors.transformer_flush,variation:"Error",error:Zt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"flush"};this.emit("error",n)}}this.reportQos(!0),this.report({variation:"Delete"})}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),this.shouldStop_=!0}report(e){this.reporter_.send({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class Fs extends X{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let n=new Rs(e[t],t);n.on("error",i=>{this.emit("error",i)}),n.on("warn",i=>{this.emit("warn",i)}),this.transformers_.push(n)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let n=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async()=>{console.log("[Pipeline] Setup."),await t.abort(),await n.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async i=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(s=>{console.error("[Pipeline] Error from stream transform:",s)}),await t.abort(i),await n.cancel(i),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{this.emit("pipelineInfo","pipeline_started_with_error"),this.destroy();return}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Ps extends X{constructor(){super(),this.reporter_=new Kt,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==="video"){const n=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=n.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise(async(e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:le.errors.transformer_none,variation:"Error"}),t("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:le.errors.readable_null}),t("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:le.errors.writable_null}),t("[MediaProcessor] Writable is null.");return}let n=!1;this.pipeline_&&(n=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Fs(this.transformers_),this.pipeline_.on("warn",i=>{this.emit("warn",i)}),this.pipeline_.on("error",i=>{this.emit("error",i)}),this.pipeline_.on("pipelineInfo",i=>{n&&(i==="pipeline_started"?i=er.pipeline_restarted:i==="pipeline_started_with_error"&&(i=er.pipeline_restarted_with_error)),this.emit("pipelineInfo",i)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(i=>{t(i)})})}setTransformers(e){return this.report({variation:"Update",message:le.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async e=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),e()})}report(e){this.reporter_.send({version:dt,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}var ks=Object.defineProperty,Cs=(r,e,t)=>e in r?ks(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ms=(r,e,t)=>(Cs(r,e+"",t),t);const Ds="hlg.tokbox.com/prod/logging/vcp_webrtc",Bs="https://",Os=1e4;let ht;const Us=new Uint8Array(16);function Ns(){if(!ht&&(ht=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ht))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ht(Us)}const P=[];for(let r=0;r<256;++r)P.push((r+256).toString(16).slice(1));function Ls(r,e=0){return(P[r[e+0]]+P[r[e+1]]+P[r[e+2]]+P[r[e+3]]+"-"+P[r[e+4]]+P[r[e+5]]+"-"+P[r[e+6]]+P[r[e+7]]+"-"+P[r[e+8]]+P[r[e+9]]+"-"+P[r[e+10]]+P[r[e+11]]+P[r[e+12]]+P[r[e+13]]+P[r[e+14]]+P[r[e+15]]).toLowerCase()}const zs=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cn={randomUUID:zs};function Gs(r,e,t){if(cn.randomUUID&&!e&&!r)return cn.randomUUID();r=r||{};const n=r.random||(r.rng||Ns)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Ls(n)}function tr(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const ee=tr("globals",{});var de=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(de||{});function un(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let $s=0;function Ws(r,e,t,n,i){const s=$s++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>un(o))),new Promise(o=>{i?.set(s,o)})}function Ue(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>un(s)))}const fn=tr("workerized",{});function ln(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function Vs(){if(ln())Ue({type:de.GLOBALS_SYNC},ee);else{const r=[];for(const e in fn){const{worker:t,resolvers:n}=fn[e].workerContext;t&&r.push(Ws(t,de.GLOBALS_SYNC,"",[ee],n))}await Promise.all(r)}}function mt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],mt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},mt(r[t],e[t])):e[t]=r[t]}async function Hs(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Ue(r,await e.instance[t](...n??[]))}const js=tr("registeredWorkers",{});function Ys(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=js[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;mt(n,ee),Ue(r,typeof e.instance!==void 0)}async function Xs(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Ue(r,n)}function Qs(r){if(!r.args)throw"Missing globals while syncing";mt(r.args[0],ee),Ue(r,{})}function qs(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case de.INIT:Ys(t,r);break;case de.FORWARD:Hs(t,r);break;case de.TERMINATE:Xs(t,r);break;case de.GLOBALS_SYNC:Qs(t);break}}}ln()&&qs();function Ks(r,e){return ee[r]||(ee[r]=e),[()=>ee[r],async t=>{ee[r]=t,await Vs()}]}function Js(r,e){return Ks(r,e)}const[Zs]=Js("metadata");function rr(){return Zs()}class eo{constructor(e){Ms(this,"uuid",Gs()),this.config=e}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=rr())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),Os);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=rr().proxyUrl)!=null?e:Bs;return t+=(t.at(-1)==="/"?"":"/")+Ds,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=rr();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const to="7.0.0-alpha.1";var pt=(r=>(r.Low="Low",r.High="High",r))(pt||{}),nr=(r=>(r.FAST="FAST",r.PRECISE="PRECISE",r))(nr||{}),gt=(r=>(r.CANVAS="CANVAS",r.WEBGL="WEBGL",r))(gt||{});function ro(){const e=new OffscreenCanvas(0,0).getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(e){const t=e?.getExtension("WEBGL_lose_context");t&&t.loseContext()}else return{supported:!1,message:"Your hardware does not perform good enough to run the library efficiently"};return{supported:!0}}class ir{constructor(){const e=new OffscreenCanvas(0,0),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw"Fail to retrieve 2d context";this.canvas=e,this.context=t}setFlickeringOptions(e){}enablePostProcessing(){}disablePostProcessing(){}async profileWebgl(e){return[]}async render(e,t){return this.canvas}resizeCanvas(e){const{width:t,height:n}=e;this.canvas.width=t,this.canvas.height=n}renderSilhouette(e,t,n="none"){const{width:i,height:s}=e;this.context.save(),this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.globalCompositeOperation="source-in",this.context.filter=n,this.context.drawImage(e,0,0,i,s,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class no extends ir{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.context.save(),this.context.filter=`blur(${this.radius}px)`,this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class io extends ir{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n,`blur(${this.radius}px)`),this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class so extends ir{setBackgroundImage(e){this.backgroundImage=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.backgroundImage&&(this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(this.backgroundImage,0,0,this.backgroundImage.width,this.backgroundImage.height,0,0,e.width,e.height),this.context.restore()),super.render(e,t)}}const sr=5120,Ne=5121,or=5122,ar=5123,cr=5124,ur=5125,fr=5126,oo=32819,ao=32820,co=33635,uo=5131,fo=33640,lo=35899,ho=35902,mo=36269,po=34042,dn={};{const r=dn;r[sr]=Int8Array,r[Ne]=Uint8Array,r[or]=Int16Array,r[ar]=Uint16Array,r[cr]=Int32Array,r[ur]=Uint32Array,r[fr]=Float32Array,r[oo]=Uint16Array,r[ao]=Uint16Array,r[co]=Uint16Array,r[uo]=Uint16Array,r[fo]=Uint32Array,r[lo]=Uint32Array,r[ho]=Uint32Array,r[mo]=Uint32Array,r[po]=Uint32Array}function lr(r){if(r instanceof Int8Array)return sr;if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return Ne;if(r instanceof Int16Array)return or;if(r instanceof Uint16Array)return ar;if(r instanceof Int32Array)return cr;if(r instanceof Uint32Array)return ur;if(r instanceof Float32Array)return fr;throw new Error("unsupported typed array type")}function hn(r){if(r===Int8Array)return sr;if(r===Uint8Array||r===Uint8ClampedArray)return Ne;if(r===Int16Array)return or;if(r===Uint16Array)return ar;if(r===Int32Array)return cr;if(r===Uint32Array)return ur;if(r===Float32Array)return fr;throw new Error("unsupported typed array type")}function mn(r){const e=dn[r];if(!e)throw new Error("unknown gl type");return e}const yt=typeof SharedArrayBuffer<"u"?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer};function pn(...r){console.error(...r)}const gn=new Map;function bt(r,e){if(!r||typeof r!="object")return!1;let t=gn.get(e);t||(t=new WeakMap,gn.set(e,t));let n=t.get(r);if(n===void 0){const i=Object.prototype.toString.call(r);n=i.substring(8,i.length-1)===e,t.set(r,n)}return n}function go(r,e){return typeof WebGLBuffer<"u"&&bt(e,"WebGLBuffer")}function yo(r,e){return typeof WebGLRenderbuffer<"u"&&bt(e,"WebGLRenderbuffer")}function dr(r,e){return typeof WebGLTexture<"u"&&bt(e,"WebGLTexture")}function bo(r,e){return typeof WebGLSampler<"u"&&bt(e,"WebGLSampler")}const yn=35044,he=34962,xo=34963,_o=34660,Eo=5120,wo=5121,vo=5122,To=5123,Ao=5124,So=5125,bn=5126,xn={attribPrefix:""};function Io(r,e,t,n,i){r.bindBuffer(e,t),r.bufferData(e,n,i||yn)}function _n(r,e,t,n){if(go(r,e))return e;t=t||he;const i=r.createBuffer();return Io(r,t,i,e,n),i}function En(r){return r==="indices"}function Ro(r){return r===Int8Array||r===Uint8Array}function Fo(r){return r.length?r:r.data}const Po=/coord|texture/i,ko=/color|colour/i;function Co(r,e){let t;if(Po.test(r)?t=2:ko.test(r)?t=4:t=3,e%t>0)throw new Error(`Can not guess numComponents for attribute \'${r}\'. Tried ${t} but ${e} values is not evenly divisible by ${t}. You should specify it.`);return t}function Mo(r,e,t){return r.numComponents||r.size||Co(e,t||Fo(r).length)}function wn(r,e){if(yt(r))return r;if(yt(r.data))return r.data;Array.isArray(r)&&(r={data:r});let t=r.type?hr(r.type):void 0;return t||(En(e)?t=Uint16Array:t=Float32Array),new t(r.data)}function Do(r){return typeof r=="number"?r:r?hn(r):bn}function hr(r){return typeof r=="number"?mn(r):r||Float32Array}function Bo(r,e){return{buffer:e.buffer,numValues:24,type:Do(e.type),arrayType:hr(e.type)}}function Oo(r,e){const t=e.data||e,n=hr(e.type),i=t*n.BYTES_PER_ELEMENT,s=r.createBuffer();return r.bindBuffer(he,s),r.bufferData(he,i,e.drawType||yn),{buffer:s,numValues:t,type:hn(n),arrayType:n}}function Uo(r,e,t){const n=wn(e,t);return{arrayType:n.constructor,buffer:_n(r,n,void 0,e.drawType),type:lr(n),numValues:0}}function No(r,e){const t={};return Object.keys(e).forEach(function(n){if(!En(n)){const i=e[n],s=i.attrib||i.name||i.attribName||xn.attribPrefix+n;if(i.value){if(!Array.isArray(i.value)&&!yt(i.value))throw new Error("array.value is not array or typedarray");t[s]={value:i.value}}else{let o;i.buffer&&i.buffer instanceof WebGLBuffer?o=Bo:typeof i=="number"||typeof i.data=="number"?o=Oo:o=Uo;const{buffer:a,type:c,numValues:u,arrayType:d}=o(r,i,n),m=i.normalize!==void 0?i.normalize:Ro(d),p=Mo(i,n,u);t[s]={buffer:a,numComponents:p,type:c,normalize:m,stride:i.stride||0,offset:i.offset||0,divisor:i.divisor===void 0?void 0:i.divisor,drawType:i.drawType}}}}),r.bindBuffer(he,null),t}function Lo(r,e){return e===Eo||e===wo?1:e===vo||e===To?2:e===Ao||e===So||e===bn?4:0}const mr=["position","positions","a_position"];function zo(r,e){let t,n;for(n=0;n<mr.length&&(t=mr[n],!(t in e||(t=xn.attribPrefix+t,t in e)));++n);n===mr.length&&(t=Object.keys(e)[0]);const i=e[t];if(!i.buffer)return 1;r.bindBuffer(he,i.buffer);const s=r.getBufferParameter(he,_o);r.bindBuffer(he,null);const o=Lo(r,i.type),a=s/o,c=i.numComponents||i.size,u=a/c;if(u%1!==0)throw new Error(`numComponents ${c} not correct for length ${length}`);return u}function Go(r,e,t){const n=No(r,e),i=Object.assign({},t||{});i.attribs=Object.assign({},t?t.attribs:{},n);const s=e.indices;if(s){const o=wn(s,"indices");i.indices=_n(r,o,xo),i.numElements=o.length,i.elementType=lr(o)}else i.numElements||(i.numElements=zo(r,i.attribs));return i}function Le(r){return!!r.texStorage2D}const vn=(function(){const r={},e={};function t(n){const i=n.constructor.name;if(!r[i]){for(const s in n)if(typeof n[s]=="number"){const o=e[n[s]];e[n[s]]=o?`${o} | ${s}`:s}r[i]=!0}}return function(i,s){return t(i),e[s]||(typeof s=="number"?`0x${s.toString(16)}`:s)}})(),te={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},ze=yt,Tn=(function(){let r;return function(){return r=r||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),r}})(),An=6406,V=6407,A=6408,Sn=6409,In=6410,Ge=6402,Rn=34041,xt=33071,$o=9728,Wo=9729,re=3553,ne=34067,me=32879,pe=35866,pr=34069,Vo=34070,Ho=34071,jo=34072,Yo=34073,Xo=34074,gr=10241,yr=10240,_t=10242,Et=10243,Fn=32882,Qo=33082,qo=33083,Ko=33084,Jo=33085,Zo=34892,ea=34893,br=3317,Pn=3314,kn=32878,Cn=3316,Mn=3315,Dn=32877,ta=37443,ra=37441,na=37440,ia=33321,sa=36756,oa=33325,aa=33326,ca=33330,ua=33329,fa=33338,la=33337,da=33340,ha=33339,ma=33323,pa=36757,ga=33327,ya=33328,ba=33336,xa=33335,_a=33332,Ea=33331,wa=33334,va=33333,Ta=32849,Aa=35905,Sa=36194,Ia=36758,Ra=35898,Fa=35901,Pa=34843,ka=34837,Ca=36221,Ma=36239,Da=36215,Ba=36233,Oa=36209,Ua=36227,Na=32856,La=35907,za=36759,Ga=32855,$a=32854,Wa=32857,Va=34842,Ha=34836,ja=36220,Ya=36238,Xa=36975,Qa=36214,qa=36232,Ka=36226,Ja=36208,Za=33189,ec=33190,tc=36012,rc=36013,nc=35056,ie=5120,T=5121,wt=5122,Ie=5123,vt=5124,ge=5125,M=5126,Bn=32819,On=32820,Un=33635,z=5131,$e=36193,xr=33640,ic=35899,sc=35902,oc=36269,ac=34042,Tt=33319,Re=33320,At=6403,Fe=36244,Pe=36248,ye=36249;let _r;function St(r){if(!_r){const e={};e[An]={textureFormat:An,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,M]},e[Sn]={textureFormat:Sn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,M]},e[In]={textureFormat:In,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[T,z,$e,M]},e[V]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[T,z,$e,M,Un]},e[A]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[T,z,$e,M,Bn,On]},e[Ge]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[ge,Ie]},e[ia]={textureFormat:At,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[T]},e[sa]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ie]},e[oa]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[M,z]},e[aa]={textureFormat:At,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[M]},e[ca]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[T]},e[ua]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ie]},e[_a]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Ie]},e[Ea]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[wt]},e[wa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[va]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[vt]},e[ma]={textureFormat:Tt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[T]},e[pa]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ie]},e[ga]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[M,z]},e[ya]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[M]},e[ba]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[T]},e[xa]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ie]},e[fa]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ie]},e[la]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[wt]},e[da]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ge]},e[ha]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[vt]},e[Ta]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[Aa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[Sa]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[T,Un]},e[Ia]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ie]},e[Ra]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[M,z,ic]},e[Fa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[M,z,sc]},e[Pa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[M,z]},e[ka]={textureFormat:V,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[M]},e[Ca]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[T]},e[Ma]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ie]},e[Da]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Ie]},e[Ba]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[wt]},e[Oa]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[ge]},e[Ua]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[vt]},e[Na]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[La]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[za]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ie]},e[Ga]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[T,On,xr]},e[$a]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[T,Bn]},e[Wa]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[xr]},e[Va]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[M,z]},e[Ha]={textureFormat:A,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[M]},e[ja]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[T]},e[Ya]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ie]},e[Xa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[xr]},e[Qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Ie]},e[qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[wt]},e[Ka]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[vt]},e[Ja]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[ge]},e[Za]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Ie,ge]},e[ec]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[tc]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[M]},e[nc]={textureFormat:Rn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ac]},e[rc]={textureFormat:Rn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[oc]},Object.keys(e).forEach(function(t){const n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(i,s){const o=n.type[s];n.bytesPerElementMap[o]=i})}),_r=e}return _r[r]}function cc(r,e){const t=St(r);if(!t)throw"unknown internal format";const n=t.bytesPerElementMap[e];if(n===void 0)throw"unknown internal format";return n}function We(r){const e=St(r);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function Nn(r){return(r&r-1)===0}function uc(r,e,t,n){if(!Le(r))return Nn(e)&&Nn(t);const i=St(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function fc(r){const e=St(r);if(!e)throw"unknown internal format";return e.textureFilterable}function lc(r,e,t){return ze(e)?lr(e):t||T}function It(r,e,t,n,i){if(i%1!==0)throw"can\'t guess dimensions";if(!t&&!n){const s=Math.sqrt(i/(e===ne?6:1));s%1===0?(t=s,n=s):(t=i,n=1)}else if(n){if(!t&&(t=i/n,t%1))throw"can\'t guess dimensions"}else if(n=i/t,n%1)throw"can\'t guess dimensions";return{width:t,height:n}}function ke(r,e){e.colorspaceConversion!==void 0&&r.pixelStorei(ta,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&r.pixelStorei(ra,e.premultiplyAlpha),e.flipY!==void 0&&r.pixelStorei(na,e.flipY)}function Ln(r){r.pixelStorei(br,4),Le(r)&&(r.pixelStorei(Pn,0),r.pixelStorei(kn,0),r.pixelStorei(Cn,0),r.pixelStorei(Mn,0),r.pixelStorei(Dn,0))}function dc(r,e,t,n){n.minMag&&(t.call(r,e,gr,n.minMag),t.call(r,e,yr,n.minMag)),n.min&&t.call(r,e,gr,n.min),n.mag&&t.call(r,e,yr,n.mag),n.wrap&&(t.call(r,e,_t,n.wrap),t.call(r,e,Et,n.wrap),(e===me||bo(r,e))&&t.call(r,e,Fn,n.wrap)),n.wrapR&&t.call(r,e,Fn,n.wrapR),n.wrapS&&t.call(r,e,_t,n.wrapS),n.wrapT&&t.call(r,e,Et,n.wrapT),n.minLod!==void 0&&t.call(r,e,Qo,n.minLod),n.maxLod!==void 0&&t.call(r,e,qo,n.maxLod),n.baseLevel!==void 0&&t.call(r,e,Ko,n.baseLevel),n.maxLevel!==void 0&&t.call(r,e,Jo,n.maxLevel),n.compareFunc!==void 0&&t.call(r,e,ea,n.compareFunc),n.compareMode!==void 0&&t.call(r,e,Zo,n.compareMode)}function zn(r,e,t){const n=t.target||re;r.bindTexture(n,e),dc(r,n,r.texParameteri,t)}function hc(r){return r=r||te.textureColor,ze(r)?r:new Uint8Array([r[0]*255,r[1]*255,r[2]*255,r[3]*255])}function Er(r,e,t,n,i,s){t=t||te.textureOptions,s=s||A;const o=t.target||re;if(n=n||t.width,i=i||t.height,r.bindTexture(o,e),uc(r,n,i,s))r.generateMipmap(o);else{const a=fc(s)?Wo:$o;r.texParameteri(o,gr,a),r.texParameteri(o,yr,a),r.texParameteri(o,_t,xt),r.texParameteri(o,Et,xt)}}function Ve(r){return r.auto===!0||r.auto===void 0&&r.level===void 0}function wr(r,e){return e=e||{},e.cubeFaceOrder||[pr,Vo,Ho,jo,Yo,Xo]}function vr(r,e){const n=wr(r,e).map(function(i,s){return{face:i,ndx:s}});return n.sort(function(i,s){return i.face-s.face}),n}function Gn(r,e,t,n){n=n||te.textureOptions;const i=n.target||re,s=n.level||0;let o=t.width,a=t.height;const c=n.internalFormat||n.format||A,u=We(c),d=n.format||u.format,m=n.type||u.type;if(ke(r,n),r.bindTexture(i,e),i===ne){const p=t.width,y=t.height;let l,b;if(p/6===y)l=y,b=[0,0,1,0,2,0,3,0,4,0,5,0];else if(y/6===p)l=p,b=[0,0,0,1,0,2,0,3,0,4,0,5];else if(p/3===y/2)l=p/3,b=[0,0,1,0,2,0,0,1,1,1,2,1];else if(p/2===y/3)l=p/2,b=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can\'t figure out cube map from element: "+(t.src?t.src:t.nodeName);const _=Tn();_?(_.canvas.width=l,_.canvas.height=l,o=l,a=l,vr(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;_.drawImage(t,R,k,l,l,0,0,l,l),r.texImage2D(E.face,s,c,d,m,_.canvas)}),_.canvas.width=1,_.canvas.height=1):typeof createImageBitmap<"u"&&(o=l,a=l,vr(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;r.texImage2D(E.face,s,c,l,l,0,d,m,null),createImageBitmap(t,R,k,l,l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(N){ke(r,n),r.bindTexture(i,e),r.texImage2D(E.face,s,c,d,m,N),Ve(n)&&Er(r,e,n,o,a,c)})}))}else if(i===me||i===pe){const p=Math.min(t.width,t.height),y=Math.max(t.width,t.height),l=y/p;if(l%1!==0)throw"can not compute 3D dimensions of element";const b=t.width===y?1:0,_=t.height===y?1:0;r.pixelStorei(br,1),r.pixelStorei(Pn,t.width),r.pixelStorei(kn,0),r.pixelStorei(Dn,0),r.texImage3D(i,s,c,p,p,p,0,d,m,null);for(let E=0;E<l;++E){const R=E*p*b,k=E*p*_;r.pixelStorei(Cn,R),r.pixelStorei(Mn,k),r.texSubImage3D(i,s,0,0,E,p,p,1,d,m,t)}Ln(r)}else r.texImage2D(i,s,c,d,m,t);Ve(n)&&Er(r,e,n,o,a,c),zn(r,e,n)}function He(){}function mc(r){if(typeof document<"u"){const e=document.createElement("a");return e.href=r,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}else{const e=new URL(location.href).origin;return new URL(r,location.href).origin===e}}function pc(r,e){return e===void 0&&!mc(r)?"anonymous":e}function gc(r,e,t){t=t||He;let n;if(e=e!==void 0?e:te.crossOrigin,e=pc(r,e),typeof Image<"u"){n=new Image,e!==void 0&&(n.crossOrigin=e);const i=function(){n.removeEventListener("error",s),n.removeEventListener("load",o),n=null},s=function(){const c="couldn\'t load image: "+r;pn(c),t(c,n),i()},o=function(){t(null,n),i()};return n.addEventListener("error",s),n.addEventListener("load",o),n.src=r,n}else if(typeof ImageBitmap<"u"){let i,s;const o=function(){t(i,s)},a={};e&&(a.mode="cors"),fetch(r,a).then(function(c){if(!c.ok)throw c;return c.blob()}).then(function(c){return createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(c){s=c,setTimeout(o)}).catch(function(c){i=c,setTimeout(o)}),n=null}return n}function $n(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof ImageData<"u"&&r instanceof ImageData||typeof HTMLElement<"u"&&r instanceof HTMLElement}function Tr(r,e,t){return $n(r)?(setTimeout(function(){t(null,r)}),r):gc(r,e,t)}function Ar(r,e,t){t=t||te.textureOptions;const n=t.target||re;if(r.bindTexture(n,e),t.color===!1)return;const i=hc(t.color);if(n===ne)for(let s=0;s<6;++s)r.texImage2D(pr+s,0,A,1,1,0,A,T,i);else n===me||n===pe?r.texImage3D(n,0,A,1,1,1,0,A,T,i):r.texImage2D(n,0,A,1,1,0,A,T,i)}function yc(r,e,t,n){return n=n||He,t=t||te.textureOptions,Ar(r,e,t),t=Object.assign({},t),Tr(t.src,t.crossOrigin,function(s,o){s?n(s,e,o):(Gn(r,e,o,t),n(null,e,o))})}function bc(r,e,t,n){n=n||He;const i=t.src;if(i.length!==6)throw"there must be 6 urls for a cubemap";const s=t.level||0,o=t.internalFormat||t.format||A,a=We(o),c=t.format||a.format,u=t.type||T,d=t.target||re;if(d!==ne)throw"target must be TEXTURE_CUBE_MAP";Ar(r,e,t),t=Object.assign({},t);let m=6;const p=[],y=wr(r,t);let l;function b(_){return function(E,R){--m,E?p.push(E):R.width!==R.height?p.push("cubemap face img is not a square: "+R.src):(ke(r,t),r.bindTexture(d,e),m===5?wr().forEach(function(k){r.texImage2D(k,s,o,c,u,R)}):r.texImage2D(_,s,o,c,u,R),Ve(t)&&r.generateMipmap(d)),m===0&&n(p.length?p:void 0,e,l)}}l=i.map(function(_,E){return Tr(_,t.crossOrigin,b(y[E]))})}function xc(r,e,t,n){n=n||He;const i=t.src,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||T,u=t.target||pe;if(u!==me&&u!==pe)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";Ar(r,e,t),t=Object.assign({},t);let d=i.length;const m=[];let p;const y=t.level||0;let l=t.width,b=t.height;const _=i.length;let E=!0;function R(k){return function(N,Q){if(--d,N)m.push(N);else{if(ke(r,t),r.bindTexture(u,e),E){E=!1,l=t.width||Q.width,b=t.height||Q.height,r.texImage3D(u,y,s,l,b,_,0,a,c,null);for(let q=0;q<_;++q)r.texSubImage3D(u,y,0,0,q,l,b,1,a,c,Q)}else{let q=Q,L;(Q.width!==l||Q.height!==b)&&(L=Tn(),q=L.canvas,L.canvas.width=l,L.canvas.height=b,L.drawImage(Q,0,0,l,b)),r.texSubImage3D(u,y,0,0,k,l,b,1,a,c,q),L&&q===L.canvas&&(L.canvas.width=0,L.canvas.height=0)}Ve(t)&&r.generateMipmap(u)}d===0&&n(m.length?m:void 0,e,p)}}p=i.map(function(k,N){return Tr(k,t.crossOrigin,R(N))})}function _c(r,e,t,n){n=n||te.textureOptions;const i=n.target||re;r.bindTexture(i,e);let s=n.width,o=n.height,a=n.depth;const c=n.level||0,u=n.internalFormat||n.format||A,d=We(u),m=n.format||d.format,p=n.type||lc(r,t,d.type);if(ze(t))t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));else{const _=mn(p);t=new _(t)}const y=cc(u,p),l=t.byteLength/y;if(l%1)throw"length wrong size for format: "+vn(r,m);let b;if(i===me||i===pe)if(!s&&!o&&!a){const _=Math.cbrt(l);if(_%1!==0)throw"can\'t guess cube size of array of numElements: "+l;s=_,o=_,a=_}else s&&(!o||!a)?(b=It(r,i,o,a,l/s),o=b.width,a=b.height):o&&(!s||!a)?(b=It(r,i,s,a,l/o),s=b.width,a=b.height):(b=It(r,i,s,o,l/a),s=b.width,o=b.height);else b=It(r,i,s,o,l),s=b.width,o=b.height;if(Ln(r),r.pixelStorei(br,n.unpackAlignment||1),ke(r,n),i===ne){const _=y/t.BYTES_PER_ELEMENT,E=l/6*_;vr(r,n).forEach(R=>{const k=E*R.ndx,N=t.subarray(k,k+E);r.texImage2D(R.face,c,u,s,o,0,m,p,N)})}else i===me||i===pe?r.texImage3D(i,c,u,s,o,a,0,m,p,t):r.texImage2D(i,c,u,s,o,0,m,p,t);return{width:s,height:o,depth:a,type:p}}function Ec(r,e,t){const n=t.target||re;r.bindTexture(n,e);const i=t.level||0,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||o.type;if(ke(r,t),n===ne)for(let u=0;u<6;++u)r.texImage2D(pr+u,i,s,t.width,t.height,0,a,c,null);else n===me||n===pe?r.texImage3D(n,i,s,t.width,t.height,t.depth,0,a,c,null):r.texImage2D(n,i,s,t.width,t.height,0,a,c,null)}function Wn(r,e,t){t=t||He,e=e||te.textureOptions;const n=r.createTexture(),i=e.target||re;let s=e.width||1,o=e.height||1;const a=e.internalFormat||A;r.bindTexture(i,n),i===ne&&(r.texParameteri(i,_t,xt),r.texParameteri(i,Et,xt));let c=e.src;if(c)if(typeof c=="function"&&(c=c(r,e)),typeof c=="string")yc(r,n,e,t);else if(ze(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||ze(c[0]))){const u=_c(r,n,c,e);s=u.width,o=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||$n(c[0]))?i===ne?bc(r,n,e,t):xc(r,n,e,t):(Gn(r,n,c,e),s=c.width,o=c.height);else Ec(r,n,e);return Ve(e)&&Er(r,n,e,s,o,a),zn(r,n,e),n}const Sr=pn;function Vn(r){return typeof document<"u"&&document.getElementById?document.getElementById(r):null}const Rt=33984,Ft=34962,wc=34963,vc=35713,Tc=35714,Ac=35632,Sc=35633,Ic=35981,Hn=35718,Rc=35721,Fc=35971,Pc=35382,kc=35396,Cc=35398,Mc=35392,Dc=35395,Pt=5126,jn=35664,Yn=35665,Xn=35666,Ir=5124,Qn=35667,qn=35668,Kn=35669,Jn=35670,Zn=35671,ei=35672,ti=35673,ri=35674,ni=35675,ii=35676,Bc=35678,Oc=35680,Uc=35679,Nc=35682,Lc=35685,zc=35686,Gc=35687,$c=35688,Wc=35689,Vc=35690,Hc=36289,jc=36292,Yc=36293,Rr=5125,si=36294,oi=36295,ai=36296,Xc=36298,Qc=36299,qc=36300,Kc=36303,Jc=36306,Zc=36307,eu=36308,tu=36311,kt=3553,Ct=34067,Fr=32879,Mt=35866,x={};function ci(r,e){return x[e].bindPoint}function ru(r,e){return function(t){r.uniform1f(e,t)}}function nu(r,e){return function(t){r.uniform1fv(e,t)}}function iu(r,e){return function(t){r.uniform2fv(e,t)}}function su(r,e){return function(t){r.uniform3fv(e,t)}}function ou(r,e){return function(t){r.uniform4fv(e,t)}}function ui(r,e){return function(t){r.uniform1i(e,t)}}function fi(r,e){return function(t){r.uniform1iv(e,t)}}function li(r,e){return function(t){r.uniform2iv(e,t)}}function di(r,e){return function(t){r.uniform3iv(e,t)}}function hi(r,e){return function(t){r.uniform4iv(e,t)}}function au(r,e){return function(t){r.uniform1ui(e,t)}}function cu(r,e){return function(t){r.uniform1uiv(e,t)}}function uu(r,e){return function(t){r.uniform2uiv(e,t)}}function fu(r,e){return function(t){r.uniform3uiv(e,t)}}function lu(r,e){return function(t){r.uniform4uiv(e,t)}}function du(r,e){return function(t){r.uniformMatrix2fv(e,!1,t)}}function hu(r,e){return function(t){r.uniformMatrix3fv(e,!1,t)}}function mu(r,e){return function(t){r.uniformMatrix4fv(e,!1,t)}}function pu(r,e){return function(t){r.uniformMatrix2x3fv(e,!1,t)}}function gu(r,e){return function(t){r.uniformMatrix3x2fv(e,!1,t)}}function yu(r,e){return function(t){r.uniformMatrix2x4fv(e,!1,t)}}function bu(r,e){return function(t){r.uniformMatrix4x2fv(e,!1,t)}}function xu(r,e){return function(t){r.uniformMatrix3x4fv(e,!1,t)}}function _u(r,e){return function(t){r.uniformMatrix4x3fv(e,!1,t)}}function O(r,e,t,n){const i=ci(r,e);return Le(r)?function(s){let o,a;!s||dr(r,s)?(o=s,a=null):(o=s.texture,a=s.sampler),r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,o),r.bindSampler(t,a)}:function(s){r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,s)}}function U(r,e,t,n,i){const s=ci(r,e),o=new Int32Array(i);for(let a=0;a<i;++a)o[a]=t+a;return Le(r)?function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]);let d,m;!c||dr(r,c)?(d=c,m=null):(d=c.texture,m=c.sampler),r.bindSampler(t,m),r.bindTexture(s,d)})}:function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]),r.bindTexture(s,c)})}}x[Pt]={Type:Float32Array,size:4,setter:ru,arraySetter:nu},x[jn]={Type:Float32Array,size:8,setter:iu,cols:2},x[Yn]={Type:Float32Array,size:12,setter:su,cols:3},x[Xn]={Type:Float32Array,size:16,setter:ou,cols:4},x[Ir]={Type:Int32Array,size:4,setter:ui,arraySetter:fi},x[Qn]={Type:Int32Array,size:8,setter:li,cols:2},x[qn]={Type:Int32Array,size:12,setter:di,cols:3},x[Kn]={Type:Int32Array,size:16,setter:hi,cols:4},x[Rr]={Type:Uint32Array,size:4,setter:au,arraySetter:cu},x[si]={Type:Uint32Array,size:8,setter:uu,cols:2},x[oi]={Type:Uint32Array,size:12,setter:fu,cols:3},x[ai]={Type:Uint32Array,size:16,setter:lu,cols:4},x[Jn]={Type:Uint32Array,size:4,setter:ui,arraySetter:fi},x[Zn]={Type:Uint32Array,size:8,setter:li,cols:2},x[ei]={Type:Uint32Array,size:12,setter:di,cols:3},x[ti]={Type:Uint32Array,size:16,setter:hi,cols:4},x[ri]={Type:Float32Array,size:32,setter:du,rows:2,cols:2},x[ni]={Type:Float32Array,size:48,setter:hu,rows:3,cols:3},x[ii]={Type:Float32Array,size:64,setter:mu,rows:4,cols:4},x[Lc]={Type:Float32Array,size:32,setter:pu,rows:2,cols:3},x[zc]={Type:Float32Array,size:32,setter:yu,rows:2,cols:4},x[Gc]={Type:Float32Array,size:48,setter:gu,rows:3,cols:2},x[$c]={Type:Float32Array,size:48,setter:xu,rows:3,cols:4},x[Wc]={Type:Float32Array,size:64,setter:bu,rows:4,cols:2},x[Vc]={Type:Float32Array,size:64,setter:_u,rows:4,cols:3},x[Bc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Oc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Uc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Fr},x[Nc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Hc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Mt},x[jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Mt},x[Yc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Xc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Fr},x[qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Kc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Mt},x[Jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Zc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Fr},x[eu]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[tu]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Mt};function Dt(r,e){return function(t){if(t.value)switch(r.disableVertexAttribArray(e),t.value.length){case 4:r.vertexAttrib4fv(e,t.value);break;case 3:r.vertexAttrib3fv(e,t.value);break;case 2:r.vertexAttrib2fv(e,t.value);break;case 1:r.vertexAttrib1fv(e,t.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribPointer(e,t.numComponents||t.size,t.type||Pt,t.normalize||!1,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function se(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4iv(e,t.value);else throw new Error("The length of an integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ir,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Bt(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4uiv(e,t.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Rr,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Pr(r,e,t){const n=t.size,i=t.count;return function(s){r.bindBuffer(Ft,s.buffer);const o=s.size||s.numComponents||n,a=o/i,c=s.type||Pt,d=x[c].size*o,m=s.normalize||!1,p=s.offset||0,y=d/i;for(let l=0;l<i;++l)r.enableVertexAttribArray(e+l),r.vertexAttribPointer(e+l,a,c,m,d,p+y*l),r.vertexAttribDivisor&&r.vertexAttribDivisor(e+l,s.divisor||0)}}const S={};S[Pt]={size:4,setter:Dt},S[jn]={size:8,setter:Dt},S[Yn]={size:12,setter:Dt},S[Xn]={size:16,setter:Dt},S[Ir]={size:4,setter:se},S[Qn]={size:8,setter:se},S[qn]={size:12,setter:se},S[Kn]={size:16,setter:se},S[Rr]={size:4,setter:Bt},S[si]={size:8,setter:Bt},S[oi]={size:12,setter:Bt},S[ai]={size:16,setter:Bt},S[Jn]={size:4,setter:se},S[Zn]={size:8,setter:se},S[ei]={size:12,setter:se},S[ti]={size:16,setter:se},S[ri]={size:4,setter:Pr,count:2},S[ni]={size:9,setter:Pr,count:3},S[ii]={size:16,setter:Pr,count:4};const Eu=/ERROR:\\s*\\d+:(\\d+)/gi;function wu(r,e="",t=0){const n=[...e.matchAll(Eu)],i=new Map(n.map((s,o)=>{const a=parseInt(s[1]),c=n[o+1],u=c?c.index:e.length,d=e.substring(s.index,u);return[a-1,d]}));return r.split(`\n`).map((s,o)=>{const a=i.get(o);return`${o+1+t}: ${s}${a?`\n\n^^^ ${a}`:""}`}).join(`\n`)}const mi=/^[ \\t]*\\n/;function pi(r){let e=0;return mi.test(r)&&(e=1,r=r.replace(mi,"")),{lineOffset:e,shaderSource:r}}function vu(r,e){return r.errorCallback(e),r.callback&&setTimeout(()=>{r.callback(`${e}\n${r.errors.join(`\n`)}`)}),null}function Tu(r,e,t,n){if(n=n||Sr,!r.getShaderParameter(t,vc)){const s=r.getShaderInfoLog(t),{lineOffset:o,shaderSource:a}=pi(r.getShaderSource(t)),c=`${wu(a,s,o)}\nError compiling ${vn(r,e)}: ${s}`;return n(c),c}return""}function kr(r,e,t){let n,i,s;if(typeof e=="function"&&(t=e,e=void 0),typeof r=="function")t=r,r=void 0;else if(r&&!Array.isArray(r)){const u=r;t=u.errorCallback,r=u.attribLocations,n=u.transformFeedbackVaryings,i=u.transformFeedbackMode,s=u.callback}const o=t||Sr,a=[],c={errorCallback(u,...d){a.push(u),o(u,...d)},transformFeedbackVaryings:n,transformFeedbackMode:i,callback:s,errors:a};{let u={};Array.isArray(r)?r.forEach(function(d,m){u[d]=e?e[m]:m}):u=r||{},c.attribLocations=u}return c}const Au=["VERTEX_SHADER","FRAGMENT_SHADER"];function Su(r,e){if(e.indexOf("frag")>=0)return Ac;if(e.indexOf("vert")>=0)return Sc}function Iu(r,e,t){const n=r.getAttachedShaders(e);for(const i of n)t.has(i)&&r.deleteShader(i);r.deleteProgram(e)}const Ru=(r=0)=>new Promise(e=>setTimeout(e,r));function Fu(r,e,t){const n=r.createProgram(),{attribLocations:i,transformFeedbackVaryings:s,transformFeedbackMode:o}=kr(t);for(let a=0;a<e.length;++a){let c=e[a];if(typeof c=="string"){const u=Vn(c),d=u?u.text:c;let m=r[Au[a]];u&&u.type&&(m=Su(r,u.type)||m),c=r.createShader(m),r.shaderSource(c,pi(d).shaderSource),r.compileShader(c),r.attachShader(n,c)}}Object.entries(i).forEach(([a,c])=>r.bindAttribLocation(n,c,a));{let a=s;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),r.transformFeedbackVaryings(n,a,o||Ic))}return r.linkProgram(n),n}function Pu(r,e,t,n,i){const s=kr(t,n,i),o=new Set(e),a=Fu(r,e,s);function c(u,d){const m=Cu(u,d,s.errorCallback);return m&&Iu(u,d,o),m}if(s.callback){ku(r,a).then(()=>{const u=c(r,a);s.callback(u,u?void 0:a)});return}return c(r,a)?void 0:a}async function ku(r,e){const t=r.getExtension("KHR_parallel_shader_compile"),n=t?(s,o)=>s.getProgramParameter(o,t.COMPLETION_STATUS_KHR):()=>!0;let i=0;do await Ru(i),i=1e3/60;while(!n(r,e))}function Cu(r,e,t){if(t=t||Sr,!r.getProgramParameter(e,Tc)){const i=r.getProgramInfoLog(e);t(`Error in program linking: ${i}`);const o=r.getAttachedShaders(e).map(a=>Tu(r,r.getShaderParameter(a,r.SHADER_TYPE),a,t));return`${i}\n${o.filter(a=>a).join(`\n`)}`}}function Mu(r,e,t,n,i){return Pu(r,e,t,n,i)}function gi(r){const e=r.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Du=/(\\.|\\[|]|\\w+)/g,Bu=r=>r>="0"&&r<="9";function Ou(r,e,t,n){const i=r.split(Du).filter(a=>a!=="");let s=0,o="";for(;;){const a=i[s++];o+=a;const c=Bu(a[0]),u=c?parseInt(a):a;if(c&&(o+=i[s++]),s===i.length){t[u]=e;break}else{const m=i[s++],p=m==="[",y=t[u]||(p?[]:{});t[u]=y,t=y,n[o]=n[o]||(function(l){return function(b){yi(l,b)}})(y),o+=m}}}function Uu(r,e){let t=0;function n(a,c,u){const d=c.name.endsWith("[0]"),m=c.type,p=x[m];if(!p)throw new Error(`unknown type: 0x${m.toString(16)}`);let y;if(p.bindPoint){const l=t;t+=c.size,d?y=p.arraySetter(r,m,l,u,c.size):y=p.setter(r,m,l,u,c.size)}else p.arraySetter&&d?y=p.arraySetter(r,u):y=p.setter(r,u);return y.location=u,y}const i={},s={},o=r.getProgramParameter(e,Hn);for(let a=0;a<o;++a){const c=r.getActiveUniform(e,a);if(gi(c))continue;let u=c.name;u.endsWith("[0]")&&(u=u.substr(0,u.length-3));const d=r.getUniformLocation(e,c.name);if(d){const m=n(e,c,d);i[u]=m,Ou(u,m,s,i)}}return i}function Nu(r,e){const t={},n=r.getProgramParameter(e,Fc);for(let i=0;i<n;++i){const s=r.getTransformFeedbackVarying(e,i);t[s.name]={index:i,type:s.type,size:s.size}}return t}function Lu(r,e){const t=r.getProgramParameter(e,Hn),n=[],i=[];for(let a=0;a<t;++a){i.push(a),n.push({});const c=r.getActiveUniform(e,a);n[a].name=c.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const c=a[0],u=a[1];r.getActiveUniforms(e,i,r[c]).forEach(function(d,m){n[m][u]=d})});const s={},o=r.getProgramParameter(e,Pc);for(let a=0;a<o;++a){const c=r.getActiveUniformBlockName(e,a),u={index:r.getUniformBlockIndex(e,c),usedByVertexShader:r.getActiveUniformBlockParameter(e,a,kc),usedByFragmentShader:r.getActiveUniformBlockParameter(e,a,Cc),size:r.getActiveUniformBlockParameter(e,a,Mc),uniformIndices:r.getActiveUniformBlockParameter(e,a,Dc)};u.used=u.usedByVertexShader||u.usedByFragmentShader,s[c]=u}return{blockSpecs:s,uniformData:n}}function yi(r,e){for(const t in e){const n=r[t];typeof n=="function"?n(e[t]):yi(r[t],e[t])}}function bi(r,...e){const t=r.uniformSetters||r,n=e.length;for(let i=0;i<n;++i){const s=e[i];if(Array.isArray(s)){const o=s.length;for(let a=0;a<o;++a)bi(t,s[a])}else for(const o in s){const a=t[o];a&&a(s[o])}}}function zu(r,e){const t={},n=r.getProgramParameter(e,Rc);for(let i=0;i<n;++i){const s=r.getActiveAttrib(e,i);if(gi(s))continue;const o=r.getAttribLocation(e,s.name),a=S[s.type],c=a.setter(r,o,a);c.location=o,t[s.name]=c}return t}function Gu(r,e){for(const t in e){const n=r[t];n&&n(e[t])}}function $u(r,e,t){t.vertexArrayObject?r.bindVertexArray(t.vertexArrayObject):(Gu(e.attribSetters||e,t.attribs),t.indices&&r.bindBuffer(wc,t.indices))}function xi(r,e){const t=Uu(r,e),n=zu(r,e),i={program:e,uniformSetters:t,attribSetters:n};return Le(r)&&(i.uniformBlockSpec=Lu(r,e),i.transformFeedbackInfo=Nu(r,e)),i}const Wu=/\\s|{|}|;/;function Vu(r,e,t,n,i){const s=kr(t,n,i),o=[];if(e=e.map(function(u){if(!Wu.test(u)){const d=Vn(u);if(d)u=d.text;else{const m=`no element with id: ${u}`;s.errorCallback(m),o.push(m)}}return u}),o.length)return vu(s,"");const a=s.callback;a&&(s.callback=(u,d)=>{a(u,u?void 0:xi(r,d))});const c=Mu(r,e,s);return c?xi(r,c):null}const Hu=4,_i=5123;function ju(r,e,t,n,i,s){t=t===void 0?Hu:t;const o=e.indices,a=e.elementType,c=n===void 0?e.numElements:n;i=i===void 0?0:i,a||o?s!==void 0?r.drawElementsInstanced(t,c,a===void 0?_i:e.elementType,i,s):r.drawElements(t,c,a===void 0?_i:e.elementType,i):s!==void 0?r.drawArraysInstanced(t,i,c,s):r.drawArrays(t,i,c)}const Ei=36160,Ot=36161,Yu=3553,Xu=5121,Qu=6402,qu=6408,Ku=33190,Ju=36012,Zu=35056,ef=36013,tf=32854,rf=32855,nf=36194,wi=33189,vi=6401,Ti=36168,Cr=34041,Mr=36064,Ut=36096,Ai=36128,Dr=33306,Br=33071,Or=9729,sf=[{format:qu,type:Xu,min:Or,wrap:Br},{format:Cr}],G={};G[Cr]=Dr,G[vi]=Ai,G[Ti]=Ai,G[Qu]=Ut,G[wi]=Ut,G[Ku]=Ut,G[Ju]=Ut,G[Zu]=Dr,G[ef]=Dr;function of(r,e){return G[r]||G[e]}const oe={};oe[tf]=!0,oe[rf]=!0,oe[nf]=!0,oe[Cr]=!0,oe[wi]=!0,oe[vi]=!0,oe[Ti]=!0;function af(r){return oe[r]}const cf=32;function uf(r){return r>=Mr&&r<Mr+cf}function Si(r,e,t,n){const i=Ei,s=r.createFramebuffer();r.bindFramebuffer(i,s),t=t||r.drawingBufferWidth,n=n||r.drawingBufferHeight,e=e||sf;const o=[],a={framebuffer:s,attachments:[],width:t,height:n};return e.forEach(function(c,u){let d=c.attachment;const m=c.samples,p=c.format;let y=c.attachmentPoint||of(p,c.internalFormat);if(y||(y=Mr+u),uf(y)&&o.push(y),!d)if(m!==void 0||af(p))d=r.createRenderbuffer(),r.bindRenderbuffer(Ot,d),m>1?r.renderbufferStorageMultisample(Ot,m,p,t,n):r.renderbufferStorage(Ot,p,t,n);else{const l=Object.assign({},c);l.width=t,l.height=n,l.auto===void 0&&(l.auto=!1,l.min=l.min||l.minMag||Or,l.mag=l.mag||l.minMag||Or,l.wrapS=l.wrapS||l.wrap||Br,l.wrapT=l.wrapT||l.wrap||Br),d=Wn(r,l)}if(yo(r,d))r.framebufferRenderbuffer(i,y,Ot,d);else if(dr(r,d))c.layer!==void 0?r.framebufferTextureLayer(i,y,d,c.level||0,c.layer):r.framebufferTexture2D(i,y,c.target||Yu,d,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(d)}),r.drawBuffers&&r.drawBuffers(o),a}function ff(r,e,t){t=t||Ei,e?(r.bindFramebuffer(t,e.framebuffer),r.viewport(0,0,e.width,e.height)):(r.bindFramebuffer(t,null),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight))}function D(r,e){return()=>e instanceof WebGLTexture?e:Wn(r,{src:e,wrap:r.CLAMP_TO_EDGE})}const Ce=2;class je{constructor(e){this.id="_";const{context:t,width:n,height:i}=e;this.context=t,this.options=e;const s=this.buildDefines();this.programInfo=Vu(this.context,[s+this.getVertexShader(),s+this.getFragmentShader()]),this.bufferInfo=Go(this.context,this.getBuffers()),this.fbi=Si(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],n,i),this.output=this.fbi.attachments[0]}resizeOutput(e,t){this.fbi=Si(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],e,t),this.options.width=e,this.options.height=t,this.output=this.fbi.attachments[0]}getDefines(){return{}}getBuffers(){return{position:{numComponents:2,data:[-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]},texture_coord:{numComponents:2,data:[0,0,0,1,1,0,1,1,0,1,1,0]}}}buildDefines(){let e="";const t=this.getDefines();for(let n in t)e+=`#define ${n} ${t[n].toFixed(1)}\n`;return e}run(e){this.profiler?.pushContext(`[${this.id}] PROG : ${this.constructor.name}`),this.profiler?.pushContext(`[${this.id}] UNIFORMS`);for(const i in e)typeof e[i]=="function"&&(this.profiler?.pushContext(`[${this.id}] UNI : ${i}`),e[i]=e[i](),this.profiler?.popContext(`[${this.id}] UNI : ${i}`));this.profiler?.popContext(`[${this.id}] UNIFORMS`);const t=Date.now();let n=0;this.lastRun&&(n=(t-this.lastRun)/1e3),this.lastRun=t,this.context.viewport(0,0,this.context.canvas.width,this.context.canvas.height),this.context.useProgram(this.programInfo.program),$u(this.context,this.programInfo,this.bufferInfo),bi(this.programInfo,{delta:n,canvas:[this.context.canvas.width,this.context.canvas.height],...e}),ff(this.context,this.options.disableFramebuffer?null:this.fbi),ju(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(e){this.profiler=e}}var lf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform sampler2D background;\nuniform sampler2D foreground;\nuniform sampler2D threshold;\n\nvoid main() {\n vec4 backgroundColor = texture2D(background, _texture_coord);\n vec4 foregroundColor = texture2D(foreground, _texture_coord);\n vec4 tresholdColor = texture2D(threshold, _texture_coord);\n gl_FragColor = foregroundColor * tresholdColor.a +\n backgroundColor * (1. - tresholdColor.a);\n}\n`,df=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n _texture_coord.y = 1. - texture_coord.y;\n}\n`;class Ur extends je{getFragmentShader(){return lf}getVertexShader(){return df}}class Nr{constructor(){this.steps=[]}addStep(e){this.steps.push(e)}async run(){for(const e of this.steps)e.program.run(e.getUniforms())}resizeOutput(e,t){this.profiler?.pushContext(`PIP [${this.constructor.name}]`);for(const n of this.steps)n.preventResize||n.program.resizeOutput(e,t);this.profiler?.popContext(`PIP [${this.constructor.name}]`)}setProfiler(e){this.profiler=e;for(const t of this.steps)t.program.setProfiler(e)}setId(e){for(const t of this.steps)t.program.id=e}}class Lr extends Nr{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class Ii extends Lr{constructor(e){super(),this.context=e,this.preciseMaskEnabled=!0;const t={context:e,height:e.canvas.height,width:e.canvas.width},n=new Ur({...t,disableFramebuffer:!0});this.addStep({program:n,getUniforms:()=>({background:D(e,this.inputBackgroundImage),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}var hf=`precision mediump float;\n\nvarying vec2 _texture_coord;\nuniform sampler2D texture;\n\nvoid main() { gl_FragColor = texture2D(texture, _texture_coord); }\n`,mf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\nuniform bool invert_y;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n if (invert_y) {\n _texture_coord.y = 1. - texture_coord.y;\n }\n}\n`;class pf extends je{getFragmentShader(){return hf}getVertexShader(){return mf}}class gf extends Nr{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t};this.addStep({program:new pf({...i,disableFramebuffer:!0}),getUniforms:()=>({texture:D(e,this.inputImage),invert_y:!0})})}setData(e){this.inputImage=e}}async function Ri(r){return new Promise(e=>{setTimeout(()=>{e()},r)})}var yf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,bf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`,zr=(r=>(r[r.LINEAR=0]="LINEAR",r[r.GAUSSIAN=1]="GAUSSIAN",r))(zr||{});class Fi extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return yf+this.createLoopFunction()}getVertexShader(){return bf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = 1.;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}getFactor(e,t){return this.options.type===1?this.getLinearFactor(e,t):this.getLinearFactor(e,t)}getLinearFactor(e,t){return 1}getGaussianFactor(e,t){const n=Math.PI*2,i=Math.max(this.options.radius??1,1),s=1/(n*i**2),o=-(e**2+t**2),a=s*o;return s*Math.E**a}}var xf=`#version 300 es\n// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts\n\nprecision highp float;\nuniform sampler2D input_frame;\nuniform sampler2D segmentation_mask;\nuniform sampler2D threshold;\nuniform vec2 texel_size;\nuniform float step;\nuniform float radius;\nuniform float offset;\nuniform float sigma_texel;\nuniform float sigma_color;\n\nin vec2 _texture_coord;\nout vec4 outColor;\n\nfloat gaussian(float x, float sigma) {\n float coeff = -0.5 / (sigma * sigma * 4.0 + 1.0e-6);\n return exp((x * x) * coeff);\n}\n\nvoid main() {\n vec2 centerCoord = _texture_coord;\n vec3 centerColor = texture(input_frame, centerCoord).rgb;\n float newVal = 0.0;\n float spaceWeight = 0.0;\n float colorWeight = 0.0;\n float totalWeight = 0.0;\n // Subsample kernel space.\n for (float i = -radius + offset; i <= radius; i += step) {\n for (float j = -radius + offset; j <= radius; j += step) {\n vec2 shift = vec2(j, i) * texel_size;\n vec2 coord = vec2(centerCoord + shift);\n vec3 frameColor = texture(input_frame, coord).rgb;\n float threshold = texture(threshold, coord).a;\n float outVal = texture(segmentation_mask, coord).a;\n\n spaceWeight = gaussian(distance(centerCoord, coord), sigma_texel);\n colorWeight = gaussian(distance(centerColor, frameColor), sigma_color);\n totalWeight += spaceWeight * colorWeight;\n newVal += spaceWeight * colorWeight * outVal * threshold;\n }\n }\n newVal /= totalWeight;\n outColor = vec4(vec3(0.), newVal);\n}`,_f=`#version 300 es\nin vec2 position;\nin vec2 texture_coord;\nout vec2 _texture_coord;\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n _texture_coord = texture_coord;\n}`;class Ef extends je{getFragmentShader(){return xf}getVertexShader(){return _f}}class wf extends Nr{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t},s=new Fi({...i,radius:1,type:zr.GAUSSIAN});this.jointBilateral=new Ef(i),this.addStep({program:s,getUniforms:()=>({inputs:D(e,this.inputMask)})}),this.addStep({program:this.jointBilateral,getUniforms:()=>{const a=this.inputImage?.width??1,c=this.inputImage?.height??1;this.inputMask?.width,this.inputMask?.height;const u=3,d=Math.max(1,Math.sqrt(u)*.66),m=1/a,p=1/c;return{input_frame:D(e,this.inputImage),segmentation_mask:D(e,this.inputMask),texel_size:[m,p],step:d,radius:u,offset:d>1?d*.5:0,sigma_texel:Math.max(m,p)*u,sigma_color:u}}}),this.output=this.jointBilateral.output}setData(e,t){this.previousInputImage=this.inputImage?this.inputImage:e,this.previousInputMask=this.inputMask?this.inputMask:t,this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t),this.output=this.jointBilateral.output}}class vf{constructor(e){this.queries=[],this.context=e,this.extension=e.getExtension("EXT_disjoint_timer_query_webgl2")}start(){}stop(){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT)}pushContext(e){this.createQuery("PUSH",e)}popContext(e){this.createQuery("POP",e)}createQuery(e,t){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT),this.activeQuery=this.context.createQuery(),this.context.beginQuery(this.extension.TIME_ELAPSED_EXT,this.activeQuery),this.queries.push({name:t,action:e,query:this.activeQuery})}async getResolvedQueries(){const e=(await Promise.all([...this.queries].map(t=>this.resolveQuery(t)))).filter(t=>t);for(let t=1;t<e.length;++t)e[t].timestamp+=e[t-1].duration+e[t-1].timestamp;return e}async resolveQuery(e){if(!await this.awaitQueryAvailable(e)){console.log("Unawaitable query",e);return}if(this.context.getParameter(this.extension.GPU_DISJOINT_EXT)){console.log("Disjointed query",e);return}return{...e,duration:this.context.getQueryParameter(e.query,this.context.QUERY_RESULT),timestamp:0}}async awaitQueryAvailable(e){for(let t=0;t<10;++t){if(this.context.getQueryParameter(e.query,this.context.QUERY_RESULT_AVAILABLE))return e;await Ri(200)}}}class Nt{constructor(){this.previousImageWidth=0,this.previousImageHeight=0,this.previousMaskWidth=Ce,this.previousMaskHeight=Ce,this.postProcessingEnabled=!0;const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl2 context";this.canvas=e,this.context=t,this.improveMask=new wf(this.context,Ce,Ce)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(e){const t=new vf(this.context);return this.profiler=t,t.start(),await Ri(e),this.profiler=void 0,t.stop(),t.getResolvedQueries()}async render(e,t){if(!this.pipeline)throw"missing pipeline";(this.previousImageHeight!==e.height||this.previousImageWidth!==e.width)&&this.resizeOutput(e.width,e.height),(this.previousMaskHeight!==t.height||this.previousMaskWidth!==t.width)&&(this.improveMask.resizeOutput(t.width,t.height),this.previousMaskWidth=t.width,this.previousMaskHeight=t.height);const n="renderer";this.profiler?.pushContext(n),this.improveMask.setProfiler(this.profiler),this.pipeline.setProfiler(this.profiler);const i=await createImageBitmap(t);let s=i;return this.postProcessingEnabled&&(this.improveMask.setData(e,i),this.improveMask.run(),s=this.improveMask.output),this.pipeline.setData(e,s),await this.pipeline.run(),this.profiler?.popContext(n),this.canvas}resizeOutput(e,t){this.canvas.width=e,this.canvas.height=t,this.pipeline?.resizeOutput(e,t),this.previousImageWidth=e,this.previousImageHeight=t}destroy(){const e=this.context?.getExtension("WEBGL_lose_context");e&&e.loseContext()}}class Pi extends Nt{constructor(){super(),this.pipeline=new Ii(this.context);const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl context";this.backgroundImageResizerCanvas=e,this.backgroundImageResizerContext=t,this.backgroundImageResizer=new gf(this.backgroundImageResizerContext,0,0)}setBackgroundImage(e){this.backgroundImage=e,this.updateBackgroundImage()}updateBackgroundImage(){const{width:e,height:t}=this.canvas;this.backgroundImageResizer.resizeOutput(e,t),this.backgroundImageResizer.setData(this.backgroundImage),this.backgroundImageResizer.run(),this.pipeline.inputBackgroundImage=this.backgroundImageResizerCanvas}resizeOutput(e,t){super.resizeOutput(e,t),this.backgroundImageResizerCanvas.width=e,this.backgroundImageResizerCanvas.height=t,this.backgroundImageResizer.resizeOutput(e,t),this.updateBackgroundImage()}destroy(){const e=this.backgroundImageResizerContext?.getExtension("WEBGL_lose_context");e&&e.loseContext(),super.destroy()}}class Tf extends Pi{setBackgroundVideo(e){this.frameReader=e}async render(e,t){return await this.readNextVideoFrame(),super.render(e,t)}async readNextVideoFrame(){const e=await this.frameReader?.read();if(e?.value){const t=await createImageBitmap(e.value);this.setBackgroundImage(t),e.value.close()}}}class ki{blurBackground(e){return new no(e)}blurSilhouette(e){return new io(e)}imageBackground(){return new so}videoBackground(){return new Tf}}var Af=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\nuniform sampler2D mask;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,Sf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`;class If extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return Af+this.createLoopFunction()}getVertexShader(){return Sf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n float maxLength = length(normalizedRadius);\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = (1.- texture2D(mask, _texture_coord + diff).a) * (maxLength - length(diff)) / maxLength;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}const Rf=10,Ff=2,Pf=8;class kf extends Lr{constructor(e,t){super(),this.context=e,this.radius=t;const n={context:e,height:e.canvas.height,width:e.canvas.width};this.blur=new If({...n,radius:t,...this.getBlurTextureSize(e.canvas.width,e.canvas.height)});const i=new Ur({...n,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:D(e,this.inputImage),mask:D(e,this.inputMask)})}),this.addStep({program:i,getUniforms:()=>({background:D(e,this.blur.output),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}getBlurTextureSize(e,t){const n=this.radius>Rf?Pf:Ff;return{width:Math.max(Ce,e/n),height:Math.max(Ce,t/n)}}setData(e,t){this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t);const n=this.getBlurTextureSize(e,t);this.blur.resizeOutput(n.width,n.height)}}class Cf extends Nt{constructor(e){super(),this.pipeline=new kf(this.context,e),this.disablePostProcessing()}}class Mf extends Lr{constructor(e,t){super(),this.context=e;const n={context:e,height:e.canvas.height,width:e.canvas.width},i=new Fi({...n,radius:t,type:zr.GAUSSIAN}),s=new Ur({...n,disableFramebuffer:!0});this.addStep({program:i,getUniforms:()=>({texture:D(e,this.inputImage)})}),this.addStep({program:s,getUniforms:()=>({background:D(e,this.inputImage),foreground:D(e,i.output),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}class Df extends Nt{constructor(e){super(),this.pipeline=new Mf(this.context,e),this.disablePostProcessing()}}class Bf extends Ii{constructor(){super(...arguments),this.preciseMaskEnabled=!0}set reader(e){this.frameReader=e}async run(){this.frameReader&&(await this.readNextVideoFrame(),await super.run())}async readNextVideoFrame(){const e=await this.frameReader?.read();e?.value&&(this.inputBackgroundImage=await createImageBitmap(e.value),e.value.close())}}class Of extends Nt{constructor(){super(),this.pipeline=new Bf(this.context)}setBackgroundVideo(e){this.pipeline.reader=e}}class Ci{blurBackground(e){return new Cf(e)}blurSilhouette(e){return new Df(e)}imageBackground(){return new Pi}videoBackground(){return new Of}}class Uf{constructor(e){switch(e){case gt.CANVAS:this.factory=new ki;break;case gt.WEBGL:this.factory=new Ci;break;default:const t=ro();this.factory=t.supported?new Ci:new ki}}blurBackground(e){return this.getFactory().blurBackground(e)}blurSilhouette(e){return this.getFactory().blurSilhouette(e)}imageBackground(){return this.getFactory().imageBackground()}videoBackground(){return this.getFactory().videoBackground()}getFactory(){if(!this.factory)throw"Factory is not initialized";return this.factory}}class Nf{setBackgroundOptions(e){this.renderer&&this.renderer.destroy();const t=new Uf(e.renderingOptions?.type);switch(e.transformerType){case"BackgroundBlur":this.renderer=t.blurBackground(this.getBlurSize(e.radius));break;case"SilhouetteBlur":this.renderer=t.blurSilhouette(this.getBlurSize(e.radius));break;case"VideoBackground":const n=t.videoBackground();this.backgroundVideo&&n.setBackgroundVideo(this.backgroundVideo),this.renderer=n;break;case"VirtualBackground":const i=t.imageBackground();this.backgroundImage&&i.setBackgroundImage(this.backgroundImage),this.renderer=i;break;default:throw`Unknown rendering type [${e.transformerType}]`}e.renderingOptions?.type===gt.WEBGL&&(e.renderingOptions.selfieSegmentationType===nr.PRECISE?this.renderer.enablePostProcessing():e.renderingOptions.selfieSegmentationType===nr.FAST&&this.renderer.disablePostProcessing())}setVideoBGReadable(e){this.backgroundVideo=e.getReader();const t=this.renderer;t?.setBackgroundVideo&&t.setBackgroundVideo(this.backgroundVideo)}async setVirtualBGImage(e){const t=this.renderer;t?.setBackgroundImage&&t.setBackgroundImage(e),this.backgroundImage=e}async process(e,t){if(this.renderer)return this.renderer.render(e,t)}async resizeForeground(e,t){}getBlurSize(e=pt.Low){switch(e){case pt.Low:return 5;case pt.High:return 12}return e}async profile(e){return this.renderer?.profileWebgl(e)??[]}}var Lf=(function(){var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return(function(e){e=e||{};var t=typeof e<"u"?e:{},n,i;t.ready=new Promise(function(f,h){n=f,i=h});var s={},o;for(o in t)t.hasOwnProperty(o)&&(s[o]=t[o]);var a="./this.program",c=function(f,h){throw h},u=!0,d="";function m(f){return t.locateFile?t.locateFile(f,d):d+f}var p;typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),r&&(d=r),d.indexOf("blob:")!==0?d=d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):d="";var y=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);for(o in s)s.hasOwnProperty(o)&&(t[o]=s[o]);s=null,t.arguments&&t.arguments,t.thisProgram&&(a=t.thisProgram),t.quit&&(c=t.quit);var b;t.wasmBinary&&(b=t.wasmBinary),t.noExitRuntime,typeof WebAssembly!="object"&&ae("no native wasm support detected");var _,E=!1,R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function k(f,h,g){for(var w=h+g,I=h;f[I]&&!(I>=w);)++I;if(I-h>16&&f.subarray&&R)return R.decode(f.subarray(h,I));for(var C="";h<I;){var v=f[h++];if(!(v&128)){C+=String.fromCharCode(v);continue}var B=f[h++]&63;if((v&224)==192){C+=String.fromCharCode((v&31)<<6|B);continue}var H=f[h++]&63;if((v&240)==224?v=(v&15)<<12|B<<6|H:v=(v&7)<<18|B<<12|H<<6|f[h++]&63,v<65536)C+=String.fromCharCode(v);else{var Gi=v-65536;C+=String.fromCharCode(55296|Gi>>10,56320|Gi&1023)}}return C}function N(f,h){return f?k(Ye,f,h):""}function Q(f,h,g){for(var w=0;w<f.length;++w)Lt[h++>>0]=f.charCodeAt(w);Lt[h>>0]=0}function q(f,h){return f%h>0&&(f+=h-f%h),f}var L,Lt,Ye,$;function Di(f){L=f,t.HEAP8=Lt=new Int8Array(f),t.HEAP16=new Int16Array(f),t.HEAP32=$=new Int32Array(f),t.HEAPU8=Ye=new Uint8Array(f),t.HEAPU16=new Uint16Array(f),t.HEAPU32=new Uint32Array(f),t.HEAPF32=new Float32Array(f),t.HEAPF64=new Float64Array(f)}t.INITIAL_MEMORY;var $r,Bi=[],Oi=[],Ui=[];function qf(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)Zf(t.preRun.shift());Wr(Bi)}function Kf(){Wr(Oi)}function Jf(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)tl(t.postRun.shift());Wr(Ui)}function Zf(f){Bi.unshift(f)}function el(f){Oi.unshift(f)}function tl(f){Ui.unshift(f)}var be=0,Xe=null;function rl(f){be++,t.monitorRunDependencies&&t.monitorRunDependencies(be)}function nl(f){if(be--,t.monitorRunDependencies&&t.monitorRunDependencies(be),be==0&&Xe){var h=Xe;Xe=null,h()}}t.preloadedImages={},t.preloadedAudios={};function ae(f){t.onAbort&&t.onAbort(f),f="Aborted("+f+")",l(f),E=!0,f+=". Build with -s ASSERTIONS=1 for more info.";var h=new WebAssembly.RuntimeError(f);throw i(h),h}var il="data:application/octet-stream;base64,";function Ni(f){return f.startsWith(il)}var W;W="tflite-simd.wasm",Ni(W)||(W=m(W));function Li(f){try{if(f==W&&b)return new Uint8Array(b);if(!p)throw"both async and sync fetching of the wasm failed"}catch(h){ae(h)}}function sl(){return!b&&u&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(f){if(!f.ok)throw"failed to load wasm binary file at \'"+W+"\'";return f.arrayBuffer()}).catch(function(){return Li(W)}):Promise.resolve().then(function(){return Li(W)})}function ol(){var f={a:Il};function h(v,B){var H=v.exports;t.asm=H,_=t.asm.q,Di(_.buffer),$r=t.asm.E,el(t.asm.r),nl()}rl();function g(v){h(v.instance)}function w(v){return sl().then(function(B){return WebAssembly.instantiate(B,f)}).then(function(B){return B}).then(v,function(B){l("failed to asynchronously prepare wasm: "+B),ae(B)})}function I(){return!b&&typeof WebAssembly.instantiateStreaming=="function"&&!Ni(W)&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(v){var B=WebAssembly.instantiateStreaming(v,f);return B.then(g,function(H){return l("wasm streaming compile failed: "+H),l("falling back to ArrayBuffer instantiation"),w(g)})}):w(g)}if(t.instantiateWasm)try{var C=t.instantiateWasm(f,h);return C}catch(v){return l("Module.instantiateWasm callback failed with error: "+v),!1}return I().catch(i),{}}function Wr(f){for(;f.length>0;){var h=f.shift();if(typeof h=="function"){h(t);continue}var g=h.func;typeof g=="number"?h.arg===void 0?$r.get(g)():$r.get(g)(h.arg):g(h.arg===void 0?null:h.arg)}}function al(f,h,g,w){ae("Assertion failed: "+N(f)+", at: "+[h?N(h):"unknown filename",g,w?N(w):"unknown function"])}function cl(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function ul(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function fl(){ae("")}var zt;zt=function(){return performance.now()};var ll=!0;function dl(f){return $[zi()>>2]=f,f}function hl(f,h){var g;if(f===0)g=Date.now();else if((f===1||f===4)&&ll)g=zt();else return dl(28),-1;return $[h>>2]=g/1e3|0,$[h+4>>2]=g%1e3*1e3*1e3|0,0}function ml(){return 2147483648}function pl(f,h,g){Ye.copyWithin(f,h,h+g)}function gl(f){try{return _.grow(f-L.byteLength+65535>>>16),Di(_.buffer),1}catch{}}function yl(f){var h=Ye.length;f=f>>>0;var g=2147483648;if(f>g)return!1;for(var w=1;w<=4;w*=2){var I=h*(1+.2/w);I=Math.min(I,f+100663296);var C=Math.min(g,q(Math.max(f,I),65536)),v=gl(C);if(v)return!0}return!1}function bl(f){for(var h=zt();zt()-h<f;);}var Vr={};function xl(){return a||"./this.program"}function Qe(){if(!Qe.strings){var f=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",h={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:f,_:xl()};for(var g in Vr)Vr[g]===void 0?delete h[g]:h[g]=Vr[g];var w=[];for(var g in h)w.push(g+"="+h[g]);Qe.strings=w}return Qe.strings}var Gt={mappings:{},buffers:[null,[],[]],printChar:function(f,h){var g=Gt.buffers[f];h===0||h===10?((f===1?y:l)(k(g,0)),g.length=0):g.push(h)},varargs:void 0,get:function(){Gt.varargs+=4;var f=$[Gt.varargs-4>>2];return f},getStr:function(f){var h=N(f);return h},get64:function(f,h){return f}};function _l(f,h){var g=0;return Qe().forEach(function(w,I){var C=h+g;$[f+I*4>>2]=C,Q(w,C),g+=w.length+1}),0}function El(f,h){var g=Qe();$[f>>2]=g.length;var w=0;return g.forEach(function(I){w+=I.length+1}),$[h>>2]=w,0}function wl(f){Fl(f)}function vl(f){return 0}function Tl(f,h,g,w,I){}function Al(f,h,g,w){for(var I=0,C=0;C<g;C++){for(var v=$[h+C*8>>2],B=$[h+(C*8+4)>>2],H=0;H<B;H++)Gt.printChar(f,Ye[v+H]);I+=B}return $[w>>2]=I,0}function Sl(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var f=new Uint8Array(1);return function(){return crypto.getRandomValues(f),f[0]}}else return function(){ae("randomDevice")}}function $t(f,h){$t.randomDevice||($t.randomDevice=Sl());for(var g=0;g<h;g++)Lt[f+g>>0]=$t.randomDevice();return 0}var Il={a:al,e:cl,d:ul,b:fl,n:hl,h:ml,l:pl,m:yl,p:bl,f:_l,g:El,j:wl,i:vl,k:Tl,c:Al,o:$t};ol(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.r).apply(null,arguments)},t._getModelBufferMemoryOffset=function(){return(t._getModelBufferMemoryOffset=t.asm.s).apply(null,arguments)},t._getInputMemoryOffset=function(){return(t._getInputMemoryOffset=t.asm.t).apply(null,arguments)},t._getInputHeight=function(){return(t._getInputHeight=t.asm.u).apply(null,arguments)},t._getInputWidth=function(){return(t._getInputWidth=t.asm.v).apply(null,arguments)},t._getInputChannelCount=function(){return(t._getInputChannelCount=t.asm.w).apply(null,arguments)},t._getOutputMemoryOffset=function(){return(t._getOutputMemoryOffset=t.asm.x).apply(null,arguments)},t._getOutputHeight=function(){return(t._getOutputHeight=t.asm.y).apply(null,arguments)},t._getOutputWidth=function(){return(t._getOutputWidth=t.asm.z).apply(null,arguments)},t._getOutputChannelCount=function(){return(t._getOutputChannelCount=t.asm.A).apply(null,arguments)},t._loadModel=function(){return(t._loadModel=t.asm.B).apply(null,arguments)},t._runInference=function(){return(t._runInference=t.asm.C).apply(null,arguments)},t._isGPUEnabled=function(){return(t._isGPUEnabled=t.asm.D).apply(null,arguments)};var zi=t.___errno_location=function(){return(zi=t.___errno_location=t.asm.F).apply(null,arguments)},Wt;function Rl(f){this.name="ExitStatus",this.message="Program terminated with exit("+f+")",this.status=f}Xe=function f(){Wt||Hr(),Wt||(Xe=f)};function Hr(f){if(be>0||(qf(),be>0))return;function h(){Wt||(Wt=!0,t.calledRun=!0,!E&&(Kf(),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),Jf()))}t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),h()},1)):h()}t.run=Hr;function Fl(f,h){Pl(f)}function Pl(f){c(f,new Rl(f))}if(t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Hr(),e.ready})})();class zf{constructor(){this.isSIMDSupported=!1,this.isThreadsSupported=!1,this.inputWidth=0,this.inputHeight=0,this.inputChannelCount=0,this.inputMemoryOffset=0,this.outputWidth=0,this.outputHeight=0,this.outputChannelCount=0,this.outputMemoryOffset=0}}const Gf="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",$f="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function Wf(r=Gf,e=$f){let t=new zf;var n=new Promise(function(i,s){async function o(){return Lf({locateFile:function(u){return r+u}})}async function a(c){return new Promise(async(u,d)=>{const m=c;if(typeof m>"u")return d("TFLite backend unavailable: wasmSimd");let p=e;console.log("TFLite modelUrl: "+p);try{const l=await(await fetch(p)).arrayBuffer();console.log("Model buffer size:",l.byteLength);const b=m._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",b),console.log("Loading model buffer..."),m.HEAPU8.set(new Uint8Array(l),b);const _=m._loadModel(l.byteLength);if(console.log("Load model result:",_),_!==0){d("Cannot load model");return}t.inputWidth=m._getInputWidth(),t.inputHeight=m._getInputHeight(),t.inputChannelCount=m._getInputChannelCount(),t.inputMemoryOffset=m._getInputMemoryOffset(),console.log("Input memory offset:",t.inputMemoryOffset),console.log("Input height:",t.inputHeight),console.log("Input width:",t.inputWidth),console.log("Input channels:",t.inputChannelCount),t.outputMemoryOffset=m._getOutputMemoryOffset(),t.outputWidth=m._getOutputWidth(),t.outputHeight=m._getOutputHeight(),t.outputChannelCount=m._getOutputChannelCount(),console.log("Output memory offset:",t.outputMemoryOffset),console.log("Output height:",t.outputHeight),console.log("Output width:",t.outputWidth),console.log("Output channels:",t.outputChannelCount),t.selectedTFLite=m}catch(y){d(y);return}u()})}o().then(c=>{if(c===null)throw console.error("loadTFLite null"),"loadTFLite null";a(c).then(u=>{i(t)}).catch(u=>{console.error("loadTFLiteModel error"),s("loadTFLiteModel error")})}).catch(c=>{console.error("loadTFLite error:",c),s("loadTFLite error:"+c)})});return n}const Vf=.1,Hf=.7,jf="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class Yf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=0,this.height=0,this.gpuDelegate=!0}async createImageSegmenter(){if(!this.ImageSegmenter||!this.wasmFileset){console.warn("Mediapipe objects not loaded");return}this.imageSegmenter=await this.ImageSegmenter.createFromOptions(this.wasmFileset,{baseOptions:{modelAssetPath:this.modelAssetUriPath,delegate:this.gpuDelegate?"GPU":"CPU"},runningMode:"VIDEO",outputCategoryMask:!0,outputConfidenceMasks:!0})}async loadMediapipeAssets(e,t){this.modelAssetUriPath=e||jf;const n=t?`${t}/task-vision.js`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/+esm",i=t?`${t}/wasm`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/wasm",{FilesetResolver:s,ImageSegmenter:o}=await import(n);this.ImageSegmenter=o,this.wasmFileset=await s.forVisionTasks(i)}async init(e,t,n){n===!1&&(this.gpuDelegate=!1),await this.loadMediapipeAssets(e,t),globalThis.document={},await this.createImageSegmenter()}async process(e){if(!this.imageSegmenter){console.warn("ImageSegmenter instance not available");return}(this.width!==e.width||this.height!==e.height)&&(this.canvas.width=this.width=e.width,this.canvas.height=this.height=e.height,this.mask&&(this.mask=new ImageData(this.width,this.height))),this.mask||(this.mask=new ImageData(this.width,this.height)),this.context.drawImage(e,0,0,e.width,e.height);const t=Date.now();let n;try{this.imageSegmenter?.segmentForVideo(this.context.getImageData(0,0,e.width,e.height),t,o=>{n=o.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{await this.createImageSegmenter();return}if(!n)return;if(!this.previousConfidenceMask){this.previousConfidenceMask=n.slice();return}const i=n.map((o,a)=>{const c=this.previousConfidenceMask?.[a];return c!==void 0?this.blend(c,o):o}),s=[255,0,0];for(let o=0;o<i?.length;o++){const a=1-i[o];a>Vf?(a<Hf?(this.mask.data[o*4]=s[0]*a,this.mask.data[o*4+3]=255*a):(this.mask.data[o*4]=s[0],this.mask.data[o*4+3]=255),this.mask.data[o*4+1]=s[1],this.mask.data[o*4+2]=s[2]):this.mask.data[o*4]=this.mask.data[o*4+1]=this.mask.data[o*4+2]=this.mask.data[o*4+3]=0}return this.previousConfidenceMask=i.slice(),this.mask}isGpuSupported(){return!0}blend(e,t){const i=-.748699,s=-57.8051,o=291.309,a=-624.717,c=t-.5,u=c*c,d=1-Math.min(1,u*(5.68842+u*(i+u*(s+u*(o+u*a)))));return t+(e-t)*(d*.9)}}class Xf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.pixelCount=0,this.inputOffset=0,this.outputOffset=0}async init(e,t,n){await this.initWasm(t,e),this.infos&&(this.canvas.width=this.infos.inputWidth,this.canvas.height=this.infos.inputHeight,this.pixelCount=this.infos.inputWidth*this.infos.inputHeight,this.mask=new ImageData(this.infos.inputWidth,this.infos.inputHeight),this.inputOffset=this.infos.inputMemoryOffset/4,this.outputOffset=this.infos.outputMemoryOffset/4)}async initWasm(e,t){this.infos=await Wf(e,t)}async process(e){if(!this.mask||!this.infos)return;const t=this.infos.inputWidth,n=this.infos.inputHeight;this.context.drawImage(e,0,0,e.width,e.height,0,0,t,n);const i=this.context.getImageData(0,0,t,n),s=this.infos.selectedTFLite.HEAPF32;for(let o=0;o<this.pixelCount;o++){const a=this.inputOffset+o*3;s[a]=i.data[o*4]/255,s[a+1]=i.data[o*4+1]/255,s[a+2]=i.data[o*4+2]/255}this.infos.selectedTFLite._runInference();for(let o=0;o<this.pixelCount;o++){const a=this.infos.selectedTFLite.HEAPF32[this.outputOffset+o];this.mask.data[o*4]=this.mask.data[o*4+3]=255*a}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class Qf{constructor(){this.reporter=new eo,this.isEnabled=!0}async init(e,t){t.segmentationOptions?.lightWeightEngine===!0?this.selfieSegmentation=new Xf:this.selfieSegmentation=new Yf,await this.selfieSegmentation?.init(t.modelAssetUriPath,t.mediapipeBaseAssetsUri,t.segmentationOptions?.gpuSupport),this.backgroundFilter=new Nf,this.report({variation:"Create"})}async transform(e,t){if(!this.isEnabled)return t.enqueue(e);let n;const i=e.timestamp??0,s=await createImageBitmap(e),o=await this.selfieSegmentation?.process(s);o&&(n=await this.backgroundFilter?.process(s,o)),n?(e.close(),t.enqueue(new VideoFrame(n,{timestamp:i,alpha:"discard"}))):t.enqueue(e)}async setBackgroundOptions(e){this.backgroundOptions=e,await this.backgroundFilter?.setBackgroundOptions(e),this.report({variation:"Update"})}async setVideoBGReadable(e){await this.backgroundFilter?.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundFilter?.setVirtualBGImage(e)}async profile(e){return this.backgroundFilter?.profile(e)??[]}getTransformerType(){return this.backgroundOptions?.transformerType??"Undefined"}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}report(e){this.reporter.send({version:to,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...e})}}const Gr=class Gr{constructor(){this.backgroundTransformer=new Qf,this.mediaProcessor=new Ps,this.rate=30,this.eventsQueue=[],this.frameTransformLatencyMs=[]}async init(e,t){this.frameTransformLatencyMs=[],await this.backgroundTransformer.init(e,t),await this.mediaProcessor.setTransformers([this.backgroundTransformer]),this.mediaProcessor.setTrackExpectedRate(this.rate),this.mediaProcessor.onAny((n,i)=>{this.resolveOnMediaProcessor?(this.resolveOnMediaProcessor({name:n,data:i}),this.resolveOnMediaProcessor=void 0):this.eventsQueue.push({name:n,data:i})})}enable(){this.backgroundTransformer.enable()}disable(){this.backgroundTransformer.disable()}async onMediaProcessorEvent(){return await new Promise(e=>{this.eventsQueue.length>0?e(this.eventsQueue.shift()):this.resolveOnMediaProcessor=e})}async setTrackExpectedRate(e){this.rate=e,this.mediaProcessor.setTrackExpectedRate(e)}async transform(e,t){let n=this.mediaProcessor.transform(e,t),i=performance.now();return this.frameTransformLatencyMs.push(performance.now()-i),n}async setBackgroundOptions(e){await this.backgroundTransformer?.setBackgroundOptions(e)}setVideoBGReadable(e){this.backgroundTransformer.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundTransformer.setVirtualBGImage(e)}async terminate(){await this.mediaProcessor.destroy();const t=this.frameTransformLatencyMs.reduce((n,i)=>n+i,0)/this.frameTransformLatencyMs.length||0;console.log(`Transform latency average is: ${t} ms`)}setVonageMetadata(e){ws(e)}async profile(e){return JSON.stringify(await this.backgroundTransformer.profile(e))}};ji("ProcessorWorker",Gr);let Mi=Gr})();\n//# sourceMappingURL=processor-worker-Ct1XXlKJ.js.map\n',Js=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",pu],{type:"text/javascript;charset=utf-8"});function U3(t){let e;try{if(e=Js&&(self.URL||self.webkitURL).createObjectURL(Js),!e)throw"";const r=new Worker(e,{name:t?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(pu),{name:t?.name})}}const eo=class t extends ei{constructor(t){super(),this.rate=30,this.isEnabled=!0,this.config=t}async setTrackExpectedRate(t){await this.startWorker(),await(this.worker?.setTrackExpectedRate(t))}async setBackgroundOptions(t){this.backgroundOptions=t,await this.updateBackgroundOptions(t)}async transform(t,e){return await this.startWorker(),await(this.worker?.transform(t,e))}async destroy(){await(this.worker?.terminate()),this.worker=void 0}async profile(t){const e=await(this.worker?.profile(t));return JSON.parse(e??"[]")}async enable(){this.isEnabled=!0,await(this.worker?.enable())}async disable(){this.isEnabled=!1,await(this.worker?.disable())}async listenWorker(){for(;this.worker?.workerContext.worker;){const{name:t,data:e}=await(this.worker?.onMediaProcessorEvent());switch(t){case"error":case"warn":this.emit(t,e);break;case"pipelineInfo":switch(this.emit(t,e),e){case"pipeline_ended":case"pipeline_ended_with_error":return void await this.destroy()}}}}async startWorker(){!this.config||this.worker||(this.worker=await dc(Lo,U3),this.isEnabled||await this.worker.disable(),await this.worker.init("worker_"+t.initCount++,this.config),await this.worker.setVonageMetadata(wi()),this.backgroundOptions?await this.setBackgroundOptions(this.backgroundOptions):await this.setBackgroundOptions(this.config),this.listenWorker())}async updateBackgroundOptions(t){await this.startWorker();const{transformerType:e}=t;switch(e){case"VideoBackground":await(this.worker?.setVideoBGReadable(await Ps.createVideoReadable(t.backgroundAssetUri)));break;case"VirtualBackground":await(this.worker?.setVirtualBGImage(await Ps.createImageCanvas(t.backgroundAssetUri)))}await(this.worker?.setBackgroundOptions(t))}};eo.initCount=0;let jo=eo;class B3{constructor(t){this.queries=t}async downloadSpeedscope(){this.download(await this.convertToSpeedscope())}download(t){const e=document.createElement("a");e.href=URL.createObjectURL(new Blob([t],{type:"application/json"})),e.download=`profile-${+new Date}.speedscope.json`,document.body.appendChild(e),e.click(),document.body.removeChild(e)}convertToSpeedscope(){const t=[],e={},r=[];let n=0;for(const i of this.queries){const o=[];for(const r of i)void 0===e[r.name]&&(e[r.name]=t.length,t.push({name:r.name})),o.push({type:r.action==hu.PUSH?"O":"C",frame:e[r.name],at:r.timestamp}),n=Math.max(n,r.timestamp+r.duration);r.push({events:o,type:"evented",name:"GPU Profile",unit:"nanoseconds",startValue:0,endValue:n})}return JSON.stringify({$schema:"https://www.speedscope.app/file-format-schema.json",shared:{frames:t},profiles:r},null,2)}}const ms=class extends ei{constructor(t){super(),this.worker=new jo(t),this.connector=new qu(this.worker),this.worker.onAny((t,e)=>this.emit(t,e))}async setBackgroundOptions(t){await this.worker.setBackgroundOptions(t)}async enable(){await this.worker.enable()}async disable(){await this.worker.disable()}setTrackExpectedRate(t){this.worker.setTrackExpectedRate(t)}getConnector(){return this.connector}async profile(t){return this.worker.profile(t)}static async profile(t){const e=await Promise.all(this.instances.map(e=>e.profile(t)));return new B3(e)}static async create(t){const e=new this(t);return this.instances.push(e),e}};ms.instances=[];let Uo=ms;function W3(){return Ii}function z3(){return ki}function H3(){return Pi}function V3(){return Ci}function $3(){return Mi}function Y3(){return Li}function X3(){return ji}async function K3(t){return await Uo.create(t)}export{j3 as BackgroundTransformer,ec as BackgroundTransformerType,_i as BlurRadius,Yu as ErrorFunction,Es as MediapipeHelper,Ao as PipelineInfoData,Oi as RenderingType,Uo as VonageMediaProcessor,$u as WarningType,To as WebglSelfieSegmentationType,K3 as createVonageMediaProcessor,rc as getSupportedBrowserFeatures,V3 as getVonageFaceDetection,$3 as getVonageFaceMash,z3 as getVonageHands,H3 as getVonageHolistic,Y3 as getVonageObjectron,X3 as getVonagePose,W3 as getVonageSelfieSegmentation,G3 as isSupported};
1
+ async function is(){return new Promise(async(e,t)=>{await si()||oi()?e():t("Your browser does not support the MediaStreamTrack API for Insertable Streams of Media.")})}function oi(){return void 0!==self.MediaStreamTrackProcessor&&void 0!==self.MediaStreamTrackGenerator||os()}function os(){return 0===[self.ReadableStream,self.WritableStream,self.MediaStream,self.OffscreenCanvas,self.VideoFrame,self.AudioContext,self.AudioWorkletNode].filter(e=>void 0===e).length}function si(){return new Promise(e=>{new Worker(`data:text/javascript,(${function(){self.postMessage(typeof MediaStreamTrackProcessor<"u"&&typeof VideoTrackGenerator<"u")}.toString()})()`).onmessage=({data:t})=>e(t)})}const ee=new WeakMap,me=new WeakMap,q=new WeakMap,Rt=Symbol("anyProducer"),Tn=Promise.resolve(),kt=Symbol("listenerAdded"),Pt=Symbol("listenerRemoved");let Ft=!1,mr=!1;const Ct=e=>"string"==typeof e||"symbol"==typeof e||"number"==typeof e;function Ae(e){if(!Ct(e))throw new TypeError("`eventName` must be a string, symbol, or number")}function ft(e){if("function"!=typeof e)throw new TypeError("listener must be a function")}function Te(e,t){const r=me.get(e);if(r.has(t))return r.get(t)}function je(e,t){const r=Ct(t)?t:Rt,n=q.get(e);if(n.has(r))return n.get(r)}function ss(e,t,r){const n=q.get(e);if(n.has(t))for(const e of n.get(t))e.enqueue(r);if(n.has(Rt)){const e=Promise.all([t,r]);for(const t of n.get(Rt))t.enqueue(e)}}function Sn(e,t){t=Array.isArray(t)?t:[t];let r=!1,n=()=>{},i=[];const o={enqueue(e){i.push(e),n()},finish(){r=!0,n()}};for(const r of t){let t=je(e,r);t||(t=new Set,q.get(e).set(r,t)),t.add(o)}return{async next(){return i?0===i.length?r?(i=void 0,this.next()):(await new Promise(e=>{n=e}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(r){i=void 0;for(const r of t){const t=je(e,r);t&&(t.delete(o),0===t.size&&q.get(e).delete(r))}return n(),arguments.length>0?{done:!0,value:await r}:{done:!0}},[Symbol.asyncIterator](){return this}}}function In(e){if(void 0===e)return Rn;if(!Array.isArray(e))throw new TypeError("`methodNames` must be an array of strings");for(const t of e)if(!Rn.includes(t))throw"string"!=typeof t?new TypeError("`methodNames` element must be a string"):new Error(`${t} is not Emittery method`);return e}const Me=e=>e===kt||e===Pt;function dt(e,t,r){if(Me(t))try{Ft=!0,e.emit(t,r)}finally{Ft=!1}}class J{static mixin(e,t){return t=In(t),r=>{if("function"!=typeof r)throw new TypeError("`target` must be function");for(const e of t)if(void 0!==r.prototype[e])throw new Error(`The property \`${e}\` already exists on \`target\``);Object.defineProperty(r.prototype,e,{enumerable:!1,get:function(){return Object.defineProperty(this,e,{enumerable:!1,value:new J}),this[e]}});const n=t=>function(...r){return this[e][t](...r)};for(const e of t)Object.defineProperty(r.prototype,e,{enumerable:!1,value:n(e)});return r}}static get isDebugEnabled(){if("object"!=typeof globalThis.process?.env)return mr;const{env:e}=globalThis.process??{env:{}};return"emittery"===e.DEBUG||"*"===e.DEBUG||mr}static set isDebugEnabled(e){mr=e}constructor(e={}){ee.set(this,new Set),me.set(this,new Map),q.set(this,new Map),q.get(this).set(Rt,new Set),this.debug=e.debug??{},void 0===this.debug.enabled&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(e,t,r,n)=>{try{n=JSON.stringify(n)}catch{n=`Object with the following keys failed to stringify: ${Object.keys(n).join(",")}`}("symbol"==typeof r||"number"==typeof r)&&(r=r.toString());const i=new Date,o=`${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}.${i.getMilliseconds()}`;console.log(`[${o}][emittery:${e}][${t}] Event Name: ${r}\n\tdata: ${n}`)})}logIfDebugEnabled(e,t,r){(J.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,r)}on(e,t,{signal:r}={}){ft(t),e=Array.isArray(e)?e:[e];for(const r of e){Ae(r);let e=Te(this,r);e||(e=new Set,me.get(this).set(r,e)),e.add(t),this.logIfDebugEnabled("subscribe",r,void 0),Me(r)||dt(this,kt,{eventName:r,listener:t})}const n=()=>{this.off(e,t),r?.removeEventListener("abort",n)};return r?.addEventListener("abort",n,{once:!0}),r?.aborted&&n(),n}off(e,t){ft(t),e=Array.isArray(e)?e:[e];for(const r of e){Ae(r);const e=Te(this,r);e&&(e.delete(t),0===e.size&&me.get(this).delete(r)),this.logIfDebugEnabled("unsubscribe",r,void 0),Me(r)||dt(this,Pt,{eventName:r,listener:t})}}once(e,t){if(void 0!==t&&"function"!=typeof t)throw new TypeError("predicate must be a function");let r;const n=new Promise(n=>{r=this.on(e,e=>{t&&!t(e)||(r(),n(e))})});return n.off=r,n}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Ae(t);return Sn(this,e)}async emit(e,t){if(Ae(e),Me(e)&&!Ft)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),ss(this,e,t);const r=Te(this,e)??new Set,n=ee.get(this),i=[...r],o=Me(e)?[]:[...n];await Tn,await Promise.all([...i.map(async e=>{if(r.has(e))return e(t)}),...o.map(async r=>{if(n.has(r))return r(e,t)})])}async emitSerial(e,t){if(Ae(e),Me(e)&&!Ft)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const r=Te(this,e)??new Set,n=ee.get(this),i=[...r],o=[...n];await Tn;for(const e of i)r.has(e)&&await e(t);for(const r of o)n.has(r)&&await r(e,t)}onAny(e,{signal:t}={}){ft(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),ee.get(this).add(e),dt(this,kt,{listener:e});const r=()=>{this.offAny(e),t?.removeEventListener("abort",r)};return t?.addEventListener("abort",r,{once:!0}),t?.aborted&&r(),r}anyEvent(){return Sn(this)}offAny(e){ft(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),dt(this,Pt,{listener:e}),ee.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),Ct(t)){const e=Te(this,t);e&&e.clear();const r=je(this,t);if(r){for(const e of r)e.finish();r.clear()}}else{ee.get(this).clear();for(const[e,t]of me.get(this).entries())t.clear(),me.get(this).delete(e);for(const[e,t]of q.get(this).entries()){for(const e of t)e.finish();t.clear(),q.get(this).delete(e)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const r of e)if(Ct(r))t+=ee.get(this).size+(Te(this,r)?.size??0)+(je(this,r)?.size??0)+(je(this)?.size??0);else{void 0!==r&&Ae(r),t+=ee.get(this).size;for(const e of me.get(this).values())t+=e.size;for(const e of q.get(this).values())t+=e.size}return t}bindMethods(e,t){if("object"!=typeof e||null===e)throw new TypeError("`target` must be an object");t=In(t);for(const r of t){if(void 0!==e[r])throw new Error(`The property \`${r}\` already exists on \`target\``);Object.defineProperty(e,r,{enumerable:!1,value:this[r].bind(this)})}}}const Rn=Object.getOwnPropertyNames(J.prototype).filter(e=>"constructor"!==e);Object.defineProperty(J,"listenerAdded",{value:kt,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(J,"listenerRemoved",{value:Pt,writable:!1,enumerable:!0,configurable:!1});var as=Object.defineProperty,cs=(e,t,r)=>t in e?as(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,us=(e,t,r)=>(cs(e,t+"",r),r);const ls="hlg.tokbox.com/prod/logging/vcp_webrtc",fs="https://",ds=1e4;let ht;const hs=new Uint8Array(16);function ms(){if(!ht&&(ht=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ht))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ht(hs)}const F=[];for(let e=0;e<256;++e)F.push((e+256).toString(16).slice(1));function ps(e,t=0){return(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+"-"+F[e[t+4]]+F[e[t+5]]+"-"+F[e[t+6]]+F[e[t+7]]+"-"+F[e[t+8]]+F[e[t+9]]+"-"+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase()}const gs=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),kn={randomUUID:gs};function ys(e,t,r){if(kn.randomUUID&&!e)return kn.randomUUID();const n=(e=e||{}).random||(e.rng||ms)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,ps(n)}function Ur(e,t){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let r=globalThis.vonage.workerizer;return r[e]||(r[e]=t),r[e]}const ie=Ur("globals",{});var ye=(e=>(e.INIT="INIT",e.FORWARD="FORWARD",e.TERMINATE="TERMINATE",e.GLOBALS_SYNC="GLOBALS_SYNC",e))(ye||{});function ai(e){return[ImageBitmap,ReadableStream,WritableStream].some(t=>e instanceof t)}let bs=0;function ws(e,t,r,n,i){const o=bs++;return e.postMessage({id:o,type:t,functionName:r,args:n},n.filter(e=>ai(e))),new Promise(e=>{i?.set(o,e)})}function Ze(e,t){const{id:r,type:n}=e,i=Array.isArray(t)?t:[t];postMessage({id:r,type:n,result:t},i.filter(e=>ai(e)))}const Pn=Ur("workerized",{});function ci(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function xs(){if(ci())Ze({type:ye.GLOBALS_SYNC},ie);else{const e=[];for(const t in Pn){const{worker:r,resolvers:n}=Pn[t].workerContext;r&&e.push(ws(r,ye.GLOBALS_SYNC,"",[ie],n))}await Promise.all(e)}}function Ot(e,t){if(Array.isArray(t))t.splice(0,t.length);else if("object"==typeof t)for(const e in t)delete t[e];for(const r in e)Array.isArray(e[r])?(t[r]=[],Ot(e[r],t[r])):"object"==typeof e[r]?(t[r]={},Ot(e[r],t[r])):t[r]=e[r]}async function vs(e,t){const{functionName:r,args:n}=e;if(!t.instance)throw"instance not initialized";if(!r)throw"missing function name to call";if(!t.instance[r])throw`undefined function [${r}] in class ${t.instance.constructor.workerId}`;Ze(e,await t.instance[r](...n??[]))}const _s=Ur("registeredWorkers",{});function Es(e,t){if(!e.args)throw"Missing className while initializing worker";const[r,n]=e.args,i=_s[r];if(!i)throw`unknown worker class ${r}`;t.instance=new i(e.args.slice(1)),Ot(n,ie),Ze(e,void 0!==typeof t.instance)}async function As(e,t){const{args:r}=e;if(!t.instance)throw"instance not initialized";let n;t.instance.terminate&&(n=await t.instance.terminate(...r??[])),Ze(e,n)}function Ts(e){if(!e.args)throw"Missing globals while syncing";Ot(e.args[0],ie),Ze(e,{})}function Ss(){const e={};onmessage=async t=>{const r=t.data;switch(r.type){case ye.INIT:Es(r,e);break;case ye.FORWARD:vs(r,e);break;case ye.TERMINATE:As(r,e);break;case ye.GLOBALS_SYNC:Ts(r)}}}function Is(e,t){return ie[e]||(ie[e]=t),[()=>ie[e],async t=>{ie[e]=t,await xs()}]}function Rs(e,t){return Is(e,t)}ci()&&Ss();const[ks,Ps]=Rs("metadata");function Fs(e){Ps(e)}function Tt(){return ks()}let Lr=class{constructor(e,t){us(this,"uuid"),this.config=e,this.uuid=t??ys()}async send(e){var t,r,n;const{appId:i,sourceType:o}=null!=(t=Tt())?t:{};if(!i||!o)return"metadata missing";const s=new AbortController,a=setTimeout(()=>s.abort(),ds);return await(null!=(n=null==(r=this.config)?void 0:r.fetch)?n:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:s.signal}),clearTimeout(a),"success"}getUrl(){var e;let t=null!=(e=Tt().proxyUrl)?e:fs;return t+=("/"===t.at(-1)?"":"/")+ls,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=Tt();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}};const St="3.0.1-alpha.0",_r=class{};_r.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},_r.errors={transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer",readable_null:"Readable is null",writable_null:"Writable is null"};let be=_r;function Cs(e){return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message}function Os(e){if(Cs(e))return e;try{return new Error(JSON.stringify(e))}catch{return new Error(String(e))}}function pr(e){return Os(e).message}class Ms{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new Lr(e,t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this;return t/((Date.now()-e)/1e3)}async onFrameTransformed(e={},t=!1){0===this.startAt&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:r,frameTransformedCount:n,frameFromSourceCount:i}=this,o=Date.now(),s=(o-r)/1e3,a=n/s,c=i/s;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:c,transformedFps:a,framesTransformed:n,...e})):"success"}}var Bs=(e=>(e.FPS_DROP="fps_drop",e))(Bs||{}),Ds=(e=>(e.start="start",e.transform="transform",e.flush="flush",e))(Ds||{}),Er=(e=>(e.pipeline_ended="pipeline_ended",e.pipeline_ended_with_error="pipeline_ended_with_error",e.pipeline_started="pipeline_started",e.pipeline_started_with_error="pipeline_started_with_error",e.pipeline_restarted="pipeline_restarted",e.pipeline_restarted_with_error="pipeline_restarted_with_error",e))(Er||{});const Us=500,Ls=.8;class zs extends J{constructor(e,t){super(),this.reporter_=new Lr,this.reporterQos_=new Ms({loggingIntervalFrameCount:Us,report:{version:St}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e}async start(e){if(this.controller_=e,this.transformer_&&"function"==typeof this.transformer_.start)try{await this.transformer_.start(e)}catch(e){this.report({message:be.errors.transformer_start,variation:"Error",error:pr(e)});const t={eventMetaData:{transformerIndex:this.index_},error:e,function:"start"};this.emit("error",t)}}async transform(e,t){if(0===this.mediaTransformerQosReportStartTimestamp_&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),e.close(),this.flush(t),t.terminate();else{try{await(this.transformer_.transform?.(e,t)),this.reportQos()}catch(e){this.report({message:be.errors.transformer_transform,variation:"Error",error:pr(e)});const t={eventMetaData:{transformerIndex:this.index_},error:e,function:"transform"};this.emit("error",t)}if(-1!=this.trackExpectedRate_&&this.trackExpectedRate_*Ls>this.reporterQos_.fps){const e={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",e)}}}async flush(e){if(this.transformer_&&"function"==typeof this.transformer_.flush&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(e){this.report({message:be.errors.transformer_flush,variation:"Error",error:pr(e)});const t={eventMetaData:{transformerIndex:this.index_},error:e,function:"flush"};this.emit("error",t)}}this.reportQos(!0),this.report({variation:"Delete"})}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),this.shouldStop_=!0}report(e){this.reporter_.send({version:St,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:St,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class Ns extends J{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let r=new zs(e[t],t);r.on("error",e=>{this.emit("error",e)}),r.on("warn",e=>{this.emit("warn",e)}),this.transformers_.push(r)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let e of this.transformers_)e.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(this.transformers_&&0!==this.transformers_.length){try{let r=e;for(let t of this.transformers_)e=e.pipeThrough(new TransformStream(t));e.pipeTo(t).then(async()=>{console.log("[Pipeline] Setup."),await t.abort(),await r.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async n=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(e=>{console.error("[Pipeline] Error from stream transform:",e)}),await t.abort(n),await r.cancel(n),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{return this.emit("pipelineInfo","pipeline_started_with_error"),void this.destroy()}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}else console.log("[Pipeline] No transformers.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class ui extends J{constructor(){super(),this.reporter_=new Lr,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if("video"===e.kind){const t=new MediaStreamTrackProcessor({track:e}),r=new VideoTrackGenerator;return this.readable_=t.readable,this.writable_=r.writable,await this.transformInternal(),r.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise(async(e,t)=>{if(!this.transformers_||0===this.transformers_.length)return this.report({message:be.errors.transformer_none,variation:"Error"}),void t("[MediaProcessor] Need to set transformers.");if(!this.readable_)return this.report({variation:"Error",message:be.errors.readable_null}),void t("[MediaProcessor] Readable is null.");if(!this.writable_)return this.report({variation:"Error",message:be.errors.writable_null}),void t("[MediaProcessor] Writable is null.");let r=!1;this.pipeline_&&(r=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Ns(this.transformers_),this.pipeline_.on("warn",e=>{this.emit("warn",e)}),this.pipeline_.on("error",e=>{this.emit("error",e)}),this.pipeline_.on("pipelineInfo",e=>{r&&("pipeline_started"===e?e=Er.pipeline_restarted:"pipeline_started_with_error"===e&&(e=Er.pipeline_restarted_with_error)),this.emit("pipelineInfo",e)}),-1!=this.trackExpectedRate_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(e=>{t(e)})})}setTransformers(e){return this.report({variation:"Update",message:be.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async e=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),e()})}report(e){this.reporter_.send({version:St,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}class $s{constructor({kind:e}){if("video"==e){const e=document.createElement("canvas"),t=e.getContext("2d",{desynchronized:!0}),r=e.captureStream().getVideoTracks()[0];return r.writable=new WritableStream({write(r){e.width=r.displayWidth,e.height=r.displayHeight,t.drawImage(r,0,0,e.width,e.height),r.close()}}),r}if("audio"==e){const e=new AudioContext,t=e.createMediaStreamDestination(),[r]=t.stream.getAudioTracks();return r.writable=new WritableStream({async start(n){return this.arrays=[],await e.audioWorklet.addModule(`data:text/javascript,(${function(){registerProcessor("mstg-shim",class extends AudioWorkletProcessor{constructor(){super(),this.arrays=[],this.arrayOffset=0,this.port.onmessage=({data:e})=>this.arrays.push(e),this.emptyArray=new Float32Array(0)}process(e,[[t]]){for(let e=0;e<t.length;e++)(!this.array||this.arrayOffset>=this.array.length)&&(this.array=this.arrays.shift()||this.emptyArray,this.arrayOffset=0),t[e]=this.array[this.arrayOffset++]||0;return!0}})}.toString()})()`),this.node=new AudioWorkletNode(e,"mstg-shim"),this.node.connect(t),r},write(e){const t=new Float32Array(e.numberOfFrames*e.numberOfChannels);e.copyTo(t,{planeIndex:0}),this.node.port.postMessage(t,[t.buffer]),e.close()}}),r}}}function Ws(){return self.MediaStreamTrackGenerator?self.MediaStreamTrackGenerator:$s}class Gs{constructor(e){const t=e.track??e;"video"==t.kind?this.readable=new ReadableStream({async start(e){t.addEventListener("ended",()=>e.close(),{once:!0}),this.video=document.createElement("video"),this.video.srcObject=new MediaStream([t]),await Promise.all([this.video.play(),new Promise(e=>this.video.onloadedmetadata=e)]),this.track=t,this.canvas=new OffscreenCanvas(this.video.videoWidth,this.video.videoHeight),this.ctx=this.canvas.getContext("2d",{desynchronized:!0}),this.t1=performance.now()},async pull(e){if("ended"==t.readyState)return e.close();const r=t.getSettings().frameRate||30;for(;performance.now()-this.t1<1e3/r;)if(await new Promise(e=>requestAnimationFrame(e)),"ended"==t.readyState)return e.close();this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,this.t1=performance.now(),this.ctx.drawImage(this.video,0,0),e.enqueue(new VideoFrame(this.canvas,{timestamp:this.t1}))}}):"audio"==t.kind&&(this.readable=new ReadableStream({async start(e){t.addEventListener("ended",()=>e.close(),{once:!0}),this.ac=new AudioContext,this.arrays=[],await this.ac.audioWorklet.addModule(`data:text/javascript,(${function(){registerProcessor("mstp-shim",class extends AudioWorkletProcessor{process(e){return this.port.postMessage(e),!0}})}.toString()})()`),this.node=new AudioWorkletNode(this.ac,"mstp-shim"),this.ac.createMediaStreamSource(new MediaStream([t])).connect(this.node),this.node.port.addEventListener("message",({data:e})=>e[0][0]&&this.arrays.push(e))},async pull(e){if("ended"==t.readyState)return e.close();for(;!this.arrays.length;)if(await new Promise(e=>this.node.port.onmessage=e),"ended"==t.readyState)return e.close();const[r]=this.arrays.shift(),n=new Float32Array(r.reduce((e,t)=>e+t.length,0));r.reduce((e,t)=>(n.set(t,e),e+t.length),0),e.enqueue(new AudioData({format:"f32-planar",sampleRate:this.ac.sampleRate,numberOfFrames:r[0].length,numberOfChannels:r.length,timestamp:1e6*this.ac.currentTime|0,data:n,transfer:[n.buffer]}))}}))}}function Vs(){return self.MediaStreamTrackProcessor?self.MediaStreamTrackProcessor:Gs}class Hs{constructor(){this.processor_=null,this.generator_=null}init(e){return new Promise((t,r)=>{try{const t=Vs();this.processor_=new t(e)}catch(e){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${e}`),r(e)}try{const t=Ws();"audio"===e.kind?this.generator_=new t({kind:"audio"}):"video"===e.kind?this.generator_=new t({kind:"video"}):r("kind not supported")}catch(e){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${e}`),r(e)}t()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class js{constructor(e){this.mediaProcessor_=e}async setTrack(e){if(!(this.mediaProcessor_ instanceof ui)&&await si()){if("audio"===e.kind)throw Error("Cannot process audio tracks inside a web worker when passing a track to transform");return await this.mediaProcessor_.transform(e)}if(oi()){const t=new Hs;return await t.init(e),await this.mediaProcessor_.transform(t.getReadable(),t.getWriteable()),t.getProccesorTrack()}throw Error("MediaStreamTrack API for Insertable Streams of Media is not supported")}destroy(){return new Promise((e,t)=>{this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>{e()}).catch(e=>{t(e)}):t("no processor")})}}var It=(e=>(e.Low="Low",e.High="High",e))(It||{}),Ys=(e=>(e.BackgroundBlur="BackgroundBlur",e.VirtualBackground="VirtualBackground",e.VideoBackground="VideoBackground",e.SilhouetteBlur="SilhouetteBlur",e))(Ys||{}),Ar=(e=>(e.FAST="FAST",e.PRECISE="PRECISE",e))(Ar||{}),Mt=(e=>(e.CANVAS="CANVAS",e.WEBGL="WEBGL",e))(Mt||{});const Qs=async()=>WebAssembly.validate(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 Md(){const{wasm:e,insertableStreams:t,simd:r,webgl:n}=await qs();if(!e.supported)throw e.message;if(!t.supported)throw t.message;if(!r.supported)throw r.message;if(!n.supported)throw n.message}async function qs(){const e={wasm:{supported:"object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate,message:"Your browser does not support WebAssembly features."},simd:{supported:await Qs(),message:"Your browser does not support simd features."},insertableStreams:{supported:!0},gpu:{message:"Your browser does not support gpu features.",supported:!0},webgl:Xs(),performance:li()};try{await is()}catch(t){e.insertableStreams.supported=!1,e.insertableStreams.message=t}return e}function Xs(){if(!OffscreenCanvas)return{supported:!1,message:"Your browser does not support offscreen canvas"};const e=new OffscreenCanvas(0,0).getContext("webgl2");if(!e)return{supported:!1,message:"Your browser does not support webgl 2"};{const t=e?.getExtension("WEBGL_lose_context");t&&t.loseContext()}return{supported:!0}}function li(){const e=new OffscreenCanvas(0,0).getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(!e)return{supported:!1,message:"Your hardware does not perform good enough to run the library efficiently"};{const t=e?.getExtension("WEBGL_lose_context");t&&t.loseContext()}return{supported:!0}}const te=new WeakMap,pe=new WeakMap,X=new WeakMap,Bt=Symbol("anyProducer"),Fn=Promise.resolve(),Dt=Symbol("listenerAdded"),Ut=Symbol("listenerRemoved");let Lt=!1,gr=!1;const zt=e=>"string"==typeof e||"symbol"==typeof e||"number"==typeof e;function Se(e){if(!zt(e))throw new TypeError("`eventName` must be a string, symbol, or number")}function mt(e){if("function"!=typeof e)throw new TypeError("listener must be a function")}function Ie(e,t){const r=pe.get(e);if(r.has(t))return r.get(t)}function Ye(e,t){const r=zt(t)?t:Bt,n=X.get(e);if(n.has(r))return n.get(r)}function Ks(e,t,r){const n=X.get(e);if(n.has(t))for(const e of n.get(t))e.enqueue(r);if(n.has(Bt)){const e=Promise.all([t,r]);for(const t of n.get(Bt))t.enqueue(e)}}function Cn(e,t){t=Array.isArray(t)?t:[t];let r=!1,n=()=>{},i=[];const o={enqueue(e){i.push(e),n()},finish(){r=!0,n()}};for(const r of t){let t=Ye(e,r);t||(t=new Set,X.get(e).set(r,t)),t.add(o)}return{async next(){return i?0===i.length?r?(i=void 0,this.next()):(await new Promise(e=>{n=e}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(r){i=void 0;for(const r of t){const t=Ye(e,r);t&&(t.delete(o),0===t.size&&X.get(e).delete(r))}return n(),arguments.length>0?{done:!0,value:await r}:{done:!0}},[Symbol.asyncIterator](){return this}}}function On(e){if(void 0===e)return Mn;if(!Array.isArray(e))throw new TypeError("`methodNames` must be an array of strings");for(const t of e)if(!Mn.includes(t))throw"string"!=typeof t?new TypeError("`methodNames` element must be a string"):new Error(`${t} is not Emittery method`);return e}const Be=e=>e===Dt||e===Ut;function pt(e,t,r){if(Be(t))try{Lt=!0,e.emit(t,r)}finally{Lt=!1}}let et=class e{static mixin(t,r){return r=On(r),n=>{if("function"!=typeof n)throw new TypeError("`target` must be function");for(const e of r)if(void 0!==n.prototype[e])throw new Error(`The property \`${e}\` already exists on \`target\``);Object.defineProperty(n.prototype,t,{enumerable:!1,get:function(){return Object.defineProperty(this,t,{enumerable:!1,value:new e}),this[t]}});const i=e=>function(...r){return this[t][e](...r)};for(const e of r)Object.defineProperty(n.prototype,e,{enumerable:!1,value:i(e)});return n}}static get isDebugEnabled(){if("object"!=typeof globalThis.process?.env)return gr;const{env:e}=globalThis.process??{env:{}};return"emittery"===e.DEBUG||"*"===e.DEBUG||gr}static set isDebugEnabled(e){gr=e}constructor(e={}){te.set(this,new Set),pe.set(this,new Map),X.set(this,new Map),X.get(this).set(Bt,new Set),this.debug=e.debug??{},void 0===this.debug.enabled&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(e,t,r,n)=>{try{n=JSON.stringify(n)}catch{n=`Object with the following keys failed to stringify: ${Object.keys(n).join(",")}`}("symbol"==typeof r||"number"==typeof r)&&(r=r.toString());const i=new Date,o=`${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}.${i.getMilliseconds()}`;console.log(`[${o}][emittery:${e}][${t}] Event Name: ${r}\n\tdata: ${n}`)})}logIfDebugEnabled(t,r,n){(e.isDebugEnabled||this.debug.enabled)&&this.debug.logger(t,this.debug.name,r,n)}on(e,t,{signal:r}={}){mt(t),e=Array.isArray(e)?e:[e];for(const r of e){Se(r);let e=Ie(this,r);e||(e=new Set,pe.get(this).set(r,e)),e.add(t),this.logIfDebugEnabled("subscribe",r,void 0),Be(r)||pt(this,Dt,{eventName:r,listener:t})}const n=()=>{this.off(e,t),r?.removeEventListener("abort",n)};return r?.addEventListener("abort",n,{once:!0}),r?.aborted&&n(),n}off(e,t){mt(t),e=Array.isArray(e)?e:[e];for(const r of e){Se(r);const e=Ie(this,r);e&&(e.delete(t),0===e.size&&pe.get(this).delete(r)),this.logIfDebugEnabled("unsubscribe",r,void 0),Be(r)||pt(this,Ut,{eventName:r,listener:t})}}once(e,t){if(void 0!==t&&"function"!=typeof t)throw new TypeError("predicate must be a function");let r;const n=new Promise(n=>{r=this.on(e,e=>{t&&!t(e)||(r(),n(e))})});return n.off=r,n}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Se(t);return Cn(this,e)}async emit(e,t){if(Se(e),Be(e)&&!Lt)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Ks(this,e,t);const r=Ie(this,e)??new Set,n=te.get(this),i=[...r],o=Be(e)?[]:[...n];await Fn,await Promise.all([...i.map(async e=>{if(r.has(e))return e(t)}),...o.map(async r=>{if(n.has(r))return r(e,t)})])}async emitSerial(e,t){if(Se(e),Be(e)&&!Lt)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const r=Ie(this,e)??new Set,n=te.get(this),i=[...r],o=[...n];await Fn;for(const e of i)r.has(e)&&await e(t);for(const r of o)n.has(r)&&await r(e,t)}onAny(e,{signal:t}={}){mt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),te.get(this).add(e),pt(this,Dt,{listener:e});const r=()=>{this.offAny(e),t?.removeEventListener("abort",r)};return t?.addEventListener("abort",r,{once:!0}),t?.aborted&&r(),r}anyEvent(){return Cn(this)}offAny(e){mt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),pt(this,Ut,{listener:e}),te.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),zt(t)){const e=Ie(this,t);e&&e.clear();const r=Ye(this,t);if(r){for(const e of r)e.finish();r.clear()}}else{te.get(this).clear();for(const[e,t]of pe.get(this).entries())t.clear(),pe.get(this).delete(e);for(const[e,t]of X.get(this).entries()){for(const e of t)e.finish();t.clear(),X.get(this).delete(e)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const r of e)if(zt(r))t+=te.get(this).size+(Ie(this,r)?.size??0)+(Ye(this,r)?.size??0)+(Ye(this)?.size??0);else{void 0!==r&&Se(r),t+=te.get(this).size;for(const e of pe.get(this).values())t+=e.size;for(const e of X.get(this).values())t+=e.size}return t}bindMethods(e,t){if("object"!=typeof e||null===e)throw new TypeError("`target` must be an object");t=On(t);for(const r of t){if(void 0!==e[r])throw new Error(`The property \`${r}\` already exists on \`target\``);Object.defineProperty(e,r,{enumerable:!1,value:this[r].bind(this)})}}};const Mn=Object.getOwnPropertyNames(et.prototype).filter(e=>"constructor"!==e);function zr(e,t){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let r=globalThis.vonage.workerizer;return r[e]||(r[e]=t),r[e]}Object.defineProperty(et,"listenerAdded",{value:Dt,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(et,"listenerRemoved",{value:Ut,writable:!1,enumerable:!0,configurable:!1});const Le=zr("globals",{});var z=(e=>(e.INIT="INIT",e.FORWARD="FORWARD",e.TERMINATE="TERMINATE",e.GLOBALS_SYNC="GLOBALS_SYNC",e.EVENT="EVENT",e))(z||{});function fi(e){return[ImageBitmap,ReadableStream,WritableStream].some(t=>e instanceof t)}let Js=0;function Nt(e,t,r,n,i){const o=Js++;return e.postMessage({id:o,type:t,functionName:r,args:n},n.filter(e=>fi(e))),new Promise(e=>{i?.set(o,e)})}function ze(e,t){const{id:r,type:n}=e,i=Array.isArray(t)?t:[t];postMessage({id:r,type:n,result:t},i.filter(e=>fi(e)))}const $t=zr("workerized",{});function Nr(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function Zs(){if(Nr())ze({type:z.GLOBALS_SYNC},Le);else{const e=[];for(const t in $t){const{worker:r,resolvers:n}=$t[t].workerContext;r&&e.push(Nt(r,z.GLOBALS_SYNC,"",[Le],n))}await Promise.all(e)}}function qe(e,t){if(Array.isArray(t))t.splice(0,t.length);else if("object"==typeof t)for(const e in t)delete t[e];for(const r in e)Array.isArray(e[r])?(t[r]=[],qe(e[r],t[r])):"object"==typeof e[r]?(t[r]={},qe(e[r],t[r])):t[r]=e[r]}async function ea(e,t,r,n){const i=new t;if(i.addEventListener("message",async({data:e})=>{var t,i,o,s,a,c,u;switch(e.type){case z.GLOBALS_SYNC:e.id?(null==(i=r.get(null!=(t=e.id)?t:-1))||i(e.result),r.delete(null!=(o=e.id)?o:-1)):(qe(null!=(s=e.result)?s:{},Le),await Zs());break;case z.EVENT:const{result:l}=e,f=l;if(null==f?.name)throw"Missing event name";n(f.name,f.data);break;default:null==(c=r.get(null!=(a=e.id)?a:-1))||c(e.result),r.delete(null!=(u=e.id)?u:-1)}}),!await Nt(i,z.INIT,"",[e.workerId,Le],r))throw"Failed to instantiate workerized class";return i}const re=new WeakMap,ge=new WeakMap,K=new WeakMap,Wt=Symbol("anyProducer"),Bn=Promise.resolve(),Gt=Symbol("listenerAdded"),Vt=Symbol("listenerRemoved");let Ht=!1,yr=!1;function Re(e){if("string"!=typeof e&&"symbol"!=typeof e&&"number"!=typeof e)throw new TypeError("`eventName` must be a string, symbol, or number")}function gt(e){if("function"!=typeof e)throw new TypeError("listener must be a function")}function ke(e,t){const r=ge.get(e);if(r.has(t))return r.get(t)}function Qe(e,t){const r="string"==typeof t||"symbol"==typeof t||"number"==typeof t?t:Wt,n=K.get(e);if(n.has(r))return n.get(r)}function ta(e,t,r){const n=K.get(e);if(n.has(t))for(const e of n.get(t))e.enqueue(r);if(n.has(Wt)){const e=Promise.all([t,r]);for(const t of n.get(Wt))t.enqueue(e)}}function Dn(e,t){t=Array.isArray(t)?t:[t];let r=!1,n=()=>{},i=[];const o={enqueue(e){i.push(e),n()},finish(){r=!0,n()}};for(const r of t){let t=Qe(e,r);t||(t=new Set,K.get(e).set(r,t)),t.add(o)}return{async next(){return i?0===i.length?r?(i=void 0,this.next()):(await new Promise(e=>{n=e}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(r){i=void 0;for(const r of t){const t=Qe(e,r);t&&(t.delete(o),0===t.size&&K.get(e).delete(r))}return n(),arguments.length>0?{done:!0,value:await r}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Un(e){if(void 0===e)return Ln;if(!Array.isArray(e))throw new TypeError("`methodNames` must be an array of strings");for(const t of e)if(!Ln.includes(t))throw"string"!=typeof t?new TypeError("`methodNames` element must be a string"):new Error(`${t} is not Emittery method`);return e}const De=e=>e===Gt||e===Vt;function yt(e,t,r){if(De(t))try{Ht=!0,e.emit(t,r)}finally{Ht=!1}}class ve{static mixin(e,t){return t=Un(t),r=>{if("function"!=typeof r)throw new TypeError("`target` must be function");for(const e of t)if(void 0!==r.prototype[e])throw new Error(`The property \`${e}\` already exists on \`target\``);Object.defineProperty(r.prototype,e,{enumerable:!1,get:function(){return Object.defineProperty(this,e,{enumerable:!1,value:new ve}),this[e]}});const n=t=>function(...r){return this[e][t](...r)};for(const e of t)Object.defineProperty(r.prototype,e,{enumerable:!1,value:n(e)});return r}}static get isDebugEnabled(){var e,t;if("object"!=typeof(null==(e=globalThis.process)?void 0:e.env))return yr;const{env:r}=null!=(t=globalThis.process)?t:{env:{}};return"emittery"===r.DEBUG||"*"===r.DEBUG||yr}static set isDebugEnabled(e){yr=e}constructor(e={}){var t;re.set(this,new Set),ge.set(this,new Map),K.set(this,new Map),K.get(this).set(Wt,new Set),this.debug=null!=(t=e.debug)?t:{},void 0===this.debug.enabled&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(e,t,r,n)=>{try{n=JSON.stringify(n)}catch{n=`Object with the following keys failed to stringify: ${Object.keys(n).join(",")}`}("symbol"==typeof r||"number"==typeof r)&&(r=r.toString());const i=new Date,o=`${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}.${i.getMilliseconds()}`;console.log(`[${o}][emittery:${e}][${t}] Event Name: ${r}\n\tdata: ${n}`)})}logIfDebugEnabled(e,t,r){(ve.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,r)}on(e,t){gt(t),e=Array.isArray(e)?e:[e];for(const r of e){Re(r);let e=ke(this,r);e||(e=new Set,ge.get(this).set(r,e)),e.add(t),this.logIfDebugEnabled("subscribe",r,void 0),De(r)||yt(this,Gt,{eventName:r,listener:t})}return this.off.bind(this,e,t)}off(e,t){gt(t),e=Array.isArray(e)?e:[e];for(const r of e){Re(r);const e=ke(this,r);e&&(e.delete(t),0===e.size&&ge.get(this).delete(r)),this.logIfDebugEnabled("unsubscribe",r,void 0),De(r)||yt(this,Vt,{eventName:r,listener:t})}}once(e){let t;const r=new Promise(r=>{t=this.on(e,e=>{t(),r(e)})});return r.off=t,r}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Re(t);return Dn(this,e)}async emit(e,t){var r;if(Re(e),De(e)&&!Ht)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),ta(this,e,t);const n=null!=(r=ke(this,e))?r:new Set,i=re.get(this),o=[...n],s=De(e)?[]:[...i];await Bn,await Promise.all([...o.map(async e=>{if(n.has(e))return e(t)}),...s.map(async r=>{if(i.has(r))return r(e,t)})])}async emitSerial(e,t){var r;if(Re(e),De(e)&&!Ht)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const n=null!=(r=ke(this,e))?r:new Set,i=re.get(this),o=[...n],s=[...i];await Bn;for(const e of o)n.has(e)&&await e(t);for(const r of s)i.has(r)&&await r(e,t)}onAny(e){return gt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),re.get(this).add(e),yt(this,Gt,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Dn(this)}offAny(e){gt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),yt(this,Vt,{listener:e}),re.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),"string"==typeof t||"symbol"==typeof t||"number"==typeof t){const e=ke(this,t);e&&e.clear();const r=Qe(this,t);if(r){for(const e of r)e.finish();r.clear()}}else{re.get(this).clear();for(const[e,t]of ge.get(this).entries())t.clear(),ge.get(this).delete(e);for(const[e,t]of K.get(this).entries()){for(const e of t)e.finish();t.clear(),K.get(this).delete(e)}}}listenerCount(e){var t,r,n,i,o,s;e=Array.isArray(e)?e:[e];let a=0;for(const c of e)if("string"!=typeof c){typeof c<"u"&&Re(c),a+=re.get(this).size;for(const e of ge.get(this).values())a+=e.size;for(const e of K.get(this).values())a+=e.size}else a+=re.get(this).size+(null!=(r=null==(t=ke(this,c))?void 0:t.size)?r:0)+(null!=(i=null==(n=Qe(this,c))?void 0:n.size)?i:0)+(null!=(s=null==(o=Qe(this))?void 0:o.size)?s:0);return a}bindMethods(e,t){if("object"!=typeof e||null===e)throw new TypeError("`target` must be an object");t=Un(t);for(const r of t){if(void 0!==e[r])throw new Error(`The property \`${r}\` already exists on \`target\``);Object.defineProperty(e,r,{enumerable:!1,value:this[r].bind(this)})}}}const Ln=Object.getOwnPropertyNames(ve.prototype).filter(e=>"constructor"!==e);function ra(e){return e.onAny&&e.emit}function na(e){return e.prototype.onAny&&e.prototype.emit}Object.defineProperty(ve,"listenerAdded",{value:Gt,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(ve,"listenerRemoved",{value:Vt,writable:!1,enumerable:!0,configurable:!1});let ia=0;async function oa(e,t,r){const n=na(e)?new ve:{},i=ia++;return Object.getOwnPropertyNames(e.prototype).forEach(e=>{n[e]=(...n)=>Nt(t,z.FORWARD,e,n,r)}),n.terminate=async(...e)=>{const o=await Nt(t,z.TERMINATE,"",e,r);return delete $t[i],t.terminate(),n.workerContext.worker=void 0,o},n.workerContext={id:i,worker:t,resolvers:r},$t[i]=n,n}async function sa(e,t){const r=new Map;let n;const i=await ea(e,t,r,(e,t)=>{n?.emit&&n?.emit(e,t)});return n=await oa(e,i,r),n}async function aa(e,t){const{functionName:r,args:n}=e;if(!t.instance)throw"instance not initialized";if(!r)throw"missing function name to call";if(!t.instance[r])throw`undefined function [${r}] in class ${t.instance.constructor.workerId}`;ze(e,await t.instance[r](...n??[]))}const di=zr("registeredWorkers",{});function ca(e,t){t.workerId=e,Nr()&&(di[t.workerId]=t)}function ua(e,t){if(!e.args)throw"Missing className while initializing worker";const[r,n]=e.args,i=di[r];if(!i)throw`unknown worker class ${r}`;t.instance=new i(e.args.slice(1)),qe(n,Le),ra(t.instance)&&t.instance.onAny((e,t)=>{ze({type:z.EVENT},{name:e,data:t})}),ze(e,void 0!==typeof t.instance)}async function la(e,t){const{args:r}=e;if(!t.instance)throw"instance not initialized";let n;t.instance.terminate&&(n=await t.instance.terminate(...r??[])),ze(e,n)}function fa(e){if(!e.args)throw"Missing globals while syncing";qe(e.args[0],Le),ze(e,{})}function da(){const e={};onmessage=async t=>{const r=t.data;switch(r.type){case z.INIT:ua(r,e);break;case z.FORWARD:aa(r,e);break;case z.TERMINATE:la(r,e);break;case z.GLOBALS_SYNC:fa(r)}}}Nr()&&da();class zn{static async createVideoReadable(e){return new Promise((t,r)=>{const n=document.createElement("video");let i=new AbortController,o=new AbortController;n.addEventListener("canplay",()=>{i.abort(),n.muted=!0,n.loop=!0,n.play().then(()=>{try{const e=n.captureStream(),r=new MediaStreamTrackProcessor(e.getVideoTracks()[0]);t(r.readable)}catch(e){r(e)}})},{once:!0,signal:o.signal}),n.addEventListener("error",e=>{o.abort(),r("loading error:"+e)},{once:!0,signal:i.signal}),n.crossOrigin="anonymous",n.src=e})}static async createImageCanvas(e){const t=await(await fetch(e)).blob();return await createImageBitmap(t)}}var ha=Object.defineProperty,ma=(e,t,r)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pa=(e,t,r)=>(ma(e,t+"",r),r);const ga="hlg.tokbox.com/prod/logging/vcp_webrtc",ya="https://",ba=1e4;let bt;const wa=new Uint8Array(16);function xa(){if(!bt&&(bt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!bt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return bt(wa)}const C=[];for(let e=0;e<256;++e)C.push((e+256).toString(16).slice(1));function va(e,t=0){return(C[e[t+0]]+C[e[t+1]]+C[e[t+2]]+C[e[t+3]]+"-"+C[e[t+4]]+C[e[t+5]]+"-"+C[e[t+6]]+C[e[t+7]]+"-"+C[e[t+8]]+C[e[t+9]]+"-"+C[e[t+10]]+C[e[t+11]]+C[e[t+12]]+C[e[t+13]]+C[e[t+14]]+C[e[t+15]]).toLowerCase()}const _a=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Nn={randomUUID:_a};function Ea(e,t,r){if(Nn.randomUUID&&!t&&!e)return Nn.randomUUID();const n=(e=e||{}).random||(e.rng||xa)();return n[6]=15&n[6]|64,n[8]=63&n[8]|128,va(n)}function $r(e,t){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let r=globalThis.vonage.workerizer;return r[e]||(r[e]=t),r[e]}const oe=$r("globals",{});var we=(e=>(e.INIT="INIT",e.FORWARD="FORWARD",e.TERMINATE="TERMINATE",e.GLOBALS_SYNC="GLOBALS_SYNC",e))(we||{});function hi(e){return[ImageBitmap,ReadableStream,WritableStream].some(t=>e instanceof t)}let Aa=0;function Ta(e,t,r,n,i){const o=Aa++;return e.postMessage({id:o,type:t,functionName:r,args:n},n.filter(e=>hi(e))),new Promise(e=>{i?.set(o,e)})}function tt(e,t){const{id:r,type:n}=e,i=Array.isArray(t)?t:[t];postMessage({id:r,type:n,result:t},i.filter(e=>hi(e)))}const $n=$r("workerized",{});function mi(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function Sa(){if(mi())tt({type:we.GLOBALS_SYNC},oe);else{const e=[];for(const t in $n){const{worker:r,resolvers:n}=$n[t].workerContext;r&&e.push(Ta(r,we.GLOBALS_SYNC,"",[oe],n))}await Promise.all(e)}}function jt(e,t){if(Array.isArray(t))t.splice(0,t.length);else if("object"==typeof t)for(const e in t)delete t[e];for(const r in e)Array.isArray(e[r])?(t[r]=[],jt(e[r],t[r])):"object"==typeof e[r]?(t[r]={},jt(e[r],t[r])):t[r]=e[r]}async function Ia(e,t){const{functionName:r,args:n}=e;if(!t.instance)throw"instance not initialized";if(!r)throw"missing function name to call";if(!t.instance[r])throw`undefined function [${r}] in class ${t.instance.constructor.workerId}`;tt(e,await t.instance[r](...n??[]))}const Ra=$r("registeredWorkers",{});function ka(e,t){if(!e.args)throw"Missing className while initializing worker";const[r,n]=e.args,i=Ra[r];if(!i)throw`unknown worker class ${r}`;t.instance=new i(e.args.slice(1)),jt(n,oe),tt(e,void 0!==typeof t.instance)}async function Pa(e,t){const{args:r}=e;if(!t.instance)throw"instance not initialized";let n;t.instance.terminate&&(n=await t.instance.terminate(...r??[])),tt(e,n)}function Fa(e){if(!e.args)throw"Missing globals while syncing";jt(e.args[0],oe),tt(e,{})}function Ca(){const e={};onmessage=async t=>{const r=t.data;switch(r.type){case we.INIT:ka(r,e);break;case we.FORWARD:Ia(r,e);break;case we.TERMINATE:Pa(r,e);break;case we.GLOBALS_SYNC:Fa(r)}}}function Oa(e,t){return oe[e]||(oe[e]=t),[()=>oe[e],async t=>{oe[e]=t,await Sa()}]}function Ma(e,t){return Oa(e,t)}mi()&&Ca();const[Ba]=Ma("metadata");function br(){return Ba()}class Da{constructor(e){pa(this,"uuid",Ea()),this.config=e}async send(e){var t,r,n;const{appId:i,sourceType:o}=null!=(t=br())?t:{};if(!i||!o)return"metadata missing";const s=new AbortController,a=setTimeout(()=>s.abort(),ba);return await(null!=(n=null==(r=this.config)?void 0:r.fetch)?n:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:s.signal}),clearTimeout(a),"success"}getUrl(){var e;let t=null!=(e=br().proxyUrl)?e:ya;return t+=("/"===t.at(-1)?"":"/")+ga,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=br();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const Ua="7.0.0-alpha.3";class Wr{constructor(){const e=new OffscreenCanvas(0,0),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw"Fail to retrieve 2d context";this.canvas=e,this.context=t}enablePostProcessing(){}disablePostProcessing(){}async profileWebgl(e){return[]}async render(e,t){return this.canvas}resizeCanvas(e){const{width:t,height:r}=e;this.canvas.width=t,this.canvas.height=r}renderSilhouette(e,t,r="none"){const{width:n,height:i}=e;this.context.save(),this.context.drawImage(t,0,0,t.width,t.height,0,0,n,i),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(t,0,0,t.width,t.height,0,0,n,i),this.context.globalCompositeOperation="source-in",this.context.filter=r,this.context.drawImage(e,0,0,n,i,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class La extends Wr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const r=await createImageBitmap(t);return this.renderSilhouette(e,r),this.context.save(),this.context.filter=`blur(${this.radius}px)`,this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class za extends Wr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const r=await createImageBitmap(t);return this.renderSilhouette(e,r,`blur(${this.radius}px)`),this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class Na extends Wr{setBackgroundImage(e){this.backgroundImage=e}async render(e,t){super.resizeCanvas(e);const r=await createImageBitmap(t);return this.renderSilhouette(e,r),this.backgroundImage&&(this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(this.backgroundImage,0,0,this.backgroundImage.width,this.backgroundImage.height,0,0,e.width,e.height),this.context.restore()),super.render(e,t)}}const Gr=5120,Xe=5121,Vr=5122,Hr=5123,jr=5124,Yr=5125,Qr=5126,$a=32819,Wa=32820,Ga=33635,Va=5131,Ha=33640,ja=35899,Ya=35902,Qa=36269,qa=34042,pi={};{const e=pi;e[Gr]=Int8Array,e[Xe]=Uint8Array,e[Vr]=Int16Array,e[Hr]=Uint16Array,e[jr]=Int32Array,e[Yr]=Uint32Array,e[Qr]=Float32Array,e[$a]=Uint16Array,e[Wa]=Uint16Array,e[Ga]=Uint16Array,e[Va]=Uint16Array,e[Ha]=Uint32Array,e[ja]=Uint32Array,e[Ya]=Uint32Array,e[Qa]=Uint32Array,e[qa]=Uint32Array}function qr(e){if(e instanceof Int8Array)return Gr;if(e instanceof Uint8Array||e instanceof Uint8ClampedArray)return Xe;if(e instanceof Int16Array)return Vr;if(e instanceof Uint16Array)return Hr;if(e instanceof Int32Array)return jr;if(e instanceof Uint32Array)return Yr;if(e instanceof Float32Array)return Qr;throw new Error("unsupported typed array type")}function gi(e){if(e===Int8Array)return Gr;if(e===Uint8Array||e===Uint8ClampedArray)return Xe;if(e===Int16Array)return Vr;if(e===Uint16Array)return Hr;if(e===Int32Array)return jr;if(e===Uint32Array)return Yr;if(e===Float32Array)return Qr;throw new Error("unsupported typed array type")}function yi(e){const t=pi[e];if(!t)throw new Error("unknown gl type");return t}const Yt=typeof SharedArrayBuffer<"u"?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer};function bi(...e){console.error(...e)}const Wn=new Map;function Zt(e,t){if(!e||"object"!=typeof e)return!1;let r=Wn.get(t);r||(r=new WeakMap,Wn.set(t,r));let n=r.get(e);if(void 0===n){const i=Object.prototype.toString.call(e);n=i.substring(8,i.length-1)===t,r.set(e,n)}return n}function Xa(e,t){return typeof WebGLBuffer<"u"&&Zt(t,"WebGLBuffer")}function Ka(e,t){return typeof WebGLRenderbuffer<"u"&&Zt(t,"WebGLRenderbuffer")}function Xr(e,t){return typeof WebGLTexture<"u"&&Zt(t,"WebGLTexture")}function Ja(e,t){return typeof WebGLSampler<"u"&&Zt(t,"WebGLSampler")}const wi=35044,xe=34962,Za=34963,ec=34660,tc=5120,rc=5121,nc=5122,ic=5123,oc=5124,sc=5125,xi=5126,vi={attribPrefix:""};function ac(e,t,r,n,i){e.bindBuffer(t,r),e.bufferData(t,n,i||wi)}function _i(e,t,r,n){if(Xa(e,t))return t;r=r||xe;const i=e.createBuffer();return ac(e,r,i,t,n),i}function Ei(e){return"indices"===e}function cc(e){return e===Int8Array||e===Uint8Array}function uc(e){return e.length?e:e.data}const lc=/coord|texture/i,fc=/color|colour/i;function dc(e,t){let r;if(r=lc.test(e)?2:fc.test(e)?4:3,t%r>0)throw new Error(`Can not guess numComponents for attribute '${e}'. Tried ${r} but ${t} values is not evenly divisible by ${r}. You should specify it.`);return r}function hc(e,t,r){return e.numComponents||e.size||dc(t,r||uc(e).length)}function Ai(e,t){if(Yt(e))return e;if(Yt(e.data))return e.data;Array.isArray(e)&&(e={data:e});let r=e.type?Kr(e.type):void 0;return r||(r=Ei(t)?Uint16Array:Float32Array),new r(e.data)}function mc(e){return"number"==typeof e?e:e?gi(e):xi}function Kr(e){return"number"==typeof e?yi(e):e||Float32Array}function pc(e,t){return{buffer:t.buffer,numValues:24,type:mc(t.type),arrayType:Kr(t.type)}}function gc(e,t){const r=t.data||t,n=Kr(t.type),i=r*n.BYTES_PER_ELEMENT,o=e.createBuffer();return e.bindBuffer(xe,o),e.bufferData(xe,i,t.drawType||wi),{buffer:o,numValues:r,type:gi(n),arrayType:n}}function yc(e,t,r){const n=Ai(t,r);return{arrayType:n.constructor,buffer:_i(e,n,void 0,t.drawType),type:qr(n),numValues:0}}function bc(e,t){const r={};return Object.keys(t).forEach(function(n){if(!Ei(n)){const i=t[n],o=i.attrib||i.name||i.attribName||vi.attribPrefix+n;if(i.value){if(!Array.isArray(i.value)&&!Yt(i.value))throw new Error("array.value is not array or typedarray");r[o]={value:i.value}}else{let t;t=i.buffer&&i.buffer instanceof WebGLBuffer?pc:"number"==typeof i||"number"==typeof i.data?gc:yc;const{buffer:s,type:a,numValues:c,arrayType:u}=t(e,i,n),l=void 0!==i.normalize?i.normalize:cc(u),f=hc(i,n,c);r[o]={buffer:s,numComponents:f,type:a,normalize:l,stride:i.stride||0,offset:i.offset||0,divisor:void 0===i.divisor?void 0:i.divisor,drawType:i.drawType}}}}),e.bindBuffer(xe,null),r}function wc(e,t){return t===tc||t===rc?1:t===nc||t===ic?2:t===oc||t===sc||t===xi?4:0}const wr=["position","positions","a_position"];function xc(e,t){let r,n;for(n=0;n<wr.length&&(r=wr[n],!(r in t)&&(r=vi.attribPrefix+r,!(r in t)));++n);n===wr.length&&(r=Object.keys(t)[0]);const i=t[r];if(!i.buffer)return 1;e.bindBuffer(xe,i.buffer);const o=e.getBufferParameter(xe,ec);e.bindBuffer(xe,null);const s=o/wc(e,i.type),a=i.numComponents||i.size,c=s/a;if(c%1!=0)throw new Error(`numComponents ${a} not correct for length ${length}`);return c}function vc(e,t,r){const n=bc(e,t),i=Object.assign({},r||{});i.attribs=Object.assign({},r?r.attribs:{},n);const o=t.indices;if(o){const t=Ai(o,"indices");i.indices=_i(e,t,Za),i.numElements=t.length,i.elementType=qr(t)}else i.numElements||(i.numElements=xc(e,i.attribs));return i}function rt(e){return!!e.texStorage2D}const Ti=function(){const e={},t={};return function(r,n){return function(r){const n=r.constructor.name;if(!e[n]){for(const e in r)if("number"==typeof r[e]){const n=t[r[e]];t[r[e]]=n?`${n} | ${e}`:e}e[n]=!0}}(r),t[n]||("number"==typeof n?`0x${n.toString(16)}`:n)}}(),ae={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},Ke=Yt,Si=function(){let e;return function(){return e=e||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),e}}(),Gn=6406,j=6407,T=6408,Vn=6409,Hn=6410,Ve=6402,jn=34041,Qt=33071,_c=9728,Ec=9729,ce=3553,se=34067,_e=32879,Ee=35866,Jr=34069,Ac=34070,Tc=34071,Sc=34072,Ic=34073,Rc=34074,Sr=10241,Ir=10240,qt=10242,Xt=10243,Yn=32882,kc=33082,Pc=33083,Fc=33084,Cc=33085,Oc=34892,Mc=34893,Zr=3317,Ii=3314,Ri=32878,ki=3316,Pi=3315,Fi=32877,Bc=37443,Dc=37441,Uc=37440,Lc=33321,zc=36756,Nc=33325,$c=33326,Wc=33330,Gc=33329,Vc=33338,Hc=33337,jc=33340,Yc=33339,Qc=33323,qc=36757,Xc=33327,Kc=33328,Jc=33336,Zc=33335,eu=33332,tu=33331,ru=33334,nu=33333,iu=32849,ou=35905,su=36194,au=36758,cu=35898,uu=35901,lu=34843,fu=34837,du=36221,hu=36239,mu=36215,pu=36233,gu=36209,yu=36227,bu=32856,wu=35907,xu=36759,vu=32855,_u=32854,Eu=32857,Au=34842,Tu=34836,Su=36220,Iu=36238,Ru=36975,ku=36214,Pu=36232,Fu=36226,Cu=36208,Ou=33189,Mu=33190,Bu=36012,Du=36013,Uu=35056,ne=5120,A=5121,wt=5122,Pe=5123,xt=5124,de=5125,M=5126,Qn=32819,qn=32820,Xn=33635,G=5131,He=36193,xr=33640,Lu=35899,zu=35902,Nu=36269,$u=34042,vt=33319,Fe=33320,_t=6403,Ce=36244,Oe=36248,he=36249;let vr;function er(e){if(!vr){const e={};e[Gn]={textureFormat:Gn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,G,He,M]},e[Vn]={textureFormat:Vn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,G,He,M]},e[Hn]={textureFormat:Hn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[A,G,He,M]},e[j]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[A,G,He,M,Xn]},e[T]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[A,G,He,M,Qn,qn]},e[Ve]={textureFormat:Ve,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[de,Pe]},e[Lc]={textureFormat:_t,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[A]},e[zc]={textureFormat:_t,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ne]},e[Nc]={textureFormat:_t,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[M,G]},e[$c]={textureFormat:_t,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[M]},e[Wc]={textureFormat:Ce,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[A]},e[Gc]={textureFormat:Ce,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ne]},e[eu]={textureFormat:Ce,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Pe]},e[tu]={textureFormat:Ce,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[wt]},e[ru]={textureFormat:Ce,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[de]},e[nu]={textureFormat:Ce,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[xt]},e[Qc]={textureFormat:vt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[A]},e[qc]={textureFormat:vt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ne]},e[Xc]={textureFormat:vt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[M,G]},e[Kc]={textureFormat:vt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[M]},e[Jc]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[A]},e[Zc]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ne]},e[Vc]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Pe]},e[Hc]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[wt]},e[jc]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[de]},e[Yc]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[xt]},e[iu]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[A]},e[ou]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[A]},e[su]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[A,Xn]},e[au]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ne]},e[cu]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[M,G,Lu]},e[uu]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[M,G,zu]},e[lu]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[M,G]},e[fu]={textureFormat:j,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[M]},e[du]={textureFormat:Oe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[A]},e[hu]={textureFormat:Oe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ne]},e[mu]={textureFormat:Oe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Pe]},e[pu]={textureFormat:Oe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[wt]},e[gu]={textureFormat:Oe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[de]},e[yu]={textureFormat:Oe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[xt]},e[bu]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},e[wu]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},e[xu]={textureFormat:T,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ne]},e[vu]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[A,qn,xr]},e[_u]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[A,Qn]},e[Eu]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[xr]},e[Au]={textureFormat:T,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[M,G]},e[Tu]={textureFormat:T,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[M]},e[Su]={textureFormat:he,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[A]},e[Iu]={textureFormat:he,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ne]},e[Ru]={textureFormat:he,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[xr]},e[ku]={textureFormat:he,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Pe]},e[Pu]={textureFormat:he,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[wt]},e[Fu]={textureFormat:he,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[xt]},e[Cu]={textureFormat:he,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[de]},e[Ou]={textureFormat:Ve,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Pe,de]},e[Mu]={textureFormat:Ve,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[de]},e[Bu]={textureFormat:Ve,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[M]},e[Uu]={textureFormat:jn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[$u]},e[Du]={textureFormat:jn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Nu]},Object.keys(e).forEach(function(t){const r=e[t];r.bytesPerElementMap={},r.bytesPerElement.forEach(function(e,t){const n=r.type[t];r.bytesPerElementMap[n]=e})}),vr=e}return vr[e]}function Wu(e,t){const r=er(e);if(!r)throw"unknown internal format";const n=r.bytesPerElementMap[t];if(void 0===n)throw"unknown internal format";return n}function nt(e){const t=er(e);if(!t)throw"unknown internal format";return{format:t.textureFormat,type:t.type[0]}}function Kn(e){return!(e&e-1)}function Gu(e,t,r,n){if(!rt(e))return Kn(t)&&Kn(r);const i=er(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function Vu(e){const t=er(e);if(!t)throw"unknown internal format";return t.textureFilterable}function Hu(e,t,r){return Ke(t)?qr(t):r||A}function Et(e,t,r,n,i){if(i%1!=0)throw"can't guess dimensions";if(r||n){if(n){if(!r&&(r=i/n)%1)throw"can't guess dimensions"}else if((n=i/r)%1)throw"can't guess dimensions"}else{const e=Math.sqrt(i/(t===se?6:1));e%1==0?(r=e,n=e):(r=i,n=1)}return{width:r,height:n}}function Ne(e,t){void 0!==t.colorspaceConversion&&e.pixelStorei(Bc,t.colorspaceConversion),void 0!==t.premultiplyAlpha&&e.pixelStorei(Dc,t.premultiplyAlpha),void 0!==t.flipY&&e.pixelStorei(Uc,t.flipY)}function Ci(e){e.pixelStorei(Zr,4),rt(e)&&(e.pixelStorei(Ii,0),e.pixelStorei(Ri,0),e.pixelStorei(ki,0),e.pixelStorei(Pi,0),e.pixelStorei(Fi,0))}function ju(e,t,r,n){n.minMag&&(r.call(e,t,Sr,n.minMag),r.call(e,t,Ir,n.minMag)),n.min&&r.call(e,t,Sr,n.min),n.mag&&r.call(e,t,Ir,n.mag),n.wrap&&(r.call(e,t,qt,n.wrap),r.call(e,t,Xt,n.wrap),(t===_e||Ja(e,t))&&r.call(e,t,Yn,n.wrap)),n.wrapR&&r.call(e,t,Yn,n.wrapR),n.wrapS&&r.call(e,t,qt,n.wrapS),n.wrapT&&r.call(e,t,Xt,n.wrapT),void 0!==n.minLod&&r.call(e,t,kc,n.minLod),void 0!==n.maxLod&&r.call(e,t,Pc,n.maxLod),void 0!==n.baseLevel&&r.call(e,t,Fc,n.baseLevel),void 0!==n.maxLevel&&r.call(e,t,Cc,n.maxLevel),void 0!==n.compareFunc&&r.call(e,t,Mc,n.compareFunc),void 0!==n.compareMode&&r.call(e,t,Oc,n.compareMode)}function Oi(e,t,r){const n=r.target||ce;e.bindTexture(n,t),ju(e,n,e.texParameteri,r)}function Yu(e){return Ke(e=e||ae.textureColor)?e:new Uint8Array([255*e[0],255*e[1],255*e[2],255*e[3]])}function Rr(e,t,r,n,i,o){o=o||T;const s=(r=r||ae.textureOptions).target||ce;if(n=n||r.width,i=i||r.height,e.bindTexture(s,t),Gu(e,n,i,o))e.generateMipmap(s);else{const t=Vu(o)?Ec:_c;e.texParameteri(s,Sr,t),e.texParameteri(s,Ir,t),e.texParameteri(s,qt,Qt),e.texParameteri(s,Xt,Qt)}}function Je(e){return!0===e.auto||void 0===e.auto&&void 0===e.level}function kr(e,t){return(t=t||{}).cubeFaceOrder||[Jr,Ac,Tc,Sc,Ic,Rc]}function Pr(e,t){const r=kr(e,t).map(function(e,t){return{face:e,ndx:t}});return r.sort(function(e,t){return e.face-t.face}),r}function Mi(e,t,r,n){const i=(n=n||ae.textureOptions).target||ce,o=n.level||0;let s=r.width,a=r.height;const c=n.internalFormat||n.format||T,u=nt(c),l=n.format||u.format,f=n.type||u.type;if(Ne(e,n),e.bindTexture(i,t),i===se){const u=r.width,h=r.height;let d,m;if(u/6===h)d=h,m=[0,0,1,0,2,0,3,0,4,0,5,0];else if(h/6===u)d=u,m=[0,0,0,1,0,2,0,3,0,4,0,5];else if(u/3==h/2)d=u/3,m=[0,0,1,0,2,0,0,1,1,1,2,1];else{if(u/2!=h/3)throw"can't figure out cube map from element: "+(r.src?r.src:r.nodeName);d=u/2,m=[0,0,1,0,0,1,1,1,0,2,1,2]}const p=Si();p?(p.canvas.width=d,p.canvas.height=d,s=d,a=d,Pr(e,n).forEach(function(t){const n=m[2*t.ndx+0]*d,i=m[2*t.ndx+1]*d;p.drawImage(r,n,i,d,d,0,0,d,d),e.texImage2D(t.face,o,c,l,f,p.canvas)}),p.canvas.width=1,p.canvas.height=1):typeof createImageBitmap<"u"&&(s=d,a=d,Pr(e,n).forEach(function(u){const h=m[2*u.ndx+0]*d,p=m[2*u.ndx+1]*d;e.texImage2D(u.face,o,c,d,d,0,l,f,null),createImageBitmap(r,h,p,d,d,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(r){Ne(e,n),e.bindTexture(i,t),e.texImage2D(u.face,o,c,l,f,r),Je(n)&&Rr(e,t,n,s,a,c)})}))}else if(i===_e||i===Ee){const t=Math.min(r.width,r.height),n=Math.max(r.width,r.height),s=n/t;if(s%1!=0)throw"can not compute 3D dimensions of element";const a=r.width===n?1:0,u=r.height===n?1:0;e.pixelStorei(Zr,1),e.pixelStorei(Ii,r.width),e.pixelStorei(Ri,0),e.pixelStorei(Fi,0),e.texImage3D(i,o,c,t,t,t,0,l,f,null);for(let n=0;n<s;++n){const s=n*t*a,c=n*t*u;e.pixelStorei(ki,s),e.pixelStorei(Pi,c),e.texSubImage3D(i,o,0,0,n,t,t,1,l,f,r)}Ci(e)}else e.texImage2D(i,o,c,l,f,r);Je(n)&&Rr(e,t,n,s,a,c),Oi(e,t,n)}function it(){}function Qu(e){if(typeof document<"u"){const t=document.createElement("a");return t.href=e,t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol}{const t=new URL(location.href).origin;return new URL(e,location.href).origin===t}}function qu(e,t){return void 0!==t||Qu(e)?t:"anonymous"}function Xu(e,t,r){let n;if(r=r||it,t=qu(e,t=void 0!==t?t:ae.crossOrigin),typeof Image<"u"){n=new Image,void 0!==t&&(n.crossOrigin=t);const i=function(){n.removeEventListener("error",o),n.removeEventListener("load",s),n=null},o=function(){const t="couldn't load image: "+e;bi(t),r(t,n),i()},s=function(){r(null,n),i()};return n.addEventListener("error",o),n.addEventListener("load",s),n.src=e,n}if(typeof ImageBitmap<"u"){let i,o;const s=function(){r(i,o)},a={};t&&(a.mode="cors"),fetch(e,a).then(function(e){if(!e.ok)throw e;return e.blob()}).then(function(e){return createImageBitmap(e,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(e){o=e,setTimeout(s)}).catch(function(e){i=e,setTimeout(s)}),n=null}return n}function Bi(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof ImageData<"u"&&e instanceof ImageData||typeof HTMLElement<"u"&&e instanceof HTMLElement}function en(e,t,r){return Bi(e)?(setTimeout(function(){r(null,e)}),e):Xu(e,t,r)}function tn(e,t,r){const n=(r=r||ae.textureOptions).target||ce;if(e.bindTexture(n,t),!1===r.color)return;const i=Yu(r.color);if(n===se)for(let t=0;t<6;++t)e.texImage2D(Jr+t,0,T,1,1,0,T,A,i);else n===_e||n===Ee?e.texImage3D(n,0,T,1,1,1,0,T,A,i):e.texImage2D(n,0,T,1,1,0,T,A,i)}function Ku(e,t,r,n){return n=n||it,tn(e,t,r=r||ae.textureOptions),en((r=Object.assign({},r)).src,r.crossOrigin,function(i,o){i?n(i,t,o):(Mi(e,t,o,r),n(null,t,o))})}function Ju(e,t,r,n){n=n||it;const i=r.src;if(6!==i.length)throw"there must be 6 urls for a cubemap";const o=r.level||0,s=r.internalFormat||r.format||T,a=nt(s),c=r.format||a.format,u=r.type||A,l=r.target||ce;if(l!==se)throw"target must be TEXTURE_CUBE_MAP";tn(e,t,r),r=Object.assign({},r);let f=6;const h=[],d=kr(e,r);let m;m=i.map(function(i,a){return en(i,r.crossOrigin,function(i){return function(a,d){--f,a?h.push(a):d.width!==d.height?h.push("cubemap face img is not a square: "+d.src):(Ne(e,r),e.bindTexture(l,t),5===f?kr().forEach(function(t){e.texImage2D(t,o,s,c,u,d)}):e.texImage2D(i,o,s,c,u,d),Je(r)&&e.generateMipmap(l)),0===f&&n(h.length?h:void 0,t,m)}}(d[a]))})}function Zu(e,t,r,n){n=n||it;const i=r.src,o=r.internalFormat||r.format||T,s=nt(o),a=r.format||s.format,c=r.type||A,u=r.target||Ee;if(u!==_e&&u!==Ee)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";tn(e,t,r),r=Object.assign({},r);let l=i.length;const f=[];let h;const d=r.level||0;let m=r.width,p=r.height;const g=i.length;let y=!0;h=i.map(function(i,s){return en(i,r.crossOrigin,function(i){return function(s,b){if(--l,s)f.push(s);else{if(Ne(e,r),e.bindTexture(u,t),y){y=!1,m=r.width||b.width,p=r.height||b.height,e.texImage3D(u,d,o,m,p,g,0,a,c,null);for(let t=0;t<g;++t)e.texSubImage3D(u,d,0,0,t,m,p,1,a,c,b)}else{let t,r=b;(b.width!==m||b.height!==p)&&(t=Si(),r=t.canvas,t.canvas.width=m,t.canvas.height=p,t.drawImage(b,0,0,m,p)),e.texSubImage3D(u,d,0,0,i,m,p,1,a,c,r),t&&r===t.canvas&&(t.canvas.width=0,t.canvas.height=0)}Je(r)&&e.generateMipmap(u)}0===l&&n(f.length?f:void 0,t,h)}}(s))})}function el(e,t,r,n){const i=(n=n||ae.textureOptions).target||ce;e.bindTexture(i,t);let o=n.width,s=n.height,a=n.depth;const c=n.level||0,u=n.internalFormat||n.format||T,l=nt(u),f=n.format||l.format,h=n.type||Hu(e,r,l.type);if(Ke(r))r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));else{const e=yi(h);r=new e(r)}const d=Wu(u,h),m=r.byteLength/d;if(m%1)throw"length wrong size for format: "+Ti(e,f);let p;if(i===_e||i===Ee)if(o||s||a)!o||s&&a?!s||o&&a?(p=Et(e,i,o,s,m/a),o=p.width,s=p.height):(p=Et(e,i,o,a,m/s),o=p.width,a=p.height):(p=Et(e,i,s,a,m/o),s=p.width,a=p.height);else{const e=Math.cbrt(m);if(e%1!=0)throw"can't guess cube size of array of numElements: "+m;o=e,s=e,a=e}else p=Et(e,i,o,s,m),o=p.width,s=p.height;if(Ci(e),e.pixelStorei(Zr,n.unpackAlignment||1),Ne(e,n),i===se){const t=m/6*(d/r.BYTES_PER_ELEMENT);Pr(e,n).forEach(n=>{const i=t*n.ndx,a=r.subarray(i,i+t);e.texImage2D(n.face,c,u,o,s,0,f,h,a)})}else i===_e||i===Ee?e.texImage3D(i,c,u,o,s,a,0,f,h,r):e.texImage2D(i,c,u,o,s,0,f,h,r);return{width:o,height:s,depth:a,type:h}}function tl(e,t,r){const n=r.target||ce;e.bindTexture(n,t);const i=r.level||0,o=r.internalFormat||r.format||T,s=nt(o),a=r.format||s.format,c=r.type||s.type;if(Ne(e,r),n===se)for(let t=0;t<6;++t)e.texImage2D(Jr+t,i,o,r.width,r.height,0,a,c,null);else n===_e||n===Ee?e.texImage3D(n,i,o,r.width,r.height,r.depth,0,a,c,null):e.texImage2D(n,i,o,r.width,r.height,0,a,c,null)}function Di(e,t,r){r=r||it,t=t||ae.textureOptions;const n=e.createTexture(),i=t.target||ce;let o=t.width||1,s=t.height||1;const a=t.internalFormat||T;e.bindTexture(i,n),i===se&&(e.texParameteri(i,qt,Qt),e.texParameteri(i,Xt,Qt));let c=t.src;if(c)if("function"==typeof c&&(c=c(e,t)),"string"==typeof c)Ku(e,n,t,r);else if(Ke(c)||Array.isArray(c)&&("number"==typeof c[0]||Array.isArray(c[0])||Ke(c[0]))){const r=el(e,n,c,t);o=r.width,s=r.height}else Array.isArray(c)&&("string"==typeof c[0]||Bi(c[0]))?i===se?Ju(e,n,t,r):Zu(e,n,t,r):(Mi(e,n,c,t),o=c.width,s=c.height);else tl(e,n,t);return Je(t)&&Rr(e,n,t,o,s,a),Oi(e,n,t),n}const rn=bi;function Ui(e){return typeof document<"u"&&document.getElementById?document.getElementById(e):null}const Kt=33984,tr=34962,rl=34963,nl=35713,il=35714,ol=35632,sl=35633,al=35981,Li=35718,cl=35721,ul=35971,ll=35382,fl=35396,dl=35398,hl=35392,ml=35395,rr=5126,zi=35664,Ni=35665,$i=35666,nn=5124,Wi=35667,Gi=35668,Vi=35669,Hi=35670,ji=35671,Yi=35672,Qi=35673,qi=35674,Xi=35675,Ki=35676,pl=35678,gl=35680,yl=35679,bl=35682,wl=35685,xl=35686,vl=35687,_l=35688,El=35689,Al=35690,Tl=36289,Sl=36292,Il=36293,on=5125,Ji=36294,Zi=36295,eo=36296,Rl=36298,kl=36299,Pl=36300,Fl=36303,Cl=36306,Ol=36307,Ml=36308,Bl=36311,nr=3553,ir=34067,sn=32879,or=35866,w={};function to(e,t){return w[t].bindPoint}function Dl(e,t){return function(r){e.uniform1f(t,r)}}function Ul(e,t){return function(r){e.uniform1fv(t,r)}}function Ll(e,t){return function(r){e.uniform2fv(t,r)}}function zl(e,t){return function(r){e.uniform3fv(t,r)}}function Nl(e,t){return function(r){e.uniform4fv(t,r)}}function ro(e,t){return function(r){e.uniform1i(t,r)}}function no(e,t){return function(r){e.uniform1iv(t,r)}}function io(e,t){return function(r){e.uniform2iv(t,r)}}function oo(e,t){return function(r){e.uniform3iv(t,r)}}function so(e,t){return function(r){e.uniform4iv(t,r)}}function $l(e,t){return function(r){e.uniform1ui(t,r)}}function Wl(e,t){return function(r){e.uniform1uiv(t,r)}}function Gl(e,t){return function(r){e.uniform2uiv(t,r)}}function Vl(e,t){return function(r){e.uniform3uiv(t,r)}}function Hl(e,t){return function(r){e.uniform4uiv(t,r)}}function jl(e,t){return function(r){e.uniformMatrix2fv(t,!1,r)}}function Yl(e,t){return function(r){e.uniformMatrix3fv(t,!1,r)}}function Ql(e,t){return function(r){e.uniformMatrix4fv(t,!1,r)}}function ql(e,t){return function(r){e.uniformMatrix2x3fv(t,!1,r)}}function Xl(e,t){return function(r){e.uniformMatrix3x2fv(t,!1,r)}}function Kl(e,t){return function(r){e.uniformMatrix2x4fv(t,!1,r)}}function Jl(e,t){return function(r){e.uniformMatrix4x2fv(t,!1,r)}}function Zl(e,t){return function(r){e.uniformMatrix3x4fv(t,!1,r)}}function ef(e,t){return function(r){e.uniformMatrix4x3fv(t,!1,r)}}function D(e,t,r,n){const i=to(e,t);return rt(e)?function(t){let o,s;!t||Xr(e,t)?(o=t,s=null):(o=t.texture,s=t.sampler),e.uniform1i(n,r),e.activeTexture(Kt+r),e.bindTexture(i,o),e.bindSampler(r,s)}:function(t){e.uniform1i(n,r),e.activeTexture(Kt+r),e.bindTexture(i,t)}}function U(e,t,r,n,i){const o=to(e,t),s=new Int32Array(i);for(let e=0;e<i;++e)s[e]=r+e;return rt(e)?function(t){e.uniform1iv(n,s),t.forEach(function(t,n){let i,a;e.activeTexture(Kt+s[n]),!t||Xr(e,t)?(i=t,a=null):(i=t.texture,a=t.sampler),e.bindSampler(r,a),e.bindTexture(o,i)})}:function(t){e.uniform1iv(n,s),t.forEach(function(t,r){e.activeTexture(Kt+s[r]),e.bindTexture(o,t)})}}function sr(e,t){return function(r){if(r.value)switch(e.disableVertexAttribArray(t),r.value.length){case 4:e.vertexAttrib4fv(t,r.value);break;case 3:e.vertexAttrib3fv(t,r.value);break;case 2:e.vertexAttrib2fv(t,r.value);break;case 1:e.vertexAttrib1fv(t,r.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else e.bindBuffer(tr,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribPointer(t,r.numComponents||r.size,r.type||rr,r.normalize||!1,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function ue(e,t){return function(r){if(r.value){if(e.disableVertexAttribArray(t),4!==r.value.length)throw new Error("The length of an integer constant value must be 4!");e.vertexAttrib4iv(t,r.value)}else e.bindBuffer(tr,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||nn,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function ar(e,t){return function(r){if(r.value){if(e.disableVertexAttribArray(t),4!==r.value.length)throw new Error("The length of an unsigned integer constant value must be 4!");e.vertexAttrib4uiv(t,r.value)}else e.bindBuffer(tr,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||on,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function an(e,t,r){const n=r.size,i=r.count;return function(r){e.bindBuffer(tr,r.buffer);const o=r.size||r.numComponents||n,s=o/i,a=r.type||rr,c=w[a].size*o,u=r.normalize||!1,l=r.offset||0,f=c/i;for(let n=0;n<i;++n)e.enableVertexAttribArray(t+n),e.vertexAttribPointer(t+n,s,a,u,c,l+f*n),e.vertexAttribDivisor&&e.vertexAttribDivisor(t+n,r.divisor||0)}}w[rr]={Type:Float32Array,size:4,setter:Dl,arraySetter:Ul},w[zi]={Type:Float32Array,size:8,setter:Ll,cols:2},w[Ni]={Type:Float32Array,size:12,setter:zl,cols:3},w[$i]={Type:Float32Array,size:16,setter:Nl,cols:4},w[nn]={Type:Int32Array,size:4,setter:ro,arraySetter:no},w[Wi]={Type:Int32Array,size:8,setter:io,cols:2},w[Gi]={Type:Int32Array,size:12,setter:oo,cols:3},w[Vi]={Type:Int32Array,size:16,setter:so,cols:4},w[on]={Type:Uint32Array,size:4,setter:$l,arraySetter:Wl},w[Ji]={Type:Uint32Array,size:8,setter:Gl,cols:2},w[Zi]={Type:Uint32Array,size:12,setter:Vl,cols:3},w[eo]={Type:Uint32Array,size:16,setter:Hl,cols:4},w[Hi]={Type:Uint32Array,size:4,setter:ro,arraySetter:no},w[ji]={Type:Uint32Array,size:8,setter:io,cols:2},w[Yi]={Type:Uint32Array,size:12,setter:oo,cols:3},w[Qi]={Type:Uint32Array,size:16,setter:so,cols:4},w[qi]={Type:Float32Array,size:32,setter:jl,rows:2,cols:2},w[Xi]={Type:Float32Array,size:48,setter:Yl,rows:3,cols:3},w[Ki]={Type:Float32Array,size:64,setter:Ql,rows:4,cols:4},w[wl]={Type:Float32Array,size:32,setter:ql,rows:2,cols:3},w[xl]={Type:Float32Array,size:32,setter:Kl,rows:2,cols:4},w[vl]={Type:Float32Array,size:48,setter:Xl,rows:3,cols:2},w[_l]={Type:Float32Array,size:48,setter:Zl,rows:3,cols:4},w[El]={Type:Float32Array,size:64,setter:Jl,rows:4,cols:2},w[Al]={Type:Float32Array,size:64,setter:ef,rows:4,cols:3},w[pl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:nr},w[gl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:ir},w[yl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:sn},w[bl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:nr},w[Tl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:or},w[Sl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:or},w[Il]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:ir},w[Rl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:nr},w[kl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:sn},w[Pl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:ir},w[Fl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:or},w[Cl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:nr},w[Ol]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:sn},w[Ml]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:ir},w[Bl]={Type:null,size:0,setter:D,arraySetter:U,bindPoint:or};const I={};I[rr]={size:4,setter:sr},I[zi]={size:8,setter:sr},I[Ni]={size:12,setter:sr},I[$i]={size:16,setter:sr},I[nn]={size:4,setter:ue},I[Wi]={size:8,setter:ue},I[Gi]={size:12,setter:ue},I[Vi]={size:16,setter:ue},I[on]={size:4,setter:ar},I[Ji]={size:8,setter:ar},I[Zi]={size:12,setter:ar},I[eo]={size:16,setter:ar},I[Hi]={size:4,setter:ue},I[ji]={size:8,setter:ue},I[Yi]={size:12,setter:ue},I[Qi]={size:16,setter:ue},I[qi]={size:4,setter:an,count:2},I[Xi]={size:9,setter:an,count:3},I[Ki]={size:16,setter:an,count:4};const tf=/ERROR:\s*\d+:(\d+)/gi;function rf(e,t="",r=0){const n=[...t.matchAll(tf)],i=new Map(n.map((e,r)=>{const i=parseInt(e[1]),o=n[r+1],s=o?o.index:t.length;return[i-1,t.substring(e.index,s)]}));return e.split("\n").map((e,t)=>{const n=i.get(t);return`${t+1+r}: ${e}${n?`\n\n^^^ ${n}`:""}`}).join("\n")}const Jn=/^[ \t]*\n/;function ao(e){let t=0;return Jn.test(e)&&(t=1,e=e.replace(Jn,"")),{lineOffset:t,shaderSource:e}}function nf(e,t){return e.errorCallback(t),e.callback&&setTimeout(()=>{e.callback(`${t}\n${e.errors.join("\n")}`)}),null}function of(e,t,r,n){if(n=n||rn,!e.getShaderParameter(r,nl)){const i=e.getShaderInfoLog(r),{lineOffset:o,shaderSource:s}=ao(e.getShaderSource(r)),a=`${rf(s,i,o)}\nError compiling ${Ti(e,t)}: ${i}`;return n(a),a}return""}function cn(e,t,r){let n,i,o;if("function"==typeof t&&(r=t,t=void 0),"function"==typeof e)r=e,e=void 0;else if(e&&!Array.isArray(e)){const t=e;r=t.errorCallback,e=t.attribLocations,n=t.transformFeedbackVaryings,i=t.transformFeedbackMode,o=t.callback}const s=r||rn,a=[],c={errorCallback(e,...t){a.push(e),s(e,...t)},transformFeedbackVaryings:n,transformFeedbackMode:i,callback:o,errors:a};{let r={};Array.isArray(e)?e.forEach(function(e,n){r[e]=t?t[n]:n}):r=e||{},c.attribLocations=r}return c}const sf=["VERTEX_SHADER","FRAGMENT_SHADER"];function af(e,t){return t.indexOf("frag")>=0?ol:t.indexOf("vert")>=0?sl:void 0}function cf(e,t,r){const n=e.getAttachedShaders(t);for(const t of n)r.has(t)&&e.deleteShader(t);e.deleteProgram(t)}const uf=(e=0)=>new Promise(t=>setTimeout(t,e));function lf(e,t,r){const n=e.createProgram(),{attribLocations:i,transformFeedbackVaryings:o,transformFeedbackMode:s}=cn(r);for(let r=0;r<t.length;++r){let i=t[r];if("string"==typeof i){const t=Ui(i),o=t?t.text:i;let s=e[sf[r]];t&&t.type&&(s=af(e,t.type)||s),i=e.createShader(s),e.shaderSource(i,ao(o).shaderSource),e.compileShader(i),e.attachShader(n,i)}}Object.entries(i).forEach(([t,r])=>e.bindAttribLocation(n,r,t));{let t=o;t&&(t.attribs&&(t=t.attribs),Array.isArray(t)||(t=Object.keys(t)),e.transformFeedbackVaryings(n,t,s||al))}return e.linkProgram(n),n}function ff(e,t,r,n,i){const o=cn(r,n,i),s=new Set(t),a=lf(e,t,o);function c(e,t){const r=hf(e,t,o.errorCallback);return r&&cf(e,t,s),r}if(!o.callback)return c(e,a)?void 0:a;df(e,a).then(()=>{const t=c(e,a);o.callback(t,t?void 0:a)})}async function df(e,t){const r=e.getExtension("KHR_parallel_shader_compile"),n=r?(e,t)=>e.getProgramParameter(t,r.COMPLETION_STATUS_KHR):()=>!0;let i=0;do{await uf(i),i=1e3/60}while(!n(e,t))}function hf(e,t,r){if(r=r||rn,!e.getProgramParameter(t,il)){const n=e.getProgramInfoLog(t);r(`Error in program linking: ${n}`);return`${n}\n${e.getAttachedShaders(t).map(t=>of(e,e.getShaderParameter(t,e.SHADER_TYPE),t,r)).filter(e=>e).join("\n")}`}}function mf(e,t,r,n,i){return ff(e,t,r,n,i)}function co(e){const t=e.name;return t.startsWith("gl_")||t.startsWith("webgl_")}const pf=/(\.|\[|]|\w+)/g,gf=e=>e>="0"&&e<="9";function yf(e,t,r,n){const i=e.split(pf).filter(e=>""!==e);let o=0,s="";for(;;){const e=i[o++];s+=e;const a=gf(e[0]),c=a?parseInt(e):e;if(a&&(s+=i[o++]),o===i.length){r[c]=t;break}{const e=i[o++],t="["===e,a=r[c]||(t?[]:{});r[c]=a,r=a,n[s]=n[s]||function(e){return function(t){uo(e,t)}}(a),s+=e}}}function bf(e,t){let r=0;function n(t,n,i){const o=n.name.endsWith("[0]"),s=n.type,a=w[s];if(!a)throw new Error(`unknown type: 0x${s.toString(16)}`);let c;if(a.bindPoint){const t=r;r+=n.size,c=o?a.arraySetter(e,s,t,i,n.size):a.setter(e,s,t,i,n.size)}else c=a.arraySetter&&o?a.arraySetter(e,i):a.setter(e,i);return c.location=i,c}const i={},o={},s=e.getProgramParameter(t,Li);for(let r=0;r<s;++r){const s=e.getActiveUniform(t,r);if(co(s))continue;let a=s.name;a.endsWith("[0]")&&(a=a.substr(0,a.length-3));const c=e.getUniformLocation(t,s.name);if(c){const e=n(0,s,c);i[a]=e,yf(a,e,o,i)}}return i}function wf(e,t){const r={},n=e.getProgramParameter(t,ul);for(let i=0;i<n;++i){const n=e.getTransformFeedbackVarying(t,i);r[n.name]={index:i,type:n.type,size:n.size}}return r}function xf(e,t){const r=e.getProgramParameter(t,Li),n=[],i=[];for(let o=0;o<r;++o){i.push(o),n.push({});const r=e.getActiveUniform(t,o);n[o].name=r.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(r){const o=r[0],s=r[1];e.getActiveUniforms(t,i,e[o]).forEach(function(e,t){n[t][s]=e})});const o={},s=e.getProgramParameter(t,ll);for(let r=0;r<s;++r){const n=e.getActiveUniformBlockName(t,r),i={index:e.getUniformBlockIndex(t,n),usedByVertexShader:e.getActiveUniformBlockParameter(t,r,fl),usedByFragmentShader:e.getActiveUniformBlockParameter(t,r,dl),size:e.getActiveUniformBlockParameter(t,r,hl),uniformIndices:e.getActiveUniformBlockParameter(t,r,ml)};i.used=i.usedByVertexShader||i.usedByFragmentShader,o[n]=i}return{blockSpecs:o,uniformData:n}}function uo(e,t){for(const r in t){const n=e[r];"function"==typeof n?n(t[r]):uo(e[r],t[r])}}function lo(e,...t){const r=e.uniformSetters||e,n=t.length;for(let e=0;e<n;++e){const n=t[e];if(Array.isArray(n)){const e=n.length;for(let t=0;t<e;++t)lo(r,n[t])}else for(const e in n){const t=r[e];t&&t(n[e])}}}function vf(e,t){const r={},n=e.getProgramParameter(t,cl);for(let i=0;i<n;++i){const n=e.getActiveAttrib(t,i);if(co(n))continue;const o=e.getAttribLocation(t,n.name),s=I[n.type],a=s.setter(e,o,s);a.location=o,r[n.name]=a}return r}function _f(e,t){for(const r in t){const n=e[r];n&&n(t[r])}}function Ef(e,t,r){r.vertexArrayObject?e.bindVertexArray(r.vertexArrayObject):(_f(t.attribSetters||t,r.attribs),r.indices&&e.bindBuffer(rl,r.indices))}function Zn(e,t){const r={program:t,uniformSetters:bf(e,t),attribSetters:vf(e,t)};return rt(e)&&(r.uniformBlockSpec=xf(e,t),r.transformFeedbackInfo=wf(e,t)),r}const Af=/\s|{|}|;/;function Tf(e,t,r,n,i){const o=cn(r,n,i),s=[];if(t=t.map(function(e){if(!Af.test(e)){const t=Ui(e);if(t)e=t.text;else{const t=`no element with id: ${e}`;o.errorCallback(t),s.push(t)}}return e}),s.length)return nf(o,"");const a=o.callback;a&&(o.callback=(t,r)=>{a(t,t?void 0:Zn(e,r))});const c=mf(e,t,o);return c?Zn(e,c):null}const Sf=4,ei=5123;function If(e,t,r,n,i,o){r=void 0===r?4:r;const s=t.indices,a=t.elementType,c=void 0===n?t.numElements:n;i=void 0===i?0:i,a||s?void 0!==o?e.drawElementsInstanced(r,c,void 0===a?ei:t.elementType,i,o):e.drawElements(r,c,void 0===a?ei:t.elementType,i):void 0!==o?e.drawArraysInstanced(r,i,c,o):e.drawArrays(r,i,c)}const fo=36160,At=36161,Rf=3553,kf=5121,Pf=6402,Ff=6408,Cf=33190,Of=36012,Mf=35056,Bf=36013,Df=32854,Uf=32855,Lf=36194,ho=33189,mo=6401,po=36168,un=34041,Fr=36064,cr=36096,go=36128,ln=33306,Cr=33071,Or=9729,zf=[{format:Ff,type:kf,min:Or,wrap:Cr},{format:un}],V={};function Nf(e,t){return V[e]||V[t]}V[un]=ln,V[mo]=go,V[po]=go,V[Pf]=cr,V[ho]=cr,V[Cf]=cr,V[Of]=cr,V[Mf]=ln,V[Bf]=ln;const le={};function $f(e){return le[e]}le[Df]=!0,le[Uf]=!0,le[Lf]=!0,le[un]=!0,le[ho]=!0,le[mo]=!0,le[po]=!0;const Wf=32;function Gf(e){return e>=Fr&&e<36096}function ti(e,t,r,n){const i=fo,o=e.createFramebuffer();e.bindFramebuffer(i,o),r=r||e.drawingBufferWidth,n=n||e.drawingBufferHeight;const s=[],a={framebuffer:o,attachments:[],width:r,height:n};return(t=t||zf).forEach(function(t,o){let c=t.attachment;const u=t.samples,l=t.format;let f=t.attachmentPoint||Nf(l,t.internalFormat);if(f||(f=Fr+o),Gf(f)&&s.push(f),!c)if(void 0!==u||$f(l))c=e.createRenderbuffer(),e.bindRenderbuffer(At,c),u>1?e.renderbufferStorageMultisample(At,u,l,r,n):e.renderbufferStorage(At,l,r,n);else{const i=Object.assign({},t);i.width=r,i.height=n,void 0===i.auto&&(i.auto=!1,i.min=i.min||i.minMag||Or,i.mag=i.mag||i.minMag||Or,i.wrapS=i.wrapS||i.wrap||Cr,i.wrapT=i.wrapT||i.wrap||Cr),c=Di(e,i)}if(Ka(e,c))e.framebufferRenderbuffer(i,f,At,c);else{if(!Xr(e,c))throw new Error("unknown attachment type");void 0!==t.layer?e.framebufferTextureLayer(i,f,c,t.level||0,t.layer):e.framebufferTexture2D(i,f,t.target||Rf,c,t.level||0)}a.attachments.push(c)}),e.drawBuffers&&e.drawBuffers(s),a}function Vf(e,t,r){r=r||fo,t?(e.bindFramebuffer(r,t.framebuffer),e.viewport(0,0,t.width,t.height)):(e.bindFramebuffer(r,null),e.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight))}function B(e,t){return()=>t instanceof WebGLTexture?t:Di(e,{src:t,wrap:e.CLAMP_TO_EDGE})}const Ue=2;class ot{constructor(e){this.id="_";const{context:t,width:r,height:n}=e;this.context=t,this.options=e;const i=this.buildDefines();this.programInfo=Tf(this.context,[i+this.getVertexShader(),i+this.getFragmentShader()]),this.bufferInfo=vc(this.context,this.getBuffers()),this.fbi=ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],r,n),this.output=this.fbi.attachments[0]}resizeOutput(e,t){this.fbi=ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],e,t),this.options.width=e,this.options.height=t,this.output=this.fbi.attachments[0]}getDefines(){return{}}getBuffers(){return{position:{numComponents:2,data:[-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]},texture_coord:{numComponents:2,data:[0,0,0,1,1,0,1,1,0,1,1,0]}}}buildDefines(){let e="";const t=this.getDefines();for(let r in t)e+=`#define ${r} ${t[r].toFixed(1)}\n`;return e}run(e){this.profiler?.pushContext(`[${this.id}] PROG : ${this.constructor.name}`),this.profiler?.pushContext(`[${this.id}] UNIFORMS`);for(const t in e)"function"==typeof e[t]&&(this.profiler?.pushContext(`[${this.id}] UNI : ${t}`),e[t]=e[t](),this.profiler?.popContext(`[${this.id}] UNI : ${t}`));this.profiler?.popContext(`[${this.id}] UNIFORMS`);const t=Date.now();let r=0;this.lastRun&&(r=(t-this.lastRun)/1e3),this.lastRun=t,this.context.viewport(0,0,this.context.canvas.width,this.context.canvas.height),this.context.useProgram(this.programInfo.program),Ef(this.context,this.programInfo,this.bufferInfo),lo(this.programInfo,{delta:r,canvas:[this.context.canvas.width,this.context.canvas.height],...e}),Vf(this.context,this.options.disableFramebuffer?null:this.fbi),If(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(e){this.profiler=e}}const Hf="precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform sampler2D background;\nuniform sampler2D foreground;\nuniform sampler2D threshold;\n\nvoid main() {\n vec4 backgroundColor = texture2D(background, _texture_coord);\n vec4 foregroundColor = texture2D(foreground, _texture_coord);\n vec4 tresholdColor = texture2D(threshold, _texture_coord);\n gl_FragColor = foregroundColor * tresholdColor.a +\n backgroundColor * (1. - tresholdColor.a);\n}\n",jf="varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n _texture_coord.y = 1. - texture_coord.y;\n}\n";class fn extends ot{getFragmentShader(){return Hf}getVertexShader(){return jf}}class dn{constructor(){this.steps=[]}addStep(e){this.steps.push(e)}async run(){for(const e of this.steps)e.program.run(e.getUniforms())}resizeOutput(e,t){this.profiler?.pushContext(`PIP [${this.constructor.name}]`);for(const r of this.steps)r.preventResize||r.program.resizeOutput(e,t);this.profiler?.popContext(`PIP [${this.constructor.name}]`)}setProfiler(e){this.profiler=e;for(const t of this.steps)t.program.setProfiler(e)}setId(e){for(const t of this.steps)t.program.id=e}}class hn extends dn{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class yo extends hn{constructor(e){super(),this.context=e,this.preciseMaskEnabled=!0;const t={context:e,height:e.canvas.height,width:e.canvas.width},r=new fn({...t,disableFramebuffer:!0});this.addStep({program:r,getUniforms:()=>({background:B(e,this.inputBackgroundImage),foreground:B(e,this.inputImage),threshold:B(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}const Yf="precision mediump float;\n\nvarying vec2 _texture_coord;\nuniform sampler2D texture;\n\nvoid main() { gl_FragColor = texture2D(texture, _texture_coord); }\n",Qf="varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\nuniform bool invert_y;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n if (invert_y) {\n _texture_coord.y = 1. - texture_coord.y;\n }\n}\n";class qf extends ot{getFragmentShader(){return Yf}getVertexShader(){return Qf}}class Xf extends dn{constructor(e,t,r){super(),this.context=e;const n={context:e,height:r,width:t};this.addStep({program:new qf({...n,disableFramebuffer:!0}),getUniforms:()=>({texture:B(e,this.inputImage),invert_y:!0})})}setData(e){this.inputImage=e}}async function bo(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}const Kf="precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n",Jf="varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n";var mn=(e=>(e[e.LINEAR=0]="LINEAR",e[e.GAUSSIAN=1]="GAUSSIAN",e))(mn||{});class wo extends ot{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return Kf+this.createLoopFunction()}getVertexShader(){return Jf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = 1.;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}const Zf="#version 300 es\n// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts\n\nprecision highp float;\nuniform sampler2D input_frame;\nuniform sampler2D segmentation_mask;\nuniform sampler2D threshold;\nuniform vec2 texel_size;\nuniform float step;\nuniform float radius;\nuniform float offset;\nuniform float sigma_texel;\nuniform float sigma_color;\n\nin vec2 _texture_coord;\nout vec4 outColor;\n\nfloat gaussian(float x, float sigma) {\n float coeff = -0.5 / (sigma * sigma * 4.0 + 1.0e-6);\n return exp((x * x) * coeff);\n}\n\nvoid main() {\n vec2 centerCoord = _texture_coord;\n vec3 centerColor = texture(input_frame, centerCoord).rgb;\n float newVal = 0.0;\n float spaceWeight = 0.0;\n float colorWeight = 0.0;\n float totalWeight = 0.0;\n // Subsample kernel space.\n for (float i = -radius + offset; i <= radius; i += step) {\n for (float j = -radius + offset; j <= radius; j += step) {\n vec2 shift = vec2(j, i) * texel_size;\n vec2 coord = vec2(centerCoord + shift);\n vec3 frameColor = texture(input_frame, coord).rgb;\n float threshold = texture(threshold, coord).a;\n float outVal = texture(segmentation_mask, coord).a;\n\n spaceWeight = gaussian(distance(centerCoord, coord), sigma_texel);\n colorWeight = gaussian(distance(centerColor, frameColor), sigma_color);\n totalWeight += spaceWeight * colorWeight;\n newVal += spaceWeight * colorWeight * outVal * threshold;\n }\n }\n newVal /= totalWeight;\n outColor = vec4(vec3(0.), newVal);\n}",ed="#version 300 es\nin vec2 position;\nin vec2 texture_coord;\nout vec2 _texture_coord;\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n _texture_coord = texture_coord;\n}";class td extends ot{getFragmentShader(){return Zf}getVertexShader(){return ed}}class rd extends dn{constructor(e,t,r){super(),this.context=e;const n={context:e,height:r,width:t},i=new wo({...n,radius:1,type:mn.GAUSSIAN});this.jointBilateral=new td(n),this.addStep({program:i,getUniforms:()=>({inputs:B(e,this.inputMask)})}),this.addStep({program:this.jointBilateral,getUniforms:()=>{const t=this.inputImage?.width??1,r=this.inputImage?.height??1;this.inputMask,this.inputMask;const n=Math.max(1,.66*Math.sqrt(3)),i=1/t,o=1/r;return{input_frame:B(e,this.inputImage),segmentation_mask:B(e,this.inputMask),texel_size:[i,o],step:n,radius:3,offset:n>1?.5*n:0,sigma_texel:3*Math.max(i,o),sigma_color:3}}}),this.output=this.jointBilateral.output}setData(e,t){this.previousInputImage=this.inputImage?this.inputImage:e,this.previousInputMask=this.inputMask?this.inputMask:t,this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t),this.output=this.jointBilateral.output}}var xo=(e=>(e.PUSH="PUSH",e.POP="POP",e))(xo||{});class nd{constructor(e){this.queries=[],this.context=e,this.extension=e.getExtension("EXT_disjoint_timer_query_webgl2")}start(){}stop(){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT)}pushContext(e){this.createQuery("PUSH",e)}popContext(e){this.createQuery("POP",e)}createQuery(e,t){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT),this.activeQuery=this.context.createQuery(),this.context.beginQuery(this.extension.TIME_ELAPSED_EXT,this.activeQuery),this.queries.push({name:t,action:e,query:this.activeQuery})}async getResolvedQueries(){const e=(await Promise.all([...this.queries].map(e=>this.resolveQuery(e)))).filter(e=>e);for(let t=1;t<e.length;++t)e[t].timestamp+=e[t-1].duration+e[t-1].timestamp;return e}async resolveQuery(e){if(await this.awaitQueryAvailable(e)){if(!this.context.getParameter(this.extension.GPU_DISJOINT_EXT))return{...e,duration:this.context.getQueryParameter(e.query,this.context.QUERY_RESULT),timestamp:0};console.log("Disjointed query",e)}else console.log("Unawaitable query",e)}async awaitQueryAvailable(e){for(let t=0;t<10;++t){if(this.context.getQueryParameter(e.query,this.context.QUERY_RESULT_AVAILABLE))return e;await bo(200)}}}class ur{constructor(){this.previousImageWidth=0,this.previousImageHeight=0,this.previousMaskWidth=2,this.previousMaskHeight=2,this.postProcessingEnabled=!0;const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl2 context";this.canvas=e,this.context=t,this.improveMask=new rd(this.context,2,2)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(e){const t=new nd(this.context);return this.profiler=t,t.start(),await bo(e),this.profiler=void 0,t.stop(),t.getResolvedQueries()}async render(e,t){if(!this.pipeline)throw"missing pipeline";(this.previousImageHeight!==e.height||this.previousImageWidth!==e.width)&&this.resizeOutput(e.width,e.height),(this.previousMaskHeight!==t.height||this.previousMaskWidth!==t.width)&&(this.improveMask.resizeOutput(t.width,t.height),this.previousMaskWidth=t.width,this.previousMaskHeight=t.height);const r="renderer";this.profiler?.pushContext(r),this.improveMask.setProfiler(this.profiler),this.pipeline.setProfiler(this.profiler);const n=await createImageBitmap(t);let i=n;return this.postProcessingEnabled&&(this.improveMask.setData(e,n),this.improveMask.run(),i=this.improveMask.output),this.pipeline.setData(e,i),await this.pipeline.run(),this.profiler?.popContext(r),this.canvas}resizeOutput(e,t){this.canvas.width=e,this.canvas.height=t,this.pipeline?.resizeOutput(e,t),this.previousImageWidth=e,this.previousImageHeight=t}destroy(){const e=this.context?.getExtension("WEBGL_lose_context");e&&e.loseContext()}}class vo extends ur{constructor(){super(),this.pipeline=new yo(this.context);const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl context";this.backgroundImageResizerCanvas=e,this.backgroundImageResizerContext=t,this.backgroundImageResizer=new Xf(this.backgroundImageResizerContext,0,0)}setBackgroundImage(e){this.backgroundImage=e,this.updateBackgroundImage()}updateBackgroundImage(){const{width:e,height:t}=this.canvas;this.backgroundImageResizer.resizeOutput(e,t),this.backgroundImageResizer.setData(this.backgroundImage),this.backgroundImageResizer.run(),this.pipeline.inputBackgroundImage=this.backgroundImageResizerCanvas}resizeOutput(e,t){super.resizeOutput(e,t),this.backgroundImageResizerCanvas.width=e,this.backgroundImageResizerCanvas.height=t,this.backgroundImageResizer.resizeOutput(e,t),this.updateBackgroundImage()}destroy(){const e=this.backgroundImageResizerContext?.getExtension("WEBGL_lose_context");e&&e.loseContext(),super.destroy()}}class id extends vo{setBackgroundVideo(e){this.frameReader=e}async render(e,t){return await this.readNextVideoFrame(),super.render(e,t)}async readNextVideoFrame(){const e=await(this.frameReader?.read());if(e?.value){const t=await createImageBitmap(e.value);this.setBackgroundImage(t),e.value.close()}}}class ri{blurBackground(e){return new La(e)}blurSilhouette(e){return new za(e)}imageBackground(){return new Na}videoBackground(){return new id}}const od="precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\nuniform sampler2D mask;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n",sd="varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n";class ad extends ot{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return od+this.createLoopFunction()}getVertexShader(){return sd}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n float maxLength = length(normalizedRadius);\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = (1.- texture2D(mask, _texture_coord + diff).a) * (maxLength - length(diff)) / maxLength;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}const cd=10,ud=2,ld=8;class fd extends hn{constructor(e,t){super(),this.context=e,this.radius=t;const r={context:e,height:e.canvas.height,width:e.canvas.width};this.blur=new ad({...r,radius:t,...this.getBlurTextureSize(e.canvas.width,e.canvas.height)});const n=new fn({...r,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:B(e,this.inputImage),mask:B(e,this.inputMask)})}),this.addStep({program:n,getUniforms:()=>({background:B(e,this.blur.output),foreground:B(e,this.inputImage),threshold:B(e,this.inputMask)})})}getBlurTextureSize(e,t){const r=this.radius>10?8:2;return{width:Math.max(2,e/r),height:Math.max(2,t/r)}}setData(e,t){this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t);const r=this.getBlurTextureSize(e,t);this.blur.resizeOutput(r.width,r.height)}}class dd extends ur{constructor(e){super(),this.pipeline=new fd(this.context,e),this.disablePostProcessing()}}class hd extends hn{constructor(e,t){super(),this.context=e;const r={context:e,height:e.canvas.height,width:e.canvas.width},n=new wo({...r,radius:t,type:mn.GAUSSIAN}),i=new fn({...r,disableFramebuffer:!0});this.addStep({program:n,getUniforms:()=>({texture:B(e,this.inputImage)})}),this.addStep({program:i,getUniforms:()=>({background:B(e,this.inputImage),foreground:B(e,n.output),threshold:B(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}class md extends ur{constructor(e){super(),this.pipeline=new hd(this.context,e),this.disablePostProcessing()}}class pd extends yo{constructor(){super(...arguments),this.preciseMaskEnabled=!0}set reader(e){this.frameReader=e}async run(){this.frameReader&&(await this.readNextVideoFrame(),await super.run())}async readNextVideoFrame(){const e=await(this.frameReader?.read());e?.value&&(this.inputBackgroundImage=await createImageBitmap(e.value),e.value.close())}}class gd extends ur{constructor(){super(),this.pipeline=new pd(this.context)}setBackgroundVideo(e){this.pipeline.reader=e}}class ni{blurBackground(e){return new dd(e)}blurSilhouette(e){return new md(e)}imageBackground(){return new vo}videoBackground(){return new gd}}class yd{constructor(e){switch(e){case Mt.CANVAS:this.factory=new ri;break;case Mt.WEBGL:this.factory=new ni;break;default:const e=li();this.factory=e.supported?new ni:new ri}}blurBackground(e){return this.getFactory().blurBackground(e)}blurSilhouette(e){return this.getFactory().blurSilhouette(e)}imageBackground(){return this.getFactory().imageBackground()}videoBackground(){return this.getFactory().videoBackground()}getFactory(){if(!this.factory)throw"Factory is not initialized";return this.factory}}class bd{setBackgroundOptions(e){this.renderer&&this.renderer.destroy();const t=new yd(e.renderingOptions?.type);switch(e.transformerType){case"BackgroundBlur":this.renderer=t.blurBackground(this.getBlurSize(e.radius));break;case"SilhouetteBlur":this.renderer=t.blurSilhouette(this.getBlurSize(e.radius));break;case"VideoBackground":const r=t.videoBackground();this.backgroundVideo&&r.setBackgroundVideo(this.backgroundVideo),this.renderer=r;break;case"VirtualBackground":const n=t.imageBackground();this.backgroundImage&&n.setBackgroundImage(this.backgroundImage),this.renderer=n;break;default:throw`Unknown rendering type [${e.transformerType}]`}e.renderingOptions?.type===Mt.WEBGL&&(e.renderingOptions.selfieSegmentationType===Ar.PRECISE?this.renderer.enablePostProcessing():e.renderingOptions.selfieSegmentationType===Ar.FAST&&this.renderer.disablePostProcessing())}setVideoBGReadable(e){this.backgroundVideo=e.getReader();const t=this.renderer;t?.setBackgroundVideo&&t.setBackgroundVideo(this.backgroundVideo)}async setVirtualBGImage(e){const t=this.renderer;t?.setBackgroundImage&&t.setBackgroundImage(e),this.backgroundImage=e}async process(e,t){if(this.renderer)return this.renderer.render(e,t)}async resizeForeground(e,t){}getBlurSize(e=It.Low){switch(e){case It.Low:return 5;case It.High:return 12}return e}async profile(e){return this.renderer?.profileWebgl(e)??[]}}var wd=function(){var e=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(t){var r,n,i=typeof(t=t||{})<"u"?t:{};i.ready=new Promise(function(e,t){r=e,n=t});var o,s={};for(o in i)i.hasOwnProperty(o)&&(s[o]=i[o]);var a="./this.program",c=function(e,t){throw t},u="";typeof document<"u"&&document.currentScript&&(u=document.currentScript.src),e&&(u=e),u=0!==u.indexOf("blob:")?u.substr(0,u.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var l,f=i.print||console.log.bind(console),h=i.printErr||console.warn.bind(console);for(o in s)s.hasOwnProperty(o)&&(i[o]=s[o]);s=null,i.arguments&&i.arguments,i.thisProgram&&(a=i.thisProgram),i.quit&&(c=i.quit),i.wasmBinary&&(l=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&M("no native wasm support detected");var d,m,p,g,y,b=!1,w=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function v(e,t,r){for(var n=t+r,i=t;e[i]&&!(i>=n);)++i;if(i-t>16&&e.subarray&&w)return w.decode(e.subarray(t,i));for(var o="";t<i;){var s=e[t++];if(128&s){var a=63&e[t++];if(192!=(224&s)){var c=63&e[t++];if((s=224==(240&s)?(15&s)<<12|a<<6|c:(7&s)<<18|a<<12|c<<6|63&e[t++])<65536)o+=String.fromCharCode(s);else{var u=s-65536;o+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else o+=String.fromCharCode((31&s)<<6|a)}else o+=String.fromCharCode(s)}return o}function x(e,t){return e?v(g,e,t):""}function _(e,t){return e%t>0&&(e+=t-e%t),e}function k(e){m=e,i.HEAP8=p=new Int8Array(e),i.HEAP16=new Int16Array(e),i.HEAP32=y=new Int32Array(e),i.HEAPU8=g=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAPU32=new Uint32Array(e),i.HEAPF32=new Float32Array(e),i.HEAPF64=new Float64Array(e)}i.INITIAL_MEMORY;var A,E=[],I=[],S=[];function T(e){E.unshift(e)}function P(e){S.unshift(e)}var F=0,R=null;function M(e){i.onAbort&&i.onAbort(e),h(e="Aborted("+e+")"),b=!0,e+=". Build with -s ASSERTIONS=1 for more info.";var t=new WebAssembly.RuntimeError(e);throw n(t),t}i.preloadedImages={},i.preloadedAudios={};var O,C,z;function B(e){return e.startsWith("data:application/octet-stream;base64,")}function D(e){try{if(e==O&&l)return new Uint8Array(l);throw"both async and sync fetching of the wasm failed"}catch(e){M(e)}}function U(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var r=t.func;"number"==typeof r?void 0===t.arg?A.get(r)():A.get(r)(t.arg):r(void 0===t.arg?null:t.arg)}else t(i)}}B(O="tflite-simd.wasm")||(C=O,O=i.locateFile?i.locateFile(C,u):u+C),z=function(){return performance.now()};function L(e){try{return d.grow(e-m.byteLength+65535>>>16),k(d.buffer),1}catch{}}var N={};function W(){if(!W.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:a||"./this.program"};for(var t in N)void 0===N[t]?delete e[t]:e[t]=N[t];var r=[];for(var t in e)r.push(t+"="+e[t]);W.strings=r}return W.strings}var j={mappings:{},buffers:[null,[],[]],printChar:function(e,t){var r=j.buffers[e];0===t||10===t?((1===e?f:h)(v(r,0)),r.length=0):r.push(t)},varargs:void 0,get:function(){return j.varargs+=4,y[j.varargs-4>>2]},getStr:function(e){return x(e)},get64:function(e,t){return e}};var V={a:function(e,t,r,n){M("Assertion failed: "+x(e)+", at: "+[t?x(t):"unknown filename",r,n?x(n):"unknown function"])},e:function(e,t){M("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},d:function(e,t){M("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")},b:function(){M("")},n:function(e,t){var r;if(0===e)r=Date.now();else{if(1!==e&&4!==e)return function(e){y[G()>>2]=e}(28),-1;r=z()}return y[t>>2]=r/1e3|0,y[t+4>>2]=r%1e3*1e3*1e3|0,0},h:function(){return 2147483648},l:function(e,t,r){g.copyWithin(e,t,t+r)},m:function(e){var t=g.length,r=2147483648;if((e>>>=0)>r)return!1;for(var n=1;n<=4;n*=2){var i=t*(1+.2/n);if(i=Math.min(i,e+100663296),L(Math.min(r,_(Math.max(e,i),65536))))return!0}return!1},p:function(e){for(var t=z();z()-t<e;);},f:function(e,t){var r=0;return W().forEach(function(n,i){var o=t+r;y[e+4*i>>2]=o,function(e,t){for(var r=0;r<e.length;++r)p[0|t++]=e.charCodeAt(r);p[0|t]=0}(n,o),r+=n.length+1}),0},g:function(e,t){var r=W();y[e>>2]=r.length;var n=0;return r.forEach(function(e){n+=e.length+1}),y[t>>2]=n,0},j:function(e){!function(e){!function(e){c(e,new H(e))}(e)}(e)},i:function(e){return 0},k:function(e,t,r,n,i){},c:function(e,t,r,n){for(var i=0,o=0;o<r;o++){for(var s=y[t+8*o>>2],a=y[t+(8*o+4)>>2],c=0;c<a;c++)j.printChar(e,g[s+c]);i+=a}return y[n>>2]=i,0},o:function e(t,r){e.randomDevice||(e.randomDevice=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}return function(){M("randomDevice")}}());for(var n=0;n<r;n++)p[t+n|0]=e.randomDevice();return 0}};(function(){var e={a:V};function t(e,t){var r=e.exports;i.asm=r,k((d=i.asm.q).buffer),A=i.asm.E,function(e){I.unshift(e)}(i.asm.r),function(){if(F--,i.monitorRunDependencies&&i.monitorRunDependencies(F),0==F&&R){var e=R;R=null,e()}}()}function r(e){t(e.instance)}function o(t){return(l||"function"!=typeof fetch?Promise.resolve().then(function(){return D(O)}):fetch(O,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+O+"'";return e.arrayBuffer()}).catch(function(){return D(O)})).then(function(t){return WebAssembly.instantiate(t,e)}).then(function(e){return e}).then(t,function(e){h("failed to asynchronously prepare wasm: "+e),M(e)})}if(F++,i.monitorRunDependencies&&i.monitorRunDependencies(F),i.instantiateWasm)try{return i.instantiateWasm(e,t)}catch(e){return h("Module.instantiateWasm callback failed with error: "+e),!1}(l||"function"!=typeof WebAssembly.instantiateStreaming||B(O)||"function"!=typeof fetch?o(r):fetch(O,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,e).then(r,function(e){return h("wasm streaming compile failed: "+e),h("falling back to ArrayBuffer instantiation"),o(r)})})).catch(n)})(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.r).apply(null,arguments)},i._getModelBufferMemoryOffset=function(){return(i._getModelBufferMemoryOffset=i.asm.s).apply(null,arguments)},i._getInputMemoryOffset=function(){return(i._getInputMemoryOffset=i.asm.t).apply(null,arguments)},i._getInputHeight=function(){return(i._getInputHeight=i.asm.u).apply(null,arguments)},i._getInputWidth=function(){return(i._getInputWidth=i.asm.v).apply(null,arguments)},i._getInputChannelCount=function(){return(i._getInputChannelCount=i.asm.w).apply(null,arguments)},i._getOutputMemoryOffset=function(){return(i._getOutputMemoryOffset=i.asm.x).apply(null,arguments)},i._getOutputHeight=function(){return(i._getOutputHeight=i.asm.y).apply(null,arguments)},i._getOutputWidth=function(){return(i._getOutputWidth=i.asm.z).apply(null,arguments)},i._getOutputChannelCount=function(){return(i._getOutputChannelCount=i.asm.A).apply(null,arguments)},i._loadModel=function(){return(i._loadModel=i.asm.B).apply(null,arguments)},i._runInference=function(){return(i._runInference=i.asm.C).apply(null,arguments)},i._isGPUEnabled=function(){return(i._isGPUEnabled=i.asm.D).apply(null,arguments)};var $,G=i.___errno_location=function(){return(G=i.___errno_location=i.asm.F).apply(null,arguments)};function H(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function q(e){function t(){$||($=!0,i.calledRun=!0,!b&&(U(I),r(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)P(i.postRun.shift());U(S)}()))}F>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)T(i.preRun.shift());U(E)}(),F>0)||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),t()},1)):t())}if(R=function e(){$||q(),$||(R=e)},i.run=q,i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return q(),t.ready}}();class xd{constructor(){this.isSIMDSupported=!1,this.isThreadsSupported=!1,this.inputWidth=0,this.inputHeight=0,this.inputChannelCount=0,this.inputMemoryOffset=0,this.outputWidth=0,this.outputHeight=0,this.outputChannelCount=0,this.outputMemoryOffset=0}}const vd="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",_d="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function Ed(e=vd,t=_d){let r=new xd;return new Promise(function(n,i){(async function(){return wd({locateFile:function(t){return e+t}})})().then(e=>{if(null===e)throw console.error("loadTFLite null"),"loadTFLite null";(async function(e){return new Promise(async(n,i)=>{const o=e;if(typeof o>"u")return i("TFLite backend unavailable: wasmSimd");let s=t;console.log("TFLite modelUrl: "+s);try{const e=await(await fetch(s)).arrayBuffer();console.log("Model buffer size:",e.byteLength);const t=o._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",t),console.log("Loading model buffer..."),o.HEAPU8.set(new Uint8Array(e),t);const n=o._loadModel(e.byteLength);if(console.log("Load model result:",n),0!==n)return void i("Cannot load model");r.inputWidth=o._getInputWidth(),r.inputHeight=o._getInputHeight(),r.inputChannelCount=o._getInputChannelCount(),r.inputMemoryOffset=o._getInputMemoryOffset(),console.log("Input memory offset:",r.inputMemoryOffset),console.log("Input height:",r.inputHeight),console.log("Input width:",r.inputWidth),console.log("Input channels:",r.inputChannelCount),r.outputMemoryOffset=o._getOutputMemoryOffset(),r.outputWidth=o._getOutputWidth(),r.outputHeight=o._getOutputHeight(),r.outputChannelCount=o._getOutputChannelCount(),console.log("Output memory offset:",r.outputMemoryOffset),console.log("Output height:",r.outputHeight),console.log("Output width:",r.outputWidth),console.log("Output channels:",r.outputChannelCount),r.selectedTFLite=o}catch(e){return void i(e)}n()})})(e).then(e=>{n(r)}).catch(e=>{console.error("loadTFLiteModel error"),i("loadTFLiteModel error")})}).catch(e=>{console.error("loadTFLite error:",e),i("loadTFLite error:"+e)})})}const Ad=.1,Td=.7,Sd="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class Id{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=0,this.height=0,this.gpuDelegate=!0}async createImageSegmenter(){this.ImageSegmenter&&this.wasmFileset?this.imageSegmenter=await this.ImageSegmenter.createFromOptions(this.wasmFileset,{baseOptions:{modelAssetPath:this.modelAssetUriPath,delegate:this.gpuDelegate?"GPU":"CPU"},runningMode:"VIDEO",outputCategoryMask:!0,outputConfidenceMasks:!0}):console.warn("Mediapipe objects not loaded")}async loadMediapipeAssets(e,t){this.modelAssetUriPath=e||Sd;const r=t?`${t}/task-vision.js`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/+esm",n=t?`${t}/wasm`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/wasm",{FilesetResolver:i,ImageSegmenter:o}=await import(r);this.ImageSegmenter=o,this.wasmFileset=await i.forVisionTasks(n)}async init(e,t,r){!1===r&&(this.gpuDelegate=!1),await this.loadMediapipeAssets(e,t),globalThis.document={},await this.createImageSegmenter()}async process(e){if(!this.imageSegmenter)return void console.warn("ImageSegmenter instance not available");(this.width!==e.width||this.height!==e.height)&&(this.canvas.width=this.width=e.width,this.canvas.height=this.height=e.height,this.mask&&(this.mask=new ImageData(this.width,this.height))),this.mask||(this.mask=new ImageData(this.width,this.height)),this.context.drawImage(e,0,0,e.width,e.height);const t=Date.now();let r;try{this.imageSegmenter?.segmentForVideo(this.context.getImageData(0,0,e.width,e.height),t,e=>{r=e.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{return void await this.createImageSegmenter()}if(!r)return;if(!this.previousConfidenceMask)return void(this.previousConfidenceMask=r.slice());const n=r.map((e,t)=>{const r=this.previousConfidenceMask?.[t];return void 0!==r?this.blend(r,e):e}),i=[255,0,0];for(let e=0;e<n?.length;e++){const t=1-n[e];t>Ad?(t<Td?(this.mask.data[4*e]=i[0]*t,this.mask.data[4*e+3]=255*t):(this.mask.data[4*e]=i[0],this.mask.data[4*e+3]=255),this.mask.data[4*e+1]=i[1],this.mask.data[4*e+2]=i[2]):this.mask.data[4*e]=this.mask.data[4*e+1]=this.mask.data[4*e+2]=this.mask.data[4*e+3]=0}return this.previousConfidenceMask=n.slice(),this.mask}isGpuSupported(){return!0}blend(e,t){const r=t-.5,n=r*r;return t+.9*(1-Math.min(1,n*(5.68842+n*(n*(n*(291.309+-624.717*n)-57.8051)-.748699))))*(e-t)}}class Rd{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.pixelCount=0,this.inputOffset=0,this.outputOffset=0}async init(e,t,r){await this.initWasm(t,e),this.infos&&(this.canvas.width=this.infos.inputWidth,this.canvas.height=this.infos.inputHeight,this.pixelCount=this.infos.inputWidth*this.infos.inputHeight,this.mask=new ImageData(this.infos.inputWidth,this.infos.inputHeight),this.inputOffset=this.infos.inputMemoryOffset/4,this.outputOffset=this.infos.outputMemoryOffset/4)}async initWasm(e,t){this.infos=await Ed(e,t)}async process(e){if(!this.mask||!this.infos)return;const t=this.infos.inputWidth,r=this.infos.inputHeight;this.context.drawImage(e,0,0,e.width,e.height,0,0,t,r);const n=this.context.getImageData(0,0,t,r),i=this.infos.selectedTFLite.HEAPF32;for(let e=0;e<this.pixelCount;e++){const t=this.inputOffset+3*e;i[t]=n.data[4*e]/255,i[t+1]=n.data[4*e+1]/255,i[t+2]=n.data[4*e+2]/255}this.infos.selectedTFLite._runInference();for(let e=0;e<this.pixelCount;e++){const t=this.infos.selectedTFLite.HEAPF32[this.outputOffset+e];this.mask.data[4*e]=this.mask.data[4*e+3]=255*t}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class kd{constructor(){this.reporter=new Da,this.isEnabled=!0}async init(e,t){!0===t.segmentationOptions?.lightWeightEngine?this.selfieSegmentation=new Rd:this.selfieSegmentation=new Id,this.selfieSegmentation?.init(t.modelAssetUriPath,t.mediapipeBaseAssetsUri,t.segmentationOptions?.gpuSupport),this.backgroundFilter=new bd,this.report({variation:"Create"})}async transform(e,t){if(!this.isEnabled)return t.enqueue(e);let r;const n=e.timestamp??0,i=await createImageBitmap(e),o=await(this.selfieSegmentation?.process(i));o&&(r=await(this.backgroundFilter?.process(i,o))),r?(e.close(),t.enqueue(new VideoFrame(r,{timestamp:n,alpha:"discard"}))):t.enqueue(e)}async setBackgroundOptions(e){this.backgroundOptions=e,this.backgroundFilter?.setBackgroundOptions(e),this.report({variation:"Update"})}setVideoBGReadable(e){this.backgroundFilter?.setVideoBGReadable(e)}async setVirtualBGImage(e){await(this.backgroundFilter?.setVirtualBGImage(e))}async profile(e){return this.backgroundFilter?.profile(e)??[]}getTransformerType(){return this.backgroundOptions?.transformerType??"Undefined"}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}report(e){this.reporter.send({version:Ua,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...e})}}const pn=class{constructor(){this.backgroundTransformer=new kd,this.mediaProcessor=new ui,this.rate=30,this.eventsQueue=[],this.frameTransformLatencyMs=[]}async init(e,t){this.frameTransformLatencyMs=[],await this.backgroundTransformer.init(e,t),await this.mediaProcessor.setTransformers([this.backgroundTransformer]),this.mediaProcessor.setTrackExpectedRate(this.rate),this.mediaProcessor.onAny((e,t)=>{this.resolveOnMediaProcessor?(this.resolveOnMediaProcessor({name:e,data:t}),this.resolveOnMediaProcessor=void 0):this.eventsQueue.push({name:e,data:t})})}enable(){this.backgroundTransformer.enable()}disable(){this.backgroundTransformer.disable()}async onMediaProcessorEvent(){return await new Promise(e=>{this.eventsQueue.length>0?e(this.eventsQueue.shift()):this.resolveOnMediaProcessor=e})}async setTrackExpectedRate(e){this.rate=e,this.mediaProcessor.setTrackExpectedRate(e)}async transform(e,t){let r=this.mediaProcessor.transform(e,t),n=performance.now();return this.frameTransformLatencyMs.push(performance.now()-n),r}async setBackgroundOptions(e){await(this.backgroundTransformer?.setBackgroundOptions(e))}setVideoBGReadable(e){this.backgroundTransformer.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundTransformer.setVirtualBGImage(e)}async terminate(){await this.mediaProcessor.destroy();const e=this.frameTransformLatencyMs.reduce((e,t)=>e+t,0)/this.frameTransformLatencyMs.length||0;console.log(`Transform latency average is: ${e} ms`)}setVonageMetadata(e){Fs(e)}async profile(e){return JSON.stringify(await this.backgroundTransformer.profile(e))}};ca("ProcessorWorker",pn);let Mr=pn;const _o='(function(){"use strict";function Vt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Vr=Vt("globals",{});var xe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r.EVENT="EVENT",r))(xe||{});function zi(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}function Be(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>zi(s)))}Vt("workerized",{});function Hr(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function qe(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],qe(r[t],e[t])):typeof r[t]=="object"?(e[t]={},qe(r[t],e[t])):e[t]=r[t]}const K=new WeakMap,ce=new WeakMap,j=new WeakMap,Ke=Symbol("anyProducer"),jr=Promise.resolve(),Je=Symbol("listenerAdded"),Ze=Symbol("listenerRemoved");let et=!1,Ht=!1;function _e(r){if(typeof r!="string"&&typeof r!="symbol"&&typeof r!="number")throw new TypeError("`eventName` must be a string, symbol, or number")}function tt(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ee(r,e){const t=ce.get(r);if(t.has(e))return t.get(e)}function De(r,e){const t=typeof e=="string"||typeof e=="symbol"||typeof e=="number"?e:Ke,n=j.get(r);if(n.has(t))return n.get(t)}function Gi(r,e,t){const n=j.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(Ke)){const i=Promise.all([e,t]);for(const s of n.get(Ke))s.enqueue(i)}}function Xr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=De(r,o);a||(a=new Set,j.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=De(r,a);c&&(c.delete(s),c.size===0&&j.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Yr(r){if(r===void 0)return Qr;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!Qr.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const we=r=>r===Je||r===Ze;function rt(r,e,t){if(we(e))try{et=!0,r.emit(e,t)}finally{et=!1}}class ve{static mixin(e,t){return t=Yr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new ve}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){var e,t;if(typeof((e=globalThis.process)==null?void 0:e.env)!="object")return Ht;const{env:n}=(t=globalThis.process)!=null?t:{env:{}};return n.DEBUG==="emittery"||n.DEBUG==="*"||Ht}static set isDebugEnabled(e){Ht=e}constructor(e={}){var t;K.set(this,new Set),ce.set(this,new Map),j.set(this,new Map),j.get(this).set(Ke,new Set),this.debug=(t=e.debug)!=null?t:{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(n,i,s,o)=>{try{o=JSON.stringify(o)}catch{o=`Object with the following keys failed to stringify: ${Object.keys(o).join(",")}`}(typeof s=="symbol"||typeof s=="number")&&(s=s.toString());const a=new Date,c=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()}.${a.getMilliseconds()}`;console.log(`[${c}][emittery:${n}][${i}] Event Name: ${s}\n\tdata: ${o}`)})}logIfDebugEnabled(e,t,n){(ve.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);let i=Ee(this,n);i||(i=new Set,ce.get(this).set(n,i)),i.add(t),this.logIfDebugEnabled("subscribe",n,void 0),we(n)||rt(this,Je,{eventName:n,listener:t})}return this.off.bind(this,e,t)}off(e,t){tt(t),e=Array.isArray(e)?e:[e];for(const n of e){_e(n);const i=Ee(this,n);i&&(i.delete(t),i.size===0&&ce.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),we(n)||rt(this,Ze,{eventName:n,listener:t})}}once(e){let t;const n=new Promise(i=>{t=this.on(e,s=>{t(),i(s)})});return n.off=t,n}events(e){e=Array.isArray(e)?e:[e];for(const t of e)_e(t);return Xr(this,e)}async emit(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Gi(this,e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=we(e)?[]:[...s];await jr,await Promise.all([...o.map(async c=>{if(i.has(c))return c(t)}),...a.map(async c=>{if(s.has(c))return c(e,t)})])}async emitSerial(e,t){var n;if(_e(e),we(e)&&!et)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const i=(n=Ee(this,e))!=null?n:new Set,s=K.get(this),o=[...i],a=[...s];await jr;for(const c of o)i.has(c)&&await c(t);for(const c of a)s.has(c)&&await c(e,t)}onAny(e){return tt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),K.get(this).add(e),rt(this,Je,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return Xr(this)}offAny(e){tt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),rt(this,Ze,{listener:e}),K.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),typeof t=="string"||typeof t=="symbol"||typeof t=="number"){const n=Ee(this,t);n&&n.clear();const i=De(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{K.get(this).clear();for(const[n,i]of ce.get(this).entries())i.clear(),ce.get(this).delete(n);for(const[n,i]of j.get(this).entries()){for(const s of i)s.finish();i.clear(),j.get(this).delete(n)}}}listenerCount(e){var t,n,i,s,o,a;e=Array.isArray(e)?e:[e];let c=0;for(const u of e){if(typeof u=="string"){c+=K.get(this).size+((n=(t=Ee(this,u))==null?void 0:t.size)!=null?n:0)+((s=(i=De(this,u))==null?void 0:i.size)!=null?s:0)+((a=(o=De(this))==null?void 0:o.size)!=null?a:0);continue}typeof u<"u"&&_e(u),c+=K.get(this).size;for(const d of ce.get(this).values())c+=d.size;for(const d of j.get(this).values())c+=d.size}return c}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Yr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const Qr=Object.getOwnPropertyNames(ve.prototype).filter(r=>r!=="constructor");Object.defineProperty(ve,"listenerAdded",{value:Je,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(ve,"listenerRemoved",{value:Ze,writable:!1,enumerable:!0,configurable:!1});function $i(r){return r.onAny&&r.emit}async function Wi(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Be(r,await e.instance[t](...n??[]))}const qr=Vt("registeredWorkers",{});function Vi(r,e){e.workerId=r,Hr()&&(qr[e.workerId]=e)}function Hi(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=qr[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;qe(n,Vr),$i(e.instance)&&e.instance.onAny((s,o)=>{Be({type:xe.EVENT},{name:s,data:o})}),Be(r,typeof e.instance!==void 0)}async function ji(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Be(r,n)}function Xi(r){if(!r.args)throw"Missing globals while syncing";qe(r.args[0],Vr),Be(r,{})}function Yi(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case xe.INIT:Hi(t,r);break;case xe.FORWARD:Wi(t,r);break;case xe.TERMINATE:ji(t,r);break;case xe.GLOBALS_SYNC:Xi(t);break}}}Hr()&&Yi();const J=new WeakMap,ue=new WeakMap,X=new WeakMap,nt=Symbol("anyProducer"),Kr=Promise.resolve(),it=Symbol("listenerAdded"),st=Symbol("listenerRemoved");let ot=!1,jt=!1;const at=r=>typeof r=="string"||typeof r=="symbol"||typeof r=="number";function Te(r){if(!at(r))throw new TypeError("`eventName` must be a string, symbol, or number")}function ct(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Ae(r,e){const t=ue.get(r);if(t.has(e))return t.get(e)}function Me(r,e){const t=at(e)?e:nt,n=X.get(r);if(n.has(t))return n.get(t)}function Qi(r,e,t){const n=X.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(nt)){const i=Promise.all([e,t]);for(const s of n.get(nt))s.enqueue(i)}}function Jr(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const s={enqueue(o){i.push(o),n()},finish(){t=!0,n()}};for(const o of e){let a=Me(r,o);a||(a=new Set,X.get(r).set(o,a)),a.add(s)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(o=>{n=o}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(o){i=void 0;for(const a of e){const c=Me(r,a);c&&(c.delete(s),c.size===0&&X.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await o}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Zr(r){if(r===void 0)return en;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!en.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const Ie=r=>r===it||r===st;function ut(r,e,t){if(Ie(e))try{ot=!0,r.emit(e,t)}finally{ot=!1}}class Y{static mixin(e,t){return t=Zr(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const o of t)if(n.prototype[o]!==void 0)throw new Error(`The property \\`${o}\\` already exists on \\`target\\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new Y}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const s=o=>function(...a){return this[e][o](...a)};for(const o of t)Object.defineProperty(n.prototype,o,{enumerable:!1,value:s(o)});return n}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return jt;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||jt}static set isDebugEnabled(e){jt=e}constructor(e={}){J.set(this,new Set),ue.set(this,new Map),X.set(this,new Map),X.get(this).set(nt,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,s)=>{try{s=JSON.stringify(s)}catch{s=`Object with the following keys failed to stringify: ${Object.keys(s).join(",")}`}(typeof i=="symbol"||typeof i=="number")&&(i=i.toString());const o=new Date,a=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${n}] Event Name: ${i}\n\tdata: ${s}`)})}logIfDebugEnabled(e,t,n){(Y.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t,{signal:n}={}){ct(t),e=Array.isArray(e)?e:[e];for(const s of e){Te(s);let o=Ae(this,s);o||(o=new Set,ue.get(this).set(s,o)),o.add(t),this.logIfDebugEnabled("subscribe",s,void 0),Ie(s)||ut(this,it,{eventName:s,listener:t})}const i=()=>{this.off(e,t),n?.removeEventListener("abort",i)};return n?.addEventListener("abort",i,{once:!0}),n?.aborted&&i(),i}off(e,t){ct(t),e=Array.isArray(e)?e:[e];for(const n of e){Te(n);const i=Ae(this,n);i&&(i.delete(t),i.size===0&&ue.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),Ie(n)||ut(this,st,{eventName:n,listener:t})}}once(e,t){if(t!==void 0&&typeof t!="function")throw new TypeError("predicate must be a function");let n;const i=new Promise(s=>{n=this.on(e,o=>{t&&!t(o)||(n(),s(o))})});return i.off=n,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Te(t);return Jr(this,e)}async emit(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Qi(this,e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=Ie(e)?[]:[...i];await Kr,await Promise.all([...s.map(async a=>{if(n.has(a))return a(t)}),...o.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(Te(e),Ie(e)&&!ot)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const n=Ae(this,e)??new Set,i=J.get(this),s=[...n],o=[...i];await Kr;for(const a of s)n.has(a)&&await a(t);for(const a of o)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){ct(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),J.get(this).add(e),ut(this,it,{listener:e});const n=()=>{this.offAny(e),t?.removeEventListener("abort",n)};return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),n}anyEvent(){return Jr(this)}offAny(e){ct(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),ut(this,st,{listener:e}),J.get(this).delete(e)}clearListeners(e){e=Array.isArray(e)?e:[e];for(const t of e)if(this.logIfDebugEnabled("clear",t,void 0),at(t)){const n=Ae(this,t);n&&n.clear();const i=Me(this,t);if(i){for(const s of i)s.finish();i.clear()}}else{J.get(this).clear();for(const[n,i]of ue.get(this).entries())i.clear(),ue.get(this).delete(n);for(const[n,i]of X.get(this).entries()){for(const s of i)s.finish();i.clear(),X.get(this).delete(n)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const n of e){if(at(n)){t+=J.get(this).size+(Ae(this,n)?.size??0)+(Me(this,n)?.size??0)+(Me(this)?.size??0);continue}n!==void 0&&Te(n),t+=J.get(this).size;for(const i of ue.get(this).values())t+=i.size;for(const i of X.get(this).values())t+=i.size}return t}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Zr(t);for(const n of t){if(e[n]!==void 0)throw new Error(`The property \\`${n}\\` already exists on \\`target\\``);Object.defineProperty(e,n,{enumerable:!1,value:this[n].bind(this)})}}}const en=Object.getOwnPropertyNames(Y.prototype).filter(r=>r!=="constructor");Object.defineProperty(Y,"listenerAdded",{value:it,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Y,"listenerRemoved",{value:st,writable:!1,enumerable:!0,configurable:!1});var qi=Object.defineProperty,Ki=(r,e,t)=>e in r?qi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ji=(r,e,t)=>(Ki(r,e+"",t),t);const Zi="hlg.tokbox.com/prod/logging/vcp_webrtc",es="https://",ts=1e4;let ft;const rs=new Uint8Array(16);function ns(){if(!ft&&(ft=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ft))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ft(rs)}const F=[];for(let r=0;r<256;++r)F.push((r+256).toString(16).slice(1));function is(r,e=0){return(F[r[e+0]]+F[r[e+1]]+F[r[e+2]]+F[r[e+3]]+"-"+F[r[e+4]]+F[r[e+5]]+"-"+F[r[e+6]]+F[r[e+7]]+"-"+F[r[e+8]]+F[r[e+9]]+"-"+F[r[e+10]]+F[r[e+11]]+F[r[e+12]]+F[r[e+13]]+F[r[e+14]]+F[r[e+15]]).toLowerCase()}const ss=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),tn={randomUUID:ss};function os(r,e,t){if(tn.randomUUID&&!r)return tn.randomUUID();r=r||{};const n=r.random||(r.rng||ns)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,is(n)}function Xt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const Z=Xt("globals",{});var fe=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(fe||{});function rn(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let as=0;function cs(r,e,t,n,i){const s=as++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>rn(o))),new Promise(o=>{i?.set(s,o)})}function Oe(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>rn(s)))}const nn=Xt("workerized",{});function sn(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function us(){if(sn())Oe({type:fe.GLOBALS_SYNC},Z);else{const r=[];for(const e in nn){const{worker:t,resolvers:n}=nn[e].workerContext;t&&r.push(cs(t,fe.GLOBALS_SYNC,"",[Z],n))}await Promise.all(r)}}function lt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],lt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},lt(r[t],e[t])):e[t]=r[t]}async function fs(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Oe(r,await e.instance[t](...n??[]))}const ls=Xt("registeredWorkers",{});function ds(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=ls[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;lt(n,Z),Oe(r,typeof e.instance!==void 0)}async function hs(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Oe(r,n)}function ms(r){if(!r.args)throw"Missing globals while syncing";lt(r.args[0],Z),Oe(r,{})}function ps(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case fe.INIT:ds(t,r);break;case fe.FORWARD:fs(t,r);break;case fe.TERMINATE:hs(t,r);break;case fe.GLOBALS_SYNC:ms(t);break}}}sn()&&ps();function gs(r,e){return Z[r]||(Z[r]=e),[()=>Z[r],async t=>{Z[r]=t,await us()}]}function ys(r,e){return gs(r,e)}const[bs,xs]=ys("metadata");function _s(r){xs(r)}function Yt(){return bs()}let Qt=class{constructor(e,t){Ji(this,"uuid"),this.config=e,this.uuid=t??os()}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=Yt())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),ts);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=Yt().proxyUrl)!=null?e:es;return t+=(t.at(-1)==="/"?"":"/")+Zi,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=Yt();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}};const dt="3.0.1-alpha.0",qt=class{};qt.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},qt.errors={transformer_none:"No transformers provided",transformer_start:"Cannot start transformer",transformer_transform:"Cannot transform frame",transformer_flush:"Cannot flush transformer",readable_null:"Readable is null",writable_null:"Writable is null"};let le=qt;function Es(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function ws(r){if(Es(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function Kt(r){return ws(r).message}class vs{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new Qt(e,t)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:e,frameFromSourceCount:t}=this,n=(Date.now()-e)/1e3;return t/n}async onFrameTransformed(e={},t=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:n,frameTransformedCount:i,frameFromSourceCount:s}=this,o=Date.now(),a=(o-n)/1e3,c=i/a,u=s/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=o,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:u,transformedFps:c,framesTransformed:i,...e})):"success"}}var Jt=(r=>(r.pipeline_ended="pipeline_ended",r.pipeline_ended_with_error="pipeline_ended_with_error",r.pipeline_started="pipeline_started",r.pipeline_started_with_error="pipeline_started_with_error",r.pipeline_restarted="pipeline_restarted",r.pipeline_restarted_with_error="pipeline_restarted_with_error",r))(Jt||{});const Ts=500,As=.8;class Is extends Y{constructor(e,t){super(),this.reporter_=new Qt,this.reporterQos_=new vs({loggingIntervalFrameCount:Ts,report:{version:dt}}),this.index_=t,this.transformer_=e,this.shouldStop_=!1,this.isFlashed_=!1,this.mediaTransformerQosReportStartTimestamp_=0,this.videoHeight_=0,this.videoWidth_=0,this.trackExpectedRate_=-1,this.transformerType_="Custom","getTransformerType"in e&&(this.transformerType_=e.getTransformerType()),this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e}async start(e){if(this.controller_=e,this.transformer_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(e)}catch(t){this.report({message:le.errors.transformer_start,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"start"};this.emit("error",n)}}async transform(e,t){if(this.mediaTransformerQosReportStartTimestamp_===0&&(this.mediaTransformerQosReportStartTimestamp_=Date.now()),e instanceof VideoFrame&&(this.videoHeight_=e?.displayHeight??0,this.videoWidth_=e?.displayWidth??0),this.reporterQos_.onFrameFromSource(),this.transformer_)if(this.shouldStop_)console.warn("[Pipeline] flush from transform"),e.close(),this.flush(t),t.terminate();else{try{await this.transformer_.transform?.(e,t),this.reportQos()}catch(n){this.report({message:le.errors.transformer_transform,variation:"Error",error:Kt(n)});const i={eventMetaData:{transformerIndex:this.index_},error:n,function:"transform"};this.emit("error",i)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*As>this.reporterQos_.fps){const n={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",n)}}}async flush(e){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(e)}catch(t){this.report({message:le.errors.transformer_flush,variation:"Error",error:Kt(t)});const n={eventMetaData:{transformerIndex:this.index_},error:t,function:"flush"};this.emit("error",n)}}this.reportQos(!0),this.report({variation:"Delete"})}stop(){console.log("[Pipeline] Stop stream."),this.controller_&&(this.flush(this.controller_),this.controller_.terminate()),this.shouldStop_=!0}report(e){this.reporter_.send({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:dt,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class Ss extends Y{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let n=new Is(e[t],t);n.on("error",i=>{this.emit("error",i)}),n.on("warn",i=>{this.emit("warn",i)}),this.transformers_.push(n)}}setTrackExpectedRate(e){this.trackExpectedRate_=e;for(let t of this.transformers_)t.setTrackExpectedRate(this.trackExpectedRate_)}async start(e,t){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let n=e;for(let i of this.transformers_)e=e.pipeThrough(new TransformStream(i));e.pipeTo(t).then(async()=>{console.log("[Pipeline] Setup."),await t.abort(),await n.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async i=>{e.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(s=>{console.error("[Pipeline] Error from stream transform:",s)}),await t.abort(i),await n.cancel(i),this.emit("pipelineInfo","pipeline_ended_with_error")})}catch{this.emit("pipelineInfo","pipeline_started_with_error"),this.destroy();return}this.emit("pipelineInfo","pipeline_started"),console.log("[Pipeline] Pipeline started.")}async destroy(){console.log("[Pipeline] Destroying Pipeline.");for(let e of this.transformers_)e.stop()}}class Rs extends Y{constructor(){super(),this.reporter_=new Qt,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(e){this.trackExpectedRate_=e,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(e,t){if(this.isTrack(e)){if(e.kind==="video"){const n=new MediaStreamTrackProcessor({track:e}),i=new VideoTrackGenerator;return this.readable_=n.readable,this.writable_=i.writable,await this.transformInternal(),i.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}else return this.readable_=e,this.writable_=t,this.transformInternal()}transformInternal(){return new Promise(async(e,t)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:le.errors.transformer_none,variation:"Error"}),t("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:le.errors.readable_null}),t("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:le.errors.writable_null}),t("[MediaProcessor] Writable is null.");return}let n=!1;this.pipeline_&&(n=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new Ss(this.transformers_),this.pipeline_.on("warn",i=>{this.emit("warn",i)}),this.pipeline_.on("error",i=>{this.emit("error",i)}),this.pipeline_.on("pipelineInfo",i=>{n&&(i==="pipeline_started"?i=Jt.pipeline_restarted:i==="pipeline_started_with_error"&&(i=Jt.pipeline_restarted_with_error)),this.emit("pipelineInfo",i)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{e()}).catch(i=>{t(i)})})}setTransformers(e){return this.report({variation:"Update",message:le.updates.transformer_new}),this.transformers_=e,this.readable_&&this.writable_?this.transformInternal():Promise.resolve()}destroy(){return new Promise(async e=>{this.pipeline_&&this.pipeline_.destroy(),this.report({variation:"Delete"}),e()})}report(e){this.reporter_.send({version:dt,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}var Fs=Object.defineProperty,Ps=(r,e,t)=>e in r?Fs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ks=(r,e,t)=>(Ps(r,e+"",t),t);const Cs="hlg.tokbox.com/prod/logging/vcp_webrtc",Bs="https://",Ds=1e4;let ht;const Ms=new Uint8Array(16);function Os(){if(!ht&&(ht=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ht))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ht(Ms)}const P=[];for(let r=0;r<256;++r)P.push((r+256).toString(16).slice(1));function Us(r,e=0){return(P[r[e+0]]+P[r[e+1]]+P[r[e+2]]+P[r[e+3]]+"-"+P[r[e+4]]+P[r[e+5]]+"-"+P[r[e+6]]+P[r[e+7]]+"-"+P[r[e+8]]+P[r[e+9]]+"-"+P[r[e+10]]+P[r[e+11]]+P[r[e+12]]+P[r[e+13]]+P[r[e+14]]+P[r[e+15]]).toLowerCase()}const Ns=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),on={randomUUID:Ns};function Ls(r,e,t){if(on.randomUUID&&!e&&!r)return on.randomUUID();r=r||{};const n=r.random||(r.rng||Os)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Us(n)}function Zt(r,e){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let t=globalThis.vonage.workerizer;return t[r]||(t[r]=e),t[r]}const ee=Zt("globals",{});var de=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(de||{});function an(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let zs=0;function Gs(r,e,t,n,i){const s=zs++;return r.postMessage({id:s,type:e,functionName:t,args:n},n.filter(o=>an(o))),new Promise(o=>{i?.set(s,o)})}function Ue(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(s=>an(s)))}const cn=Zt("workerized",{});function un(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function $s(){if(un())Ue({type:de.GLOBALS_SYNC},ee);else{const r=[];for(const e in cn){const{worker:t,resolvers:n}=cn[e].workerContext;t&&r.push(Gs(t,de.GLOBALS_SYNC,"",[ee],n))}await Promise.all(r)}}function mt(r,e){if(Array.isArray(e))e.splice(0,e.length);else if(typeof e=="object")for(const t in e)delete e[t];for(const t in r)Array.isArray(r[t])?(e[t]=[],mt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},mt(r[t],e[t])):e[t]=r[t]}async function Ws(r,e){const{functionName:t,args:n}=r;if(!e.instance)throw"instance not initialized";if(!t)throw"missing function name to call";if(!e.instance[t])throw`undefined function [${t}] in class ${e.instance.constructor.workerId}`;Ue(r,await e.instance[t](...n??[]))}const Vs=Zt("registeredWorkers",{});function Hs(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Vs[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;mt(n,ee),Ue(r,typeof e.instance!==void 0)}async function js(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Ue(r,n)}function Xs(r){if(!r.args)throw"Missing globals while syncing";mt(r.args[0],ee),Ue(r,{})}function Ys(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case de.INIT:Hs(t,r);break;case de.FORWARD:Ws(t,r);break;case de.TERMINATE:js(t,r);break;case de.GLOBALS_SYNC:Xs(t);break}}}un()&&Ys();function Qs(r,e){return ee[r]||(ee[r]=e),[()=>ee[r],async t=>{ee[r]=t,await $s()}]}function qs(r,e){return Qs(r,e)}const[Ks]=qs("metadata");function er(){return Ks()}class Js{constructor(e){ks(this,"uuid",Ls()),this.config=e}async send(e){var t,n,i;const{appId:s,sourceType:o}=(t=er())!=null?t:{};if(!s||!o)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),Ds);return await((i=(n=this.config)==null?void 0:n.fetch)!=null?i:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(e)),signal:a.signal}),clearTimeout(c),"success"}getUrl(){var e;let t=(e=er().proxyUrl)!=null?e:Bs;return t+=(t.at(-1)==="/"?"":"/")+Cs,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=er();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const Zs="7.0.0-alpha.3";var pt=(r=>(r.Low="Low",r.High="High",r))(pt||{}),tr=(r=>(r.FAST="FAST",r.PRECISE="PRECISE",r))(tr||{}),gt=(r=>(r.CANVAS="CANVAS",r.WEBGL="WEBGL",r))(gt||{});function eo(){const e=new OffscreenCanvas(0,0).getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(e){const t=e?.getExtension("WEBGL_lose_context");t&&t.loseContext()}else return{supported:!1,message:"Your hardware does not perform good enough to run the library efficiently"};return{supported:!0}}class rr{constructor(){const e=new OffscreenCanvas(0,0),t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw"Fail to retrieve 2d context";this.canvas=e,this.context=t}enablePostProcessing(){}disablePostProcessing(){}async profileWebgl(e){return[]}async render(e,t){return this.canvas}resizeCanvas(e){const{width:t,height:n}=e;this.canvas.width=t,this.canvas.height=n}renderSilhouette(e,t,n="none"){const{width:i,height:s}=e;this.context.save(),this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(t,0,0,t.width,t.height,0,0,i,s),this.context.globalCompositeOperation="source-in",this.context.filter=n,this.context.drawImage(e,0,0,i,s,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class to extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.context.save(),this.context.filter=`blur(${this.radius}px)`,this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class ro extends rr{constructor(e){super(),this.radius=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n,`blur(${this.radius}px)`),this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(e,0,0,e.width,e.height),this.context.restore(),super.render(e,t)}}class no extends rr{setBackgroundImage(e){this.backgroundImage=e}async render(e,t){super.resizeCanvas(e);const n=await createImageBitmap(t);return this.renderSilhouette(e,n),this.backgroundImage&&(this.context.save(),this.context.filter="none",this.context.globalCompositeOperation="destination-over",this.context.drawImage(this.backgroundImage,0,0,this.backgroundImage.width,this.backgroundImage.height,0,0,e.width,e.height),this.context.restore()),super.render(e,t)}}const nr=5120,Ne=5121,ir=5122,sr=5123,or=5124,ar=5125,cr=5126,io=32819,so=32820,oo=33635,ao=5131,co=33640,uo=35899,fo=35902,lo=36269,ho=34042,fn={};{const r=fn;r[nr]=Int8Array,r[Ne]=Uint8Array,r[ir]=Int16Array,r[sr]=Uint16Array,r[or]=Int32Array,r[ar]=Uint32Array,r[cr]=Float32Array,r[io]=Uint16Array,r[so]=Uint16Array,r[oo]=Uint16Array,r[ao]=Uint16Array,r[co]=Uint32Array,r[uo]=Uint32Array,r[fo]=Uint32Array,r[lo]=Uint32Array,r[ho]=Uint32Array}function ur(r){if(r instanceof Int8Array)return nr;if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return Ne;if(r instanceof Int16Array)return ir;if(r instanceof Uint16Array)return sr;if(r instanceof Int32Array)return or;if(r instanceof Uint32Array)return ar;if(r instanceof Float32Array)return cr;throw new Error("unsupported typed array type")}function ln(r){if(r===Int8Array)return nr;if(r===Uint8Array||r===Uint8ClampedArray)return Ne;if(r===Int16Array)return ir;if(r===Uint16Array)return sr;if(r===Int32Array)return or;if(r===Uint32Array)return ar;if(r===Float32Array)return cr;throw new Error("unsupported typed array type")}function dn(r){const e=fn[r];if(!e)throw new Error("unknown gl type");return e}const yt=typeof SharedArrayBuffer<"u"?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer};function hn(...r){console.error(...r)}const mn=new Map;function bt(r,e){if(!r||typeof r!="object")return!1;let t=mn.get(e);t||(t=new WeakMap,mn.set(e,t));let n=t.get(r);if(n===void 0){const i=Object.prototype.toString.call(r);n=i.substring(8,i.length-1)===e,t.set(r,n)}return n}function mo(r,e){return typeof WebGLBuffer<"u"&&bt(e,"WebGLBuffer")}function po(r,e){return typeof WebGLRenderbuffer<"u"&&bt(e,"WebGLRenderbuffer")}function fr(r,e){return typeof WebGLTexture<"u"&&bt(e,"WebGLTexture")}function go(r,e){return typeof WebGLSampler<"u"&&bt(e,"WebGLSampler")}const pn=35044,he=34962,yo=34963,bo=34660,xo=5120,_o=5121,Eo=5122,wo=5123,vo=5124,To=5125,gn=5126,yn={attribPrefix:""};function Ao(r,e,t,n,i){r.bindBuffer(e,t),r.bufferData(e,n,i||pn)}function bn(r,e,t,n){if(mo(r,e))return e;t=t||he;const i=r.createBuffer();return Ao(r,t,i,e,n),i}function xn(r){return r==="indices"}function Io(r){return r===Int8Array||r===Uint8Array}function So(r){return r.length?r:r.data}const Ro=/coord|texture/i,Fo=/color|colour/i;function Po(r,e){let t;if(Ro.test(r)?t=2:Fo.test(r)?t=4:t=3,e%t>0)throw new Error(`Can not guess numComponents for attribute \'${r}\'. Tried ${t} but ${e} values is not evenly divisible by ${t}. You should specify it.`);return t}function ko(r,e,t){return r.numComponents||r.size||Po(e,t||So(r).length)}function _n(r,e){if(yt(r))return r;if(yt(r.data))return r.data;Array.isArray(r)&&(r={data:r});let t=r.type?lr(r.type):void 0;return t||(xn(e)?t=Uint16Array:t=Float32Array),new t(r.data)}function Co(r){return typeof r=="number"?r:r?ln(r):gn}function lr(r){return typeof r=="number"?dn(r):r||Float32Array}function Bo(r,e){return{buffer:e.buffer,numValues:24,type:Co(e.type),arrayType:lr(e.type)}}function Do(r,e){const t=e.data||e,n=lr(e.type),i=t*n.BYTES_PER_ELEMENT,s=r.createBuffer();return r.bindBuffer(he,s),r.bufferData(he,i,e.drawType||pn),{buffer:s,numValues:t,type:ln(n),arrayType:n}}function Mo(r,e,t){const n=_n(e,t);return{arrayType:n.constructor,buffer:bn(r,n,void 0,e.drawType),type:ur(n),numValues:0}}function Oo(r,e){const t={};return Object.keys(e).forEach(function(n){if(!xn(n)){const i=e[n],s=i.attrib||i.name||i.attribName||yn.attribPrefix+n;if(i.value){if(!Array.isArray(i.value)&&!yt(i.value))throw new Error("array.value is not array or typedarray");t[s]={value:i.value}}else{let o;i.buffer&&i.buffer instanceof WebGLBuffer?o=Bo:typeof i=="number"||typeof i.data=="number"?o=Do:o=Mo;const{buffer:a,type:c,numValues:u,arrayType:d}=o(r,i,n),m=i.normalize!==void 0?i.normalize:Io(d),p=ko(i,n,u);t[s]={buffer:a,numComponents:p,type:c,normalize:m,stride:i.stride||0,offset:i.offset||0,divisor:i.divisor===void 0?void 0:i.divisor,drawType:i.drawType}}}}),r.bindBuffer(he,null),t}function Uo(r,e){return e===xo||e===_o?1:e===Eo||e===wo?2:e===vo||e===To||e===gn?4:0}const dr=["position","positions","a_position"];function No(r,e){let t,n;for(n=0;n<dr.length&&(t=dr[n],!(t in e||(t=yn.attribPrefix+t,t in e)));++n);n===dr.length&&(t=Object.keys(e)[0]);const i=e[t];if(!i.buffer)return 1;r.bindBuffer(he,i.buffer);const s=r.getBufferParameter(he,bo);r.bindBuffer(he,null);const o=Uo(r,i.type),a=s/o,c=i.numComponents||i.size,u=a/c;if(u%1!==0)throw new Error(`numComponents ${c} not correct for length ${length}`);return u}function Lo(r,e,t){const n=Oo(r,e),i=Object.assign({},t||{});i.attribs=Object.assign({},t?t.attribs:{},n);const s=e.indices;if(s){const o=_n(s,"indices");i.indices=bn(r,o,yo),i.numElements=o.length,i.elementType=ur(o)}else i.numElements||(i.numElements=No(r,i.attribs));return i}function Le(r){return!!r.texStorage2D}const En=(function(){const r={},e={};function t(n){const i=n.constructor.name;if(!r[i]){for(const s in n)if(typeof n[s]=="number"){const o=e[n[s]];e[n[s]]=o?`${o} | ${s}`:s}r[i]=!0}}return function(i,s){return t(i),e[s]||(typeof s=="number"?`0x${s.toString(16)}`:s)}})(),te={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},ze=yt,wn=(function(){let r;return function(){return r=r||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),r}})(),vn=6406,V=6407,A=6408,Tn=6409,An=6410,Ge=6402,In=34041,xt=33071,zo=9728,Go=9729,re=3553,ne=34067,me=32879,pe=35866,hr=34069,$o=34070,Wo=34071,Vo=34072,Ho=34073,jo=34074,mr=10241,pr=10240,_t=10242,Et=10243,Sn=32882,Xo=33082,Yo=33083,Qo=33084,qo=33085,Ko=34892,Jo=34893,gr=3317,Rn=3314,Fn=32878,Pn=3316,kn=3315,Cn=32877,Zo=37443,ea=37441,ta=37440,ra=33321,na=36756,ia=33325,sa=33326,oa=33330,aa=33329,ca=33338,ua=33337,fa=33340,la=33339,da=33323,ha=36757,ma=33327,pa=33328,ga=33336,ya=33335,ba=33332,xa=33331,_a=33334,Ea=33333,wa=32849,va=35905,Ta=36194,Aa=36758,Ia=35898,Sa=35901,Ra=34843,Fa=34837,Pa=36221,ka=36239,Ca=36215,Ba=36233,Da=36209,Ma=36227,Oa=32856,Ua=35907,Na=36759,La=32855,za=32854,Ga=32857,$a=34842,Wa=34836,Va=36220,Ha=36238,ja=36975,Xa=36214,Ya=36232,Qa=36226,qa=36208,Ka=33189,Ja=33190,Za=36012,ec=36013,tc=35056,ie=5120,T=5121,wt=5122,Se=5123,vt=5124,ge=5125,B=5126,Bn=32819,Dn=32820,Mn=33635,z=5131,$e=36193,yr=33640,rc=35899,nc=35902,ic=36269,sc=34042,Tt=33319,Re=33320,At=6403,Fe=36244,Pe=36248,ye=36249;let br;function It(r){if(!br){const e={};e[vn]={textureFormat:vn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[Tn]={textureFormat:Tn,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[T,z,$e,B]},e[An]={textureFormat:An,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[T,z,$e,B]},e[V]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[T,z,$e,B,Mn]},e[A]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[T,z,$e,B,Bn,Dn]},e[Ge]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[ge,Se]},e[ra]={textureFormat:At,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[T]},e[na]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ie]},e[ia]={textureFormat:At,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[B,z]},e[sa]={textureFormat:At,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[oa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[T]},e[aa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ie]},e[ba]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Se]},e[xa]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[wt]},e[_a]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Ea]={textureFormat:Fe,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[vt]},e[da]={textureFormat:Tt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[T]},e[ha]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ie]},e[ma]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[B,z]},e[pa]={textureFormat:Tt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[B]},e[ga]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[T]},e[ya]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ie]},e[ca]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Se]},e[ua]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[wt]},e[fa]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[ge]},e[la]={textureFormat:Re,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[vt]},e[wa]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[va]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[T]},e[Ta]={textureFormat:V,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[T,Mn]},e[Aa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ie]},e[Ia]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,rc]},e[Sa]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[B,z,nc]},e[Ra]={textureFormat:V,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[B,z]},e[Fa]={textureFormat:V,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[B]},e[Pa]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[T]},e[ka]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ie]},e[Ca]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Se]},e[Ba]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[wt]},e[Da]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[ge]},e[Ma]={textureFormat:Pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[vt]},e[Oa]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Ua]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[T]},e[Na]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ie]},e[La]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[T,Dn,yr]},e[za]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[T,Bn]},e[Ga]={textureFormat:A,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[yr]},e[$a]={textureFormat:A,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[B,z]},e[Wa]={textureFormat:A,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[B]},e[Va]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[T]},e[Ha]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ie]},e[ja]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[yr]},e[Xa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Se]},e[Ya]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[wt]},e[Qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[vt]},e[qa]={textureFormat:ye,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[ge]},e[Ka]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Se,ge]},e[Ja]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ge]},e[Za]={textureFormat:Ge,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[B]},e[tc]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[sc]},e[ec]={textureFormat:In,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ic]},Object.keys(e).forEach(function(t){const n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(i,s){const o=n.type[s];n.bytesPerElementMap[o]=i})}),br=e}return br[r]}function oc(r,e){const t=It(r);if(!t)throw"unknown internal format";const n=t.bytesPerElementMap[e];if(n===void 0)throw"unknown internal format";return n}function We(r){const e=It(r);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function On(r){return(r&r-1)===0}function ac(r,e,t,n){if(!Le(r))return On(e)&&On(t);const i=It(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function cc(r){const e=It(r);if(!e)throw"unknown internal format";return e.textureFilterable}function uc(r,e,t){return ze(e)?ur(e):t||T}function St(r,e,t,n,i){if(i%1!==0)throw"can\'t guess dimensions";if(!t&&!n){const s=Math.sqrt(i/(e===ne?6:1));s%1===0?(t=s,n=s):(t=i,n=1)}else if(n){if(!t&&(t=i/n,t%1))throw"can\'t guess dimensions"}else if(n=i/t,n%1)throw"can\'t guess dimensions";return{width:t,height:n}}function ke(r,e){e.colorspaceConversion!==void 0&&r.pixelStorei(Zo,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&r.pixelStorei(ea,e.premultiplyAlpha),e.flipY!==void 0&&r.pixelStorei(ta,e.flipY)}function Un(r){r.pixelStorei(gr,4),Le(r)&&(r.pixelStorei(Rn,0),r.pixelStorei(Fn,0),r.pixelStorei(Pn,0),r.pixelStorei(kn,0),r.pixelStorei(Cn,0))}function fc(r,e,t,n){n.minMag&&(t.call(r,e,mr,n.minMag),t.call(r,e,pr,n.minMag)),n.min&&t.call(r,e,mr,n.min),n.mag&&t.call(r,e,pr,n.mag),n.wrap&&(t.call(r,e,_t,n.wrap),t.call(r,e,Et,n.wrap),(e===me||go(r,e))&&t.call(r,e,Sn,n.wrap)),n.wrapR&&t.call(r,e,Sn,n.wrapR),n.wrapS&&t.call(r,e,_t,n.wrapS),n.wrapT&&t.call(r,e,Et,n.wrapT),n.minLod!==void 0&&t.call(r,e,Xo,n.minLod),n.maxLod!==void 0&&t.call(r,e,Yo,n.maxLod),n.baseLevel!==void 0&&t.call(r,e,Qo,n.baseLevel),n.maxLevel!==void 0&&t.call(r,e,qo,n.maxLevel),n.compareFunc!==void 0&&t.call(r,e,Jo,n.compareFunc),n.compareMode!==void 0&&t.call(r,e,Ko,n.compareMode)}function Nn(r,e,t){const n=t.target||re;r.bindTexture(n,e),fc(r,n,r.texParameteri,t)}function lc(r){return r=r||te.textureColor,ze(r)?r:new Uint8Array([r[0]*255,r[1]*255,r[2]*255,r[3]*255])}function xr(r,e,t,n,i,s){t=t||te.textureOptions,s=s||A;const o=t.target||re;if(n=n||t.width,i=i||t.height,r.bindTexture(o,e),ac(r,n,i,s))r.generateMipmap(o);else{const a=cc(s)?Go:zo;r.texParameteri(o,mr,a),r.texParameteri(o,pr,a),r.texParameteri(o,_t,xt),r.texParameteri(o,Et,xt)}}function Ve(r){return r.auto===!0||r.auto===void 0&&r.level===void 0}function _r(r,e){return e=e||{},e.cubeFaceOrder||[hr,$o,Wo,Vo,Ho,jo]}function Er(r,e){const n=_r(r,e).map(function(i,s){return{face:i,ndx:s}});return n.sort(function(i,s){return i.face-s.face}),n}function Ln(r,e,t,n){n=n||te.textureOptions;const i=n.target||re,s=n.level||0;let o=t.width,a=t.height;const c=n.internalFormat||n.format||A,u=We(c),d=n.format||u.format,m=n.type||u.type;if(ke(r,n),r.bindTexture(i,e),i===ne){const p=t.width,y=t.height;let l,b;if(p/6===y)l=y,b=[0,0,1,0,2,0,3,0,4,0,5,0];else if(y/6===p)l=p,b=[0,0,0,1,0,2,0,3,0,4,0,5];else if(p/3===y/2)l=p/3,b=[0,0,1,0,2,0,0,1,1,1,2,1];else if(p/2===y/3)l=p/2,b=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can\'t figure out cube map from element: "+(t.src?t.src:t.nodeName);const _=wn();_?(_.canvas.width=l,_.canvas.height=l,o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;_.drawImage(t,R,k,l,l,0,0,l,l),r.texImage2D(E.face,s,c,d,m,_.canvas)}),_.canvas.width=1,_.canvas.height=1):typeof createImageBitmap<"u"&&(o=l,a=l,Er(r,n).forEach(function(E){const R=b[E.ndx*2+0]*l,k=b[E.ndx*2+1]*l;r.texImage2D(E.face,s,c,l,l,0,d,m,null),createImageBitmap(t,R,k,l,l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(N){ke(r,n),r.bindTexture(i,e),r.texImage2D(E.face,s,c,d,m,N),Ve(n)&&xr(r,e,n,o,a,c)})}))}else if(i===me||i===pe){const p=Math.min(t.width,t.height),y=Math.max(t.width,t.height),l=y/p;if(l%1!==0)throw"can not compute 3D dimensions of element";const b=t.width===y?1:0,_=t.height===y?1:0;r.pixelStorei(gr,1),r.pixelStorei(Rn,t.width),r.pixelStorei(Fn,0),r.pixelStorei(Cn,0),r.texImage3D(i,s,c,p,p,p,0,d,m,null);for(let E=0;E<l;++E){const R=E*p*b,k=E*p*_;r.pixelStorei(Pn,R),r.pixelStorei(kn,k),r.texSubImage3D(i,s,0,0,E,p,p,1,d,m,t)}Un(r)}else r.texImage2D(i,s,c,d,m,t);Ve(n)&&xr(r,e,n,o,a,c),Nn(r,e,n)}function He(){}function dc(r){if(typeof document<"u"){const e=document.createElement("a");return e.href=r,e.hostname===location.hostname&&e.port===location.port&&e.protocol===location.protocol}else{const e=new URL(location.href).origin;return new URL(r,location.href).origin===e}}function hc(r,e){return e===void 0&&!dc(r)?"anonymous":e}function mc(r,e,t){t=t||He;let n;if(e=e!==void 0?e:te.crossOrigin,e=hc(r,e),typeof Image<"u"){n=new Image,e!==void 0&&(n.crossOrigin=e);const i=function(){n.removeEventListener("error",s),n.removeEventListener("load",o),n=null},s=function(){const c="couldn\'t load image: "+r;hn(c),t(c,n),i()},o=function(){t(null,n),i()};return n.addEventListener("error",s),n.addEventListener("load",o),n.src=r,n}else if(typeof ImageBitmap<"u"){let i,s;const o=function(){t(i,s)},a={};e&&(a.mode="cors"),fetch(r,a).then(function(c){if(!c.ok)throw c;return c.blob()}).then(function(c){return createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(c){s=c,setTimeout(o)}).catch(function(c){i=c,setTimeout(o)}),n=null}return n}function zn(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof ImageData<"u"&&r instanceof ImageData||typeof HTMLElement<"u"&&r instanceof HTMLElement}function wr(r,e,t){return zn(r)?(setTimeout(function(){t(null,r)}),r):mc(r,e,t)}function vr(r,e,t){t=t||te.textureOptions;const n=t.target||re;if(r.bindTexture(n,e),t.color===!1)return;const i=lc(t.color);if(n===ne)for(let s=0;s<6;++s)r.texImage2D(hr+s,0,A,1,1,0,A,T,i);else n===me||n===pe?r.texImage3D(n,0,A,1,1,1,0,A,T,i):r.texImage2D(n,0,A,1,1,0,A,T,i)}function pc(r,e,t,n){return n=n||He,t=t||te.textureOptions,vr(r,e,t),t=Object.assign({},t),wr(t.src,t.crossOrigin,function(s,o){s?n(s,e,o):(Ln(r,e,o,t),n(null,e,o))})}function gc(r,e,t,n){n=n||He;const i=t.src;if(i.length!==6)throw"there must be 6 urls for a cubemap";const s=t.level||0,o=t.internalFormat||t.format||A,a=We(o),c=t.format||a.format,u=t.type||T,d=t.target||re;if(d!==ne)throw"target must be TEXTURE_CUBE_MAP";vr(r,e,t),t=Object.assign({},t);let m=6;const p=[],y=_r(r,t);let l;function b(_){return function(E,R){--m,E?p.push(E):R.width!==R.height?p.push("cubemap face img is not a square: "+R.src):(ke(r,t),r.bindTexture(d,e),m===5?_r().forEach(function(k){r.texImage2D(k,s,o,c,u,R)}):r.texImage2D(_,s,o,c,u,R),Ve(t)&&r.generateMipmap(d)),m===0&&n(p.length?p:void 0,e,l)}}l=i.map(function(_,E){return wr(_,t.crossOrigin,b(y[E]))})}function yc(r,e,t,n){n=n||He;const i=t.src,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||T,u=t.target||pe;if(u!==me&&u!==pe)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";vr(r,e,t),t=Object.assign({},t);let d=i.length;const m=[];let p;const y=t.level||0;let l=t.width,b=t.height;const _=i.length;let E=!0;function R(k){return function(N,Q){if(--d,N)m.push(N);else{if(ke(r,t),r.bindTexture(u,e),E){E=!1,l=t.width||Q.width,b=t.height||Q.height,r.texImage3D(u,y,s,l,b,_,0,a,c,null);for(let q=0;q<_;++q)r.texSubImage3D(u,y,0,0,q,l,b,1,a,c,Q)}else{let q=Q,L;(Q.width!==l||Q.height!==b)&&(L=wn(),q=L.canvas,L.canvas.width=l,L.canvas.height=b,L.drawImage(Q,0,0,l,b)),r.texSubImage3D(u,y,0,0,k,l,b,1,a,c,q),L&&q===L.canvas&&(L.canvas.width=0,L.canvas.height=0)}Ve(t)&&r.generateMipmap(u)}d===0&&n(m.length?m:void 0,e,p)}}p=i.map(function(k,N){return wr(k,t.crossOrigin,R(N))})}function bc(r,e,t,n){n=n||te.textureOptions;const i=n.target||re;r.bindTexture(i,e);let s=n.width,o=n.height,a=n.depth;const c=n.level||0,u=n.internalFormat||n.format||A,d=We(u),m=n.format||d.format,p=n.type||uc(r,t,d.type);if(ze(t))t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));else{const _=dn(p);t=new _(t)}const y=oc(u,p),l=t.byteLength/y;if(l%1)throw"length wrong size for format: "+En(r,m);let b;if(i===me||i===pe)if(!s&&!o&&!a){const _=Math.cbrt(l);if(_%1!==0)throw"can\'t guess cube size of array of numElements: "+l;s=_,o=_,a=_}else s&&(!o||!a)?(b=St(r,i,o,a,l/s),o=b.width,a=b.height):o&&(!s||!a)?(b=St(r,i,s,a,l/o),s=b.width,a=b.height):(b=St(r,i,s,o,l/a),s=b.width,o=b.height);else b=St(r,i,s,o,l),s=b.width,o=b.height;if(Un(r),r.pixelStorei(gr,n.unpackAlignment||1),ke(r,n),i===ne){const _=y/t.BYTES_PER_ELEMENT,E=l/6*_;Er(r,n).forEach(R=>{const k=E*R.ndx,N=t.subarray(k,k+E);r.texImage2D(R.face,c,u,s,o,0,m,p,N)})}else i===me||i===pe?r.texImage3D(i,c,u,s,o,a,0,m,p,t):r.texImage2D(i,c,u,s,o,0,m,p,t);return{width:s,height:o,depth:a,type:p}}function xc(r,e,t){const n=t.target||re;r.bindTexture(n,e);const i=t.level||0,s=t.internalFormat||t.format||A,o=We(s),a=t.format||o.format,c=t.type||o.type;if(ke(r,t),n===ne)for(let u=0;u<6;++u)r.texImage2D(hr+u,i,s,t.width,t.height,0,a,c,null);else n===me||n===pe?r.texImage3D(n,i,s,t.width,t.height,t.depth,0,a,c,null):r.texImage2D(n,i,s,t.width,t.height,0,a,c,null)}function Gn(r,e,t){t=t||He,e=e||te.textureOptions;const n=r.createTexture(),i=e.target||re;let s=e.width||1,o=e.height||1;const a=e.internalFormat||A;r.bindTexture(i,n),i===ne&&(r.texParameteri(i,_t,xt),r.texParameteri(i,Et,xt));let c=e.src;if(c)if(typeof c=="function"&&(c=c(r,e)),typeof c=="string")pc(r,n,e,t);else if(ze(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||ze(c[0]))){const u=bc(r,n,c,e);s=u.width,o=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||zn(c[0]))?i===ne?gc(r,n,e,t):yc(r,n,e,t):(Ln(r,n,c,e),s=c.width,o=c.height);else xc(r,n,e);return Ve(e)&&xr(r,n,e,s,o,a),Nn(r,n,e),n}const Tr=hn;function $n(r){return typeof document<"u"&&document.getElementById?document.getElementById(r):null}const Rt=33984,Ft=34962,_c=34963,Ec=35713,wc=35714,vc=35632,Tc=35633,Ac=35981,Wn=35718,Ic=35721,Sc=35971,Rc=35382,Fc=35396,Pc=35398,kc=35392,Cc=35395,Pt=5126,Vn=35664,Hn=35665,jn=35666,Ar=5124,Xn=35667,Yn=35668,Qn=35669,qn=35670,Kn=35671,Jn=35672,Zn=35673,ei=35674,ti=35675,ri=35676,Bc=35678,Dc=35680,Mc=35679,Oc=35682,Uc=35685,Nc=35686,Lc=35687,zc=35688,Gc=35689,$c=35690,Wc=36289,Vc=36292,Hc=36293,Ir=5125,ni=36294,ii=36295,si=36296,jc=36298,Xc=36299,Yc=36300,Qc=36303,qc=36306,Kc=36307,Jc=36308,Zc=36311,kt=3553,Ct=34067,Sr=32879,Bt=35866,x={};function oi(r,e){return x[e].bindPoint}function eu(r,e){return function(t){r.uniform1f(e,t)}}function tu(r,e){return function(t){r.uniform1fv(e,t)}}function ru(r,e){return function(t){r.uniform2fv(e,t)}}function nu(r,e){return function(t){r.uniform3fv(e,t)}}function iu(r,e){return function(t){r.uniform4fv(e,t)}}function ai(r,e){return function(t){r.uniform1i(e,t)}}function ci(r,e){return function(t){r.uniform1iv(e,t)}}function ui(r,e){return function(t){r.uniform2iv(e,t)}}function fi(r,e){return function(t){r.uniform3iv(e,t)}}function li(r,e){return function(t){r.uniform4iv(e,t)}}function su(r,e){return function(t){r.uniform1ui(e,t)}}function ou(r,e){return function(t){r.uniform1uiv(e,t)}}function au(r,e){return function(t){r.uniform2uiv(e,t)}}function cu(r,e){return function(t){r.uniform3uiv(e,t)}}function uu(r,e){return function(t){r.uniform4uiv(e,t)}}function fu(r,e){return function(t){r.uniformMatrix2fv(e,!1,t)}}function lu(r,e){return function(t){r.uniformMatrix3fv(e,!1,t)}}function du(r,e){return function(t){r.uniformMatrix4fv(e,!1,t)}}function hu(r,e){return function(t){r.uniformMatrix2x3fv(e,!1,t)}}function mu(r,e){return function(t){r.uniformMatrix3x2fv(e,!1,t)}}function pu(r,e){return function(t){r.uniformMatrix2x4fv(e,!1,t)}}function gu(r,e){return function(t){r.uniformMatrix4x2fv(e,!1,t)}}function yu(r,e){return function(t){r.uniformMatrix3x4fv(e,!1,t)}}function bu(r,e){return function(t){r.uniformMatrix4x3fv(e,!1,t)}}function O(r,e,t,n){const i=oi(r,e);return Le(r)?function(s){let o,a;!s||fr(r,s)?(o=s,a=null):(o=s.texture,a=s.sampler),r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,o),r.bindSampler(t,a)}:function(s){r.uniform1i(n,t),r.activeTexture(Rt+t),r.bindTexture(i,s)}}function U(r,e,t,n,i){const s=oi(r,e),o=new Int32Array(i);for(let a=0;a<i;++a)o[a]=t+a;return Le(r)?function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]);let d,m;!c||fr(r,c)?(d=c,m=null):(d=c.texture,m=c.sampler),r.bindSampler(t,m),r.bindTexture(s,d)})}:function(a){r.uniform1iv(n,o),a.forEach(function(c,u){r.activeTexture(Rt+o[u]),r.bindTexture(s,c)})}}x[Pt]={Type:Float32Array,size:4,setter:eu,arraySetter:tu},x[Vn]={Type:Float32Array,size:8,setter:ru,cols:2},x[Hn]={Type:Float32Array,size:12,setter:nu,cols:3},x[jn]={Type:Float32Array,size:16,setter:iu,cols:4},x[Ar]={Type:Int32Array,size:4,setter:ai,arraySetter:ci},x[Xn]={Type:Int32Array,size:8,setter:ui,cols:2},x[Yn]={Type:Int32Array,size:12,setter:fi,cols:3},x[Qn]={Type:Int32Array,size:16,setter:li,cols:4},x[Ir]={Type:Uint32Array,size:4,setter:su,arraySetter:ou},x[ni]={Type:Uint32Array,size:8,setter:au,cols:2},x[ii]={Type:Uint32Array,size:12,setter:cu,cols:3},x[si]={Type:Uint32Array,size:16,setter:uu,cols:4},x[qn]={Type:Uint32Array,size:4,setter:ai,arraySetter:ci},x[Kn]={Type:Uint32Array,size:8,setter:ui,cols:2},x[Jn]={Type:Uint32Array,size:12,setter:fi,cols:3},x[Zn]={Type:Uint32Array,size:16,setter:li,cols:4},x[ei]={Type:Float32Array,size:32,setter:fu,rows:2,cols:2},x[ti]={Type:Float32Array,size:48,setter:lu,rows:3,cols:3},x[ri]={Type:Float32Array,size:64,setter:du,rows:4,cols:4},x[Uc]={Type:Float32Array,size:32,setter:hu,rows:2,cols:3},x[Nc]={Type:Float32Array,size:32,setter:pu,rows:2,cols:4},x[Lc]={Type:Float32Array,size:48,setter:mu,rows:3,cols:2},x[zc]={Type:Float32Array,size:48,setter:yu,rows:3,cols:4},x[Gc]={Type:Float32Array,size:64,setter:gu,rows:4,cols:2},x[$c]={Type:Float32Array,size:64,setter:bu,rows:4,cols:3},x[Bc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Dc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Mc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Oc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Wc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Vc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[Hc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Xc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Yc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt},x[qc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:kt},x[Kc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Sr},x[Jc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Ct},x[Zc]={Type:null,size:0,setter:O,arraySetter:U,bindPoint:Bt};function Dt(r,e){return function(t){if(t.value)switch(r.disableVertexAttribArray(e),t.value.length){case 4:r.vertexAttrib4fv(e,t.value);break;case 3:r.vertexAttrib3fv(e,t.value);break;case 2:r.vertexAttrib2fv(e,t.value);break;case 1:r.vertexAttrib1fv(e,t.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribPointer(e,t.numComponents||t.size,t.type||Pt,t.normalize||!1,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function se(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4iv(e,t.value);else throw new Error("The length of an integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ar,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Mt(r,e){return function(t){if(t.value)if(r.disableVertexAttribArray(e),t.value.length===4)r.vertexAttrib4uiv(e,t.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else r.bindBuffer(Ft,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Ir,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Rr(r,e,t){const n=t.size,i=t.count;return function(s){r.bindBuffer(Ft,s.buffer);const o=s.size||s.numComponents||n,a=o/i,c=s.type||Pt,d=x[c].size*o,m=s.normalize||!1,p=s.offset||0,y=d/i;for(let l=0;l<i;++l)r.enableVertexAttribArray(e+l),r.vertexAttribPointer(e+l,a,c,m,d,p+y*l),r.vertexAttribDivisor&&r.vertexAttribDivisor(e+l,s.divisor||0)}}const I={};I[Pt]={size:4,setter:Dt},I[Vn]={size:8,setter:Dt},I[Hn]={size:12,setter:Dt},I[jn]={size:16,setter:Dt},I[Ar]={size:4,setter:se},I[Xn]={size:8,setter:se},I[Yn]={size:12,setter:se},I[Qn]={size:16,setter:se},I[Ir]={size:4,setter:Mt},I[ni]={size:8,setter:Mt},I[ii]={size:12,setter:Mt},I[si]={size:16,setter:Mt},I[qn]={size:4,setter:se},I[Kn]={size:8,setter:se},I[Jn]={size:12,setter:se},I[Zn]={size:16,setter:se},I[ei]={size:4,setter:Rr,count:2},I[ti]={size:9,setter:Rr,count:3},I[ri]={size:16,setter:Rr,count:4};const xu=/ERROR:\\s*\\d+:(\\d+)/gi;function _u(r,e="",t=0){const n=[...e.matchAll(xu)],i=new Map(n.map((s,o)=>{const a=parseInt(s[1]),c=n[o+1],u=c?c.index:e.length,d=e.substring(s.index,u);return[a-1,d]}));return r.split(`\n`).map((s,o)=>{const a=i.get(o);return`${o+1+t}: ${s}${a?`\n\n^^^ ${a}`:""}`}).join(`\n`)}const di=/^[ \\t]*\\n/;function hi(r){let e=0;return di.test(r)&&(e=1,r=r.replace(di,"")),{lineOffset:e,shaderSource:r}}function Eu(r,e){return r.errorCallback(e),r.callback&&setTimeout(()=>{r.callback(`${e}\n${r.errors.join(`\n`)}`)}),null}function wu(r,e,t,n){if(n=n||Tr,!r.getShaderParameter(t,Ec)){const s=r.getShaderInfoLog(t),{lineOffset:o,shaderSource:a}=hi(r.getShaderSource(t)),c=`${_u(a,s,o)}\nError compiling ${En(r,e)}: ${s}`;return n(c),c}return""}function Fr(r,e,t){let n,i,s;if(typeof e=="function"&&(t=e,e=void 0),typeof r=="function")t=r,r=void 0;else if(r&&!Array.isArray(r)){const u=r;t=u.errorCallback,r=u.attribLocations,n=u.transformFeedbackVaryings,i=u.transformFeedbackMode,s=u.callback}const o=t||Tr,a=[],c={errorCallback(u,...d){a.push(u),o(u,...d)},transformFeedbackVaryings:n,transformFeedbackMode:i,callback:s,errors:a};{let u={};Array.isArray(r)?r.forEach(function(d,m){u[d]=e?e[m]:m}):u=r||{},c.attribLocations=u}return c}const vu=["VERTEX_SHADER","FRAGMENT_SHADER"];function Tu(r,e){if(e.indexOf("frag")>=0)return vc;if(e.indexOf("vert")>=0)return Tc}function Au(r,e,t){const n=r.getAttachedShaders(e);for(const i of n)t.has(i)&&r.deleteShader(i);r.deleteProgram(e)}const Iu=(r=0)=>new Promise(e=>setTimeout(e,r));function Su(r,e,t){const n=r.createProgram(),{attribLocations:i,transformFeedbackVaryings:s,transformFeedbackMode:o}=Fr(t);for(let a=0;a<e.length;++a){let c=e[a];if(typeof c=="string"){const u=$n(c),d=u?u.text:c;let m=r[vu[a]];u&&u.type&&(m=Tu(r,u.type)||m),c=r.createShader(m),r.shaderSource(c,hi(d).shaderSource),r.compileShader(c),r.attachShader(n,c)}}Object.entries(i).forEach(([a,c])=>r.bindAttribLocation(n,c,a));{let a=s;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),r.transformFeedbackVaryings(n,a,o||Ac))}return r.linkProgram(n),n}function Ru(r,e,t,n,i){const s=Fr(t,n,i),o=new Set(e),a=Su(r,e,s);function c(u,d){const m=Pu(u,d,s.errorCallback);return m&&Au(u,d,o),m}if(s.callback){Fu(r,a).then(()=>{const u=c(r,a);s.callback(u,u?void 0:a)});return}return c(r,a)?void 0:a}async function Fu(r,e){const t=r.getExtension("KHR_parallel_shader_compile"),n=t?(s,o)=>s.getProgramParameter(o,t.COMPLETION_STATUS_KHR):()=>!0;let i=0;do await Iu(i),i=1e3/60;while(!n(r,e))}function Pu(r,e,t){if(t=t||Tr,!r.getProgramParameter(e,wc)){const i=r.getProgramInfoLog(e);t(`Error in program linking: ${i}`);const o=r.getAttachedShaders(e).map(a=>wu(r,r.getShaderParameter(a,r.SHADER_TYPE),a,t));return`${i}\n${o.filter(a=>a).join(`\n`)}`}}function ku(r,e,t,n,i){return Ru(r,e,t,n,i)}function mi(r){const e=r.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Cu=/(\\.|\\[|]|\\w+)/g,Bu=r=>r>="0"&&r<="9";function Du(r,e,t,n){const i=r.split(Cu).filter(a=>a!=="");let s=0,o="";for(;;){const a=i[s++];o+=a;const c=Bu(a[0]),u=c?parseInt(a):a;if(c&&(o+=i[s++]),s===i.length){t[u]=e;break}else{const m=i[s++],p=m==="[",y=t[u]||(p?[]:{});t[u]=y,t=y,n[o]=n[o]||(function(l){return function(b){pi(l,b)}})(y),o+=m}}}function Mu(r,e){let t=0;function n(a,c,u){const d=c.name.endsWith("[0]"),m=c.type,p=x[m];if(!p)throw new Error(`unknown type: 0x${m.toString(16)}`);let y;if(p.bindPoint){const l=t;t+=c.size,d?y=p.arraySetter(r,m,l,u,c.size):y=p.setter(r,m,l,u,c.size)}else p.arraySetter&&d?y=p.arraySetter(r,u):y=p.setter(r,u);return y.location=u,y}const i={},s={},o=r.getProgramParameter(e,Wn);for(let a=0;a<o;++a){const c=r.getActiveUniform(e,a);if(mi(c))continue;let u=c.name;u.endsWith("[0]")&&(u=u.substr(0,u.length-3));const d=r.getUniformLocation(e,c.name);if(d){const m=n(e,c,d);i[u]=m,Du(u,m,s,i)}}return i}function Ou(r,e){const t={},n=r.getProgramParameter(e,Sc);for(let i=0;i<n;++i){const s=r.getTransformFeedbackVarying(e,i);t[s.name]={index:i,type:s.type,size:s.size}}return t}function Uu(r,e){const t=r.getProgramParameter(e,Wn),n=[],i=[];for(let a=0;a<t;++a){i.push(a),n.push({});const c=r.getActiveUniform(e,a);n[a].name=c.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const c=a[0],u=a[1];r.getActiveUniforms(e,i,r[c]).forEach(function(d,m){n[m][u]=d})});const s={},o=r.getProgramParameter(e,Rc);for(let a=0;a<o;++a){const c=r.getActiveUniformBlockName(e,a),u={index:r.getUniformBlockIndex(e,c),usedByVertexShader:r.getActiveUniformBlockParameter(e,a,Fc),usedByFragmentShader:r.getActiveUniformBlockParameter(e,a,Pc),size:r.getActiveUniformBlockParameter(e,a,kc),uniformIndices:r.getActiveUniformBlockParameter(e,a,Cc)};u.used=u.usedByVertexShader||u.usedByFragmentShader,s[c]=u}return{blockSpecs:s,uniformData:n}}function pi(r,e){for(const t in e){const n=r[t];typeof n=="function"?n(e[t]):pi(r[t],e[t])}}function gi(r,...e){const t=r.uniformSetters||r,n=e.length;for(let i=0;i<n;++i){const s=e[i];if(Array.isArray(s)){const o=s.length;for(let a=0;a<o;++a)gi(t,s[a])}else for(const o in s){const a=t[o];a&&a(s[o])}}}function Nu(r,e){const t={},n=r.getProgramParameter(e,Ic);for(let i=0;i<n;++i){const s=r.getActiveAttrib(e,i);if(mi(s))continue;const o=r.getAttribLocation(e,s.name),a=I[s.type],c=a.setter(r,o,a);c.location=o,t[s.name]=c}return t}function Lu(r,e){for(const t in e){const n=r[t];n&&n(e[t])}}function zu(r,e,t){t.vertexArrayObject?r.bindVertexArray(t.vertexArrayObject):(Lu(e.attribSetters||e,t.attribs),t.indices&&r.bindBuffer(_c,t.indices))}function yi(r,e){const t=Mu(r,e),n=Nu(r,e),i={program:e,uniformSetters:t,attribSetters:n};return Le(r)&&(i.uniformBlockSpec=Uu(r,e),i.transformFeedbackInfo=Ou(r,e)),i}const Gu=/\\s|{|}|;/;function $u(r,e,t,n,i){const s=Fr(t,n,i),o=[];if(e=e.map(function(u){if(!Gu.test(u)){const d=$n(u);if(d)u=d.text;else{const m=`no element with id: ${u}`;s.errorCallback(m),o.push(m)}}return u}),o.length)return Eu(s,"");const a=s.callback;a&&(s.callback=(u,d)=>{a(u,u?void 0:yi(r,d))});const c=ku(r,e,s);return c?yi(r,c):null}const Wu=4,bi=5123;function Vu(r,e,t,n,i,s){t=t===void 0?Wu:t;const o=e.indices,a=e.elementType,c=n===void 0?e.numElements:n;i=i===void 0?0:i,a||o?s!==void 0?r.drawElementsInstanced(t,c,a===void 0?bi:e.elementType,i,s):r.drawElements(t,c,a===void 0?bi:e.elementType,i):s!==void 0?r.drawArraysInstanced(t,i,c,s):r.drawArrays(t,i,c)}const xi=36160,Ot=36161,Hu=3553,ju=5121,Xu=6402,Yu=6408,Qu=33190,qu=36012,Ku=35056,Ju=36013,Zu=32854,ef=32855,tf=36194,_i=33189,Ei=6401,wi=36168,Pr=34041,kr=36064,Ut=36096,vi=36128,Cr=33306,Br=33071,Dr=9729,rf=[{format:Yu,type:ju,min:Dr,wrap:Br},{format:Pr}],G={};G[Pr]=Cr,G[Ei]=vi,G[wi]=vi,G[Xu]=Ut,G[_i]=Ut,G[Qu]=Ut,G[qu]=Ut,G[Ku]=Cr,G[Ju]=Cr;function nf(r,e){return G[r]||G[e]}const oe={};oe[Zu]=!0,oe[ef]=!0,oe[tf]=!0,oe[Pr]=!0,oe[_i]=!0,oe[Ei]=!0,oe[wi]=!0;function sf(r){return oe[r]}const of=32;function af(r){return r>=kr&&r<kr+of}function Ti(r,e,t,n){const i=xi,s=r.createFramebuffer();r.bindFramebuffer(i,s),t=t||r.drawingBufferWidth,n=n||r.drawingBufferHeight,e=e||rf;const o=[],a={framebuffer:s,attachments:[],width:t,height:n};return e.forEach(function(c,u){let d=c.attachment;const m=c.samples,p=c.format;let y=c.attachmentPoint||nf(p,c.internalFormat);if(y||(y=kr+u),af(y)&&o.push(y),!d)if(m!==void 0||sf(p))d=r.createRenderbuffer(),r.bindRenderbuffer(Ot,d),m>1?r.renderbufferStorageMultisample(Ot,m,p,t,n):r.renderbufferStorage(Ot,p,t,n);else{const l=Object.assign({},c);l.width=t,l.height=n,l.auto===void 0&&(l.auto=!1,l.min=l.min||l.minMag||Dr,l.mag=l.mag||l.minMag||Dr,l.wrapS=l.wrapS||l.wrap||Br,l.wrapT=l.wrapT||l.wrap||Br),d=Gn(r,l)}if(po(r,d))r.framebufferRenderbuffer(i,y,Ot,d);else if(fr(r,d))c.layer!==void 0?r.framebufferTextureLayer(i,y,d,c.level||0,c.layer):r.framebufferTexture2D(i,y,c.target||Hu,d,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(d)}),r.drawBuffers&&r.drawBuffers(o),a}function cf(r,e,t){t=t||xi,e?(r.bindFramebuffer(t,e.framebuffer),r.viewport(0,0,e.width,e.height)):(r.bindFramebuffer(t,null),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight))}function D(r,e){return()=>e instanceof WebGLTexture?e:Gn(r,{src:e,wrap:r.CLAMP_TO_EDGE})}const Ce=2;class je{constructor(e){this.id="_";const{context:t,width:n,height:i}=e;this.context=t,this.options=e;const s=this.buildDefines();this.programInfo=$u(this.context,[s+this.getVertexShader(),s+this.getFragmentShader()]),this.bufferInfo=Lo(this.context,this.getBuffers()),this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],n,i),this.output=this.fbi.attachments[0]}resizeOutput(e,t){this.fbi=Ti(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],e,t),this.options.width=e,this.options.height=t,this.output=this.fbi.attachments[0]}getDefines(){return{}}getBuffers(){return{position:{numComponents:2,data:[-1,-1,-1,1,1,-1,1,1,-1,1,1,-1]},texture_coord:{numComponents:2,data:[0,0,0,1,1,0,1,1,0,1,1,0]}}}buildDefines(){let e="";const t=this.getDefines();for(let n in t)e+=`#define ${n} ${t[n].toFixed(1)}\n`;return e}run(e){this.profiler?.pushContext(`[${this.id}] PROG : ${this.constructor.name}`),this.profiler?.pushContext(`[${this.id}] UNIFORMS`);for(const i in e)typeof e[i]=="function"&&(this.profiler?.pushContext(`[${this.id}] UNI : ${i}`),e[i]=e[i](),this.profiler?.popContext(`[${this.id}] UNI : ${i}`));this.profiler?.popContext(`[${this.id}] UNIFORMS`);const t=Date.now();let n=0;this.lastRun&&(n=(t-this.lastRun)/1e3),this.lastRun=t,this.context.viewport(0,0,this.context.canvas.width,this.context.canvas.height),this.context.useProgram(this.programInfo.program),zu(this.context,this.programInfo,this.bufferInfo),gi(this.programInfo,{delta:n,canvas:[this.context.canvas.width,this.context.canvas.height],...e}),cf(this.context,this.options.disableFramebuffer?null:this.fbi),Vu(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(e){this.profiler=e}}var uf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform sampler2D background;\nuniform sampler2D foreground;\nuniform sampler2D threshold;\n\nvoid main() {\n vec4 backgroundColor = texture2D(background, _texture_coord);\n vec4 foregroundColor = texture2D(foreground, _texture_coord);\n vec4 tresholdColor = texture2D(threshold, _texture_coord);\n gl_FragColor = foregroundColor * tresholdColor.a +\n backgroundColor * (1. - tresholdColor.a);\n}\n`,ff=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n _texture_coord.y = 1. - texture_coord.y;\n}\n`;class Mr extends je{getFragmentShader(){return uf}getVertexShader(){return ff}}class Or{constructor(){this.steps=[]}addStep(e){this.steps.push(e)}async run(){for(const e of this.steps)e.program.run(e.getUniforms())}resizeOutput(e,t){this.profiler?.pushContext(`PIP [${this.constructor.name}]`);for(const n of this.steps)n.preventResize||n.program.resizeOutput(e,t);this.profiler?.popContext(`PIP [${this.constructor.name}]`)}setProfiler(e){this.profiler=e;for(const t of this.steps)t.program.setProfiler(e)}setId(e){for(const t of this.steps)t.program.id=e}}class Ur extends Or{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class Ai extends Ur{constructor(e){super(),this.context=e,this.preciseMaskEnabled=!0;const t={context:e,height:e.canvas.height,width:e.canvas.width},n=new Mr({...t,disableFramebuffer:!0});this.addStep({program:n,getUniforms:()=>({background:D(e,this.inputBackgroundImage),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}var lf=`precision mediump float;\n\nvarying vec2 _texture_coord;\nuniform sampler2D texture;\n\nvoid main() { gl_FragColor = texture2D(texture, _texture_coord); }\n`,df=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\nuniform bool invert_y;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n if (invert_y) {\n _texture_coord.y = 1. - texture_coord.y;\n }\n}\n`;class hf extends je{getFragmentShader(){return lf}getVertexShader(){return df}}class mf extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t};this.addStep({program:new hf({...i,disableFramebuffer:!0}),getUniforms:()=>({texture:D(e,this.inputImage),invert_y:!0})})}setData(e){this.inputImage=e}}async function Ii(r){return new Promise(e=>{setTimeout(()=>{e()},r)})}var pf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,gf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`,Nr=(r=>(r[r.LINEAR=0]="LINEAR",r[r.GAUSSIAN=1]="GAUSSIAN",r))(Nr||{});class Si extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return pf+this.createLoopFunction()}getVertexShader(){return gf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = 1.;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}var yf=`#version 300 es\n// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts\n\nprecision highp float;\nuniform sampler2D input_frame;\nuniform sampler2D segmentation_mask;\nuniform sampler2D threshold;\nuniform vec2 texel_size;\nuniform float step;\nuniform float radius;\nuniform float offset;\nuniform float sigma_texel;\nuniform float sigma_color;\n\nin vec2 _texture_coord;\nout vec4 outColor;\n\nfloat gaussian(float x, float sigma) {\n float coeff = -0.5 / (sigma * sigma * 4.0 + 1.0e-6);\n return exp((x * x) * coeff);\n}\n\nvoid main() {\n vec2 centerCoord = _texture_coord;\n vec3 centerColor = texture(input_frame, centerCoord).rgb;\n float newVal = 0.0;\n float spaceWeight = 0.0;\n float colorWeight = 0.0;\n float totalWeight = 0.0;\n // Subsample kernel space.\n for (float i = -radius + offset; i <= radius; i += step) {\n for (float j = -radius + offset; j <= radius; j += step) {\n vec2 shift = vec2(j, i) * texel_size;\n vec2 coord = vec2(centerCoord + shift);\n vec3 frameColor = texture(input_frame, coord).rgb;\n float threshold = texture(threshold, coord).a;\n float outVal = texture(segmentation_mask, coord).a;\n\n spaceWeight = gaussian(distance(centerCoord, coord), sigma_texel);\n colorWeight = gaussian(distance(centerColor, frameColor), sigma_color);\n totalWeight += spaceWeight * colorWeight;\n newVal += spaceWeight * colorWeight * outVal * threshold;\n }\n }\n newVal /= totalWeight;\n outColor = vec4(vec3(0.), newVal);\n}`,bf=`#version 300 es\nin vec2 position;\nin vec2 texture_coord;\nout vec2 _texture_coord;\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n _texture_coord = texture_coord;\n}`;class xf extends je{getFragmentShader(){return yf}getVertexShader(){return bf}}class _f extends Or{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t},s=new Si({...i,radius:1,type:Nr.GAUSSIAN});this.jointBilateral=new xf(i),this.addStep({program:s,getUniforms:()=>({inputs:D(e,this.inputMask)})}),this.addStep({program:this.jointBilateral,getUniforms:()=>{const a=this.inputImage?.width??1,c=this.inputImage?.height??1;this.inputMask?.width,this.inputMask?.height;const u=3,d=Math.max(1,Math.sqrt(u)*.66),m=1/a,p=1/c;return{input_frame:D(e,this.inputImage),segmentation_mask:D(e,this.inputMask),texel_size:[m,p],step:d,radius:u,offset:d>1?d*.5:0,sigma_texel:Math.max(m,p)*u,sigma_color:u}}}),this.output=this.jointBilateral.output}setData(e,t){this.previousInputImage=this.inputImage?this.inputImage:e,this.previousInputMask=this.inputMask?this.inputMask:t,this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t),this.output=this.jointBilateral.output}}class Ef{constructor(e){this.queries=[],this.context=e,this.extension=e.getExtension("EXT_disjoint_timer_query_webgl2")}start(){}stop(){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT)}pushContext(e){this.createQuery("PUSH",e)}popContext(e){this.createQuery("POP",e)}createQuery(e,t){this.activeQuery&&this.context.endQuery(this.extension.TIME_ELAPSED_EXT),this.activeQuery=this.context.createQuery(),this.context.beginQuery(this.extension.TIME_ELAPSED_EXT,this.activeQuery),this.queries.push({name:t,action:e,query:this.activeQuery})}async getResolvedQueries(){const e=(await Promise.all([...this.queries].map(t=>this.resolveQuery(t)))).filter(t=>t);for(let t=1;t<e.length;++t)e[t].timestamp+=e[t-1].duration+e[t-1].timestamp;return e}async resolveQuery(e){if(!await this.awaitQueryAvailable(e)){console.log("Unawaitable query",e);return}if(this.context.getParameter(this.extension.GPU_DISJOINT_EXT)){console.log("Disjointed query",e);return}return{...e,duration:this.context.getQueryParameter(e.query,this.context.QUERY_RESULT),timestamp:0}}async awaitQueryAvailable(e){for(let t=0;t<10;++t){if(this.context.getQueryParameter(e.query,this.context.QUERY_RESULT_AVAILABLE))return e;await Ii(200)}}}class Nt{constructor(){this.previousImageWidth=0,this.previousImageHeight=0,this.previousMaskWidth=Ce,this.previousMaskHeight=Ce,this.postProcessingEnabled=!0;const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl2 context";this.canvas=e,this.context=t,this.improveMask=new _f(this.context,Ce,Ce)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(e){const t=new Ef(this.context);return this.profiler=t,t.start(),await Ii(e),this.profiler=void 0,t.stop(),t.getResolvedQueries()}async render(e,t){if(!this.pipeline)throw"missing pipeline";(this.previousImageHeight!==e.height||this.previousImageWidth!==e.width)&&this.resizeOutput(e.width,e.height),(this.previousMaskHeight!==t.height||this.previousMaskWidth!==t.width)&&(this.improveMask.resizeOutput(t.width,t.height),this.previousMaskWidth=t.width,this.previousMaskHeight=t.height);const n="renderer";this.profiler?.pushContext(n),this.improveMask.setProfiler(this.profiler),this.pipeline.setProfiler(this.profiler);const i=await createImageBitmap(t);let s=i;return this.postProcessingEnabled&&(this.improveMask.setData(e,i),this.improveMask.run(),s=this.improveMask.output),this.pipeline.setData(e,s),await this.pipeline.run(),this.profiler?.popContext(n),this.canvas}resizeOutput(e,t){this.canvas.width=e,this.canvas.height=t,this.pipeline?.resizeOutput(e,t),this.previousImageWidth=e,this.previousImageHeight=t}destroy(){const e=this.context?.getExtension("WEBGL_lose_context");e&&e.loseContext()}}class Ri extends Nt{constructor(){super(),this.pipeline=new Ai(this.context);const e=new OffscreenCanvas(0,0),t=e.getContext("webgl2");if(!t)throw"Fail to retrieve webgl context";this.backgroundImageResizerCanvas=e,this.backgroundImageResizerContext=t,this.backgroundImageResizer=new mf(this.backgroundImageResizerContext,0,0)}setBackgroundImage(e){this.backgroundImage=e,this.updateBackgroundImage()}updateBackgroundImage(){const{width:e,height:t}=this.canvas;this.backgroundImageResizer.resizeOutput(e,t),this.backgroundImageResizer.setData(this.backgroundImage),this.backgroundImageResizer.run(),this.pipeline.inputBackgroundImage=this.backgroundImageResizerCanvas}resizeOutput(e,t){super.resizeOutput(e,t),this.backgroundImageResizerCanvas.width=e,this.backgroundImageResizerCanvas.height=t,this.backgroundImageResizer.resizeOutput(e,t),this.updateBackgroundImage()}destroy(){const e=this.backgroundImageResizerContext?.getExtension("WEBGL_lose_context");e&&e.loseContext(),super.destroy()}}class wf extends Ri{setBackgroundVideo(e){this.frameReader=e}async render(e,t){return await this.readNextVideoFrame(),super.render(e,t)}async readNextVideoFrame(){const e=await this.frameReader?.read();if(e?.value){const t=await createImageBitmap(e.value);this.setBackgroundImage(t),e.value.close()}}}class Fi{blurBackground(e){return new to(e)}blurSilhouette(e){return new ro(e)}imageBackground(){return new no}videoBackground(){return new wf}}var vf=`precision mediump float;\n\nvarying vec2 _texture_coord;\n\nuniform vec2 canvas;\nuniform sampler2D texture;\nuniform sampler2D mask;\n\nvec4 loop();\n\nvoid main() { gl_FragColor = loop(); }\n`,Tf=`varying vec2 _texture_coord;\n\nattribute vec2 position;\nattribute vec2 texture_coord;\n\nvoid main() {\n gl_Position = vec4(position, 0., 1.);\n _texture_coord = texture_coord;\n}\n`;class Af extends je{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return vf+this.createLoopFunction()}getVertexShader(){return Tf}createLoopFunction(){let e=this.options.radius??1;return`\n\n vec4 loop() { \n vec4 result = vec4(0,0,0,0);\n float factorSum = 0.;\n\n vec2 normalizedRadius = vec2(-${e}.) / canvas;\n vec2 normalizedIncrement = vec2(1.) / canvas;\n vec2 diff = normalizedRadius;\n float maxLength = length(normalizedRadius);\n\n for(int y=-${e}; y<${e+1}; ++y) {\n for(int x=-${e}; x<${e+1}; ++x) {\n float factor = (1.- texture2D(mask, _texture_coord + diff).a) * (maxLength - length(diff)) / maxLength;\n result += factor * texture2D(texture, _texture_coord + diff);\n factorSum += factor;\n diff.x += normalizedIncrement.x;\n }\n diff.y += normalizedIncrement.y;\n diff.x = normalizedRadius.x;\n }\n return result / factorSum;\n }`}}const If=10,Sf=2,Rf=8;class Ff extends Ur{constructor(e,t){super(),this.context=e,this.radius=t;const n={context:e,height:e.canvas.height,width:e.canvas.width};this.blur=new Af({...n,radius:t,...this.getBlurTextureSize(e.canvas.width,e.canvas.height)});const i=new Mr({...n,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:D(e,this.inputImage),mask:D(e,this.inputMask)})}),this.addStep({program:i,getUniforms:()=>({background:D(e,this.blur.output),foreground:D(e,this.inputImage),threshold:D(e,this.inputMask)})})}getBlurTextureSize(e,t){const n=this.radius>If?Rf:Sf;return{width:Math.max(Ce,e/n),height:Math.max(Ce,t/n)}}setData(e,t){this.inputImage=e,this.inputMask=t}resizeOutput(e,t){super.resizeOutput(e,t);const n=this.getBlurTextureSize(e,t);this.blur.resizeOutput(n.width,n.height)}}class Pf extends Nt{constructor(e){super(),this.pipeline=new Ff(this.context,e),this.disablePostProcessing()}}class kf extends Ur{constructor(e,t){super(),this.context=e;const n={context:e,height:e.canvas.height,width:e.canvas.width},i=new Si({...n,radius:t,type:Nr.GAUSSIAN}),s=new Mr({...n,disableFramebuffer:!0});this.addStep({program:i,getUniforms:()=>({texture:D(e,this.inputImage)})}),this.addStep({program:s,getUniforms:()=>({background:D(e,this.inputImage),foreground:D(e,i.output),threshold:D(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}class Cf extends Nt{constructor(e){super(),this.pipeline=new kf(this.context,e),this.disablePostProcessing()}}class Bf extends Ai{constructor(){super(...arguments),this.preciseMaskEnabled=!0}set reader(e){this.frameReader=e}async run(){this.frameReader&&(await this.readNextVideoFrame(),await super.run())}async readNextVideoFrame(){const e=await this.frameReader?.read();e?.value&&(this.inputBackgroundImage=await createImageBitmap(e.value),e.value.close())}}class Df extends Nt{constructor(){super(),this.pipeline=new Bf(this.context)}setBackgroundVideo(e){this.pipeline.reader=e}}class Pi{blurBackground(e){return new Pf(e)}blurSilhouette(e){return new Cf(e)}imageBackground(){return new Ri}videoBackground(){return new Df}}class Mf{constructor(e){switch(e){case gt.CANVAS:this.factory=new Fi;break;case gt.WEBGL:this.factory=new Pi;break;default:const t=eo();this.factory=t.supported?new Pi:new Fi}}blurBackground(e){return this.getFactory().blurBackground(e)}blurSilhouette(e){return this.getFactory().blurSilhouette(e)}imageBackground(){return this.getFactory().imageBackground()}videoBackground(){return this.getFactory().videoBackground()}getFactory(){if(!this.factory)throw"Factory is not initialized";return this.factory}}class Of{setBackgroundOptions(e){this.renderer&&this.renderer.destroy();const t=new Mf(e.renderingOptions?.type);switch(e.transformerType){case"BackgroundBlur":this.renderer=t.blurBackground(this.getBlurSize(e.radius));break;case"SilhouetteBlur":this.renderer=t.blurSilhouette(this.getBlurSize(e.radius));break;case"VideoBackground":const n=t.videoBackground();this.backgroundVideo&&n.setBackgroundVideo(this.backgroundVideo),this.renderer=n;break;case"VirtualBackground":const i=t.imageBackground();this.backgroundImage&&i.setBackgroundImage(this.backgroundImage),this.renderer=i;break;default:throw`Unknown rendering type [${e.transformerType}]`}e.renderingOptions?.type===gt.WEBGL&&(e.renderingOptions.selfieSegmentationType===tr.PRECISE?this.renderer.enablePostProcessing():e.renderingOptions.selfieSegmentationType===tr.FAST&&this.renderer.disablePostProcessing())}setVideoBGReadable(e){this.backgroundVideo=e.getReader();const t=this.renderer;t?.setBackgroundVideo&&t.setBackgroundVideo(this.backgroundVideo)}async setVirtualBGImage(e){const t=this.renderer;t?.setBackgroundImage&&t.setBackgroundImage(e),this.backgroundImage=e}async process(e,t){if(this.renderer)return this.renderer.render(e,t)}async resizeForeground(e,t){}getBlurSize(e=pt.Low){switch(e){case pt.Low:return 5;case pt.High:return 12}return e}async profile(e){return this.renderer?.profileWebgl(e)??[]}}var Uf=(function(){var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return(function(e){e=e||{};var t=typeof e<"u"?e:{},n,i;t.ready=new Promise(function(f,h){n=f,i=h});var s={},o;for(o in t)t.hasOwnProperty(o)&&(s[o]=t[o]);var a="./this.program",c=function(f,h){throw h},u=!0,d="";function m(f){return t.locateFile?t.locateFile(f,d):d+f}var p;typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),r&&(d=r),d.indexOf("blob:")!==0?d=d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):d="";var y=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);for(o in s)s.hasOwnProperty(o)&&(t[o]=s[o]);s=null,t.arguments&&t.arguments,t.thisProgram&&(a=t.thisProgram),t.quit&&(c=t.quit);var b;t.wasmBinary&&(b=t.wasmBinary),t.noExitRuntime,typeof WebAssembly!="object"&&ae("no native wasm support detected");var _,E=!1,R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function k(f,h,g){for(var w=h+g,S=h;f[S]&&!(S>=w);)++S;if(S-h>16&&f.subarray&&R)return R.decode(f.subarray(h,S));for(var C="";h<S;){var v=f[h++];if(!(v&128)){C+=String.fromCharCode(v);continue}var M=f[h++]&63;if((v&224)==192){C+=String.fromCharCode((v&31)<<6|M);continue}var H=f[h++]&63;if((v&240)==224?v=(v&15)<<12|M<<6|H:v=(v&7)<<18|M<<12|H<<6|f[h++]&63,v<65536)C+=String.fromCharCode(v);else{var Li=v-65536;C+=String.fromCharCode(55296|Li>>10,56320|Li&1023)}}return C}function N(f,h){return f?k(Xe,f,h):""}function Q(f,h,g){for(var w=0;w<f.length;++w)Lt[h++>>0]=f.charCodeAt(w);Lt[h>>0]=0}function q(f,h){return f%h>0&&(f+=h-f%h),f}var L,Lt,Xe,$;function Ci(f){L=f,t.HEAP8=Lt=new Int8Array(f),t.HEAP16=new Int16Array(f),t.HEAP32=$=new Int32Array(f),t.HEAPU8=Xe=new Uint8Array(f),t.HEAPU16=new Uint16Array(f),t.HEAPU32=new Uint32Array(f),t.HEAPF32=new Float32Array(f),t.HEAPF64=new Float64Array(f)}t.INITIAL_MEMORY;var zr,Bi=[],Di=[],Mi=[];function Yf(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)Kf(t.preRun.shift());Gr(Bi)}function Qf(){Gr(Di)}function qf(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)Zf(t.postRun.shift());Gr(Mi)}function Kf(f){Bi.unshift(f)}function Jf(f){Di.unshift(f)}function Zf(f){Mi.unshift(f)}var be=0,Ye=null;function el(f){be++,t.monitorRunDependencies&&t.monitorRunDependencies(be)}function tl(f){if(be--,t.monitorRunDependencies&&t.monitorRunDependencies(be),be==0&&Ye){var h=Ye;Ye=null,h()}}t.preloadedImages={},t.preloadedAudios={};function ae(f){t.onAbort&&t.onAbort(f),f="Aborted("+f+")",l(f),E=!0,f+=". Build with -s ASSERTIONS=1 for more info.";var h=new WebAssembly.RuntimeError(f);throw i(h),h}var rl="data:application/octet-stream;base64,";function Oi(f){return f.startsWith(rl)}var W;W="tflite-simd.wasm",Oi(W)||(W=m(W));function Ui(f){try{if(f==W&&b)return new Uint8Array(b);if(!p)throw"both async and sync fetching of the wasm failed"}catch(h){ae(h)}}function nl(){return!b&&u&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(f){if(!f.ok)throw"failed to load wasm binary file at \'"+W+"\'";return f.arrayBuffer()}).catch(function(){return Ui(W)}):Promise.resolve().then(function(){return Ui(W)})}function il(){var f={a:Al};function h(v,M){var H=v.exports;t.asm=H,_=t.asm.q,Ci(_.buffer),zr=t.asm.E,Jf(t.asm.r),tl()}el();function g(v){h(v.instance)}function w(v){return nl().then(function(M){return WebAssembly.instantiate(M,f)}).then(function(M){return M}).then(v,function(M){l("failed to asynchronously prepare wasm: "+M),ae(M)})}function S(){return!b&&typeof WebAssembly.instantiateStreaming=="function"&&!Oi(W)&&typeof fetch=="function"?fetch(W,{credentials:"same-origin"}).then(function(v){var M=WebAssembly.instantiateStreaming(v,f);return M.then(g,function(H){return l("wasm streaming compile failed: "+H),l("falling back to ArrayBuffer instantiation"),w(g)})}):w(g)}if(t.instantiateWasm)try{var C=t.instantiateWasm(f,h);return C}catch(v){return l("Module.instantiateWasm callback failed with error: "+v),!1}return S().catch(i),{}}function Gr(f){for(;f.length>0;){var h=f.shift();if(typeof h=="function"){h(t);continue}var g=h.func;typeof g=="number"?h.arg===void 0?zr.get(g)():zr.get(g)(h.arg):g(h.arg===void 0?null:h.arg)}}function sl(f,h,g,w){ae("Assertion failed: "+N(f)+", at: "+[h?N(h):"unknown filename",g,w?N(w):"unknown function"])}function ol(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function al(f,h){ae("To use dlopen, you need to use Emscripten\'s linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function cl(){ae("")}var zt;zt=function(){return performance.now()};var ul=!0;function fl(f){return $[Ni()>>2]=f,f}function ll(f,h){var g;if(f===0)g=Date.now();else if((f===1||f===4)&&ul)g=zt();else return fl(28),-1;return $[h>>2]=g/1e3|0,$[h+4>>2]=g%1e3*1e3*1e3|0,0}function dl(){return 2147483648}function hl(f,h,g){Xe.copyWithin(f,h,h+g)}function ml(f){try{return _.grow(f-L.byteLength+65535>>>16),Ci(_.buffer),1}catch{}}function pl(f){var h=Xe.length;f=f>>>0;var g=2147483648;if(f>g)return!1;for(var w=1;w<=4;w*=2){var S=h*(1+.2/w);S=Math.min(S,f+100663296);var C=Math.min(g,q(Math.max(f,S),65536)),v=ml(C);if(v)return!0}return!1}function gl(f){for(var h=zt();zt()-h<f;);}var $r={};function yl(){return a||"./this.program"}function Qe(){if(!Qe.strings){var f=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",h={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:f,_:yl()};for(var g in $r)$r[g]===void 0?delete h[g]:h[g]=$r[g];var w=[];for(var g in h)w.push(g+"="+h[g]);Qe.strings=w}return Qe.strings}var Gt={mappings:{},buffers:[null,[],[]],printChar:function(f,h){var g=Gt.buffers[f];h===0||h===10?((f===1?y:l)(k(g,0)),g.length=0):g.push(h)},varargs:void 0,get:function(){Gt.varargs+=4;var f=$[Gt.varargs-4>>2];return f},getStr:function(f){var h=N(f);return h},get64:function(f,h){return f}};function bl(f,h){var g=0;return Qe().forEach(function(w,S){var C=h+g;$[f+S*4>>2]=C,Q(w,C),g+=w.length+1}),0}function xl(f,h){var g=Qe();$[f>>2]=g.length;var w=0;return g.forEach(function(S){w+=S.length+1}),$[h>>2]=w,0}function _l(f){Sl(f)}function El(f){return 0}function wl(f,h,g,w,S){}function vl(f,h,g,w){for(var S=0,C=0;C<g;C++){for(var v=$[h+C*8>>2],M=$[h+(C*8+4)>>2],H=0;H<M;H++)Gt.printChar(f,Xe[v+H]);S+=M}return $[w>>2]=S,0}function Tl(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var f=new Uint8Array(1);return function(){return crypto.getRandomValues(f),f[0]}}else return function(){ae("randomDevice")}}function $t(f,h){$t.randomDevice||($t.randomDevice=Tl());for(var g=0;g<h;g++)Lt[f+g>>0]=$t.randomDevice();return 0}var Al={a:sl,e:ol,d:al,b:cl,n:ll,h:dl,l:hl,m:pl,p:gl,f:bl,g:xl,j:_l,i:El,k:wl,c:vl,o:$t};il(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.r).apply(null,arguments)},t._getModelBufferMemoryOffset=function(){return(t._getModelBufferMemoryOffset=t.asm.s).apply(null,arguments)},t._getInputMemoryOffset=function(){return(t._getInputMemoryOffset=t.asm.t).apply(null,arguments)},t._getInputHeight=function(){return(t._getInputHeight=t.asm.u).apply(null,arguments)},t._getInputWidth=function(){return(t._getInputWidth=t.asm.v).apply(null,arguments)},t._getInputChannelCount=function(){return(t._getInputChannelCount=t.asm.w).apply(null,arguments)},t._getOutputMemoryOffset=function(){return(t._getOutputMemoryOffset=t.asm.x).apply(null,arguments)},t._getOutputHeight=function(){return(t._getOutputHeight=t.asm.y).apply(null,arguments)},t._getOutputWidth=function(){return(t._getOutputWidth=t.asm.z).apply(null,arguments)},t._getOutputChannelCount=function(){return(t._getOutputChannelCount=t.asm.A).apply(null,arguments)},t._loadModel=function(){return(t._loadModel=t.asm.B).apply(null,arguments)},t._runInference=function(){return(t._runInference=t.asm.C).apply(null,arguments)},t._isGPUEnabled=function(){return(t._isGPUEnabled=t.asm.D).apply(null,arguments)};var Ni=t.___errno_location=function(){return(Ni=t.___errno_location=t.asm.F).apply(null,arguments)},Wt;function Il(f){this.name="ExitStatus",this.message="Program terminated with exit("+f+")",this.status=f}Ye=function f(){Wt||Wr(),Wt||(Ye=f)};function Wr(f){if(be>0||(Yf(),be>0))return;function h(){Wt||(Wt=!0,t.calledRun=!0,!E&&(Qf(),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),qf()))}t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),h()},1)):h()}t.run=Wr;function Sl(f,h){Rl(f)}function Rl(f){c(f,new Il(f))}if(t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return Wr(),e.ready})})();class Nf{constructor(){this.isSIMDSupported=!1,this.isThreadsSupported=!1,this.inputWidth=0,this.inputHeight=0,this.inputChannelCount=0,this.inputMemoryOffset=0,this.outputWidth=0,this.outputHeight=0,this.outputChannelCount=0,this.outputMemoryOffset=0}}const Lf="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",zf="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function Gf(r=Lf,e=zf){let t=new Nf;var n=new Promise(function(i,s){async function o(){return Uf({locateFile:function(u){return r+u}})}async function a(c){return new Promise(async(u,d)=>{const m=c;if(typeof m>"u")return d("TFLite backend unavailable: wasmSimd");let p=e;console.log("TFLite modelUrl: "+p);try{const l=await(await fetch(p)).arrayBuffer();console.log("Model buffer size:",l.byteLength);const b=m._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",b),console.log("Loading model buffer..."),m.HEAPU8.set(new Uint8Array(l),b);const _=m._loadModel(l.byteLength);if(console.log("Load model result:",_),_!==0){d("Cannot load model");return}t.inputWidth=m._getInputWidth(),t.inputHeight=m._getInputHeight(),t.inputChannelCount=m._getInputChannelCount(),t.inputMemoryOffset=m._getInputMemoryOffset(),console.log("Input memory offset:",t.inputMemoryOffset),console.log("Input height:",t.inputHeight),console.log("Input width:",t.inputWidth),console.log("Input channels:",t.inputChannelCount),t.outputMemoryOffset=m._getOutputMemoryOffset(),t.outputWidth=m._getOutputWidth(),t.outputHeight=m._getOutputHeight(),t.outputChannelCount=m._getOutputChannelCount(),console.log("Output memory offset:",t.outputMemoryOffset),console.log("Output height:",t.outputHeight),console.log("Output width:",t.outputWidth),console.log("Output channels:",t.outputChannelCount),t.selectedTFLite=m}catch(y){d(y);return}u()})}o().then(c=>{if(c===null)throw console.error("loadTFLite null"),"loadTFLite null";a(c).then(u=>{i(t)}).catch(u=>{console.error("loadTFLiteModel error"),s("loadTFLiteModel error")})}).catch(c=>{console.error("loadTFLite error:",c),s("loadTFLite error:"+c)})});return n}const $f=.1,Wf=.7,Vf="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class Hf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.width=0,this.height=0,this.gpuDelegate=!0}async createImageSegmenter(){if(!this.ImageSegmenter||!this.wasmFileset){console.warn("Mediapipe objects not loaded");return}this.imageSegmenter=await this.ImageSegmenter.createFromOptions(this.wasmFileset,{baseOptions:{modelAssetPath:this.modelAssetUriPath,delegate:this.gpuDelegate?"GPU":"CPU"},runningMode:"VIDEO",outputCategoryMask:!0,outputConfidenceMasks:!0})}async loadMediapipeAssets(e,t){this.modelAssetUriPath=e||Vf;const n=t?`${t}/task-vision.js`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/+esm",i=t?`${t}/wasm`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/wasm",{FilesetResolver:s,ImageSegmenter:o}=await import(n);this.ImageSegmenter=o,this.wasmFileset=await s.forVisionTasks(i)}async init(e,t,n){n===!1&&(this.gpuDelegate=!1),await this.loadMediapipeAssets(e,t),globalThis.document={},await this.createImageSegmenter()}async process(e){if(!this.imageSegmenter){console.warn("ImageSegmenter instance not available");return}(this.width!==e.width||this.height!==e.height)&&(this.canvas.width=this.width=e.width,this.canvas.height=this.height=e.height,this.mask&&(this.mask=new ImageData(this.width,this.height))),this.mask||(this.mask=new ImageData(this.width,this.height)),this.context.drawImage(e,0,0,e.width,e.height);const t=Date.now();let n;try{this.imageSegmenter?.segmentForVideo(this.context.getImageData(0,0,e.width,e.height),t,o=>{n=o.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{await this.createImageSegmenter();return}if(!n)return;if(!this.previousConfidenceMask){this.previousConfidenceMask=n.slice();return}const i=n.map((o,a)=>{const c=this.previousConfidenceMask?.[a];return c!==void 0?this.blend(c,o):o}),s=[255,0,0];for(let o=0;o<i?.length;o++){const a=1-i[o];a>$f?(a<Wf?(this.mask.data[o*4]=s[0]*a,this.mask.data[o*4+3]=255*a):(this.mask.data[o*4]=s[0],this.mask.data[o*4+3]=255),this.mask.data[o*4+1]=s[1],this.mask.data[o*4+2]=s[2]):this.mask.data[o*4]=this.mask.data[o*4+1]=this.mask.data[o*4+2]=this.mask.data[o*4+3]=0}return this.previousConfidenceMask=i.slice(),this.mask}isGpuSupported(){return!0}blend(e,t){const i=-.748699,s=-57.8051,o=291.309,a=-624.717,c=t-.5,u=c*c,d=1-Math.min(1,u*(5.68842+u*(i+u*(s+u*(o+u*a)))));return t+(e-t)*(d*.9)}}class jf{constructor(){this.canvas=new OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.pixelCount=0,this.inputOffset=0,this.outputOffset=0}async init(e,t,n){await this.initWasm(t,e),this.infos&&(this.canvas.width=this.infos.inputWidth,this.canvas.height=this.infos.inputHeight,this.pixelCount=this.infos.inputWidth*this.infos.inputHeight,this.mask=new ImageData(this.infos.inputWidth,this.infos.inputHeight),this.inputOffset=this.infos.inputMemoryOffset/4,this.outputOffset=this.infos.outputMemoryOffset/4)}async initWasm(e,t){this.infos=await Gf(e,t)}async process(e){if(!this.mask||!this.infos)return;const t=this.infos.inputWidth,n=this.infos.inputHeight;this.context.drawImage(e,0,0,e.width,e.height,0,0,t,n);const i=this.context.getImageData(0,0,t,n),s=this.infos.selectedTFLite.HEAPF32;for(let o=0;o<this.pixelCount;o++){const a=this.inputOffset+o*3;s[a]=i.data[o*4]/255,s[a+1]=i.data[o*4+1]/255,s[a+2]=i.data[o*4+2]/255}this.infos.selectedTFLite._runInference();for(let o=0;o<this.pixelCount;o++){const a=this.infos.selectedTFLite.HEAPF32[this.outputOffset+o];this.mask.data[o*4]=this.mask.data[o*4+3]=255*a}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class Xf{constructor(){this.reporter=new Js,this.isEnabled=!0}async init(e,t){t.segmentationOptions?.lightWeightEngine===!0?this.selfieSegmentation=new jf:this.selfieSegmentation=new Hf,this.selfieSegmentation?.init(t.modelAssetUriPath,t.mediapipeBaseAssetsUri,t.segmentationOptions?.gpuSupport),this.backgroundFilter=new Of,this.report({variation:"Create"})}async transform(e,t){if(!this.isEnabled)return t.enqueue(e);let n;const i=e.timestamp??0,s=await createImageBitmap(e),o=await this.selfieSegmentation?.process(s);o&&(n=await this.backgroundFilter?.process(s,o)),n?(e.close(),t.enqueue(new VideoFrame(n,{timestamp:i,alpha:"discard"}))):t.enqueue(e)}async setBackgroundOptions(e){this.backgroundOptions=e,this.backgroundFilter?.setBackgroundOptions(e),this.report({variation:"Update"})}setVideoBGReadable(e){this.backgroundFilter?.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundFilter?.setVirtualBGImage(e)}async profile(e){return this.backgroundFilter?.profile(e)??[]}getTransformerType(){return this.backgroundOptions?.transformerType??"Undefined"}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}report(e){this.reporter.send({version:Zs,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...e})}}const Lr=class Lr{constructor(){this.backgroundTransformer=new Xf,this.mediaProcessor=new Rs,this.rate=30,this.eventsQueue=[],this.frameTransformLatencyMs=[]}async init(e,t){this.frameTransformLatencyMs=[],await this.backgroundTransformer.init(e,t),await this.mediaProcessor.setTransformers([this.backgroundTransformer]),this.mediaProcessor.setTrackExpectedRate(this.rate),this.mediaProcessor.onAny((n,i)=>{this.resolveOnMediaProcessor?(this.resolveOnMediaProcessor({name:n,data:i}),this.resolveOnMediaProcessor=void 0):this.eventsQueue.push({name:n,data:i})})}enable(){this.backgroundTransformer.enable()}disable(){this.backgroundTransformer.disable()}async onMediaProcessorEvent(){return await new Promise(e=>{this.eventsQueue.length>0?e(this.eventsQueue.shift()):this.resolveOnMediaProcessor=e})}async setTrackExpectedRate(e){this.rate=e,this.mediaProcessor.setTrackExpectedRate(e)}async transform(e,t){let n=this.mediaProcessor.transform(e,t),i=performance.now();return this.frameTransformLatencyMs.push(performance.now()-i),n}async setBackgroundOptions(e){await this.backgroundTransformer?.setBackgroundOptions(e)}setVideoBGReadable(e){this.backgroundTransformer.setVideoBGReadable(e)}async setVirtualBGImage(e){await this.backgroundTransformer.setVirtualBGImage(e)}async terminate(){await this.mediaProcessor.destroy();const t=this.frameTransformLatencyMs.reduce((n,i)=>n+i,0)/this.frameTransformLatencyMs.length||0;console.log(`Transform latency average is: ${t} ms`)}setVonageMetadata(e){_s(e)}async profile(e){return JSON.stringify(await this.backgroundTransformer.profile(e))}};Vi("ProcessorWorker",Lr);let ki=Lr})();\n//# sourceMappingURL=processor-worker-CR7IjkAn.js.map\n',ii=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",_o],{type:"text/javascript;charset=utf-8"});function Pd(e){let t;try{if(t=ii&&(self.URL||self.webkitURL).createObjectURL(ii),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(_o),{name:e?.name})}}const Jt=class e extends et{constructor(e){super(),this.rate=30,this.isEnabled=!0,this.config=e}async setTrackExpectedRate(e){await this.startWorker(),await(this.worker?.setTrackExpectedRate(e))}async setBackgroundOptions(e){this.backgroundOptions=e,await this.updateBackgroundOptions(e)}async transform(e,t){return await this.startWorker(),await(this.worker?.transform(e,t))}async destroy(){await(this.worker?.terminate()),this.worker=void 0}async profile(e){const t=await(this.worker?.profile(e));return JSON.parse(t??"[]")}async enable(){this.isEnabled=!0,await(this.worker?.enable())}async disable(){this.isEnabled=!1,await(this.worker?.disable())}async listenWorker(){for(;this.worker?.workerContext.worker;){const{name:e,data:t}=await(this.worker?.onMediaProcessorEvent());switch(e){case"error":case"warn":this.emit(e,t);break;case"pipelineInfo":switch(this.emit(e,t),t){case"pipeline_ended":case"pipeline_ended_with_error":return void await this.destroy()}}}}async startWorker(){!this.config||this.worker||(this.worker=await sa(Mr,Pd),this.isEnabled||await this.worker.disable(),await this.worker.init("worker_"+e.initCount++,this.config),await this.worker.setVonageMetadata(Tt()),this.backgroundOptions?await this.setBackgroundOptions(this.backgroundOptions):await this.setBackgroundOptions(this.config),this.listenWorker())}async updateBackgroundOptions(e){await this.startWorker();const{transformerType:t}=e;switch(t){case"VideoBackground":await(this.worker?.setVideoBGReadable(await zn.createVideoReadable(e.backgroundAssetUri)));break;case"VirtualBackground":await(this.worker?.setVirtualBGImage(await zn.createImageCanvas(e.backgroundAssetUri)))}await(this.worker?.setBackgroundOptions(e))}};Jt.initCount=0;let Br=Jt;class Fd{constructor(e){this.queries=e}async downloadSpeedscope(){this.download(await this.convertToSpeedscope())}download(e){const t=document.createElement("a");t.href=URL.createObjectURL(new Blob([e],{type:"application/json"})),t.download=`profile-${+new Date}.speedscope.json`,document.body.appendChild(t),t.click(),document.body.removeChild(t)}convertToSpeedscope(){const e=[],t={},r=[];let n=0;for(const i of this.queries){const o=[];for(const r of i)void 0===t[r.name]&&(t[r.name]=e.length,e.push({name:r.name})),o.push({type:r.action==xo.PUSH?"O":"C",frame:t[r.name],at:r.timestamp}),n=Math.max(n,r.timestamp+r.duration);r.push({events:o,type:"evented",name:"GPU Profile",unit:"nanoseconds",startValue:0,endValue:n})}return JSON.stringify({$schema:"https://www.speedscope.app/file-format-schema.json",shared:{frames:e},profiles:r},null,2)}}const gn=class extends et{constructor(e){super(),this.worker=new Br(e),this.connector=new js(this.worker),this.worker.onAny((e,t)=>this.emit(e,t))}async setBackgroundOptions(e){await this.worker.setBackgroundOptions(e)}async enable(){await this.worker.enable()}async disable(){await this.worker.disable()}setTrackExpectedRate(e){this.worker.setTrackExpectedRate(e)}getConnector(){return this.connector}async profile(e){return this.worker.profile(e)}static async profile(e){const t=await Promise.all(this.instances.map(t=>t.profile(e)));return new Fd(t)}static async create(e){const t=new this(e);return this.instances.push(t),t}};gn.instances=[];let Dr=gn;async function Bd(e){return await Dr.create(e)}export{kd as BackgroundTransformer,Ys as BackgroundTransformerType,It as BlurRadius,Ds as ErrorFunction,Er as PipelineInfoData,Mt as RenderingType,Dr as VonageMediaProcessor,Bs as WarningType,Ar as WebglSelfieSegmentationType,Bd as createVonageMediaProcessor,qs as getSupportedBrowserFeatures,Md as isSupported};