@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.
- package/dist/assets/processor-worker-CR7IjkAn.js.map +1 -0
- package/dist/ml-transformers.es.js +3371 -22011
- package/dist/ml-transformers.es.js.map +1 -1
- package/dist/ml-transformers.min.js +1 -1
- package/dist/ml-transformers.static.js +3371 -22011
- package/dist/ml-transformers.umd.js +32 -151
- package/dist/ml-transformers.umd.js.map +1 -1
- package/dist/types/lib/main.d.ts +3 -121
- package/dist/types/lib/src/renderers/canvas2d/renderers/canvas2d-renderer.d.ts +0 -2
- package/dist/types/lib/src/renderers/webgl/pipelines/improve-segmentation-mask.d.ts +0 -12
- package/dist/types/lib/src/renderers/webgl/programs/blur/blur.d.ts +0 -3
- package/dist/types/lib/src/transformers/background-transformer.d.ts +2 -2
- package/dist/types/lib/src/types.d.ts +0 -56
- package/dist/types/lib/src/utils/webgl.d.ts +1 -16
- package/package.json +4 -11
- package/dist/assets/processor-worker-Ct1XXlKJ.js.map +0 -1
- package/dist/types/lib/src/renderers/webgl/programs/expend/expend.d.ts +0 -5
- package/dist/types/lib/src/renderers/webgl/programs/flickering/flickering.d.ts +0 -5
- package/dist/types/lib/src/renderers/webgl/programs/highpass/highpass.d.ts +0 -5
- package/dist/types/lib/src/renderers/webgl/programs/minimum-surface/minimum-surface.d.ts +0 -5
- package/dist/types/lib/src/renderers/webgl/programs/power/power.d.ts +0 -5
- package/dist/types/lib/src/renderers/webgl/programs/refine-mask/refine-mask.d.ts +0 -5
- package/dist/types/lib/src/renderers/webgl/programs/smooth/smooth.d.ts +0 -5
- package/dist/types/lib/src/renderers/webgl/programs/track/track.d.ts +0 -5
- package/dist/types/lib/src/renderers/webgl/webgl-pipeline-program-double-buffer.d.ts +0 -15
- package/dist/types/lib/src/utils/error.d.ts +0 -1
- package/dist/types/lib/src/utils/mediapipe.d.ts +0 -11
|
@@ -1,136 +1,17 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
data: ${R}`)})}logIfDebugEnabled(t,n,p){(en.isDebugEnabled||this.debug.enabled)&&this.debug.logger(t,this.debug.name,n,p)}on(t,n,{signal:p}={}){gi(n),t=Array.isArray(t)?t:[t];for(const R of t){On(R);let k=In(this,R);k||(k=new Set,yn.get(this).set(R,k)),k.add(n),this.logIfDebugEnabled("subscribe",R,void 0),kn(R)||mi(this,fi,{eventName:R,listener:n})}const y=()=>{this.off(t,n),p?.removeEventListener("abort",y)};return p?.addEventListener("abort",y,{once:!0}),p?.aborted&&y(),y}off(t,n){gi(n),t=Array.isArray(t)?t:[t];for(const p of t){On(p);const y=In(this,p);y&&(y.delete(n),y.size===0&&yn.get(this).delete(p)),this.logIfDebugEnabled("unsubscribe",p,void 0),kn(p)||mi(this,hi,{eventName:p,listener:n})}}once(t,n){if(n!==void 0&&typeof n!="function")throw new TypeError("predicate must be a function");let p;const y=new Promise(R=>{p=this.on(t,k=>{n&&!n(k)||(p(),R(k))})});return y.off=p,y}events(t){t=Array.isArray(t)?t:[t];for(const n of t)On(n);return _s(this,t)}async emit(t,n){if(On(t),kn(t)&&!di)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",t,n),Eu(this,t,n);const p=In(this,t)??new Set,y=nn.get(this),R=[...p],k=kn(t)?[]:[...y];await xs,await Promise.all([...R.map(async O=>{if(p.has(O))return O(n)}),...k.map(async O=>{if(y.has(O))return O(t,n)})])}async emitSerial(t,n){if(On(t),kn(t)&&!di)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",t,n);const p=In(this,t)??new Set,y=nn.get(this),R=[...p],k=[...y];await xs;for(const O of R)p.has(O)&&await O(n);for(const O of k)y.has(O)&&await O(t,n)}onAny(t,{signal:n}={}){gi(t),this.logIfDebugEnabled("subscribeAny",void 0,void 0),nn.get(this).add(t),mi(this,fi,{listener:t});const p=()=>{this.offAny(t),n?.removeEventListener("abort",p)};return n?.addEventListener("abort",p,{once:!0}),n?.aborted&&p(),p}anyEvent(){return _s(this)}offAny(t){gi(t),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),mi(this,hi,{listener:t}),nn.get(this).delete(t)}clearListeners(t){t=Array.isArray(t)?t:[t];for(const n of t)if(this.logIfDebugEnabled("clear",n,void 0),pi(n)){const p=In(this,n);p&&p.clear();const y=$n(this,n);if(y){for(const R of y)R.finish();y.clear()}}else{nn.get(this).clear();for(const[p,y]of yn.get(this).entries())y.clear(),yn.get(this).delete(p);for(const[p,y]of qr.get(this).entries()){for(const R of y)R.finish();y.clear(),qr.get(this).delete(p)}}}listenerCount(t){t=Array.isArray(t)?t:[t];let n=0;for(const p of t){if(pi(p)){n+=nn.get(this).size+(In(this,p)?.size??0)+($n(this,p)?.size??0)+($n(this)?.size??0);continue}p!==void 0&&On(p),n+=nn.get(this).size;for(const y of yn.get(this).values())n+=y.size;for(const y of qr.get(this).values())n+=y.size}return n}bindMethods(t,n){if(typeof t!="object"||t===null)throw new TypeError("`target` must be an object");n=Es(n);for(const p of n){if(t[p]!==void 0)throw new Error(`The property \`${p}\` already exists on \`target\``);Object.defineProperty(t,p,{enumerable:!1,value:this[p].bind(this)})}}}const As=Object.getOwnPropertyNames(en.prototype).filter(i=>i!=="constructor");Object.defineProperty(en,"listenerAdded",{value:fi,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(en,"listenerRemoved",{value:hi,writable:!1,enumerable:!0,configurable:!1});var Au=Object.defineProperty,Tu=(i,t,n)=>t in i?Au(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,Su=(i,t,n)=>(Tu(i,t+"",n),n);const Ru="hlg.tokbox.com/prod/logging/vcp_webrtc",Fu="https://",Ou=1e4;let yi;const Iu=new Uint8Array(16);function ku(){if(!yi&&(yi=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!yi))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yi(Iu)}const Lr=[];for(let i=0;i<256;++i)Lr.push((i+256).toString(16).slice(1));function Pu(i,t=0){return(Lr[i[t+0]]+Lr[i[t+1]]+Lr[i[t+2]]+Lr[i[t+3]]+"-"+Lr[i[t+4]]+Lr[i[t+5]]+"-"+Lr[i[t+6]]+Lr[i[t+7]]+"-"+Lr[i[t+8]]+Lr[i[t+9]]+"-"+Lr[i[t+10]]+Lr[i[t+11]]+Lr[i[t+12]]+Lr[i[t+13]]+Lr[i[t+14]]+Lr[i[t+15]]).toLowerCase()}const Cu=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ts={randomUUID:Cu};function Mu(i,t,n){if(Ts.randomUUID&&!i)return Ts.randomUUID();i=i||{};const p=i.random||(i.rng||ku)();return p[6]=p[6]&15|64,p[8]=p[8]&63|128,Pu(p)}function wo(i,t){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let n=globalThis.vonage.workerizer;return n[i]||(n[i]=t),n[i]}const on=wo("globals",{});var vn=(i=>(i.INIT="INIT",i.FORWARD="FORWARD",i.TERMINATE="TERMINATE",i.GLOBALS_SYNC="GLOBALS_SYNC",i))(vn||{});function Ss(i){return[ImageBitmap,ReadableStream,WritableStream].some(t=>i instanceof t)}let ju=0;function Lu(i,t,n,p,y){const R=ju++;return i.postMessage({id:R,type:t,functionName:n,args:p},p.filter(k=>Ss(k))),new Promise(k=>{y?.set(R,k)})}function Yn(i,t){const{id:n,type:p}=i,y=Array.isArray(t)?t:[t];postMessage({id:n,type:p,result:t},y.filter(R=>Ss(R)))}const Rs=wo("workerized",{});function Fs(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function Uu(){if(Fs())Yn({type:vn.GLOBALS_SYNC},on);else{const i=[];for(const t in Rs){const{worker:n,resolvers:p}=Rs[t].workerContext;n&&i.push(Lu(n,vn.GLOBALS_SYNC,"",[on],p))}await Promise.all(i)}}function vi(i,t){if(Array.isArray(t))t.splice(0,t.length);else if(typeof t=="object")for(const n in t)delete t[n];for(const n in i)Array.isArray(i[n])?(t[n]=[],vi(i[n],t[n])):typeof i[n]=="object"?(t[n]={},vi(i[n],t[n])):t[n]=i[n]}async function Bu(i,t){const{functionName:n,args:p}=i;if(!t.instance)throw"instance not initialized";if(!n)throw"missing function name to call";if(!t.instance[n])throw`undefined function [${n}] in class ${t.instance.constructor.workerId}`;Yn(i,await t.instance[n](...p??[]))}const Nu=wo("registeredWorkers",{});function Du(i,t){if(!i.args)throw"Missing className while initializing worker";const[n,p]=i.args,y=Nu[n];if(y)t.instance=new y(i.args.slice(1));else throw`unknown worker class ${n}`;vi(p,on),Yn(i,typeof t.instance!==void 0)}async function Gu(i,t){const{args:n}=i;if(!t.instance)throw"instance not initialized";let p;t.instance.terminate&&(p=await t.instance.terminate(...n??[])),Yn(i,p)}function Wu(i){if(!i.args)throw"Missing globals while syncing";vi(i.args[0],on),Yn(i,{})}function zu(){const i={};onmessage=async t=>{const n=t.data;switch(n.type){case vn.INIT:Du(n,i);break;case vn.FORWARD:Bu(n,i);break;case vn.TERMINATE:Gu(n,i);break;case vn.GLOBALS_SYNC:Wu(n);break}}}Fs()&&zu();function Hu(i,t){return on[i]||(on[i]=t),[()=>on[i],async n=>{on[i]=n,await Uu()}]}function Vu(i,t){return Hu(i,t)}const[$u,Yu]=Vu("metadata");function Xu(i){Yu(i)}function bi(){return $u()}let xo=class{constructor(t,n){Su(this,"uuid"),this.config=t,this.uuid=n??Mu()}async send(t){var n,p,y;const{appId:R,sourceType:k}=(n=bi())!=null?n:{};if(!R||!k)return"metadata missing";const O=new AbortController,L=setTimeout(()=>O.abort(),Ou);return await((y=(p=this.config)==null?void 0:p.fetch)!=null?y:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(t)),signal:O.signal}),clearTimeout(L),"success"}getUrl(){var t;let n=(t=bi().proxyUrl)!=null?t:Fu;return n+=(n.at(-1)==="/"?"":"/")+Ru,n}getHeaders(){return{"Content-Type":"application/json"}}buildReport(t){const n=bi();return{guid:this.uuid,...t,applicationId:n.appId,timestamp:Date.now(),proxyUrl:n.proxyUrl,source:n.sourceType}}};const wi="3.0.0-alpha.2",_o=class{};_o.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},_o.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 bn=_o;function Ku(i){return typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"}function Qu(i){if(Ku(i))return i;try{return new Error(JSON.stringify(i))}catch{return new Error(String(i))}}function Eo(i){return Qu(i).message}class Ju{constructor(t,n){this.config=t,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new xo(t,n)}async onFrameFromSource(){this.frameFromSourceCount++}get fps(){const{startAt:t,frameFromSourceCount:n}=this,p=(Date.now()-t)/1e3;return n/p}async onFrameTransformed(t={},n=!1){this.startAt===0&&(this.startAt=Date.now()),this.frameTransformedCount++;const{startAt:p,frameTransformedCount:y,frameFromSourceCount:R}=this,k=Date.now(),O=(k-p)/1e3,L=y/O,te=R/O;return n||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=k,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:te,transformedFps:L,framesTransformed:y,...t})):"success"}}var Os=(i=>(i.FPS_DROP="fps_drop",i))(Os||{}),Is=(i=>(i.start="start",i.transform="transform",i.flush="flush",i))(Is||{}),xi=(i=>(i.pipeline_ended="pipeline_ended",i.pipeline_ended_with_error="pipeline_ended_with_error",i.pipeline_started="pipeline_started",i.pipeline_started_with_error="pipeline_started_with_error",i.pipeline_restarted="pipeline_restarted",i.pipeline_restarted_with_error="pipeline_restarted_with_error",i))(xi||{});const Zu=500,qu=.8;class ec extends en{constructor(t,n){super(),this.reporter_=new xo,this.reporterQos_=new Ju({loggingIntervalFrameCount:Zu,report:{version:wi}}),this.index_=n,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_&&typeof this.transformer_.start=="function")try{await this.transformer_.start(t)}catch(n){this.report({message:bn.errors.transformer_start,variation:"Error",error:Eo(n)});const p={eventMetaData:{transformerIndex:this.index_},error:n,function:"start"};this.emit("error",p)}}async transform(t,n){if(this.mediaTransformerQosReportStartTimestamp_===0&&(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(n),n.terminate();else{try{await this.transformer_.transform?.(t,n),this.reportQos()}catch(p){this.report({message:bn.errors.transformer_transform,variation:"Error",error:Eo(p)});const y={eventMetaData:{transformerIndex:this.index_},error:p,function:"transform"};this.emit("error",y)}if(this.trackExpectedRate_!=-1&&this.trackExpectedRate_*qu>this.reporterQos_.fps){const p={eventMetaData:{transformerIndex:this.index_},warningType:"fps_drop",dropInfo:{requested:this.trackExpectedRate_,current:this.reporterQos_.fps}};this.emit("warn",p)}}}async flush(t){if(this.transformer_&&typeof this.transformer_.flush=="function"&&!this.isFlashed_){this.isFlashed_=!0;try{await this.transformer_.flush(t)}catch(n){this.report({message:bn.errors.transformer_flush,variation:"Error",error:Eo(n)});const p={eventMetaData:{transformerIndex:this.index_},error:n,function:"flush"};this.emit("error",p)}}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:wi,action:"MediaTransformer",transformerType:this.transformerType_,...t})}reportQos(t=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:wi,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},t)}}class tc extends en{constructor(t){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let n=0;n<t.length;n++){let p=new ec(t[n],n);p.on("error",y=>{this.emit("error",y)}),p.on("warn",y=>{this.emit("warn",y)}),this.transformers_.push(p)}}setTrackExpectedRate(t){this.trackExpectedRate_=t;for(let n of this.transformers_)n.setTrackExpectedRate(this.trackExpectedRate_)}async start(t,n){if(!this.transformers_||this.transformers_.length===0){console.log("[Pipeline] No transformers.");return}try{let p=t;for(let y of this.transformers_)t=t.pipeThrough(new TransformStream(y));t.pipeTo(n).then(async()=>{console.log("[Pipeline] Setup."),await n.abort(),await p.cancel(),this.emit("pipelineInfo","pipeline_ended")}).catch(async y=>{t.cancel().then(()=>{console.log("[Pipeline] Shutting down streams after abort.")}).catch(R=>{console.error("[Pipeline] Error from stream transform:",R)}),await n.abort(y),await p.cancel(y),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 t of this.transformers_)t.stop()}}class ks extends en{constructor(){super(),this.reporter_=new xo,this.trackExpectedRate_=-1,this.report({variation:"Create"})}setTrackExpectedRate(t){this.trackExpectedRate_=t,this.pipeline_&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_)}async transform(t,n){if(this.isTrack(t)){if(t.kind==="video"){const p=new MediaStreamTrackProcessor({track:t}),y=new VideoTrackGenerator;return this.readable_=p.readable,this.writable_=y.writable,await this.transformInternal(),y.track}throw Error("Cannot process audio tracks inside a web worker when passing a track to transform")}else return this.readable_=t,this.writable_=n,this.transformInternal()}transformInternal(){return new Promise(async(t,n)=>{if(!this.transformers_||this.transformers_.length===0){this.report({message:bn.errors.transformer_none,variation:"Error"}),n("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:bn.errors.readable_null}),n("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:bn.errors.writable_null}),n("[MediaProcessor] Writable is null.");return}let p=!1;this.pipeline_&&(p=!0,this.pipeline_.clearListeners(),this.pipeline_.destroy()),this.pipeline_=new tc(this.transformers_),this.pipeline_.on("warn",y=>{this.emit("warn",y)}),this.pipeline_.on("error",y=>{this.emit("error",y)}),this.pipeline_.on("pipelineInfo",y=>{p&&(y==="pipeline_started"?y=xi.pipeline_restarted:y==="pipeline_started_with_error"&&(y=xi.pipeline_restarted_with_error)),this.emit("pipelineInfo",y)}),this.trackExpectedRate_!=-1&&this.pipeline_.setTrackExpectedRate(this.trackExpectedRate_),this.pipeline_.start(this.readable_,this.writable_).then(()=>{t()}).catch(y=>{n(y)})})}setTransformers(t){return this.report({variation:"Update",message:bn.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:wi,action:"MediaProcessor",...t})}isTrack(t){return"kind"in t}}class rc{constructor(){this.processor_=null,this.generator_=null}init(t){return new Promise((n,p)=>{try{this.processor_=new MediaStreamTrackProcessor(t)}catch(y){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${y}`),p(y)}try{t.kind==="audio"?this.generator_=new MediaStreamTrackGenerator({kind:"audio"}):t.kind==="video"?this.generator_=new MediaStreamTrackGenerator({kind:"video"}):p("kind not supported")}catch(y){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${y}`),p(y)}n()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class nc{constructor(t){this.mediaProcessor_=t}async setTrack(t){if(!(this.mediaProcessor_ instanceof ks)&&await ws()){if(t.kind==="audio")throw Error("Cannot process audio tracks inside a web worker when passing a track to transform");return await this.mediaProcessor_.transform(t)}if(bs()){const n=new rc;return await n.init(t),await this.mediaProcessor_.transform(n.getReadable(),n.getWriteable()),n.getProccesorTrack()}throw Error("MediaStreamTrack API for Insertable Streams of Media is not supported")}destroy(){return new Promise((t,n)=>{this.mediaProcessor_?this.mediaProcessor_.destroy().then(()=>{t()}).catch(p=>{n(p)}):n("no processor")})}}var Xn=(i=>(i.Low="Low",i.High="High",i))(Xn||{}),Ps=(i=>(i.BackgroundBlur="BackgroundBlur",i.VirtualBackground="VirtualBackground",i.VideoBackground="VideoBackground",i.SilhouetteBlur="SilhouetteBlur",i))(Ps||{}),_i=(i=>(i.FAST="FAST",i.PRECISE="PRECISE",i))(_i||{}),Kn=(i=>(i.CANVAS="CANVAS",i.WEBGL="WEBGL",i))(Kn||{});const ic=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 oc(){const{wasm:i,insertableStreams:t,simd:n,webgl:p}=await Cs();if(!i.supported)throw i.message;if(!t.supported)throw t.message;if(!n.supported)throw n.message;if(!p.supported)throw p.message}async function Cs(){const i={wasm:{supported:typeof WebAssembly=="object"&&typeof WebAssembly.instantiate=="function",message:"Your browser does not support WebAssembly features."},simd:{supported:await ic(),message:"Your browser does not support simd features."},insertableStreams:{supported:!0},gpu:{message:"Your browser does not support gpu features.",supported:!0},webgl:sc(),performance:Ms()};try{await xu()}catch(t){i.insertableStreams.supported=!1,i.insertableStreams.message=t}return i}function sc(){if(!OffscreenCanvas)return{supported:!1,message:"Your browser does not support offscreen canvas"};const t=new OffscreenCanvas(0,0).getContext("webgl2");if(t){const n=t?.getExtension("WEBGL_lose_context");n&&n.loseContext()}else return{supported:!1,message:"Your browser does not support webgl 2"};return{supported:!0}}function Ms(){const t=new OffscreenCanvas(0,0).getContext("webgl2",{failIfMajorPerformanceCaveat:!0});if(t){const n=t?.getExtension("WEBGL_lose_context");n&&n.loseContext()}else return{supported:!1,message:"Your hardware does not perform good enough to run the library efficiently"};return{supported:!0}}const Ei={};(function(){var i;function t(g){var E=0;return function(){return E<g.length?{done:!1,value:g[E++]}:{done:!0}}}var n=typeof Object.defineProperties=="function"?Object.defineProperty:function(g,E,A){return g==Array.prototype||g==Object.prototype||(g[E]=A.value),g};function p(g){g=[typeof globalThis=="object"&&globalThis,g,typeof window=="object"&&window,typeof self=="object"&&self,typeof global=="object"&&global];for(var E=0;E<g.length;++E){var A=g[E];if(A&&A.Math==Math)return A}throw Error("Cannot find global object")}var y=p(this);function R(g,E){if(E)e:{var A=y;g=g.split(".");for(var N=0;N<g.length-1;N++){var Y=g[N];if(!(Y in A))break e;A=A[Y]}g=g[g.length-1],N=A[g],E=E(N),E!=N&&E!=null&&n(A,g,{configurable:!0,writable:!0,value:E})}}R("Symbol",function(g){function E(oe){if(this instanceof E)throw new TypeError("Symbol is not a constructor");return new A(N+(oe||"")+"_"+Y++,oe)}function A(oe,$){this.g=oe,n(this,"description",{configurable:!0,writable:!0,value:$})}if(g)return g;A.prototype.toString=function(){return this.g};var N="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",Y=0;return E}),R("Symbol.iterator",function(g){if(g)return g;g=Symbol("Symbol.iterator");for(var E="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),A=0;A<E.length;A++){var N=y[E[A]];typeof N=="function"&&typeof N.prototype[g]!="function"&&n(N.prototype,g,{configurable:!0,writable:!0,value:function(){return k(t(this))}})}return g});function k(g){return g={next:g},g[Symbol.iterator]=function(){return this},g}function O(g){var E=typeof Symbol<"u"&&Symbol.iterator&&g[Symbol.iterator];return E?E.call(g):{next:t(g)}}function L(g){if(!(g instanceof Array)){g=O(g);for(var E,A=[];!(E=g.next()).done;)A.push(E.value);g=A}return g}var te=typeof Object.create=="function"?Object.create:function(g){function E(){}return E.prototype=g,new E},ue;if(typeof Object.setPrototypeOf=="function")ue=Object.setPrototypeOf;else{var pe;e:{var Oe={a:!0},Me={};try{Me.__proto__=Oe,pe=Me.a;break e}catch{}pe=!1}ue=pe?function(g,E){if(g.__proto__=E,g.__proto__!==E)throw new TypeError(g+" is not extensible");return g}:null}var ce=ue;function he(g,E){if(g.prototype=te(E.prototype),g.prototype.constructor=g,ce)ce(g,E);else for(var A in E)if(A!="prototype")if(Object.defineProperties){var N=Object.getOwnPropertyDescriptor(E,A);N&&Object.defineProperty(g,A,N)}else g[A]=E[A];g.ea=E.prototype}function Ge(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function Ve(g){if(g.l)throw new TypeError("Generator is already running");g.l=!0}Ge.prototype.o=function(g){this.h=g};function ct(g,E){g.j={U:E,V:!0},g.g=g.m||g.s}Ge.prototype.return=function(g){this.j={return:g},this.g=this.s};function J(g,E,A){return g.g=A,{value:E}}function Jt(g){this.g=new Ge,this.h=g}function mr(g,E){Ve(g.g);var A=g.g.i;return A?At(g,"return"in A?A.return:function(N){return{value:N,done:!0}},E,g.g.return):(g.g.return(E),Xe(g))}function At(g,E,A,N){try{var Y=E.call(g.g.i,A);if(!(Y instanceof Object))throw new TypeError("Iterator result "+Y+" is not an object");if(!Y.done)return g.g.l=!1,Y;var oe=Y.value}catch($){return g.g.i=null,ct(g.g,$),Xe(g)}return g.g.i=null,N.call(g.g,oe),Xe(g)}function Xe(g){for(;g.g.g;)try{var E=g.h(g.g);if(E)return g.g.l=!1,{value:E.value,done:!1}}catch(A){g.g.h=void 0,ct(g.g,A)}if(g.g.l=!1,g.g.j){if(E=g.g.j,g.g.j=null,E.V)throw E.U;return{value:E.return,done:!0}}return{value:void 0,done:!0}}function Mr(g){this.next=function(E){return Ve(g.g),g.g.i?E=At(g,g.g.i.next,E,g.g.o):(g.g.o(E),E=Xe(g)),E},this.throw=function(E){return Ve(g.g),g.g.i?E=At(g,g.g.i.throw,E,g.g.o):(ct(g.g,E),E=Xe(g)),E},this.return=function(E){return mr(g,E)},this[Symbol.iterator]=function(){return this}}function at(g,E){return E=new Mr(new Jt(E)),ce&&g.prototype&&ce(E,g.prototype),E}function me(g,E){g instanceof String&&(g+="");var A=0,N=!1,Y={next:function(){if(!N&&A<g.length){var oe=A++;return{value:E(oe,g[oe]),done:!1}}return N=!0,{done:!0,value:void 0}}};return Y[Symbol.iterator]=function(){return Y},Y}var Wr=typeof Object.assign=="function"?Object.assign:function(g,E){for(var A=1;A<arguments.length;A++){var N=arguments[A];if(N)for(var Y in N)Object.prototype.hasOwnProperty.call(N,Y)&&(g[Y]=N[Y])}return g};R("Object.assign",function(g){return g||Wr}),R("Promise",function(g){function E($){this.h=0,this.i=void 0,this.g=[],this.o=!1;var ne=this.j();try{$(ne.resolve,ne.reject)}catch(ge){ne.reject(ge)}}function A(){this.g=null}function N($){return $ instanceof E?$:new E(function(ne){ne($)})}if(g)return g;A.prototype.h=function($){if(this.g==null){this.g=[];var ne=this;this.i(function(){ne.l()})}this.g.push($)};var Y=y.setTimeout;A.prototype.i=function($){Y($,0)},A.prototype.l=function(){for(;this.g&&this.g.length;){var $=this.g;this.g=[];for(var ne=0;ne<$.length;++ne){var ge=$[ne];$[ne]=null;try{ge()}catch(Ae){this.j(Ae)}}}this.g=null},A.prototype.j=function($){this.i(function(){throw $})},E.prototype.j=function(){function $(Ae){return function(Ne){ge||(ge=!0,Ae.call(ne,Ne))}}var ne=this,ge=!1;return{resolve:$(this.C),reject:$(this.l)}},E.prototype.C=function($){if($===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if($ instanceof E)this.F($);else{e:switch(typeof $){case"object":var ne=$!=null;break e;case"function":ne=!0;break e;default:ne=!1}ne?this.u($):this.m($)}},E.prototype.u=function($){var ne=void 0;try{ne=$.then}catch(ge){this.l(ge);return}typeof ne=="function"?this.G(ne,$):this.m($)},E.prototype.l=function($){this.s(2,$)},E.prototype.m=function($){this.s(1,$)},E.prototype.s=function($,ne){if(this.h!=0)throw Error("Cannot settle("+$+", "+ne+"): Promise already settled in state"+this.h);this.h=$,this.i=ne,this.h===2&&this.D(),this.A()},E.prototype.D=function(){var $=this;Y(function(){if($.B()){var ne=y.console;typeof ne<"u"&&ne.error($.i)}},1)},E.prototype.B=function(){if(this.o)return!1;var $=y.CustomEvent,ne=y.Event,ge=y.dispatchEvent;return typeof ge>"u"?!0:(typeof $=="function"?$=new $("unhandledrejection",{cancelable:!0}):typeof ne=="function"?$=new ne("unhandledrejection",{cancelable:!0}):($=y.document.createEvent("CustomEvent"),$.initCustomEvent("unhandledrejection",!1,!0,$)),$.promise=this,$.reason=this.i,ge($))},E.prototype.A=function(){if(this.g!=null){for(var $=0;$<this.g.length;++$)oe.h(this.g[$]);this.g=null}};var oe=new A;return E.prototype.F=function($){var ne=this.j();$.J(ne.resolve,ne.reject)},E.prototype.G=function($,ne){var ge=this.j();try{$.call(ne,ge.resolve,ge.reject)}catch(Ae){ge.reject(Ae)}},E.prototype.then=function($,ne){function ge(Ze,Ue){return typeof Ze=="function"?function(Fe){try{Ae(Ze(Fe))}catch(Be){Ne(Be)}}:Ue}var Ae,Ne,Le=new E(function(Ze,Ue){Ae=Ze,Ne=Ue});return this.J(ge($,Ae),ge(ne,Ne)),Le},E.prototype.catch=function($){return this.then(void 0,$)},E.prototype.J=function($,ne){function ge(){switch(Ae.h){case 1:$(Ae.i);break;case 2:ne(Ae.i);break;default:throw Error("Unexpected state: "+Ae.h)}}var Ae=this;this.g==null?oe.h(ge):this.g.push(ge),this.o=!0},E.resolve=N,E.reject=function($){return new E(function(ne,ge){ge($)})},E.race=function($){return new E(function(ne,ge){for(var Ae=O($),Ne=Ae.next();!Ne.done;Ne=Ae.next())N(Ne.value).J(ne,ge)})},E.all=function($){var ne=O($),ge=ne.next();return ge.done?N([]):new E(function(Ae,Ne){function Le(Fe){return function(Be){Ze[Fe]=Be,Ue--,Ue==0&&Ae(Ze)}}var Ze=[],Ue=0;do Ze.push(void 0),Ue++,N(ge.value).J(Le(Ze.length-1),Ne),ge=ne.next();while(!ge.done)})},E}),R("Object.is",function(g){return g||function(E,A){return E===A?E!==0||1/E===1/A:E!==E&&A!==A}}),R("Array.prototype.includes",function(g){return g||function(E,A){var N=this;N instanceof String&&(N=String(N));var Y=N.length;for(A=A||0,0>A&&(A=Math.max(A+Y,0));A<Y;A++){var oe=N[A];if(oe===E||Object.is(oe,E))return!0}return!1}}),R("String.prototype.includes",function(g){return g||function(E,A){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(E instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(E,A||0)!==-1}}),R("Array.prototype.keys",function(g){return g||function(){return me(this,function(E){return E})}});var Br=this||self;function Tt(g,E){g=g.split(".");var A=Br;g[0]in A||typeof A.execScript>"u"||A.execScript("var "+g[0]);for(var N;g.length&&(N=g.shift());)g.length||E===void 0?A[N]&&A[N]!==Object.prototype[N]?A=A[N]:A=A[N]={}:A[N]=E}function je(g,E){return E=String.fromCharCode.apply(null,E),g==null?E:g+E}var Ot,tr=typeof TextDecoder<"u",yr,Or=typeof TextEncoder<"u";function wr(g){if(Or)g=(yr||(yr=new TextEncoder)).encode(g);else{var E=void 0;E=E===void 0?!1:E;for(var A=0,N=new Uint8Array(3*g.length),Y=0;Y<g.length;Y++){var oe=g.charCodeAt(Y);if(128>oe)N[A++]=oe;else{if(2048>oe)N[A++]=oe>>6|192;else{if(55296<=oe&&57343>=oe){if(56319>=oe&&Y<g.length){var $=g.charCodeAt(++Y);if(56320<=$&&57343>=$){oe=1024*(oe-55296)+$-56320+65536,N[A++]=oe>>18|240,N[A++]=oe>>12&63|128,N[A++]=oe>>6&63|128,N[A++]=oe&63|128;continue}else Y--}if(E)throw Error("Found an unpaired surrogate");oe=65533}N[A++]=oe>>12|224,N[A++]=oe>>6&63|128}N[A++]=oe&63|128}}g=N.subarray(0,A)}return g}var Pr={},rr=null;function Dt(g,E){E===void 0&&(E=0),vr(),E=Pr[E];for(var A=Array(Math.floor(g.length/3)),N=E[64]||"",Y=0,oe=0;Y<g.length-2;Y+=3){var $=g[Y],ne=g[Y+1],ge=g[Y+2],Ae=E[$>>2];$=E[($&3)<<4|ne>>4],ne=E[(ne&15)<<2|ge>>6],ge=E[ge&63],A[oe++]=Ae+$+ne+ge}switch(Ae=0,ge=N,g.length-Y){case 2:Ae=g[Y+1],ge=E[(Ae&15)<<2]||N;case 1:g=g[Y],A[oe]=E[g>>2]+E[(g&3)<<4|Ae>>4]+ge+N}return A.join("")}function xr(g){var E=g.length,A=3*E/4;A%3?A=Math.floor(A):"=.".indexOf(g[E-1])!=-1&&(A="=.".indexOf(g[E-2])!=-1?A-2:A-1);var N=new Uint8Array(A),Y=0;return Ir(g,function(oe){N[Y++]=oe}),N.subarray(0,Y)}function Ir(g,E){function A(ge){for(;N<g.length;){var Ae=g.charAt(N++),Ne=rr[Ae];if(Ne!=null)return Ne;if(!/^[\s\xa0]*$/.test(Ae))throw Error("Unknown base64 encoding at char: "+Ae)}return ge}vr();for(var N=0;;){var Y=A(-1),oe=A(0),$=A(64),ne=A(64);if(ne===64&&Y===-1)break;E(Y<<2|oe>>4),$!=64&&(E(oe<<4&240|$>>2),ne!=64&&E($<<6&192|ne))}}function vr(){if(!rr){rr={};for(var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),E=["+/=","+/","-_=","-_.","-_"],A=0;5>A;A++){var N=g.concat(E[A].split(""));Pr[A]=N;for(var Y=0;Y<N.length;Y++){var oe=N[Y];rr[oe]===void 0&&(rr[oe]=Y)}}}}var Ct=typeof Uint8Array.prototype.slice=="function",_r;function lr(g,E,A){return E===A?_r||(_r=new Uint8Array(0)):Ct?g.slice(E,A):new Uint8Array(g.subarray(E,A))}var ut=0,St=0;function Ht(g,E){E=E===void 0?{}:E,E=E.v===void 0?!1:E.v,this.h=null,this.g=this.i=this.j=0,this.l=!1,this.v=E,g&&xt(this,g)}function xt(g,E){E=E.constructor===Uint8Array?E:E.constructor===ArrayBuffer?new Uint8Array(E):E.constructor===Array?new Uint8Array(E):E.constructor===String?xr(E):E instanceof Uint8Array?new Uint8Array(E.buffer,E.byteOffset,E.byteLength):new Uint8Array(0),g.h=E,g.j=0,g.i=g.h.length,g.g=g.j}Ht.prototype.reset=function(){this.g=this.j};function _t(g){var E=g.h,A=E[g.g],N=A&127;return 128>A?(g.g+=1,N):(A=E[g.g+1],N|=(A&127)<<7,128>A?(g.g+=2,N):(A=E[g.g+2],N|=(A&127)<<14,128>A?(g.g+=3,N):(A=E[g.g+3],N|=(A&127)<<21,128>A?(g.g+=4,N):(A=E[g.g+4],N|=(A&15)<<28,128>A?(g.g+=5,N>>>0):(g.g+=5,128<=E[g.g++]&&128<=E[g.g++]&&128<=E[g.g++]&&128<=E[g.g++]&&g.g++,N)))))}function Zt(g){var E=g.h[g.g],A=g.h[g.g+1],N=g.h[g.g+2],Y=g.h[g.g+3];return g.g+=4,A=(E<<0|A<<8|N<<16|Y<<24)>>>0,g=2*(A>>31)+1,E=A>>>23&255,A&=8388607,E==255?A?NaN:1/0*g:E==0?g*Math.pow(2,-149)*A:g*Math.pow(2,E-150)*(A+Math.pow(2,23))}var Gt=[];function qe(){this.g=new Uint8Array(64),this.h=0}qe.prototype.push=function(g){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++]=g},qe.prototype.length=function(){return this.h},qe.prototype.end=function(){var g=this.g,E=this.h;return this.h=0,lr(g,0,E)};function mt(g,E){for(;127<E;)g.push(E&127|128),E>>>=7;g.push(E)}function Rt(g){var E={},A=E.N===void 0?!1:E.N;this.o={v:E.v===void 0?!1:E.v},this.N=A,E=this.o,Gt.length?(A=Gt.pop(),E&&(A.v=E.v),g&&xt(A,g),g=A):g=new Ht(g,E),this.g=g,this.m=this.g.g,this.h=this.i=this.l=-1,this.j=!1}Rt.prototype.reset=function(){this.g.reset(),this.h=this.l=-1};function We(g){var E=g.g;if((E=E.g==E.i)||(E=g.j)||(E=g.g,E=E.l||0>E.g||E.g>E.i),E)return!1;g.m=g.g.g,E=_t(g.g);var A=E&7;return A!=0&&A!=5&&A!=1&&A!=2&&A!=3&&A!=4?(g.j=!0,!1):(g.i=E,g.l=E>>>3,g.h=A,!0)}function Ft(g){switch(g.h){case 0:if(g.h!=0)Ft(g);else{for(g=g.g;g.h[g.g]&128;)g.g++;g.g++}break;case 1:g.h!=1?Ft(g):(g=g.g,g.g+=8);break;case 2:if(g.h!=2)Ft(g);else{var E=_t(g.g);g=g.g,g.g+=E}break;case 5:g.h!=5?Ft(g):(g=g.g,g.g+=4);break;case 3:E=g.l;do{if(!We(g)){g.j=!0;break}if(g.h==4){g.l!=E&&(g.j=!0);break}Ft(g)}while(!0);break;default:g.j=!0}}function et(g,E,A){var N=g.g.i,Y=_t(g.g);return Y=g.g.g+Y,g.g.i=Y,A(E,g),g.g.g=Y,g.g.i=N,E}function pt(g){var E=_t(g.g);g=g.g;var A=g.g;g.g+=E,g=g.h;var N;if(tr)(N=Ot)||(N=Ot=new TextDecoder("utf-8",{fatal:!1})),N=N.decode(g.subarray(A,A+E));else{E=A+E;for(var Y=[],oe=null,$,ne,ge;A<E;)$=g[A++],128>$?Y.push($):224>$?A>=E?Y.push(65533):(ne=g[A++],194>$||(ne&192)!==128?(A--,Y.push(65533)):Y.push(($&31)<<6|ne&63)):240>$?A>=E-1?Y.push(65533):(ne=g[A++],(ne&192)!==128||$===224&&160>ne||$===237&&160<=ne||((N=g[A++])&192)!==128?(A--,Y.push(65533)):Y.push(($&15)<<12|(ne&63)<<6|N&63)):244>=$?A>=E-2?Y.push(65533):(ne=g[A++],(ne&192)!==128||($<<28)+(ne-144)>>30!==0||((N=g[A++])&192)!==128||((ge=g[A++])&192)!==128?(A--,Y.push(65533)):($=($&7)<<18|(ne&63)<<12|(N&63)<<6|ge&63,$-=65536,Y.push(($>>10&1023)+55296,($&1023)+56320))):Y.push(65533),8192<=Y.length&&(oe=je(oe,Y),Y.length=0);N=je(oe,Y)}return N}function It(){this.h=[],this.i=0,this.g=new qe}function Vt(g,E){E.length!==0&&(g.h.push(E),g.i+=E.length)}function wt(g){var E=g.i+g.g.length();if(E===0)return new Uint8Array(0);E=new Uint8Array(E);for(var A=g.h,N=A.length,Y=0,oe=0;oe<N;oe++){var $=A[oe];$.length!==0&&(E.set($,Y),Y+=$.length)}return A=g.g,N=A.h,N!==0&&(E.set(A.g.subarray(0,N),Y),A.h=0),g.h=[E],E}function Ye(g,E,A){if(A!=null){mt(g.g,8*E+5),g=g.g;var N=A;N=(A=0>N?1:0)?-N:N,N===0?0<1/N?ut=St=0:(St=0,ut=2147483648):isNaN(N)?(St=0,ut=2147483647):34028234663852886e22<N?(St=0,ut=(A<<31|2139095040)>>>0):11754943508222875e-54>N?(N=Math.round(N/Math.pow(2,-149)),St=0,ut=(A<<31|N)>>>0):(E=Math.floor(Math.log(N)/Math.LN2),N*=Math.pow(2,-E),N=Math.round(8388608*N)&8388607,St=0,ut=(A<<31|E+127<<23|N)>>>0),A=ut,g.push(A>>>0&255),g.push(A>>>8&255),g.push(A>>>16&255),g.push(A>>>24&255)}}var Lt=typeof Uint8Array=="function";function zt(g,E,A){if(g!=null)return typeof g=="object"?Lt&&g instanceof Uint8Array?A(g):Et(g,E,A):E(g)}function Et(g,E,A){if(Array.isArray(g)){for(var N=Array(g.length),Y=0;Y<g.length;Y++)N[Y]=zt(g[Y],E,A);return Array.isArray(g)&&g.W&&sr(N),N}N={};for(Y in g)N[Y]=zt(g[Y],E,A);return N}function fr(g){return typeof g=="number"?isFinite(g)?g:String(g):g}var qt={W:{value:!0,configurable:!0}};function sr(g){return Array.isArray(g)&&!Object.isFrozen(g)&&Object.defineProperties(g,qt),g}var hr;function yt(g,E,A){var N=hr;hr=null,g||(g=N),N=this.constructor.ca,g||(g=N?[N]:[]),this.j=N?0:-1,this.i=null,this.g=g;e:{if(N=this.g.length,g=N-1,N&&(N=this.g[g],N!==null&&typeof N=="object"&&N.constructor===Object)){this.l=g-this.j,this.h=N;break e}E!==void 0&&-1<E?(this.l=Math.max(E,g+1-this.j),this.h=null):this.l=Number.MAX_VALUE}if(A)for(E=0;E<A.length;E++)g=A[E],g<this.l?(g+=this.j,(N=this.g[g])?sr(N):this.g[g]=kt):(vt(this),(N=this.h[g])?sr(N):this.h[g]=kt)}var kt=Object.freeze(sr([]));function vt(g){var E=g.l+g.j;g.g[E]||(g.h=g.g[E]={})}function rt(g,E,A){return E===-1?null:A!==void 0&&A||E>=g.l?g.h?g.h[E]:void 0:g.g[E+g.j]}function Ut(g){var E=E===void 0?!1:E,A=rt(g,1,E);return A==null&&(A=kt),A===kt&&(A=sr([]),$e(g,1,A,E)),A}function tt(g,E,A){return g=rt(g,E),g=g==null?g:+g,g??(A===void 0?0:A)}function $e(g,E,A,N){N!==void 0&&N||E>=g.l?(vt(g),g.h[E]=A):g.g[E+g.j]=A}function nr(g,E){g.i||(g.i={});var A=g.i[1];if(!A){var N=Ut(g);A=[];for(var Y=0;Y<N.length;Y++)A[Y]=new E(N[Y]);g.i[1]=A}return A}function lt(g,E,A,N){var Y=nr(g,A);E=E||new A,g=Ut(g),N!=null?(Y.splice(N,0,E),g.splice(N,0,Ce(E))):(Y.push(E),g.push(Ce(E)))}yt.prototype.toJSON=function(){var g=Ce(this);return Et(g,fr,Dt)};function Ce(g,E){if(g.i)for(var A in g.i){var N=g.i[A];if(Array.isArray(N))for(var Y=0;Y<N.length;Y++)N[Y]&&Ce(N[Y]);else N&&Ce(N)}return g.g}yt.prototype.toString=function(){return Ce(this).toString()};function Se(g,E){return g=rt(g,E),g??0}function nt(g,E){return g=rt(g,E),g??""}function ee(g,E){if(g=g.m){Vt(E,E.g.end());for(var A=0;A<g.length;A++)Vt(E,g[A])}}function ie(g,E){if(E.h==4)return!1;var A=E.m;return Ft(E),E.N||(E=lr(E.g.h,A,E.g.g),(A=g.m)?A.push(E):g.m=[E]),!0}function ve(g,E){var A=void 0;return new(A||(A=Promise))(function(N,Y){function oe(ge){try{ne(E.next(ge))}catch(Ae){Y(Ae)}}function $(ge){try{ne(E.throw(ge))}catch(Ae){Y(Ae)}}function ne(ge){ge.done?N(ge.value):new A(function(Ae){Ae(ge.value)}).then(oe,$)}ne((E=E.apply(g,void 0)).next())})}function He(g){yt.call(this,g)}he(He,yt);function Ie(g,E){for(;We(E);)switch(E.i){case 8:var A=_t(E.g);$e(g,1,A);break;case 21:A=Zt(E.g),$e(g,2,A);break;case 26:A=pt(E),$e(g,3,A);break;case 34:A=pt(E),$e(g,4,A);break;default:if(!ie(g,E))return g}return g}function xe(g){yt.call(this,g,-1,Ke)}he(xe,yt),xe.prototype.addClassification=function(g,E){lt(this,g,He,E)};var Ke=[1];function ht(g){yt.call(this,g)}he(ht,yt);function bt(g,E){for(;We(E);)switch(E.i){case 13:var A=Zt(E.g);$e(g,1,A);break;case 21:A=Zt(E.g),$e(g,2,A);break;case 29:A=Zt(E.g),$e(g,3,A);break;case 37:A=Zt(E.g),$e(g,4,A);break;case 45:A=Zt(E.g),$e(g,5,A);break;default:if(!ie(g,E))return g}return g}function Qe(g){yt.call(this,g,-1,$t)}he(Qe,yt);var $t=[1];function Er(g){yt.call(this,g)}he(Er,yt);function ar(g,E,A){if(A=g.createShader(A===0?g.VERTEX_SHADER:g.FRAGMENT_SHADER),g.shaderSource(A,E),g.compileShader(A),!g.getShaderParameter(A,g.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
|
|
3
|
-
|
|
4
|
-
`+g.getShaderInfoLog(A));return A}function Yt(g){return nr(g,He).map(function(E){return{index:Se(E,1),Y:tt(E,2),label:rt(E,3)!=null?nt(E,3):void 0,displayName:rt(E,4)!=null?nt(E,4):void 0}})}function ir(g){return{x:tt(g,1),y:tt(g,2),z:tt(g,3),visibility:rt(g,4)!=null?tt(g,4):void 0}}function ur(g,E){this.h=g,this.g=E,this.l=0}function Pt(g,E,A){return Xt(g,E),typeof g.g.canvas.transferToImageBitmap=="function"?Promise.resolve(g.g.canvas.transferToImageBitmap()):A?Promise.resolve(g.g.canvas):typeof createImageBitmap=="function"?createImageBitmap(g.g.canvas):(g.i===void 0&&(g.i=document.createElement("canvas")),new Promise(function(N){g.i.height=g.g.canvas.height,g.i.width=g.g.canvas.width,g.i.getContext("2d",{}).drawImage(g.g.canvas,0,0,g.g.canvas.width,g.g.canvas.height),N(g.i)}))}function Xt(g,E){var A=g.g;if(g.m===void 0){var N=ar(A,`
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
void main(){
|
|
16
|
-
gl_FragColor = texture2D(sampler0, vTex);
|
|
17
|
-
}`,1),oe=A.createProgram();if(A.attachShader(oe,N),A.attachShader(oe,Y),A.linkProgram(oe),!A.getProgramParameter(oe,A.LINK_STATUS))throw Error(`Could not compile WebGL program.
|
|
18
|
-
|
|
19
|
-
`+A.getProgramInfoLog(oe));N=g.m=oe,A.useProgram(N),Y=A.getUniformLocation(N,"sampler0"),g.j={I:A.getAttribLocation(N,"aVertex"),H:A.getAttribLocation(N,"aTex"),da:Y},g.s=A.createBuffer(),A.bindBuffer(A.ARRAY_BUFFER,g.s),A.enableVertexAttribArray(g.j.I),A.vertexAttribPointer(g.j.I,2,A.FLOAT,!1,0,0),A.bufferData(A.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),A.STATIC_DRAW),A.bindBuffer(A.ARRAY_BUFFER,null),g.o=A.createBuffer(),A.bindBuffer(A.ARRAY_BUFFER,g.o),A.enableVertexAttribArray(g.j.H),A.vertexAttribPointer(g.j.H,2,A.FLOAT,!1,0,0),A.bufferData(A.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),A.STATIC_DRAW),A.bindBuffer(A.ARRAY_BUFFER,null),A.uniform1i(Y,0)}N=g.j,A.useProgram(g.m),A.canvas.width=E.width,A.canvas.height=E.height,A.viewport(0,0,E.width,E.height),A.activeTexture(A.TEXTURE0),g.h.bindTexture2d(E.glName),A.enableVertexAttribArray(N.I),A.bindBuffer(A.ARRAY_BUFFER,g.s),A.vertexAttribPointer(N.I,2,A.FLOAT,!1,0,0),A.enableVertexAttribArray(N.H),A.bindBuffer(A.ARRAY_BUFFER,g.o),A.vertexAttribPointer(N.H,2,A.FLOAT,!1,0,0),A.bindFramebuffer(A.DRAW_FRAMEBUFFER?A.DRAW_FRAMEBUFFER:A.FRAMEBUFFER,null),A.clearColor(0,0,0,0),A.clear(A.COLOR_BUFFER_BIT),A.colorMask(!0,!0,!0,!0),A.drawArrays(A.TRIANGLE_FAN,0,4),A.disableVertexAttribArray(N.I),A.disableVertexAttribArray(N.H),A.bindBuffer(A.ARRAY_BUFFER,null),g.h.bindTexture2d(0)}function zr(g){this.g=g}var Kt=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 Mt(g,E){return E+g}function dr(g,E){window[g]=E}function Ar(g){var E=document.createElement("script");return E.setAttribute("src",g),E.setAttribute("crossorigin","anonymous"),new Promise(function(A){E.addEventListener("load",function(){A()},!1),E.addEventListener("error",function(){A()},!1),document.body.appendChild(E)})}function Wt(){return ve(this,function g(){return at(g,function(E){switch(E.g){case 1:return E.m=2,J(E,WebAssembly.instantiate(Kt),4);case 4:E.g=3,E.m=0;break;case 2:return E.m=0,E.j=null,E.return(!1);case 3:return E.return(!0)}})})}function jr(g){if(this.g=g,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=g&&g.locateFile||Mt,typeof window=="object")var E=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")E=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.S=E,g.options){E=O(Object.keys(g.options));for(var A=E.next();!A.done;A=E.next()){A=A.value;var N=g.options[A].default;N!==void 0&&(this.j[A]=typeof N=="function"?N():N)}}}i=jr.prototype,i.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function Qt(g,E){return g.g.files===void 0?[]:typeof g.g.files=="function"?g.g.files(E):g.g.files}function pr(g){return ve(g,function E(){var A=this,N,Y,oe,$,ne,ge,Ae,Ne,Le,Ze,Ue;return at(E,function(Fe){switch(Fe.g){case 1:return N=A,A.R?(Y=Qt(A,A.j),J(Fe,Wt(),2)):Fe.return();case 2:if(oe=Fe.h,typeof window=="object")return dr("createMediapipeSolutionsWasm",{locateFile:A.locateFile}),dr("createMediapipeSolutionsPackedAssets",{locateFile:A.locateFile}),ge=Y.filter(function(Be){return Be.data!==void 0}),Ae=Y.filter(function(Be){return Be.data===void 0}),Ne=Promise.all(ge.map(function(Be){var Je=er(N,Be.url);if(Be.path!==void 0){var st=Be.path;Je=Je.then(function(ft){return N.overrideFile(st,ft),Promise.resolve(ft)})}return Je})),Le=Promise.all(Ae.map(function(Be){return Be.simd===void 0||Be.simd&&oe||!Be.simd&&!oe?Ar(N.locateFile(Be.url,N.S)):Promise.resolve()})).then(function(){return ve(N,function Be(){var Je,st,ft=this;return at(Be,function(gt){if(gt.g==1)return Je=window.createMediapipeSolutionsWasm,st=window.createMediapipeSolutionsPackedAssets,J(gt,Je(st),2);ft.h=gt.h,gt.g=0})})}),Ze=(function(){return ve(N,function Be(){var Je=this;return at(Be,function(st){return Je.g.graph&&Je.g.graph.url?st=J(st,er(Je,Je.g.graph.url),0):(st.g=0,st=void 0),st})})})(),J(Fe,Promise.all([Le,Ne,Ze]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return $=Y.filter(function(Be){return Be.simd===void 0||Be.simd&&oe||!Be.simd&&!oe}).map(function(Be){return N.locateFile(Be.url,N.S)}),importScripts.apply(null,L($)),J(Fe,createMediapipeSolutionsWasm(Module),6);case 6:A.h=Fe.h,A.l=new OffscreenCanvas(1,1),A.h.canvas=A.l,ne=A.h.GL.createContext(A.l,{antialias:!1,alpha:!1,ba:typeof WebGL2RenderingContext<"u"?2:1}),A.h.GL.makeContextCurrent(ne),Fe.g=4;break;case 7:if(A.l=document.createElement("canvas"),Ue=A.l.getContext("webgl2",{}),!Ue&&(Ue=A.l.getContext("webgl",{}),!Ue))return alert("Failed to create WebGL canvas context when passing video frame."),Fe.return();A.D=Ue,A.h.canvas=A.l,A.h.createContext(A.l,!0,!0,{});case 4:A.i=new A.h.SolutionWasm,A.R=!1,Fe.g=0}})})}function Tr(g){return ve(g,function E(){var A=this,N,Y,oe,$,ne,ge,Ae,Ne;return at(E,function(Le){if(Le.g==1){if(A.g.graph&&A.g.graph.url&&A.P===A.g.graph.url)return Le.return();if(A.o=!0,!A.g.graph||!A.g.graph.url){Le.g=2;return}return A.P=A.g.graph.url,J(Le,er(A,A.g.graph.url),3)}for(Le.g!=2&&(N=Le.h,A.i.loadGraph(N)),Y=O(Object.keys(A.B)),oe=Y.next();!oe.done;oe=Y.next())$=oe.value,A.i.overrideFile($,A.B[$]);if(A.B={},A.g.listeners)for(ne=O(A.g.listeners),ge=ne.next();!ge.done;ge=ne.next())Ae=ge.value,Yr(A,Ae);Ne=A.j,A.j={},A.setOptions(Ne),Le.g=0})})}i.reset=function(){return ve(this,function g(){var E=this;return at(g,function(A){E.i&&(E.i.reset(),E.m={},E.s={}),A.g=0})})},i.setOptions=function(g,E){var A=this;if(E=E||this.g.options){for(var N=[],Y=[],oe={},$=O(Object.keys(g)),ne=$.next();!ne.done;oe={K:oe.K,L:oe.L},ne=$.next()){var ge=ne.value;ge in this.j&&this.j[ge]===g[ge]||(this.j[ge]=g[ge],ne=E[ge],ne!==void 0&&(ne.onChange&&(oe.K=ne.onChange,oe.L=g[ge],N.push((function(Ae){return function(){return ve(A,function Ne(){var Le,Ze=this;return at(Ne,function(Ue){if(Ue.g==1)return J(Ue,Ae.K(Ae.L),2);Le=Ue.h,Le===!0&&(Ze.o=!0),Ue.g=0})})}})(oe))),ne.graphOptionXref&&(ge={valueNumber:ne.type===1?g[ge]:0,valueBoolean:ne.type===0?g[ge]:!1,valueString:ne.type===2?g[ge]:""},ne=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),ne.graphOptionXref),ge),Y.push(ne))))}(N.length!==0||Y.length!==0)&&(this.o=!0,this.A=(this.A===void 0?[]:this.A).concat(Y),this.u=(this.u===void 0?[]:this.u).concat(N))}};function Nr(g){return ve(g,function E(){var A=this,N,Y,oe,$,ne,ge,Ae;return at(E,function(Ne){switch(Ne.g){case 1:if(!A.o)return Ne.return();if(!A.u){Ne.g=2;break}N=O(A.u),Y=N.next();case 3:if(Y.done){Ne.g=5;break}return oe=Y.value,J(Ne,oe(),4);case 4:Y=N.next(),Ne.g=3;break;case 5:A.u=void 0;case 2:if(A.A){for($=new A.h.GraphOptionChangeRequestList,ne=O(A.A),ge=ne.next();!ge.done;ge=ne.next())Ae=ge.value,$.push_back(Ae);A.i.changeOptions($),$.delete(),A.A=void 0}A.o=!1,Ne.g=0}})})}i.initialize=function(){return ve(this,function g(){var E=this;return at(g,function(A){return A.g==1?J(A,pr(E),2):A.g!=3?J(A,Tr(E),3):J(A,Nr(E),0)})})};function er(g,E){return ve(g,function A(){var N=this,Y,oe;return at(A,function($){return E in N.F?$.return(N.F[E]):(Y=N.locateFile(E,""),oe=fetch(Y).then(function(ne){return ne.arrayBuffer()}),N.F[E]=oe,$.return(oe))})})}i.overrideFile=function(g,E){this.i?this.i.overrideFile(g,E):this.B[g]=E},i.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},i.send=function(g,E){return ve(this,function A(){var N=this,Y,oe,$,ne,ge,Ae,Ne,Le,Ze;return at(A,function(Ue){switch(Ue.g){case 1:return N.g.inputs?(Y=1e3*(E??performance.now()),J(Ue,N.C,2)):Ue.return();case 2:return J(Ue,N.initialize(),3);case 3:for(oe=new N.h.PacketDataList,$=O(Object.keys(g)),ne=$.next();!ne.done;ne=$.next())if(ge=ne.value,Ae=N.g.inputs[ge]){e:{var Fe=N,Be=g[ge];switch(Ae.type){case"video":var Je=Fe.m[Ae.stream];if(Je||(Je=new ur(Fe.h,Fe.D),Fe.m[Ae.stream]=Je),Fe=Je,Fe.l===0&&(Fe.l=Fe.h.createTexture()),typeof HTMLVideoElement<"u"&&Be instanceof HTMLVideoElement){var st=Be.videoWidth;Je=Be.videoHeight}else typeof HTMLImageElement<"u"&&Be instanceof HTMLImageElement?(st=Be.naturalWidth,Je=Be.naturalHeight):(st=Be.width,Je=Be.height);Je={glName:Fe.l,width:st,height:Je},st=Fe.g,st.canvas.width=Je.width,st.canvas.height=Je.height,st.activeTexture(st.TEXTURE0),Fe.h.bindTexture2d(Fe.l),st.texImage2D(st.TEXTURE_2D,0,st.RGBA,st.RGBA,st.UNSIGNED_BYTE,Be),Fe.h.bindTexture2d(0),Fe=Je;break e;case"detections":for(Je=Fe.m[Ae.stream],Je||(Je=new zr(Fe.h),Fe.m[Ae.stream]=Je),Fe=Je,Fe.data||(Fe.data=new Fe.g.DetectionListData),Fe.data.reset(Be.length),Je=0;Je<Be.length;++Je){st=Be[Je];var ft=Fe.data,gt=ft.setBoundingBox,jt=Je,h=st.T,v=new Er;$e(v,1,h.Z),$e(v,2,h.$),$e(v,3,h.height),$e(v,4,h.width),$e(v,5,h.rotation),$e(v,6,h.X);var x=h=new It;Ye(x,1,rt(v,1)),Ye(x,2,rt(v,2)),Ye(x,3,rt(v,3)),Ye(x,4,rt(v,4)),Ye(x,5,rt(v,5));var j=rt(v,6);if(j!=null&&j!=null){mt(x.g,48);var W=x.g,X=j;j=0>X,X=Math.abs(X);var z=X>>>0;for(X=Math.floor((X-z)/4294967296),X>>>=0,j&&(X=~X>>>0,z=(~z>>>0)+1,4294967295<z&&(z=0,X++,4294967295<X&&(X=0))),ut=z,St=X,j=ut,z=St;0<z||127<j;)W.push(j&127|128),j=(j>>>7|z<<25)>>>0,z>>>=7;W.push(j)}if(ee(v,x),h=wt(h),gt.call(ft,jt,h),st.O)for(ft=0;ft<st.O.length;++ft)v=st.O[ft],x=!!v.visibility,gt=Fe.data,jt=gt.addNormalizedLandmark,h=Je,v=Object.assign(Object.assign({},v),{visibility:x?v.visibility:0}),x=new ht,$e(x,1,v.x),$e(x,2,v.y),$e(x,3,v.z),v.visibility&&$e(x,4,v.visibility),W=v=new It,Ye(W,1,rt(x,1)),Ye(W,2,rt(x,2)),Ye(W,3,rt(x,3)),Ye(W,4,rt(x,4)),Ye(W,5,rt(x,5)),ee(x,W),v=wt(v),jt.call(gt,h,v);if(st.M)for(ft=0;ft<st.M.length;++ft){if(gt=Fe.data,jt=gt.addClassification,h=Je,v=st.M[ft],x=new He,$e(x,2,v.Y),v.index&&$e(x,1,v.index),v.label&&$e(x,3,v.label),v.displayName&&$e(x,4,v.displayName),W=v=new It,z=rt(x,1),z!=null&&z!=null)if(mt(W.g,8),j=W.g,0<=z)mt(j,z);else{for(X=0;9>X;X++)j.push(z&127|128),z>>=7;j.push(1)}Ye(W,2,rt(x,2)),j=rt(x,3),j!=null&&(j=wr(j),mt(W.g,26),mt(W.g,j.length),Vt(W,W.g.end()),Vt(W,j)),j=rt(x,4),j!=null&&(j=wr(j),mt(W.g,34),mt(W.g,j.length),Vt(W,W.g.end()),Vt(W,j)),ee(x,W),v=wt(v),jt.call(gt,h,v)}}Fe=Fe.data;break e;default:Fe={}}}switch(Ne=Fe,Le=Ae.stream,Ae.type){case"video":oe.pushTexture2d(Object.assign(Object.assign({},Ne),{stream:Le,timestamp:Y}));break;case"detections":Ze=Ne,Ze.stream=Le,Ze.timestamp=Y,oe.pushDetectionList(Ze);break;default:throw Error("Unknown input config type: '"+Ae.type+"'")}}return N.i.send(oe),J(Ue,N.C,4);case 4:oe.delete(),Ue.g=0}})})};function Sr(g,E,A){return ve(g,function N(){var Y,oe,$,ne,ge,Ae,Ne=this,Le,Ze,Ue,Fe,Be,Je,st,ft;return at(N,function(gt){switch(gt.g){case 1:if(!A)return gt.return(E);for(Y={},oe=0,$=O(Object.keys(A)),ne=$.next();!ne.done;ne=$.next())ge=ne.value,Ae=A[ge],typeof Ae!="string"&&Ae.type==="texture"&&E[Ae.stream]!==void 0&&++oe;1<oe&&(Ne.G=!1),Le=O(Object.keys(A)),ne=Le.next();case 2:if(ne.done){gt.g=4;break}if(Ze=ne.value,Ue=A[Ze],typeof Ue=="string")return st=Y,ft=Ze,J(gt,$r(Ne,Ze,E[Ue]),14);if(Fe=E[Ue.stream],Ue.type==="detection_list"){if(Fe){for(var jt=Fe.getRectList(),h=Fe.getLandmarksList(),v=Fe.getClassificationsList(),x=[],j=0;j<jt.size();++j){var W=jt.get(j);e:{var X=new Er;for(W=new Rt(W);We(W);)switch(W.i){case 13:var z=Zt(W.g);$e(X,1,z);break;case 21:z=Zt(W.g),$e(X,2,z);break;case 29:z=Zt(W.g),$e(X,3,z);break;case 37:z=Zt(W.g),$e(X,4,z);break;case 45:z=Zt(W.g),$e(X,5,z);break;case 48:for(var q=W.g,ae=128,s=0,_=z=0;4>_&&128<=ae;_++)ae=q.h[q.g++],s|=(ae&127)<<7*_;if(128<=ae&&(ae=q.h[q.g++],s|=(ae&127)<<28,z|=(ae&127)>>4),128<=ae)for(_=0;5>_&&128<=ae;_++)ae=q.h[q.g++],z|=(ae&127)<<7*_+3;128>ae?(q=s>>>0,ae=z>>>0,(z=ae&2147483648)&&(q=~q+1>>>0,ae=~ae>>>0,q==0&&(ae=ae+1>>>0)),q=4294967296*ae+(q>>>0),z=z?-q:q):(q.l=!0,z=void 0),$e(X,6,z);break;default:if(!ie(X,W))break e}}X={Z:tt(X,1),$:tt(X,2),height:tt(X,3),width:tt(X,4),rotation:tt(X,5,0),X:Se(X,6)},z=h.get(j);e:for(W=new Qe,z=new Rt(z);We(z);)switch(z.i){case 10:q=et(z,new ht,bt),lt(W,q,ht,void 0);break;default:if(!ie(W,z))break e}W=nr(W,ht).map(ir),q=v.get(j);e:for(z=new xe,q=new Rt(q);We(q);)switch(q.i){case 10:z.addClassification(et(q,new He,Ie));break;default:if(!ie(z,q))break e}X={T:X,O:W,M:Yt(z)},x.push(X)}jt=x}else jt=[];Y[Ze]=jt,gt.g=7;break}if(Ue.type==="proto_list"){if(Fe){for(jt=Array(Fe.size()),h=0;h<Fe.size();h++)jt[h]=Fe.get(h);Fe.delete()}else jt=[];Y[Ze]=jt,gt.g=7;break}if(Fe===void 0){gt.g=3;break}if(Ue.type==="float_list"){Y[Ze]=Fe,gt.g=7;break}if(Ue.type==="proto"){Y[Ze]=Fe,gt.g=7;break}if(Ue.type!=="texture")throw Error("Unknown output config type: '"+Ue.type+"'");return Be=Ne.s[Ze],Be||(Be=new ur(Ne.h,Ne.D),Ne.s[Ze]=Be),J(gt,Pt(Be,Fe,Ne.G),13);case 13:Je=gt.h,Y[Ze]=Je;case 7:Ue.transform&&Y[Ze]&&(Y[Ze]=Ue.transform(Y[Ze])),gt.g=3;break;case 14:st[ft]=gt.h;case 3:ne=Le.next(),gt.g=2;break;case 4:return gt.return(Y)}})})}function $r(g,E,A){return ve(g,function N(){var Y=this,oe;return at(N,function($){return typeof A=="number"||A instanceof Uint8Array||A instanceof Y.h.Uint8BlobList?$.return(A):A instanceof Y.h.Texture2dDataOut?(oe=Y.s[E],oe||(oe=new ur(Y.h,Y.D),Y.s[E]=oe),$.return(Pt(oe,A,Y.G))):$.return(void 0)})})}function Yr(g,E){for(var A=E.name||"$",N=[].concat(L(E.wants)),Y=new g.h.StringList,oe=O(E.wants),$=oe.next();!$.done;$=oe.next())Y.push_back($.value);oe=g.h.PacketListener.implement({onResults:function(ne){for(var ge={},Ae=0;Ae<E.wants.length;++Ae)ge[N[Ae]]=ne.get(Ae);var Ne=g.listeners[A];Ne&&(g.C=Sr(g,ge,E.outs).then(function(Le){Le=Ne(Le);for(var Ze=0;Ze<E.wants.length;++Ze){var Ue=ge[N[Ze]];typeof Ue=="object"&&Ue.hasOwnProperty&&Ue.hasOwnProperty("delete")&&Ue.delete()}Le&&(g.C=Le)}))}}),g.i.attachMultiListener(Y,oe),Y.delete()}i.onResults=function(g,E){this.listeners[E||"$"]=g},Tt("Solution",jr),Tt("OptionType",{BOOL:0,NUMBER:1,aa:2,0:"BOOL",1:"NUMBER",2:"STRING"});function Rr(g){return g===void 0&&(g=0),g===1?"selfie_segmentation_landscape.tflite":"selfie_segmentation.tflite"}function kr(g){var E=this;g=g||{},this.g=new jr({locateFile:g.locateFile,files:function(A){return[{simd:!0,url:"selfie_segmentation_solution_simd_wasm_bin.js"},{simd:!1,url:"selfie_segmentation_solution_wasm_bin.js"},{data:!0,url:Rr(A.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(A){return ve(E,function N(){var Y,oe,$=this,ne;return at(N,function(ge){return ge.g==1?(Y=Rr(A),oe="third_party/mediapipe/modules/selfie_segmentation/"+Y,J(ge,er($.g,Y),2)):(ne=ge.h,$.g.overrideFile(oe,ne),ge.return(!0))})})}}}})}i=kr.prototype,i.close=function(){return this.g.close(),Promise.resolve()},i.onResults=function(g){this.g.onResults(g)},i.initialize=function(){return ve(this,function g(){var E=this;return at(g,function(A){return J(A,E.g.initialize(),0)})})},i.reset=function(){this.g.reset()},i.send=function(g){return ve(this,function E(){var A=this;return at(E,function(N){return J(N,A.g.send(g),0)})})},i.setOptions=function(g){this.g.setOptions(g)},Tt("SelfieSegmentation",kr),Tt("VERSION","0.1.1632777926")}).call(Ei);const Ai={};(function(){var i;function t(a){var w=0;return function(){return w<a.length?{done:!1,value:a[w++]}:{done:!0}}}var n=typeof Object.defineProperties=="function"?Object.defineProperty:function(a,w,S){return a==Array.prototype||a==Object.prototype||(a[w]=S.value),a};function p(a){a=[typeof globalThis=="object"&&globalThis,a,typeof window=="object"&&window,typeof self=="object"&&self,typeof global=="object"&&global];for(var w=0;w<a.length;++w){var S=a[w];if(S&&S.Math==Math)return S}throw Error("Cannot find global object")}var y=p(this);function R(a,w){if(w)e:{var S=y;a=a.split(".");for(var I=0;I<a.length-1;I++){var B=a[I];if(!(B in S))break e;S=S[B]}a=a[a.length-1],I=S[a],w=w(I),w!=I&&w!=null&&n(S,a,{configurable:!0,writable:!0,value:w})}}R("Symbol",function(a){function w(o){if(this instanceof w)throw new TypeError("Symbol is not a constructor");return new S(I+(o||"")+"_"+B++,o)}function S(o,f){this.g=o,n(this,"description",{configurable:!0,writable:!0,value:f})}if(a)return a;S.prototype.toString=function(){return this.g};var I="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",B=0;return w}),R("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var w="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),S=0;S<w.length;S++){var I=y[w[S]];typeof I=="function"&&typeof I.prototype[a]!="function"&&n(I.prototype,a,{configurable:!0,writable:!0,value:function(){return k(t(this))}})}return a});function k(a){return a={next:a},a[Symbol.iterator]=function(){return this},a}function O(a){var w=typeof Symbol<"u"&&Symbol.iterator&&a[Symbol.iterator];return w?w.call(a):{next:t(a)}}function L(a){if(!(a instanceof Array)){a=O(a);for(var w,S=[];!(w=a.next()).done;)S.push(w.value);a=S}return a}var te=typeof Object.create=="function"?Object.create:function(a){function w(){}return w.prototype=a,new w},ue;if(typeof Object.setPrototypeOf=="function")ue=Object.setPrototypeOf;else{var pe;e:{var Oe={a:!0},Me={};try{Me.__proto__=Oe,pe=Me.a;break e}catch{}pe=!1}ue=pe?function(a,w){if(a.__proto__=w,a.__proto__!==w)throw new TypeError(a+" is not extensible");return a}:null}var ce=ue;function he(a,w){if(a.prototype=te(w.prototype),a.prototype.constructor=a,ce)ce(a,w);else for(var S in w)if(S!="prototype")if(Object.defineProperties){var I=Object.getOwnPropertyDescriptor(w,S);I&&Object.defineProperty(a,S,I)}else a[S]=w[S];a.ra=w.prototype}function Ge(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.u=this.o=0,this.j=null}function Ve(a){if(a.l)throw new TypeError("Generator is already running");a.l=!0}Ge.prototype.s=function(a){this.h=a};function ct(a,w){a.j={fa:w,ga:!0},a.g=a.o||a.u}Ge.prototype.return=function(a){this.j={return:a},this.g=this.u};function J(a,w,S){return a.g=S,{value:w}}function Jt(a){this.g=new Ge,this.h=a}function mr(a,w){Ve(a.g);var S=a.g.i;return S?At(a,"return"in S?S.return:function(I){return{value:I,done:!0}},w,a.g.return):(a.g.return(w),Xe(a))}function At(a,w,S,I){try{var B=w.call(a.g.i,S);if(!(B instanceof Object))throw new TypeError("Iterator result "+B+" is not an object");if(!B.done)return a.g.l=!1,B;var o=B.value}catch(f){return a.g.i=null,ct(a.g,f),Xe(a)}return a.g.i=null,I.call(a.g,o),Xe(a)}function Xe(a){for(;a.g.g;)try{var w=a.h(a.g);if(w)return a.g.l=!1,{value:w.value,done:!1}}catch(S){a.g.h=void 0,ct(a.g,S)}if(a.g.l=!1,a.g.j){if(w=a.g.j,a.g.j=null,w.ga)throw w.fa;return{value:w.return,done:!0}}return{value:void 0,done:!0}}function Mr(a){this.next=function(w){return Ve(a.g),a.g.i?w=At(a,a.g.i.next,w,a.g.s):(a.g.s(w),w=Xe(a)),w},this.throw=function(w){return Ve(a.g),a.g.i?w=At(a,a.g.i.throw,w,a.g.s):(ct(a.g,w),w=Xe(a)),w},this.return=function(w){return mr(a,w)},this[Symbol.iterator]=function(){return this}}function at(a){function w(I){return a.next(I)}function S(I){return a.throw(I)}return new Promise(function(I,B){function o(f){f.done?I(f.value):Promise.resolve(f.value).then(w,S).then(o,B)}o(a.next())})}function me(a){return at(new Mr(new Jt(a)))}R("Promise",function(a){function w(f){this.h=0,this.i=void 0,this.g=[],this.s=!1;var b=this.j();try{f(b.resolve,b.reject)}catch(r){b.reject(r)}}function S(){this.g=null}function I(f){return f instanceof w?f:new w(function(b){b(f)})}if(a)return a;S.prototype.h=function(f){if(this.g==null){this.g=[];var b=this;this.i(function(){b.l()})}this.g.push(f)};var B=y.setTimeout;S.prototype.i=function(f){B(f,0)},S.prototype.l=function(){for(;this.g&&this.g.length;){var f=this.g;this.g=[];for(var b=0;b<f.length;++b){var r=f[b];f[b]=null;try{r()}catch(c){this.j(c)}}}this.g=null},S.prototype.j=function(f){this.i(function(){throw f})},w.prototype.j=function(){function f(c){return function(d){r||(r=!0,c.call(b,d))}}var b=this,r=!1;return{resolve:f(this.D),reject:f(this.l)}},w.prototype.D=function(f){if(f===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(f instanceof w)this.H(f);else{e:switch(typeof f){case"object":var b=f!=null;break e;case"function":b=!0;break e;default:b=!1}b?this.A(f):this.o(f)}},w.prototype.A=function(f){var b=void 0;try{b=f.then}catch(r){this.l(r);return}typeof b=="function"?this.I(b,f):this.o(f)},w.prototype.l=function(f){this.u(2,f)},w.prototype.o=function(f){this.u(1,f)},w.prototype.u=function(f,b){if(this.h!=0)throw Error("Cannot settle("+f+", "+b+"): Promise already settled in state"+this.h);this.h=f,this.i=b,this.h===2&&this.G(),this.B()},w.prototype.G=function(){var f=this;B(function(){if(f.C()){var b=y.console;typeof b<"u"&&b.error(f.i)}},1)},w.prototype.C=function(){if(this.s)return!1;var f=y.CustomEvent,b=y.Event,r=y.dispatchEvent;return typeof r>"u"?!0:(typeof f=="function"?f=new f("unhandledrejection",{cancelable:!0}):typeof b=="function"?f=new b("unhandledrejection",{cancelable:!0}):(f=y.document.createEvent("CustomEvent"),f.initCustomEvent("unhandledrejection",!1,!0,f)),f.promise=this,f.reason=this.i,r(f))},w.prototype.B=function(){if(this.g!=null){for(var f=0;f<this.g.length;++f)o.h(this.g[f]);this.g=null}};var o=new S;return w.prototype.H=function(f){var b=this.j();f.M(b.resolve,b.reject)},w.prototype.I=function(f,b){var r=this.j();try{f.call(b,r.resolve,r.reject)}catch(c){r.reject(c)}},w.prototype.then=function(f,b){function r(u,l){return typeof u=="function"?function(m){try{c(u(m))}catch(F){d(F)}}:l}var c,d,e=new w(function(u,l){c=u,d=l});return this.M(r(f,c),r(b,d)),e},w.prototype.catch=function(f){return this.then(void 0,f)},w.prototype.M=function(f,b){function r(){switch(c.h){case 1:f(c.i);break;case 2:b(c.i);break;default:throw Error("Unexpected state: "+c.h)}}var c=this;this.g==null?o.h(r):this.g.push(r),this.s=!0},w.resolve=I,w.reject=function(f){return new w(function(b,r){r(f)})},w.race=function(f){return new w(function(b,r){for(var c=O(f),d=c.next();!d.done;d=c.next())I(d.value).M(b,r)})},w.all=function(f){var b=O(f),r=b.next();return r.done?I([]):new w(function(c,d){function e(m){return function(F){u[m]=F,l--,l==0&&c(u)}}var u=[],l=0;do u.push(void 0),l++,I(r.value).M(e(u.length-1),d),r=b.next();while(!r.done)})},w});function Wr(a,w){a instanceof String&&(a+="");var S=0,I=!1,B={next:function(){if(!I&&S<a.length){var o=S++;return{value:w(o,a[o]),done:!1}}return I=!0,{done:!0,value:void 0}}};return B[Symbol.iterator]=function(){return B},B}var Br=typeof Object.assign=="function"?Object.assign:function(a,w){for(var S=1;S<arguments.length;S++){var I=arguments[S];if(I)for(var B in I)Object.prototype.hasOwnProperty.call(I,B)&&(a[B]=I[B])}return a};R("Object.assign",function(a){return a||Br}),R("Object.is",function(a){return a||function(w,S){return w===S?w!==0||1/w===1/S:w!==w&&S!==S}}),R("Array.prototype.includes",function(a){return a||function(w,S){var I=this;I instanceof String&&(I=String(I));var B=I.length;for(S=S||0,0>S&&(S=Math.max(S+B,0));S<B;S++){var o=I[S];if(o===w||Object.is(o,w))return!0}return!1}}),R("String.prototype.includes",function(a){return a||function(w,S){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(w instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(w,S||0)!==-1}}),R("Array.prototype.keys",function(a){return a||function(){return Wr(this,function(w){return w})}});var Tt=this||self;function je(a,w){a=a.split(".");var S=Tt;a[0]in S||typeof S.execScript>"u"||S.execScript("var "+a[0]);for(var I;a.length&&(I=a.shift());)a.length||w===void 0?S[I]&&S[I]!==Object.prototype[I]?S=S[I]:S=S[I]={}:S[I]=w}function Ot(){throw Error("Invalid UTF8")}function tr(a,w){return w=String.fromCharCode.apply(null,w),a==null?w:a+w}var yr,Or=typeof TextDecoder<"u",wr,Pr=typeof TextEncoder<"u",rr={},Dt=null;function xr(a){var w;w===void 0&&(w=0),Ct(),w=rr[w];for(var S=Array(Math.floor(a.length/3)),I=w[64]||"",B=0,o=0;B<a.length-2;B+=3){var f=a[B],b=a[B+1],r=a[B+2],c=w[f>>2];f=w[(f&3)<<4|b>>4],b=w[(b&15)<<2|r>>6],r=w[r&63],S[o++]=c+f+b+r}switch(c=0,r=I,a.length-B){case 2:c=a[B+1],r=w[(c&15)<<2]||I;case 1:a=a[B],S[o]=w[a>>2]+w[(a&3)<<4|c>>4]+r+I}return S.join("")}function Ir(a){var w=a.length,S=3*w/4;S%3?S=Math.floor(S):"=.".indexOf(a[w-1])!=-1&&(S="=.".indexOf(a[w-2])!=-1?S-2:S-1);var I=new Uint8Array(S),B=0;return vr(a,function(o){I[B++]=o}),B!==S?I.subarray(0,B):I}function vr(a,w){function S(r){for(;I<a.length;){var c=a.charAt(I++),d=Dt[c];if(d!=null)return d;if(!/^[\s\xa0]*$/.test(c))throw Error("Unknown base64 encoding at char: "+c)}return r}Ct();for(var I=0;;){var B=S(-1),o=S(0),f=S(64),b=S(64);if(b===64&&B===-1)break;w(B<<2|o>>4),f!=64&&(w(o<<4&240|f>>2),b!=64&&w(f<<6&192|b))}}function Ct(){if(!Dt){Dt={};for(var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),w=["+/=","+/","-_=","-_.","-_"],S=0;5>S;S++){var I=a.concat(w[S].split(""));rr[S]=I;for(var B=0;B<I.length;B++){var o=I[B];Dt[o]===void 0&&(Dt[o]=B)}}}}var _r=typeof Uint8Array=="function";function lr(a){return _r&&a!=null&&a instanceof Uint8Array}var ut;function St(a){if(this.L=a,a!==null&&a.length===0)throw Error("ByteString should be constructed with non-empty values")}var Ht=typeof Uint8Array.prototype.slice=="function",xt=0,_t=0;function Zt(a,w){if(a.constructor===Uint8Array)return a;if(a.constructor===ArrayBuffer)return new Uint8Array(a);if(a.constructor===Array)return new Uint8Array(a);if(a.constructor===String)return Ir(a);if(a.constructor===St)return!w&&(w=a.L)&&w.constructor===Uint8Array?w:(w=a.L,w=w==null||lr(w)?w:typeof w=="string"?Ir(w):null,(a=a.L=w)?new Uint8Array(a):ut||(ut=new Uint8Array(0)));if(a instanceof Uint8Array)return new Uint8Array(a.buffer,a.byteOffset,a.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}function Gt(a,w){return Error("Invalid wire type: "+a+" (at position "+w+")")}function qe(){return Error("Failed to read varint, encoding is invalid.")}function mt(a,w){w=w===void 0?{}:w,w=w.v===void 0?!1:w.v,this.h=null,this.g=this.i=this.j=0,this.v=w,a&&Rt(this,a)}function Rt(a,w){a.h=Zt(w,a.v),a.j=0,a.i=a.h.length,a.g=a.j}mt.prototype.reset=function(){this.g=this.j};function We(a){if(a.g>a.i)throw Error("Tried to read past the end of the data "+a.g+" > "+a.i)}function Ft(a){var w=a.h,S=w[a.g],I=S&127;if(128>S)return a.g+=1,We(a),I;if(S=w[a.g+1],I|=(S&127)<<7,128>S)return a.g+=2,We(a),I;if(S=w[a.g+2],I|=(S&127)<<14,128>S)return a.g+=3,We(a),I;if(S=w[a.g+3],I|=(S&127)<<21,128>S)return a.g+=4,We(a),I;if(S=w[a.g+4],a.g+=5,I|=(S&15)<<28,128>S)return We(a),I;if(128<=w[a.g++]&&128<=w[a.g++]&&128<=w[a.g++]&&128<=w[a.g++]&&128<=w[a.g++])throw qe();return We(a),I}var et=[];function pt(){this.g=[]}pt.prototype.length=function(){return this.g.length},pt.prototype.end=function(){var a=this.g;return this.g=[],a};function It(a,w){for(;127<w;)a.g.push(w&127|128),w>>>=7;a.g.push(w)}function Vt(a){var w={},S=w.W===void 0?!1:w.W;this.l={v:w.v===void 0?!1:w.v},this.W=S,w=this.l,et.length?(S=et.pop(),w&&(S.v=w.v),a&&Rt(S,a),a=S):a=new mt(a,w),this.g=a,this.j=this.g.g,this.h=this.i=-1}Vt.prototype.reset=function(){this.g.reset(),this.j=this.g.g,this.h=this.i=-1};function wt(a){var w=a.g;if(w.g==w.i)return!1;a.j=a.g.g;var S=Ft(a.g)>>>0;if(w=S>>>3,S&=7,!(0<=S&&5>=S))throw Gt(S,a.j);if(1>w)throw Error("Invalid field number: "+w+" (at position "+a.j+")");return a.i=w,a.h=S,!0}function Ye(a){switch(a.h){case 0:if(a.h!=0)Ye(a);else e:{a=a.g;for(var w=a.g,S=w+10;w<S;)if((a.h[w++]&128)===0){a.g=w,We(a);break e}throw qe()}break;case 1:a=a.g,a.g+=8,We(a);break;case 2:a.h!=2?Ye(a):(w=Ft(a.g)>>>0,a=a.g,a.g+=w,We(a));break;case 5:a=a.g,a.g+=4,We(a);break;case 3:w=a.i;do{if(!wt(a))throw Error("Unmatched start-group tag: stream EOF");if(a.h==4){if(a.i!=w)throw Error("Unmatched end-group tag");break}Ye(a)}while(!0);break;default:throw Gt(a.h,a.j)}}var Lt=[];function zt(){this.i=[],this.h=0,this.g=new pt}function Et(a,w){w.length!==0&&(a.i.push(w),a.h+=w.length)}function fr(a,w){if(w=w.ca){Et(a,a.g.end());for(var S=0;S<w.length;S++)Et(a,w[S])}}var qt=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol(void 0):void 0;function sr(a,w){Object.isFrozen(a)||(qt?a[qt]|=w:a.N!==void 0?a.N|=w:Object.defineProperties(a,{N:{value:w,configurable:!0,writable:!0,enumerable:!1}}))}function hr(a){var w;return qt?w=a[qt]:w=a.N,w??0}function yt(a){return sr(a,1),a}function kt(a){return Array.isArray(a)?!!(hr(a)&2):!1}function vt(a){if(!Array.isArray(a))throw Error("cannot mark non-array as immutable");sr(a,2)}function rt(a){return a!==null&&typeof a=="object"&&!Array.isArray(a)&&a.constructor===Object}var Ut=Object.freeze(yt([]));function tt(a){if(kt(a.m))throw Error("Cannot mutate an immutable Message")}var $e=typeof Symbol<"u"&&typeof Symbol.hasInstance<"u";function nr(a){return{value:a,configurable:!1,writable:!1,enumerable:!1}}function lt(a,w,S){return w===-1?null:w>=a.i?a.g?a.g[w]:void 0:S!==void 0&&S&&a.g&&(S=a.g[w],S!=null)?S:a.m[w+a.h]}function Ce(a,w,S,I){I=I===void 0?!1:I,tt(a),w<a.i&&!I?a.m[w+a.h]=S:(a.g||(a.g=a.m[a.i+a.h]={}))[w]=S}function Se(a,w,S,I){S=S===void 0?!0:S,I=I===void 0?!1:I;var B=lt(a,w,I);return B==null&&(B=Ut),kt(a.m)?S&&(vt(B),Object.freeze(B)):(B===Ut||kt(B))&&(B=yt(B.slice()),Ce(a,w,B,I)),B}function nt(a,w,S){return a=lt(a,w),a=a==null?a:+a,a??(S===void 0?0:S)}function ee(a,w,S,I){a.j||(a.j={});var B=kt(a.m),o=a.j[S];if(!o){I=Se(a,S,!0,I===void 0?!1:I),o=[],B=B||kt(I);for(var f=0;f<I.length;f++)o[f]=new w(I[f]),B&&vt(o[f].m);B&&(vt(o),Object.freeze(o)),a.j[S]=o}return o}function ie(a,w,S,I,B){var o=o===void 0?!1:o;return tt(a),o=ee(a,S,w,o),S=I||new S,a=Se(a,w),B!=null?(o.splice(B,0,S),a.splice(B,0,S.m)):(o.push(S),a.push(S.m)),S}function ve(a,w){return a=lt(a,w),a??0}function He(a,w){return a=lt(a,w),a??""}function Ie(a){switch(typeof a){case"number":return isFinite(a)?a:String(a);case"object":if(a&&!Array.isArray(a)){if(lr(a))return xr(a);if(a instanceof St){var w=a.L;return w=w==null||typeof w=="string"?w:_r&&w instanceof Uint8Array?xr(w):null,(a.L=w)||""}}}return a}function xe(a){var w=bt;return w=w===void 0?Qe:w,ht(a,w)}function Ke(a,w){if(a!=null){if(Array.isArray(a))a=ht(a,w);else if(rt(a)){var S={},I;for(I in a)S[I]=Ke(a[I],w);a=S}else a=w(a);return a}}function ht(a,w){for(var S=a.slice(),I=0;I<S.length;I++)S[I]=Ke(S[I],w);return Array.isArray(a)&&hr(a)&1&&yt(S),S}function bt(a){return a&&typeof a=="object"&&a.toJSON?a.toJSON():(a=Ie(a),Array.isArray(a)?xe(a):a)}function Qe(a){return lr(a)?new Uint8Array(a):a}function $t(a,w,S){a||(a=Er),Er=null;var I=this.constructor.h;a||(a=I?[I]:[]),this.h=(I?0:-1)-(this.constructor.g||0),this.j=void 0,this.m=a;e:{if(I=this.m.length,a=I-1,I&&(I=this.m[a],rt(I))){this.i=a-this.h,this.g=I;break e}w!==void 0&&-1<w?(this.i=Math.max(w,a+1-this.h),this.g=void 0):this.i=Number.MAX_VALUE}if(S)for(w=0;w<S.length;w++)if(a=S[w],a<this.i)a+=this.h,(I=this.m[a])?Array.isArray(I)&&yt(I):this.m[a]=Ut;else{I=this.g||(this.g=this.m[this.i+this.h]={});var B=I[a];B?Array.isArray(B)&&yt(B):I[a]=Ut}}$t.prototype.toJSON=function(){return xe(this.m)},$t.prototype.toString=function(){return this.m.toString()};var Er;function ar(){$t.apply(this,arguments)}if(he(ar,$t),$e){var Yt={};Object.defineProperties(ar,(Yt[Symbol.hasInstance]=nr(function(){throw Error("Cannot perform instanceof checks for MutableMessage")}),Yt))}function ir(a,w,S){if(S){var I={},B;for(B in S){var o=S[B],f=o.ja;f||(I.F=o.pa||o.ha.P,o.ba?(I.U=Ar(o.ba),f=(function(b){return function(r,c,d){return b.F(r,c,d,b.U)}})(I)):o.da?(I.T=Wt(o.X.g,o.da),f=(function(b){return function(r,c,d){return b.F(r,c,d,b.T)}})(I)):f=I.F,o.ja=f),f(w,a,o.X),I={F:I.F,U:I.U,T:I.T}}}fr(w,a)}var ur=Symbol();function Pt(a,w,S){return a[ur]||(a[ur]=function(I,B){return w(I,B,S)})}function Xt(a){var w=a[ur];if(!w){var S=g(a);w=function(I,B){return E(I,B,S)},a[ur]=w}return w}function zr(a){var w=a.ba;if(w)return Xt(w);if(w=a.oa)return Pt(a.X.g,w,a.da)}function Kt(a){var w=zr(a),S=a.X,I=a.ha.O;return w?function(B,o){return I(B,o,S,w)}:function(B,o){return I(B,o,S)}}function Mt(a,w,S,I,B,o){a=a();var f=0;for(a.length&&typeof a[0]!="number"&&(S(w,a[0]),f++);f<a.length;){S=a[f++];for(var b=f+1;b<a.length&&typeof a[b]!="number";)b++;var r=a[f++];switch(b-=f,b){case 0:I(w,S,r);break;case 1:I(w,S,r,a[f++]);break;case 2:B(w,S,r,a[f++],a[f++]);break;case 3:b=a[f++];var c=a[f++],d=a[f++];Array.isArray(d)?B(w,S,r,b,c,d):o(w,S,r,b,c,d);break;case 4:o(w,S,r,a[f++],a[f++],a[f++],a[f++]);break;default:throw Error("unexpected number of binary field arguments: "+b)}}return w}var dr=Symbol();function Ar(a){var w=a[dr];if(!w){var S=er(a);w=function(I,B){return N(I,B,S)},a[dr]=w}return w}function Wt(a,w){var S=a[dr];return S||(S=function(I,B){return ir(I,B,w)},a[dr]=S),S}var jr=Symbol();function Qt(a,w){a.push(w)}function pr(a,w,S){a.push(w,S.P)}function Tr(a,w,S,I,B){var o=Ar(B),f=S.P;a.push(w,function(b,r,c){return f(b,r,c,I,o)})}function Nr(a,w,S,I,B,o){var f=Wt(I,o),b=S.P;a.push(w,function(r,c,d){return b(r,c,d,I,f)})}function er(a){var w=a[jr];return w||Mt(a,a[jr]=[],Qt,pr,Tr,Nr)}var Sr=Symbol();function $r(a,w){a[0]=w}function Yr(a,w,S,I){var B=S.O;a[w]=I?function(o,f,b){return B(o,f,b,I)}:B}function Rr(a,w,S,I,B,o){var f=S.O,b=Xt(B);a[w]=function(r,c,d){return f(r,c,d,I,b,o)}}function kr(a,w,S,I,B,o,f){var b=S.O,r=Pt(I,B,o);a[w]=function(c,d,e){return b(c,d,e,I,r,f)}}function g(a){var w=a[Sr];return w||Mt(a,a[Sr]={},$r,Yr,Rr,kr)}function E(a,w,S){for(;wt(w)&&w.h!=4;){var I=w.i,B=S[I];if(!B){var o=S[0];o&&(o=o[I])&&(B=S[I]=Kt(o))}if((!B||!B(w,a,I))&&(B=w,I=a,o=B.j,Ye(B),!B.W)){var f=B.g.h;B=B.g.g,B=o===B?ut||(ut=new Uint8Array(0)):Ht?f.slice(o,B):new Uint8Array(f.subarray(o,B)),(o=I.ca)?o.push(B):I.ca=[B]}}return a}function A(a,w,S){if(Lt.length){var I=Lt.pop();a&&(Rt(I.g,a),I.i=-1,I.h=-1),a=I}else a=new Vt(a);try{return E(new w,a,g(S))}finally{w=a.g,w.h=null,w.j=0,w.i=0,w.g=0,w.v=!1,a.i=-1,a.h=-1,100>Lt.length&&Lt.push(a)}}function N(a,w,S){for(var I=S.length,B=I%2==1,o=B?1:0;o<I;o+=2)(0,S[o+1])(w,a,S[o]);ir(a,w,B?S[0]:void 0)}function Y(a,w){var S=new zt;N(a,S,er(w)),Et(S,S.g.end()),a=new Uint8Array(S.h),w=S.i;for(var I=w.length,B=0,o=0;o<I;o++){var f=w[o];a.set(f,B),B+=f.length}return S.i=[a],a}function oe(a,w){return{O:a,P:w}}var $=oe(function(a,w,S){if(a.h!==5)return!1;a=a.g;var I=a.h[a.g],B=a.h[a.g+1],o=a.h[a.g+2],f=a.h[a.g+3];return a.g+=4,We(a),B=(I<<0|B<<8|o<<16|f<<24)>>>0,a=2*(B>>31)+1,I=B>>>23&255,B&=8388607,Ce(w,S,I==255?B?NaN:1/0*a:I==0?a*Math.pow(2,-149)*B:a*Math.pow(2,I-150)*(B+Math.pow(2,23))),!0},function(a,w,S){if(w=lt(w,S),w!=null){It(a.g,8*S+5),a=a.g;var I=w;I=(S=0>I?1:0)?-I:I,I===0?0<1/I?xt=_t=0:(_t=0,xt=2147483648):isNaN(I)?(_t=0,xt=2147483647):34028234663852886e22<I?(_t=0,xt=(S<<31|2139095040)>>>0):11754943508222875e-54>I?(I=Math.round(I/Math.pow(2,-149)),_t=0,xt=(S<<31|I)>>>0):(w=Math.floor(Math.log(I)/Math.LN2),I*=Math.pow(2,-w),I=Math.round(8388608*I),16777216<=I&&++w,_t=0,xt=(S<<31|w+127<<23|I&8388607)>>>0),S=xt,a.g.push(S>>>0&255),a.g.push(S>>>8&255),a.g.push(S>>>16&255),a.g.push(S>>>24&255)}}),ne=oe(function(a,w,S){if(a.h!==0)return!1;for(var I=a.g,B=128,o=0,f=a=0;4>f&&128<=B;f++)B=I.h[I.g++],We(I),o|=(B&127)<<7*f;if(128<=B&&(B=I.h[I.g++],We(I),o|=(B&127)<<28,a|=(B&127)>>4),128<=B)for(f=0;5>f&&128<=B;f++)B=I.h[I.g++],We(I),a|=(B&127)<<7*f+3;if(128>B)I=o>>>0,B=a>>>0,(a=B&2147483648)&&(I=~I+1>>>0,B=~B>>>0,I==0&&(B=B+1>>>0)),I=4294967296*B+(I>>>0);else throw qe();return Ce(w,S,a?-I:I),!0},function(a,w,S){if(w=lt(w,S),w!=null&&w!=null){It(a.g,8*S),a=a.g;var I=w;for(S=0>I,I=Math.abs(I),w=I>>>0,I=Math.floor((I-w)/4294967296),I>>>=0,S&&(I=~I>>>0,w=(~w>>>0)+1,4294967295<w&&(w=0,I++,4294967295<I&&(I=0))),xt=w,_t=I,S=xt,w=_t;0<w||127<S;)a.g.push(S&127|128),S=(S>>>7|w<<25)>>>0,w>>>=7;a.g.push(S)}}),ge=oe(function(a,w,S){return a.h!==0?!1:(Ce(w,S,Ft(a.g)),!0)},function(a,w,S){if(w=lt(w,S),w!=null&&w!=null)if(It(a.g,8*S),a=a.g,S=w,0<=S)It(a,S);else{for(w=0;9>w;w++)a.g.push(S&127|128),S>>=7;a.g.push(1)}}),Ae=oe(function(a,w,S){if(a.h!==2)return!1;var I=Ft(a.g)>>>0;a=a.g;var B=a.g;a.g+=I,We(a),a=a.h;var o;if(Or)(o=yr)||(o=yr=new TextDecoder("utf-8",{fatal:!0})),o=o.decode(a.subarray(B,B+I));else{I=B+I;for(var f=[],b=null,r,c,d;B<I;)r=a[B++],128>r?f.push(r):224>r?B>=I?Ot():(c=a[B++],194>r||(c&192)!==128?(B--,Ot()):f.push((r&31)<<6|c&63)):240>r?B>=I-1?Ot():(c=a[B++],(c&192)!==128||r===224&&160>c||r===237&&160<=c||((o=a[B++])&192)!==128?(B--,Ot()):f.push((r&15)<<12|(c&63)<<6|o&63)):244>=r?B>=I-2?Ot():(c=a[B++],(c&192)!==128||(r<<28)+(c-144)>>30!==0||((o=a[B++])&192)!==128||((d=a[B++])&192)!==128?(B--,Ot()):(r=(r&7)<<18|(c&63)<<12|(o&63)<<6|d&63,r-=65536,f.push((r>>10&1023)+55296,(r&1023)+56320))):Ot(),8192<=f.length&&(b=tr(b,f),f.length=0);o=tr(b,f)}return Ce(w,S,o),!0},function(a,w,S){if(w=lt(w,S),w!=null){var I=!1;if(I=I===void 0?!1:I,Pr){if(I&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(w))throw Error("Found an unpaired surrogate");w=(wr||(wr=new TextEncoder)).encode(w)}else{for(var B=0,o=new Uint8Array(3*w.length),f=0;f<w.length;f++){var b=w.charCodeAt(f);if(128>b)o[B++]=b;else{if(2048>b)o[B++]=b>>6|192;else{if(55296<=b&&57343>=b){if(56319>=b&&f<w.length){var r=w.charCodeAt(++f);if(56320<=r&&57343>=r){b=1024*(b-55296)+r-56320+65536,o[B++]=b>>18|240,o[B++]=b>>12&63|128,o[B++]=b>>6&63|128,o[B++]=b&63|128;continue}else f--}if(I)throw Error("Found an unpaired surrogate");b=65533}o[B++]=b>>12|224,o[B++]=b>>6&63|128}o[B++]=b&63|128}}w=o.subarray(0,B)}It(a.g,8*S+2),It(a.g,w.length),Et(a,a.g.end()),Et(a,w)}}),Ne=oe(function(a,w,S,I,B){if(a.h!==2)return!1;w=ie(w,S,I),S=a.g.i,I=Ft(a.g)>>>0;var o=a.g.g+I,f=o-S;if(0>=f&&(a.g.i=o,B(w,a),f=o-a.g.g),f)throw Error("Message parsing ended unexpectedly. Expected to read "+(I+" bytes, instead read "+(I-f)+" bytes, either the data ended unexpectedly or the message misreported its own length"));return a.g.g=o,a.g.i=S,!0},function(a,w,S,I,B){if(w=ee(w,I,S),w!=null)for(I=0;I<w.length;I++){var o=a;It(o.g,8*S+2);var f=o.g.end();Et(o,f),f.push(o.h),o=f,B(w[I],a),f=a;var b=o.pop();for(b=f.h+f.g.length()-b;127<b;)o.push(b&127|128),b>>>=7,f.h++;o.push(b),f.h++}});function Le(){ar.apply(this,arguments)}if(he(Le,ar),$e){var Ze={};Object.defineProperties(Le,(Ze[Symbol.hasInstance]=nr(Object[Symbol.hasInstance]),Ze))}function Ue(a){Le.call(this,a)}he(Ue,Le);function Fe(){return[1,ge,2,$,3,Ae,4,Ae]}function Be(a){Le.call(this,a,-1,st)}he(Be,Le),Be.prototype.addClassification=function(a,w){return ie(this,1,Ue,a,w),this};function Je(){return[1,Ne,Ue,Fe]}var st=[1];function ft(a){Le.call(this,a)}he(ft,Le);function gt(){return[1,$,2,$,3,$,4,$,5,$]}function jt(a){Le.call(this,a,-1,v)}he(jt,Le);function h(){return[1,Ne,ft,gt]}var v=[1];function x(a){Le.call(this,a)}he(x,Le);function j(){return[1,$,2,$,3,$,4,$,5,$,6,ne]}function W(a,w,S){if(S=a.createShader(S===0?a.VERTEX_SHADER:a.FRAGMENT_SHADER),a.shaderSource(S,w),a.compileShader(S),!a.getShaderParameter(S,a.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
|
|
20
|
-
|
|
21
|
-
`+a.getShaderInfoLog(S));return S}function X(a){return ee(a,Ue,1).map(function(w){return{index:ve(w,1),score:nt(w,2),label:lt(w,3)!=null?He(w,3):void 0,displayName:lt(w,4)!=null?He(w,4):void 0}})}function z(a){return{x:nt(a,1),y:nt(a,2),z:nt(a,3),visibility:lt(a,4)!=null?nt(a,4):void 0}}function q(a){return a.map(function(w){return ee(A(w,jt,h),ft,1).map(z)})}function ae(a,w){this.h=a,this.g=w,this.l=0}function s(a,w,S){return _(a,w),typeof a.g.canvas.transferToImageBitmap=="function"?Promise.resolve(a.g.canvas.transferToImageBitmap()):S?Promise.resolve(a.g.canvas):typeof createImageBitmap=="function"?createImageBitmap(a.g.canvas):(a.i===void 0&&(a.i=document.createElement("canvas")),new Promise(function(I){a.i.height=a.g.canvas.height,a.i.width=a.g.canvas.width,a.i.getContext("2d",{}).drawImage(a.g.canvas,0,0,a.g.canvas.width,a.g.canvas.height),I(a.i)}))}function _(a,w){var S=a.g;if(a.o===void 0){var I=W(S,`
|
|
22
|
-
attribute vec2 aVertex;
|
|
23
|
-
attribute vec2 aTex;
|
|
24
|
-
varying vec2 vTex;
|
|
25
|
-
void main(void) {
|
|
26
|
-
gl_Position = vec4(aVertex, 0.0, 1.0);
|
|
27
|
-
vTex = aTex;
|
|
28
|
-
}`,0),B=W(S,`
|
|
29
|
-
precision mediump float;
|
|
30
|
-
varying vec2 vTex;
|
|
31
|
-
uniform sampler2D sampler0;
|
|
32
|
-
void main(){
|
|
33
|
-
gl_FragColor = texture2D(sampler0, vTex);
|
|
34
|
-
}`,1),o=S.createProgram();if(S.attachShader(o,I),S.attachShader(o,B),S.linkProgram(o),!S.getProgramParameter(o,S.LINK_STATUS))throw Error(`Could not compile WebGL program.
|
|
35
|
-
|
|
36
|
-
`+S.getProgramInfoLog(o));I=a.o=o,S.useProgram(I),B=S.getUniformLocation(I,"sampler0"),a.j={K:S.getAttribLocation(I,"aVertex"),J:S.getAttribLocation(I,"aTex"),qa:B},a.u=S.createBuffer(),S.bindBuffer(S.ARRAY_BUFFER,a.u),S.enableVertexAttribArray(a.j.K),S.vertexAttribPointer(a.j.K,2,S.FLOAT,!1,0,0),S.bufferData(S.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),S.STATIC_DRAW),S.bindBuffer(S.ARRAY_BUFFER,null),a.s=S.createBuffer(),S.bindBuffer(S.ARRAY_BUFFER,a.s),S.enableVertexAttribArray(a.j.J),S.vertexAttribPointer(a.j.J,2,S.FLOAT,!1,0,0),S.bufferData(S.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),S.STATIC_DRAW),S.bindBuffer(S.ARRAY_BUFFER,null),S.uniform1i(B,0)}I=a.j,S.useProgram(a.o),S.canvas.width=w.width,S.canvas.height=w.height,S.viewport(0,0,w.width,w.height),S.activeTexture(S.TEXTURE0),a.h.bindTexture2d(w.glName),S.enableVertexAttribArray(I.K),S.bindBuffer(S.ARRAY_BUFFER,a.u),S.vertexAttribPointer(I.K,2,S.FLOAT,!1,0,0),S.enableVertexAttribArray(I.J),S.bindBuffer(S.ARRAY_BUFFER,a.s),S.vertexAttribPointer(I.J,2,S.FLOAT,!1,0,0),S.bindFramebuffer(S.DRAW_FRAMEBUFFER?S.DRAW_FRAMEBUFFER:S.FRAMEBUFFER,null),S.clearColor(0,0,0,0),S.clear(S.COLOR_BUFFER_BIT),S.colorMask(!0,!0,!0,!0),S.drawArrays(S.TRIANGLE_FAN,0,4),S.disableVertexAttribArray(I.K),S.disableVertexAttribArray(I.J),S.bindBuffer(S.ARRAY_BUFFER,null),a.h.bindTexture2d(0)}function T(a){this.g=a}var P=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 U(a,w){return w+a}function H(a,w){window[a]=w}function G(a){var w=document.createElement("script");return w.setAttribute("src",a),w.setAttribute("crossorigin","anonymous"),new Promise(function(S){w.addEventListener("load",function(){S()},!1),w.addEventListener("error",function(){S()},!1),document.body.appendChild(w)})}function re(){return me(function(a){switch(a.g){case 1:return a.o=2,J(a,WebAssembly.instantiate(P),4);case 4:a.g=3,a.o=0;break;case 2:return a.o=0,a.j=null,a.return(!1);case 3:return a.return(!0)}})}function Z(a){if(this.g=a,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=a&&a.locateFile||U,typeof window=="object")var w=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")w=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.aa=w,a.options){w=O(Object.keys(a.options));for(var S=w.next();!S.done;S=w.next()){S=S.value;var I=a.options[S].default;I!==void 0&&(this.j[S]=typeof I=="function"?I():I)}}}i=Z.prototype,i.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function ye(a){var w,S,I,B,o,f,b,r,c,d,e;return me(function(u){switch(u.g){case 1:return a.$?(w=a.g.files===void 0?[]:typeof a.g.files=="function"?a.g.files(a.j):a.g.files,J(u,re(),2)):u.return();case 2:if(S=u.h,typeof window=="object")return H("createMediapipeSolutionsWasm",{locateFile:a.locateFile}),H("createMediapipeSolutionsPackedAssets",{locateFile:a.locateFile}),f=w.filter(function(l){return l.data!==void 0}),b=w.filter(function(l){return l.data===void 0}),r=Promise.all(f.map(function(l){var m=Te(a,l.url);if(l.path!==void 0){var F=l.path;m=m.then(function(C){return a.overrideFile(F,C),Promise.resolve(C)})}return m})),c=Promise.all(b.map(function(l){return l.simd===void 0||l.simd&&S||!l.simd&&!S?G(a.locateFile(l.url,a.aa)):Promise.resolve()})).then(function(){var l,m,F;return me(function(C){if(C.g==1)return l=window.createMediapipeSolutionsWasm,m=window.createMediapipeSolutionsPackedAssets,F=a,J(C,l(m),2);F.h=C.h,C.g=0})}),d=(function(){return me(function(l){return a.g.graph&&a.g.graph.url?l=J(l,Te(a,a.g.graph.url),0):(l.g=0,l=void 0),l})})(),J(u,Promise.all([c,r,d]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return I=w.filter(function(l){return l.simd===void 0||l.simd&&S||!l.simd&&!S}).map(function(l){return a.locateFile(l.url,a.aa)}),importScripts.apply(null,L(I)),B=a,J(u,createMediapipeSolutionsWasm(Module),6);case 6:B.h=u.h,a.l=new OffscreenCanvas(1,1),a.h.canvas=a.l,o=a.h.GL.createContext(a.l,{antialias:!1,alpha:!1,na:typeof WebGL2RenderingContext<"u"?2:1}),a.h.GL.makeContextCurrent(o),u.g=4;break;case 7:if(a.l=document.createElement("canvas"),e=a.l.getContext("webgl2",{}),!e&&(e=a.l.getContext("webgl",{}),!e))return alert("Failed to create WebGL canvas context when passing video frame."),u.return();a.G=e,a.h.canvas=a.l,a.h.createContext(a.l,!0,!0,{});case 4:a.i=new a.h.SolutionWasm,a.$=!1,u.g=0}})}function _e(a){var w,S,I,B,o,f,b,r;return me(function(c){if(c.g==1){if(a.g.graph&&a.g.graph.url&&a.Z===a.g.graph.url)return c.return();if(a.s=!0,!a.g.graph||!a.g.graph.url){c.g=2;return}return a.Z=a.g.graph.url,J(c,Te(a,a.g.graph.url),3)}for(c.g!=2&&(w=c.h,a.i.loadGraph(w)),S=O(Object.keys(a.C)),I=S.next();!I.done;I=S.next())B=I.value,a.i.overrideFile(B,a.C[B]);if(a.C={},a.g.listeners)for(o=O(a.g.listeners),f=o.next();!f.done;f=o.next())b=f.value,Re(a,b);r=a.j,a.j={},a.setOptions(r),c.g=0})}i.reset=function(){var a=this;return me(function(w){a.i&&(a.i.reset(),a.o={},a.u={}),w.g=0})},i.setOptions=function(a,w){var S=this;if(w=w||this.g.options){for(var I=[],B=[],o={},f=O(Object.keys(a)),b=f.next();!b.done;o={R:o.R,S:o.S},b=f.next()){var r=b.value;r in this.j&&this.j[r]===a[r]||(this.j[r]=a[r],b=w[r],b!==void 0&&(b.onChange&&(o.R=b.onChange,o.S=a[r],I.push((function(c){return function(){var d;return me(function(e){if(e.g==1)return J(e,c.R(c.S),2);d=e.h,d===!0&&(S.s=!0),e.g=0})}})(o))),b.graphOptionXref&&(r={valueNumber:b.type===1?a[r]:0,valueBoolean:b.type===0?a[r]:!1,valueString:b.type===2?a[r]:""},b=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),b.graphOptionXref),r),B.push(b))))}(I.length!==0||B.length!==0)&&(this.s=!0,this.B=(this.B===void 0?[]:this.B).concat(B),this.A=(this.A===void 0?[]:this.A).concat(I))}};function De(a){var w,S,I,B,o,f,b;return me(function(r){switch(r.g){case 1:if(!a.s)return r.return();if(!a.A){r.g=2;break}w=O(a.A),S=w.next();case 3:if(S.done){r.g=5;break}return I=S.value,J(r,I(),4);case 4:S=w.next(),r.g=3;break;case 5:a.A=void 0;case 2:if(a.B){for(B=new a.h.GraphOptionChangeRequestList,o=O(a.B),f=o.next();!f.done;f=o.next())b=f.value,B.push_back(b);a.i.changeOptions(B),B.delete(),a.B=void 0}a.s=!1,r.g=0}})}i.initialize=function(){var a=this;return me(function(w){return w.g==1?J(w,ye(a),2):w.g!=3?J(w,_e(a),3):J(w,De(a),0)})};function Te(a,w){var S,I;return me(function(B){return w in a.H?B.return(a.H[w]):(S=a.locateFile(w,""),I=fetch(S).then(function(o){return o.arrayBuffer()}),a.H[w]=I,B.return(I))})}i.overrideFile=function(a,w){this.i?this.i.overrideFile(a,w):this.C[a]=w},i.clearOverriddenFiles=function(){this.C={},this.i&&this.i.clearOverriddenFiles()},i.send=function(a,w){var S=this,I,B,o,f,b,r,c,d,e;return me(function(u){switch(u.g){case 1:return S.g.inputs?(I=1e3*(w??performance.now()),J(u,S.D,2)):u.return();case 2:return J(u,S.initialize(),3);case 3:for(B=new S.h.PacketDataList,o=O(Object.keys(a)),f=o.next();!f.done;f=o.next())if(b=f.value,r=S.g.inputs[b]){e:{var l=a[b];switch(r.type){case"video":var m=S.o[r.stream];if(m||(m=new ae(S.h,S.G),S.o[r.stream]=m),m.l===0&&(m.l=m.h.createTexture()),typeof HTMLVideoElement<"u"&&l instanceof HTMLVideoElement)var F=l.videoWidth,C=l.videoHeight;else typeof HTMLImageElement<"u"&&l instanceof HTMLImageElement?(F=l.naturalWidth,C=l.naturalHeight):(F=l.width,C=l.height);C={glName:m.l,width:F,height:C},F=m.g,F.canvas.width=C.width,F.canvas.height=C.height,F.activeTexture(F.TEXTURE0),m.h.bindTexture2d(m.l),F.texImage2D(F.TEXTURE_2D,0,F.RGBA,F.RGBA,F.UNSIGNED_BYTE,l),m.h.bindTexture2d(0),m=C;break e;case"detections":for(m=S.o[r.stream],m||(m=new T(S.h),S.o[r.stream]=m),m.data||(m.data=new m.g.DetectionListData),m.data.reset(l.length),C=0;C<l.length;++C){F=l[C];var M=m.data,D=M.setBoundingBox,V=C,K=F.ea,Q=new x;if(Ce(Q,1,K.ka),Ce(Q,2,K.la),Ce(Q,3,K.height),Ce(Q,4,K.width),Ce(Q,5,K.rotation),Ce(Q,6,K.ia),K=Y(Q,j),D.call(M,V,K),F.Y)for(M=0;M<F.Y.length;++M){Q=F.Y[M];var se=!!Q.visibility;D=m.data,V=D.addNormalizedLandmark,K=C,Q=Object.assign(Object.assign({},Q),{visibility:se?Q.visibility:0}),se=new ft,Ce(se,1,Q.x),Ce(se,2,Q.y),Ce(se,3,Q.z),Q.visibility&&Ce(se,4,Q.visibility),Q=Y(se,gt),V.call(D,K,Q)}if(F.V)for(M=0;M<F.V.length;++M)D=m.data,V=D.addClassification,K=C,Q=F.V[M],se=new Ue,Ce(se,2,Q.score),Q.index&&Ce(se,1,Q.index),Q.label&&Ce(se,3,Q.label),Q.displayName&&Ce(se,4,Q.displayName),Q=Y(se,Fe),V.call(D,K,Q)}m=m.data;break e;default:m={}}}switch(c=m,d=r.stream,r.type){case"video":B.pushTexture2d(Object.assign(Object.assign({},c),{stream:d,timestamp:I}));break;case"detections":e=c,e.stream=d,e.timestamp=I,B.pushDetectionList(e);break;default:throw Error("Unknown input config type: '"+r.type+"'")}}return S.i.send(B),J(u,S.D,4);case 4:B.delete(),u.g=0}})};function le(a,w,S){var I,B,o,f,b,r,c,d,e,u,l,m,F,C;return me(function(M){switch(M.g){case 1:if(!S)return M.return(w);for(I={},B=0,o=O(Object.keys(S)),f=o.next();!f.done;f=o.next())b=f.value,r=S[b],typeof r!="string"&&r.type==="texture"&&w[r.stream]!==void 0&&++B;1<B&&(a.I=!1),c=O(Object.keys(S)),f=c.next();case 2:if(f.done){M.g=4;break}if(d=f.value,e=S[d],typeof e=="string")return F=I,C=d,J(M,Ee(a,d,w[e]),14);if(u=w[e.stream],e.type==="detection_list"){if(u){for(var D=u.getRectList(),V=u.getLandmarksList(),K=u.getClassificationsList(),Q=[],se=0;se<D.size();++se){var fe=A(D.get(se),x,j);fe={ea:{ka:nt(fe,1),la:nt(fe,2),height:nt(fe,3),width:nt(fe,4),rotation:nt(fe,5,0),ia:ve(fe,6)},Y:ee(A(V.get(se),jt,h),ft,1).map(z),V:X(A(K.get(se),Be,Je))},Q.push(fe)}D=Q}else D=[];I[d]=D,M.g=7;break}if(e.type==="proto_list"){if(u){for(D=Array(u.size()),V=0;V<u.size();V++)D[V]=u.get(V);u.delete()}else D=[];I[d]=D,M.g=7;break}if(u===void 0){M.g=3;break}if(e.type==="float_list"){I[d]=u,M.g=7;break}if(e.type==="proto"){I[d]=u,M.g=7;break}if(e.type!=="texture")throw Error("Unknown output config type: '"+e.type+"'");return l=a.u[d],l||(l=new ae(a.h,a.G),a.u[d]=l),J(M,s(l,u,a.I),13);case 13:m=M.h,I[d]=m;case 7:e.transform&&I[d]&&(I[d]=e.transform(I[d])),M.g=3;break;case 14:F[C]=M.h;case 3:f=c.next(),M.g=2;break;case 4:return M.return(I)}})}function Ee(a,w,S){var I;return me(function(B){return typeof S=="number"||S instanceof Uint8Array||S instanceof a.h.Uint8BlobList?B.return(S):S instanceof a.h.Texture2dDataOut?(I=a.u[w],I||(I=new ae(a.h,a.G),a.u[w]=I),B.return(s(I,S,a.I))):B.return(void 0)})}function Re(a,w){for(var S=w.name||"$",I=[].concat(L(w.wants)),B=new a.h.StringList,o=O(w.wants),f=o.next();!f.done;f=o.next())B.push_back(f.value);o=a.h.PacketListener.implement({onResults:function(b){for(var r={},c=0;c<w.wants.length;++c)r[I[c]]=b.get(c);var d=a.listeners[S];d&&(a.D=le(a,r,w.outs).then(function(e){e=d(e);for(var u=0;u<w.wants.length;++u){var l=r[I[u]];typeof l=="object"&&l.hasOwnProperty&&l.hasOwnProperty("delete")&&l.delete()}e&&(a.D=e)}))}}),a.i.attachMultiListener(B,o),B.delete()}i.onResults=function(a,w){this.listeners[w||"$"]=a},je("Solution",Z),je("OptionType",{BOOL:0,NUMBER:1,ma:2,0:"BOOL",1:"NUMBER",2:"STRING"});function ke(a){return a===void 0&&(a=0),a===1?"hand_landmark_full.tflite":"hand_landmark_lite.tflite"}function Pe(a){var w=this;a=a||{},this.g=new Z({locateFile:a.locateFile,files:function(S){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:ke(S.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:q},multiHandWorldLandmarks:{type:"proto_list",stream:"multi_hand_world_landmarks",transform:q},multiHandedness:{type:"proto_list",stream:"multi_handedness",transform:function(S){return S.map(function(I){return X(A(I,Be,Je))[0]})}}}}],options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:typeof window!="object"||window.navigator===void 0?!1:"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(S){var I,B,o;return me(function(f){return f.g==1?(I=ke(S),B="third_party/mediapipe/modules/hand_landmark/"+I,J(f,Te(w.g,I),2)):(o=f.h,w.g.overrideFile(B,o),f.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"}}}})}i=Pe.prototype,i.close=function(){return this.g.close(),Promise.resolve()},i.onResults=function(a){this.g.onResults(a)},i.initialize=function(){var a=this;return me(function(w){return J(w,a.g.initialize(),0)})},i.reset=function(){this.g.reset()},i.send=function(a){var w=this;return me(function(S){return J(S,w.g.send(a),0)})},i.setOptions=function(a){this.g.setOptions(a)},je("Hands",Pe),je("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]]),je("VERSION","0.4.1646424915")}).call(Ai);var Ti={};(function(){var i;function t(r){var c=0;return function(){return c<r.length?{done:!1,value:r[c++]}:{done:!0}}}var n=typeof Object.defineProperties=="function"?Object.defineProperty:function(r,c,d){return r==Array.prototype||r==Object.prototype||(r[c]=d.value),r};function p(r){r=[typeof globalThis=="object"&&globalThis,r,typeof window=="object"&&window,typeof self=="object"&&self,typeof global=="object"&&global];for(var c=0;c<r.length;++c){var d=r[c];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var y=p(this);function R(r,c){if(c)e:{var d=y;r=r.split(".");for(var e=0;e<r.length-1;e++){var u=r[e];if(!(u in d))break e;d=d[u]}r=r[r.length-1],e=d[r],c=c(e),c!=e&&c!=null&&n(d,r,{configurable:!0,writable:!0,value:c})}}R("Symbol",function(r){function c(l){if(this instanceof c)throw new TypeError("Symbol is not a constructor");return new d(e+(l||"")+"_"+u++,l)}function d(l,m){this.g=l,n(this,"description",{configurable:!0,writable:!0,value:m})}if(r)return r;d.prototype.toString=function(){return this.g};var e="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",u=0;return c}),R("Symbol.iterator",function(r){if(r)return r;r=Symbol("Symbol.iterator");for(var c="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),d=0;d<c.length;d++){var e=y[c[d]];typeof e=="function"&&typeof e.prototype[r]!="function"&&n(e.prototype,r,{configurable:!0,writable:!0,value:function(){return k(t(this))}})}return r});function k(r){return r={next:r},r[Symbol.iterator]=function(){return this},r}function O(r){var c=typeof Symbol<"u"&&Symbol.iterator&&r[Symbol.iterator];return c?c.call(r):{next:t(r)}}function L(r){if(!(r instanceof Array)){r=O(r);for(var c,d=[];!(c=r.next()).done;)d.push(c.value);r=d}return r}var te=typeof Object.create=="function"?Object.create:function(r){function c(){}return c.prototype=r,new c},ue;if(typeof Object.setPrototypeOf=="function")ue=Object.setPrototypeOf;else{var pe;e:{var Oe={a:!0},Me={};try{Me.__proto__=Oe,pe=Me.a;break e}catch{}pe=!1}ue=pe?function(r,c){if(r.__proto__=c,r.__proto__!==c)throw new TypeError(r+" is not extensible");return r}:null}var ce=ue;function he(r,c){if(r.prototype=te(c.prototype),r.prototype.constructor=r,ce)ce(r,c);else for(var d in c)if(d!="prototype")if(Object.defineProperties){var e=Object.getOwnPropertyDescriptor(c,d);e&&Object.defineProperty(r,d,e)}else r[d]=c[d];r.da=c.prototype}function Ge(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function Ve(r){if(r.l)throw new TypeError("Generator is already running");r.l=!0}Ge.prototype.o=function(r){this.h=r};function ct(r,c){r.j={U:c,V:!0},r.g=r.m||r.s}Ge.prototype.return=function(r){this.j={return:r},this.g=this.s};function J(r,c,d){return r.g=d,{value:c}}function Jt(r){this.g=new Ge,this.h=r}function mr(r,c){Ve(r.g);var d=r.g.i;return d?At(r,"return"in d?d.return:function(e){return{value:e,done:!0}},c,r.g.return):(r.g.return(c),Xe(r))}function At(r,c,d,e){try{var u=c.call(r.g.i,d);if(!(u instanceof Object))throw new TypeError("Iterator result "+u+" is not an object");if(!u.done)return r.g.l=!1,u;var l=u.value}catch(m){return r.g.i=null,ct(r.g,m),Xe(r)}return r.g.i=null,e.call(r.g,l),Xe(r)}function Xe(r){for(;r.g.g;)try{var c=r.h(r.g);if(c)return r.g.l=!1,{value:c.value,done:!1}}catch(d){r.g.h=void 0,ct(r.g,d)}if(r.g.l=!1,r.g.j){if(c=r.g.j,r.g.j=null,c.V)throw c.U;return{value:c.return,done:!0}}return{value:void 0,done:!0}}function Mr(r){this.next=function(c){return Ve(r.g),r.g.i?c=At(r,r.g.i.next,c,r.g.o):(r.g.o(c),c=Xe(r)),c},this.throw=function(c){return Ve(r.g),r.g.i?c=At(r,r.g.i.throw,c,r.g.o):(ct(r.g,c),c=Xe(r)),c},this.return=function(c){return mr(r,c)},this[Symbol.iterator]=function(){return this}}function at(r){function c(e){return r.next(e)}function d(e){return r.throw(e)}return new Promise(function(e,u){function l(m){m.done?e(m.value):Promise.resolve(m.value).then(c,d).then(l,u)}l(r.next())})}function me(r){return at(new Mr(new Jt(r)))}R("Promise",function(r){function c(m){this.h=0,this.i=void 0,this.g=[],this.o=!1;var F=this.j();try{m(F.resolve,F.reject)}catch(C){F.reject(C)}}function d(){this.g=null}function e(m){return m instanceof c?m:new c(function(F){F(m)})}if(r)return r;d.prototype.h=function(m){if(this.g==null){this.g=[];var F=this;this.i(function(){F.l()})}this.g.push(m)};var u=y.setTimeout;d.prototype.i=function(m){u(m,0)},d.prototype.l=function(){for(;this.g&&this.g.length;){var m=this.g;this.g=[];for(var F=0;F<m.length;++F){var C=m[F];m[F]=null;try{C()}catch(M){this.j(M)}}}this.g=null},d.prototype.j=function(m){this.i(function(){throw m})},c.prototype.j=function(){function m(M){return function(D){C||(C=!0,M.call(F,D))}}var F=this,C=!1;return{resolve:m(this.C),reject:m(this.l)}},c.prototype.C=function(m){if(m===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(m instanceof c)this.F(m);else{e:switch(typeof m){case"object":var F=m!=null;break e;case"function":F=!0;break e;default:F=!1}F?this.v(m):this.m(m)}},c.prototype.v=function(m){var F=void 0;try{F=m.then}catch(C){this.l(C);return}typeof F=="function"?this.G(F,m):this.m(m)},c.prototype.l=function(m){this.s(2,m)},c.prototype.m=function(m){this.s(1,m)},c.prototype.s=function(m,F){if(this.h!=0)throw Error("Cannot settle("+m+", "+F+"): Promise already settled in state"+this.h);this.h=m,this.i=F,this.h===2&&this.D(),this.A()},c.prototype.D=function(){var m=this;u(function(){if(m.B()){var F=y.console;typeof F<"u"&&F.error(m.i)}},1)},c.prototype.B=function(){if(this.o)return!1;var m=y.CustomEvent,F=y.Event,C=y.dispatchEvent;return typeof C>"u"?!0:(typeof m=="function"?m=new m("unhandledrejection",{cancelable:!0}):typeof F=="function"?m=new F("unhandledrejection",{cancelable:!0}):(m=y.document.createEvent("CustomEvent"),m.initCustomEvent("unhandledrejection",!1,!0,m)),m.promise=this,m.reason=this.i,C(m))},c.prototype.A=function(){if(this.g!=null){for(var m=0;m<this.g.length;++m)l.h(this.g[m]);this.g=null}};var l=new d;return c.prototype.F=function(m){var F=this.j();m.J(F.resolve,F.reject)},c.prototype.G=function(m,F){var C=this.j();try{m.call(F,C.resolve,C.reject)}catch(M){C.reject(M)}},c.prototype.then=function(m,F){function C(K,Q){return typeof K=="function"?function(se){try{M(K(se))}catch(fe){D(fe)}}:Q}var M,D,V=new c(function(K,Q){M=K,D=Q});return this.J(C(m,M),C(F,D)),V},c.prototype.catch=function(m){return this.then(void 0,m)},c.prototype.J=function(m,F){function C(){switch(M.h){case 1:m(M.i);break;case 2:F(M.i);break;default:throw Error("Unexpected state: "+M.h)}}var M=this;this.g==null?l.h(C):this.g.push(C),this.o=!0},c.resolve=e,c.reject=function(m){return new c(function(F,C){C(m)})},c.race=function(m){return new c(function(F,C){for(var M=O(m),D=M.next();!D.done;D=M.next())e(D.value).J(F,C)})},c.all=function(m){var F=O(m),C=F.next();return C.done?e([]):new c(function(M,D){function V(se){return function(fe){K[se]=fe,Q--,Q==0&&M(K)}}var K=[],Q=0;do K.push(void 0),Q++,e(C.value).J(V(K.length-1),D),C=F.next();while(!C.done)})},c});function Wr(r,c){r instanceof String&&(r+="");var d=0,e=!1,u={next:function(){if(!e&&d<r.length){var l=d++;return{value:c(l,r[l]),done:!1}}return e=!0,{done:!0,value:void 0}}};return u[Symbol.iterator]=function(){return u},u}var Br=typeof Object.assign=="function"?Object.assign:function(r,c){for(var d=1;d<arguments.length;d++){var e=arguments[d];if(e)for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&(r[u]=e[u])}return r};R("Object.assign",function(r){return r||Br}),R("Object.is",function(r){return r||function(c,d){return c===d?c!==0||1/c===1/d:c!==c&&d!==d}}),R("Array.prototype.includes",function(r){return r||function(c,d){var e=this;e instanceof String&&(e=String(e));var u=e.length;for(d=d||0,0>d&&(d=Math.max(d+u,0));d<u;d++){var l=e[d];if(l===c||Object.is(l,c))return!0}return!1}}),R("String.prototype.includes",function(r){return r||function(c,d){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(c instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(c,d||0)!==-1}}),R("Array.prototype.keys",function(r){return r||function(){return Wr(this,function(c){return c})}});var Tt=this||self;function je(r,c){r=r.split(".");var d=Tt;r[0]in d||typeof d.execScript>"u"||d.execScript("var "+r[0]);for(var e;r.length&&(e=r.shift());)r.length||c===void 0?d[e]&&d[e]!==Object.prototype[e]?d=d[e]:d=d[e]={}:d[e]=c}function Ot(r){Tt.setTimeout(function(){throw r},0)}function tr(r){Ot(r)}function yr(r,c){tr(Error("Invalid wire type: "+r+" (at position "+c+")"))}function Or(){tr(Error("Failed to read varint, encoding is invalid."))}function wr(r,c){return c=String.fromCharCode.apply(null,c),r==null?c:r+c}var Pr,rr=typeof TextDecoder<"u",Dt,xr=typeof TextEncoder<"u";function Ir(r){if(xr)r=(Dt||(Dt=new TextEncoder)).encode(r);else{var c=void 0;c=c===void 0?!1:c;for(var d=0,e=new Uint8Array(3*r.length),u=0;u<r.length;u++){var l=r.charCodeAt(u);if(128>l)e[d++]=l;else{if(2048>l)e[d++]=l>>6|192;else{if(55296<=l&&57343>=l){if(56319>=l&&u<r.length){var m=r.charCodeAt(++u);if(56320<=m&&57343>=m){l=1024*(l-55296)+m-56320+65536,e[d++]=l>>18|240,e[d++]=l>>12&63|128,e[d++]=l>>6&63|128,e[d++]=l&63|128;continue}else u--}if(c)throw Error("Found an unpaired surrogate");l=65533}e[d++]=l>>12|224,e[d++]=l>>6&63|128}e[d++]=l&63|128}}r=e.subarray(0,d)}return r}var vr={},Ct=null;function _r(r){var c;c===void 0&&(c=0),St(),c=vr[c];for(var d=Array(Math.floor(r.length/3)),e=c[64]||"",u=0,l=0;u<r.length-2;u+=3){var m=r[u],F=r[u+1],C=r[u+2],M=c[m>>2];m=c[(m&3)<<4|F>>4],F=c[(F&15)<<2|C>>6],C=c[C&63],d[l++]=M+m+F+C}switch(M=0,C=e,r.length-u){case 2:M=r[u+1],C=c[(M&15)<<2]||e;case 1:r=r[u],d[l]=c[r>>2]+c[(r&3)<<4|M>>4]+C+e}return d.join("")}function lr(r){var c=r.length,d=3*c/4;d%3?d=Math.floor(d):"=.".indexOf(r[c-1])!=-1&&(d="=.".indexOf(r[c-2])!=-1?d-2:d-1);var e=new Uint8Array(d),u=0;return ut(r,function(l){e[u++]=l}),e.subarray(0,u)}function ut(r,c){function d(C){for(;e<r.length;){var M=r.charAt(e++),D=Ct[M];if(D!=null)return D;if(!/^[\s\xa0]*$/.test(M))throw Error("Unknown base64 encoding at char: "+M)}return C}St();for(var e=0;;){var u=d(-1),l=d(0),m=d(64),F=d(64);if(F===64&&u===-1)break;c(u<<2|l>>4),m!=64&&(c(l<<4&240|m>>2),F!=64&&c(m<<6&192|F))}}function St(){if(!Ct){Ct={};for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),c=["+/=","+/","-_=","-_.","-_"],d=0;5>d;d++){var e=r.concat(c[d].split(""));vr[d]=e;for(var u=0;u<e.length;u++){var l=e[u];Ct[l]===void 0&&(Ct[l]=u)}}}}var Ht=typeof Uint8Array=="function",xt;function _t(r){if(this.g=r,r!==null&&r.length===0)throw Error("ByteString should be constructed with non-empty values")}_t.prototype.toJSON=function(){if(this.g==null)var r="";else r=this.g,r=this.g=r==null||typeof r=="string"?r:Ht&&r instanceof Uint8Array?_r(r):null;return r};var Zt=typeof Uint8Array.prototype.slice=="function";function Gt(r,c,d){return c===d?xt||(xt=new Uint8Array(0)):Zt?r.slice(c,d):new Uint8Array(r.subarray(c,d))}var qe=0,mt=0;function Rt(r){if(r.constructor===Uint8Array)return r;if(r.constructor===ArrayBuffer)return new Uint8Array(r);if(r.constructor===Array)return new Uint8Array(r);if(r.constructor===String)return lr(r);if(r.constructor===_t){if(r.g==null)var c=xt||(xt=new Uint8Array(0));else{c=Uint8Array;var d=r.g;d=d==null||Ht&&d!=null&&d instanceof Uint8Array?d:typeof d=="string"?lr(d):null,r=r.g=d,c=new c(r)}return c}if(r instanceof Uint8Array)return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}function We(r,c){c=c===void 0?{}:c,c=c.u===void 0?!1:c.u,this.h=null,this.g=this.i=this.m=0,this.l=!1,this.u=c,r&&Ft(this,r)}function Ft(r,c){r.h=Rt(c),r.m=0,r.i=r.h.length,r.g=r.m}We.prototype.reset=function(){this.g=this.m};function et(r){for(var c=128,d=0,e=0,u=0;4>u&&128<=c;u++)c=r.h[r.g++],d|=(c&127)<<7*u;if(128<=c&&(c=r.h[r.g++],d|=(c&127)<<28,e|=(c&127)>>4),128<=c)for(u=0;5>u&&128<=c;u++)c=r.h[r.g++],e|=(c&127)<<7*u+3;if(128>c)return r=d>>>0,c=e>>>0,(e=c&2147483648)&&(r=~r+1>>>0,c=~c>>>0,r==0&&(c=c+1>>>0)),r=4294967296*c+(r>>>0),e?-r:r;r.l=!0,Or()}function pt(r){r.g>r.i&&(r.l=!0,tr(Error("Tried to read past the end of the data "+r.g+" > "+r.i)))}We.prototype.j=function(){var r=this.h,c=r[this.g],d=c&127;return 128>c?(this.g+=1,pt(this),d):(c=r[this.g+1],d|=(c&127)<<7,128>c?(this.g+=2,pt(this),d):(c=r[this.g+2],d|=(c&127)<<14,128>c?(this.g+=3,pt(this),d):(c=r[this.g+3],d|=(c&127)<<21,128>c?(this.g+=4,pt(this),d):(c=r[this.g+4],d|=(c&15)<<28,128>c?(this.g+=5,pt(this),d>>>0):(this.g+=5,128<=r[this.g++]&&128<=r[this.g++]&&128<=r[this.g++]&&128<=r[this.g++]&&128<=r[this.g++]?(this.l=!0,Or(),d):(pt(this),d))))))},We.prototype.o=function(){var r=this.h[this.g],c=this.h[this.g+1],d=this.h[this.g+2],e=this.h[this.g+3];return this.g+=4,pt(this),d=(r<<0|c<<8|d<<16|e<<24)>>>0,r=2*(d>>31)+1,c=d>>>23&255,d&=8388607,c==255?d?NaN:1/0*r:c==0?r*Math.pow(2,-149)*d:r*Math.pow(2,c-150)*(d+Math.pow(2,23))};var It=[];function Vt(){this.g=new Uint8Array(64),this.h=0}function wt(r,c){if(!(r.h+1<r.g.length)){var d=r.g;r.g=new Uint8Array(Math.ceil(1+2*r.g.length)),r.g.set(d)}r.g[r.h++]=c}Vt.prototype.length=function(){return this.h},Vt.prototype.end=function(){var r=this.g,c=this.h;return this.h=0,Gt(r,0,c)};function Ye(r,c){for(;127<c;)wt(r,c&127|128),c>>>=7;wt(r,c)}function Lt(r){var c={},d=c.N===void 0?!1:c.N;this.m={u:c.u===void 0?!1:c.u},this.N=d,c=this.m,It.length?(d=It.pop(),c&&(d.u=c.u),r&&Ft(d,r),r=d):r=new We(r,c),this.g=r,this.l=this.g.g,this.h=this.i=-1,this.j=!1}Lt.prototype.reset=function(){this.g.reset(),this.h=this.i=-1};function zt(r){var c=r.g;if((c=c.g==c.i)||(c=r.j)||(c=r.g,c=c.l||0>c.g||c.g>c.i),c)return!1;r.l=r.g.g;var d=r.g.j();return c=d>>>3,d&=7,0<=d&&5>=d?(r.i=c,r.h=d,!0):(r.j=!0,yr(d,r.l),!1)}function Et(r){switch(r.h){case 0:if(r.h!=0)Et(r);else e:{r=r.g;for(var c=r.g,d=0;10>d;d++){if((r.h[c]&128)===0){r.g=c+1,pt(r);break e}c++}r.l=!0,Or()}break;case 1:r=r.g,r.g+=8,pt(r);break;case 2:r.h!=2?Et(r):(c=r.g.j(),r=r.g,r.g+=c,pt(r));break;case 5:r=r.g,r.g+=4,pt(r);break;case 3:c=r.i;do{if(!zt(r)){r.j=!0,tr(Error("Unmatched start-group tag: stream EOF"));break}if(r.h==4){r.i!=c&&(r.j=!0,tr(Error("Unmatched end-group tag")));break}Et(r)}while(!0);break;default:r.j=!0,yr(r.h,r.l)}}function fr(r,c,d){r.N||(r=Gt(r.g.h,d,r.g.g),(d=c.o)?d.push(r):c.o=[r])}function qt(r,c,d){var e=r.g.i,u=r.g.j(),l=r.g.g+u;if(r.g.i=l,d(c,r),d=l-r.g.g,d!==0)throw Error("Message parsing ended unexpectedly. Expected to read "+(u+" bytes, instead read "+(u-d)+" bytes, either the data ended unexpectedly or the message misreported its own length"));return r.g.g=l,r.g.i=e,c}function sr(r,c,d){var e=r.g.j();for(e=r.g.g+e;r.g.g<e;)d.push(c.call(r.g))}var hr=[];function yt(){this.h=[],this.i=0,this.g=new Vt}function kt(r,c){c.length!==0&&(r.h.push(c),r.i+=c.length)}function vt(r,c,d){Ye(r.g,8*c+2),Ye(r.g,d.length),kt(r,r.g.end()),kt(r,d)}var rt=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol(void 0):void 0;function Ut(r,c){Object.isFrozen(r)||(rt?r[rt]|=c:r.g!==void 0?r.g|=c:Object.defineProperties(r,{g:{value:c,configurable:!0,writable:!0,enumerable:!1}}))}function tt(r){if(!r)return 0;var c;return rt?c=r[rt]:c=r.g,c??0}function $e(r){return Array.isArray(r)&&Ut(r,1),r}function nr(r){if(!Array.isArray(r))throw Error("cannot mark non-array as immutable");Ut(r,2)}function lt(r){return r!==null&&typeof r=="object"&&r.constructor===Object}function Ce(r){switch(typeof r){case"number":return isFinite(r)?r:String(r);case"object":return Ht&&r!=null&&r instanceof Uint8Array?_r(r):r;default:return r}}function Se(r,c){if(r!=null)return Array.isArray(r)||lt(r)?nt(r,c):c(r)}function nt(r,c){if(Array.isArray(r)){for(var d=Array(r.length),e=0;e<r.length;e++)d[e]=Se(r[e],c);return tt(r)&1&&$e(d),d}d={};for(e in r)d[e]=Se(r[e],c);return d}var ee;function ie(r,c,d){var e=ee;ee=null,r||(r=e),e=this.constructor.ba,r||(r=e?[e]:[]),this.j=(e?0:-1)-(this.constructor.$||0),this.m=this.g=null,this.h=r;e:{if(e=this.h.length,r=e-1,e&&(e=this.h[r],lt(e))){this.l=r-this.j,this.i=e;break e}c!==void 0&&-1<c?(this.l=Math.max(c,r+1-this.j),this.i=null):this.l=Number.MAX_VALUE}if(d)for(c=0;c<d.length;c++)r=d[c],r<this.l?(r+=this.j,(e=this.h[r])?$e(e):this.h[r]=ve):(He(this),(e=this.i[r])?$e(e):this.i[r]=ve)}var ve=Object.freeze($e([]));function He(r){var c=r.l+r.j;r.h[c]||(r.i=r.h[c]={})}function Ie(r,c,d){return c===-1?null:d!==void 0&&d||c>=r.l?r.i?r.i[c]:void 0:r.h[c+r.j]}function xe(r,c,d){d=d===void 0?!0:d;var e=e===void 0?!1:e,u=Ie(r,c,e);return u==null&&(u=ve),u===ve?(u=$e([]),Qe(r,c,u,e)):d&&Array.isArray(u)&&tt(u)&2&&(u=u.slice(),Qe(r,c,u,e)),u}function Ke(r){var c=xe(r,3,!1);if(r.m||(r.m={}),!r.m[3]){for(var d=0;d<c.length;d++)c[d]=+c[d];r.m[3]=!0}return c}function ht(r,c,d){return r=Ie(r,c),r??d}function bt(r,c,d){return r=Ie(r,c),r=r==null?r:+r,r??(d===void 0?0:d)}function Qe(r,c,d,e){e!==void 0&&e||c>=r.l?(He(r),r.i[c]=d):r.h[c+r.j]=d}function $t(r,c,d){if(d===-1)return null;r.g||(r.g={});var e=r.g[d];if(e)return e;var u=Ie(r,d,!1);return u==null?e:(c=new c(u),r.g[d]=c)}function Er(r,c,d){r.g||(r.g={});var e=r.g[d];if(!e){var u=xe(r,d,!1);e=[];for(var l=Array.isArray(u)?!!(tt(u)&2):!1,m=0;m<u.length;m++)e[m]=new c(u[m]),l&&nr(e[m].h);l&&(nr(e),Object.freeze(e)),r.g[d]=e}return e}function ar(r,c,d,e,u){var l=Er(r,e,c);d=d||new e,r=xe(r,c),u!=null?(l.splice(u,0,d),r.splice(u,0,Yt(d))):(l.push(d),r.push(Yt(d)))}ie.prototype.toJSON=function(){var r=Yt(this);return nt(r,Ce)};function Yt(r){if(r.g)for(var c in r.g){var d=r.g[c];if(Array.isArray(d))for(var e=0;e<d.length;e++)d[e]&&Yt(d[e]);else d&&Yt(d)}return r.h}ie.prototype.toString=function(){return Yt(this).toString()};function ir(r,c){if(r=r.o){kt(c,c.g.end());for(var d=0;d<r.length;d++)kt(c,r[d])}}function ur(r){var c=r[0];switch(r.length){case 2:var d=r[1];return function(C,M,D){return c(C,M,D,d)};case 3:var e=r[1],u=r[2];return function(C,M,D){return c(C,M,D,e,u)};case 4:var l=r[1],m=r[2],F=r[3];return function(C,M,D){return c(C,M,D,l,m,F)};default:throw Error("unsupported number of parameters, expected [2-4], got "+r.length)}}function Pt(r,c,d){for(;zt(c)&&c.h!=4;){var e=c.i,u=d[e];if(u){if(Array.isArray(u)&&(u=d[e]=ur(u)),!u(c,r,e)){e=c,u=r;var l=e.l;Et(e),fr(e,u,l)}}else e=c,u=r,l=e.l,Et(e),fr(e,u,l)}return r}function Xt(r,c){var d=new yt;if(c(r,d),r=d.i+d.g.length(),r===0)d=new Uint8Array(0);else{r=new Uint8Array(r);for(var e=d.h,u=e.length,l=c=0;l<u;l++){var m=e[l];m.length!==0&&(r.set(m,c),c+=m.length)}e=d.g,u=e.h,u!==0&&(r.set(e.g.subarray(0,u),c),e.h=0),d.h=[r],d=r}return d}function zr(r,c,d){if(hr.length){var e=hr.pop();r&&(Ft(e.g,r),e.i=-1,e.h=-1),r=e}else r=new Lt(r);try{return d(new c,r)}finally{c=r.g,c.h=null,c.m=0,c.i=0,c.g=0,c.l=!1,c.u=!1,r.i=-1,r.h=-1,r.j=!1,100>hr.length&&hr.push(r)}}function Kt(r,c,d){if(c=Ie(c,d),c!=null){Ye(r.g,8*d+5),r=r.g;var e=c;e=(d=0>e?1:0)?-e:e,e===0?0<1/e?qe=mt=0:(mt=0,qe=2147483648):isNaN(e)?(mt=0,qe=2147483647):34028234663852886e22<e?(mt=0,qe=(d<<31|2139095040)>>>0):11754943508222875e-54>e?(e=Math.round(e/Math.pow(2,-149)),mt=0,qe=(d<<31|e)>>>0):(c=Math.floor(Math.log(e)/Math.LN2),e*=Math.pow(2,-c),e=Math.round(8388608*e),16777216<=e&&++c,mt=0,qe=(d<<31|c+127<<23|e&8388607)>>>0),d=qe,wt(r,d>>>0&255),wt(r,d>>>8&255),wt(r,d>>>16&255),wt(r,d>>>24&255)}}function Mt(r,c,d){return r.h!==5?!1:(Qe(c,d,r.g.o()),!0)}function dr(r,c,d){return r.h!==5&&r.h!==2?!1:(c=xe(c,d),r.h==2?sr(r,We.prototype.o,c):c.push(r.g.o()),!0)}function Ar(r,c,d){return r.h!==0?!1:(Qe(c,d,et(r.g)),!0)}function Wt(r,c,d){return r.h!==0?!1:(Qe(c,d,r.g.j()),!0)}function jr(r,c,d){if(r.h!==2)return!1;var e=r.g.j();r=r.g;var u=r.g;r.g+=e,pt(r),r=r.h;var l;if(rr)(l=Pr)||(l=Pr=new TextDecoder("utf-8",{fatal:!1})),l=l.decode(r.subarray(u,u+e));else{e=u+e;for(var m=[],F=null,C,M,D;u<e;)C=r[u++],128>C?m.push(C):224>C?u>=e?m.push(65533):(M=r[u++],194>C||(M&192)!==128?(u--,m.push(65533)):m.push((C&31)<<6|M&63)):240>C?u>=e-1?m.push(65533):(M=r[u++],(M&192)!==128||C===224&&160>M||C===237&&160<=M||((l=r[u++])&192)!==128?(u--,m.push(65533)):m.push((C&15)<<12|(M&63)<<6|l&63)):244>=C?u>=e-2?m.push(65533):(M=r[u++],(M&192)!==128||(C<<28)+(M-144)>>30!==0||((l=r[u++])&192)!==128||((D=r[u++])&192)!==128?(u--,m.push(65533)):(C=(C&7)<<18|(M&63)<<12|(l&63)<<6|D&63,C-=65536,m.push((C>>10&1023)+55296,(C&1023)+56320))):m.push(65533),8192<=m.length&&(F=wr(F,m),m.length=0);l=wr(F,m)}return Qe(c,d,l),!0}function Qt(r,c,d,e,u){if(r.h!==2)return!1;r=qt(r,new e,u);var l=l===void 0?!1:l;return c.g||(c.g={}),e=r&&Yt(r),c.g[d]=r,Qe(c,d,e,l),!0}function pr(r,c,d,e,u){return r.h!==2?!1:(r=qt(r,new e,u),ar(c,d,r,e,void 0),!0)}function Tr(r,c,d){return r.h!==0&&r.h!==2?!1:(c=xe(c,d),r.h==2?sr(r,We.prototype.j,c):c.push(r.g.j()),!0)}function Nr(r,c,d){return r.h!==0?!1:(Qe(c,d,et(r.g)),!0)}function er(r){ie.call(this,r,-1,Yr)}var Sr;he(er,ie),er.prototype.getRows=function(){return Ie(this,1)},er.prototype.getCols=function(){return Ie(this,2)},er.prototype.getPackedDataList=function(){return Ke(this)},er.prototype.getLayout=function(){return ht(this,4,0)};function $r(r,c){return Pt(r,c,Sr||(Sr={1:Wt,2:Wt,3:dr,4:Nr}))}var Yr=[3];function Rr(r){ie.call(this,r)}var kr;he(Rr,ie);function g(r,c){var d=Ie(r,1);if(d!=null&&d!=null){Ye(c.g,8);var e=c.g;if(0<=d)Ye(e,d);else{for(var u=0;9>u;u++)wt(e,d&127|128),d>>=7;wt(e,1)}}Kt(c,r,2),e=Ie(r,3),e!=null&&vt(c,3,Ir(e)),e=Ie(r,4),e!=null&&vt(c,4,Ir(e)),ir(r,c)}function E(r,c){return Pt(r,c,kr||(kr={1:Wt,2:Mt,3:jr,4:jr}))}function A(r){ie.call(this,r,-1,oe)}var N;he(A,ie),A.prototype.addClassification=function(r,c){return ar(this,1,r,Rr,c),this};function Y(r,c){return Pt(r,c,N||(N={1:[pr,Rr,E]}))}var oe=[1];function $(r){ie.call(this,r)}var ne;he($,ie);function ge(r,c){Kt(c,r,1),Kt(c,r,2),Kt(c,r,3),Kt(c,r,4),Kt(c,r,5),ir(r,c)}function Ae(r,c){return Pt(r,c,ne||(ne={1:Mt,2:Mt,3:Mt,4:Mt,5:Mt}))}function Ne(r){ie.call(this,r,-1,Ue)}var Le;he(Ne,ie);function Ze(r,c){return Pt(r,c,Le||(Le={1:[pr,$,Ae]}))}var Ue=[1];function Fe(r){ie.call(this,r)}var Be;he(Fe,ie);function Je(r,c){Kt(c,r,1),Kt(c,r,2),Kt(c,r,3),Kt(c,r,4),Kt(c,r,5);var d=Ie(r,6);if(d!=null&&d!=null){Ye(c.g,48);var e=c.g,u=d;d=0>u,u=Math.abs(u);var l=u>>>0;for(u=Math.floor((u-l)/4294967296),u>>>=0,d&&(u=~u>>>0,l=(~l>>>0)+1,4294967295<l&&(l=0,u++,4294967295<u&&(u=0))),qe=l,mt=u,d=qe,l=mt;0<l||127<d;)wt(e,d&127|128),d=(d>>>7|l<<25)>>>0,l>>>=7;wt(e,d)}ir(r,c)}function st(r,c){return Pt(r,c,Be||(Be={1:Mt,2:Mt,3:Mt,4:Mt,5:Mt,6:Ar}))}function ft(r){ie.call(this,r,-1,h)}var gt;he(ft,ie),ft.prototype.getVertexType=function(){return ht(this,1,0)},ft.prototype.getPrimitiveType=function(){return ht(this,2,0)},ft.prototype.getVertexBufferList=function(){return Ke(this)},ft.prototype.getIndexBufferList=function(){return xe(this,4)};function jt(r,c){return Pt(r,c,gt||(gt={1:Nr,2:Nr,3:dr,4:Tr}))}var h=[3,4];function v(r){ie.call(this,r)}var x;he(v,ie),v.prototype.getMesh=function(){return $t(this,ft,1)},v.prototype.getPoseTransformMatrix=function(){return $t(this,er,2)};function j(r,c){return Pt(r,c,x||(x={1:[Qt,ft,jt],2:[Qt,er,$r]}))}var W=[[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]],X=[[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]],z=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],q=[[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]],ae=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],s=[[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]],_=[].concat(L(W),L(X),L(z),L(q),L(ae),L(s));function T(r,c,d){if(d=r.createShader(d===0?r.VERTEX_SHADER:r.FRAGMENT_SHADER),r.shaderSource(d,c),r.compileShader(d),!r.getShaderParameter(d,r.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
|
|
37
|
-
|
|
38
|
-
`+r.getShaderInfoLog(d));return d}function P(r){return Er(r,Rr,1).map(function(c){return{index:ht(c,1,0),score:bt(c,2),label:Ie(c,3)!=null?ht(c,3,""):void 0,displayName:Ie(c,4)!=null?ht(c,4,""):void 0}})}function U(r){return{x:bt(r,1),y:bt(r,2),z:bt(r,3),visibility:Ie(r,4)!=null?bt(r,4):void 0}}function H(r){return Er(zr(r,Ne,Ze),$,1).map(U)}function G(r,c){this.h=r,this.g=c,this.l=0}function re(r,c,d){return Z(r,c),typeof r.g.canvas.transferToImageBitmap=="function"?Promise.resolve(r.g.canvas.transferToImageBitmap()):d?Promise.resolve(r.g.canvas):typeof createImageBitmap=="function"?createImageBitmap(r.g.canvas):(r.i===void 0&&(r.i=document.createElement("canvas")),new Promise(function(e){r.i.height=r.g.canvas.height,r.i.width=r.g.canvas.width,r.i.getContext("2d",{}).drawImage(r.g.canvas,0,0,r.g.canvas.width,r.g.canvas.height),e(r.i)}))}function Z(r,c){var d=r.g;if(r.m===void 0){var e=T(d,`
|
|
39
|
-
attribute vec2 aVertex;
|
|
40
|
-
attribute vec2 aTex;
|
|
41
|
-
varying vec2 vTex;
|
|
42
|
-
void main(void) {
|
|
43
|
-
gl_Position = vec4(aVertex, 0.0, 1.0);
|
|
44
|
-
vTex = aTex;
|
|
45
|
-
}`,0),u=T(d,`
|
|
46
|
-
precision mediump float;
|
|
47
|
-
varying vec2 vTex;
|
|
48
|
-
uniform sampler2D sampler0;
|
|
49
|
-
void main(){
|
|
50
|
-
gl_FragColor = texture2D(sampler0, vTex);
|
|
51
|
-
}`,1),l=d.createProgram();if(d.attachShader(l,e),d.attachShader(l,u),d.linkProgram(l),!d.getProgramParameter(l,d.LINK_STATUS))throw Error(`Could not compile WebGL program.
|
|
52
|
-
|
|
53
|
-
`+d.getProgramInfoLog(l));e=r.m=l,d.useProgram(e),u=d.getUniformLocation(e,"sampler0"),r.j={I:d.getAttribLocation(e,"aVertex"),H:d.getAttribLocation(e,"aTex"),ca:u},r.s=d.createBuffer(),d.bindBuffer(d.ARRAY_BUFFER,r.s),d.enableVertexAttribArray(r.j.I),d.vertexAttribPointer(r.j.I,2,d.FLOAT,!1,0,0),d.bufferData(d.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),d.STATIC_DRAW),d.bindBuffer(d.ARRAY_BUFFER,null),r.o=d.createBuffer(),d.bindBuffer(d.ARRAY_BUFFER,r.o),d.enableVertexAttribArray(r.j.H),d.vertexAttribPointer(r.j.H,2,d.FLOAT,!1,0,0),d.bufferData(d.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),d.STATIC_DRAW),d.bindBuffer(d.ARRAY_BUFFER,null),d.uniform1i(u,0)}e=r.j,d.useProgram(r.m),d.canvas.width=c.width,d.canvas.height=c.height,d.viewport(0,0,c.width,c.height),d.activeTexture(d.TEXTURE0),r.h.bindTexture2d(c.glName),d.enableVertexAttribArray(e.I),d.bindBuffer(d.ARRAY_BUFFER,r.s),d.vertexAttribPointer(e.I,2,d.FLOAT,!1,0,0),d.enableVertexAttribArray(e.H),d.bindBuffer(d.ARRAY_BUFFER,r.o),d.vertexAttribPointer(e.H,2,d.FLOAT,!1,0,0),d.bindFramebuffer(d.DRAW_FRAMEBUFFER?d.DRAW_FRAMEBUFFER:d.FRAMEBUFFER,null),d.clearColor(0,0,0,0),d.clear(d.COLOR_BUFFER_BIT),d.colorMask(!0,!0,!0,!0),d.drawArrays(d.TRIANGLE_FAN,0,4),d.disableVertexAttribArray(e.I),d.disableVertexAttribArray(e.H),d.bindBuffer(d.ARRAY_BUFFER,null),r.h.bindTexture2d(0)}function ye(r){this.g=r}var _e=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(r,c){return c+r}function Te(r,c){window[r]=c}function le(r){var c=document.createElement("script");return c.setAttribute("src",r),c.setAttribute("crossorigin","anonymous"),new Promise(function(d){c.addEventListener("load",function(){d()},!1),c.addEventListener("error",function(){d()},!1),document.body.appendChild(c)})}function Ee(){return me(function(r){switch(r.g){case 1:return r.m=2,J(r,WebAssembly.instantiate(_e),4);case 4:r.g=3,r.m=0;break;case 2:return r.m=0,r.j=null,r.return(!1);case 3:return r.return(!0)}})}function Re(r){if(this.g=r,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=r&&r.locateFile||De,typeof window=="object")var c=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")c=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.S=c,r.options){c=O(Object.keys(r.options));for(var d=c.next();!d.done;d=c.next()){d=d.value;var e=r.options[d].default;e!==void 0&&(this.j[d]=typeof e=="function"?e():e)}}}i=Re.prototype,i.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function ke(r){var c,d,e,u,l,m,F,C,M,D,V;return me(function(K){switch(K.g){case 1:return r.R?(c=r.g.files===void 0?[]:typeof r.g.files=="function"?r.g.files(r.j):r.g.files,J(K,Ee(),2)):K.return();case 2:if(d=K.h,typeof window=="object")return Te("createMediapipeSolutionsWasm",{locateFile:r.locateFile}),Te("createMediapipeSolutionsPackedAssets",{locateFile:r.locateFile}),m=c.filter(function(Q){return Q.data!==void 0}),F=c.filter(function(Q){return Q.data===void 0}),C=Promise.all(m.map(function(Q){var se=w(r,Q.url);if(Q.path!==void 0){var fe=Q.path;se=se.then(function(de){return r.overrideFile(fe,de),Promise.resolve(de)})}return se})),M=Promise.all(F.map(function(Q){return Q.simd===void 0||Q.simd&&d||!Q.simd&&!d?le(r.locateFile(Q.url,r.S)):Promise.resolve()})).then(function(){var Q,se,fe;return me(function(de){if(de.g==1)return Q=window.createMediapipeSolutionsWasm,se=window.createMediapipeSolutionsPackedAssets,fe=r,J(de,Q(se),2);fe.h=de.h,de.g=0})}),D=(function(){return me(function(Q){return r.g.graph&&r.g.graph.url?Q=J(Q,w(r,r.g.graph.url),0):(Q.g=0,Q=void 0),Q})})(),J(K,Promise.all([M,C,D]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return e=c.filter(function(Q){return Q.simd===void 0||Q.simd&&d||!Q.simd&&!d}).map(function(Q){return r.locateFile(Q.url,r.S)}),importScripts.apply(null,L(e)),u=r,J(K,createMediapipeSolutionsWasm(Module),6);case 6:u.h=K.h,r.l=new OffscreenCanvas(1,1),r.h.canvas=r.l,l=r.h.GL.createContext(r.l,{antialias:!1,alpha:!1,aa:typeof WebGL2RenderingContext<"u"?2:1}),r.h.GL.makeContextCurrent(l),K.g=4;break;case 7:if(r.l=document.createElement("canvas"),V=r.l.getContext("webgl2",{}),!V&&(V=r.l.getContext("webgl",{}),!V))return alert("Failed to create WebGL canvas context when passing video frame."),K.return();r.D=V,r.h.canvas=r.l,r.h.createContext(r.l,!0,!0,{});case 4:r.i=new r.h.SolutionWasm,r.R=!1,K.g=0}})}function Pe(r){var c,d,e,u,l,m,F,C;return me(function(M){if(M.g==1){if(r.g.graph&&r.g.graph.url&&r.P===r.g.graph.url)return M.return();if(r.o=!0,!r.g.graph||!r.g.graph.url){M.g=2;return}return r.P=r.g.graph.url,J(M,w(r,r.g.graph.url),3)}for(M.g!=2&&(c=M.h,r.i.loadGraph(c)),d=O(Object.keys(r.B)),e=d.next();!e.done;e=d.next())u=e.value,r.i.overrideFile(u,r.B[u]);if(r.B={},r.g.listeners)for(l=O(r.g.listeners),m=l.next();!m.done;m=l.next())F=m.value,B(r,F);C=r.j,r.j={},r.setOptions(C),M.g=0})}i.reset=function(){var r=this;return me(function(c){r.i&&(r.i.reset(),r.m={},r.s={}),c.g=0})},i.setOptions=function(r,c){var d=this;if(c=c||this.g.options){for(var e=[],u=[],l={},m=O(Object.keys(r)),F=m.next();!F.done;l={K:l.K,L:l.L},F=m.next()){var C=F.value;C in this.j&&this.j[C]===r[C]||(this.j[C]=r[C],F=c[C],F!==void 0&&(F.onChange&&(l.K=F.onChange,l.L=r[C],e.push((function(M){return function(){var D;return me(function(V){if(V.g==1)return J(V,M.K(M.L),2);D=V.h,D===!0&&(d.o=!0),V.g=0})}})(l))),F.graphOptionXref&&(C={valueNumber:F.type===1?r[C]:0,valueBoolean:F.type===0?r[C]:!1,valueString:F.type===2?r[C]:""},F=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),F.graphOptionXref),C),u.push(F))))}(e.length!==0||u.length!==0)&&(this.o=!0,this.A=(this.A===void 0?[]:this.A).concat(u),this.v=(this.v===void 0?[]:this.v).concat(e))}};function a(r){var c,d,e,u,l,m,F;return me(function(C){switch(C.g){case 1:if(!r.o)return C.return();if(!r.v){C.g=2;break}c=O(r.v),d=c.next();case 3:if(d.done){C.g=5;break}return e=d.value,J(C,e(),4);case 4:d=c.next(),C.g=3;break;case 5:r.v=void 0;case 2:if(r.A){for(u=new r.h.GraphOptionChangeRequestList,l=O(r.A),m=l.next();!m.done;m=l.next())F=m.value,u.push_back(F);r.i.changeOptions(u),u.delete(),r.A=void 0}r.o=!1,C.g=0}})}i.initialize=function(){var r=this;return me(function(c){return c.g==1?J(c,ke(r),2):c.g!=3?J(c,Pe(r),3):J(c,a(r),0)})};function w(r,c){var d,e;return me(function(u){return c in r.F?u.return(r.F[c]):(d=r.locateFile(c,""),e=fetch(d).then(function(l){return l.arrayBuffer()}),r.F[c]=e,u.return(e))})}i.overrideFile=function(r,c){this.i?this.i.overrideFile(r,c):this.B[r]=c},i.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},i.send=function(r,c){var d=this,e,u,l,m,F,C,M,D,V;return me(function(K){switch(K.g){case 1:return d.g.inputs?(e=1e3*(c??performance.now()),J(K,d.C,2)):K.return();case 2:return J(K,d.initialize(),3);case 3:for(u=new d.h.PacketDataList,l=O(Object.keys(r)),m=l.next();!m.done;m=l.next())if(F=m.value,C=d.g.inputs[F]){e:{var Q=r[F];switch(C.type){case"video":var se=d.m[C.stream];if(se||(se=new G(d.h,d.D),d.m[C.stream]=se),se.l===0&&(se.l=se.h.createTexture()),typeof HTMLVideoElement<"u"&&Q instanceof HTMLVideoElement)var fe=Q.videoWidth,de=Q.videoHeight;else typeof HTMLImageElement<"u"&&Q instanceof HTMLImageElement?(fe=Q.naturalWidth,de=Q.naturalHeight):(fe=Q.width,de=Q.height);de={glName:se.l,width:fe,height:de},fe=se.g,fe.canvas.width=de.width,fe.canvas.height=de.height,fe.activeTexture(fe.TEXTURE0),se.h.bindTexture2d(se.l),fe.texImage2D(fe.TEXTURE_2D,0,fe.RGBA,fe.RGBA,fe.UNSIGNED_BYTE,Q),se.h.bindTexture2d(0),se=de;break e;case"detections":for(se=d.m[C.stream],se||(se=new ye(d.h),d.m[C.stream]=se),se.data||(se.data=new se.g.DetectionListData),se.data.reset(Q.length),de=0;de<Q.length;++de){fe=Q[de];var we=se.data,be=we.setBoundingBox,ze=de,it=fe.T,ot=new Fe;if(Qe(ot,1,it.X),Qe(ot,2,it.Y),Qe(ot,3,it.height),Qe(ot,4,it.width),Qe(ot,5,it.rotation),Qe(ot,6,it.W),it=Xt(ot,Je),be.call(we,ze,it),fe.O)for(we=0;we<fe.O.length;++we){ot=fe.O[we];var Bt=!!ot.visibility;be=se.data,ze=be.addNormalizedLandmark,it=de,ot=Object.assign(Object.assign({},ot),{visibility:Bt?ot.visibility:0}),Bt=new $,Qe(Bt,1,ot.x),Qe(Bt,2,ot.y),Qe(Bt,3,ot.z),ot.visibility&&Qe(Bt,4,ot.visibility),ot=Xt(Bt,ge),ze.call(be,it,ot)}if(fe.M)for(we=0;we<fe.M.length;++we)be=se.data,ze=be.addClassification,it=de,ot=fe.M[we],Bt=new Rr,Qe(Bt,2,ot.score),ot.index&&Qe(Bt,1,ot.index),ot.label&&Qe(Bt,3,ot.label),ot.displayName&&Qe(Bt,4,ot.displayName),ot=Xt(Bt,g),ze.call(be,it,ot)}se=se.data;break e;default:se={}}}switch(M=se,D=C.stream,C.type){case"video":u.pushTexture2d(Object.assign(Object.assign({},M),{stream:D,timestamp:e}));break;case"detections":V=M,V.stream=D,V.timestamp=e,u.pushDetectionList(V);break;default:throw Error("Unknown input config type: '"+C.type+"'")}}return d.i.send(u),J(K,d.C,4);case 4:u.delete(),K.g=0}})};function S(r,c,d){var e,u,l,m,F,C,M,D,V,K,Q,se,fe,de;return me(function(we){switch(we.g){case 1:if(!d)return we.return(c);for(e={},u=0,l=O(Object.keys(d)),m=l.next();!m.done;m=l.next())F=m.value,C=d[F],typeof C!="string"&&C.type==="texture"&&c[C.stream]!==void 0&&++u;1<u&&(r.G=!1),M=O(Object.keys(d)),m=M.next();case 2:if(m.done){we.g=4;break}if(D=m.value,V=d[D],typeof V=="string")return fe=e,de=D,J(we,I(r,D,c[V]),14);if(K=c[V.stream],V.type==="detection_list"){if(K){for(var be=K.getRectList(),ze=K.getLandmarksList(),it=K.getClassificationsList(),ot=[],Bt=0;Bt<be.size();++Bt){var br=zr(be.get(Bt),Fe,st);br={T:{X:bt(br,1),Y:bt(br,2),height:bt(br,3),width:bt(br,4),rotation:bt(br,5,0),W:ht(br,6,0)},O:H(ze.get(Bt)),M:P(zr(it.get(Bt),A,Y))},ot.push(br)}be=ot}else be=[];e[D]=be,we.g=7;break}if(V.type==="proto_list"){if(K){for(be=Array(K.size()),ze=0;ze<K.size();ze++)be[ze]=K.get(ze);K.delete()}else be=[];e[D]=be,we.g=7;break}if(K===void 0){we.g=3;break}if(V.type==="float_list"){e[D]=K,we.g=7;break}if(V.type==="proto"){e[D]=K,we.g=7;break}if(V.type!=="texture")throw Error("Unknown output config type: '"+V.type+"'");return Q=r.s[D],Q||(Q=new G(r.h,r.D),r.s[D]=Q),J(we,re(Q,K,r.G),13);case 13:se=we.h,e[D]=se;case 7:V.transform&&e[D]&&(e[D]=V.transform(e[D])),we.g=3;break;case 14:fe[de]=we.h;case 3:m=M.next(),we.g=2;break;case 4:return we.return(e)}})}function I(r,c,d){var e;return me(function(u){return typeof d=="number"||d instanceof Uint8Array||d instanceof r.h.Uint8BlobList?u.return(d):d instanceof r.h.Texture2dDataOut?(e=r.s[c],e||(e=new G(r.h,r.D),r.s[c]=e),u.return(re(e,d,r.G))):u.return(void 0)})}function B(r,c){for(var d=c.name||"$",e=[].concat(L(c.wants)),u=new r.h.StringList,l=O(c.wants),m=l.next();!m.done;m=l.next())u.push_back(m.value);l=r.h.PacketListener.implement({onResults:function(F){for(var C={},M=0;M<c.wants.length;++M)C[e[M]]=F.get(M);var D=r.listeners[d];D&&(r.C=S(r,C,c.outs).then(function(V){V=D(V);for(var K=0;K<c.wants.length;++K){var Q=C[e[K]];typeof Q=="object"&&Q.hasOwnProperty&&Q.hasOwnProperty("delete")&&Q.delete()}V&&(r.C=V)}))}}),r.i.attachMultiListener(u,l),u.delete()}i.onResults=function(r,c){this.listeners[c||"$"]=r},je("Solution",Re),je("OptionType",{BOOL:0,NUMBER:1,Z:2,0:"BOOL",1:"NUMBER",2:"STRING"});function o(r){return r.map(f)}function f(r){r=zr(r,v,j);var c=r.getMesh();if(!c)return r;var d=new Float32Array(c.getVertexBufferList());c.getVertexBufferList=function(){return d};var e=new Uint32Array(c.getIndexBufferList());return c.getIndexBufferList=function(){return e},r}function b(r){var c=this;r=r||{},this.g=new Re({locateFile:r.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:H},rightHandLandmarks:{type:"proto",stream:"right_hand_landmarks",transform:H},faceLandmarks:{type:"proto",stream:"face_landmarks",transform:H},poseLandmarks:{type:"proto",stream:"pose_landmarks",transform:H},ea:{type:"proto",stream:"world_landmarks",transform:H},segmentationMask:{type:"texture",stream:"segmentation_mask"},multiFaceGeometry:{type:"proto_list",stream:"multi_face_geometry",transform:o}}}],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(d){var e,u,l,m;return me(function(F){if(F.g==1){switch(e="",d){case 1:e="pose_landmark_full.tflite";break;case 2:e="pose_landmark_heavy.tflite";break;default:e="pose_landmark_lite.tflite"}return u="third_party/mediapipe/modules/pose_landmark/"+e,l=c.g.locateFile(e,""),J(F,fetch(l),3)}return F.g!=2?J(F,F.h.arrayBuffer(),2):(m=F.h,c.g.overrideFile(u,m),J(F,c.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"}}}})}i=b.prototype,i.close=function(){return this.g.close(),Promise.resolve()},i.onResults=function(r){this.g.onResults(r)},i.initialize=function(){var r=this;return me(function(c){return J(c,r.g.initialize(),0)})},i.reset=function(){this.g.reset()},i.send=function(r){var c=this;return me(function(d){return J(d,c.g.send(r),0)})},i.setOptions=function(r){this.g.setOptions(r)},je("Holistic",b),je("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}}),je("FACEMESH_LIPS",W),je("FACEMESH_LEFT_EYE",X),je("FACEMESH_LEFT_EYEBROW",z),je("FACEMESH_LEFT_IRIS",[[474,475],[475,476],[476,477],[477,474]]),je("FACEMESH_RIGHT_EYE",q),je("FACEMESH_RIGHT_EYEBROW",ae),je("FACEMESH_RIGHT_IRIS",[[469,470],[470,471],[471,472],[472,469]]),je("FACEMESH_FACE_OVAL",s),je("FACEMESH_CONTOURS",_),je("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]]),je("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]]),je("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]]),je("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}),je("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}),je("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}),je("POSE_LANDMARKS_NEUTRAL",{NOSE:0}),je("matrixDataToMatrix",function(r){for(var c=r.getCols(),d=r.getRows(),e=r.getPackedDataList(),u=[],l=0;l<d;l++)u.push(Array(c));for(l=0;l<d;l++)for(var m=0;m<c;m++){var F=r.getLayout()===1?l*c+m:m*d+l;u[l][m]=e[F]}return u}),je("VERSION","0.5.1635989137")}).call(Ti);const Si={};(function(){var i;function t(o){var f=0;return function(){return f<o.length?{done:!1,value:o[f++]}:{done:!0}}}var n=typeof Object.defineProperties=="function"?Object.defineProperty:function(o,f,b){return o==Array.prototype||o==Object.prototype||(o[f]=b.value),o};function p(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof global=="object"&&global];for(var f=0;f<o.length;++f){var b=o[f];if(b&&b.Math==Math)return b}throw Error("Cannot find global object")}var y=p(this);function R(o,f){if(f)e:{var b=y;o=o.split(".");for(var r=0;r<o.length-1;r++){var c=o[r];if(!(c in b))break e;b=b[c]}o=o[o.length-1],r=b[o],f=f(r),f!=r&&f!=null&&n(b,o,{configurable:!0,writable:!0,value:f})}}R("Symbol",function(o){function f(d){if(this instanceof f)throw new TypeError("Symbol is not a constructor");return new b(r+(d||"")+"_"+c++,d)}function b(d,e){this.g=d,n(this,"description",{configurable:!0,writable:!0,value:e})}if(o)return o;b.prototype.toString=function(){return this.g};var r="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",c=0;return f}),R("Symbol.iterator",function(o){if(o)return o;o=Symbol("Symbol.iterator");for(var f="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),b=0;b<f.length;b++){var r=y[f[b]];typeof r=="function"&&typeof r.prototype[o]!="function"&&n(r.prototype,o,{configurable:!0,writable:!0,value:function(){return k(t(this))}})}return o});function k(o){return o={next:o},o[Symbol.iterator]=function(){return this},o}function O(o){var f=typeof Symbol<"u"&&Symbol.iterator&&o[Symbol.iterator];return f?f.call(o):{next:t(o)}}function L(o){if(!(o instanceof Array)){o=O(o);for(var f,b=[];!(f=o.next()).done;)b.push(f.value);o=b}return o}var te=typeof Object.create=="function"?Object.create:function(o){function f(){}return f.prototype=o,new f},ue;if(typeof Object.setPrototypeOf=="function")ue=Object.setPrototypeOf;else{var pe;e:{var Oe={a:!0},Me={};try{Me.__proto__=Oe,pe=Me.a;break e}catch{}pe=!1}ue=pe?function(o,f){if(o.__proto__=f,o.__proto__!==f)throw new TypeError(o+" is not extensible");return o}:null}var ce=ue;function he(o,f){if(o.prototype=te(f.prototype),o.prototype.constructor=o,ce)ce(o,f);else for(var b in f)if(b!="prototype")if(Object.defineProperties){var r=Object.getOwnPropertyDescriptor(f,b);r&&Object.defineProperty(o,b,r)}else o[b]=f[b];o.na=f.prototype}function Ge(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.u=this.o=0,this.j=null}function Ve(o){if(o.l)throw new TypeError("Generator is already running");o.l=!0}Ge.prototype.s=function(o){this.h=o};function ct(o,f){o.j={da:f,ea:!0},o.g=o.o||o.u}Ge.prototype.return=function(o){this.j={return:o},this.g=this.u};function J(o,f,b){return o.g=b,{value:f}}function Jt(o){this.g=new Ge,this.h=o}function mr(o,f){Ve(o.g);var b=o.g.i;return b?At(o,"return"in b?b.return:function(r){return{value:r,done:!0}},f,o.g.return):(o.g.return(f),Xe(o))}function At(o,f,b,r){try{var c=f.call(o.g.i,b);if(!(c instanceof Object))throw new TypeError("Iterator result "+c+" is not an object");if(!c.done)return o.g.l=!1,c;var d=c.value}catch(e){return o.g.i=null,ct(o.g,e),Xe(o)}return o.g.i=null,r.call(o.g,d),Xe(o)}function Xe(o){for(;o.g.g;)try{var f=o.h(o.g);if(f)return o.g.l=!1,{value:f.value,done:!1}}catch(b){o.g.h=void 0,ct(o.g,b)}if(o.g.l=!1,o.g.j){if(f=o.g.j,o.g.j=null,f.ea)throw f.da;return{value:f.return,done:!0}}return{value:void 0,done:!0}}function Mr(o){this.next=function(f){return Ve(o.g),o.g.i?f=At(o,o.g.i.next,f,o.g.s):(o.g.s(f),f=Xe(o)),f},this.throw=function(f){return Ve(o.g),o.g.i?f=At(o,o.g.i.throw,f,o.g.s):(ct(o.g,f),f=Xe(o)),f},this.return=function(f){return mr(o,f)},this[Symbol.iterator]=function(){return this}}function at(o){function f(r){return o.next(r)}function b(r){return o.throw(r)}return new Promise(function(r,c){function d(e){e.done?r(e.value):Promise.resolve(e.value).then(f,b).then(d,c)}d(o.next())})}function me(o){return at(new Mr(new Jt(o)))}R("Promise",function(o){function f(e){this.h=0,this.i=void 0,this.g=[],this.s=!1;var u=this.j();try{e(u.resolve,u.reject)}catch(l){u.reject(l)}}function b(){this.g=null}function r(e){return e instanceof f?e:new f(function(u){u(e)})}if(o)return o;b.prototype.h=function(e){if(this.g==null){this.g=[];var u=this;this.i(function(){u.l()})}this.g.push(e)};var c=y.setTimeout;b.prototype.i=function(e){c(e,0)},b.prototype.l=function(){for(;this.g&&this.g.length;){var e=this.g;this.g=[];for(var u=0;u<e.length;++u){var l=e[u];e[u]=null;try{l()}catch(m){this.j(m)}}}this.g=null},b.prototype.j=function(e){this.i(function(){throw e})},f.prototype.j=function(){function e(m){return function(F){l||(l=!0,m.call(u,F))}}var u=this,l=!1;return{resolve:e(this.D),reject:e(this.l)}},f.prototype.D=function(e){if(e===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof f)this.H(e);else{e:switch(typeof e){case"object":var u=e!=null;break e;case"function":u=!0;break e;default:u=!1}u?this.A(e):this.o(e)}},f.prototype.A=function(e){var u=void 0;try{u=e.then}catch(l){this.l(l);return}typeof u=="function"?this.I(u,e):this.o(e)},f.prototype.l=function(e){this.u(2,e)},f.prototype.o=function(e){this.u(1,e)},f.prototype.u=function(e,u){if(this.h!=0)throw Error("Cannot settle("+e+", "+u+"): Promise already settled in state"+this.h);this.h=e,this.i=u,this.h===2&&this.G(),this.B()},f.prototype.G=function(){var e=this;c(function(){if(e.C()){var u=y.console;typeof u<"u"&&u.error(e.i)}},1)},f.prototype.C=function(){if(this.s)return!1;var e=y.CustomEvent,u=y.Event,l=y.dispatchEvent;return typeof l>"u"?!0:(typeof e=="function"?e=new e("unhandledrejection",{cancelable:!0}):typeof u=="function"?e=new u("unhandledrejection",{cancelable:!0}):(e=y.document.createEvent("CustomEvent"),e.initCustomEvent("unhandledrejection",!1,!0,e)),e.promise=this,e.reason=this.i,l(e))},f.prototype.B=function(){if(this.g!=null){for(var e=0;e<this.g.length;++e)d.h(this.g[e]);this.g=null}};var d=new b;return f.prototype.H=function(e){var u=this.j();e.M(u.resolve,u.reject)},f.prototype.I=function(e,u){var l=this.j();try{e.call(u,l.resolve,l.reject)}catch(m){l.reject(m)}},f.prototype.then=function(e,u){function l(M,D){return typeof M=="function"?function(V){try{m(M(V))}catch(K){F(K)}}:D}var m,F,C=new f(function(M,D){m=M,F=D});return this.M(l(e,m),l(u,F)),C},f.prototype.catch=function(e){return this.then(void 0,e)},f.prototype.M=function(e,u){function l(){switch(m.h){case 1:e(m.i);break;case 2:u(m.i);break;default:throw Error("Unexpected state: "+m.h)}}var m=this;this.g==null?d.h(l):this.g.push(l),this.s=!0},f.resolve=r,f.reject=function(e){return new f(function(u,l){l(e)})},f.race=function(e){return new f(function(u,l){for(var m=O(e),F=m.next();!F.done;F=m.next())r(F.value).M(u,l)})},f.all=function(e){var u=O(e),l=u.next();return l.done?r([]):new f(function(m,F){function C(V){return function(K){M[V]=K,D--,D==0&&m(M)}}var M=[],D=0;do M.push(void 0),D++,r(l.value).M(C(M.length-1),F),l=u.next();while(!l.done)})},f});function Wr(o,f){o instanceof String&&(o+="");var b=0,r=!1,c={next:function(){if(!r&&b<o.length){var d=b++;return{value:f(d,o[d]),done:!1}}return r=!0,{done:!0,value:void 0}}};return c[Symbol.iterator]=function(){return c},c}var Br=typeof Object.assign=="function"?Object.assign:function(o,f){for(var b=1;b<arguments.length;b++){var r=arguments[b];if(r)for(var c in r)Object.prototype.hasOwnProperty.call(r,c)&&(o[c]=r[c])}return o};R("Object.assign",function(o){return o||Br}),R("Object.is",function(o){return o||function(f,b){return f===b?f!==0||1/f===1/b:f!==f&&b!==b}}),R("Array.prototype.includes",function(o){return o||function(f,b){var r=this;r instanceof String&&(r=String(r));var c=r.length;for(b=b||0,0>b&&(b=Math.max(b+c,0));b<c;b++){var d=r[b];if(d===f||Object.is(d,f))return!0}return!1}}),R("String.prototype.includes",function(o){return o||function(f,b){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(f instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(f,b||0)!==-1}}),R("Array.prototype.keys",function(o){return o||function(){return Wr(this,function(f){return f})}});var Tt=this||self;function je(o,f){o=o.split(".");var b=Tt;o[0]in b||typeof b.execScript>"u"||b.execScript("var "+o[0]);for(var r;o.length&&(r=o.shift());)o.length||f===void 0?b[r]&&b[r]!==Object.prototype[r]?b=b[r]:b=b[r]={}:b[r]=f}function Ot(){throw Error("Invalid UTF8")}function tr(o,f){return f=String.fromCharCode.apply(null,f),o==null?f:o+f}var yr,Or=typeof TextDecoder<"u",wr,Pr=typeof TextEncoder<"u",rr={},Dt=null;function xr(o){var f;f===void 0&&(f=0),Ct(),f=rr[f];for(var b=Array(Math.floor(o.length/3)),r=f[64]||"",c=0,d=0;c<o.length-2;c+=3){var e=o[c],u=o[c+1],l=o[c+2],m=f[e>>2];e=f[(e&3)<<4|u>>4],u=f[(u&15)<<2|l>>6],l=f[l&63],b[d++]=m+e+u+l}switch(m=0,l=r,o.length-c){case 2:m=o[c+1],l=f[(m&15)<<2]||r;case 1:o=o[c],b[d]=f[o>>2]+f[(o&3)<<4|m>>4]+l+r}return b.join("")}function Ir(o){var f=o.length,b=3*f/4;b%3?b=Math.floor(b):"=.".indexOf(o[f-1])!=-1&&(b="=.".indexOf(o[f-2])!=-1?b-2:b-1);var r=new Uint8Array(b),c=0;return vr(o,function(d){r[c++]=d}),c!==b?r.subarray(0,c):r}function vr(o,f){function b(l){for(;r<o.length;){var m=o.charAt(r++),F=Dt[m];if(F!=null)return F;if(!/^[\s\xa0]*$/.test(m))throw Error("Unknown base64 encoding at char: "+m)}return l}Ct();for(var r=0;;){var c=b(-1),d=b(0),e=b(64),u=b(64);if(u===64&&c===-1)break;f(c<<2|d>>4),e!=64&&(f(d<<4&240|e>>2),u!=64&&f(e<<6&192|u))}}function Ct(){if(!Dt){Dt={};for(var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),f=["+/=","+/","-_=","-_.","-_"],b=0;5>b;b++){var r=o.concat(f[b].split(""));rr[b]=r;for(var c=0;c<r.length;c++){var d=r[c];Dt[d]===void 0&&(Dt[d]=c)}}}}var _r=typeof Uint8Array=="function";function lr(o){return _r&&o!=null&&o instanceof Uint8Array}var ut;function St(o){if(this.L=o,o!==null&&o.length===0)throw Error("ByteString should be constructed with non-empty values")}var Ht=typeof Uint8Array.prototype.slice=="function",xt=0,_t=0;function Zt(o,f){if(o.constructor===Uint8Array)return o;if(o.constructor===ArrayBuffer)return new Uint8Array(o);if(o.constructor===Array)return new Uint8Array(o);if(o.constructor===String)return Ir(o);if(o.constructor===St)return!f&&(f=o.L)&&f.constructor===Uint8Array?f:(f=o.L,f=f==null||lr(f)?f:typeof f=="string"?Ir(f):null,(o=o.L=f)?new Uint8Array(o):ut||(ut=new Uint8Array(0)));if(o instanceof Uint8Array)return new Uint8Array(o.buffer,o.byteOffset,o.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}function Gt(o,f){return Error("Invalid wire type: "+o+" (at position "+f+")")}function qe(){return Error("Failed to read varint, encoding is invalid.")}function mt(o,f){f=f===void 0?{}:f,f=f.v===void 0?!1:f.v,this.h=null,this.g=this.i=this.j=0,this.v=f,o&&Rt(this,o)}function Rt(o,f){o.h=Zt(f,o.v),o.j=0,o.i=o.h.length,o.g=o.j}mt.prototype.reset=function(){this.g=this.j};function We(o){if(o.g>o.i)throw Error("Tried to read past the end of the data "+o.g+" > "+o.i)}function Ft(o){var f=o.h,b=f[o.g],r=b&127;if(128>b)return o.g+=1,We(o),r;if(b=f[o.g+1],r|=(b&127)<<7,128>b)return o.g+=2,We(o),r;if(b=f[o.g+2],r|=(b&127)<<14,128>b)return o.g+=3,We(o),r;if(b=f[o.g+3],r|=(b&127)<<21,128>b)return o.g+=4,We(o),r;if(b=f[o.g+4],o.g+=5,r|=(b&15)<<28,128>b)return We(o),r;if(128<=f[o.g++]&&128<=f[o.g++]&&128<=f[o.g++]&&128<=f[o.g++]&&128<=f[o.g++])throw qe();return We(o),r}var et=[];function pt(){this.g=[]}pt.prototype.length=function(){return this.g.length},pt.prototype.end=function(){var o=this.g;return this.g=[],o};function It(o,f){for(;127<f;)o.g.push(f&127|128),f>>>=7;o.g.push(f)}function Vt(o){var f={},b=f.W===void 0?!1:f.W;this.l={v:f.v===void 0?!1:f.v},this.W=b,f=this.l,et.length?(b=et.pop(),f&&(b.v=f.v),o&&Rt(b,o),o=b):o=new mt(o,f),this.g=o,this.j=this.g.g,this.h=this.i=-1}Vt.prototype.reset=function(){this.g.reset(),this.j=this.g.g,this.h=this.i=-1};function wt(o){var f=o.g;if(f.g==f.i)return!1;o.j=o.g.g;var b=Ft(o.g)>>>0;if(f=b>>>3,b&=7,!(0<=b&&5>=b))throw Gt(b,o.j);if(1>f)throw Error("Invalid field number: "+f+" (at position "+o.j+")");return o.i=f,o.h=b,!0}function Ye(o){switch(o.h){case 0:if(o.h!=0)Ye(o);else e:{o=o.g;for(var f=o.g,b=f+10;f<b;)if((o.h[f++]&128)===0){o.g=f,We(o);break e}throw qe()}break;case 1:o=o.g,o.g+=8,We(o);break;case 2:o.h!=2?Ye(o):(f=Ft(o.g)>>>0,o=o.g,o.g+=f,We(o));break;case 5:o=o.g,o.g+=4,We(o);break;case 3:f=o.i;do{if(!wt(o))throw Error("Unmatched start-group tag: stream EOF");if(o.h==4){if(o.i!=f)throw Error("Unmatched end-group tag");break}Ye(o)}while(!0);break;default:throw Gt(o.h,o.j)}}var Lt=[];function zt(){this.i=[],this.h=0,this.g=new pt}function Et(o,f){f.length!==0&&(o.i.push(f),o.h+=f.length)}function fr(o,f){if(f=f.ba){Et(o,o.g.end());for(var b=0;b<f.length;b++)Et(o,f[b])}}var qt=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol(void 0):void 0;function sr(o,f){Object.isFrozen(o)||(qt?o[qt]|=f:o.N!==void 0?o.N|=f:Object.defineProperties(o,{N:{value:f,configurable:!0,writable:!0,enumerable:!1}}))}function hr(o){var f;return qt?f=o[qt]:f=o.N,f??0}function yt(o){return sr(o,1),o}function kt(o){return Array.isArray(o)?!!(hr(o)&2):!1}function vt(o){if(!Array.isArray(o))throw Error("cannot mark non-array as immutable");sr(o,2)}function rt(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)&&o.constructor===Object}var Ut=Object.freeze(yt([]));function tt(o){if(kt(o.m))throw Error("Cannot mutate an immutable Message")}var $e=typeof Symbol<"u"&&typeof Symbol.hasInstance<"u";function nr(o){return{value:o,configurable:!1,writable:!1,enumerable:!1}}function lt(o,f,b){return f===-1?null:f>=o.i?o.g?o.g[f]:void 0:b!==void 0&&b&&o.g&&(b=o.g[f],b!=null)?b:o.m[f+o.h]}function Ce(o,f,b,r){r=r===void 0?!1:r,tt(o),f<o.i&&!r?o.m[f+o.h]=b:(o.g||(o.g=o.m[o.i+o.h]={}))[f]=b}function Se(o,f,b,r){b=b===void 0?!0:b,r=r===void 0?!1:r;var c=lt(o,f,r);return c==null&&(c=Ut),kt(o.m)?b&&(vt(c),Object.freeze(c)):(c===Ut||kt(c))&&(c=yt(c.slice()),Ce(o,f,c,r)),c}function nt(o,f,b){return o=lt(o,f),o=o==null?o:+o,o??(b===void 0?0:b)}function ee(o,f,b,r){o.j||(o.j={});var c=kt(o.m),d=o.j[b];if(!d){r=Se(o,b,!0,r===void 0?!1:r),d=[],c=c||kt(r);for(var e=0;e<r.length;e++)d[e]=new f(r[e]),c&&vt(d[e].m);c&&(vt(d),Object.freeze(d)),o.j[b]=d}return d}function ie(o,f,b,r,c){var d=d===void 0?!1:d;return tt(o),d=ee(o,b,f,d),b=r||new b,o=Se(o,f),c!=null?(d.splice(c,0,b),o.splice(c,0,b.m)):(d.push(b),o.push(b.m)),b}function ve(o,f){return o=lt(o,f),o??0}function He(o,f){return o=lt(o,f),o??""}function Ie(o){switch(typeof o){case"number":return isFinite(o)?o:String(o);case"object":if(o&&!Array.isArray(o)){if(lr(o))return xr(o);if(o instanceof St){var f=o.L;return f=f==null||typeof f=="string"?f:_r&&f instanceof Uint8Array?xr(f):null,(o.L=f)||""}}}return o}function xe(o){var f=bt;return f=f===void 0?Qe:f,ht(o,f)}function Ke(o,f){if(o!=null){if(Array.isArray(o))o=ht(o,f);else if(rt(o)){var b={},r;for(r in o)b[r]=Ke(o[r],f);o=b}else o=f(o);return o}}function ht(o,f){for(var b=o.slice(),r=0;r<b.length;r++)b[r]=Ke(b[r],f);return Array.isArray(o)&&hr(o)&1&&yt(b),b}function bt(o){return o&&typeof o=="object"&&o.toJSON?o.toJSON():(o=Ie(o),Array.isArray(o)?xe(o):o)}function Qe(o){return lr(o)?new Uint8Array(o):o}function $t(o,f,b){o||(o=Er),Er=null;var r=this.constructor.h;o||(o=r?[r]:[]),this.h=(r?0:-1)-(this.constructor.g||0),this.j=void 0,this.m=o;e:{if(r=this.m.length,o=r-1,r&&(r=this.m[o],rt(r))){this.i=o-this.h,this.g=r;break e}f!==void 0&&-1<f?(this.i=Math.max(f,o+1-this.h),this.g=void 0):this.i=Number.MAX_VALUE}if(b)for(f=0;f<b.length;f++)if(o=b[f],o<this.i)o+=this.h,(r=this.m[o])?Array.isArray(r)&&yt(r):this.m[o]=Ut;else{r=this.g||(this.g=this.m[this.i+this.h]={});var c=r[o];c?Array.isArray(c)&&yt(c):r[o]=Ut}}$t.prototype.toJSON=function(){return xe(this.m)},$t.prototype.toString=function(){return this.m.toString()};var Er;function ar(){$t.apply(this,arguments)}if(he(ar,$t),$e){var Yt={};Object.defineProperties(ar,(Yt[Symbol.hasInstance]=nr(function(){throw Error("Cannot perform instanceof checks for MutableMessage")}),Yt))}function ir(o,f,b){if(b){var r={},c;for(c in b){var d=b[c],e=d.ha;e||(r.F=d.la||d.fa.P,d.aa?(r.U=Ar(d.aa),e=(function(u){return function(l,m,F){return u.F(l,m,F,u.U)}})(r)):d.ca?(r.T=Wt(d.X.g,d.ca),e=(function(u){return function(l,m,F){return u.F(l,m,F,u.T)}})(r)):e=r.F,d.ha=e),e(f,o,d.X),r={F:r.F,U:r.U,T:r.T}}}fr(f,o)}var ur=Symbol();function Pt(o,f,b){return o[ur]||(o[ur]=function(r,c){return f(r,c,b)})}function Xt(o){var f=o[ur];if(!f){var b=g(o);f=function(r,c){return E(r,c,b)},o[ur]=f}return f}function zr(o){var f=o.aa;if(f)return Xt(f);if(f=o.ka)return Pt(o.X.g,f,o.ca)}function Kt(o){var f=zr(o),b=o.X,r=o.fa.O;return f?function(c,d){return r(c,d,b,f)}:function(c,d){return r(c,d,b)}}function Mt(o,f,b,r,c,d){o=o();var e=0;for(o.length&&typeof o[0]!="number"&&(b(f,o[0]),e++);e<o.length;){b=o[e++];for(var u=e+1;u<o.length&&typeof o[u]!="number";)u++;var l=o[e++];switch(u-=e,u){case 0:r(f,b,l);break;case 1:r(f,b,l,o[e++]);break;case 2:c(f,b,l,o[e++],o[e++]);break;case 3:u=o[e++];var m=o[e++],F=o[e++];Array.isArray(F)?c(f,b,l,u,m,F):d(f,b,l,u,m,F);break;case 4:d(f,b,l,o[e++],o[e++],o[e++],o[e++]);break;default:throw Error("unexpected number of binary field arguments: "+u)}}return f}var dr=Symbol();function Ar(o){var f=o[dr];if(!f){var b=er(o);f=function(r,c){return N(r,c,b)},o[dr]=f}return f}function Wt(o,f){var b=o[dr];return b||(b=function(r,c){return ir(r,c,f)},o[dr]=b),b}var jr=Symbol();function Qt(o,f){o.push(f)}function pr(o,f,b){o.push(f,b.P)}function Tr(o,f,b,r,c){var d=Ar(c),e=b.P;o.push(f,function(u,l,m){return e(u,l,m,r,d)})}function Nr(o,f,b,r,c,d){var e=Wt(r,d),u=b.P;o.push(f,function(l,m,F){return u(l,m,F,r,e)})}function er(o){var f=o[jr];return f||Mt(o,o[jr]=[],Qt,pr,Tr,Nr)}var Sr=Symbol();function $r(o,f){o[0]=f}function Yr(o,f,b,r){var c=b.O;o[f]=r?function(d,e,u){return c(d,e,u,r)}:c}function Rr(o,f,b,r,c,d){var e=b.O,u=Xt(c);o[f]=function(l,m,F){return e(l,m,F,r,u,d)}}function kr(o,f,b,r,c,d,e){var u=b.O,l=Pt(r,c,d);o[f]=function(m,F,C){return u(m,F,C,r,l,e)}}function g(o){var f=o[Sr];return f||Mt(o,o[Sr]={},$r,Yr,Rr,kr)}function E(o,f,b){for(;wt(f)&&f.h!=4;){var r=f.i,c=b[r];if(!c){var d=b[0];d&&(d=d[r])&&(c=b[r]=Kt(d))}if((!c||!c(f,o,r))&&(c=f,r=o,d=c.j,Ye(c),!c.W)){var e=c.g.h;c=c.g.g,c=d===c?ut||(ut=new Uint8Array(0)):Ht?e.slice(d,c):new Uint8Array(e.subarray(d,c)),(d=r.ba)?d.push(c):r.ba=[c]}}return o}function A(o,f,b){if(Lt.length){var r=Lt.pop();o&&(Rt(r.g,o),r.i=-1,r.h=-1),o=r}else o=new Vt(o);try{return E(new f,o,g(b))}finally{f=o.g,f.h=null,f.j=0,f.i=0,f.g=0,f.v=!1,o.i=-1,o.h=-1,100>Lt.length&&Lt.push(o)}}function N(o,f,b){for(var r=b.length,c=r%2==1,d=c?1:0;d<r;d+=2)(0,b[d+1])(f,o,b[d]);ir(o,f,c?b[0]:void 0)}function Y(o,f){var b=new zt;N(o,b,er(f)),Et(b,b.g.end()),o=new Uint8Array(b.h),f=b.i;for(var r=f.length,c=0,d=0;d<r;d++){var e=f[d];o.set(e,c),c+=e.length}return b.i=[o],o}function oe(o,f){return{O:o,P:f}}var $=oe(function(o,f,b){if(o.h!==5)return!1;o=o.g;var r=o.h[o.g],c=o.h[o.g+1],d=o.h[o.g+2],e=o.h[o.g+3];return o.g+=4,We(o),c=(r<<0|c<<8|d<<16|e<<24)>>>0,o=2*(c>>31)+1,r=c>>>23&255,c&=8388607,Ce(f,b,r==255?c?NaN:1/0*o:r==0?o*Math.pow(2,-149)*c:o*Math.pow(2,r-150)*(c+Math.pow(2,23))),!0},function(o,f,b){if(f=lt(f,b),f!=null){It(o.g,8*b+5),o=o.g;var r=f;r=(b=0>r?1:0)?-r:r,r===0?0<1/r?xt=_t=0:(_t=0,xt=2147483648):isNaN(r)?(_t=0,xt=2147483647):34028234663852886e22<r?(_t=0,xt=(b<<31|2139095040)>>>0):11754943508222875e-54>r?(r=Math.round(r/Math.pow(2,-149)),_t=0,xt=(b<<31|r)>>>0):(f=Math.floor(Math.log(r)/Math.LN2),r*=Math.pow(2,-f),r=Math.round(8388608*r),16777216<=r&&++f,_t=0,xt=(b<<31|f+127<<23|r&8388607)>>>0),b=xt,o.g.push(b>>>0&255),o.g.push(b>>>8&255),o.g.push(b>>>16&255),o.g.push(b>>>24&255)}}),ne=oe(function(o,f,b){if(o.h!==0)return!1;for(var r=o.g,c=128,d=0,e=o=0;4>e&&128<=c;e++)c=r.h[r.g++],We(r),d|=(c&127)<<7*e;if(128<=c&&(c=r.h[r.g++],We(r),d|=(c&127)<<28,o|=(c&127)>>4),128<=c)for(e=0;5>e&&128<=c;e++)c=r.h[r.g++],We(r),o|=(c&127)<<7*e+3;if(128>c)r=d>>>0,c=o>>>0,(o=c&2147483648)&&(r=~r+1>>>0,c=~c>>>0,r==0&&(c=c+1>>>0)),r=4294967296*c+(r>>>0);else throw qe();return Ce(f,b,o?-r:r),!0},function(o,f,b){if(f=lt(f,b),f!=null&&f!=null){It(o.g,8*b),o=o.g;var r=f;for(b=0>r,r=Math.abs(r),f=r>>>0,r=Math.floor((r-f)/4294967296),r>>>=0,b&&(r=~r>>>0,f=(~f>>>0)+1,4294967295<f&&(f=0,r++,4294967295<r&&(r=0))),xt=f,_t=r,b=xt,f=_t;0<f||127<b;)o.g.push(b&127|128),b=(b>>>7|f<<25)>>>0,f>>>=7;o.g.push(b)}}),ge=oe(function(o,f,b){return o.h!==0?!1:(Ce(f,b,Ft(o.g)),!0)},function(o,f,b){if(f=lt(f,b),f!=null&&f!=null)if(It(o.g,8*b),o=o.g,b=f,0<=b)It(o,b);else{for(f=0;9>f;f++)o.g.push(b&127|128),b>>=7;o.g.push(1)}}),Ae=oe(function(o,f,b){if(o.h!==2)return!1;var r=Ft(o.g)>>>0;o=o.g;var c=o.g;o.g+=r,We(o),o=o.h;var d;if(Or)(d=yr)||(d=yr=new TextDecoder("utf-8",{fatal:!0})),d=d.decode(o.subarray(c,c+r));else{r=c+r;for(var e=[],u=null,l,m,F;c<r;)l=o[c++],128>l?e.push(l):224>l?c>=r?Ot():(m=o[c++],194>l||(m&192)!==128?(c--,Ot()):e.push((l&31)<<6|m&63)):240>l?c>=r-1?Ot():(m=o[c++],(m&192)!==128||l===224&&160>m||l===237&&160<=m||((d=o[c++])&192)!==128?(c--,Ot()):e.push((l&15)<<12|(m&63)<<6|d&63)):244>=l?c>=r-2?Ot():(m=o[c++],(m&192)!==128||(l<<28)+(m-144)>>30!==0||((d=o[c++])&192)!==128||((F=o[c++])&192)!==128?(c--,Ot()):(l=(l&7)<<18|(m&63)<<12|(d&63)<<6|F&63,l-=65536,e.push((l>>10&1023)+55296,(l&1023)+56320))):Ot(),8192<=e.length&&(u=tr(u,e),e.length=0);d=tr(u,e)}return Ce(f,b,d),!0},function(o,f,b){if(f=lt(f,b),f!=null){var r=!1;if(r=r===void 0?!1:r,Pr){if(r&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(f))throw Error("Found an unpaired surrogate");f=(wr||(wr=new TextEncoder)).encode(f)}else{for(var c=0,d=new Uint8Array(3*f.length),e=0;e<f.length;e++){var u=f.charCodeAt(e);if(128>u)d[c++]=u;else{if(2048>u)d[c++]=u>>6|192;else{if(55296<=u&&57343>=u){if(56319>=u&&e<f.length){var l=f.charCodeAt(++e);if(56320<=l&&57343>=l){u=1024*(u-55296)+l-56320+65536,d[c++]=u>>18|240,d[c++]=u>>12&63|128,d[c++]=u>>6&63|128,d[c++]=u&63|128;continue}else e--}if(r)throw Error("Found an unpaired surrogate");u=65533}d[c++]=u>>12|224,d[c++]=u>>6&63|128}d[c++]=u&63|128}}f=d.subarray(0,c)}It(o.g,8*b+2),It(o.g,f.length),Et(o,o.g.end()),Et(o,f)}}),Ne=oe(function(o,f,b,r,c){if(o.h!==2)return!1;f=ie(f,b,r),b=o.g.i,r=Ft(o.g)>>>0;var d=o.g.g+r,e=d-b;if(0>=e&&(o.g.i=d,c(f,o),e=d-o.g.g),e)throw Error("Message parsing ended unexpectedly. Expected to read "+(r+" bytes, instead read "+(r-e)+" bytes, either the data ended unexpectedly or the message misreported its own length"));return o.g.g=d,o.g.i=b,!0},function(o,f,b,r,c){if(f=ee(f,r,b),f!=null)for(r=0;r<f.length;r++){var d=o;It(d.g,8*b+2);var e=d.g.end();Et(d,e),e.push(d.h),d=e,c(f[r],o),e=o;var u=d.pop();for(u=e.h+e.g.length()-u;127<u;)d.push(u&127|128),u>>>=7,e.h++;d.push(u),e.h++}});function Le(){ar.apply(this,arguments)}if(he(Le,ar),$e){var Ze={};Object.defineProperties(Le,(Ze[Symbol.hasInstance]=nr(Object[Symbol.hasInstance]),Ze))}function Ue(o){Le.call(this,o)}he(Ue,Le);function Fe(){return[1,ge,2,$,3,Ae,4,Ae]}function Be(o){Le.call(this,o,-1,st)}he(Be,Le),Be.prototype.addClassification=function(o,f){return ie(this,1,Ue,o,f),this};function Je(){return[1,Ne,Ue,Fe]}var st=[1];function ft(o){Le.call(this,o)}he(ft,Le);function gt(){return[1,$,2,$,3,$,4,$,5,$]}function jt(o){Le.call(this,o,-1,v)}he(jt,Le);function h(){return[1,Ne,ft,gt]}var v=[1];function x(o){Le.call(this,o)}he(x,Le);function j(){return[1,$,2,$,3,$,4,$,5,$,6,ne]}var W=[[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]],X=[[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]],z=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],q=[[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]],ae=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],s=[[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]],_=[].concat(L(W),L(X),L(z),L(q),L(ae),L(s));function T(o,f,b){if(b=o.createShader(b===0?o.VERTEX_SHADER:o.FRAGMENT_SHADER),o.shaderSource(b,f),o.compileShader(b),!o.getShaderParameter(b,o.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
|
|
54
|
-
|
|
55
|
-
`+o.getShaderInfoLog(b));return b}function P(o){return ee(o,Ue,1).map(function(f){return{index:ve(f,1),ga:nt(f,2),label:lt(f,3)!=null?He(f,3):void 0,displayName:lt(f,4)!=null?He(f,4):void 0}})}function U(o){return{x:nt(o,1),y:nt(o,2),z:nt(o,3),visibility:lt(o,4)!=null?nt(o,4):void 0}}function H(o,f){this.h=o,this.g=f,this.l=0}function G(o,f,b){return re(o,f),typeof o.g.canvas.transferToImageBitmap=="function"?Promise.resolve(o.g.canvas.transferToImageBitmap()):b?Promise.resolve(o.g.canvas):typeof createImageBitmap=="function"?createImageBitmap(o.g.canvas):(o.i===void 0&&(o.i=document.createElement("canvas")),new Promise(function(r){o.i.height=o.g.canvas.height,o.i.width=o.g.canvas.width,o.i.getContext("2d",{}).drawImage(o.g.canvas,0,0,o.g.canvas.width,o.g.canvas.height),r(o.i)}))}function re(o,f){var b=o.g;if(o.o===void 0){var r=T(b,`
|
|
56
|
-
attribute vec2 aVertex;
|
|
57
|
-
attribute vec2 aTex;
|
|
58
|
-
varying vec2 vTex;
|
|
59
|
-
void main(void) {
|
|
60
|
-
gl_Position = vec4(aVertex, 0.0, 1.0);
|
|
61
|
-
vTex = aTex;
|
|
62
|
-
}`,0),c=T(b,`
|
|
63
|
-
precision mediump float;
|
|
64
|
-
varying vec2 vTex;
|
|
65
|
-
uniform sampler2D sampler0;
|
|
66
|
-
void main(){
|
|
67
|
-
gl_FragColor = texture2D(sampler0, vTex);
|
|
68
|
-
}`,1),d=b.createProgram();if(b.attachShader(d,r),b.attachShader(d,c),b.linkProgram(d),!b.getProgramParameter(d,b.LINK_STATUS))throw Error(`Could not compile WebGL program.
|
|
69
|
-
|
|
70
|
-
`+b.getProgramInfoLog(d));r=o.o=d,b.useProgram(r),c=b.getUniformLocation(r,"sampler0"),o.j={K:b.getAttribLocation(r,"aVertex"),J:b.getAttribLocation(r,"aTex"),ma:c},o.u=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,o.u),b.enableVertexAttribArray(o.j.K),b.vertexAttribPointer(o.j.K,2,b.FLOAT,!1,0,0),b.bufferData(b.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,null),o.s=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,o.s),b.enableVertexAttribArray(o.j.J),b.vertexAttribPointer(o.j.J,2,b.FLOAT,!1,0,0),b.bufferData(b.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,null),b.uniform1i(c,0)}r=o.j,b.useProgram(o.o),b.canvas.width=f.width,b.canvas.height=f.height,b.viewport(0,0,f.width,f.height),b.activeTexture(b.TEXTURE0),o.h.bindTexture2d(f.glName),b.enableVertexAttribArray(r.K),b.bindBuffer(b.ARRAY_BUFFER,o.u),b.vertexAttribPointer(r.K,2,b.FLOAT,!1,0,0),b.enableVertexAttribArray(r.J),b.bindBuffer(b.ARRAY_BUFFER,o.s),b.vertexAttribPointer(r.J,2,b.FLOAT,!1,0,0),b.bindFramebuffer(b.DRAW_FRAMEBUFFER?b.DRAW_FRAMEBUFFER:b.FRAMEBUFFER,null),b.clearColor(0,0,0,0),b.clear(b.COLOR_BUFFER_BIT),b.colorMask(!0,!0,!0,!0),b.drawArrays(b.TRIANGLE_FAN,0,4),b.disableVertexAttribArray(r.K),b.disableVertexAttribArray(r.J),b.bindBuffer(b.ARRAY_BUFFER,null),o.h.bindTexture2d(0)}function Z(o){this.g=o}var ye=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 _e(o,f){return f+o}function De(o,f){window[o]=f}function Te(o){var f=document.createElement("script");return f.setAttribute("src",o),f.setAttribute("crossorigin","anonymous"),new Promise(function(b){f.addEventListener("load",function(){b()},!1),f.addEventListener("error",function(){b()},!1),document.body.appendChild(f)})}function le(){return me(function(o){switch(o.g){case 1:return o.o=2,J(o,WebAssembly.instantiate(ye),4);case 4:o.g=3,o.o=0;break;case 2:return o.o=0,o.j=null,o.return(!1);case 3:return o.return(!0)}})}function Ee(o){if(this.g=o,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=o&&o.locateFile||_e,typeof window=="object")var f=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")f=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.$=f,o.options){f=O(Object.keys(o.options));for(var b=f.next();!b.done;b=f.next()){b=b.value;var r=o.options[b].default;r!==void 0&&(this.j[b]=typeof r=="function"?r():r)}}}i=Ee.prototype,i.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function Re(o){var f,b,r,c,d,e,u,l,m,F,C;return me(function(M){switch(M.g){case 1:return o.Z?(f=o.g.files===void 0?[]:typeof o.g.files=="function"?o.g.files(o.j):o.g.files,J(M,le(),2)):M.return();case 2:if(b=M.h,typeof window=="object")return De("createMediapipeSolutionsWasm",{locateFile:o.locateFile}),De("createMediapipeSolutionsPackedAssets",{locateFile:o.locateFile}),e=f.filter(function(D){return D.data!==void 0}),u=f.filter(function(D){return D.data===void 0}),l=Promise.all(e.map(function(D){var V=a(o,D.url);if(D.path!==void 0){var K=D.path;V=V.then(function(Q){return o.overrideFile(K,Q),Promise.resolve(Q)})}return V})),m=Promise.all(u.map(function(D){return D.simd===void 0||D.simd&&b||!D.simd&&!b?Te(o.locateFile(D.url,o.$)):Promise.resolve()})).then(function(){var D,V,K;return me(function(Q){if(Q.g==1)return D=window.createMediapipeSolutionsWasm,V=window.createMediapipeSolutionsPackedAssets,K=o,J(Q,D(V),2);K.h=Q.h,Q.g=0})}),F=(function(){return me(function(D){return o.g.graph&&o.g.graph.url?D=J(D,a(o,o.g.graph.url),0):(D.g=0,D=void 0),D})})(),J(M,Promise.all([m,l,F]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return r=f.filter(function(D){return D.simd===void 0||D.simd&&b||!D.simd&&!b}).map(function(D){return o.locateFile(D.url,o.$)}),importScripts.apply(null,L(r)),c=o,J(M,createMediapipeSolutionsWasm(Module),6);case 6:c.h=M.h,o.l=new OffscreenCanvas(1,1),o.h.canvas=o.l,d=o.h.GL.createContext(o.l,{antialias:!1,alpha:!1,ja:typeof WebGL2RenderingContext<"u"?2:1}),o.h.GL.makeContextCurrent(d),M.g=4;break;case 7:if(o.l=document.createElement("canvas"),C=o.l.getContext("webgl2",{}),!C&&(C=o.l.getContext("webgl",{}),!C))return alert("Failed to create WebGL canvas context when passing video frame."),M.return();o.G=C,o.h.canvas=o.l,o.h.createContext(o.l,!0,!0,{});case 4:o.i=new o.h.SolutionWasm,o.Z=!1,M.g=0}})}function ke(o){var f,b,r,c,d,e,u,l;return me(function(m){if(m.g==1){if(o.g.graph&&o.g.graph.url&&o.Y===o.g.graph.url)return m.return();if(o.s=!0,!o.g.graph||!o.g.graph.url){m.g=2;return}return o.Y=o.g.graph.url,J(m,a(o,o.g.graph.url),3)}for(m.g!=2&&(f=m.h,o.i.loadGraph(f)),b=O(Object.keys(o.C)),r=b.next();!r.done;r=b.next())c=r.value,o.i.overrideFile(c,o.C[c]);if(o.C={},o.g.listeners)for(d=O(o.g.listeners),e=d.next();!e.done;e=d.next())u=e.value,I(o,u);l=o.j,o.j={},o.setOptions(l),m.g=0})}i.reset=function(){var o=this;return me(function(f){o.i&&(o.i.reset(),o.o={},o.u={}),f.g=0})},i.setOptions=function(o,f){var b=this;if(f=f||this.g.options){for(var r=[],c=[],d={},e=O(Object.keys(o)),u=e.next();!u.done;d={R:d.R,S:d.S},u=e.next()){var l=u.value;l in this.j&&this.j[l]===o[l]||(this.j[l]=o[l],u=f[l],u!==void 0&&(u.onChange&&(d.R=u.onChange,d.S=o[l],r.push((function(m){return function(){var F;return me(function(C){if(C.g==1)return J(C,m.R(m.S),2);F=C.h,F===!0&&(b.s=!0),C.g=0})}})(d))),u.graphOptionXref&&(l={valueNumber:u.type===1?o[l]:0,valueBoolean:u.type===0?o[l]:!1,valueString:u.type===2?o[l]:""},u=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),u.graphOptionXref),l),c.push(u))))}(r.length!==0||c.length!==0)&&(this.s=!0,this.B=(this.B===void 0?[]:this.B).concat(c),this.A=(this.A===void 0?[]:this.A).concat(r))}};function Pe(o){var f,b,r,c,d,e,u;return me(function(l){switch(l.g){case 1:if(!o.s)return l.return();if(!o.A){l.g=2;break}f=O(o.A),b=f.next();case 3:if(b.done){l.g=5;break}return r=b.value,J(l,r(),4);case 4:b=f.next(),l.g=3;break;case 5:o.A=void 0;case 2:if(o.B){for(c=new o.h.GraphOptionChangeRequestList,d=O(o.B),e=d.next();!e.done;e=d.next())u=e.value,c.push_back(u);o.i.changeOptions(c),c.delete(),o.B=void 0}o.s=!1,l.g=0}})}i.initialize=function(){var o=this;return me(function(f){return f.g==1?J(f,Re(o),2):f.g!=3?J(f,ke(o),3):J(f,Pe(o),0)})};function a(o,f){var b,r;return me(function(c){return f in o.H?c.return(o.H[f]):(b=o.locateFile(f,""),r=fetch(b).then(function(d){return d.arrayBuffer()}),o.H[f]=r,c.return(r))})}i.overrideFile=function(o,f){this.i?this.i.overrideFile(o,f):this.C[o]=f},i.clearOverriddenFiles=function(){this.C={},this.i&&this.i.clearOverriddenFiles()},i.send=function(o,f){var b=this,r,c,d,e,u,l,m,F,C;return me(function(M){switch(M.g){case 1:return b.g.inputs?(r=1e3*(f??performance.now()),J(M,b.D,2)):M.return();case 2:return J(M,b.initialize(),3);case 3:for(c=new b.h.PacketDataList,d=O(Object.keys(o)),e=d.next();!e.done;e=d.next())if(u=e.value,l=b.g.inputs[u]){e:{var D=o[u];switch(l.type){case"video":var V=b.o[l.stream];if(V||(V=new H(b.h,b.G),b.o[l.stream]=V),V.l===0&&(V.l=V.h.createTexture()),typeof HTMLVideoElement<"u"&&D instanceof HTMLVideoElement)var K=D.videoWidth,Q=D.videoHeight;else typeof HTMLImageElement<"u"&&D instanceof HTMLImageElement?(K=D.naturalWidth,Q=D.naturalHeight):(K=D.width,Q=D.height);Q={glName:V.l,width:K,height:Q},K=V.g,K.canvas.width=Q.width,K.canvas.height=Q.height,K.activeTexture(K.TEXTURE0),V.h.bindTexture2d(V.l),K.texImage2D(K.TEXTURE_2D,0,K.RGBA,K.RGBA,K.UNSIGNED_BYTE,D),V.h.bindTexture2d(0),V=Q;break e;case"detections":for(V=b.o[l.stream],V||(V=new Z(b.h),b.o[l.stream]=V),V.data||(V.data=new V.g.DetectionListData),V.data.reset(D.length),Q=0;Q<D.length;++Q){K=D[Q];var se=V.data,fe=se.setBoundingBox,de=Q,we=K.boundingBox,be=new x;if(Ce(be,1,we.xCenter),Ce(be,2,we.yCenter),Ce(be,3,we.height),Ce(be,4,we.width),Ce(be,5,we.rotation),Ce(be,6,we.rectId),we=Y(be,j),fe.call(se,de,we),K.landmarks)for(se=0;se<K.landmarks.length;++se){be=K.landmarks[se];var ze=!!be.visibility;fe=V.data,de=fe.addNormalizedLandmark,we=Q,be=Object.assign(Object.assign({},be),{visibility:ze?be.visibility:0}),ze=new ft,Ce(ze,1,be.x),Ce(ze,2,be.y),Ce(ze,3,be.z),be.visibility&&Ce(ze,4,be.visibility),be=Y(ze,gt),de.call(fe,we,be)}if(K.V)for(se=0;se<K.V.length;++se)fe=V.data,de=fe.addClassification,we=Q,be=K.V[se],ze=new Ue,Ce(ze,2,be.ga),be.index&&Ce(ze,1,be.index),be.label&&Ce(ze,3,be.label),be.displayName&&Ce(ze,4,be.displayName),be=Y(ze,Fe),de.call(fe,we,be)}V=V.data;break e;default:V={}}}switch(m=V,F=l.stream,l.type){case"video":c.pushTexture2d(Object.assign(Object.assign({},m),{stream:F,timestamp:r}));break;case"detections":C=m,C.stream=F,C.timestamp=r,c.pushDetectionList(C);break;default:throw Error("Unknown input config type: '"+l.type+"'")}}return b.i.send(c),J(M,b.D,4);case 4:c.delete(),M.g=0}})};function w(o,f,b){var r,c,d,e,u,l,m,F,C,M,D,V,K,Q;return me(function(se){switch(se.g){case 1:if(!b)return se.return(f);for(r={},c=0,d=O(Object.keys(b)),e=d.next();!e.done;e=d.next())u=e.value,l=b[u],typeof l!="string"&&l.type==="texture"&&f[l.stream]!==void 0&&++c;1<c&&(o.I=!1),m=O(Object.keys(b)),e=m.next();case 2:if(e.done){se.g=4;break}if(F=e.value,C=b[F],typeof C=="string")return K=r,Q=F,J(se,S(o,F,f[C]),14);if(M=f[C.stream],C.type==="detection_list"){if(M){for(var fe=M.getRectList(),de=M.getLandmarksList(),we=M.getClassificationsList(),be=[],ze=0;ze<fe.size();++ze){var it=A(fe.get(ze),x,j);it={boundingBox:{xCenter:nt(it,1),yCenter:nt(it,2),height:nt(it,3),width:nt(it,4),rotation:nt(it,5,0),rectId:ve(it,6)},landmarks:ee(A(de.get(ze),jt,h),ft,1).map(U),V:P(A(we.get(ze),Be,Je))},be.push(it)}fe=be}else fe=[];r[F]=fe,se.g=7;break}if(C.type==="proto_list"){if(M){for(fe=Array(M.size()),de=0;de<M.size();de++)fe[de]=M.get(de);M.delete()}else fe=[];r[F]=fe,se.g=7;break}if(M===void 0){se.g=3;break}if(C.type==="float_list"){r[F]=M,se.g=7;break}if(C.type==="proto"){r[F]=M,se.g=7;break}if(C.type!=="texture")throw Error("Unknown output config type: '"+C.type+"'");return D=o.u[F],D||(D=new H(o.h,o.G),o.u[F]=D),J(se,G(D,M,o.I),13);case 13:V=se.h,r[F]=V;case 7:C.transform&&r[F]&&(r[F]=C.transform(r[F])),se.g=3;break;case 14:K[Q]=se.h;case 3:e=m.next(),se.g=2;break;case 4:return se.return(r)}})}function S(o,f,b){var r;return me(function(c){return typeof b=="number"||b instanceof Uint8Array||b instanceof o.h.Uint8BlobList?c.return(b):b instanceof o.h.Texture2dDataOut?(r=o.u[f],r||(r=new H(o.h,o.G),o.u[f]=r),c.return(G(r,b,o.I))):c.return(void 0)})}function I(o,f){for(var b=f.name||"$",r=[].concat(L(f.wants)),c=new o.h.StringList,d=O(f.wants),e=d.next();!e.done;e=d.next())c.push_back(e.value);d=o.h.PacketListener.implement({onResults:function(u){for(var l={},m=0;m<f.wants.length;++m)l[r[m]]=u.get(m);var F=o.listeners[b];F&&(o.D=w(o,l,f.outs).then(function(C){C=F(C);for(var M=0;M<f.wants.length;++M){var D=l[r[M]];typeof D=="object"&&D.hasOwnProperty&&D.hasOwnProperty("delete")&&D.delete()}C&&(o.D=C)}))}}),o.i.attachMultiListener(c,d),c.delete()}i.onResults=function(o,f){this.listeners[f||"$"]=o},je("Solution",Ee),je("OptionType",{BOOL:0,NUMBER:1,ia:2,0:"BOOL",1:"NUMBER",2:"STRING"});function B(o){var f=this;o=o||{};var b={url:"face_detection_short.binarypb"},r={type:1,graphOptionXref:{calculatorType:"TensorsToDetectionsCalculator",calculatorName:"facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator",fieldName:"min_score_thresh"}};this.g=new Ee({locateFile:o.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:b,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:typeof window!="object"||window.navigator===void 0?!1:"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(c){var d,e,u,l,m,F;return me(function(C){switch(C.g){case 1:d=c==="short"?["face_detection_short_range.tflite"]:["face_detection_full_range_sparse.tflite"],e=O(d),u=e.next();case 2:if(u.done){C.g=4;break}return l=u.value,m="third_party/mediapipe/modules/face_detection/"+l,J(C,a(f.g,l),5);case 5:F=C.h,f.g.overrideFile(m,F),u=e.next(),C.g=2;break;case 4:return b.url=c==="short"?"face_detection_short.binarypb":"face_detection_full.binarypb",r.graphOptionXref.calculatorName=c==="short"?"facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator":"facedetectionfullrangegpu__facedetectionfullrangecommon__TensorsToDetectionsCalculator",C.return(!0)}})}},minDetectionConfidence:r}})}i=B.prototype,i.close=function(){return this.g.close(),Promise.resolve()},i.onResults=function(o){this.g.onResults(o)},i.initialize=function(){var o=this;return me(function(f){return J(f,o.g.initialize(),0)})},i.reset=function(){this.g.reset()},i.send=function(o){var f=this;return me(function(b){return J(b,f.g.send(o),0)})},i.setOptions=function(o){this.g.setOptions(o)},je("FaceDetection",B),je("FACEDETECTION_LIPS",W),je("FACEDETECTION_LEFT_EYE",X),je("FACEDETECTION_LEFT_EYEBROW",z),je("FACEDETECTION_RIGHT_EYE",q),je("FACEDETECTION_RIGHT_EYEBROW",ae),je("FACEDETECTION_FACE_OVAL",s),je("FACEDETECTION_CONTOURS",_),je("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]]),je("VERSION","0.4.1646425229")}).call(Si);const Ri={};(function(){var i;function t(h){var v=0;return function(){return v<h.length?{done:!1,value:h[v++]}:{done:!0}}}var n=typeof Object.defineProperties=="function"?Object.defineProperty:function(h,v,x){return h==Array.prototype||h==Object.prototype||(h[v]=x.value),h};function p(h){h=[typeof globalThis=="object"&&globalThis,h,typeof window=="object"&&window,typeof self=="object"&&self,typeof global=="object"&&global];for(var v=0;v<h.length;++v){var x=h[v];if(x&&x.Math==Math)return x}throw Error("Cannot find global object")}var y=p(this);function R(h,v){if(v)e:{var x=y;h=h.split(".");for(var j=0;j<h.length-1;j++){var W=h[j];if(!(W in x))break e;x=x[W]}h=h[h.length-1],j=x[h],v=v(j),v!=j&&v!=null&&n(x,h,{configurable:!0,writable:!0,value:v})}}R("Symbol",function(h){function v(X){if(this instanceof v)throw new TypeError("Symbol is not a constructor");return new x(j+(X||"")+"_"+W++,X)}function x(X,z){this.g=X,n(this,"description",{configurable:!0,writable:!0,value:z})}if(h)return h;x.prototype.toString=function(){return this.g};var j="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",W=0;return v}),R("Symbol.iterator",function(h){if(h)return h;h=Symbol("Symbol.iterator");for(var v="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),x=0;x<v.length;x++){var j=y[v[x]];typeof j=="function"&&typeof j.prototype[h]!="function"&&n(j.prototype,h,{configurable:!0,writable:!0,value:function(){return k(t(this))}})}return h});function k(h){return h={next:h},h[Symbol.iterator]=function(){return this},h}function O(h){var v=typeof Symbol<"u"&&Symbol.iterator&&h[Symbol.iterator];return v?v.call(h):{next:t(h)}}function L(h){if(!(h instanceof Array)){h=O(h);for(var v,x=[];!(v=h.next()).done;)x.push(v.value);h=x}return h}var te=typeof Object.create=="function"?Object.create:function(h){function v(){}return v.prototype=h,new v},ue;if(typeof Object.setPrototypeOf=="function")ue=Object.setPrototypeOf;else{var pe;e:{var Oe={a:!0},Me={};try{Me.__proto__=Oe,pe=Me.a;break e}catch{}pe=!1}ue=pe?function(h,v){if(h.__proto__=v,h.__proto__!==v)throw new TypeError(h+" is not extensible");return h}:null}var ce=ue;function he(h,v){if(h.prototype=te(v.prototype),h.prototype.constructor=h,ce)ce(h,v);else for(var x in v)if(x!="prototype")if(Object.defineProperties){var j=Object.getOwnPropertyDescriptor(v,x);j&&Object.defineProperty(h,x,j)}else h[x]=v[x];h.ea=v.prototype}function Ge(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function Ve(h){if(h.l)throw new TypeError("Generator is already running");h.l=!0}Ge.prototype.o=function(h){this.h=h};function ct(h,v){h.j={U:v,V:!0},h.g=h.m||h.s}Ge.prototype.return=function(h){this.j={return:h},this.g=this.s};function J(h,v,x){return h.g=x,{value:v}}function Jt(h){this.g=new Ge,this.h=h}function mr(h,v){Ve(h.g);var x=h.g.i;return x?At(h,"return"in x?x.return:function(j){return{value:j,done:!0}},v,h.g.return):(h.g.return(v),Xe(h))}function At(h,v,x,j){try{var W=v.call(h.g.i,x);if(!(W instanceof Object))throw new TypeError("Iterator result "+W+" is not an object");if(!W.done)return h.g.l=!1,W;var X=W.value}catch(z){return h.g.i=null,ct(h.g,z),Xe(h)}return h.g.i=null,j.call(h.g,X),Xe(h)}function Xe(h){for(;h.g.g;)try{var v=h.h(h.g);if(v)return h.g.l=!1,{value:v.value,done:!1}}catch(x){h.g.h=void 0,ct(h.g,x)}if(h.g.l=!1,h.g.j){if(v=h.g.j,h.g.j=null,v.V)throw v.U;return{value:v.return,done:!0}}return{value:void 0,done:!0}}function Mr(h){this.next=function(v){return Ve(h.g),h.g.i?v=At(h,h.g.i.next,v,h.g.o):(h.g.o(v),v=Xe(h)),v},this.throw=function(v){return Ve(h.g),h.g.i?v=At(h,h.g.i.throw,v,h.g.o):(ct(h.g,v),v=Xe(h)),v},this.return=function(v){return mr(h,v)},this[Symbol.iterator]=function(){return this}}function at(h,v){return v=new Mr(new Jt(v)),ce&&h.prototype&&ce(v,h.prototype),v}function me(h,v){h instanceof String&&(h+="");var x=0,j=!1,W={next:function(){if(!j&&x<h.length){var X=x++;return{value:v(X,h[X]),done:!1}}return j=!0,{done:!0,value:void 0}}};return W[Symbol.iterator]=function(){return W},W}var Wr=typeof Object.assign=="function"?Object.assign:function(h,v){for(var x=1;x<arguments.length;x++){var j=arguments[x];if(j)for(var W in j)Object.prototype.hasOwnProperty.call(j,W)&&(h[W]=j[W])}return h};R("Object.assign",function(h){return h||Wr}),R("Promise",function(h){function v(z){this.h=0,this.i=void 0,this.g=[],this.o=!1;var q=this.j();try{z(q.resolve,q.reject)}catch(ae){q.reject(ae)}}function x(){this.g=null}function j(z){return z instanceof v?z:new v(function(q){q(z)})}if(h)return h;x.prototype.h=function(z){if(this.g==null){this.g=[];var q=this;this.i(function(){q.l()})}this.g.push(z)};var W=y.setTimeout;x.prototype.i=function(z){W(z,0)},x.prototype.l=function(){for(;this.g&&this.g.length;){var z=this.g;this.g=[];for(var q=0;q<z.length;++q){var ae=z[q];z[q]=null;try{ae()}catch(s){this.j(s)}}}this.g=null},x.prototype.j=function(z){this.i(function(){throw z})},v.prototype.j=function(){function z(s){return function(_){ae||(ae=!0,s.call(q,_))}}var q=this,ae=!1;return{resolve:z(this.C),reject:z(this.l)}},v.prototype.C=function(z){if(z===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(z instanceof v)this.F(z);else{e:switch(typeof z){case"object":var q=z!=null;break e;case"function":q=!0;break e;default:q=!1}q?this.u(z):this.m(z)}},v.prototype.u=function(z){var q=void 0;try{q=z.then}catch(ae){this.l(ae);return}typeof q=="function"?this.G(q,z):this.m(z)},v.prototype.l=function(z){this.s(2,z)},v.prototype.m=function(z){this.s(1,z)},v.prototype.s=function(z,q){if(this.h!=0)throw Error("Cannot settle("+z+", "+q+"): Promise already settled in state"+this.h);this.h=z,this.i=q,this.h===2&&this.D(),this.A()},v.prototype.D=function(){var z=this;W(function(){if(z.B()){var q=y.console;typeof q<"u"&&q.error(z.i)}},1)},v.prototype.B=function(){if(this.o)return!1;var z=y.CustomEvent,q=y.Event,ae=y.dispatchEvent;return typeof ae>"u"?!0:(typeof z=="function"?z=new z("unhandledrejection",{cancelable:!0}):typeof q=="function"?z=new q("unhandledrejection",{cancelable:!0}):(z=y.document.createEvent("CustomEvent"),z.initCustomEvent("unhandledrejection",!1,!0,z)),z.promise=this,z.reason=this.i,ae(z))},v.prototype.A=function(){if(this.g!=null){for(var z=0;z<this.g.length;++z)X.h(this.g[z]);this.g=null}};var X=new x;return v.prototype.F=function(z){var q=this.j();z.J(q.resolve,q.reject)},v.prototype.G=function(z,q){var ae=this.j();try{z.call(q,ae.resolve,ae.reject)}catch(s){ae.reject(s)}},v.prototype.then=function(z,q){function ae(P,U){return typeof P=="function"?function(H){try{s(P(H))}catch(G){_(G)}}:U}var s,_,T=new v(function(P,U){s=P,_=U});return this.J(ae(z,s),ae(q,_)),T},v.prototype.catch=function(z){return this.then(void 0,z)},v.prototype.J=function(z,q){function ae(){switch(s.h){case 1:z(s.i);break;case 2:q(s.i);break;default:throw Error("Unexpected state: "+s.h)}}var s=this;this.g==null?X.h(ae):this.g.push(ae),this.o=!0},v.resolve=j,v.reject=function(z){return new v(function(q,ae){ae(z)})},v.race=function(z){return new v(function(q,ae){for(var s=O(z),_=s.next();!_.done;_=s.next())j(_.value).J(q,ae)})},v.all=function(z){var q=O(z),ae=q.next();return ae.done?j([]):new v(function(s,_){function T(H){return function(G){P[H]=G,U--,U==0&&s(P)}}var P=[],U=0;do P.push(void 0),U++,j(ae.value).J(T(P.length-1),_),ae=q.next();while(!ae.done)})},v}),R("Object.is",function(h){return h||function(v,x){return v===x?v!==0||1/v===1/x:v!==v&&x!==x}}),R("Array.prototype.includes",function(h){return h||function(v,x){var j=this;j instanceof String&&(j=String(j));var W=j.length;for(x=x||0,0>x&&(x=Math.max(x+W,0));x<W;x++){var X=j[x];if(X===v||Object.is(X,v))return!0}return!1}}),R("String.prototype.includes",function(h){return h||function(v,x){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(v instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(v,x||0)!==-1}}),R("Array.prototype.keys",function(h){return h||function(){return me(this,function(v){return v})}});var Br=this||self;function Tt(h,v){h=h.split(".");var x=Br;h[0]in x||typeof x.execScript>"u"||x.execScript("var "+h[0]);for(var j;h.length&&(j=h.shift());)h.length||v===void 0?x[j]&&x[j]!==Object.prototype[j]?x=x[j]:x=x[j]={}:x[j]=v}function je(h,v){return v=String.fromCharCode.apply(null,v),h==null?v:h+v}var Ot,tr=typeof TextDecoder<"u",yr,Or=typeof TextEncoder<"u";function wr(h){if(Or)h=(yr||(yr=new TextEncoder)).encode(h);else{var v=void 0;v=v===void 0?!1:v;for(var x=0,j=new Uint8Array(3*h.length),W=0;W<h.length;W++){var X=h.charCodeAt(W);if(128>X)j[x++]=X;else{if(2048>X)j[x++]=X>>6|192;else{if(55296<=X&&57343>=X){if(56319>=X&&W<h.length){var z=h.charCodeAt(++W);if(56320<=z&&57343>=z){X=1024*(X-55296)+z-56320+65536,j[x++]=X>>18|240,j[x++]=X>>12&63|128,j[x++]=X>>6&63|128,j[x++]=X&63|128;continue}else W--}if(v)throw Error("Found an unpaired surrogate");X=65533}j[x++]=X>>12|224,j[x++]=X>>6&63|128}j[x++]=X&63|128}}h=j.subarray(0,x)}return h}var Pr={},rr=null;function Dt(h,v){v===void 0&&(v=0),vr(),v=Pr[v];for(var x=Array(Math.floor(h.length/3)),j=v[64]||"",W=0,X=0;W<h.length-2;W+=3){var z=h[W],q=h[W+1],ae=h[W+2],s=v[z>>2];z=v[(z&3)<<4|q>>4],q=v[(q&15)<<2|ae>>6],ae=v[ae&63],x[X++]=s+z+q+ae}switch(s=0,ae=j,h.length-W){case 2:s=h[W+1],ae=v[(s&15)<<2]||j;case 1:h=h[W],x[X]=v[h>>2]+v[(h&3)<<4|s>>4]+ae+j}return x.join("")}function xr(h){var v=h.length,x=3*v/4;x%3?x=Math.floor(x):"=.".indexOf(h[v-1])!=-1&&(x="=.".indexOf(h[v-2])!=-1?x-2:x-1);var j=new Uint8Array(x),W=0;return Ir(h,function(X){j[W++]=X}),j.subarray(0,W)}function Ir(h,v){function x(ae){for(;j<h.length;){var s=h.charAt(j++),_=rr[s];if(_!=null)return _;if(!/^[\s\xa0]*$/.test(s))throw Error("Unknown base64 encoding at char: "+s)}return ae}vr();for(var j=0;;){var W=x(-1),X=x(0),z=x(64),q=x(64);if(q===64&&W===-1)break;v(W<<2|X>>4),z!=64&&(v(X<<4&240|z>>2),q!=64&&v(z<<6&192|q))}}function vr(){if(!rr){rr={};for(var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),v=["+/=","+/","-_=","-_.","-_"],x=0;5>x;x++){var j=h.concat(v[x].split(""));Pr[x]=j;for(var W=0;W<j.length;W++){var X=j[W];rr[X]===void 0&&(rr[X]=W)}}}}var Ct=typeof Uint8Array.prototype.slice=="function",_r;function lr(h,v,x){return v===x?_r||(_r=new Uint8Array(0)):Ct?h.slice(v,x):new Uint8Array(h.subarray(v,x))}var ut=0,St=0;function Ht(h,v){v=v===void 0?{}:v,v=v.v===void 0?!1:v.v,this.h=null,this.g=this.j=this.l=0,this.m=!1,this.v=v,h&&xt(this,h)}function xt(h,v){v=v.constructor===Uint8Array?v:v.constructor===ArrayBuffer?new Uint8Array(v):v.constructor===Array?new Uint8Array(v):v.constructor===String?xr(v):v instanceof Uint8Array?new Uint8Array(v.buffer,v.byteOffset,v.byteLength):new Uint8Array(0),h.h=v,h.l=0,h.j=h.h.length,h.g=h.l}Ht.prototype.reset=function(){this.g=this.l};function _t(h){for(var v=128,x=0,j=0,W=0;4>W&&128<=v;W++)v=h.h[h.g++],x|=(v&127)<<7*W;if(128<=v&&(v=h.h[h.g++],x|=(v&127)<<28,j|=(v&127)>>4),128<=v)for(W=0;5>W&&128<=v;W++)v=h.h[h.g++],j|=(v&127)<<7*W+3;if(128>v)return h=x>>>0,v=j>>>0,(j=v&2147483648)&&(h=~h+1>>>0,v=~v>>>0,h==0&&(v=v+1>>>0)),h=4294967296*v+(h>>>0),j?-h:h;h.m=!0}Ht.prototype.i=function(){var h=this.h,v=h[this.g],x=v&127;return 128>v?(this.g+=1,x):(v=h[this.g+1],x|=(v&127)<<7,128>v?(this.g+=2,x):(v=h[this.g+2],x|=(v&127)<<14,128>v?(this.g+=3,x):(v=h[this.g+3],x|=(v&127)<<21,128>v?(this.g+=4,x):(v=h[this.g+4],x|=(v&15)<<28,128>v?(this.g+=5,x>>>0):(this.g+=5,128<=h[this.g++]&&128<=h[this.g++]&&128<=h[this.g++]&&128<=h[this.g++]&&this.g++,x)))))},Ht.prototype.o=function(){var h=this.h[this.g],v=this.h[this.g+1],x=this.h[this.g+2],j=this.h[this.g+3];return this.g+=4,x=(h<<0|v<<8|x<<16|j<<24)>>>0,h=2*(x>>31)+1,v=x>>>23&255,x&=8388607,v==255?x?NaN:1/0*h:v==0?h*Math.pow(2,-149)*x:h*Math.pow(2,v-150)*(x+Math.pow(2,23))};var Zt=[];function Gt(){this.g=new Uint8Array(64),this.h=0}Gt.prototype.push=function(h){if(!(this.h+1<this.g.length)){var v=this.g;this.g=new Uint8Array(Math.ceil(1+2*this.g.length)),this.g.set(v)}this.g[this.h++]=h},Gt.prototype.length=function(){return this.h},Gt.prototype.end=function(){var h=this.g,v=this.h;return this.h=0,lr(h,0,v)};function qe(h,v){for(;127<v;)h.push(v&127|128),v>>>=7;h.push(v)}function mt(h){var v={},x=v.N===void 0?!1:v.N;this.o={v:v.v===void 0?!1:v.v},this.N=x,v=this.o,Zt.length?(x=Zt.pop(),v&&(x.v=v.v),h&&xt(x,h),h=x):h=new Ht(h,v),this.g=h,this.m=this.g.g,this.h=this.i=this.l=-1,this.j=!1}mt.prototype.reset=function(){this.g.reset(),this.h=this.l=-1};function Rt(h){var v=h.g;if((v=v.g==v.j)||(v=h.j)||(v=h.g,v=v.m||0>v.g||v.g>v.j),v)return!1;h.m=h.g.g,v=h.g.i();var x=v&7;return x!=0&&x!=5&&x!=1&&x!=2&&x!=3&&x!=4?(h.j=!0,!1):(h.i=v,h.l=v>>>3,h.h=x,!0)}function We(h){switch(h.h){case 0:if(h.h!=0)We(h);else{for(h=h.g;h.h[h.g]&128;)h.g++;h.g++}break;case 1:h.h!=1?We(h):(h=h.g,h.g+=8);break;case 2:if(h.h!=2)We(h);else{var v=h.g.i();h=h.g,h.g+=v}break;case 5:h.h!=5?We(h):(h=h.g,h.g+=4);break;case 3:v=h.l;do{if(!Rt(h)){h.j=!0;break}if(h.h==4){h.l!=v&&(h.j=!0);break}We(h)}while(!0);break;default:h.j=!0}}function Ft(h,v,x){var j=h.g.j,W=h.g.i(),X=h.g.g+W;if(h.g.j=X,x(v,h),x=X-h.g.g,x!==0)throw Error("Message parsing ended unexpectedly. Expected to read "+W+" bytes, instead read "+(W-x)+" bytes, either the data ended unexpectedly or the message misreported its own length");return h.g.g=X,h.g.j=j,v}function et(h){return h.g.o()}function pt(h){var v=h.g.i();h=h.g;var x=h.g;h.g+=v,h=h.h;var j;if(tr)(j=Ot)||(j=Ot=new TextDecoder("utf-8",{fatal:!1})),j=j.decode(h.subarray(x,x+v));else{v=x+v;for(var W=[],X=null,z,q,ae;x<v;)z=h[x++],128>z?W.push(z):224>z?x>=v?W.push(65533):(q=h[x++],194>z||(q&192)!==128?(x--,W.push(65533)):W.push((z&31)<<6|q&63)):240>z?x>=v-1?W.push(65533):(q=h[x++],(q&192)!==128||z===224&&160>q||z===237&&160<=q||((j=h[x++])&192)!==128?(x--,W.push(65533)):W.push((z&15)<<12|(q&63)<<6|j&63)):244>=z?x>=v-2?W.push(65533):(q=h[x++],(q&192)!==128||(z<<28)+(q-144)>>30!==0||((j=h[x++])&192)!==128||((ae=h[x++])&192)!==128?(x--,W.push(65533)):(z=(z&7)<<18|(q&63)<<12|(j&63)<<6|ae&63,z-=65536,W.push((z>>10&1023)+55296,(z&1023)+56320))):W.push(65533),8192<=W.length&&(X=je(X,W),W.length=0);j=je(X,W)}return j}function It(h,v,x){var j=h.g.i();for(j=h.g.g+j;h.g.g<j;)x.push(v.call(h.g))}function Vt(h,v){h.h==2?It(h,Ht.prototype.o,v):v.push(et(h))}function wt(){this.h=[],this.i=0,this.g=new Gt}function Ye(h,v){v.length!==0&&(h.h.push(v),h.i+=v.length)}function Lt(h){var v=h.i+h.g.length();if(v===0)return new Uint8Array(0);v=new Uint8Array(v);for(var x=h.h,j=x.length,W=0,X=0;X<j;X++){var z=x[X];z.length!==0&&(v.set(z,W),W+=z.length)}return x=h.g,j=x.h,j!==0&&(v.set(x.g.subarray(0,j),W),x.h=0),h.h=[v],v}function zt(h,v,x){if(x!=null){qe(h.g,8*v+5),h=h.g;var j=x;j=(x=0>j?1:0)?-j:j,j===0?0<1/j?ut=St=0:(St=0,ut=2147483648):isNaN(j)?(St=0,ut=2147483647):34028234663852886e22<j?(St=0,ut=(x<<31|2139095040)>>>0):11754943508222875e-54>j?(j=Math.round(j/Math.pow(2,-149)),St=0,ut=(x<<31|j)>>>0):(v=Math.floor(Math.log(j)/Math.LN2),j*=Math.pow(2,-v),j=Math.round(8388608*j),16777216<=j&&++v,St=0,ut=(x<<31|v+127<<23|j&8388607)>>>0),x=ut,h.push(x>>>0&255),h.push(x>>>8&255),h.push(x>>>16&255),h.push(x>>>24&255)}}var Et=typeof Uint8Array=="function";function fr(h,v,x){if(h!=null)return typeof h=="object"?Et&&h instanceof Uint8Array?x(h):qt(h,v,x):v(h)}function qt(h,v,x){if(Array.isArray(h)){for(var j=Array(h.length),W=0;W<h.length;W++)j[W]=fr(h[W],v,x);return Array.isArray(h)&&h.W&&yt(j),j}j={};for(W in h)j[W]=fr(h[W],v,x);return j}function sr(h){return typeof h=="number"?isFinite(h)?h:String(h):h}var hr={W:{value:!0,configurable:!0}};function yt(h){return Array.isArray(h)&&!Object.isFrozen(h)&&Object.defineProperties(h,hr),h}var kt;function vt(h,v,x){var j=kt;kt=null,h||(h=j),j=this.constructor.ca,h||(h=j?[j]:[]),this.j=j?0:-1,this.m=this.g=null,this.h=h;e:{if(j=this.h.length,h=j-1,j&&(j=this.h[h],!(j===null||typeof j!="object"||Array.isArray(j)||Et&&j instanceof Uint8Array))){this.l=h-this.j,this.i=j;break e}v!==void 0&&-1<v?(this.l=Math.max(v,h+1-this.j),this.i=null):this.l=Number.MAX_VALUE}if(x)for(v=0;v<x.length;v++)h=x[v],h<this.l?(h+=this.j,(j=this.h[h])?yt(j):this.h[h]=rt):(Ut(this),(j=this.i[h])?yt(j):this.i[h]=rt)}var rt=Object.freeze(yt([]));function Ut(h){var v=h.l+h.j;h.h[v]||(h.i=h.h[v]={})}function tt(h,v,x){return v===-1?null:x!==void 0&&x||v>=h.l?h.i?h.i[v]:void 0:h.h[v+h.j]}function $e(h,v){var x=x===void 0?!1:x,j=tt(h,v,x);return j==null&&(j=rt),j===rt&&(j=yt([]),Se(h,v,j,x)),j}function nr(h){var v=$e(h,3);if(h.m||(h.m={}),!h.m[3]){for(var x=0;x<v.length;x++)v[x]=+v[x];h.m[3]=!0}return v}function lt(h,v,x){return h=tt(h,v),h??x}function Ce(h,v,x){return h=tt(h,v),h=h==null?h:+h,h??(x===void 0?0:x)}function Se(h,v,x,j){j!==void 0&&j||v>=h.l?(Ut(h),h.i[v]=x):h.h[v+h.j]=x}function nt(h,v,x){if(x===-1)return null;if(h.g||(h.g={}),!h.g[x]){var j=tt(h,x,!1);j&&(h.g[x]=new v(j))}return h.g[x]}function ee(h,v){h.g||(h.g={});var x=h.g[1];if(!x){var j=$e(h,1);x=[];for(var W=0;W<j.length;W++)x[W]=new v(j[W]);h.g[1]=x}return x}function ie(h,v,x){var j=j===void 0?!1:j;h.g||(h.g={});var W=x&&He(x);h.g[v]=x,Se(h,v,W,j)}function ve(h,v,x,j){var W=ee(h,x);v=v||new x,h=$e(h,1),j!=null?(W.splice(j,0,v),h.splice(j,0,He(v))):(W.push(v),h.push(He(v)))}vt.prototype.toJSON=function(){var h=He(this);return qt(h,sr,Dt)};function He(h,v){if(h.g)for(var x in h.g){var j=h.g[x];if(Array.isArray(j))for(var W=0;W<j.length;W++)j[W]&&He(j[W]);else j&&He(j)}return h.h}vt.prototype.toString=function(){return He(this).toString()};function Ie(h,v){if(h=h.o){Ye(v,v.g.end());for(var x=0;x<h.length;x++)Ye(v,h[x])}}function xe(h,v){if(v.h==4)return!1;var x=v.m;return We(v),v.N||(v=lr(v.g.h,x,v.g.g),(x=h.o)?x.push(v):h.o=[v]),!0}function Ke(h){vt.call(this,h,-1,bt)}he(Ke,vt),Ke.prototype.getRows=function(){return tt(this,1)},Ke.prototype.getCols=function(){return tt(this,2)},Ke.prototype.getPackedDataList=function(){return nr(this)},Ke.prototype.getLayout=function(){return lt(this,4,0)};function ht(h,v){for(;Rt(v);)switch(v.i){case 8:var x=v.g.i();Se(h,1,x);break;case 16:x=v.g.i(),Se(h,2,x);break;case 29:case 26:Vt(v,h.getPackedDataList());break;case 32:x=_t(v.g),Se(h,4,x);break;default:if(!xe(h,v))return h}return h}var bt=[3];function Qe(h,v){var x=void 0;return new(x||(x=Promise))(function(j,W){function X(ae){try{q(v.next(ae))}catch(s){W(s)}}function z(ae){try{q(v.throw(ae))}catch(s){W(s)}}function q(ae){ae.done?j(ae.value):new x(function(s){s(ae.value)}).then(X,z)}q((v=v.apply(h,void 0)).next())})}function $t(h){vt.call(this,h)}he($t,vt);function Er(h,v){for(;Rt(v);)switch(v.i){case 8:var x=v.g.i();Se(h,1,x);break;case 21:x=et(v),Se(h,2,x);break;case 26:x=pt(v),Se(h,3,x);break;case 34:x=pt(v),Se(h,4,x);break;default:if(!xe(h,v))return h}return h}function ar(h){vt.call(this,h,-1,Yt)}he(ar,vt),ar.prototype.addClassification=function(h,v){return ve(this,h,$t,v),this};var Yt=[1];function ir(h){vt.call(this,h)}he(ir,vt);function ur(h,v){for(;Rt(v);)switch(v.i){case 13:var x=et(v);Se(h,1,x);break;case 21:x=et(v),Se(h,2,x);break;case 29:x=et(v),Se(h,3,x);break;case 37:x=et(v),Se(h,4,x);break;case 45:x=et(v),Se(h,5,x);break;default:if(!xe(h,v))return h}return h}function Pt(h){vt.call(this,h,-1,zr)}he(Pt,vt);function Xt(h){e:{var v=new Pt;for(h=new mt(h);Rt(h);)switch(h.i){case 10:var x=Ft(h,new ir,ur);ve(v,x,ir,void 0);break;default:if(!xe(v,h))break e}}return v}var zr=[1];function Kt(h){vt.call(this,h)}he(Kt,vt);function Mt(h){vt.call(this,h,-1,Ar)}he(Mt,vt),Mt.prototype.getVertexType=function(){return lt(this,1,0)},Mt.prototype.getPrimitiveType=function(){return lt(this,2,0)},Mt.prototype.getVertexBufferList=function(){return nr(this)},Mt.prototype.getIndexBufferList=function(){return $e(this,4)};function dr(h,v){for(;Rt(v);)switch(v.i){case 8:var x=_t(v.g);Se(h,1,x);break;case 16:x=_t(v.g),Se(h,2,x);break;case 29:case 26:Vt(v,h.getVertexBufferList());break;case 32:case 34:x=v;var j=h.getIndexBufferList();x.h==2?It(x,Ht.prototype.i,j):j.push(x.g.i());break;default:if(!xe(h,v))return h}return h}var Ar=[3,4];function Wt(h){vt.call(this,h)}he(Wt,vt),Wt.prototype.getMesh=function(){return nt(this,Mt,1)},Wt.prototype.getPoseTransformMatrix=function(){return nt(this,Ke,2)};function jr(h){e:{var v=new Wt;for(h=new mt(h);Rt(h);)switch(h.i){case 10:var x=Ft(h,new Mt,dr);ie(v,1,x);break;case 18:x=Ft(h,new Ke,ht),ie(v,2,x);break;default:if(!xe(v,h))break e}}return v}function Qt(h,v,x){if(x=h.createShader(x===0?h.VERTEX_SHADER:h.FRAGMENT_SHADER),h.shaderSource(x,v),h.compileShader(x),!h.getShaderParameter(x,h.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
|
|
71
|
-
|
|
72
|
-
`+h.getShaderInfoLog(x));return x}function pr(h){return ee(h,$t).map(function(v){return{index:lt(v,1,0),Y:Ce(v,2),label:tt(v,3)!=null?lt(v,3,""):void 0,displayName:tt(v,4)!=null?lt(v,4,""):void 0}})}function Tr(h){return{x:Ce(h,1),y:Ce(h,2),z:Ce(h,3),visibility:tt(h,4)!=null?Ce(h,4):void 0}}function Nr(h,v){this.h=h,this.g=v,this.l=0}function er(h,v,x){return Sr(h,v),typeof h.g.canvas.transferToImageBitmap=="function"?Promise.resolve(h.g.canvas.transferToImageBitmap()):x?Promise.resolve(h.g.canvas):typeof createImageBitmap=="function"?createImageBitmap(h.g.canvas):(h.i===void 0&&(h.i=document.createElement("canvas")),new Promise(function(j){h.i.height=h.g.canvas.height,h.i.width=h.g.canvas.width,h.i.getContext("2d",{}).drawImage(h.g.canvas,0,0,h.g.canvas.width,h.g.canvas.height),j(h.i)}))}function Sr(h,v){var x=h.g;if(h.m===void 0){var j=Qt(x,`
|
|
73
|
-
attribute vec2 aVertex;
|
|
74
|
-
attribute vec2 aTex;
|
|
75
|
-
varying vec2 vTex;
|
|
76
|
-
void main(void) {
|
|
77
|
-
gl_Position = vec4(aVertex, 0.0, 1.0);
|
|
78
|
-
vTex = aTex;
|
|
79
|
-
}`,0),W=Qt(x,`
|
|
80
|
-
precision mediump float;
|
|
81
|
-
varying vec2 vTex;
|
|
82
|
-
uniform sampler2D sampler0;
|
|
83
|
-
void main(){
|
|
84
|
-
gl_FragColor = texture2D(sampler0, vTex);
|
|
85
|
-
}`,1),X=x.createProgram();if(x.attachShader(X,j),x.attachShader(X,W),x.linkProgram(X),!x.getProgramParameter(X,x.LINK_STATUS))throw Error(`Could not compile WebGL program.
|
|
86
|
-
|
|
87
|
-
`+x.getProgramInfoLog(X));j=h.m=X,x.useProgram(j),W=x.getUniformLocation(j,"sampler0"),h.j={I:x.getAttribLocation(j,"aVertex"),H:x.getAttribLocation(j,"aTex"),da:W},h.s=x.createBuffer(),x.bindBuffer(x.ARRAY_BUFFER,h.s),x.enableVertexAttribArray(h.j.I),x.vertexAttribPointer(h.j.I,2,x.FLOAT,!1,0,0),x.bufferData(x.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),x.STATIC_DRAW),x.bindBuffer(x.ARRAY_BUFFER,null),h.o=x.createBuffer(),x.bindBuffer(x.ARRAY_BUFFER,h.o),x.enableVertexAttribArray(h.j.H),x.vertexAttribPointer(h.j.H,2,x.FLOAT,!1,0,0),x.bufferData(x.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),x.STATIC_DRAW),x.bindBuffer(x.ARRAY_BUFFER,null),x.uniform1i(W,0)}j=h.j,x.useProgram(h.m),x.canvas.width=v.width,x.canvas.height=v.height,x.viewport(0,0,v.width,v.height),x.activeTexture(x.TEXTURE0),h.h.bindTexture2d(v.glName),x.enableVertexAttribArray(j.I),x.bindBuffer(x.ARRAY_BUFFER,h.s),x.vertexAttribPointer(j.I,2,x.FLOAT,!1,0,0),x.enableVertexAttribArray(j.H),x.bindBuffer(x.ARRAY_BUFFER,h.o),x.vertexAttribPointer(j.H,2,x.FLOAT,!1,0,0),x.bindFramebuffer(x.DRAW_FRAMEBUFFER?x.DRAW_FRAMEBUFFER:x.FRAMEBUFFER,null),x.clearColor(0,0,0,0),x.clear(x.COLOR_BUFFER_BIT),x.colorMask(!0,!0,!0,!0),x.drawArrays(x.TRIANGLE_FAN,0,4),x.disableVertexAttribArray(j.I),x.disableVertexAttribArray(j.H),x.bindBuffer(x.ARRAY_BUFFER,null),h.h.bindTexture2d(0)}function $r(h){this.g=h}var Yr=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 Rr(h,v){return v+h}function kr(h,v){window[h]=v}function g(h){var v=document.createElement("script");return v.setAttribute("src",h),v.setAttribute("crossorigin","anonymous"),new Promise(function(x){v.addEventListener("load",function(){x()},!1),v.addEventListener("error",function(){x()},!1),document.body.appendChild(v)})}function E(){return Qe(this,function h(){return at(h,function(v){switch(v.g){case 1:return v.m=2,J(v,WebAssembly.instantiate(Yr),4);case 4:v.g=3,v.m=0;break;case 2:return v.m=0,v.j=null,v.return(!1);case 3:return v.return(!0)}})})}function A(h){if(this.g=h,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=h&&h.locateFile||Rr,typeof window=="object")var v=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")v=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.S=v,h.options){v=O(Object.keys(h.options));for(var x=v.next();!x.done;x=v.next()){x=x.value;var j=h.options[x].default;j!==void 0&&(this.j[x]=typeof j=="function"?j():j)}}}i=A.prototype,i.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function N(h,v){return h.g.files===void 0?[]:typeof h.g.files=="function"?h.g.files(v):h.g.files}function Y(h){return Qe(h,function v(){var x=this,j,W,X,z,q,ae,s,_,T,P,U;return at(v,function(H){switch(H.g){case 1:return j=x,x.R?(W=N(x,x.j),J(H,E(),2)):H.return();case 2:if(X=H.h,typeof window=="object")return kr("createMediapipeSolutionsWasm",{locateFile:x.locateFile}),kr("createMediapipeSolutionsPackedAssets",{locateFile:x.locateFile}),ae=W.filter(function(G){return G.data!==void 0}),s=W.filter(function(G){return G.data===void 0}),_=Promise.all(ae.map(function(G){var re=ne(j,G.url);if(G.path!==void 0){var Z=G.path;re=re.then(function(ye){return j.overrideFile(Z,ye),Promise.resolve(ye)})}return re})),T=Promise.all(s.map(function(G){return G.simd===void 0||G.simd&&X||!G.simd&&!X?g(j.locateFile(G.url,j.S)):Promise.resolve()})).then(function(){return Qe(j,function G(){var re,Z,ye=this;return at(G,function(_e){if(_e.g==1)return re=window.createMediapipeSolutionsWasm,Z=window.createMediapipeSolutionsPackedAssets,J(_e,re(Z),2);ye.h=_e.h,_e.g=0})})}),P=(function(){return Qe(j,function G(){var re=this;return at(G,function(Z){return re.g.graph&&re.g.graph.url?Z=J(Z,ne(re,re.g.graph.url),0):(Z.g=0,Z=void 0),Z})})})(),J(H,Promise.all([T,_,P]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return z=W.filter(function(G){return G.simd===void 0||G.simd&&X||!G.simd&&!X}).map(function(G){return j.locateFile(G.url,j.S)}),importScripts.apply(null,L(z)),J(H,createMediapipeSolutionsWasm(Module),6);case 6:x.h=H.h,x.l=new OffscreenCanvas(1,1),x.h.canvas=x.l,q=x.h.GL.createContext(x.l,{antialias:!1,alpha:!1,ba:typeof WebGL2RenderingContext<"u"?2:1}),x.h.GL.makeContextCurrent(q),H.g=4;break;case 7:if(x.l=document.createElement("canvas"),U=x.l.getContext("webgl2",{}),!U&&(U=x.l.getContext("webgl",{}),!U))return alert("Failed to create WebGL canvas context when passing video frame."),H.return();x.D=U,x.h.canvas=x.l,x.h.createContext(x.l,!0,!0,{});case 4:x.i=new x.h.SolutionWasm,x.R=!1,H.g=0}})})}function oe(h){return Qe(h,function v(){var x=this,j,W,X,z,q,ae,s,_;return at(v,function(T){if(T.g==1){if(x.g.graph&&x.g.graph.url&&x.P===x.g.graph.url)return T.return();if(x.o=!0,!x.g.graph||!x.g.graph.url){T.g=2;return}return x.P=x.g.graph.url,J(T,ne(x,x.g.graph.url),3)}for(T.g!=2&&(j=T.h,x.i.loadGraph(j)),W=O(Object.keys(x.B)),X=W.next();!X.done;X=W.next())z=X.value,x.i.overrideFile(z,x.B[z]);if(x.B={},x.g.listeners)for(q=O(x.g.listeners),ae=q.next();!ae.done;ae=q.next())s=ae.value,Ne(x,s);_=x.j,x.j={},x.setOptions(_),T.g=0})})}i.reset=function(){return Qe(this,function h(){var v=this;return at(h,function(x){v.i&&(v.i.reset(),v.m={},v.s={}),x.g=0})})},i.setOptions=function(h,v){var x=this;if(v=v||this.g.options){for(var j=[],W=[],X={},z=O(Object.keys(h)),q=z.next();!q.done;X={K:X.K,L:X.L},q=z.next()){var ae=q.value;ae in this.j&&this.j[ae]===h[ae]||(this.j[ae]=h[ae],q=v[ae],q!==void 0&&(q.onChange&&(X.K=q.onChange,X.L=h[ae],j.push((function(s){return function(){return Qe(x,function _(){var T,P=this;return at(_,function(U){if(U.g==1)return J(U,s.K(s.L),2);T=U.h,T===!0&&(P.o=!0),U.g=0})})}})(X))),q.graphOptionXref&&(ae={valueNumber:q.type===1?h[ae]:0,valueBoolean:q.type===0?h[ae]:!1,valueString:q.type===2?h[ae]:""},q=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),q.graphOptionXref),ae),W.push(q))))}(j.length!==0||W.length!==0)&&(this.o=!0,this.A=(this.A===void 0?[]:this.A).concat(W),this.u=(this.u===void 0?[]:this.u).concat(j))}};function $(h){return Qe(h,function v(){var x=this,j,W,X,z,q,ae,s;return at(v,function(_){switch(_.g){case 1:if(!x.o)return _.return();if(!x.u){_.g=2;break}j=O(x.u),W=j.next();case 3:if(W.done){_.g=5;break}return X=W.value,J(_,X(),4);case 4:W=j.next(),_.g=3;break;case 5:x.u=void 0;case 2:if(x.A){for(z=new x.h.GraphOptionChangeRequestList,q=O(x.A),ae=q.next();!ae.done;ae=q.next())s=ae.value,z.push_back(s);x.i.changeOptions(z),z.delete(),x.A=void 0}x.o=!1,_.g=0}})})}i.initialize=function(){return Qe(this,function h(){var v=this;return at(h,function(x){return x.g==1?J(x,Y(v),2):x.g!=3?J(x,oe(v),3):J(x,$(v),0)})})};function ne(h,v){return Qe(h,function x(){var j=this,W,X;return at(x,function(z){return v in j.F?z.return(j.F[v]):(W=j.locateFile(v,""),X=fetch(W).then(function(q){return q.arrayBuffer()}),j.F[v]=X,z.return(X))})})}i.overrideFile=function(h,v){this.i?this.i.overrideFile(h,v):this.B[h]=v},i.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},i.send=function(h,v){return Qe(this,function x(){var j=this,W,X,z,q,ae,s,_,T,P;return at(x,function(U){switch(U.g){case 1:return j.g.inputs?(W=1e3*(v??performance.now()),J(U,j.C,2)):U.return();case 2:return J(U,j.initialize(),3);case 3:for(X=new j.h.PacketDataList,z=O(Object.keys(h)),q=z.next();!q.done;q=z.next())if(ae=q.value,s=j.g.inputs[ae]){e:{var H=j,G=h[ae];switch(s.type){case"video":var re=H.m[s.stream];if(re||(re=new Nr(H.h,H.D),H.m[s.stream]=re),H=re,H.l===0&&(H.l=H.h.createTexture()),typeof HTMLVideoElement<"u"&&G instanceof HTMLVideoElement){var Z=G.videoWidth;re=G.videoHeight}else typeof HTMLImageElement<"u"&&G instanceof HTMLImageElement?(Z=G.naturalWidth,re=G.naturalHeight):(Z=G.width,re=G.height);re={glName:H.l,width:Z,height:re},Z=H.g,Z.canvas.width=re.width,Z.canvas.height=re.height,Z.activeTexture(Z.TEXTURE0),H.h.bindTexture2d(H.l),Z.texImage2D(Z.TEXTURE_2D,0,Z.RGBA,Z.RGBA,Z.UNSIGNED_BYTE,G),H.h.bindTexture2d(0),H=re;break e;case"detections":for(re=H.m[s.stream],re||(re=new $r(H.h),H.m[s.stream]=re),H=re,H.data||(H.data=new H.g.DetectionListData),H.data.reset(G.length),re=0;re<G.length;++re){Z=G[re];var ye=H.data,_e=ye.setBoundingBox,De=re,Te=Z.T,le=new Kt;Se(le,1,Te.Z),Se(le,2,Te.$),Se(le,3,Te.height),Se(le,4,Te.width),Se(le,5,Te.rotation),Se(le,6,Te.X);var Ee=Te=new wt;zt(Ee,1,tt(le,1)),zt(Ee,2,tt(le,2)),zt(Ee,3,tt(le,3)),zt(Ee,4,tt(le,4)),zt(Ee,5,tt(le,5));var Re=tt(le,6);if(Re!=null&&Re!=null){qe(Ee.g,48);var ke=Ee.g,Pe=Re;Re=0>Pe,Pe=Math.abs(Pe);var a=Pe>>>0;for(Pe=Math.floor((Pe-a)/4294967296),Pe>>>=0,Re&&(Pe=~Pe>>>0,a=(~a>>>0)+1,4294967295<a&&(a=0,Pe++,4294967295<Pe&&(Pe=0))),ut=a,St=Pe,Re=ut,a=St;0<a||127<Re;)ke.push(Re&127|128),Re=(Re>>>7|a<<25)>>>0,a>>>=7;ke.push(Re)}if(Ie(le,Ee),Te=Lt(Te),_e.call(ye,De,Te),Z.O)for(ye=0;ye<Z.O.length;++ye)le=Z.O[ye],Ee=!!le.visibility,_e=H.data,De=_e.addNormalizedLandmark,Te=re,le=Object.assign(Object.assign({},le),{visibility:Ee?le.visibility:0}),Ee=new ir,Se(Ee,1,le.x),Se(Ee,2,le.y),Se(Ee,3,le.z),le.visibility&&Se(Ee,4,le.visibility),ke=le=new wt,zt(ke,1,tt(Ee,1)),zt(ke,2,tt(Ee,2)),zt(ke,3,tt(Ee,3)),zt(ke,4,tt(Ee,4)),zt(ke,5,tt(Ee,5)),Ie(Ee,ke),le=Lt(le),De.call(_e,Te,le);if(Z.M)for(ye=0;ye<Z.M.length;++ye){if(_e=H.data,De=_e.addClassification,Te=re,le=Z.M[ye],Ee=new $t,Se(Ee,2,le.Y),le.index&&Se(Ee,1,le.index),le.label&&Se(Ee,3,le.label),le.displayName&&Se(Ee,4,le.displayName),ke=le=new wt,a=tt(Ee,1),a!=null&&a!=null)if(qe(ke.g,8),Re=ke.g,0<=a)qe(Re,a);else{for(Pe=0;9>Pe;Pe++)Re.push(a&127|128),a>>=7;Re.push(1)}zt(ke,2,tt(Ee,2)),Re=tt(Ee,3),Re!=null&&(Re=wr(Re),qe(ke.g,26),qe(ke.g,Re.length),Ye(ke,ke.g.end()),Ye(ke,Re)),Re=tt(Ee,4),Re!=null&&(Re=wr(Re),qe(ke.g,34),qe(ke.g,Re.length),Ye(ke,ke.g.end()),Ye(ke,Re)),Ie(Ee,ke),le=Lt(le),De.call(_e,Te,le)}}H=H.data;break e;default:H={}}}switch(_=H,T=s.stream,s.type){case"video":X.pushTexture2d(Object.assign(Object.assign({},_),{stream:T,timestamp:W}));break;case"detections":P=_,P.stream=T,P.timestamp=W,X.pushDetectionList(P);break;default:throw Error("Unknown input config type: '"+s.type+"'")}}return j.i.send(X),J(U,j.C,4);case 4:X.delete(),U.g=0}})})};function ge(h,v,x){return Qe(h,function j(){var W,X,z,q,ae,s,_=this,T,P,U,H,G,re,Z,ye;return at(j,function(_e){switch(_e.g){case 1:if(!x)return _e.return(v);for(W={},X=0,z=O(Object.keys(x)),q=z.next();!q.done;q=z.next())ae=q.value,s=x[ae],typeof s!="string"&&s.type==="texture"&&v[s.stream]!==void 0&&++X;1<X&&(_.G=!1),T=O(Object.keys(x)),q=T.next();case 2:if(q.done){_e.g=4;break}if(P=q.value,U=x[P],typeof U=="string")return Z=W,ye=P,J(_e,Ae(_,P,v[U]),14);if(H=v[U.stream],U.type==="detection_list"){if(H){for(var De=H.getRectList(),Te=H.getLandmarksList(),le=H.getClassificationsList(),Ee=[],Re=0;Re<De.size();++Re){var ke=De.get(Re);e:{var Pe=new Kt;for(ke=new mt(ke);Rt(ke);)switch(ke.i){case 13:var a=et(ke);Se(Pe,1,a);break;case 21:a=et(ke),Se(Pe,2,a);break;case 29:a=et(ke),Se(Pe,3,a);break;case 37:a=et(ke),Se(Pe,4,a);break;case 45:a=et(ke),Se(Pe,5,a);break;case 48:a=_t(ke.g),Se(Pe,6,a);break;default:if(!xe(Pe,ke))break e}}Pe={Z:Ce(Pe,1),$:Ce(Pe,2),height:Ce(Pe,3),width:Ce(Pe,4),rotation:Ce(Pe,5,0),X:lt(Pe,6,0)},ke=ee(Xt(Te.get(Re)),ir).map(Tr);var w=le.get(Re);e:for(a=new ar,w=new mt(w);Rt(w);)switch(w.i){case 10:a.addClassification(Ft(w,new $t,Er));break;default:if(!xe(a,w))break e}Pe={T:Pe,O:ke,M:pr(a)},Ee.push(Pe)}De=Ee}else De=[];W[P]=De,_e.g=7;break}if(U.type==="proto_list"){if(H){for(De=Array(H.size()),Te=0;Te<H.size();Te++)De[Te]=H.get(Te);H.delete()}else De=[];W[P]=De,_e.g=7;break}if(H===void 0){_e.g=3;break}if(U.type==="float_list"){W[P]=H,_e.g=7;break}if(U.type==="proto"){W[P]=H,_e.g=7;break}if(U.type!=="texture")throw Error("Unknown output config type: '"+U.type+"'");return G=_.s[P],G||(G=new Nr(_.h,_.D),_.s[P]=G),J(_e,er(G,H,_.G),13);case 13:re=_e.h,W[P]=re;case 7:U.transform&&W[P]&&(W[P]=U.transform(W[P])),_e.g=3;break;case 14:Z[ye]=_e.h;case 3:q=T.next(),_e.g=2;break;case 4:return _e.return(W)}})})}function Ae(h,v,x){return Qe(h,function j(){var W=this,X;return at(j,function(z){return typeof x=="number"||x instanceof Uint8Array||x instanceof W.h.Uint8BlobList?z.return(x):x instanceof W.h.Texture2dDataOut?(X=W.s[v],X||(X=new Nr(W.h,W.D),W.s[v]=X),z.return(er(X,x,W.G))):z.return(void 0)})})}function Ne(h,v){for(var x=v.name||"$",j=[].concat(L(v.wants)),W=new h.h.StringList,X=O(v.wants),z=X.next();!z.done;z=X.next())W.push_back(z.value);X=h.h.PacketListener.implement({onResults:function(q){for(var ae={},s=0;s<v.wants.length;++s)ae[j[s]]=q.get(s);var _=h.listeners[x];_&&(h.C=ge(h,ae,v.outs).then(function(T){T=_(T);for(var P=0;P<v.wants.length;++P){var U=ae[j[P]];typeof U=="object"&&U.hasOwnProperty&&U.hasOwnProperty("delete")&&U.delete()}T&&(h.C=T)}))}}),h.i.attachMultiListener(W,X),W.delete()}i.onResults=function(h,v){this.listeners[v||"$"]=h},Tt("Solution",A),Tt("OptionType",{BOOL:0,NUMBER:1,aa:2,0:"BOOL",1:"NUMBER",2:"STRING"});function Le(h){h=jr(h);var v=h.getMesh();if(!v)return h;var x=new Float32Array(v.getVertexBufferList());v.getVertexBufferList=function(){return x};var j=new Uint32Array(v.getIndexBufferList());return v.getIndexBufferList=function(){return j},h}var Ze={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(h){return h.map(Le)}},multiFaceLandmarks:{type:"proto_list",stream:"multi_face_landmarks",transform:function(h){return h.map(function(v){return ee(Xt(v),ir).map(Tr)})}}}}],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]],Fe=[[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]],Be=[[276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]],Je=[[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]],st=[[46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]],ft=[[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]],gt=[].concat(L(Ue),L(Fe),L(Be),L(Je),L(st),L(ft));function jt(h){h=h||{},h=Object.assign(Object.assign({},Ze),h),this.g=new A(h)}i=jt.prototype,i.close=function(){return this.g.close(),Promise.resolve()},i.onResults=function(h){this.g.onResults(h)},i.initialize=function(){return Qe(this,function h(){var v=this;return at(h,function(x){return J(x,v.g.initialize(),0)})})},i.reset=function(){this.g.reset()},i.send=function(h){return Qe(this,function v(){var x=this;return at(v,function(j){return J(j,x.g.send(h),0)})})},i.setOptions=function(h){this.g.setOptions(h)},Tt("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}}),Tt("FaceMesh",jt),Tt("FACEMESH_LIPS",Ue),Tt("FACEMESH_LEFT_EYE",Fe),Tt("FACEMESH_LEFT_EYEBROW",Be),Tt("FACEMESH_LEFT_IRIS",[[474,475],[475,476],[476,477],[477,474]]),Tt("FACEMESH_RIGHT_EYE",Je),Tt("FACEMESH_RIGHT_EYEBROW",st),Tt("FACEMESH_RIGHT_IRIS",[[469,470],[470,471],[471,472],[472,469]]),Tt("FACEMESH_FACE_OVAL",ft),Tt("FACEMESH_CONTOURS",gt),Tt("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]]),Tt("matrixDataToMatrix",function(h){for(var v=h.getCols(),x=h.getRows(),j=h.getPackedDataList(),W=[],X=0;X<x;X++)W.push(Array(v));for(X=0;X<x;X++)for(var z=0;z<v;z++){var q=h.getLayout()===1?X*v+z:z*x+X;W[X][z]=j[q]}return W}),Tt("VERSION","0.4.1633559619")}).call(Ri);const Fi={};(function(){var i;function t(e){var u=0;return function(){return u<e.length?{done:!1,value:e[u++]}:{done:!0}}}var n=typeof Object.defineProperties=="function"?Object.defineProperty:function(e,u,l){return e==Array.prototype||e==Object.prototype||(e[u]=l.value),e};function p(e){e=[typeof globalThis=="object"&&globalThis,e,typeof window=="object"&&window,typeof self=="object"&&self,typeof global=="object"&&global];for(var u=0;u<e.length;++u){var l=e[u];if(l&&l.Math==Math)return l}throw Error("Cannot find global object")}var y=p(this);function R(e,u){if(u)e:{var l=y;e=e.split(".");for(var m=0;m<e.length-1;m++){var F=e[m];if(!(F in l))break e;l=l[F]}e=e[e.length-1],m=l[e],u=u(m),u!=m&&u!=null&&n(l,e,{configurable:!0,writable:!0,value:u})}}R("Symbol",function(e){function u(C){if(this instanceof u)throw new TypeError("Symbol is not a constructor");return new l(m+(C||"")+"_"+F++,C)}function l(C,M){this.g=C,n(this,"description",{configurable:!0,writable:!0,value:M})}if(e)return e;l.prototype.toString=function(){return this.g};var m="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",F=0;return u}),R("Symbol.iterator",function(e){if(e)return e;e=Symbol("Symbol.iterator");for(var u="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),l=0;l<u.length;l++){var m=y[u[l]];typeof m=="function"&&typeof m.prototype[e]!="function"&&n(m.prototype,e,{configurable:!0,writable:!0,value:function(){return k(t(this))}})}return e});function k(e){return e={next:e},e[Symbol.iterator]=function(){return this},e}function O(e){var u=typeof Symbol<"u"&&Symbol.iterator&&e[Symbol.iterator];return u?u.call(e):{next:t(e)}}function L(e){if(!(e instanceof Array)){e=O(e);for(var u,l=[];!(u=e.next()).done;)l.push(u.value);e=l}return e}var te=typeof Object.create=="function"?Object.create:function(e){function u(){}return u.prototype=e,new u},ue;if(typeof Object.setPrototypeOf=="function")ue=Object.setPrototypeOf;else{var pe;e:{var Oe={a:!0},Me={};try{Me.__proto__=Oe,pe=Me.a;break e}catch{}pe=!1}ue=pe?function(e,u){if(e.__proto__=u,e.__proto__!==u)throw new TypeError(e+" is not extensible");return e}:null}var ce=ue;function he(e,u){if(e.prototype=te(u.prototype),e.prototype.constructor=e,ce)ce(e,u);else for(var l in u)if(l!="prototype")if(Object.defineProperties){var m=Object.getOwnPropertyDescriptor(u,l);m&&Object.defineProperty(e,l,m)}else e[l]=u[l];e.ka=u.prototype}function Ge(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function Ve(e){if(e.l)throw new TypeError("Generator is already running");e.l=!0}Ge.prototype.o=function(e){this.h=e};function ct(e,u){e.j={V:u,X:!0},e.g=e.m||e.s}Ge.prototype.return=function(e){this.j={return:e},this.g=this.s};function J(e,u,l){return e.g=l,{value:u}}function Jt(e){this.g=new Ge,this.h=e}function mr(e,u){Ve(e.g);var l=e.g.i;return l?At(e,"return"in l?l.return:function(m){return{value:m,done:!0}},u,e.g.return):(e.g.return(u),Xe(e))}function At(e,u,l,m){try{var F=u.call(e.g.i,l);if(!(F instanceof Object))throw new TypeError("Iterator result "+F+" is not an object");if(!F.done)return e.g.l=!1,F;var C=F.value}catch(M){return e.g.i=null,ct(e.g,M),Xe(e)}return e.g.i=null,m.call(e.g,C),Xe(e)}function Xe(e){for(;e.g.g;)try{var u=e.h(e.g);if(u)return e.g.l=!1,{value:u.value,done:!1}}catch(l){e.g.h=void 0,ct(e.g,l)}if(e.g.l=!1,e.g.j){if(u=e.g.j,e.g.j=null,u.X)throw u.V;return{value:u.return,done:!0}}return{value:void 0,done:!0}}function Mr(e){this.next=function(u){return Ve(e.g),e.g.i?u=At(e,e.g.i.next,u,e.g.o):(e.g.o(u),u=Xe(e)),u},this.throw=function(u){return Ve(e.g),e.g.i?u=At(e,e.g.i.throw,u,e.g.o):(ct(e.g,u),u=Xe(e)),u},this.return=function(u){return mr(e,u)},this[Symbol.iterator]=function(){return this}}function at(e){function u(m){return e.next(m)}function l(m){return e.throw(m)}return new Promise(function(m,F){function C(M){M.done?m(M.value):Promise.resolve(M.value).then(u,l).then(C,F)}C(e.next())})}function me(e){return at(new Mr(new Jt(e)))}R("Promise",function(e){function u(M){this.h=0,this.i=void 0,this.g=[],this.o=!1;var D=this.j();try{M(D.resolve,D.reject)}catch(V){D.reject(V)}}function l(){this.g=null}function m(M){return M instanceof u?M:new u(function(D){D(M)})}if(e)return e;l.prototype.h=function(M){if(this.g==null){this.g=[];var D=this;this.i(function(){D.l()})}this.g.push(M)};var F=y.setTimeout;l.prototype.i=function(M){F(M,0)},l.prototype.l=function(){for(;this.g&&this.g.length;){var M=this.g;this.g=[];for(var D=0;D<M.length;++D){var V=M[D];M[D]=null;try{V()}catch(K){this.j(K)}}}this.g=null},l.prototype.j=function(M){this.i(function(){throw M})},u.prototype.j=function(){function M(K){return function(Q){V||(V=!0,K.call(D,Q))}}var D=this,V=!1;return{resolve:M(this.D),reject:M(this.l)}},u.prototype.D=function(M){if(M===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(M instanceof u)this.G(M);else{e:switch(typeof M){case"object":var D=M!=null;break e;case"function":D=!0;break e;default:D=!1}D?this.A(M):this.m(M)}},u.prototype.A=function(M){var D=void 0;try{D=M.then}catch(V){this.l(V);return}typeof D=="function"?this.H(D,M):this.m(M)},u.prototype.l=function(M){this.s(2,M)},u.prototype.m=function(M){this.s(1,M)},u.prototype.s=function(M,D){if(this.h!=0)throw Error("Cannot settle("+M+", "+D+"): Promise already settled in state"+this.h);this.h=M,this.i=D,this.h===2&&this.F(),this.B()},u.prototype.F=function(){var M=this;F(function(){if(M.C()){var D=y.console;typeof D<"u"&&D.error(M.i)}},1)},u.prototype.C=function(){if(this.o)return!1;var M=y.CustomEvent,D=y.Event,V=y.dispatchEvent;return typeof V>"u"?!0:(typeof M=="function"?M=new M("unhandledrejection",{cancelable:!0}):typeof D=="function"?M=new D("unhandledrejection",{cancelable:!0}):(M=y.document.createEvent("CustomEvent"),M.initCustomEvent("unhandledrejection",!1,!0,M)),M.promise=this,M.reason=this.i,V(M))},u.prototype.B=function(){if(this.g!=null){for(var M=0;M<this.g.length;++M)C.h(this.g[M]);this.g=null}};var C=new l;return u.prototype.G=function(M){var D=this.j();M.K(D.resolve,D.reject)},u.prototype.H=function(M,D){var V=this.j();try{M.call(D,V.resolve,V.reject)}catch(K){V.reject(K)}},u.prototype.then=function(M,D){function V(fe,de){return typeof fe=="function"?function(we){try{K(fe(we))}catch(be){Q(be)}}:de}var K,Q,se=new u(function(fe,de){K=fe,Q=de});return this.K(V(M,K),V(D,Q)),se},u.prototype.catch=function(M){return this.then(void 0,M)},u.prototype.K=function(M,D){function V(){switch(K.h){case 1:M(K.i);break;case 2:D(K.i);break;default:throw Error("Unexpected state: "+K.h)}}var K=this;this.g==null?C.h(V):this.g.push(V),this.o=!0},u.resolve=m,u.reject=function(M){return new u(function(D,V){V(M)})},u.race=function(M){return new u(function(D,V){for(var K=O(M),Q=K.next();!Q.done;Q=K.next())m(Q.value).K(D,V)})},u.all=function(M){var D=O(M),V=D.next();return V.done?m([]):new u(function(K,Q){function se(we){return function(be){fe[we]=be,de--,de==0&&K(fe)}}var fe=[],de=0;do fe.push(void 0),de++,m(V.value).K(se(fe.length-1),Q),V=D.next();while(!V.done)})},u});function Wr(e,u){e instanceof String&&(e+="");var l=0,m=!1,F={next:function(){if(!m&&l<e.length){var C=l++;return{value:u(C,e[C]),done:!1}}return m=!0,{done:!0,value:void 0}}};return F[Symbol.iterator]=function(){return F},F}var Br=typeof Object.assign=="function"?Object.assign:function(e,u){for(var l=1;l<arguments.length;l++){var m=arguments[l];if(m)for(var F in m)Object.prototype.hasOwnProperty.call(m,F)&&(e[F]=m[F])}return e};R("Object.assign",function(e){return e||Br}),R("Object.is",function(e){return e||function(u,l){return u===l?u!==0||1/u===1/l:u!==u&&l!==l}}),R("Array.prototype.includes",function(e){return e||function(u,l){var m=this;m instanceof String&&(m=String(m));var F=m.length;for(l=l||0,0>l&&(l=Math.max(l+F,0));l<F;l++){var C=m[l];if(C===u||Object.is(C,u))return!0}return!1}}),R("String.prototype.includes",function(e){return e||function(u,l){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(u instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(u,l||0)!==-1}}),R("Array.prototype.keys",function(e){return e||function(){return Wr(this,function(u){return u})}});var Tt=this||self;function je(e,u){e=e.split(".");var l=Tt;e[0]in l||typeof l.execScript>"u"||l.execScript("var "+e[0]);for(var m;e.length&&(m=e.shift());)e.length||u===void 0?l[m]&&l[m]!==Object.prototype[m]?l=l[m]:l=l[m]={}:l[m]=u}function Ot(e){throw e}function tr(e,u){Ot(Error("Invalid wire type: "+e+" (at position "+u+")"))}function yr(){Ot(Error("Failed to read varint, encoding is invalid."))}function Or(e,u){return u=String.fromCharCode.apply(null,u),e==null?u:e+u}var wr,Pr=typeof TextDecoder<"u",rr,Dt=typeof TextEncoder<"u";function xr(e){if(Dt)e=(rr||(rr=new TextEncoder)).encode(e);else{var u=void 0;u=u===void 0?!1:u;for(var l=0,m=new Uint8Array(3*e.length),F=0;F<e.length;F++){var C=e.charCodeAt(F);if(128>C)m[l++]=C;else{if(2048>C)m[l++]=C>>6|192;else{if(55296<=C&&57343>=C){if(56319>=C&&F<e.length){var M=e.charCodeAt(++F);if(56320<=M&&57343>=M){C=1024*(C-55296)+M-56320+65536,m[l++]=C>>18|240,m[l++]=C>>12&63|128,m[l++]=C>>6&63|128,m[l++]=C&63|128;continue}else F--}if(u)throw Error("Found an unpaired surrogate");C=65533}m[l++]=C>>12|224,m[l++]=C>>6&63|128}m[l++]=C&63|128}}e=m.subarray(0,l)}return e}var Ir={},vr=null;function Ct(e){var u;u===void 0&&(u=0),ut(),u=Ir[u];for(var l=Array(Math.floor(e.length/3)),m=u[64]||"",F=0,C=0;F<e.length-2;F+=3){var M=e[F],D=e[F+1],V=e[F+2],K=u[M>>2];M=u[(M&3)<<4|D>>4],D=u[(D&15)<<2|V>>6],V=u[V&63],l[C++]=K+M+D+V}switch(K=0,V=m,e.length-F){case 2:K=e[F+1],V=u[(K&15)<<2]||m;case 1:e=e[F],l[C]=u[e>>2]+u[(e&3)<<4|K>>4]+V+m}return l.join("")}function _r(e){var u=e.length,l=3*u/4;l%3?l=Math.floor(l):"=.".indexOf(e[u-1])!=-1&&(l="=.".indexOf(e[u-2])!=-1?l-2:l-1);var m=new Uint8Array(l),F=0;return lr(e,function(C){m[F++]=C}),m.subarray(0,F)}function lr(e,u){function l(V){for(;m<e.length;){var K=e.charAt(m++),Q=vr[K];if(Q!=null)return Q;if(!/^[\s\xa0]*$/.test(K))throw Error("Unknown base64 encoding at char: "+K)}return V}ut();for(var m=0;;){var F=l(-1),C=l(0),M=l(64),D=l(64);if(D===64&&F===-1)break;u(F<<2|C>>4),M!=64&&(u(C<<4&240|M>>2),D!=64&&u(M<<6&192|D))}}function ut(){if(!vr){vr={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=["+/=","+/","-_=","-_.","-_"],l=0;5>l;l++){var m=e.concat(u[l].split(""));Ir[l]=m;for(var F=0;F<m.length;F++){var C=m[F];vr[C]===void 0&&(vr[C]=F)}}}}var St=typeof Uint8Array=="function",Ht;function xt(e){if(this.g=e,e!==null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}var _t=typeof Uint8Array.prototype.slice=="function";function Zt(e,u,l){return u===l?Ht||(Ht=new Uint8Array(0)):_t?e.slice(u,l):new Uint8Array(e.subarray(u,l))}var Gt=0,qe=0;function mt(e){if(e.constructor===Uint8Array)return e;if(e.constructor===ArrayBuffer)return new Uint8Array(e);if(e.constructor===Array)return new Uint8Array(e);if(e.constructor===String)return _r(e);if(e.constructor===xt){if(e.g==null)var u=Ht||(Ht=new Uint8Array(0));else{u=Uint8Array;var l=e.g;l=l==null||St&&l!=null&&l instanceof Uint8Array?l:typeof l=="string"?_r(l):null,e=e.g=l,u=new u(e)}return u}if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}function Rt(e,u){u=u===void 0?{}:u,u=u.v===void 0?!1:u.v,this.h=null,this.g=this.i=this.l=0,this.j=!1,this.v=u,e&&We(this,e)}function We(e,u){e.h=mt(u),e.l=0,e.i=e.h.length,e.g=e.l}Rt.prototype.reset=function(){this.g=this.l};function Ft(e){for(var u=128,l=0,m=0,F=0;4>F&&128<=u;F++)u=e.h[e.g++],l|=(u&127)<<7*F;if(128<=u&&(u=e.h[e.g++],l|=(u&127)<<28,m|=(u&127)>>4),128<=u)for(F=0;5>F&&128<=u;F++)u=e.h[e.g++],m|=(u&127)<<7*F+3;if(128>u)return e=l>>>0,u=m>>>0,(m=u&2147483648)&&(e=~e+1>>>0,u=~u>>>0,e==0&&(u=u+1>>>0)),e=4294967296*u+(e>>>0),m?-e:e;e.j=!0,yr()}function et(e){e.g>e.i&&(e.j=!0,Ot(Error("Tried to read past the end of the data "+e.g+" > "+e.i)))}function pt(e){var u=e.h,l=u[e.g],m=l&127;return 128>l?(e.g+=1,et(e),m):(l=u[e.g+1],m|=(l&127)<<7,128>l?(e.g+=2,et(e),m):(l=u[e.g+2],m|=(l&127)<<14,128>l?(e.g+=3,et(e),m):(l=u[e.g+3],m|=(l&127)<<21,128>l?(e.g+=4,et(e),m):(l=u[e.g+4],m|=(l&15)<<28,128>l?(e.g+=5,et(e),m>>>0):(e.g+=5,128<=u[e.g++]&&128<=u[e.g++]&&128<=u[e.g++]&&128<=u[e.g++]&&128<=u[e.g++]?(e.j=!0,yr(),m):(et(e),m))))))}function It(e){var u=e.h[e.g],l=e.h[e.g+1],m=e.h[e.g+2],F=e.h[e.g+3];return e.g+=4,et(e),(u<<0|l<<8|m<<16|F<<24)>>>0}Rt.prototype.m=function(){var e=It(this),u=2*(e>>31)+1,l=e>>>23&255;return e&=8388607,l==255?e?NaN:1/0*u:l==0?u*Math.pow(2,-149)*e:u*Math.pow(2,l-150)*(e+Math.pow(2,23))};var Vt=[];function wt(){this.g=new Uint8Array(64),this.h=0}function Ye(e,u){if(!(e.h+1<e.g.length)){var l=e.g;e.g=new Uint8Array(Math.ceil(1+2*e.g.length)),e.g.set(l)}e.g[e.h++]=u}wt.prototype.length=function(){return this.h},wt.prototype.end=function(){var e=this.g,u=this.h;return this.h=0,Zt(e,0,u)};function Lt(e,u){for(;127<u;)Ye(e,u&127|128),u>>>=7;Ye(e,u)}function zt(e){var u={},l=u.O===void 0?!1:u.O;this.m={v:u.v===void 0?!1:u.v},this.O=l,u=this.m,Vt.length?(l=Vt.pop(),u&&(l.v=u.v),e&&We(l,e),e=l):e=new Rt(e,u),this.g=e,this.l=this.g.g,this.h=this.i=-1,this.j=!1}zt.prototype.reset=function(){this.g.reset(),this.h=this.i=-1};function Et(e){var u=e.g;if((u=u.g==u.i)||(u=e.j)||(u=e.g,u=u.j||0>u.g||u.g>u.i),u)return!1;e.l=e.g.g;var l=pt(e.g);return u=l>>>3,l&=7,0<=l&&5>=l?(e.i=u,e.h=l,!0):(e.j=!0,tr(l,e.l),!1)}function fr(e){switch(e.h){case 0:if(e.h!=0)fr(e);else e:{e=e.g;for(var u=e.g,l=0;10>l;l++){if((e.h[u]&128)===0){e.g=u+1,et(e);break e}u++}e.j=!0,yr()}break;case 1:e=e.g,e.g+=8,et(e);break;case 2:e.h!=2?fr(e):(u=pt(e.g),e=e.g,e.g+=u,et(e));break;case 5:e=e.g,e.g+=4,et(e);break;case 3:u=e.i;do{if(!Et(e)){e.j=!0,Ot(Error("Unmatched start-group tag: stream EOF"));break}if(e.h==4){e.i!=u&&(e.j=!0,Ot(Error("Unmatched end-group tag")));break}fr(e)}while(!0);break;default:e.j=!0,tr(e.h,e.l)}}function qt(e,u,l){var m=e.g.i,F=pt(e.g),C=e.g.g+F;if(e.g.i=C,l(u,e),l=C-e.g.g,l!==0)throw Error("Message parsing ended unexpectedly. Expected to read "+(F+" bytes, instead read "+(F-l)+" bytes, either the data ended unexpectedly or the message misreported its own length"));return e.g.g=C,e.g.i=m,u}var sr=[];function hr(){this.h=[],this.i=0,this.g=new wt}function yt(e,u){u.length!==0&&(e.h.push(u),e.i+=u.length)}function kt(e,u,l){Lt(e.g,8*u+2),Lt(e.g,l.length),yt(e,e.g.end()),yt(e,l)}var vt=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol(void 0):void 0;function rt(e){return Object.isFrozen(e)||(vt?e[vt]|=1:e.g!==void 0?e.g|=1:Object.defineProperties(e,{g:{value:1,configurable:!0,writable:!0,enumerable:!1}})),e}function Ut(e){return e!==null&&typeof e=="object"&&e.constructor===Object}function tt(e){switch(typeof e){case"number":return isFinite(e)?e:String(e);case"object":if(St&&e!=null&&e instanceof Uint8Array)return Ct(e);if(e instanceof xt){if(e.g==null)e="";else{var u=e.g;u=u==null||typeof u=="string"?u:St&&u instanceof Uint8Array?Ct(u):null,e=e.g=u}return e}}return e}function $e(e,u){if(e!=null)return Array.isArray(e)||Ut(e)?nr(e,u):u(e)}function nr(e,u){if(Array.isArray(e)){for(var l=Array(e.length),m=0;m<e.length;m++)l[m]=$e(e[m],u);if(u=Array.isArray(e)){var F;vt?F=e[vt]:F=e.g,u=(F??0)&1}return u&&rt(l),l}F={};for(l in e)F[l]=$e(e[l],u);return F}function lt(e){return e=tt(e),Array.isArray(e)?nr(e,lt):e}var Ce;function Se(e,u,l){var m=Ce;Ce=null,e||(e=m),m=this.constructor.ha,e||(e=m?[m]:[]),this.i=(m?0:-1)-(this.constructor.fa||0),this.l=this.g=null,this.u=e;e:{if(m=this.u.length,e=m-1,m&&(m=this.u[e],Ut(m))){this.j=e-this.i,this.h=m;break e}u!==void 0&&-1<u?(this.j=Math.max(u,e+1-this.i),this.h=null):this.j=Number.MAX_VALUE}if(l)for(u=0;u<l.length;u++)e=l[u],e<this.j?(e+=this.i,(m=this.u[e])?Array.isArray(m)&&rt(m):this.u[e]=nt):(ee(this),(m=this.h[e])?Array.isArray(m)&&rt(m):this.h[e]=nt)}var nt=Object.freeze(rt([]));function ee(e){var u=e.j+e.i;e.u[u]||(e.h=e.u[u]={})}function ie(e,u,l){return u===-1?null:l!==void 0&&l||u>=e.j?e.h?e.h[u]:void 0:e.u[u+e.i]}function ve(e,u,l){l=l===void 0?!1:l;var m=ie(e,u,l);return m==null&&(m=nt),m===nt&&(m=rt(m.slice()),xe(e,u,m,l)),m}function He(e,u){var l=ve(e,u);if(e.l||(e.l={}),!e.l[u]){for(var m=0;m<l.length;m++)l[m]=+l[m];e.l[u]=!0}return l}function Ie(e,u,l){return e=ie(e,u),e=e==null?e:+e,e??(l===void 0?0:l)}function xe(e,u,l,m){m!==void 0&&m||u>=e.j?(ee(e),e.h[u]=l):e.u[u+e.i]=l}function Ke(e,u,l,m){l!==m?xe(e,u,l):xe(e,u,void 0,!1)}function ht(e,u,l){if(l===-1)return null;e.g||(e.g={});var m=e.g[l];if(m)return m;var F=ie(e,l,!1);return F==null?m:(u=new u(F),e.g[l]=u)}function bt(e,u,l){e.g||(e.g={});var m=e.g[l];if(!m){var F=ve(e,l,!1);m=[];for(var C=0;C<F.length;C++)m[C]=new u(F[C]);e.g[l]=m}return m}function Qe(e,u,l,m,F){var C=bt(e,m,u);l=l||new m,e=ve(e,u),F!=null?(C.splice(F,0,l),e.splice(F,0,l.u)):(C.push(l),e.push(l.u))}Se.prototype.toJSON=function(){return nr(this.u,lt)},Se.prototype.toString=function(){return this.u.toString()};function $t(e,u){return e=ie(e,u),e??0}function Er(e,u){return e=ie(e,u),e??""}function ar(e,u){if(e=e.m){yt(u,u.g.end());for(var l=0;l<e.length;l++)yt(u,e[l])}}var Yt=Symbol();function ir(e,u,l){return e[Yt]||(e[Yt]=function(m,F){return u(m,F,l)})}function ur(e){var u=e[Yt];if(!u){var l=e[Kt]||(e[Kt]=e());u=function(m,F){return Mt(m,F,l)},e[Yt]=u}return u}function Pt(e){var u=e.da;if(u)return ur(u);if(u=e.ia){var l=e.Y;return delete e.Y,ir(e.W.g,u,l)}}function Xt(e){var u=Pt(e),l=e.W,m=e.ea;return u?function(F,C){return m(F,C,l,u)}:function(F,C){return m(F,C,l)}}function zr(e){var u=e[0];switch(e.length){case 2:var l=e[1];return function(de,we,be){return u(de,we,be,l)};case 3:var m=e[1],F=ur(e[2]);return function(de,we,be){return u(de,we,be,m,F)};case 4:var C=e[1],M=e[3],D=ur(e[2]);return function(de,we,be){return u(de,we,be,C,D,M)};case 5:var V=e[1],K=ir(V,e[3],e[4]);return function(de,we,be){return u(de,we,be,V,K)};case 6:var Q=e[1],se=e[5],fe=ir(Q,e[3],e[4]);return function(de,we,be){return u(de,we,be,Q,fe,se)};default:throw Error("Unsupported number of parameters, expected [2-6], got "+e.length)}}var Kt=Symbol();function Mt(e,u,l){for(;Et(u)&&u.h!=4;){var m=u.i,F=l[m];if(F)Array.isArray(F)&&(F=l[m]=zr(F));else{var C=l[0];C&&(C=C[m])&&(F=l[m]=Xt(C))}F&&F(u,e,m)||(F=u,m=e,C=F.l,fr(F),F.O||(F=Zt(F.g.h,C,F.g.g),(C=m.m)?C.push(F):m.m=[F]))}return e}function dr(e,u){var l=new hr;if(u(e,l),e=l.i+l.g.length(),e===0)l=new Uint8Array(0);else{e=new Uint8Array(e);for(var m=l.h,F=m.length,C=u=0;C<F;C++){var M=m[C];M.length!==0&&(e.set(M,u),u+=M.length)}m=l.g,F=m.h,F!==0&&(e.set(m.g.subarray(0,F),u),m.h=0),l.h=[e],l=e}return l}function Ar(e,u,l){if(sr.length){var m=sr.pop();e&&(We(m.g,e),m.i=-1,m.h=-1),e=m}else e=new zt(e);try{var F=new u;return Mt(F,e,l[Kt]||(l[Kt]=l()))}finally{u=e.g,u.h=null,u.l=0,u.i=0,u.g=0,u.j=!1,u.v=!1,e.i=-1,e.h=-1,e.j=!1,100>sr.length&&sr.push(e)}}function Wt(e,u,l){if(u=ie(u,l),u!=null){Lt(e.g,8*l+5),e=e.g;var m=u;m=(l=0>m?1:0)?-m:m,m===0?0<1/m?Gt=qe=0:(qe=0,Gt=2147483648):isNaN(m)?(qe=0,Gt=2147483647):34028234663852886e22<m?(qe=0,Gt=(l<<31|2139095040)>>>0):11754943508222875e-54>m?(m=Math.round(m/Math.pow(2,-149)),qe=0,Gt=(l<<31|m)>>>0):(u=Math.floor(Math.log(m)/Math.LN2),m*=Math.pow(2,-u),m=Math.round(8388608*m),16777216<=m&&++u,qe=0,Gt=(l<<31|u+127<<23|m&8388607)>>>0),l=Gt,Ye(e,l>>>0&255),Ye(e,l>>>8&255),Ye(e,l>>>16&255),Ye(e,l>>>24&255)}}function jr(e,u,l){if(e.h!==1)return!1;var m=e.g;e=It(m);var F=It(m);m=2*(F>>31)+1;var C=F>>>20&2047;return e=4294967296*(F&1048575)+e,Ke(u,l,C==2047?e?NaN:1/0*m:C==0?m*Math.pow(2,-1074)*e:m*Math.pow(2,C-1075)*(e+4503599627370496),0),!0}function Qt(e,u,l){return e.h!==5?!1:(xe(u,l,e.g.m()),!0)}function pr(e,u,l){if(e.h!==5&&e.h!==2)return!1;if(u=ve(u,l),e.h==2){l=Rt.prototype.m;var m=pt(e.g);for(m=e.g.g+m;e.g.g<m;)u.push(l.call(e.g))}else u.push(e.g.m());return!0}function Tr(e,u,l){return e.h!==5?!1:(e=e.g.m(),Ke(u,l,e,0),!0)}function Nr(e,u,l){return e.h!==0?!1:(xe(u,l,Ft(e.g)),!0)}function er(e,u,l){return e.h!==0?!1:(xe(u,l,pt(e.g)),!0)}function Sr(e,u,l){return e.h!==0?!1:(e=pt(e.g),Ke(u,l,e,0),!0)}function $r(e,u,l){return e.h!==0?!1:(e=!!pt(e.g),Ke(u,l,e,!1),!0)}function Yr(e,u,l){if(e.h!==2)return!1;var m=pt(e.g);e=e.g;var F=e.g;e.g+=m,et(e),e=e.h;var C;if(Pr)(C=wr)||(C=wr=new TextDecoder("utf-8",{fatal:!1})),C=C.decode(e.subarray(F,F+m));else{m=F+m;for(var M=[],D=null,V,K,Q;F<m;)V=e[F++],128>V?M.push(V):224>V?F>=m?M.push(65533):(K=e[F++],194>V||(K&192)!==128?(F--,M.push(65533)):M.push((V&31)<<6|K&63)):240>V?F>=m-1?M.push(65533):(K=e[F++],(K&192)!==128||V===224&&160>K||V===237&&160<=K||((C=e[F++])&192)!==128?(F--,M.push(65533)):M.push((V&15)<<12|(K&63)<<6|C&63)):244>=V?F>=m-2?M.push(65533):(K=e[F++],(K&192)!==128||(V<<28)+(K-144)>>30!==0||((C=e[F++])&192)!==128||((Q=e[F++])&192)!==128?(F--,M.push(65533)):(V=(V&7)<<18|(K&63)<<12|(C&63)<<6|Q&63,V-=65536,M.push((V>>10&1023)+55296,(V&1023)+56320))):M.push(65533),8192<=M.length&&(D=Or(D,M),M.length=0);C=Or(D,M)}return xe(u,l,C),!0}function Rr(e,u,l,m,F){return e.h!==2?!1:(e=qt(e,new m,F),u.g||(u.g={}),m=e&&e.u,u.g[l]=e,xe(u,l,m,!1),!0)}function kr(e,u,l,m,F){return e.h!==2?!1:(e=qt(e,new m,F),Qe(u,l,e,m,void 0),!0)}function g(e,u,l){return e.h!==0?!1:(xe(u,l,Ft(e.g)),!0)}function E(e){Se.call(this,e)}he(E,Se);function A(){return{1:er,2:Qt,3:Yr,4:Yr}}function N(e,u){var l=ie(e,1);if(l!=null&&l!=null){Lt(u.g,8);var m=u.g;if(0<=l)Lt(m,l);else{for(var F=0;9>F;F++)Ye(m,l&127|128),l>>=7;Ye(m,1)}}Wt(u,e,2),m=ie(e,3),m!=null&&kt(u,3,xr(m)),m=ie(e,4),m!=null&&kt(u,4,xr(m)),ar(e,u)}function Y(e){Se.call(this,e,-1,$)}he(Y,Se),Y.prototype.addClassification=function(e,u){return Qe(this,1,e,E,u),this};function oe(){return{1:[kr,E,A]}}var $=[1];function ne(e){Se.call(this,e)}he(ne,Se);function ge(){return{1:Qt,2:Qt,3:Qt,4:Qt,5:Qt}}function Ae(e,u){Wt(u,e,1),Wt(u,e,2),Wt(u,e,3),Wt(u,e,4),Wt(u,e,5),ar(e,u)}function Ne(e){Se.call(this,e,-1,Ze)}he(Ne,Se);function Le(){return{1:[kr,ne,ge]}}var Ze=[1];function Ue(e){Se.call(this,e)}he(Ue,Se);function Fe(){return{1:Qt,2:Qt,3:Qt,4:Qt,5:Qt,6:Nr}}function Be(e,u){Wt(u,e,1),Wt(u,e,2),Wt(u,e,3),Wt(u,e,4),Wt(u,e,5);var l=ie(e,6);if(l!=null&&l!=null){Lt(u.g,48);var m=u.g,F=l;l=0>F,F=Math.abs(F);var C=F>>>0;for(F=Math.floor((F-C)/4294967296),F>>>=0,l&&(F=~F>>>0,C=(~C>>>0)+1,4294967295<C&&(C=0,F++,4294967295<F&&(F=0))),Gt=C,qe=F,l=Gt,C=qe;0<C||127<l;)Ye(m,l&127|128),l=(l>>>7|C<<25)>>>0,C>>>=7;Ye(m,l)}ar(e,u)}function Je(e){Se.call(this,e,-1,jt)}he(Je,Se);function st(){return{1:g,2:g,3:pr,4:[Rr,ft,gt],5:er,6:er,7:pr,8:pr,9:pr}}function ft(e){Se.call(this,e)}he(ft,Se);function gt(){return{1:Qt,2:Qt,3:Qt}}var jt=[3,7,8,9];function h(e){Se.call(this,e)}he(h,Se);function v(){return{1:Tr,2:Tr,3:Tr}}function x(e){Se.call(this,e)}he(x,Se);function j(){return{1:Tr,2:Tr,3:Tr}}function W(e){Se.call(this,e)}he(W,Se);function X(){return{1:Sr,2:[Rr,x,j],3:[Rr,h,v],4:$r}}function z(e){Se.call(this,e,-1,ae)}he(z,Se);function q(){return{1:Sr,2:[kr,W,X],3:Tr,4:pr,5:pr,6:pr}}var ae=[2,4,5,6];function s(e){Se.call(this,e,-1,T)}he(s,Se);function _(){return{1:Sr,2:[kr,z,q],3:[Rr,Je,st],4:jr,5:pr,6:pr}}var T=[2,5,6];function P(e,u,l){if(l=e.createShader(l===0?e.VERTEX_SHADER:e.FRAGMENT_SHADER),e.shaderSource(l,u),e.compileShader(l),!e.getShaderParameter(l,e.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
|
|
88
|
-
|
|
89
|
-
`+e.getShaderInfoLog(l));return l}function U(e){return bt(e,E,1).map(function(u){return{index:$t(u,1),$:Ie(u,2),label:ie(u,3)!=null?Er(u,3):void 0,displayName:ie(u,4)!=null?Er(u,4):void 0}})}function H(e){return{x:Ie(e,1),y:Ie(e,2),z:Ie(e,3),visibility:ie(e,4)!=null?Ie(e,4):void 0}}function G(e,u){this.h=e,this.g=u,this.l=0}function re(e,u,l){return Z(e,u),typeof e.g.canvas.transferToImageBitmap=="function"?Promise.resolve(e.g.canvas.transferToImageBitmap()):l?Promise.resolve(e.g.canvas):typeof createImageBitmap=="function"?createImageBitmap(e.g.canvas):(e.i===void 0&&(e.i=document.createElement("canvas")),new Promise(function(m){e.i.height=e.g.canvas.height,e.i.width=e.g.canvas.width,e.i.getContext("2d",{}).drawImage(e.g.canvas,0,0,e.g.canvas.width,e.g.canvas.height),m(e.i)}))}function Z(e,u){var l=e.g;if(e.m===void 0){var m=P(l,`
|
|
90
|
-
attribute vec2 aVertex;
|
|
91
|
-
attribute vec2 aTex;
|
|
92
|
-
varying vec2 vTex;
|
|
93
|
-
void main(void) {
|
|
94
|
-
gl_Position = vec4(aVertex, 0.0, 1.0);
|
|
95
|
-
vTex = aTex;
|
|
96
|
-
}`,0),F=P(l,`
|
|
97
|
-
precision mediump float;
|
|
98
|
-
varying vec2 vTex;
|
|
99
|
-
uniform sampler2D sampler0;
|
|
100
|
-
void main(){
|
|
101
|
-
gl_FragColor = texture2D(sampler0, vTex);
|
|
102
|
-
}`,1),C=l.createProgram();if(l.attachShader(C,m),l.attachShader(C,F),l.linkProgram(C),!l.getProgramParameter(C,l.LINK_STATUS))throw Error(`Could not compile WebGL program.
|
|
103
|
-
|
|
104
|
-
`+l.getProgramInfoLog(C));m=e.m=C,l.useProgram(m),F=l.getUniformLocation(m,"sampler0"),e.j={J:l.getAttribLocation(m,"aVertex"),I:l.getAttribLocation(m,"aTex"),ja:F},e.s=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,e.s),l.enableVertexAttribArray(e.j.J),l.vertexAttribPointer(e.j.J,2,l.FLOAT,!1,0,0),l.bufferData(l.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),l.STATIC_DRAW),l.bindBuffer(l.ARRAY_BUFFER,null),e.o=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,e.o),l.enableVertexAttribArray(e.j.I),l.vertexAttribPointer(e.j.I,2,l.FLOAT,!1,0,0),l.bufferData(l.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),l.STATIC_DRAW),l.bindBuffer(l.ARRAY_BUFFER,null),l.uniform1i(F,0)}m=e.j,l.useProgram(e.m),l.canvas.width=u.width,l.canvas.height=u.height,l.viewport(0,0,u.width,u.height),l.activeTexture(l.TEXTURE0),e.h.bindTexture2d(u.glName),l.enableVertexAttribArray(m.J),l.bindBuffer(l.ARRAY_BUFFER,e.s),l.vertexAttribPointer(m.J,2,l.FLOAT,!1,0,0),l.enableVertexAttribArray(m.I),l.bindBuffer(l.ARRAY_BUFFER,e.o),l.vertexAttribPointer(m.I,2,l.FLOAT,!1,0,0),l.bindFramebuffer(l.DRAW_FRAMEBUFFER?l.DRAW_FRAMEBUFFER:l.FRAMEBUFFER,null),l.clearColor(0,0,0,0),l.clear(l.COLOR_BUFFER_BIT),l.colorMask(!0,!0,!0,!0),l.drawArrays(l.TRIANGLE_FAN,0,4),l.disableVertexAttribArray(m.J),l.disableVertexAttribArray(m.I),l.bindBuffer(l.ARRAY_BUFFER,null),e.h.bindTexture2d(0)}function ye(e){this.g=e}var _e=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(e,u){return u+e}function Te(e,u){window[e]=u}function le(e){var u=document.createElement("script");return u.setAttribute("src",e),u.setAttribute("crossorigin","anonymous"),new Promise(function(l){u.addEventListener("load",function(){l()},!1),u.addEventListener("error",function(){l()},!1),document.body.appendChild(u)})}function Ee(){return me(function(e){switch(e.g){case 1:return e.m=2,J(e,WebAssembly.instantiate(_e),4);case 4:e.g=3,e.m=0;break;case 2:return e.m=0,e.j=null,e.return(!1);case 3:return e.return(!0)}})}function Re(e){if(this.g=e,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=e&&e.locateFile||De,typeof window=="object")var u=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")u=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.T=u,e.options){u=O(Object.keys(e.options));for(var l=u.next();!l.done;l=u.next()){l=l.value;var m=e.options[l].default;m!==void 0&&(this.j[l]=typeof m=="function"?m():m)}}}i=Re.prototype,i.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function ke(e){var u,l,m,F,C,M,D,V,K,Q,se;return me(function(fe){switch(fe.g){case 1:return e.S?(u=e.g.files===void 0?[]:typeof e.g.files=="function"?e.g.files(e.j):e.g.files,J(fe,Ee(),2)):fe.return();case 2:if(l=fe.h,typeof window=="object")return Te("createMediapipeSolutionsWasm",{locateFile:e.locateFile}),Te("createMediapipeSolutionsPackedAssets",{locateFile:e.locateFile}),M=u.filter(function(de){return de.data!==void 0}),D=u.filter(function(de){return de.data===void 0}),V=Promise.all(M.map(function(de){var we=w(e,de.url);if(de.path!==void 0){var be=de.path;we=we.then(function(ze){return e.overrideFile(be,ze),Promise.resolve(ze)})}return we})),K=Promise.all(D.map(function(de){return de.simd===void 0||de.simd&&l||!de.simd&&!l?le(e.locateFile(de.url,e.T)):Promise.resolve()})).then(function(){var de,we,be;return me(function(ze){if(ze.g==1)return de=window.createMediapipeSolutionsWasm,we=window.createMediapipeSolutionsPackedAssets,be=e,J(ze,de(we),2);be.h=ze.h,ze.g=0})}),Q=(function(){return me(function(de){return e.g.graph&&e.g.graph.url?de=J(de,w(e,e.g.graph.url),0):(de.g=0,de=void 0),de})})(),J(fe,Promise.all([K,V,Q]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return m=u.filter(function(de){return de.simd===void 0||de.simd&&l||!de.simd&&!l}).map(function(de){return e.locateFile(de.url,e.T)}),importScripts.apply(null,L(m)),F=e,J(fe,createMediapipeSolutionsWasm(Module),6);case 6:F.h=fe.h,e.l=new OffscreenCanvas(1,1),e.h.canvas=e.l,C=e.h.GL.createContext(e.l,{antialias:!1,alpha:!1,ga:typeof WebGL2RenderingContext<"u"?2:1}),e.h.GL.makeContextCurrent(C),fe.g=4;break;case 7:if(e.l=document.createElement("canvas"),se=e.l.getContext("webgl2",{}),!se&&(se=e.l.getContext("webgl",{}),!se))return alert("Failed to create WebGL canvas context when passing video frame."),fe.return();e.F=se,e.h.canvas=e.l,e.h.createContext(e.l,!0,!0,{});case 4:e.i=new e.h.SolutionWasm,e.S=!1,fe.g=0}})}function Pe(e){var u,l,m,F,C,M,D,V;return me(function(K){if(K.g==1){if(e.g.graph&&e.g.graph.url&&e.R===e.g.graph.url)return K.return();if(e.o=!0,!e.g.graph||!e.g.graph.url){K.g=2;return}return e.R=e.g.graph.url,J(K,w(e,e.g.graph.url),3)}for(K.g!=2&&(u=K.h,e.i.loadGraph(u)),l=O(Object.keys(e.C)),m=l.next();!m.done;m=l.next())F=m.value,e.i.overrideFile(F,e.C[F]);if(e.C={},e.g.listeners)for(C=O(e.g.listeners),M=C.next();!M.done;M=C.next())D=M.value,B(e,D);V=e.j,e.j={},e.setOptions(V),K.g=0})}i.reset=function(){var e=this;return me(function(u){e.i&&(e.i.reset(),e.m={},e.s={}),u.g=0})},i.setOptions=function(e,u){var l=this;if(u=u||this.g.options){for(var m=[],F=[],C={},M=O(Object.keys(e)),D=M.next();!D.done;C={L:C.L,M:C.M},D=M.next()){var V=D.value;V in this.j&&this.j[V]===e[V]||(this.j[V]=e[V],D=u[V],D!==void 0&&(D.onChange&&(C.L=D.onChange,C.M=e[V],m.push((function(K){return function(){var Q;return me(function(se){if(se.g==1)return J(se,K.L(K.M),2);Q=se.h,Q===!0&&(l.o=!0),se.g=0})}})(C))),D.graphOptionXref&&(V={valueNumber:D.type===1?e[V]:0,valueBoolean:D.type===0?e[V]:!1,valueString:D.type===2?e[V]:""},D=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),D.graphOptionXref),V),F.push(D))))}(m.length!==0||F.length!==0)&&(this.o=!0,this.B=(this.B===void 0?[]:this.B).concat(F),this.A=(this.A===void 0?[]:this.A).concat(m))}};function a(e){var u,l,m,F,C,M,D;return me(function(V){switch(V.g){case 1:if(!e.o)return V.return();if(!e.A){V.g=2;break}u=O(e.A),l=u.next();case 3:if(l.done){V.g=5;break}return m=l.value,J(V,m(),4);case 4:l=u.next(),V.g=3;break;case 5:e.A=void 0;case 2:if(e.B){for(F=new e.h.GraphOptionChangeRequestList,C=O(e.B),M=C.next();!M.done;M=C.next())D=M.value,F.push_back(D);e.i.changeOptions(F),F.delete(),e.B=void 0}e.o=!1,V.g=0}})}i.initialize=function(){var e=this;return me(function(u){return u.g==1?J(u,ke(e),2):u.g!=3?J(u,Pe(e),3):J(u,a(e),0)})};function w(e,u){var l,m;return me(function(F){return u in e.G?F.return(e.G[u]):(l=e.locateFile(u,""),m=fetch(l).then(function(C){return C.arrayBuffer()}),e.G[u]=m,F.return(m))})}i.overrideFile=function(e,u){this.i?this.i.overrideFile(e,u):this.C[e]=u},i.clearOverriddenFiles=function(){this.C={},this.i&&this.i.clearOverriddenFiles()},i.send=function(e,u){var l=this,m,F,C,M,D,V,K,Q,se;return me(function(fe){switch(fe.g){case 1:return l.g.inputs?(m=1e3*(u??performance.now()),J(fe,l.D,2)):fe.return();case 2:return J(fe,l.initialize(),3);case 3:for(F=new l.h.PacketDataList,C=O(Object.keys(e)),M=C.next();!M.done;M=C.next())if(D=M.value,V=l.g.inputs[D]){e:{var de=e[D];switch(V.type){case"video":var we=l.m[V.stream];if(we||(we=new G(l.h,l.F),l.m[V.stream]=we),we.l===0&&(we.l=we.h.createTexture()),typeof HTMLVideoElement<"u"&&de instanceof HTMLVideoElement)var be=de.videoWidth,ze=de.videoHeight;else typeof HTMLImageElement<"u"&&de instanceof HTMLImageElement?(be=de.naturalWidth,ze=de.naturalHeight):(be=de.width,ze=de.height);ze={glName:we.l,width:be,height:ze},be=we.g,be.canvas.width=ze.width,be.canvas.height=ze.height,be.activeTexture(be.TEXTURE0),we.h.bindTexture2d(we.l),be.texImage2D(be.TEXTURE_2D,0,be.RGBA,be.RGBA,be.UNSIGNED_BYTE,de),we.h.bindTexture2d(0),we=ze;break e;case"detections":for(we=l.m[V.stream],we||(we=new ye(l.h),l.m[V.stream]=we),we.data||(we.data=new we.g.DetectionListData),we.data.reset(de.length),ze=0;ze<de.length;++ze){be=de[ze];var it=we.data,ot=it.setBoundingBox,Bt=ze,br=be.U,Nt=new Ue;if(xe(Nt,1,br.aa),xe(Nt,2,br.ba),xe(Nt,3,br.height),xe(Nt,4,br.width),xe(Nt,5,br.rotation),xe(Nt,6,br.Z),br=dr(Nt,Be),ot.call(it,Bt,br),be.P)for(it=0;it<be.P.length;++it){Nt=be.P[it];var Cr=!!Nt.visibility;ot=we.data,Bt=ot.addNormalizedLandmark,br=ze,Nt=Object.assign(Object.assign({},Nt),{visibility:Cr?Nt.visibility:0}),Cr=new ne,xe(Cr,1,Nt.x),xe(Cr,2,Nt.y),xe(Cr,3,Nt.z),Nt.visibility&&xe(Cr,4,Nt.visibility),Nt=dr(Cr,Ae),Bt.call(ot,br,Nt)}if(be.N)for(it=0;it<be.N.length;++it)ot=we.data,Bt=ot.addClassification,br=ze,Nt=be.N[it],Cr=new E,xe(Cr,2,Nt.$),Nt.index&&xe(Cr,1,Nt.index),Nt.label&&xe(Cr,3,Nt.label),Nt.displayName&&xe(Cr,4,Nt.displayName),Nt=dr(Cr,N),Bt.call(ot,br,Nt)}we=we.data;break e;default:we={}}}switch(K=we,Q=V.stream,V.type){case"video":F.pushTexture2d(Object.assign(Object.assign({},K),{stream:Q,timestamp:m}));break;case"detections":se=K,se.stream=Q,se.timestamp=m,F.pushDetectionList(se);break;default:throw Error("Unknown input config type: '"+V.type+"'")}}return l.i.send(F),J(fe,l.D,4);case 4:F.delete(),fe.g=0}})};function S(e,u,l){var m,F,C,M,D,V,K,Q,se,fe,de,we,be,ze;return me(function(it){switch(it.g){case 1:if(!l)return it.return(u);for(m={},F=0,C=O(Object.keys(l)),M=C.next();!M.done;M=C.next())D=M.value,V=l[D],typeof V!="string"&&V.type==="texture"&&u[V.stream]!==void 0&&++F;1<F&&(e.H=!1),K=O(Object.keys(l)),M=K.next();case 2:if(M.done){it.g=4;break}if(Q=M.value,se=l[Q],typeof se=="string")return be=m,ze=Q,J(it,I(e,Q,u[se]),14);if(fe=u[se.stream],se.type==="detection_list"){if(fe){for(var ot=fe.getRectList(),Bt=fe.getLandmarksList(),br=fe.getClassificationsList(),Nt=[],Cr=0;Cr<ot.size();++Cr){var gn=Ar(ot.get(Cr),Ue,Fe);gn={U:{aa:Ie(gn,1),ba:Ie(gn,2),height:Ie(gn,3),width:Ie(gn,4),rotation:Ie(gn,5,0),Z:$t(gn,6)},P:bt(Ar(Bt.get(Cr),Ne,Le),ne,1).map(H),N:U(Ar(br.get(Cr),Y,oe))},Nt.push(gn)}ot=Nt}else ot=[];m[Q]=ot,it.g=7;break}if(se.type==="proto_list"){if(fe){for(ot=Array(fe.size()),Bt=0;Bt<fe.size();Bt++)ot[Bt]=fe.get(Bt);fe.delete()}else ot=[];m[Q]=ot,it.g=7;break}if(fe===void 0){it.g=3;break}if(se.type==="float_list"){m[Q]=fe,it.g=7;break}if(se.type==="proto"){m[Q]=fe,it.g=7;break}if(se.type!=="texture")throw Error("Unknown output config type: '"+se.type+"'");return de=e.s[Q],de||(de=new G(e.h,e.F),e.s[Q]=de),J(it,re(de,fe,e.H),13);case 13:we=it.h,m[Q]=we;case 7:se.transform&&m[Q]&&(m[Q]=se.transform(m[Q])),it.g=3;break;case 14:be[ze]=it.h;case 3:M=K.next(),it.g=2;break;case 4:return it.return(m)}})}function I(e,u,l){var m;return me(function(F){return typeof l=="number"||l instanceof Uint8Array||l instanceof e.h.Uint8BlobList?F.return(l):l instanceof e.h.Texture2dDataOut?(m=e.s[u],m||(m=new G(e.h,e.F),e.s[u]=m),F.return(re(m,l,e.H))):F.return(void 0)})}function B(e,u){for(var l=u.name||"$",m=[].concat(L(u.wants)),F=new e.h.StringList,C=O(u.wants),M=C.next();!M.done;M=C.next())F.push_back(M.value);C=e.h.PacketListener.implement({onResults:function(D){for(var V={},K=0;K<u.wants.length;++K)V[m[K]]=D.get(K);var Q=e.listeners[l];Q&&(e.D=S(e,V,u.outs).then(function(se){se=Q(se);for(var fe=0;fe<u.wants.length;++fe){var de=V[m[fe]];typeof de=="object"&&de.hasOwnProperty&&de.hasOwnProperty("delete")&&de.delete()}se&&(e.D=se)}))}}),e.i.attachMultiListener(F,C),F.delete()}i.onResults=function(e,u){this.listeners[u||"$"]=e},je("Solution",Re),je("OptionType",{BOOL:0,NUMBER:1,ca:2,0:"BOOL",1:"NUMBER",2:"STRING"});function o(e){var u=$t(e,1),l=ht(e,h,3);return l={x:Ie(l,1),y:Ie(l,2),depth:Ie(l,3)},e=ht(e,x,2),{id:u,point2d:l,point3d:{x:Ie(e,1),y:Ie(e,2),z:Ie(e,3)}}}function f(e){var u=Ar(e,s,_);e=[],u=bt(u,z,2);for(var l=0;l<u.length;l++)e.push({id:$t(u[l],1),keypoints:bt(u[l],W,2).map(o),visibility:Ie(u[l],3),scale:He(u[l],6),translation:He(u[l],5),rotation:He(u[l],4)});return e}function b(e){switch(e){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"}}function r(e){switch(e){case"Camera":return"Camera";case"Chair":return"Chair";case"Cup":return"Coffee cup, Mug";default:return"Footwear"}}var c={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 d(e){var u=this;e=e||{},this.g=new Re({locateFile:e.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:f}}}],options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:typeof window!="object"||window.navigator===void 0?!1:"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(l){var m,F,C,M;return me(function(D){return D.g==1?(m=l,u.g.setOptions({allowedLabels:r(m)},c),F=b(m),C="object_detection_3d.tflite",J(D,w(u.g,F),2)):(M=D.h,u.g.overrideFile(C,M),D.return(!0))})}},focalLength:{default:[1,1],onChange:function(l){var m;return me(function(F){return m=l,u.h=m,u.g.setOptions({focalX:m[0],focalY:m[1]},c),F.return(!0)})}},principalPoint:{default:[0,0],onChange:function(l){var m;return me(function(F){return m=l,u.i=m,u.g.setOptions({principalX:m[0],principalY:m[1]},c),F.return(!0)})}},imageSize:{onChange:function(l){var m,F,C,M;return me(function(D){if(u.h===void 0||u.i===void 0)return console.error('"focalLength" and "principalPoint" must be set if setting image size'),D.return();m=l,F=[m[0]/2,m[1]/2],C=[u.h[0]/F[0],u.h[1]/F[1]],M=[u.i[0]/F[0],u.i[1]/F[1]],u.setOptions({focalLength:C,principalPoint:M}),D.g=0})}}}})}i=d.prototype,i.close=function(){return this.g.close(),Promise.resolve()},i.onResults=function(e){this.g.onResults(e)},i.initialize=function(){var e=this;return me(function(u){return J(u,e.g.initialize(),0)})},i.reset=function(){this.g.reset()},i.send=function(e){var u=this;return me(function(l){return J(l,u.g.send(e),0)})},i.setOptions=function(e){this.g.setOptions(e)},je("Objectron",d),je("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]]),je("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}),je("VERSION","0.4.1636596145")}).call(Fi);const Oi={};(function(){var i;function t(s){var _=0;return function(){return _<s.length?{done:!1,value:s[_++]}:{done:!0}}}var n=typeof Object.defineProperties=="function"?Object.defineProperty:function(s,_,T){return s==Array.prototype||s==Object.prototype||(s[_]=T.value),s};function p(s){s=[typeof globalThis=="object"&&globalThis,s,typeof window=="object"&&window,typeof self=="object"&&self,typeof global=="object"&&global];for(var _=0;_<s.length;++_){var T=s[_];if(T&&T.Math==Math)return T}throw Error("Cannot find global object")}var y=p(this);function R(s,_){if(_)e:{var T=y;s=s.split(".");for(var P=0;P<s.length-1;P++){var U=s[P];if(!(U in T))break e;T=T[U]}s=s[s.length-1],P=T[s],_=_(P),_!=P&&_!=null&&n(T,s,{configurable:!0,writable:!0,value:_})}}R("Symbol",function(s){function _(H){if(this instanceof _)throw new TypeError("Symbol is not a constructor");return new T(P+(H||"")+"_"+U++,H)}function T(H,G){this.g=H,n(this,"description",{configurable:!0,writable:!0,value:G})}if(s)return s;T.prototype.toString=function(){return this.g};var P="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",U=0;return _}),R("Symbol.iterator",function(s){if(s)return s;s=Symbol("Symbol.iterator");for(var _="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),T=0;T<_.length;T++){var P=y[_[T]];typeof P=="function"&&typeof P.prototype[s]!="function"&&n(P.prototype,s,{configurable:!0,writable:!0,value:function(){return k(t(this))}})}return s});function k(s){return s={next:s},s[Symbol.iterator]=function(){return this},s}function O(s){var _=typeof Symbol<"u"&&Symbol.iterator&&s[Symbol.iterator];return _?_.call(s):{next:t(s)}}function L(s){if(!(s instanceof Array)){s=O(s);for(var _,T=[];!(_=s.next()).done;)T.push(_.value);s=T}return s}var te=typeof Object.create=="function"?Object.create:function(s){function _(){}return _.prototype=s,new _},ue;if(typeof Object.setPrototypeOf=="function")ue=Object.setPrototypeOf;else{var pe;e:{var Oe={a:!0},Me={};try{Me.__proto__=Oe,pe=Me.a;break e}catch{}pe=!1}ue=pe?function(s,_){if(s.__proto__=_,s.__proto__!==_)throw new TypeError(s+" is not extensible");return s}:null}var ce=ue;function he(s,_){if(s.prototype=te(_.prototype),s.prototype.constructor=s,ce)ce(s,_);else for(var T in _)if(T!="prototype")if(Object.defineProperties){var P=Object.getOwnPropertyDescriptor(_,T);P&&Object.defineProperty(s,T,P)}else s[T]=_[T];s.ea=_.prototype}function Ge(){this.l=!1,this.i=null,this.h=void 0,this.g=1,this.s=this.m=0,this.j=null}function Ve(s){if(s.l)throw new TypeError("Generator is already running");s.l=!0}Ge.prototype.o=function(s){this.h=s};function ct(s,_){s.j={U:_,V:!0},s.g=s.m||s.s}Ge.prototype.return=function(s){this.j={return:s},this.g=this.s};function J(s,_,T){return s.g=T,{value:_}}function Jt(s){this.g=new Ge,this.h=s}function mr(s,_){Ve(s.g);var T=s.g.i;return T?At(s,"return"in T?T.return:function(P){return{value:P,done:!0}},_,s.g.return):(s.g.return(_),Xe(s))}function At(s,_,T,P){try{var U=_.call(s.g.i,T);if(!(U instanceof Object))throw new TypeError("Iterator result "+U+" is not an object");if(!U.done)return s.g.l=!1,U;var H=U.value}catch(G){return s.g.i=null,ct(s.g,G),Xe(s)}return s.g.i=null,P.call(s.g,H),Xe(s)}function Xe(s){for(;s.g.g;)try{var _=s.h(s.g);if(_)return s.g.l=!1,{value:_.value,done:!1}}catch(T){s.g.h=void 0,ct(s.g,T)}if(s.g.l=!1,s.g.j){if(_=s.g.j,s.g.j=null,_.V)throw _.U;return{value:_.return,done:!0}}return{value:void 0,done:!0}}function Mr(s){this.next=function(_){return Ve(s.g),s.g.i?_=At(s,s.g.i.next,_,s.g.o):(s.g.o(_),_=Xe(s)),_},this.throw=function(_){return Ve(s.g),s.g.i?_=At(s,s.g.i.throw,_,s.g.o):(ct(s.g,_),_=Xe(s)),_},this.return=function(_){return mr(s,_)},this[Symbol.iterator]=function(){return this}}function at(s){function _(P){return s.next(P)}function T(P){return s.throw(P)}return new Promise(function(P,U){function H(G){G.done?P(G.value):Promise.resolve(G.value).then(_,T).then(H,U)}H(s.next())})}function me(s){return at(new Mr(new Jt(s)))}R("Promise",function(s){function _(G){this.h=0,this.i=void 0,this.g=[],this.o=!1;var re=this.j();try{G(re.resolve,re.reject)}catch(Z){re.reject(Z)}}function T(){this.g=null}function P(G){return G instanceof _?G:new _(function(re){re(G)})}if(s)return s;T.prototype.h=function(G){if(this.g==null){this.g=[];var re=this;this.i(function(){re.l()})}this.g.push(G)};var U=y.setTimeout;T.prototype.i=function(G){U(G,0)},T.prototype.l=function(){for(;this.g&&this.g.length;){var G=this.g;this.g=[];for(var re=0;re<G.length;++re){var Z=G[re];G[re]=null;try{Z()}catch(ye){this.j(ye)}}}this.g=null},T.prototype.j=function(G){this.i(function(){throw G})},_.prototype.j=function(){function G(ye){return function(_e){Z||(Z=!0,ye.call(re,_e))}}var re=this,Z=!1;return{resolve:G(this.C),reject:G(this.l)}},_.prototype.C=function(G){if(G===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(G instanceof _)this.F(G);else{e:switch(typeof G){case"object":var re=G!=null;break e;case"function":re=!0;break e;default:re=!1}re?this.v(G):this.m(G)}},_.prototype.v=function(G){var re=void 0;try{re=G.then}catch(Z){this.l(Z);return}typeof re=="function"?this.G(re,G):this.m(G)},_.prototype.l=function(G){this.s(2,G)},_.prototype.m=function(G){this.s(1,G)},_.prototype.s=function(G,re){if(this.h!=0)throw Error("Cannot settle("+G+", "+re+"): Promise already settled in state"+this.h);this.h=G,this.i=re,this.h===2&&this.D(),this.A()},_.prototype.D=function(){var G=this;U(function(){if(G.B()){var re=y.console;typeof re<"u"&&re.error(G.i)}},1)},_.prototype.B=function(){if(this.o)return!1;var G=y.CustomEvent,re=y.Event,Z=y.dispatchEvent;return typeof Z>"u"?!0:(typeof G=="function"?G=new G("unhandledrejection",{cancelable:!0}):typeof re=="function"?G=new re("unhandledrejection",{cancelable:!0}):(G=y.document.createEvent("CustomEvent"),G.initCustomEvent("unhandledrejection",!1,!0,G)),G.promise=this,G.reason=this.i,Z(G))},_.prototype.A=function(){if(this.g!=null){for(var G=0;G<this.g.length;++G)H.h(this.g[G]);this.g=null}};var H=new T;return _.prototype.F=function(G){var re=this.j();G.J(re.resolve,re.reject)},_.prototype.G=function(G,re){var Z=this.j();try{G.call(re,Z.resolve,Z.reject)}catch(ye){Z.reject(ye)}},_.prototype.then=function(G,re){function Z(Te,le){return typeof Te=="function"?function(Ee){try{ye(Te(Ee))}catch(Re){_e(Re)}}:le}var ye,_e,De=new _(function(Te,le){ye=Te,_e=le});return this.J(Z(G,ye),Z(re,_e)),De},_.prototype.catch=function(G){return this.then(void 0,G)},_.prototype.J=function(G,re){function Z(){switch(ye.h){case 1:G(ye.i);break;case 2:re(ye.i);break;default:throw Error("Unexpected state: "+ye.h)}}var ye=this;this.g==null?H.h(Z):this.g.push(Z),this.o=!0},_.resolve=P,_.reject=function(G){return new _(function(re,Z){Z(G)})},_.race=function(G){return new _(function(re,Z){for(var ye=O(G),_e=ye.next();!_e.done;_e=ye.next())P(_e.value).J(re,Z)})},_.all=function(G){var re=O(G),Z=re.next();return Z.done?P([]):new _(function(ye,_e){function De(Ee){return function(Re){Te[Ee]=Re,le--,le==0&&ye(Te)}}var Te=[],le=0;do Te.push(void 0),le++,P(Z.value).J(De(Te.length-1),_e),Z=re.next();while(!Z.done)})},_});function Wr(s,_){s instanceof String&&(s+="");var T=0,P=!1,U={next:function(){if(!P&&T<s.length){var H=T++;return{value:_(H,s[H]),done:!1}}return P=!0,{done:!0,value:void 0}}};return U[Symbol.iterator]=function(){return U},U}var Br=typeof Object.assign=="function"?Object.assign:function(s,_){for(var T=1;T<arguments.length;T++){var P=arguments[T];if(P)for(var U in P)Object.prototype.hasOwnProperty.call(P,U)&&(s[U]=P[U])}return s};R("Object.assign",function(s){return s||Br}),R("Object.is",function(s){return s||function(_,T){return _===T?_!==0||1/_===1/T:_!==_&&T!==T}}),R("Array.prototype.includes",function(s){return s||function(_,T){var P=this;P instanceof String&&(P=String(P));var U=P.length;for(T=T||0,0>T&&(T=Math.max(T+U,0));T<U;T++){var H=P[T];if(H===_||Object.is(H,_))return!0}return!1}}),R("String.prototype.includes",function(s){return s||function(_,T){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(_ instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(_,T||0)!==-1}}),R("Array.prototype.keys",function(s){return s||function(){return Wr(this,function(_){return _})}});var Tt=this||self;function je(s,_){s=s.split(".");var T=Tt;s[0]in T||typeof T.execScript>"u"||T.execScript("var "+s[0]);for(var P;s.length&&(P=s.shift());)s.length||_===void 0?T[P]&&T[P]!==Object.prototype[P]?T=T[P]:T=T[P]={}:T[P]=_}function Ot(s){Tt.setTimeout(function(){throw s},0)}function tr(s){Ot(s)}function yr(s,_){tr(Error("Invalid wire type: "+s+" (at position "+_+")"))}function Or(){tr(Error("Failed to read varint, encoding is invalid."))}function wr(s,_){return _=String.fromCharCode.apply(null,_),s==null?_:s+_}var Pr,rr=typeof TextDecoder<"u",Dt,xr=typeof TextEncoder<"u";function Ir(s){if(xr)s=(Dt||(Dt=new TextEncoder)).encode(s);else{var _=void 0;_=_===void 0?!1:_;for(var T=0,P=new Uint8Array(3*s.length),U=0;U<s.length;U++){var H=s.charCodeAt(U);if(128>H)P[T++]=H;else{if(2048>H)P[T++]=H>>6|192;else{if(55296<=H&&57343>=H){if(56319>=H&&U<s.length){var G=s.charCodeAt(++U);if(56320<=G&&57343>=G){H=1024*(H-55296)+G-56320+65536,P[T++]=H>>18|240,P[T++]=H>>12&63|128,P[T++]=H>>6&63|128,P[T++]=H&63|128;continue}else U--}if(_)throw Error("Found an unpaired surrogate");H=65533}P[T++]=H>>12|224,P[T++]=H>>6&63|128}P[T++]=H&63|128}}s=P.subarray(0,T)}return s}var vr={},Ct=null;function _r(s){var _;_===void 0&&(_=0),St(),_=vr[_];for(var T=Array(Math.floor(s.length/3)),P=_[64]||"",U=0,H=0;U<s.length-2;U+=3){var G=s[U],re=s[U+1],Z=s[U+2],ye=_[G>>2];G=_[(G&3)<<4|re>>4],re=_[(re&15)<<2|Z>>6],Z=_[Z&63],T[H++]=ye+G+re+Z}switch(ye=0,Z=P,s.length-U){case 2:ye=s[U+1],Z=_[(ye&15)<<2]||P;case 1:s=s[U],T[H]=_[s>>2]+_[(s&3)<<4|ye>>4]+Z+P}return T.join("")}function lr(s){var _=s.length,T=3*_/4;T%3?T=Math.floor(T):"=.".indexOf(s[_-1])!=-1&&(T="=.".indexOf(s[_-2])!=-1?T-2:T-1);var P=new Uint8Array(T),U=0;return ut(s,function(H){P[U++]=H}),P.subarray(0,U)}function ut(s,_){function T(Z){for(;P<s.length;){var ye=s.charAt(P++),_e=Ct[ye];if(_e!=null)return _e;if(!/^[\s\xa0]*$/.test(ye))throw Error("Unknown base64 encoding at char: "+ye)}return Z}St();for(var P=0;;){var U=T(-1),H=T(0),G=T(64),re=T(64);if(re===64&&U===-1)break;_(U<<2|H>>4),G!=64&&(_(H<<4&240|G>>2),re!=64&&_(G<<6&192|re))}}function St(){if(!Ct){Ct={};for(var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),_=["+/=","+/","-_=","-_.","-_"],T=0;5>T;T++){var P=s.concat(_[T].split(""));vr[T]=P;for(var U=0;U<P.length;U++){var H=P[U];Ct[H]===void 0&&(Ct[H]=U)}}}}var Ht=typeof Uint8Array=="function",xt;function _t(s){if(this.g=s,s!==null&&s.length===0)throw Error("ByteString should be constructed with non-empty values")}_t.prototype.toJSON=function(){if(this.g==null)var s="";else s=this.g,s=this.g=s==null||typeof s=="string"?s:Ht&&s instanceof Uint8Array?_r(s):null;return s};var Zt=typeof Uint8Array.prototype.slice=="function";function Gt(s,_,T){return _===T?xt||(xt=new Uint8Array(0)):Zt?s.slice(_,T):new Uint8Array(s.subarray(_,T))}var qe=0,mt=0;function Rt(s){if(s.constructor===Uint8Array)return s;if(s.constructor===ArrayBuffer)return new Uint8Array(s);if(s.constructor===Array)return new Uint8Array(s);if(s.constructor===String)return lr(s);if(s.constructor===_t){if(s.g==null)var _=xt||(xt=new Uint8Array(0));else{_=Uint8Array;var T=s.g;T=T==null||Ht&&T!=null&&T instanceof Uint8Array?T:typeof T=="string"?lr(T):null,s=s.g=T,_=new _(s)}return _}if(s instanceof Uint8Array)return new Uint8Array(s.buffer,s.byteOffset,s.byteLength);throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers")}function We(s,_){_=_===void 0?{}:_,_=_.u===void 0?!1:_.u,this.h=null,this.g=this.i=this.l=0,this.j=!1,this.u=_,s&&Ft(this,s)}function Ft(s,_){s.h=Rt(_),s.l=0,s.i=s.h.length,s.g=s.l}We.prototype.reset=function(){this.g=this.l};function et(s){s.g>s.i&&(s.j=!0,tr(Error("Tried to read past the end of the data "+s.g+" > "+s.i)))}function pt(s){var _=s.h,T=_[s.g],P=T&127;return 128>T?(s.g+=1,et(s),P):(T=_[s.g+1],P|=(T&127)<<7,128>T?(s.g+=2,et(s),P):(T=_[s.g+2],P|=(T&127)<<14,128>T?(s.g+=3,et(s),P):(T=_[s.g+3],P|=(T&127)<<21,128>T?(s.g+=4,et(s),P):(T=_[s.g+4],P|=(T&15)<<28,128>T?(s.g+=5,et(s),P>>>0):(s.g+=5,128<=_[s.g++]&&128<=_[s.g++]&&128<=_[s.g++]&&128<=_[s.g++]&&128<=_[s.g++]?(s.j=!0,Or(),P):(et(s),P))))))}var It=[];function Vt(){this.g=new Uint8Array(64),this.h=0}function wt(s,_){if(!(s.h+1<s.g.length)){var T=s.g;s.g=new Uint8Array(Math.ceil(1+2*s.g.length)),s.g.set(T)}s.g[s.h++]=_}Vt.prototype.length=function(){return this.h},Vt.prototype.end=function(){var s=this.g,_=this.h;return this.h=0,Gt(s,0,_)};function Ye(s,_){for(;127<_;)wt(s,_&127|128),_>>>=7;wt(s,_)}function Lt(s){var _={},T=_.N===void 0?!1:_.N;this.m={u:_.u===void 0?!1:_.u},this.N=T,_=this.m,It.length?(T=It.pop(),_&&(T.u=_.u),s&&Ft(T,s),s=T):s=new We(s,_),this.g=s,this.l=this.g.g,this.h=this.i=-1,this.j=!1}Lt.prototype.reset=function(){this.g.reset(),this.h=this.i=-1};function zt(s){var _=s.g;if((_=_.g==_.i)||(_=s.j)||(_=s.g,_=_.j||0>_.g||_.g>_.i),_)return!1;s.l=s.g.g;var T=pt(s.g);return _=T>>>3,T&=7,0<=T&&5>=T?(s.i=_,s.h=T,!0):(s.j=!0,yr(T,s.l),!1)}function Et(s){switch(s.h){case 0:if(s.h!=0)Et(s);else e:{s=s.g;for(var _=s.g,T=0;10>T;T++){if((s.h[_]&128)===0){s.g=_+1,et(s);break e}_++}s.j=!0,Or()}break;case 1:s=s.g,s.g+=8,et(s);break;case 2:s.h!=2?Et(s):(_=pt(s.g),s=s.g,s.g+=_,et(s));break;case 5:s=s.g,s.g+=4,et(s);break;case 3:_=s.i;do{if(!zt(s)){s.j=!0,tr(Error("Unmatched start-group tag: stream EOF"));break}if(s.h==4){s.i!=_&&(s.j=!0,tr(Error("Unmatched end-group tag")));break}Et(s)}while(!0);break;default:s.j=!0,yr(s.h,s.l)}}function fr(s,_,T){s.N||(s=Gt(s.g.h,T,s.g.g),(T=_.m)?T.push(s):_.m=[s])}var qt=[];function sr(){this.h=[],this.i=0,this.g=new Vt}function hr(s,_){_.length!==0&&(s.h.push(_),s.i+=_.length)}function yt(s,_,T){Ye(s.g,8*_+2),Ye(s.g,T.length),hr(s,s.g.end()),hr(s,T)}var kt=typeof Symbol=="function"&&typeof Symbol()=="symbol"?Symbol(void 0):void 0;function vt(s,_){Object.isFrozen(s)||(kt?s[kt]|=_:s.g!==void 0?s.g|=_:Object.defineProperties(s,{g:{value:_,configurable:!0,writable:!0,enumerable:!1}}))}function rt(s){if(!s)return 0;var _;return kt?_=s[kt]:_=s.g,_??0}function Ut(s){return Array.isArray(s)&&vt(s,1),s}function tt(s){if(!Array.isArray(s))throw Error("cannot mark non-array as immutable");vt(s,2)}function $e(s){return s!==null&&typeof s=="object"&&s.constructor===Object}function nr(s){switch(typeof s){case"number":return isFinite(s)?s:String(s);case"object":return Ht&&s!=null&&s instanceof Uint8Array?_r(s):s;default:return s}}function lt(s,_){if(s!=null)return Array.isArray(s)||$e(s)?Ce(s,_):_(s)}function Ce(s,_){if(Array.isArray(s)){for(var T=Array(s.length),P=0;P<s.length;P++)T[P]=lt(s[P],_);return rt(s)&1&&Ut(T),T}T={};for(P in s)T[P]=lt(s[P],_);return T}var Se;function nt(s,_,T){var P=Se;Se=null,s||(s=P),P=this.constructor.ca,s||(s=P?[P]:[]),this.j=(P?0:-1)-(this.constructor.aa||0),this.i=null,this.g=s;e:{if(P=this.g.length,s=P-1,P&&(P=this.g[s],$e(P))){this.l=s-this.j,this.h=P;break e}_!==void 0&&-1<_?(this.l=Math.max(_,s+1-this.j),this.h=null):this.l=Number.MAX_VALUE}if(T)for(_=0;_<T.length;_++)s=T[_],s<this.l?(s+=this.j,(P=this.g[s])?Ut(P):this.g[s]=ee):(ie(this),(P=this.h[s])?Ut(P):this.h[s]=ee)}var ee=Object.freeze(Ut([]));function ie(s){var _=s.l+s.j;s.g[_]||(s.h=s.g[_]={})}function ve(s,_,T){return _===-1?null:T!==void 0&&T||_>=s.l?s.h?s.h[_]:void 0:s.g[_+s.j]}function He(s,_,T){T=T===void 0?!0:T;var P=P===void 0?!1:P,U=ve(s,_,P);return U==null&&(U=ee),U===ee?(U=Ut([]),xe(s,_,U,P)):T&&Array.isArray(U)&&rt(U)&2&&(U=U.slice(),xe(s,_,U,P)),U}function Ie(s,_,T){return s=ve(s,_),s=s==null?s:+s,s??(T===void 0?0:T)}function xe(s,_,T,P){P!==void 0&&P||_>=s.l?(ie(s),s.h[_]=T):s.g[_+s.j]=T}function Ke(s,_,T){s.i||(s.i={});var P=s.i[T];if(!P){var U=He(s,T,!1);P=[];for(var H=Array.isArray(U)?!!(rt(U)&2):!1,G=0;G<U.length;G++)P[G]=new _(U[G]),H&&tt(P[G].g);H&&(tt(P),Object.freeze(P)),s.i[T]=P}return P}function ht(s,_,T,P,U){var H=Ke(s,P,_);T=T||new P,s=He(s,_),U!=null?(H.splice(U,0,T),s.splice(U,0,bt(T))):(H.push(T),s.push(bt(T)))}nt.prototype.toJSON=function(){var s=bt(this);return Ce(s,nr)};function bt(s){if(s.i)for(var _ in s.i){var T=s.i[_];if(Array.isArray(T))for(var P=0;P<T.length;P++)T[P]&&bt(T[P]);else T&&bt(T)}return s.g}nt.prototype.toString=function(){return bt(this).toString()};function Qe(s,_){return s=ve(s,_),s??0}function $t(s,_){return s=ve(s,_),s??""}function Er(s,_){if(s=s.m){hr(_,_.g.end());for(var T=0;T<s.length;T++)hr(_,s[T])}}function ar(s){var _=s[0];switch(s.length){case 2:var T=s[1];return function(Z,ye,_e){return _(Z,ye,_e,T)};case 3:var P=s[1],U=s[2];return function(Z,ye,_e){return _(Z,ye,_e,P,U)};case 4:var H=s[1],G=s[2],re=s[3];return function(Z,ye,_e){return _(Z,ye,_e,H,G,re)};default:throw Error("unsupported number of parameters, expected [2-4], got "+s.length)}}function Yt(s,_,T){for(;zt(_)&&_.h!=4;){var P=_.i,U=T[P];if(U){if(Array.isArray(U)&&(U=T[P]=ar(U)),!U(_,s,P)){P=_,U=s;var H=P.l;Et(P),fr(P,U,H)}}else P=_,U=s,H=P.l,Et(P),fr(P,U,H)}return s}function ir(s,_){var T=new sr;if(_(s,T),s=T.i+T.g.length(),s===0)T=new Uint8Array(0);else{s=new Uint8Array(s);for(var P=T.h,U=P.length,H=_=0;H<U;H++){var G=P[H];G.length!==0&&(s.set(G,_),_+=G.length)}P=T.g,U=P.h,U!==0&&(s.set(P.g.subarray(0,U),_),P.h=0),T.h=[s],T=s}return T}function ur(s,_,T){if(qt.length){var P=qt.pop();s&&(Ft(P.g,s),P.i=-1,P.h=-1),s=P}else s=new Lt(s);try{return T(new _,s)}finally{_=s.g,_.h=null,_.l=0,_.i=0,_.g=0,_.j=!1,_.u=!1,s.i=-1,s.h=-1,s.j=!1,100>qt.length&&qt.push(s)}}function Pt(s,_,T){if(_=ve(_,T),_!=null){Ye(s.g,8*T+5),s=s.g;var P=_;P=(T=0>P?1:0)?-P:P,P===0?0<1/P?qe=mt=0:(mt=0,qe=2147483648):isNaN(P)?(mt=0,qe=2147483647):34028234663852886e22<P?(mt=0,qe=(T<<31|2139095040)>>>0):11754943508222875e-54>P?(P=Math.round(P/Math.pow(2,-149)),mt=0,qe=(T<<31|P)>>>0):(_=Math.floor(Math.log(P)/Math.LN2),P*=Math.pow(2,-_),P=Math.round(8388608*P),16777216<=P&&++_,mt=0,qe=(T<<31|_+127<<23|P&8388607)>>>0),T=qe,wt(s,T>>>0&255),wt(s,T>>>8&255),wt(s,T>>>16&255),wt(s,T>>>24&255)}}function Xt(s,_,T){if(s.h!==5)return!1;s=s.g;var P=s.h[s.g],U=s.h[s.g+1],H=s.h[s.g+2],G=s.h[s.g+3];return s.g+=4,et(s),U=(P<<0|U<<8|H<<16|G<<24)>>>0,s=2*(U>>31)+1,P=U>>>23&255,U&=8388607,xe(_,T,P==255?U?NaN:1/0*s:P==0?s*Math.pow(2,-149)*U:s*Math.pow(2,P-150)*(U+Math.pow(2,23))),!0}function zr(s,_,T){if(s.h!==0)return!1;for(var P=s.g,U=128,H=0,G=s=0;4>G&&128<=U;G++)U=P.h[P.g++],H|=(U&127)<<7*G;if(128<=U&&(U=P.h[P.g++],H|=(U&127)<<28,s|=(U&127)>>4),128<=U)for(G=0;5>G&&128<=U;G++)U=P.h[P.g++],s|=(U&127)<<7*G+3;return 128>U?(P=H>>>0,U=s>>>0,(s=U&2147483648)&&(P=~P+1>>>0,U=~U>>>0,P==0&&(U=U+1>>>0)),P=4294967296*U+(P>>>0),s=s?-P:P):(P.j=!0,Or(),s=void 0),xe(_,T,s),!0}function Kt(s,_,T){return s.h!==0?!1:(xe(_,T,pt(s.g)),!0)}function Mt(s,_,T){if(s.h!==2)return!1;var P=pt(s.g);s=s.g;var U=s.g;s.g+=P,et(s),s=s.h;var H;if(rr)(H=Pr)||(H=Pr=new TextDecoder("utf-8",{fatal:!1})),H=H.decode(s.subarray(U,U+P));else{P=U+P;for(var G=[],re=null,Z,ye,_e;U<P;)Z=s[U++],128>Z?G.push(Z):224>Z?U>=P?G.push(65533):(ye=s[U++],194>Z||(ye&192)!==128?(U--,G.push(65533)):G.push((Z&31)<<6|ye&63)):240>Z?U>=P-1?G.push(65533):(ye=s[U++],(ye&192)!==128||Z===224&&160>ye||Z===237&&160<=ye||((H=s[U++])&192)!==128?(U--,G.push(65533)):G.push((Z&15)<<12|(ye&63)<<6|H&63)):244>=Z?U>=P-2?G.push(65533):(ye=s[U++],(ye&192)!==128||(Z<<28)+(ye-144)>>30!==0||((H=s[U++])&192)!==128||((_e=s[U++])&192)!==128?(U--,G.push(65533)):(Z=(Z&7)<<18|(ye&63)<<12|(H&63)<<6|_e&63,Z-=65536,G.push((Z>>10&1023)+55296,(Z&1023)+56320))):G.push(65533),8192<=G.length&&(re=wr(re,G),G.length=0);H=wr(re,G)}return xe(_,T,H),!0}function dr(s,_,T,P,U){if(s.h!==2)return!1;var H=new P,G=s.g.i,re=pt(s.g),Z=s.g.g+re;if(s.g.i=Z,U(H,s),U=Z-s.g.g,U!==0)throw Error("Message parsing ended unexpectedly. Expected to read "+(re+" bytes, instead read "+(re-U)+" bytes, either the data ended unexpectedly or the message misreported its own length"));return s.g.g=Z,s.g.i=G,ht(_,T,H,P,void 0),!0}function Ar(s){nt.call(this,s)}var Wt;he(Ar,nt);function jr(s,_){var T=ve(s,1);if(T!=null&&T!=null){Ye(_.g,8);var P=_.g;if(0<=T)Ye(P,T);else{for(var U=0;9>U;U++)wt(P,T&127|128),T>>=7;wt(P,1)}}Pt(_,s,2),P=ve(s,3),P!=null&&yt(_,3,Ir(P)),P=ve(s,4),P!=null&&yt(_,4,Ir(P)),Er(s,_)}function Qt(s,_){return Yt(s,_,Wt||(Wt={1:Kt,2:Xt,3:Mt,4:Mt}))}function pr(s){nt.call(this,s,-1,er)}var Tr;he(pr,nt),pr.prototype.addClassification=function(s,_){return ht(this,1,s,Ar,_),this};function Nr(s,_){return Yt(s,_,Tr||(Tr={1:[dr,Ar,Qt]}))}var er=[1];function Sr(s){nt.call(this,s)}var $r;he(Sr,nt);function Yr(s,_){Pt(_,s,1),Pt(_,s,2),Pt(_,s,3),Pt(_,s,4),Pt(_,s,5),Er(s,_)}function Rr(s,_){return Yt(s,_,$r||($r={1:Xt,2:Xt,3:Xt,4:Xt,5:Xt}))}function kr(s){nt.call(this,s,-1,A)}var g;he(kr,nt);function E(s,_){return Yt(s,_,g||(g={1:[dr,Sr,Rr]}))}var A=[1];function N(s){nt.call(this,s)}var Y;he(N,nt);function oe(s,_){Pt(_,s,1),Pt(_,s,2),Pt(_,s,3),Pt(_,s,4),Pt(_,s,5);var T=ve(s,6);if(T!=null&&T!=null){Ye(_.g,48);var P=_.g,U=T;T=0>U,U=Math.abs(U);var H=U>>>0;for(U=Math.floor((U-H)/4294967296),U>>>=0,T&&(U=~U>>>0,H=(~H>>>0)+1,4294967295<H&&(H=0,U++,4294967295<U&&(U=0))),qe=H,mt=U,T=qe,H=mt;0<H||127<T;)wt(P,T&127|128),T=(T>>>7|H<<25)>>>0,H>>>=7;wt(P,T)}Er(s,_)}function $(s,_){return Yt(s,_,Y||(Y={1:Xt,2:Xt,3:Xt,4:Xt,5:Xt,6:zr}))}function ne(s,_,T){if(T=s.createShader(T===0?s.VERTEX_SHADER:s.FRAGMENT_SHADER),s.shaderSource(T,_),s.compileShader(T),!s.getShaderParameter(T,s.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
|
|
105
|
-
|
|
106
|
-
`+s.getShaderInfoLog(T));return T}function ge(s){return Ke(s,Ar,1).map(function(_){return{index:Qe(_,1),X:Ie(_,2),label:ve(_,3)!=null?$t(_,3):void 0,displayName:ve(_,4)!=null?$t(_,4):void 0}})}function Ae(s){return{x:Ie(s,1),y:Ie(s,2),z:Ie(s,3),visibility:ve(s,4)!=null?Ie(s,4):void 0}}function Ne(s){return Ke(ur(s,kr,E),Sr,1).map(Ae)}function Le(s,_){this.h=s,this.g=_,this.l=0}function Ze(s,_,T){return Ue(s,_),typeof s.g.canvas.transferToImageBitmap=="function"?Promise.resolve(s.g.canvas.transferToImageBitmap()):T?Promise.resolve(s.g.canvas):typeof createImageBitmap=="function"?createImageBitmap(s.g.canvas):(s.i===void 0&&(s.i=document.createElement("canvas")),new Promise(function(P){s.i.height=s.g.canvas.height,s.i.width=s.g.canvas.width,s.i.getContext("2d",{}).drawImage(s.g.canvas,0,0,s.g.canvas.width,s.g.canvas.height),P(s.i)}))}function Ue(s,_){var T=s.g;if(s.m===void 0){var P=ne(T,`
|
|
107
|
-
attribute vec2 aVertex;
|
|
108
|
-
attribute vec2 aTex;
|
|
109
|
-
varying vec2 vTex;
|
|
110
|
-
void main(void) {
|
|
111
|
-
gl_Position = vec4(aVertex, 0.0, 1.0);
|
|
112
|
-
vTex = aTex;
|
|
113
|
-
}`,0),U=ne(T,`
|
|
114
|
-
precision mediump float;
|
|
115
|
-
varying vec2 vTex;
|
|
116
|
-
uniform sampler2D sampler0;
|
|
117
|
-
void main(){
|
|
118
|
-
gl_FragColor = texture2D(sampler0, vTex);
|
|
119
|
-
}`,1),H=T.createProgram();if(T.attachShader(H,P),T.attachShader(H,U),T.linkProgram(H),!T.getProgramParameter(H,T.LINK_STATUS))throw Error(`Could not compile WebGL program.
|
|
120
|
-
|
|
121
|
-
`+T.getProgramInfoLog(H));P=s.m=H,T.useProgram(P),U=T.getUniformLocation(P,"sampler0"),s.j={I:T.getAttribLocation(P,"aVertex"),H:T.getAttribLocation(P,"aTex"),da:U},s.s=T.createBuffer(),T.bindBuffer(T.ARRAY_BUFFER,s.s),T.enableVertexAttribArray(s.j.I),T.vertexAttribPointer(s.j.I,2,T.FLOAT,!1,0,0),T.bufferData(T.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),T.STATIC_DRAW),T.bindBuffer(T.ARRAY_BUFFER,null),s.o=T.createBuffer(),T.bindBuffer(T.ARRAY_BUFFER,s.o),T.enableVertexAttribArray(s.j.H),T.vertexAttribPointer(s.j.H,2,T.FLOAT,!1,0,0),T.bufferData(T.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),T.STATIC_DRAW),T.bindBuffer(T.ARRAY_BUFFER,null),T.uniform1i(U,0)}P=s.j,T.useProgram(s.m),T.canvas.width=_.width,T.canvas.height=_.height,T.viewport(0,0,_.width,_.height),T.activeTexture(T.TEXTURE0),s.h.bindTexture2d(_.glName),T.enableVertexAttribArray(P.I),T.bindBuffer(T.ARRAY_BUFFER,s.s),T.vertexAttribPointer(P.I,2,T.FLOAT,!1,0,0),T.enableVertexAttribArray(P.H),T.bindBuffer(T.ARRAY_BUFFER,s.o),T.vertexAttribPointer(P.H,2,T.FLOAT,!1,0,0),T.bindFramebuffer(T.DRAW_FRAMEBUFFER?T.DRAW_FRAMEBUFFER:T.FRAMEBUFFER,null),T.clearColor(0,0,0,0),T.clear(T.COLOR_BUFFER_BIT),T.colorMask(!0,!0,!0,!0),T.drawArrays(T.TRIANGLE_FAN,0,4),T.disableVertexAttribArray(P.I),T.disableVertexAttribArray(P.H),T.bindBuffer(T.ARRAY_BUFFER,null),s.h.bindTexture2d(0)}function Fe(s){this.g=s}var Be=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 Je(s,_){return _+s}function st(s,_){window[s]=_}function ft(s){var _=document.createElement("script");return _.setAttribute("src",s),_.setAttribute("crossorigin","anonymous"),new Promise(function(T){_.addEventListener("load",function(){T()},!1),_.addEventListener("error",function(){T()},!1),document.body.appendChild(_)})}function gt(){return me(function(s){switch(s.g){case 1:return s.m=2,J(s,WebAssembly.instantiate(Be),4);case 4:s.g=3,s.m=0;break;case 2:return s.m=0,s.j=null,s.return(!1);case 3:return s.return(!0)}})}function jt(s){if(this.g=s,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=s&&s.locateFile||Je,typeof window=="object")var _=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else if(typeof location<"u")_=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/";else throw Error("solutions can only be loaded on a web page or in a web worker");if(this.S=_,s.options){_=O(Object.keys(s.options));for(var T=_.next();!T.done;T=_.next()){T=T.value;var P=s.options[T].default;P!==void 0&&(this.j[T]=typeof P=="function"?P():P)}}}i=jt.prototype,i.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function h(s){var _,T,P,U,H,G,re,Z,ye,_e,De;return me(function(Te){switch(Te.g){case 1:return s.R?(_=s.g.files===void 0?[]:typeof s.g.files=="function"?s.g.files(s.j):s.g.files,J(Te,gt(),2)):Te.return();case 2:if(T=Te.h,typeof window=="object")return st("createMediapipeSolutionsWasm",{locateFile:s.locateFile}),st("createMediapipeSolutionsPackedAssets",{locateFile:s.locateFile}),G=_.filter(function(le){return le.data!==void 0}),re=_.filter(function(le){return le.data===void 0}),Z=Promise.all(G.map(function(le){var Ee=j(s,le.url);if(le.path!==void 0){var Re=le.path;Ee=Ee.then(function(ke){return s.overrideFile(Re,ke),Promise.resolve(ke)})}return Ee})),ye=Promise.all(re.map(function(le){return le.simd===void 0||le.simd&&T||!le.simd&&!T?ft(s.locateFile(le.url,s.S)):Promise.resolve()})).then(function(){var le,Ee,Re;return me(function(ke){if(ke.g==1)return le=window.createMediapipeSolutionsWasm,Ee=window.createMediapipeSolutionsPackedAssets,Re=s,J(ke,le(Ee),2);Re.h=ke.h,ke.g=0})}),_e=(function(){return me(function(le){return s.g.graph&&s.g.graph.url?le=J(le,j(s,s.g.graph.url),0):(le.g=0,le=void 0),le})})(),J(Te,Promise.all([ye,Z,_e]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return P=_.filter(function(le){return le.simd===void 0||le.simd&&T||!le.simd&&!T}).map(function(le){return s.locateFile(le.url,s.S)}),importScripts.apply(null,L(P)),U=s,J(Te,createMediapipeSolutionsWasm(Module),6);case 6:U.h=Te.h,s.l=new OffscreenCanvas(1,1),s.h.canvas=s.l,H=s.h.GL.createContext(s.l,{antialias:!1,alpha:!1,ba:typeof WebGL2RenderingContext<"u"?2:1}),s.h.GL.makeContextCurrent(H),Te.g=4;break;case 7:if(s.l=document.createElement("canvas"),De=s.l.getContext("webgl2",{}),!De&&(De=s.l.getContext("webgl",{}),!De))return alert("Failed to create WebGL canvas context when passing video frame."),Te.return();s.D=De,s.h.canvas=s.l,s.h.createContext(s.l,!0,!0,{});case 4:s.i=new s.h.SolutionWasm,s.R=!1,Te.g=0}})}function v(s){var _,T,P,U,H,G,re,Z;return me(function(ye){if(ye.g==1){if(s.g.graph&&s.g.graph.url&&s.P===s.g.graph.url)return ye.return();if(s.o=!0,!s.g.graph||!s.g.graph.url){ye.g=2;return}return s.P=s.g.graph.url,J(ye,j(s,s.g.graph.url),3)}for(ye.g!=2&&(_=ye.h,s.i.loadGraph(_)),T=O(Object.keys(s.B)),P=T.next();!P.done;P=T.next())U=P.value,s.i.overrideFile(U,s.B[U]);if(s.B={},s.g.listeners)for(H=O(s.g.listeners),G=H.next();!G.done;G=H.next())re=G.value,z(s,re);Z=s.j,s.j={},s.setOptions(Z),ye.g=0})}i.reset=function(){var s=this;return me(function(_){s.i&&(s.i.reset(),s.m={},s.s={}),_.g=0})},i.setOptions=function(s,_){var T=this;if(_=_||this.g.options){for(var P=[],U=[],H={},G=O(Object.keys(s)),re=G.next();!re.done;H={K:H.K,L:H.L},re=G.next()){var Z=re.value;Z in this.j&&this.j[Z]===s[Z]||(this.j[Z]=s[Z],re=_[Z],re!==void 0&&(re.onChange&&(H.K=re.onChange,H.L=s[Z],P.push((function(ye){return function(){var _e;return me(function(De){if(De.g==1)return J(De,ye.K(ye.L),2);_e=De.h,_e===!0&&(T.o=!0),De.g=0})}})(H))),re.graphOptionXref&&(Z={valueNumber:re.type===1?s[Z]:0,valueBoolean:re.type===0?s[Z]:!1,valueString:re.type===2?s[Z]:""},re=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),re.graphOptionXref),Z),U.push(re))))}(P.length!==0||U.length!==0)&&(this.o=!0,this.A=(this.A===void 0?[]:this.A).concat(U),this.v=(this.v===void 0?[]:this.v).concat(P))}};function x(s){var _,T,P,U,H,G,re;return me(function(Z){switch(Z.g){case 1:if(!s.o)return Z.return();if(!s.v){Z.g=2;break}_=O(s.v),T=_.next();case 3:if(T.done){Z.g=5;break}return P=T.value,J(Z,P(),4);case 4:T=_.next(),Z.g=3;break;case 5:s.v=void 0;case 2:if(s.A){for(U=new s.h.GraphOptionChangeRequestList,H=O(s.A),G=H.next();!G.done;G=H.next())re=G.value,U.push_back(re);s.i.changeOptions(U),U.delete(),s.A=void 0}s.o=!1,Z.g=0}})}i.initialize=function(){var s=this;return me(function(_){return _.g==1?J(_,h(s),2):_.g!=3?J(_,v(s),3):J(_,x(s),0)})};function j(s,_){var T,P;return me(function(U){return _ in s.F?U.return(s.F[_]):(T=s.locateFile(_,""),P=fetch(T).then(function(H){return H.arrayBuffer()}),s.F[_]=P,U.return(P))})}i.overrideFile=function(s,_){this.i?this.i.overrideFile(s,_):this.B[s]=_},i.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},i.send=function(s,_){var T=this,P,U,H,G,re,Z,ye,_e,De;return me(function(Te){switch(Te.g){case 1:return T.g.inputs?(P=1e3*(_??performance.now()),J(Te,T.C,2)):Te.return();case 2:return J(Te,T.initialize(),3);case 3:for(U=new T.h.PacketDataList,H=O(Object.keys(s)),G=H.next();!G.done;G=H.next())if(re=G.value,Z=T.g.inputs[re]){e:{var le=s[re];switch(Z.type){case"video":var Ee=T.m[Z.stream];if(Ee||(Ee=new Le(T.h,T.D),T.m[Z.stream]=Ee),Ee.l===0&&(Ee.l=Ee.h.createTexture()),typeof HTMLVideoElement<"u"&&le instanceof HTMLVideoElement)var Re=le.videoWidth,ke=le.videoHeight;else typeof HTMLImageElement<"u"&&le instanceof HTMLImageElement?(Re=le.naturalWidth,ke=le.naturalHeight):(Re=le.width,ke=le.height);ke={glName:Ee.l,width:Re,height:ke},Re=Ee.g,Re.canvas.width=ke.width,Re.canvas.height=ke.height,Re.activeTexture(Re.TEXTURE0),Ee.h.bindTexture2d(Ee.l),Re.texImage2D(Re.TEXTURE_2D,0,Re.RGBA,Re.RGBA,Re.UNSIGNED_BYTE,le),Ee.h.bindTexture2d(0),Ee=ke;break e;case"detections":for(Ee=T.m[Z.stream],Ee||(Ee=new Fe(T.h),T.m[Z.stream]=Ee),Ee.data||(Ee.data=new Ee.g.DetectionListData),Ee.data.reset(le.length),ke=0;ke<le.length;++ke){Re=le[ke];var Pe=Ee.data,a=Pe.setBoundingBox,w=ke,S=Re.T,I=new N;if(xe(I,1,S.Y),xe(I,2,S.Z),xe(I,3,S.height),xe(I,4,S.width),xe(I,5,S.rotation),xe(I,6,S.W),S=ir(I,oe),a.call(Pe,w,S),Re.O)for(Pe=0;Pe<Re.O.length;++Pe){I=Re.O[Pe];var B=!!I.visibility;a=Ee.data,w=a.addNormalizedLandmark,S=ke,I=Object.assign(Object.assign({},I),{visibility:B?I.visibility:0}),B=new Sr,xe(B,1,I.x),xe(B,2,I.y),xe(B,3,I.z),I.visibility&&xe(B,4,I.visibility),I=ir(B,Yr),w.call(a,S,I)}if(Re.M)for(Pe=0;Pe<Re.M.length;++Pe)a=Ee.data,w=a.addClassification,S=ke,I=Re.M[Pe],B=new Ar,xe(B,2,I.X),I.index&&xe(B,1,I.index),I.label&&xe(B,3,I.label),I.displayName&&xe(B,4,I.displayName),I=ir(B,jr),w.call(a,S,I)}Ee=Ee.data;break e;default:Ee={}}}switch(ye=Ee,_e=Z.stream,Z.type){case"video":U.pushTexture2d(Object.assign(Object.assign({},ye),{stream:_e,timestamp:P}));break;case"detections":De=ye,De.stream=_e,De.timestamp=P,U.pushDetectionList(De);break;default:throw Error("Unknown input config type: '"+Z.type+"'")}}return T.i.send(U),J(Te,T.C,4);case 4:U.delete(),Te.g=0}})};function W(s,_,T){var P,U,H,G,re,Z,ye,_e,De,Te,le,Ee,Re,ke;return me(function(Pe){switch(Pe.g){case 1:if(!T)return Pe.return(_);for(P={},U=0,H=O(Object.keys(T)),G=H.next();!G.done;G=H.next())re=G.value,Z=T[re],typeof Z!="string"&&Z.type==="texture"&&_[Z.stream]!==void 0&&++U;1<U&&(s.G=!1),ye=O(Object.keys(T)),G=ye.next();case 2:if(G.done){Pe.g=4;break}if(_e=G.value,De=T[_e],typeof De=="string")return Re=P,ke=_e,J(Pe,X(s,_e,_[De]),14);if(Te=_[De.stream],De.type==="detection_list"){if(Te){for(var a=Te.getRectList(),w=Te.getLandmarksList(),S=Te.getClassificationsList(),I=[],B=0;B<a.size();++B){var o=ur(a.get(B),N,$);o={T:{Y:Ie(o,1),Z:Ie(o,2),height:Ie(o,3),width:Ie(o,4),rotation:Ie(o,5,0),W:Qe(o,6)},O:Ne(w.get(B)),M:ge(ur(S.get(B),pr,Nr))},I.push(o)}a=I}else a=[];P[_e]=a,Pe.g=7;break}if(De.type==="proto_list"){if(Te){for(a=Array(Te.size()),w=0;w<Te.size();w++)a[w]=Te.get(w);Te.delete()}else a=[];P[_e]=a,Pe.g=7;break}if(Te===void 0){Pe.g=3;break}if(De.type==="float_list"){P[_e]=Te,Pe.g=7;break}if(De.type==="proto"){P[_e]=Te,Pe.g=7;break}if(De.type!=="texture")throw Error("Unknown output config type: '"+De.type+"'");return le=s.s[_e],le||(le=new Le(s.h,s.D),s.s[_e]=le),J(Pe,Ze(le,Te,s.G),13);case 13:Ee=Pe.h,P[_e]=Ee;case 7:De.transform&&P[_e]&&(P[_e]=De.transform(P[_e])),Pe.g=3;break;case 14:Re[ke]=Pe.h;case 3:G=ye.next(),Pe.g=2;break;case 4:return Pe.return(P)}})}function X(s,_,T){var P;return me(function(U){return typeof T=="number"||T instanceof Uint8Array||T instanceof s.h.Uint8BlobList?U.return(T):T instanceof s.h.Texture2dDataOut?(P=s.s[_],P||(P=new Le(s.h,s.D),s.s[_]=P),U.return(Ze(P,T,s.G))):U.return(void 0)})}function z(s,_){for(var T=_.name||"$",P=[].concat(L(_.wants)),U=new s.h.StringList,H=O(_.wants),G=H.next();!G.done;G=H.next())U.push_back(G.value);H=s.h.PacketListener.implement({onResults:function(re){for(var Z={},ye=0;ye<_.wants.length;++ye)Z[P[ye]]=re.get(ye);var _e=s.listeners[T];_e&&(s.C=W(s,Z,_.outs).then(function(De){De=_e(De);for(var Te=0;Te<_.wants.length;++Te){var le=Z[P[Te]];typeof le=="object"&&le.hasOwnProperty&&le.hasOwnProperty("delete")&&le.delete()}De&&(s.C=De)}))}}),s.i.attachMultiListener(U,H),U.delete()}i.onResults=function(s,_){this.listeners[_||"$"]=s},je("Solution",jt),je("OptionType",{BOOL:0,NUMBER:1,$:2,0:"BOOL",1:"NUMBER",2:"STRING"});function q(s){switch(s===void 0&&(s=0),s){case 1:return"pose_landmark_full.tflite";case 2:return"pose_landmark_heavy.tflite";default:return"pose_landmark_lite.tflite"}}function ae(s){var _=this;s=s||{},this.g=new jt({locateFile:s.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:q(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:Ne},poseWorldLandmarks:{type:"proto",stream:"world_landmarks",transform:Ne},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 P,U,H;return me(function(G){return G.g==1?(P=q(T),U="third_party/mediapipe/modules/pose_landmark/"+P,J(G,j(_.g,P),2)):(H=G.h,_.g.overrideFile(U,H),G.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"}}}})}i=ae.prototype,i.reset=function(){this.g.reset()},i.close=function(){return this.g.close(),Promise.resolve()},i.onResults=function(s){this.g.onResults(s)},i.initialize=function(){var s=this;return me(function(_){return J(_,s.g.initialize(),0)})},i.send=function(s,_){var T=this;return me(function(P){return J(P,T.g.send(s,_),0)})},i.setOptions=function(s){this.g.setOptions(s)},je("Pose",ae),je("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]]),je("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}),je("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}),je("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}),je("POSE_LANDMARKS_NEUTRAL",{NOSE:0}),je("VERSION","0.5.1635988162")}).call(Oi);const Zr=class Zr{constructor(){this.mediapipeMap_=new Map}getVersion(t){switch(t){case"face_detection":return Si.VERSION;case"face_mesh":return Ri.VERSION;case"hands":return Ai.VERSION;case"holistic":return Ti.VERSION;case"objectron":return Fi.VERSION;case"selfie_segmentation":return Ei.VERSION;case"pose":return Oi.VERSION;default:return""}}initialize(t){return new Promise(async(n,p)=>{if(t.mediaPipeModelConfigArray.length==0){p("no model was selected");return}for(let y=0;y<t.mediaPipeModelConfigArray.length;y++){const R=t.mediaPipeModelConfigArray[y];if(this.mediapipeMap_.has(R.modelType)){p("setting same type is not supported");return}if(typeof R.listener!="function"){p(`[${R.modelType}] ResultsListener must be provided`);return}let k;switch(R.modelType){case"face_mesh":k=new Ri.FaceMesh({locateFile:(O,L)=>(R.assetsUri||Zr.defaultAssetsBaseUrl+"face_mesh/"+this.getVersion("face_mesh"))+"/"+O});break;case"face_detection":k=new Si.FaceDetection({locateFile:(O,L)=>(R.assetsUri||Zr.defaultAssetsBaseUrl+"face_detection/"+this.getVersion("face_detection"))+"/"+O});break;case"hands":k=new Ai.Hands({locateFile:(O,L)=>(R.assetsUri||Zr.defaultAssetsBaseUrl+"hands/"+this.getVersion("hands"))+"/"+O});break;case"holistic":k=new Ti.Holistic({locateFile:(O,L)=>(R.assetsUri||Zr.defaultAssetsBaseUrl+"holistic/"+this.getVersion("holistic"))+"/"+O});break;case"objectron":k=new Fi.Objectron({locateFile:(O,L)=>(R.assetsUri||Zr.defaultAssetsBaseUrl+"objectron/"+this.getVersion("objectron"))+"/"+O});break;case"selfie_segmentation":k=new Ei.SelfieSegmentation({locateFile:(O,L)=>(R.assetsUri||Zr.defaultAssetsBaseUrl+"selfie_segmentation/"+this.getVersion("selfie_segmentation"))+"/"+O});break;case"pose":k=new Oi.Pose({locateFile:(O,L)=>(R.assetsUri||Zr.defaultAssetsBaseUrl+"pose/"+this.getVersion("pose"))+"/"+O});break;default:p("unknown model type");return}k.onResults(R.listener),R.options&&k.setOptions(R.options);try{await k.initialize(),this.mediapipeMap_.set(R.modelType,k)}catch(O){p(O);return}}n()})}close(t){return new Promise((n,p)=>{let y=[];if(t){let R=this.mediapipeMap_.get(t);if(R)this.mediapipeMap_.delete(t),y.push(R.close());else{p("model not exit");return}}else{for(const[R,k]of this.mediapipeMap_.entries())y.push(k.close());this.mediapipeMap_.clear()}Promise.all(y).then(()=>{n()}).catch(R=>{p(R)})})}send(t,n){return new Promise((p,y)=>{let R=[];if(n){let k=this.mediapipeMap_.get(n);if(k)R.push(k.send({image:t}));else{y("model not exit");return}}else for(const[k,O]of this.mediapipeMap_.entries())R.push(O.send({image:t}));Promise.all(R).then(()=>{p()}).catch(k=>{y(k)})})}reset(t){if(t){let n=this.mediapipeMap_.get(t);n&&typeof n.reset=="function"&&n.reset()}else for(const[n,p]of this.mediapipeMap_.entries())p&&typeof p.reset=="function"&&p.reset()}};Zr.defaultAssetsBaseUrl="https://d3opqjmqzxf057.cloudfront.net/ml/mediapipe/";let Ao=Zr;const sn=new WeakMap,wn=new WeakMap,tn=new WeakMap,Ii=Symbol("anyProducer"),js=Promise.resolve(),ki=Symbol("listenerAdded"),Pi=Symbol("listenerRemoved");let Ci=!1,To=!1;const Mi=i=>typeof i=="string"||typeof i=="symbol"||typeof i=="number";function Pn(i){if(!Mi(i))throw new TypeError("`eventName` must be a string, symbol, or number")}function ji(i){if(typeof i!="function")throw new TypeError("listener must be a function")}function Cn(i,t){const n=wn.get(i);if(n.has(t))return n.get(t)}function Qn(i,t){const n=Mi(t)?t:Ii,p=tn.get(i);if(p.has(n))return p.get(n)}function ac(i,t,n){const p=tn.get(i);if(p.has(t))for(const y of p.get(t))y.enqueue(n);if(p.has(Ii)){const y=Promise.all([t,n]);for(const R of p.get(Ii))R.enqueue(y)}}function Ls(i,t){t=Array.isArray(t)?t:[t];let n=!1,p=()=>{},y=[];const R={enqueue(k){y.push(k),p()},finish(){n=!0,p()}};for(const k of t){let O=Qn(i,k);O||(O=new Set,tn.get(i).set(k,O)),O.add(R)}return{async next(){return y?y.length===0?n?(y=void 0,this.next()):(await new Promise(k=>{p=k}),this.next()):{done:!1,value:await y.shift()}:{done:!0}},async return(k){y=void 0;for(const O of t){const L=Qn(i,O);L&&(L.delete(R),L.size===0&&tn.get(i).delete(O))}return p(),arguments.length>0?{done:!0,value:await k}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Us(i){if(i===void 0)return Bs;if(!Array.isArray(i))throw new TypeError("`methodNames` must be an array of strings");for(const t of i)if(!Bs.includes(t))throw typeof t!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${t} is not Emittery method`);return i}const Mn=i=>i===ki||i===Pi;function Li(i,t,n){if(Mn(t))try{Ci=!0,i.emit(t,n)}finally{Ci=!1}}let Jn=class vs{static mixin(t,n){return n=Us(n),p=>{if(typeof p!="function")throw new TypeError("`target` must be function");for(const k of n)if(p.prototype[k]!==void 0)throw new Error(`The property \`${k}\` already exists on \`target\``);function y(){return Object.defineProperty(this,t,{enumerable:!1,value:new vs}),this[t]}Object.defineProperty(p.prototype,t,{enumerable:!1,get:y});const R=k=>function(...O){return this[t][k](...O)};for(const k of n)Object.defineProperty(p.prototype,k,{enumerable:!1,value:R(k)});return p}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return To;const{env:t}=globalThis.process??{env:{}};return t.DEBUG==="emittery"||t.DEBUG==="*"||To}static set isDebugEnabled(t){To=t}constructor(t={}){sn.set(this,new Set),wn.set(this,new Map),tn.set(this,new Map),tn.get(this).set(Ii,new Set),this.debug=t.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(n,p,y,R)=>{try{R=JSON.stringify(R)}catch{R=`Object with the following keys failed to stringify: ${Object.keys(R).join(",")}`}(typeof y=="symbol"||typeof y=="number")&&(y=y.toString());const k=new Date,O=`${k.getHours()}:${k.getMinutes()}:${k.getSeconds()}.${k.getMilliseconds()}`;console.log(`[${O}][emittery:${n}][${p}] Event Name: ${y}
|
|
122
|
-
data: ${R}`)})}logIfDebugEnabled(t,n,p){(vs.isDebugEnabled||this.debug.enabled)&&this.debug.logger(t,this.debug.name,n,p)}on(t,n,{signal:p}={}){ji(n),t=Array.isArray(t)?t:[t];for(const R of t){Pn(R);let k=Cn(this,R);k||(k=new Set,wn.get(this).set(R,k)),k.add(n),this.logIfDebugEnabled("subscribe",R,void 0),Mn(R)||Li(this,ki,{eventName:R,listener:n})}const y=()=>{this.off(t,n),p?.removeEventListener("abort",y)};return p?.addEventListener("abort",y,{once:!0}),p?.aborted&&y(),y}off(t,n){ji(n),t=Array.isArray(t)?t:[t];for(const p of t){Pn(p);const y=Cn(this,p);y&&(y.delete(n),y.size===0&&wn.get(this).delete(p)),this.logIfDebugEnabled("unsubscribe",p,void 0),Mn(p)||Li(this,Pi,{eventName:p,listener:n})}}once(t,n){if(n!==void 0&&typeof n!="function")throw new TypeError("predicate must be a function");let p;const y=new Promise(R=>{p=this.on(t,k=>{n&&!n(k)||(p(),R(k))})});return y.off=p,y}events(t){t=Array.isArray(t)?t:[t];for(const n of t)Pn(n);return Ls(this,t)}async emit(t,n){if(Pn(t),Mn(t)&&!Ci)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",t,n),ac(this,t,n);const p=Cn(this,t)??new Set,y=sn.get(this),R=[...p],k=Mn(t)?[]:[...y];await js,await Promise.all([...R.map(async O=>{if(p.has(O))return O(n)}),...k.map(async O=>{if(y.has(O))return O(t,n)})])}async emitSerial(t,n){if(Pn(t),Mn(t)&&!Ci)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",t,n);const p=Cn(this,t)??new Set,y=sn.get(this),R=[...p],k=[...y];await js;for(const O of R)p.has(O)&&await O(n);for(const O of k)y.has(O)&&await O(t,n)}onAny(t,{signal:n}={}){ji(t),this.logIfDebugEnabled("subscribeAny",void 0,void 0),sn.get(this).add(t),Li(this,ki,{listener:t});const p=()=>{this.offAny(t),n?.removeEventListener("abort",p)};return n?.addEventListener("abort",p,{once:!0}),n?.aborted&&p(),p}anyEvent(){return Ls(this)}offAny(t){ji(t),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),Li(this,Pi,{listener:t}),sn.get(this).delete(t)}clearListeners(t){t=Array.isArray(t)?t:[t];for(const n of t)if(this.logIfDebugEnabled("clear",n,void 0),Mi(n)){const p=Cn(this,n);p&&p.clear();const y=Qn(this,n);if(y){for(const R of y)R.finish();y.clear()}}else{sn.get(this).clear();for(const[p,y]of wn.get(this).entries())y.clear(),wn.get(this).delete(p);for(const[p,y]of tn.get(this).entries()){for(const R of y)R.finish();y.clear(),tn.get(this).delete(p)}}}listenerCount(t){t=Array.isArray(t)?t:[t];let n=0;for(const p of t){if(Mi(p)){n+=sn.get(this).size+(Cn(this,p)?.size??0)+(Qn(this,p)?.size??0)+(Qn(this)?.size??0);continue}p!==void 0&&Pn(p),n+=sn.get(this).size;for(const y of wn.get(this).values())n+=y.size;for(const y of tn.get(this).values())n+=y.size}return n}bindMethods(t,n){if(typeof t!="object"||t===null)throw new TypeError("`target` must be an object");n=Us(n);for(const p of n){if(t[p]!==void 0)throw new Error(`The property \`${p}\` already exists on \`target\``);Object.defineProperty(t,p,{enumerable:!1,value:this[p].bind(this)})}}};const Bs=Object.getOwnPropertyNames(Jn.prototype).filter(i=>i!=="constructor");Object.defineProperty(Jn,"listenerAdded",{value:ki,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Jn,"listenerRemoved",{value:Pi,writable:!1,enumerable:!0,configurable:!1});function So(i,t){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let n=globalThis.vonage.workerizer;return n[i]||(n[i]=t),n[i]}const jn=So("globals",{});var Xr=(i=>(i.INIT="INIT",i.FORWARD="FORWARD",i.TERMINATE="TERMINATE",i.GLOBALS_SYNC="GLOBALS_SYNC",i.EVENT="EVENT",i))(Xr||{});function Ns(i){return[ImageBitmap,ReadableStream,WritableStream].some(n=>i instanceof n)}let uc=0;function Ui(i,t,n,p,y){const R=uc++;return i.postMessage({id:R,type:t,functionName:n,args:p},p.filter(O=>Ns(O))),new Promise(O=>{y?.set(R,O)})}function Ln(i,t){const{id:n,type:p}=i,y=Array.isArray(t)?t:[t];postMessage({id:n,type:p,result:t},y.filter(R=>Ns(R)))}const Bi=So("workerized",{});function Ro(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function cc(){if(Ro())Ln({type:Xr.GLOBALS_SYNC},jn);else{const i=[];for(const t in Bi){const{worker:n,resolvers:p}=Bi[t].workerContext;n&&i.push(Ui(n,Xr.GLOBALS_SYNC,"",[jn],p))}await Promise.all(i)}}function Zn(i,t){if(Array.isArray(t))t.splice(0,t.length);else if(typeof t=="object")for(const n in t)delete t[n];for(const n in i)Array.isArray(i[n])?(t[n]=[],Zn(i[n],t[n])):typeof i[n]=="object"?(t[n]={},Zn(i[n],t[n])):t[n]=i[n]}async function lc(i,t,n,p){const y=new t;if(y.addEventListener("message",async({data:k})=>{var O,L,te,ue,pe,Oe,Me;switch(k.type){case Xr.GLOBALS_SYNC:k.id?((L=n.get((O=k.id)!=null?O:-1))==null||L(k.result),n.delete((te=k.id)!=null?te:-1)):(Zn((ue=k.result)!=null?ue:{},jn),await cc());break;case Xr.EVENT:const{result:ce}=k,he=ce;if(he?.name==null)throw"Missing event name";p(he.name,he.data);break;default:(Oe=n.get((pe=k.id)!=null?pe:-1))==null||Oe(k.result),n.delete((Me=k.id)!=null?Me:-1)}}),!await Ui(y,Xr.INIT,"",[i.workerId,jn],n))throw"Failed to instantiate workerized class";return y}const an=new WeakMap,xn=new WeakMap,rn=new WeakMap,Ni=Symbol("anyProducer"),Ds=Promise.resolve(),Di=Symbol("listenerAdded"),Gi=Symbol("listenerRemoved");let Wi=!1,Fo=!1;function Un(i){if(typeof i!="string"&&typeof i!="symbol"&&typeof i!="number")throw new TypeError("`eventName` must be a string, symbol, or number")}function zi(i){if(typeof i!="function")throw new TypeError("listener must be a function")}function Bn(i,t){const n=xn.get(i);if(n.has(t))return n.get(t)}function qn(i,t){const n=typeof t=="string"||typeof t=="symbol"||typeof t=="number"?t:Ni,p=rn.get(i);if(p.has(n))return p.get(n)}function fc(i,t,n){const p=rn.get(i);if(p.has(t))for(const y of p.get(t))y.enqueue(n);if(p.has(Ni)){const y=Promise.all([t,n]);for(const R of p.get(Ni))R.enqueue(y)}}function Gs(i,t){t=Array.isArray(t)?t:[t];let n=!1,p=()=>{},y=[];const R={enqueue(k){y.push(k),p()},finish(){n=!0,p()}};for(const k of t){let O=qn(i,k);O||(O=new Set,rn.get(i).set(k,O)),O.add(R)}return{async next(){return y?y.length===0?n?(y=void 0,this.next()):(await new Promise(k=>{p=k}),this.next()):{done:!1,value:await y.shift()}:{done:!0}},async return(k){y=void 0;for(const O of t){const L=qn(i,O);L&&(L.delete(R),L.size===0&&rn.get(i).delete(O))}return p(),arguments.length>0?{done:!0,value:await k}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Ws(i){if(i===void 0)return zs;if(!Array.isArray(i))throw new TypeError("`methodNames` must be an array of strings");for(const t of i)if(!zs.includes(t))throw typeof t!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${t} is not Emittery method`);return i}const Nn=i=>i===Di||i===Gi;function Hi(i,t,n){if(Nn(t))try{Wi=!0,i.emit(t,n)}finally{Wi=!1}}class _n{static mixin(t,n){return n=Ws(n),p=>{if(typeof p!="function")throw new TypeError("`target` must be function");for(const k of n)if(p.prototype[k]!==void 0)throw new Error(`The property \`${k}\` already exists on \`target\``);function y(){return Object.defineProperty(this,t,{enumerable:!1,value:new _n}),this[t]}Object.defineProperty(p.prototype,t,{enumerable:!1,get:y});const R=k=>function(...O){return this[t][k](...O)};for(const k of n)Object.defineProperty(p.prototype,k,{enumerable:!1,value:R(k)});return p}}static get isDebugEnabled(){var t,n;if(typeof((t=globalThis.process)==null?void 0:t.env)!="object")return Fo;const{env:p}=(n=globalThis.process)!=null?n:{env:{}};return p.DEBUG==="emittery"||p.DEBUG==="*"||Fo}static set isDebugEnabled(t){Fo=t}constructor(t={}){var n;an.set(this,new Set),xn.set(this,new Map),rn.set(this,new Map),rn.get(this).set(Ni,new Set),this.debug=(n=t.debug)!=null?n:{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(p,y,R,k)=>{try{k=JSON.stringify(k)}catch{k=`Object with the following keys failed to stringify: ${Object.keys(k).join(",")}`}(typeof R=="symbol"||typeof R=="number")&&(R=R.toString());const O=new Date,L=`${O.getHours()}:${O.getMinutes()}:${O.getSeconds()}.${O.getMilliseconds()}`;console.log(`[${L}][emittery:${p}][${y}] Event Name: ${R}
|
|
123
|
-
data: ${k}`)})}logIfDebugEnabled(t,n,p){(_n.isDebugEnabled||this.debug.enabled)&&this.debug.logger(t,this.debug.name,n,p)}on(t,n){zi(n),t=Array.isArray(t)?t:[t];for(const p of t){Un(p);let y=Bn(this,p);y||(y=new Set,xn.get(this).set(p,y)),y.add(n),this.logIfDebugEnabled("subscribe",p,void 0),Nn(p)||Hi(this,Di,{eventName:p,listener:n})}return this.off.bind(this,t,n)}off(t,n){zi(n),t=Array.isArray(t)?t:[t];for(const p of t){Un(p);const y=Bn(this,p);y&&(y.delete(n),y.size===0&&xn.get(this).delete(p)),this.logIfDebugEnabled("unsubscribe",p,void 0),Nn(p)||Hi(this,Gi,{eventName:p,listener:n})}}once(t){let n;const p=new Promise(y=>{n=this.on(t,R=>{n(),y(R)})});return p.off=n,p}events(t){t=Array.isArray(t)?t:[t];for(const n of t)Un(n);return Gs(this,t)}async emit(t,n){var p;if(Un(t),Nn(t)&&!Wi)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",t,n),fc(this,t,n);const y=(p=Bn(this,t))!=null?p:new Set,R=an.get(this),k=[...y],O=Nn(t)?[]:[...R];await Ds,await Promise.all([...k.map(async L=>{if(y.has(L))return L(n)}),...O.map(async L=>{if(R.has(L))return L(t,n)})])}async emitSerial(t,n){var p;if(Un(t),Nn(t)&&!Wi)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",t,n);const y=(p=Bn(this,t))!=null?p:new Set,R=an.get(this),k=[...y],O=[...R];await Ds;for(const L of k)y.has(L)&&await L(n);for(const L of O)R.has(L)&&await L(t,n)}onAny(t){return zi(t),this.logIfDebugEnabled("subscribeAny",void 0,void 0),an.get(this).add(t),Hi(this,Di,{listener:t}),this.offAny.bind(this,t)}anyEvent(){return Gs(this)}offAny(t){zi(t),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),Hi(this,Gi,{listener:t}),an.get(this).delete(t)}clearListeners(t){t=Array.isArray(t)?t:[t];for(const n of t)if(this.logIfDebugEnabled("clear",n,void 0),typeof n=="string"||typeof n=="symbol"||typeof n=="number"){const p=Bn(this,n);p&&p.clear();const y=qn(this,n);if(y){for(const R of y)R.finish();y.clear()}}else{an.get(this).clear();for(const[p,y]of xn.get(this).entries())y.clear(),xn.get(this).delete(p);for(const[p,y]of rn.get(this).entries()){for(const R of y)R.finish();y.clear(),rn.get(this).delete(p)}}}listenerCount(t){var n,p,y,R,k,O;t=Array.isArray(t)?t:[t];let L=0;for(const te of t){if(typeof te=="string"){L+=an.get(this).size+((p=(n=Bn(this,te))==null?void 0:n.size)!=null?p:0)+((R=(y=qn(this,te))==null?void 0:y.size)!=null?R:0)+((O=(k=qn(this))==null?void 0:k.size)!=null?O:0);continue}typeof te<"u"&&Un(te),L+=an.get(this).size;for(const ue of xn.get(this).values())L+=ue.size;for(const ue of rn.get(this).values())L+=ue.size}return L}bindMethods(t,n){if(typeof t!="object"||t===null)throw new TypeError("`target` must be an object");n=Ws(n);for(const p of n){if(t[p]!==void 0)throw new Error(`The property \`${p}\` already exists on \`target\``);Object.defineProperty(t,p,{enumerable:!1,value:this[p].bind(this)})}}}const zs=Object.getOwnPropertyNames(_n.prototype).filter(i=>i!=="constructor");Object.defineProperty(_n,"listenerAdded",{value:Di,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(_n,"listenerRemoved",{value:Gi,writable:!1,enumerable:!0,configurable:!1});function hc(i){return i.onAny&&i.emit}function dc(i){return i.prototype.onAny&&i.prototype.emit}let pc=0;async function gc(i,t,n){const y=dc(i)?new _n:{},R=pc++;return Object.getOwnPropertyNames(i.prototype).forEach(k=>{y[k]=(...O)=>Ui(t,Xr.FORWARD,k,O,n)}),y.terminate=async(...k)=>{const O=await Ui(t,Xr.TERMINATE,"",k,n);return delete Bi[R],t.terminate(),y.workerContext.worker=void 0,O},y.workerContext={id:R,worker:t,resolvers:n},Bi[R]=y,y}async function mc(i,t){const n=new Map;let p;const y=await lc(i,t,n,(R,k)=>{p?.emit&&p?.emit(R,k)});return p=await gc(i,y,n),p}async function yc(i,t){const{functionName:n,args:p}=i;if(!t.instance)throw"instance not initialized";if(!n)throw"missing function name to call";if(!t.instance[n])throw`undefined function [${n}] in class ${t.instance.constructor.workerId}`;Ln(i,await t.instance[n](...p??[]))}const Hs=So("registeredWorkers",{});function vc(i,t){t.workerId=i,Ro()&&(Hs[t.workerId]=t)}function bc(i,t){if(!i.args)throw"Missing className while initializing worker";const[n,p]=i.args,y=Hs[n];if(y)t.instance=new y(i.args.slice(1));else throw`unknown worker class ${n}`;Zn(p,jn),hc(t.instance)&&t.instance.onAny((R,k)=>{Ln({type:Xr.EVENT},{name:R,data:k})}),Ln(i,typeof t.instance!==void 0)}async function wc(i,t){const{args:n}=i;if(!t.instance)throw"instance not initialized";let p;t.instance.terminate&&(p=await t.instance.terminate(...n??[])),Ln(i,p)}function xc(i){if(!i.args)throw"Missing globals while syncing";Zn(i.args[0],jn),Ln(i,{})}function _c(){const i={};onmessage=async t=>{const n=t.data;switch(n.type){case Xr.INIT:bc(n,i);break;case Xr.FORWARD:yc(n,i);break;case Xr.TERMINATE:wc(n,i);break;case Xr.GLOBALS_SYNC:xc(n);break}}}Ro()&&_c();class Vs{static async createVideoReadable(t){return new Promise((n,p)=>{const y=document.createElement("video");let R=new AbortController,k=new AbortController;y.addEventListener("canplay",()=>{R.abort(),y.muted=!0,y.loop=!0,y.play().then(()=>{try{const O=y.captureStream(),L=new MediaStreamTrackProcessor(O.getVideoTracks()[0]);n(L.readable)}catch(O){p(O)}})},{once:!0,signal:k.signal}),y.addEventListener("error",O=>{k.abort(),p("loading error:"+O)},{once:!0,signal:R.signal}),y.crossOrigin="anonymous",y.src=t})}static async createImageCanvas(t){const p=await(await fetch(t)).blob();return await createImageBitmap(p)}}var Ec=Object.defineProperty,Ac=(i,t,n)=>t in i?Ec(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,Tc=(i,t,n)=>(Ac(i,t+"",n),n);const Sc="hlg.tokbox.com/prod/logging/vcp_webrtc",Rc="https://",Fc=1e4;let Vi;const Oc=new Uint8Array(16);function Ic(){if(!Vi&&(Vi=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Vi))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Vi(Oc)}const Ur=[];for(let i=0;i<256;++i)Ur.push((i+256).toString(16).slice(1));function kc(i,t=0){return(Ur[i[t+0]]+Ur[i[t+1]]+Ur[i[t+2]]+Ur[i[t+3]]+"-"+Ur[i[t+4]]+Ur[i[t+5]]+"-"+Ur[i[t+6]]+Ur[i[t+7]]+"-"+Ur[i[t+8]]+Ur[i[t+9]]+"-"+Ur[i[t+10]]+Ur[i[t+11]]+Ur[i[t+12]]+Ur[i[t+13]]+Ur[i[t+14]]+Ur[i[t+15]]).toLowerCase()}const Pc=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$s={randomUUID:Pc};function Cc(i,t,n){if($s.randomUUID&&!t&&!i)return $s.randomUUID();i=i||{};const p=i.random||(i.rng||Ic)();return p[6]=p[6]&15|64,p[8]=p[8]&63|128,kc(p)}function Oo(i,t){globalThis.vonage||(globalThis.vonage={}),globalThis.vonage.workerizer||(globalThis.vonage.workerizer={});let n=globalThis.vonage.workerizer;return n[i]||(n[i]=t),n[i]}const un=Oo("globals",{});var En=(i=>(i.INIT="INIT",i.FORWARD="FORWARD",i.TERMINATE="TERMINATE",i.GLOBALS_SYNC="GLOBALS_SYNC",i))(En||{});function Ys(i){return[ImageBitmap,ReadableStream,WritableStream].some(t=>i instanceof t)}let Mc=0;function jc(i,t,n,p,y){const R=Mc++;return i.postMessage({id:R,type:t,functionName:n,args:p},p.filter(k=>Ys(k))),new Promise(k=>{y?.set(R,k)})}function ei(i,t){const{id:n,type:p}=i,y=Array.isArray(t)?t:[t];postMessage({id:n,type:p,result:t},y.filter(R=>Ys(R)))}const Xs=Oo("workerized",{});function Ks(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function Lc(){if(Ks())ei({type:En.GLOBALS_SYNC},un);else{const i=[];for(const t in Xs){const{worker:n,resolvers:p}=Xs[t].workerContext;n&&i.push(jc(n,En.GLOBALS_SYNC,"",[un],p))}await Promise.all(i)}}function $i(i,t){if(Array.isArray(t))t.splice(0,t.length);else if(typeof t=="object")for(const n in t)delete t[n];for(const n in i)Array.isArray(i[n])?(t[n]=[],$i(i[n],t[n])):typeof i[n]=="object"?(t[n]={},$i(i[n],t[n])):t[n]=i[n]}async function Uc(i,t){const{functionName:n,args:p}=i;if(!t.instance)throw"instance not initialized";if(!n)throw"missing function name to call";if(!t.instance[n])throw`undefined function [${n}] in class ${t.instance.constructor.workerId}`;ei(i,await t.instance[n](...p??[]))}const Bc=Oo("registeredWorkers",{});function Nc(i,t){if(!i.args)throw"Missing className while initializing worker";const[n,p]=i.args,y=Bc[n];if(y)t.instance=new y(i.args.slice(1));else throw`unknown worker class ${n}`;$i(p,un),ei(i,typeof t.instance!==void 0)}async function Dc(i,t){const{args:n}=i;if(!t.instance)throw"instance not initialized";let p;t.instance.terminate&&(p=await t.instance.terminate(...n??[])),ei(i,p)}function Gc(i){if(!i.args)throw"Missing globals while syncing";$i(i.args[0],un),ei(i,{})}function Wc(){const i={};onmessage=async t=>{const n=t.data;switch(n.type){case En.INIT:Nc(n,i);break;case En.FORWARD:Uc(n,i);break;case En.TERMINATE:Dc(n,i);break;case En.GLOBALS_SYNC:Gc(n);break}}}Ks()&&Wc();function zc(i,t){return un[i]||(un[i]=t),[()=>un[i],async n=>{un[i]=n,await Lc()}]}function Hc(i,t){return zc(i,t)}const[Vc]=Hc("metadata");function Io(){return Vc()}class $c{constructor(t){Tc(this,"uuid",Cc()),this.config=t}async send(t){var n,p,y;const{appId:R,sourceType:k}=(n=Io())!=null?n:{};if(!R||!k)return"metadata missing";const O=new AbortController,L=setTimeout(()=>O.abort(),Fc);return await((y=(p=this.config)==null?void 0:p.fetch)!=null?y:fetch)(this.getUrl(),{method:"POST",headers:this.getHeaders(),body:JSON.stringify(this.buildReport(t)),signal:O.signal}),clearTimeout(L),"success"}getUrl(){var t;let n=(t=Io().proxyUrl)!=null?t:Rc;return n+=(n.at(-1)==="/"?"":"/")+Sc,n}getHeaders(){return{"Content-Type":"application/json"}}buildReport(t){const n=Io();return{guid:this.uuid,...t,applicationId:n.appId,timestamp:Date.now(),proxyUrl:n.proxyUrl,source:n.sourceType}}}const Yc="7.0.0-alpha.1";class ko{constructor(){const t=new OffscreenCanvas(0,0),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw"Fail to retrieve 2d context";this.canvas=t,this.context=n}setFlickeringOptions(t){}enablePostProcessing(){}disablePostProcessing(){}async profileWebgl(t){return[]}async render(t,n){return this.canvas}resizeCanvas(t){const{width:n,height:p}=t;this.canvas.width=n,this.canvas.height=p}renderSilhouette(t,n,p="none"){const{width:y,height:R}=t;this.context.save(),this.context.drawImage(n,0,0,n.width,n.height,0,0,y,R),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(n,0,0,n.width,n.height,0,0,y,R),this.context.globalCompositeOperation="source-in",this.context.filter=p,this.context.drawImage(t,0,0,y,R,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class Xc extends ko{constructor(t){super(),this.radius=t}async render(t,n){super.resizeCanvas(t);const p=await createImageBitmap(n);return this.renderSilhouette(t,p),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,n)}}class Kc extends ko{constructor(t){super(),this.radius=t}async render(t,n){super.resizeCanvas(t);const p=await createImageBitmap(n);return this.renderSilhouette(t,p,`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,n)}}class Qc extends ko{setBackgroundImage(t){this.backgroundImage=t}async render(t,n){super.resizeCanvas(t);const p=await createImageBitmap(n);return this.renderSilhouette(t,p),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,n)}}const Po=5120,ti=5121,Co=5122,Mo=5123,jo=5124,Lo=5125,Uo=5126,Jc=32819,Zc=32820,qc=33635,el=5131,tl=33640,rl=35899,nl=35902,il=36269,ol=34042,Qs={};{const i=Qs;i[Po]=Int8Array,i[ti]=Uint8Array,i[Co]=Int16Array,i[Mo]=Uint16Array,i[jo]=Int32Array,i[Lo]=Uint32Array,i[Uo]=Float32Array,i[Jc]=Uint16Array,i[Zc]=Uint16Array,i[qc]=Uint16Array,i[el]=Uint16Array,i[tl]=Uint32Array,i[rl]=Uint32Array,i[nl]=Uint32Array,i[il]=Uint32Array,i[ol]=Uint32Array}function Bo(i){if(i instanceof Int8Array)return Po;if(i instanceof Uint8Array||i instanceof Uint8ClampedArray)return ti;if(i instanceof Int16Array)return Co;if(i instanceof Uint16Array)return Mo;if(i instanceof Int32Array)return jo;if(i instanceof Uint32Array)return Lo;if(i instanceof Float32Array)return Uo;throw new Error("unsupported typed array type")}function Js(i){if(i===Int8Array)return Po;if(i===Uint8Array||i===Uint8ClampedArray)return ti;if(i===Int16Array)return Co;if(i===Uint16Array)return Mo;if(i===Int32Array)return jo;if(i===Uint32Array)return Lo;if(i===Float32Array)return Uo;throw new Error("unsupported typed array type")}function Zs(i){const t=Qs[i];if(!t)throw new Error("unknown gl type");return t}const Yi=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 qs(...i){console.error(...i)}const ea=new Map;function Xi(i,t){if(!i||typeof i!="object")return!1;let n=ea.get(t);n||(n=new WeakMap,ea.set(t,n));let p=n.get(i);if(p===void 0){const y=Object.prototype.toString.call(i);p=y.substring(8,y.length-1)===t,n.set(i,p)}return p}function sl(i,t){return typeof WebGLBuffer<"u"&&Xi(t,"WebGLBuffer")}function al(i,t){return typeof WebGLRenderbuffer<"u"&&Xi(t,"WebGLRenderbuffer")}function No(i,t){return typeof WebGLTexture<"u"&&Xi(t,"WebGLTexture")}function ul(i,t){return typeof WebGLSampler<"u"&&Xi(t,"WebGLSampler")}const ta=35044,An=34962,cl=34963,ll=34660,fl=5120,hl=5121,dl=5122,pl=5123,gl=5124,ml=5125,ra=5126,na={attribPrefix:""};function yl(i,t,n,p,y){i.bindBuffer(t,n),i.bufferData(t,p,y||ta)}function ia(i,t,n,p){if(sl(i,t))return t;n=n||An;const y=i.createBuffer();return yl(i,n,y,t,p),y}function oa(i){return i==="indices"}function vl(i){return i===Int8Array||i===Uint8Array}function bl(i){return i.length?i:i.data}const wl=/coord|texture/i,xl=/color|colour/i;function _l(i,t){let n;if(wl.test(i)?n=2:xl.test(i)?n=4:n=3,t%n>0)throw new Error(`Can not guess numComponents for attribute '${i}'. Tried ${n} but ${t} values is not evenly divisible by ${n}. You should specify it.`);return n}function El(i,t,n){return i.numComponents||i.size||_l(t,n||bl(i).length)}function sa(i,t){if(Yi(i))return i;if(Yi(i.data))return i.data;Array.isArray(i)&&(i={data:i});let n=i.type?Do(i.type):void 0;return n||(oa(t)?n=Uint16Array:n=Float32Array),new n(i.data)}function Al(i){return typeof i=="number"?i:i?Js(i):ra}function Do(i){return typeof i=="number"?Zs(i):i||Float32Array}function Tl(i,t){return{buffer:t.buffer,numValues:24,type:Al(t.type),arrayType:Do(t.type)}}function Sl(i,t){const n=t.data||t,p=Do(t.type),y=n*p.BYTES_PER_ELEMENT,R=i.createBuffer();return i.bindBuffer(An,R),i.bufferData(An,y,t.drawType||ta),{buffer:R,numValues:n,type:Js(p),arrayType:p}}function Rl(i,t,n){const p=sa(t,n);return{arrayType:p.constructor,buffer:ia(i,p,void 0,t.drawType),type:Bo(p),numValues:0}}function Fl(i,t){const n={};return Object.keys(t).forEach(function(p){if(!oa(p)){const y=t[p],R=y.attrib||y.name||y.attribName||na.attribPrefix+p;if(y.value){if(!Array.isArray(y.value)&&!Yi(y.value))throw new Error("array.value is not array or typedarray");n[R]={value:y.value}}else{let k;y.buffer&&y.buffer instanceof WebGLBuffer?k=Tl:typeof y=="number"||typeof y.data=="number"?k=Sl:k=Rl;const{buffer:O,type:L,numValues:te,arrayType:ue}=k(i,y,p),pe=y.normalize!==void 0?y.normalize:vl(ue),Oe=El(y,p,te);n[R]={buffer:O,numComponents:Oe,type:L,normalize:pe,stride:y.stride||0,offset:y.offset||0,divisor:y.divisor===void 0?void 0:y.divisor,drawType:y.drawType}}}}),i.bindBuffer(An,null),n}function Ol(i,t){return t===fl||t===hl?1:t===dl||t===pl?2:t===gl||t===ml||t===ra?4:0}const Go=["position","positions","a_position"];function Il(i,t){let n,p;for(p=0;p<Go.length&&(n=Go[p],!(n in t||(n=na.attribPrefix+n,n in t)));++p);p===Go.length&&(n=Object.keys(t)[0]);const y=t[n];if(!y.buffer)return 1;i.bindBuffer(An,y.buffer);const R=i.getBufferParameter(An,ll);i.bindBuffer(An,null);const k=Ol(i,y.type),O=R/k,L=y.numComponents||y.size,te=O/L;if(te%1!==0)throw new Error(`numComponents ${L} not correct for length ${length}`);return te}function kl(i,t,n){const p=Fl(i,t),y=Object.assign({},n||{});y.attribs=Object.assign({},n?n.attribs:{},p);const R=t.indices;if(R){const k=sa(R,"indices");y.indices=ia(i,k,cl),y.numElements=k.length,y.elementType=Bo(k)}else y.numElements||(y.numElements=Il(i,y.attribs));return y}function ri(i){return!!i.texStorage2D}const aa=(function(){const i={},t={};function n(p){const y=p.constructor.name;if(!i[y]){for(const R in p)if(typeof p[R]=="number"){const k=t[p[R]];t[p[R]]=k?`${k} | ${R}`:R}i[y]=!0}}return function(y,R){return n(y),t[R]||(typeof R=="number"?`0x${R.toString(16)}`:R)}})(),cn={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},ni=Yi,ua=(function(){let i;return function(){return i=i||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),i}})(),ca=6406,Jr=6407,gr=6408,la=6409,fa=6410,ii=6402,ha=34041,Ki=33071,Pl=9728,Cl=9729,ln=3553,fn=34067,Tn=32879,Sn=35866,Wo=34069,Ml=34070,jl=34071,Ll=34072,Ul=34073,Bl=34074,zo=10241,Ho=10240,Qi=10242,Ji=10243,da=32882,Nl=33082,Dl=33083,Gl=33084,Wl=33085,zl=34892,Hl=34893,Vo=3317,pa=3314,ga=32878,ma=3316,ya=3315,va=32877,Vl=37443,$l=37441,Yl=37440,Xl=33321,Kl=36756,Ql=33325,Jl=33326,Zl=33330,ql=33329,ef=33338,tf=33337,rf=33340,nf=33339,of=33323,sf=36757,af=33327,uf=33328,cf=33336,lf=33335,ff=33332,hf=33331,df=33334,pf=33333,gf=32849,mf=35905,yf=36194,vf=36758,bf=35898,wf=35901,xf=34843,_f=34837,Ef=36221,Af=36239,Tf=36215,Sf=36233,Rf=36209,Ff=36227,Of=32856,If=35907,kf=36759,Pf=32855,Cf=32854,Mf=32857,jf=34842,Lf=34836,Uf=36220,Bf=36238,Nf=36975,Df=36214,Gf=36232,Wf=36226,zf=36208,Hf=33189,Vf=33190,$f=36012,Yf=36013,Xf=35056,hn=5120,cr=5121,Zi=5122,Dn=5123,qi=5124,Rn=5125,Dr=5126,ba=32819,wa=32820,xa=33635,Kr=5131,oi=36193,$o=33640,Kf=35899,Qf=35902,Jf=36269,Zf=34042,eo=33319,Gn=33320,to=6403,Wn=36244,zn=36248,Fn=36249;let Yo;function ro(i){if(!Yo){const t={};t[ca]={textureFormat:ca,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[cr,Kr,oi,Dr]},t[la]={textureFormat:la,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[cr,Kr,oi,Dr]},t[fa]={textureFormat:fa,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[cr,Kr,oi,Dr]},t[Jr]={textureFormat:Jr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[cr,Kr,oi,Dr,xa]},t[gr]={textureFormat:gr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[cr,Kr,oi,Dr,ba,wa]},t[ii]={textureFormat:ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Rn,Dn]},t[Xl]={textureFormat:to,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[cr]},t[Kl]={textureFormat:to,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[hn]},t[Ql]={textureFormat:to,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[Dr,Kr]},t[Jl]={textureFormat:to,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[Dr]},t[Zl]={textureFormat:Wn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[cr]},t[ql]={textureFormat:Wn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[hn]},t[ff]={textureFormat:Wn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Dn]},t[hf]={textureFormat:Wn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Zi]},t[df]={textureFormat:Wn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Rn]},t[pf]={textureFormat:Wn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[qi]},t[of]={textureFormat:eo,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[cr]},t[sf]={textureFormat:eo,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[hn]},t[af]={textureFormat:eo,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[Dr,Kr]},t[uf]={textureFormat:eo,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[Dr]},t[cf]={textureFormat:Gn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[cr]},t[lf]={textureFormat:Gn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[hn]},t[ef]={textureFormat:Gn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Dn]},t[tf]={textureFormat:Gn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Zi]},t[rf]={textureFormat:Gn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Rn]},t[nf]={textureFormat:Gn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[qi]},t[gf]={textureFormat:Jr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[cr]},t[mf]={textureFormat:Jr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[cr]},t[yf]={textureFormat:Jr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[cr,xa]},t[vf]={textureFormat:Jr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[hn]},t[bf]={textureFormat:Jr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[Dr,Kr,Kf]},t[wf]={textureFormat:Jr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[Dr,Kr,Qf]},t[xf]={textureFormat:Jr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[Dr,Kr]},t[_f]={textureFormat:Jr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[Dr]},t[Ef]={textureFormat:zn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[cr]},t[Af]={textureFormat:zn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[hn]},t[Tf]={textureFormat:zn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Dn]},t[Sf]={textureFormat:zn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Zi]},t[Rf]={textureFormat:zn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[Rn]},t[Ff]={textureFormat:zn,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[qi]},t[Of]={textureFormat:gr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[cr]},t[If]={textureFormat:gr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[cr]},t[kf]={textureFormat:gr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[hn]},t[Pf]={textureFormat:gr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[cr,wa,$o]},t[Cf]={textureFormat:gr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[cr,ba]},t[Mf]={textureFormat:gr,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[$o]},t[jf]={textureFormat:gr,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[Dr,Kr]},t[Lf]={textureFormat:gr,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[Dr]},t[Uf]={textureFormat:Fn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[cr]},t[Bf]={textureFormat:Fn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[hn]},t[Nf]={textureFormat:Fn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[$o]},t[Df]={textureFormat:Fn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Dn]},t[Gf]={textureFormat:Fn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Zi]},t[Wf]={textureFormat:Fn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[qi]},t[zf]={textureFormat:Fn,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[Rn]},t[Hf]={textureFormat:ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Dn,Rn]},t[Vf]={textureFormat:ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Rn]},t[$f]={textureFormat:ii,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Dr]},t[Xf]={textureFormat:ha,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Zf]},t[Yf]={textureFormat:ha,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Jf]},Object.keys(t).forEach(function(n){const p=t[n];p.bytesPerElementMap={},p.bytesPerElement.forEach(function(y,R){const k=p.type[R];p.bytesPerElementMap[k]=y})}),Yo=t}return Yo[i]}function qf(i,t){const n=ro(i);if(!n)throw"unknown internal format";const p=n.bytesPerElementMap[t];if(p===void 0)throw"unknown internal format";return p}function si(i){const t=ro(i);if(!t)throw"unknown internal format";return{format:t.textureFormat,type:t.type[0]}}function _a(i){return(i&i-1)===0}function e2(i,t,n,p){if(!ri(i))return _a(t)&&_a(n);const y=ro(p);if(!y)throw"unknown internal format";return y.colorRenderable&&y.textureFilterable}function t2(i){const t=ro(i);if(!t)throw"unknown internal format";return t.textureFilterable}function r2(i,t,n){return ni(t)?Bo(t):n||cr}function no(i,t,n,p,y){if(y%1!==0)throw"can't guess dimensions";if(!n&&!p){const R=Math.sqrt(y/(t===fn?6:1));R%1===0?(n=R,p=R):(n=y,p=1)}else if(p){if(!n&&(n=y/p,n%1))throw"can't guess dimensions"}else if(p=y/n,p%1)throw"can't guess dimensions";return{width:n,height:p}}function Hn(i,t){t.colorspaceConversion!==void 0&&i.pixelStorei(Vl,t.colorspaceConversion),t.premultiplyAlpha!==void 0&&i.pixelStorei($l,t.premultiplyAlpha),t.flipY!==void 0&&i.pixelStorei(Yl,t.flipY)}function Ea(i){i.pixelStorei(Vo,4),ri(i)&&(i.pixelStorei(pa,0),i.pixelStorei(ga,0),i.pixelStorei(ma,0),i.pixelStorei(ya,0),i.pixelStorei(va,0))}function n2(i,t,n,p){p.minMag&&(n.call(i,t,zo,p.minMag),n.call(i,t,Ho,p.minMag)),p.min&&n.call(i,t,zo,p.min),p.mag&&n.call(i,t,Ho,p.mag),p.wrap&&(n.call(i,t,Qi,p.wrap),n.call(i,t,Ji,p.wrap),(t===Tn||ul(i,t))&&n.call(i,t,da,p.wrap)),p.wrapR&&n.call(i,t,da,p.wrapR),p.wrapS&&n.call(i,t,Qi,p.wrapS),p.wrapT&&n.call(i,t,Ji,p.wrapT),p.minLod!==void 0&&n.call(i,t,Nl,p.minLod),p.maxLod!==void 0&&n.call(i,t,Dl,p.maxLod),p.baseLevel!==void 0&&n.call(i,t,Gl,p.baseLevel),p.maxLevel!==void 0&&n.call(i,t,Wl,p.maxLevel),p.compareFunc!==void 0&&n.call(i,t,Hl,p.compareFunc),p.compareMode!==void 0&&n.call(i,t,zl,p.compareMode)}function Aa(i,t,n){const p=n.target||ln;i.bindTexture(p,t),n2(i,p,i.texParameteri,n)}function i2(i){return i=i||cn.textureColor,ni(i)?i:new Uint8Array([i[0]*255,i[1]*255,i[2]*255,i[3]*255])}function Xo(i,t,n,p,y,R){n=n||cn.textureOptions,R=R||gr;const k=n.target||ln;if(p=p||n.width,y=y||n.height,i.bindTexture(k,t),e2(i,p,y,R))i.generateMipmap(k);else{const O=t2(R)?Cl:Pl;i.texParameteri(k,zo,O),i.texParameteri(k,Ho,O),i.texParameteri(k,Qi,Ki),i.texParameteri(k,Ji,Ki)}}function ai(i){return i.auto===!0||i.auto===void 0&&i.level===void 0}function Ko(i,t){return t=t||{},t.cubeFaceOrder||[Wo,Ml,jl,Ll,Ul,Bl]}function Qo(i,t){const p=Ko(i,t).map(function(y,R){return{face:y,ndx:R}});return p.sort(function(y,R){return y.face-R.face}),p}function Ta(i,t,n,p){p=p||cn.textureOptions;const y=p.target||ln,R=p.level||0;let k=n.width,O=n.height;const L=p.internalFormat||p.format||gr,te=si(L),ue=p.format||te.format,pe=p.type||te.type;if(Hn(i,p),i.bindTexture(y,t),y===fn){const Oe=n.width,Me=n.height;let ce,he;if(Oe/6===Me)ce=Me,he=[0,0,1,0,2,0,3,0,4,0,5,0];else if(Me/6===Oe)ce=Oe,he=[0,0,0,1,0,2,0,3,0,4,0,5];else if(Oe/3===Me/2)ce=Oe/3,he=[0,0,1,0,2,0,0,1,1,1,2,1];else if(Oe/2===Me/3)ce=Oe/2,he=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can't figure out cube map from element: "+(n.src?n.src:n.nodeName);const Ge=ua();Ge?(Ge.canvas.width=ce,Ge.canvas.height=ce,k=ce,O=ce,Qo(i,p).forEach(function(Ve){const ct=he[Ve.ndx*2+0]*ce,J=he[Ve.ndx*2+1]*ce;Ge.drawImage(n,ct,J,ce,ce,0,0,ce,ce),i.texImage2D(Ve.face,R,L,ue,pe,Ge.canvas)}),Ge.canvas.width=1,Ge.canvas.height=1):typeof createImageBitmap<"u"&&(k=ce,O=ce,Qo(i,p).forEach(function(Ve){const ct=he[Ve.ndx*2+0]*ce,J=he[Ve.ndx*2+1]*ce;i.texImage2D(Ve.face,R,L,ce,ce,0,ue,pe,null),createImageBitmap(n,ct,J,ce,ce,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(Jt){Hn(i,p),i.bindTexture(y,t),i.texImage2D(Ve.face,R,L,ue,pe,Jt),ai(p)&&Xo(i,t,p,k,O,L)})}))}else if(y===Tn||y===Sn){const Oe=Math.min(n.width,n.height),Me=Math.max(n.width,n.height),ce=Me/Oe;if(ce%1!==0)throw"can not compute 3D dimensions of element";const he=n.width===Me?1:0,Ge=n.height===Me?1:0;i.pixelStorei(Vo,1),i.pixelStorei(pa,n.width),i.pixelStorei(ga,0),i.pixelStorei(va,0),i.texImage3D(y,R,L,Oe,Oe,Oe,0,ue,pe,null);for(let Ve=0;Ve<ce;++Ve){const ct=Ve*Oe*he,J=Ve*Oe*Ge;i.pixelStorei(ma,ct),i.pixelStorei(ya,J),i.texSubImage3D(y,R,0,0,Ve,Oe,Oe,1,ue,pe,n)}Ea(i)}else i.texImage2D(y,R,L,ue,pe,n);ai(p)&&Xo(i,t,p,k,O,L),Aa(i,t,p)}function ui(){}function o2(i){if(typeof document<"u"){const t=document.createElement("a");return t.href=i,t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol}else{const t=new URL(location.href).origin;return new URL(i,location.href).origin===t}}function s2(i,t){return t===void 0&&!o2(i)?"anonymous":t}function a2(i,t,n){n=n||ui;let p;if(t=t!==void 0?t:cn.crossOrigin,t=s2(i,t),typeof Image<"u"){p=new Image,t!==void 0&&(p.crossOrigin=t);const y=function(){p.removeEventListener("error",R),p.removeEventListener("load",k),p=null},R=function(){const L="couldn't load image: "+i;qs(L),n(L,p),y()},k=function(){n(null,p),y()};return p.addEventListener("error",R),p.addEventListener("load",k),p.src=i,p}else if(typeof ImageBitmap<"u"){let y,R;const k=function(){n(y,R)},O={};t&&(O.mode="cors"),fetch(i,O).then(function(L){if(!L.ok)throw L;return L.blob()}).then(function(L){return createImageBitmap(L,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(L){R=L,setTimeout(k)}).catch(function(L){y=L,setTimeout(k)}),p=null}return p}function Sa(i){return typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof ImageData<"u"&&i instanceof ImageData||typeof HTMLElement<"u"&&i instanceof HTMLElement}function Jo(i,t,n){return Sa(i)?(setTimeout(function(){n(null,i)}),i):a2(i,t,n)}function Zo(i,t,n){n=n||cn.textureOptions;const p=n.target||ln;if(i.bindTexture(p,t),n.color===!1)return;const y=i2(n.color);if(p===fn)for(let R=0;R<6;++R)i.texImage2D(Wo+R,0,gr,1,1,0,gr,cr,y);else p===Tn||p===Sn?i.texImage3D(p,0,gr,1,1,1,0,gr,cr,y):i.texImage2D(p,0,gr,1,1,0,gr,cr,y)}function u2(i,t,n,p){return p=p||ui,n=n||cn.textureOptions,Zo(i,t,n),n=Object.assign({},n),Jo(n.src,n.crossOrigin,function(R,k){R?p(R,t,k):(Ta(i,t,k,n),p(null,t,k))})}function c2(i,t,n,p){p=p||ui;const y=n.src;if(y.length!==6)throw"there must be 6 urls for a cubemap";const R=n.level||0,k=n.internalFormat||n.format||gr,O=si(k),L=n.format||O.format,te=n.type||cr,ue=n.target||ln;if(ue!==fn)throw"target must be TEXTURE_CUBE_MAP";Zo(i,t,n),n=Object.assign({},n);let pe=6;const Oe=[],Me=Ko(i,n);let ce;function he(Ge){return function(Ve,ct){--pe,Ve?Oe.push(Ve):ct.width!==ct.height?Oe.push("cubemap face img is not a square: "+ct.src):(Hn(i,n),i.bindTexture(ue,t),pe===5?Ko().forEach(function(J){i.texImage2D(J,R,k,L,te,ct)}):i.texImage2D(Ge,R,k,L,te,ct),ai(n)&&i.generateMipmap(ue)),pe===0&&p(Oe.length?Oe:void 0,t,ce)}}ce=y.map(function(Ge,Ve){return Jo(Ge,n.crossOrigin,he(Me[Ve]))})}function l2(i,t,n,p){p=p||ui;const y=n.src,R=n.internalFormat||n.format||gr,k=si(R),O=n.format||k.format,L=n.type||cr,te=n.target||Sn;if(te!==Tn&&te!==Sn)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";Zo(i,t,n),n=Object.assign({},n);let ue=y.length;const pe=[];let Oe;const Me=n.level||0;let ce=n.width,he=n.height;const Ge=y.length;let Ve=!0;function ct(J){return function(Jt,mr){if(--ue,Jt)pe.push(Jt);else{if(Hn(i,n),i.bindTexture(te,t),Ve){Ve=!1,ce=n.width||mr.width,he=n.height||mr.height,i.texImage3D(te,Me,R,ce,he,Ge,0,O,L,null);for(let At=0;At<Ge;++At)i.texSubImage3D(te,Me,0,0,At,ce,he,1,O,L,mr)}else{let At=mr,Xe;(mr.width!==ce||mr.height!==he)&&(Xe=ua(),At=Xe.canvas,Xe.canvas.width=ce,Xe.canvas.height=he,Xe.drawImage(mr,0,0,ce,he)),i.texSubImage3D(te,Me,0,0,J,ce,he,1,O,L,At),Xe&&At===Xe.canvas&&(Xe.canvas.width=0,Xe.canvas.height=0)}ai(n)&&i.generateMipmap(te)}ue===0&&p(pe.length?pe:void 0,t,Oe)}}Oe=y.map(function(J,Jt){return Jo(J,n.crossOrigin,ct(Jt))})}function f2(i,t,n,p){p=p||cn.textureOptions;const y=p.target||ln;i.bindTexture(y,t);let R=p.width,k=p.height,O=p.depth;const L=p.level||0,te=p.internalFormat||p.format||gr,ue=si(te),pe=p.format||ue.format,Oe=p.type||r2(i,n,ue.type);if(ni(n))n instanceof Uint8ClampedArray&&(n=new Uint8Array(n.buffer));else{const Ge=Zs(Oe);n=new Ge(n)}const Me=qf(te,Oe),ce=n.byteLength/Me;if(ce%1)throw"length wrong size for format: "+aa(i,pe);let he;if(y===Tn||y===Sn)if(!R&&!k&&!O){const Ge=Math.cbrt(ce);if(Ge%1!==0)throw"can't guess cube size of array of numElements: "+ce;R=Ge,k=Ge,O=Ge}else R&&(!k||!O)?(he=no(i,y,k,O,ce/R),k=he.width,O=he.height):k&&(!R||!O)?(he=no(i,y,R,O,ce/k),R=he.width,O=he.height):(he=no(i,y,R,k,ce/O),R=he.width,k=he.height);else he=no(i,y,R,k,ce),R=he.width,k=he.height;if(Ea(i),i.pixelStorei(Vo,p.unpackAlignment||1),Hn(i,p),y===fn){const Ge=Me/n.BYTES_PER_ELEMENT,Ve=ce/6*Ge;Qo(i,p).forEach(ct=>{const J=Ve*ct.ndx,Jt=n.subarray(J,J+Ve);i.texImage2D(ct.face,L,te,R,k,0,pe,Oe,Jt)})}else y===Tn||y===Sn?i.texImage3D(y,L,te,R,k,O,0,pe,Oe,n):i.texImage2D(y,L,te,R,k,0,pe,Oe,n);return{width:R,height:k,depth:O,type:Oe}}function h2(i,t,n){const p=n.target||ln;i.bindTexture(p,t);const y=n.level||0,R=n.internalFormat||n.format||gr,k=si(R),O=n.format||k.format,L=n.type||k.type;if(Hn(i,n),p===fn)for(let te=0;te<6;++te)i.texImage2D(Wo+te,y,R,n.width,n.height,0,O,L,null);else p===Tn||p===Sn?i.texImage3D(p,y,R,n.width,n.height,n.depth,0,O,L,null):i.texImage2D(p,y,R,n.width,n.height,0,O,L,null)}function Ra(i,t,n){n=n||ui,t=t||cn.textureOptions;const p=i.createTexture(),y=t.target||ln;let R=t.width||1,k=t.height||1;const O=t.internalFormat||gr;i.bindTexture(y,p),y===fn&&(i.texParameteri(y,Qi,Ki),i.texParameteri(y,Ji,Ki));let L=t.src;if(L)if(typeof L=="function"&&(L=L(i,t)),typeof L=="string")u2(i,p,t,n);else if(ni(L)||Array.isArray(L)&&(typeof L[0]=="number"||Array.isArray(L[0])||ni(L[0]))){const te=f2(i,p,L,t);R=te.width,k=te.height}else Array.isArray(L)&&(typeof L[0]=="string"||Sa(L[0]))?y===fn?c2(i,p,t,n):l2(i,p,t,n):(Ta(i,p,L,t),R=L.width,k=L.height);else h2(i,p,t);return ai(t)&&Xo(i,p,t,R,k,O),Aa(i,p,t),p}const qo=qs;function Fa(i){return typeof document<"u"&&document.getElementById?document.getElementById(i):null}const io=33984,oo=34962,d2=34963,p2=35713,g2=35714,m2=35632,y2=35633,v2=35981,Oa=35718,b2=35721,w2=35971,x2=35382,_2=35396,E2=35398,A2=35392,T2=35395,so=5126,Ia=35664,ka=35665,Pa=35666,es=5124,Ca=35667,Ma=35668,ja=35669,La=35670,Ua=35671,Ba=35672,Na=35673,Da=35674,Ga=35675,Wa=35676,S2=35678,R2=35680,F2=35679,O2=35682,I2=35685,k2=35686,P2=35687,C2=35688,M2=35689,j2=35690,L2=36289,U2=36292,B2=36293,ts=5125,za=36294,Ha=36295,Va=36296,N2=36298,D2=36299,G2=36300,W2=36303,z2=36306,H2=36307,V2=36308,$2=36311,ao=3553,uo=34067,rs=32879,co=35866,dt={};function $a(i,t){return dt[t].bindPoint}function Y2(i,t){return function(n){i.uniform1f(t,n)}}function X2(i,t){return function(n){i.uniform1fv(t,n)}}function K2(i,t){return function(n){i.uniform2fv(t,n)}}function Q2(i,t){return function(n){i.uniform3fv(t,n)}}function J2(i,t){return function(n){i.uniform4fv(t,n)}}function Ya(i,t){return function(n){i.uniform1i(t,n)}}function Xa(i,t){return function(n){i.uniform1iv(t,n)}}function Ka(i,t){return function(n){i.uniform2iv(t,n)}}function Qa(i,t){return function(n){i.uniform3iv(t,n)}}function Ja(i,t){return function(n){i.uniform4iv(t,n)}}function Z2(i,t){return function(n){i.uniform1ui(t,n)}}function q2(i,t){return function(n){i.uniform1uiv(t,n)}}function e1(i,t){return function(n){i.uniform2uiv(t,n)}}function t1(i,t){return function(n){i.uniform3uiv(t,n)}}function r1(i,t){return function(n){i.uniform4uiv(t,n)}}function n1(i,t){return function(n){i.uniformMatrix2fv(t,!1,n)}}function i1(i,t){return function(n){i.uniformMatrix3fv(t,!1,n)}}function o1(i,t){return function(n){i.uniformMatrix4fv(t,!1,n)}}function s1(i,t){return function(n){i.uniformMatrix2x3fv(t,!1,n)}}function a1(i,t){return function(n){i.uniformMatrix3x2fv(t,!1,n)}}function u1(i,t){return function(n){i.uniformMatrix2x4fv(t,!1,n)}}function c1(i,t){return function(n){i.uniformMatrix4x2fv(t,!1,n)}}function l1(i,t){return function(n){i.uniformMatrix3x4fv(t,!1,n)}}function f1(i,t){return function(n){i.uniformMatrix4x3fv(t,!1,n)}}function Hr(i,t,n,p){const y=$a(i,t);return ri(i)?function(R){let k,O;!R||No(i,R)?(k=R,O=null):(k=R.texture,O=R.sampler),i.uniform1i(p,n),i.activeTexture(io+n),i.bindTexture(y,k),i.bindSampler(n,O)}:function(R){i.uniform1i(p,n),i.activeTexture(io+n),i.bindTexture(y,R)}}function Vr(i,t,n,p,y){const R=$a(i,t),k=new Int32Array(y);for(let O=0;O<y;++O)k[O]=n+O;return ri(i)?function(O){i.uniform1iv(p,k),O.forEach(function(L,te){i.activeTexture(io+k[te]);let ue,pe;!L||No(i,L)?(ue=L,pe=null):(ue=L.texture,pe=L.sampler),i.bindSampler(n,pe),i.bindTexture(R,ue)})}:function(O){i.uniform1iv(p,k),O.forEach(function(L,te){i.activeTexture(io+k[te]),i.bindTexture(R,L)})}}dt[so]={Type:Float32Array,size:4,setter:Y2,arraySetter:X2},dt[Ia]={Type:Float32Array,size:8,setter:K2,cols:2},dt[ka]={Type:Float32Array,size:12,setter:Q2,cols:3},dt[Pa]={Type:Float32Array,size:16,setter:J2,cols:4},dt[es]={Type:Int32Array,size:4,setter:Ya,arraySetter:Xa},dt[Ca]={Type:Int32Array,size:8,setter:Ka,cols:2},dt[Ma]={Type:Int32Array,size:12,setter:Qa,cols:3},dt[ja]={Type:Int32Array,size:16,setter:Ja,cols:4},dt[ts]={Type:Uint32Array,size:4,setter:Z2,arraySetter:q2},dt[za]={Type:Uint32Array,size:8,setter:e1,cols:2},dt[Ha]={Type:Uint32Array,size:12,setter:t1,cols:3},dt[Va]={Type:Uint32Array,size:16,setter:r1,cols:4},dt[La]={Type:Uint32Array,size:4,setter:Ya,arraySetter:Xa},dt[Ua]={Type:Uint32Array,size:8,setter:Ka,cols:2},dt[Ba]={Type:Uint32Array,size:12,setter:Qa,cols:3},dt[Na]={Type:Uint32Array,size:16,setter:Ja,cols:4},dt[Da]={Type:Float32Array,size:32,setter:n1,rows:2,cols:2},dt[Ga]={Type:Float32Array,size:48,setter:i1,rows:3,cols:3},dt[Wa]={Type:Float32Array,size:64,setter:o1,rows:4,cols:4},dt[I2]={Type:Float32Array,size:32,setter:s1,rows:2,cols:3},dt[k2]={Type:Float32Array,size:32,setter:u1,rows:2,cols:4},dt[P2]={Type:Float32Array,size:48,setter:a1,rows:3,cols:2},dt[C2]={Type:Float32Array,size:48,setter:l1,rows:3,cols:4},dt[M2]={Type:Float32Array,size:64,setter:c1,rows:4,cols:2},dt[j2]={Type:Float32Array,size:64,setter:f1,rows:4,cols:3},dt[S2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:ao},dt[R2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:uo},dt[F2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:rs},dt[O2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:ao},dt[L2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:co},dt[U2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:co},dt[B2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:uo},dt[N2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:ao},dt[D2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:rs},dt[G2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:uo},dt[W2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:co},dt[z2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:ao},dt[H2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:rs},dt[V2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:uo},dt[$2]={Type:null,size:0,setter:Hr,arraySetter:Vr,bindPoint:co};function lo(i,t){return function(n){if(n.value)switch(i.disableVertexAttribArray(t),n.value.length){case 4:i.vertexAttrib4fv(t,n.value);break;case 3:i.vertexAttrib3fv(t,n.value);break;case 2:i.vertexAttrib2fv(t,n.value);break;case 1:i.vertexAttrib1fv(t,n.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else i.bindBuffer(oo,n.buffer),i.enableVertexAttribArray(t),i.vertexAttribPointer(t,n.numComponents||n.size,n.type||so,n.normalize||!1,n.stride||0,n.offset||0),i.vertexAttribDivisor&&i.vertexAttribDivisor(t,n.divisor||0)}}function dn(i,t){return function(n){if(n.value)if(i.disableVertexAttribArray(t),n.value.length===4)i.vertexAttrib4iv(t,n.value);else throw new Error("The length of an integer constant value must be 4!");else i.bindBuffer(oo,n.buffer),i.enableVertexAttribArray(t),i.vertexAttribIPointer(t,n.numComponents||n.size,n.type||es,n.stride||0,n.offset||0),i.vertexAttribDivisor&&i.vertexAttribDivisor(t,n.divisor||0)}}function fo(i,t){return function(n){if(n.value)if(i.disableVertexAttribArray(t),n.value.length===4)i.vertexAttrib4uiv(t,n.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else i.bindBuffer(oo,n.buffer),i.enableVertexAttribArray(t),i.vertexAttribIPointer(t,n.numComponents||n.size,n.type||ts,n.stride||0,n.offset||0),i.vertexAttribDivisor&&i.vertexAttribDivisor(t,n.divisor||0)}}function ns(i,t,n){const p=n.size,y=n.count;return function(R){i.bindBuffer(oo,R.buffer);const k=R.size||R.numComponents||p,O=k/y,L=R.type||so,ue=dt[L].size*k,pe=R.normalize||!1,Oe=R.offset||0,Me=ue/y;for(let ce=0;ce<y;++ce)i.enableVertexAttribArray(t+ce),i.vertexAttribPointer(t+ce,O,L,pe,ue,Oe+Me*ce),i.vertexAttribDivisor&&i.vertexAttribDivisor(t+ce,R.divisor||0)}}const Fr={};Fr[so]={size:4,setter:lo},Fr[Ia]={size:8,setter:lo},Fr[ka]={size:12,setter:lo},Fr[Pa]={size:16,setter:lo},Fr[es]={size:4,setter:dn},Fr[Ca]={size:8,setter:dn},Fr[Ma]={size:12,setter:dn},Fr[ja]={size:16,setter:dn},Fr[ts]={size:4,setter:fo},Fr[za]={size:8,setter:fo},Fr[Ha]={size:12,setter:fo},Fr[Va]={size:16,setter:fo},Fr[La]={size:4,setter:dn},Fr[Ua]={size:8,setter:dn},Fr[Ba]={size:12,setter:dn},Fr[Na]={size:16,setter:dn},Fr[Da]={size:4,setter:ns,count:2},Fr[Ga]={size:9,setter:ns,count:3},Fr[Wa]={size:16,setter:ns,count:4};const h1=/ERROR:\s*\d+:(\d+)/gi;function d1(i,t="",n=0){const p=[...t.matchAll(h1)],y=new Map(p.map((R,k)=>{const O=parseInt(R[1]),L=p[k+1],te=L?L.index:t.length,ue=t.substring(R.index,te);return[O-1,ue]}));return i.split(`
|
|
124
|
-
`).map((R,k)=>{const O=y.get(k);return`${k+1+n}: ${R}${O?`
|
|
125
|
-
|
|
126
|
-
^^^ ${O}`:""}`}).join(`
|
|
127
|
-
`)}const Za=/^[ \t]*\n/;function qa(i){let t=0;return Za.test(i)&&(t=1,i=i.replace(Za,"")),{lineOffset:t,shaderSource:i}}function p1(i,t){return i.errorCallback(t),i.callback&&setTimeout(()=>{i.callback(`${t}
|
|
128
|
-
${i.errors.join(`
|
|
129
|
-
`)}`)}),null}function g1(i,t,n,p){if(p=p||qo,!i.getShaderParameter(n,p2)){const R=i.getShaderInfoLog(n),{lineOffset:k,shaderSource:O}=qa(i.getShaderSource(n)),L=`${d1(O,R,k)}
|
|
130
|
-
Error compiling ${aa(i,t)}: ${R}`;return p(L),L}return""}function is(i,t,n){let p,y,R;if(typeof t=="function"&&(n=t,t=void 0),typeof i=="function")n=i,i=void 0;else if(i&&!Array.isArray(i)){const te=i;n=te.errorCallback,i=te.attribLocations,p=te.transformFeedbackVaryings,y=te.transformFeedbackMode,R=te.callback}const k=n||qo,O=[],L={errorCallback(te,...ue){O.push(te),k(te,...ue)},transformFeedbackVaryings:p,transformFeedbackMode:y,callback:R,errors:O};{let te={};Array.isArray(i)?i.forEach(function(ue,pe){te[ue]=t?t[pe]:pe}):te=i||{},L.attribLocations=te}return L}const m1=["VERTEX_SHADER","FRAGMENT_SHADER"];function y1(i,t){if(t.indexOf("frag")>=0)return m2;if(t.indexOf("vert")>=0)return y2}function v1(i,t,n){const p=i.getAttachedShaders(t);for(const y of p)n.has(y)&&i.deleteShader(y);i.deleteProgram(t)}const b1=(i=0)=>new Promise(t=>setTimeout(t,i));function w1(i,t,n){const p=i.createProgram(),{attribLocations:y,transformFeedbackVaryings:R,transformFeedbackMode:k}=is(n);for(let O=0;O<t.length;++O){let L=t[O];if(typeof L=="string"){const te=Fa(L),ue=te?te.text:L;let pe=i[m1[O]];te&&te.type&&(pe=y1(i,te.type)||pe),L=i.createShader(pe),i.shaderSource(L,qa(ue).shaderSource),i.compileShader(L),i.attachShader(p,L)}}Object.entries(y).forEach(([O,L])=>i.bindAttribLocation(p,L,O));{let O=R;O&&(O.attribs&&(O=O.attribs),Array.isArray(O)||(O=Object.keys(O)),i.transformFeedbackVaryings(p,O,k||v2))}return i.linkProgram(p),p}function x1(i,t,n,p,y){const R=is(n,p,y),k=new Set(t),O=w1(i,t,R);function L(te,ue){const pe=E1(te,ue,R.errorCallback);return pe&&v1(te,ue,k),pe}if(R.callback){_1(i,O).then(()=>{const te=L(i,O);R.callback(te,te?void 0:O)});return}return L(i,O)?void 0:O}async function _1(i,t){const n=i.getExtension("KHR_parallel_shader_compile"),p=n?(R,k)=>R.getProgramParameter(k,n.COMPLETION_STATUS_KHR):()=>!0;let y=0;do await b1(y),y=1e3/60;while(!p(i,t))}function E1(i,t,n){if(n=n||qo,!i.getProgramParameter(t,g2)){const y=i.getProgramInfoLog(t);n(`Error in program linking: ${y}`);const k=i.getAttachedShaders(t).map(O=>g1(i,i.getShaderParameter(O,i.SHADER_TYPE),O,n));return`${y}
|
|
131
|
-
${k.filter(O=>O).join(`
|
|
132
|
-
`)}`}}function A1(i,t,n,p,y){return x1(i,t,n,p,y)}function eu(i){const t=i.name;return t.startsWith("gl_")||t.startsWith("webgl_")}const T1=/(\.|\[|]|\w+)/g,S1=i=>i>="0"&&i<="9";function R1(i,t,n,p){const y=i.split(T1).filter(O=>O!=="");let R=0,k="";for(;;){const O=y[R++];k+=O;const L=S1(O[0]),te=L?parseInt(O):O;if(L&&(k+=y[R++]),R===y.length){n[te]=t;break}else{const pe=y[R++],Oe=pe==="[",Me=n[te]||(Oe?[]:{});n[te]=Me,n=Me,p[k]=p[k]||(function(ce){return function(he){tu(ce,he)}})(Me),k+=pe}}}function F1(i,t){let n=0;function p(O,L,te){const ue=L.name.endsWith("[0]"),pe=L.type,Oe=dt[pe];if(!Oe)throw new Error(`unknown type: 0x${pe.toString(16)}`);let Me;if(Oe.bindPoint){const ce=n;n+=L.size,ue?Me=Oe.arraySetter(i,pe,ce,te,L.size):Me=Oe.setter(i,pe,ce,te,L.size)}else Oe.arraySetter&&ue?Me=Oe.arraySetter(i,te):Me=Oe.setter(i,te);return Me.location=te,Me}const y={},R={},k=i.getProgramParameter(t,Oa);for(let O=0;O<k;++O){const L=i.getActiveUniform(t,O);if(eu(L))continue;let te=L.name;te.endsWith("[0]")&&(te=te.substr(0,te.length-3));const ue=i.getUniformLocation(t,L.name);if(ue){const pe=p(t,L,ue);y[te]=pe,R1(te,pe,R,y)}}return y}function O1(i,t){const n={},p=i.getProgramParameter(t,w2);for(let y=0;y<p;++y){const R=i.getTransformFeedbackVarying(t,y);n[R.name]={index:y,type:R.type,size:R.size}}return n}function I1(i,t){const n=i.getProgramParameter(t,Oa),p=[],y=[];for(let O=0;O<n;++O){y.push(O),p.push({});const L=i.getActiveUniform(t,O);p[O].name=L.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(O){const L=O[0],te=O[1];i.getActiveUniforms(t,y,i[L]).forEach(function(ue,pe){p[pe][te]=ue})});const R={},k=i.getProgramParameter(t,x2);for(let O=0;O<k;++O){const L=i.getActiveUniformBlockName(t,O),te={index:i.getUniformBlockIndex(t,L),usedByVertexShader:i.getActiveUniformBlockParameter(t,O,_2),usedByFragmentShader:i.getActiveUniformBlockParameter(t,O,E2),size:i.getActiveUniformBlockParameter(t,O,A2),uniformIndices:i.getActiveUniformBlockParameter(t,O,T2)};te.used=te.usedByVertexShader||te.usedByFragmentShader,R[L]=te}return{blockSpecs:R,uniformData:p}}function tu(i,t){for(const n in t){const p=i[n];typeof p=="function"?p(t[n]):tu(i[n],t[n])}}function ru(i,...t){const n=i.uniformSetters||i,p=t.length;for(let y=0;y<p;++y){const R=t[y];if(Array.isArray(R)){const k=R.length;for(let O=0;O<k;++O)ru(n,R[O])}else for(const k in R){const O=n[k];O&&O(R[k])}}}function k1(i,t){const n={},p=i.getProgramParameter(t,b2);for(let y=0;y<p;++y){const R=i.getActiveAttrib(t,y);if(eu(R))continue;const k=i.getAttribLocation(t,R.name),O=Fr[R.type],L=O.setter(i,k,O);L.location=k,n[R.name]=L}return n}function P1(i,t){for(const n in t){const p=i[n];p&&p(t[n])}}function C1(i,t,n){n.vertexArrayObject?i.bindVertexArray(n.vertexArrayObject):(P1(t.attribSetters||t,n.attribs),n.indices&&i.bindBuffer(d2,n.indices))}function nu(i,t){const n=F1(i,t),p=k1(i,t),y={program:t,uniformSetters:n,attribSetters:p};return ri(i)&&(y.uniformBlockSpec=I1(i,t),y.transformFeedbackInfo=O1(i,t)),y}const M1=/\s|{|}|;/;function j1(i,t,n,p,y){const R=is(n,p,y),k=[];if(t=t.map(function(te){if(!M1.test(te)){const ue=Fa(te);if(ue)te=ue.text;else{const pe=`no element with id: ${te}`;R.errorCallback(pe),k.push(pe)}}return te}),k.length)return p1(R,"");const O=R.callback;O&&(R.callback=(te,ue)=>{O(te,te?void 0:nu(i,ue))});const L=A1(i,t,R);return L?nu(i,L):null}const L1=4,iu=5123;function U1(i,t,n,p,y,R){n=n===void 0?L1:n;const k=t.indices,O=t.elementType,L=p===void 0?t.numElements:p;y=y===void 0?0:y,O||k?R!==void 0?i.drawElementsInstanced(n,L,O===void 0?iu:t.elementType,y,R):i.drawElements(n,L,O===void 0?iu:t.elementType,y):R!==void 0?i.drawArraysInstanced(n,y,L,R):i.drawArrays(n,y,L)}const ou=36160,ho=36161,B1=3553,N1=5121,D1=6402,G1=6408,W1=33190,z1=36012,H1=35056,V1=36013,$1=32854,Y1=32855,X1=36194,su=33189,au=6401,uu=36168,os=34041,ss=36064,po=36096,cu=36128,as=33306,us=33071,cs=9729,K1=[{format:G1,type:N1,min:cs,wrap:us},{format:os}],Qr={};Qr[os]=as,Qr[au]=cu,Qr[uu]=cu,Qr[D1]=po,Qr[su]=po,Qr[W1]=po,Qr[z1]=po,Qr[H1]=as,Qr[V1]=as;function Q1(i,t){return Qr[i]||Qr[t]}const pn={};pn[$1]=!0,pn[Y1]=!0,pn[X1]=!0,pn[os]=!0,pn[su]=!0,pn[au]=!0,pn[uu]=!0;function J1(i){return pn[i]}const Z1=32;function q1(i){return i>=ss&&i<ss+Z1}function lu(i,t,n,p){const y=ou,R=i.createFramebuffer();i.bindFramebuffer(y,R),n=n||i.drawingBufferWidth,p=p||i.drawingBufferHeight,t=t||K1;const k=[],O={framebuffer:R,attachments:[],width:n,height:p};return t.forEach(function(L,te){let ue=L.attachment;const pe=L.samples,Oe=L.format;let Me=L.attachmentPoint||Q1(Oe,L.internalFormat);if(Me||(Me=ss+te),q1(Me)&&k.push(Me),!ue)if(pe!==void 0||J1(Oe))ue=i.createRenderbuffer(),i.bindRenderbuffer(ho,ue),pe>1?i.renderbufferStorageMultisample(ho,pe,Oe,n,p):i.renderbufferStorage(ho,Oe,n,p);else{const ce=Object.assign({},L);ce.width=n,ce.height=p,ce.auto===void 0&&(ce.auto=!1,ce.min=ce.min||ce.minMag||cs,ce.mag=ce.mag||ce.minMag||cs,ce.wrapS=ce.wrapS||ce.wrap||us,ce.wrapT=ce.wrapT||ce.wrap||us),ue=Ra(i,ce)}if(al(i,ue))i.framebufferRenderbuffer(y,Me,ho,ue);else if(No(i,ue))L.layer!==void 0?i.framebufferTextureLayer(y,Me,ue,L.level||0,L.layer):i.framebufferTexture2D(y,Me,L.target||B1,ue,L.level||0);else throw new Error("unknown attachment type");O.attachments.push(ue)}),i.drawBuffers&&i.drawBuffers(k),O}function e3(i,t,n){n=n||ou,t?(i.bindFramebuffer(n,t.framebuffer),i.viewport(0,0,t.width,t.height)):(i.bindFramebuffer(n,null),i.viewport(0,0,i.drawingBufferWidth,i.drawingBufferHeight))}function Gr(i,t){return()=>t instanceof WebGLTexture?t:Ra(i,{src:t,wrap:i.CLAMP_TO_EDGE})}const Vn=2;class ci{constructor(t){this.id="_";const{context:n,width:p,height:y}=t;this.context=n,this.options=t;const R=this.buildDefines();this.programInfo=j1(this.context,[R+this.getVertexShader(),R+this.getFragmentShader()]),this.bufferInfo=kl(this.context,this.getBuffers()),this.fbi=lu(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],p,y),this.output=this.fbi.attachments[0]}resizeOutput(t,n){this.fbi=lu(this.context,[{format:this.context.RGBA,type:this.context.UNSIGNED_BYTE,min:this.context.LINEAR,wrap:this.context.CLAMP_TO_EDGE}],t,n),this.options.width=t,this.options.height=n,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 n=this.getDefines();for(let p in n)t+=`#define ${p} ${n[p].toFixed(1)}
|
|
133
|
-
`;return t}run(t){this.profiler?.pushContext(`[${this.id}] PROG : ${this.constructor.name}`),this.profiler?.pushContext(`[${this.id}] UNIFORMS`);for(const y in t)typeof t[y]=="function"&&(this.profiler?.pushContext(`[${this.id}] UNI : ${y}`),t[y]=t[y](),this.profiler?.popContext(`[${this.id}] UNI : ${y}`));this.profiler?.popContext(`[${this.id}] UNIFORMS`);const n=Date.now();let p=0;this.lastRun&&(p=(n-this.lastRun)/1e3),this.lastRun=n,this.context.viewport(0,0,this.context.canvas.width,this.context.canvas.height),this.context.useProgram(this.programInfo.program),C1(this.context,this.programInfo,this.bufferInfo),ru(this.programInfo,{delta:p,canvas:[this.context.canvas.width,this.context.canvas.height],...t}),e3(this.context,this.options.disableFramebuffer?null:this.fbi),U1(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(t){this.profiler=t}}const t3=`precision mediump float;
|
|
1
|
+
(function(k,We){typeof exports=="object"&&typeof module<"u"?We(exports):typeof define=="function"&&define.amd?define(["exports"],We):(k=typeof globalThis<"u"?globalThis:k||self,We(k["ml-transformers"]={}))})(this,(function(k){"use strict";async function We(){return new Promise(async(r,e)=>{await xn()||wn()?r():e("Your browser does not support the MediaStreamTrack API for Insertable Streams of Media.")})}function wn(){return self.MediaStreamTrackProcessor!==void 0&&self.MediaStreamTrackGenerator!==void 0||Po()}function Po(){return[self.ReadableStream,self.WritableStream,self.MediaStream,self.OffscreenCanvas,self.VideoFrame,self.AudioContext,self.AudioWorkletNode].filter(r=>r===void 0).length===0}function xn(){return new Promise(r=>{function e(){self.postMessage(typeof MediaStreamTrackProcessor<"u"&&typeof VideoTrackGenerator<"u")}const t=new Worker(`data:text/javascript,(${e.toString()})()`);t.onmessage=({data:n})=>r(n)})}const ee=new WeakMap,de=new WeakMap,Q=new WeakMap,lt=Symbol("anyProducer"),vn=Promise.resolve(),ft=Symbol("listenerAdded"),dt=Symbol("listenerRemoved");let ht=!1,pr=!1;const mt=r=>typeof r=="string"||typeof r=="symbol"||typeof r=="number";function Te(r){if(!mt(r))throw new TypeError("`eventName` must be a string, symbol, or number")}function pt(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Se(r,e){const t=de.get(r);if(t.has(e))return t.get(e)}function Ge(r,e){const t=mt(e)?e:lt,n=Q.get(r);if(n.has(t))return n.get(t)}function Fo(r,e,t){const n=Q.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(lt)){const i=Promise.all([e,t]);for(const o of n.get(lt))o.enqueue(i)}}function _n(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const o={enqueue(s){i.push(s),n()},finish(){t=!0,n()}};for(const s of e){let a=Ge(r,s);a||(a=new Set,Q.get(r).set(s,a)),a.add(o)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(s=>{n=s}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(s){i=void 0;for(const a of e){const c=Ge(r,a);c&&(c.delete(o),c.size===0&&Q.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await s}:{done:!0}},[Symbol.asyncIterator](){return this}}}function En(r){if(r===void 0)return An;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!An.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===ft||r===dt;function gt(r,e,t){if(Ie(e))try{ht=!0,r.emit(e,t)}finally{ht=!1}}class q{static mixin(e,t){return t=En(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const s of t)if(n.prototype[s]!==void 0)throw new Error(`The property \`${s}\` already exists on \`target\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new q}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const o=s=>function(...a){return this[e][s](...a)};for(const s of t)Object.defineProperty(n.prototype,s,{enumerable:!1,value:o(s)});return n}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return pr;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||pr}static set isDebugEnabled(e){pr=e}constructor(e={}){ee.set(this,new Set),de.set(this,new Map),Q.set(this,new Map),Q.get(this).set(lt,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,o)=>{try{o=JSON.stringify(o)}catch{o=`Object with the following keys failed to stringify: ${Object.keys(o).join(",")}`}(typeof i=="symbol"||typeof i=="number")&&(i=i.toString());const s=new Date,a=`${s.getHours()}:${s.getMinutes()}:${s.getSeconds()}.${s.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${n}] Event Name: ${i}
|
|
2
|
+
data: ${o}`)})}logIfDebugEnabled(e,t,n){(q.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t,{signal:n}={}){pt(t),e=Array.isArray(e)?e:[e];for(const o of e){Te(o);let s=Se(this,o);s||(s=new Set,de.get(this).set(o,s)),s.add(t),this.logIfDebugEnabled("subscribe",o,void 0),Ie(o)||gt(this,ft,{eventName:o,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){pt(t),e=Array.isArray(e)?e:[e];for(const n of e){Te(n);const i=Se(this,n);i&&(i.delete(t),i.size===0&&de.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),Ie(n)||gt(this,dt,{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(o=>{n=this.on(e,s=>{t&&!t(s)||(n(),o(s))})});return i.off=n,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Te(t);return _n(this,e)}async emit(e,t){if(Te(e),Ie(e)&&!ht)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Fo(this,e,t);const n=Se(this,e)??new Set,i=ee.get(this),o=[...n],s=Ie(e)?[]:[...i];await vn,await Promise.all([...o.map(async a=>{if(n.has(a))return a(t)}),...s.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(Te(e),Ie(e)&&!ht)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const n=Se(this,e)??new Set,i=ee.get(this),o=[...n],s=[...i];await vn;for(const a of o)n.has(a)&&await a(t);for(const a of s)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){pt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),ee.get(this).add(e),gt(this,ft,{listener:e});const n=()=>{this.offAny(e),t?.removeEventListener("abort",n)};return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),n}anyEvent(){return _n(this)}offAny(e){pt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),gt(this,dt,{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),mt(t)){const n=Se(this,t);n&&n.clear();const i=Ge(this,t);if(i){for(const o of i)o.finish();i.clear()}}else{ee.get(this).clear();for(const[n,i]of de.get(this).entries())i.clear(),de.get(this).delete(n);for(const[n,i]of Q.get(this).entries()){for(const o of i)o.finish();i.clear(),Q.get(this).delete(n)}}}listenerCount(e){e=Array.isArray(e)?e:[e];let t=0;for(const n of e){if(mt(n)){t+=ee.get(this).size+(Se(this,n)?.size??0)+(Ge(this,n)?.size??0)+(Ge(this)?.size??0);continue}n!==void 0&&Te(n),t+=ee.get(this).size;for(const i of de.get(this).values())t+=i.size;for(const i of Q.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=En(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 An=Object.getOwnPropertyNames(q.prototype).filter(r=>r!=="constructor");Object.defineProperty(q,"listenerAdded",{value:ft,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(q,"listenerRemoved",{value:dt,writable:!1,enumerable:!0,configurable:!1});var Co=Object.defineProperty,Mo=(r,e,t)=>e in r?Co(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Oo=(r,e,t)=>(Mo(r,e+"",t),t);const Bo="hlg.tokbox.com/prod/logging/vcp_webrtc",Do="https://",Uo=1e4;let yt;const Lo=new Uint8Array(16);function zo(){if(!yt&&(yt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!yt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yt(Lo)}const P=[];for(let r=0;r<256;++r)P.push((r+256).toString(16).slice(1));function No(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 $o=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Tn={randomUUID:$o};function Wo(r,e,t){if(Tn.randomUUID&&!r)return Tn.randomUUID();r=r||{};const n=r.random||(r.rng||zo)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,No(n)}function gr(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 te=gr("globals",{});var he=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(he||{});function Sn(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let Go=0;function Vo(r,e,t,n,i){const o=Go++;return r.postMessage({id:o,type:e,functionName:t,args:n},n.filter(s=>Sn(s))),new Promise(s=>{i?.set(o,s)})}function Ve(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(o=>Sn(o)))}const In=gr("workerized",{});function Rn(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function Ho(){if(Rn())Ve({type:he.GLOBALS_SYNC},te);else{const r=[];for(const e in In){const{worker:t,resolvers:n}=In[e].workerContext;t&&r.push(Vo(t,he.GLOBALS_SYNC,"",[te],n))}await Promise.all(r)}}function bt(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]=[],bt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},bt(r[t],e[t])):e[t]=r[t]}async function jo(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}`;Ve(r,await e.instance[t](...n??[]))}const Yo=gr("registeredWorkers",{});function Qo(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Yo[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;bt(n,te),Ve(r,typeof e.instance!==void 0)}async function qo(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Ve(r,n)}function Xo(r){if(!r.args)throw"Missing globals while syncing";bt(r.args[0],te),Ve(r,{})}function Ko(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case he.INIT:Qo(t,r);break;case he.FORWARD:jo(t,r);break;case he.TERMINATE:qo(t,r);break;case he.GLOBALS_SYNC:Xo(t);break}}}Rn()&&Ko();function Jo(r,e){return te[r]||(te[r]=e),[()=>te[r],async t=>{te[r]=t,await Ho()}]}function Zo(r,e){return Jo(r,e)}const[es,ts]=Zo("metadata");function rs(r){ts(r)}function wt(){return es()}let yr=class{constructor(e,t){Oo(this,"uuid"),this.config=e,this.uuid=t??Wo()}async send(e){var t,n,i;const{appId:o,sourceType:s}=(t=wt())!=null?t:{};if(!o||!s)return"metadata missing";const a=new AbortController,c=setTimeout(()=>a.abort(),Uo);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=wt().proxyUrl)!=null?e:Do;return t+=(t.at(-1)==="/"?"":"/")+Bo,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=wt();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}};const xt="3.0.1-alpha.0",br=class{};br.updates={transformer_new:"New transformer",transformer_null:"Null transformer"},br.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 me=br;function ns(r){return typeof r=="object"&&r!==null&&"message"in r&&typeof r.message=="string"}function is(r){if(ns(r))return r;try{return new Error(JSON.stringify(r))}catch{return new Error(String(r))}}function wr(r){return is(r).message}class os{constructor(e,t){this.config=e,this.frameTransformedCount=0,this.frameFromSourceCount=0,this.startAt=0,this.reporter=new yr(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:o}=this,s=Date.now(),a=(s-n)/1e3,c=i/a,u=o/a;return t||this.frameTransformedCount>=this.config.loggingIntervalFrameCount?(this.frameFromSourceCount=0,this.frameTransformedCount=0,this.startAt=s,this.reporter.config=this.config,this.reporter.send({...this.config.report,variation:"QoS",fps:u,transformedFps:c,framesTransformed:i,...e})):"success"}}var kn=(r=>(r.FPS_DROP="fps_drop",r))(kn||{}),Pn=(r=>(r.start="start",r.transform="transform",r.flush="flush",r))(Pn||{}),vt=(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))(vt||{});const ss=500,as=.8;class cs extends q{constructor(e,t){super(),this.reporter_=new yr,this.reporterQos_=new os({loggingIntervalFrameCount:ss,report:{version:xt}}),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:me.errors.transformer_start,variation:"Error",error:wr(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:me.errors.transformer_transform,variation:"Error",error:wr(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:me.errors.transformer_flush,variation:"Error",error:wr(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:xt,action:"MediaTransformer",transformerType:this.transformerType_,...e})}reportQos(e=!1){this.reporterQos_.config={...this.reporterQos_.config},this.reporterQos_.onFrameTransformed({version:xt,action:"MediaTransformer",transformerType:this.transformerType_,videoWidth:this.videoWidth_,videoHeight:this.videoHeight_},e)}}class us extends q{constructor(e){super(),this.transformers_=[],this.trackExpectedRate_=-1;for(let t=0;t<e.length;t++){let n=new cs(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(o=>{console.error("[Pipeline] Error from stream transform:",o)}),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 Fn extends q{constructor(){super(),this.reporter_=new yr,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:me.errors.transformer_none,variation:"Error"}),t("[MediaProcessor] Need to set transformers.");return}if(!this.readable_){this.report({variation:"Error",message:me.errors.readable_null}),t("[MediaProcessor] Readable is null.");return}if(!this.writable_){this.report({variation:"Error",message:me.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 us(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=vt.pipeline_restarted:i==="pipeline_started_with_error"&&(i=vt.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:me.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:xt,action:"MediaProcessor",...e})}isTrack(e){return"kind"in e}}class ls{constructor({kind:e}){if(e=="video"){const t=document.createElement("canvas"),n=t.getContext("2d",{desynchronized:!0}),i=t.captureStream().getVideoTracks()[0];return i.writable=new WritableStream({write(o){t.width=o.displayWidth,t.height=o.displayHeight,n.drawImage(o,0,0,t.width,t.height),o.close()}}),i}else if(e=="audio"){const t=new AudioContext,n=t.createMediaStreamDestination(),[i]=n.stream.getAudioTracks();return i.writable=new WritableStream({async start(o){this.arrays=[];function s(){registerProcessor("mstg-shim",class extends AudioWorkletProcessor{constructor(){super(),this.arrays=[],this.arrayOffset=0,this.port.onmessage=({data:a})=>this.arrays.push(a),this.emptyArray=new Float32Array(0)}process(a,[[c]]){for(let u=0;u<c.length;u++)(!this.array||this.arrayOffset>=this.array.length)&&(this.array=this.arrays.shift()||this.emptyArray,this.arrayOffset=0),c[u]=this.array[this.arrayOffset++]||0;return!0}})}return await t.audioWorklet.addModule(`data:text/javascript,(${s.toString()})()`),this.node=new AudioWorkletNode(t,"mstg-shim"),this.node.connect(n),i},write(o){const s=new Float32Array(o.numberOfFrames*o.numberOfChannels);o.copyTo(s,{planeIndex:0}),this.node.port.postMessage(s,[s.buffer]),o.close()}}),i}}}function fs(){return self.MediaStreamTrackGenerator?self.MediaStreamTrackGenerator:ls}class ds{constructor(e){const t=e.track??e;t.kind=="video"?this.readable=new ReadableStream({async start(n){t.addEventListener("ended",()=>n.close(),{once:!0}),this.video=document.createElement("video"),this.video.srcObject=new MediaStream([t]),await Promise.all([this.video.play(),new Promise(i=>this.video.onloadedmetadata=i)]),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(n){if(t.readyState=="ended")return n.close();const i=t.getSettings().frameRate||30;for(;performance.now()-this.t1<1e3/i;)if(await new Promise(o=>requestAnimationFrame(o)),t.readyState=="ended")return n.close();this.canvas.width=this.video.videoWidth,this.canvas.height=this.video.videoHeight,this.t1=performance.now(),this.ctx.drawImage(this.video,0,0),n.enqueue(new VideoFrame(this.canvas,{timestamp:this.t1}))}}):t.kind=="audio"&&(this.readable=new ReadableStream({async start(n){t.addEventListener("ended",()=>n.close(),{once:!0}),this.ac=new AudioContext,this.arrays=[];function i(){registerProcessor("mstp-shim",class extends AudioWorkletProcessor{process(o){return this.port.postMessage(o),!0}})}await this.ac.audioWorklet.addModule(`data:text/javascript,(${i.toString()})()`),this.node=new AudioWorkletNode(this.ac,"mstp-shim"),this.ac.createMediaStreamSource(new MediaStream([t])).connect(this.node),this.node.port.addEventListener("message",({data:o})=>o[0][0]&&this.arrays.push(o))},async pull(n){if(t.readyState=="ended")return n.close();for(;!this.arrays.length;)if(await new Promise(s=>this.node.port.onmessage=s),t.readyState=="ended")return n.close();const[i]=this.arrays.shift(),o=new Float32Array(i.reduce((s,a)=>s+a.length,0));i.reduce((s,a)=>(o.set(a,s),s+a.length),0),n.enqueue(new AudioData({format:"f32-planar",sampleRate:this.ac.sampleRate,numberOfFrames:i[0].length,numberOfChannels:i.length,timestamp:this.ac.currentTime*1e6|0,data:o,transfer:[o.buffer]}))}}))}}function hs(){return self.MediaStreamTrackProcessor?self.MediaStreamTrackProcessor:ds}class ms{constructor(){this.processor_=null,this.generator_=null}init(e){return new Promise((t,n)=>{try{const i=hs();this.processor_=new i(e)}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackProcessor failed: ${i}`),n(i)}try{const i=fs();e.kind==="audio"?this.generator_=new i({kind:"audio"}):e.kind==="video"?this.generator_=new i({kind:"video"}):n("kind not supported")}catch(i){console.log(`[InsertableStreamHelper] MediaStreamTrackGenerator failed: ${i}`),n(i)}t()})}getReadable(){return this.processor_.readable}getWriteable(){return this.generator_.writable}getProccesorTrack(){return this.generator_}}class ps{constructor(e){this.mediaProcessor_=e}async setTrack(e){if(!(this.mediaProcessor_ instanceof Fn)&&await xn()){if(e.kind==="audio")throw Error("Cannot process audio tracks inside a web worker when passing a track to transform");return await this.mediaProcessor_.transform(e)}if(wn()){const t=new ms;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(n=>{t(n)}):t("no processor")})}}var He=(r=>(r.Low="Low",r.High="High",r))(He||{}),Cn=(r=>(r.BackgroundBlur="BackgroundBlur",r.VirtualBackground="VirtualBackground",r.VideoBackground="VideoBackground",r.SilhouetteBlur="SilhouetteBlur",r))(Cn||{}),_t=(r=>(r.FAST="FAST",r.PRECISE="PRECISE",r))(_t||{}),je=(r=>(r.CANVAS="CANVAS",r.WEBGL="WEBGL",r))(je||{});const gs=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 ys(){const{wasm:r,insertableStreams:e,simd:t,webgl:n}=await Mn();if(!r.supported)throw r.message;if(!e.supported)throw e.message;if(!t.supported)throw t.message;if(!n.supported)throw n.message}async function Mn(){const r={wasm:{supported:typeof WebAssembly=="object"&&typeof WebAssembly.instantiate=="function",message:"Your browser does not support WebAssembly features."},simd:{supported:await gs(),message:"Your browser does not support simd features."},insertableStreams:{supported:!0},gpu:{message:"Your browser does not support gpu features.",supported:!0},webgl:bs(),performance:On()};try{await We()}catch(e){r.insertableStreams.supported=!1,r.insertableStreams.message=e}return r}function bs(){if(!OffscreenCanvas)return{supported:!1,message:"Your browser does not support offscreen canvas"};const e=new OffscreenCanvas(0,0).getContext("webgl2");if(e){const t=e?.getExtension("WEBGL_lose_context");t&&t.loseContext()}else return{supported:!1,message:"Your browser does not support webgl 2"};return{supported:!0}}function On(){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}}const re=new WeakMap,pe=new WeakMap,X=new WeakMap,Et=Symbol("anyProducer"),Bn=Promise.resolve(),At=Symbol("listenerAdded"),Tt=Symbol("listenerRemoved");let St=!1,xr=!1;const It=r=>typeof r=="string"||typeof r=="symbol"||typeof r=="number";function Re(r){if(!It(r))throw new TypeError("`eventName` must be a string, symbol, or number")}function Rt(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function ke(r,e){const t=pe.get(r);if(t.has(e))return t.get(e)}function Ye(r,e){const t=It(e)?e:Et,n=X.get(r);if(n.has(t))return n.get(t)}function ws(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(Et)){const i=Promise.all([e,t]);for(const o of n.get(Et))o.enqueue(i)}}function Dn(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const o={enqueue(s){i.push(s),n()},finish(){t=!0,n()}};for(const s of e){let a=Ye(r,s);a||(a=new Set,X.get(r).set(s,a)),a.add(o)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(s=>{n=s}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(s){i=void 0;for(const a of e){const c=Ye(r,a);c&&(c.delete(o),c.size===0&&X.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await s}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Un(r){if(r===void 0)return Ln;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!Ln.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const Pe=r=>r===At||r===Tt;function kt(r,e,t){if(Pe(e))try{St=!0,r.emit(e,t)}finally{St=!1}}let Qe=class bn{static mixin(e,t){return t=Un(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const s of t)if(n.prototype[s]!==void 0)throw new Error(`The property \`${s}\` already exists on \`target\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new bn}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const o=s=>function(...a){return this[e][s](...a)};for(const s of t)Object.defineProperty(n.prototype,s,{enumerable:!1,value:o(s)});return n}}static get isDebugEnabled(){if(typeof globalThis.process?.env!="object")return xr;const{env:e}=globalThis.process??{env:{}};return e.DEBUG==="emittery"||e.DEBUG==="*"||xr}static set isDebugEnabled(e){xr=e}constructor(e={}){re.set(this,new Set),pe.set(this,new Map),X.set(this,new Map),X.get(this).set(Et,new Set),this.debug=e.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(t,n,i,o)=>{try{o=JSON.stringify(o)}catch{o=`Object with the following keys failed to stringify: ${Object.keys(o).join(",")}`}(typeof i=="symbol"||typeof i=="number")&&(i=i.toString());const s=new Date,a=`${s.getHours()}:${s.getMinutes()}:${s.getSeconds()}.${s.getMilliseconds()}`;console.log(`[${a}][emittery:${t}][${n}] Event Name: ${i}
|
|
3
|
+
data: ${o}`)})}logIfDebugEnabled(e,t,n){(bn.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t,{signal:n}={}){Rt(t),e=Array.isArray(e)?e:[e];for(const o of e){Re(o);let s=ke(this,o);s||(s=new Set,pe.get(this).set(o,s)),s.add(t),this.logIfDebugEnabled("subscribe",o,void 0),Pe(o)||kt(this,At,{eventName:o,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){Rt(t),e=Array.isArray(e)?e:[e];for(const n of e){Re(n);const i=ke(this,n);i&&(i.delete(t),i.size===0&&pe.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),Pe(n)||kt(this,Tt,{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(o=>{n=this.on(e,s=>{t&&!t(s)||(n(),o(s))})});return i.off=n,i}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Re(t);return Dn(this,e)}async emit(e,t){if(Re(e),Pe(e)&&!St)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),ws(this,e,t);const n=ke(this,e)??new Set,i=re.get(this),o=[...n],s=Pe(e)?[]:[...i];await Bn,await Promise.all([...o.map(async a=>{if(n.has(a))return a(t)}),...s.map(async a=>{if(i.has(a))return a(e,t)})])}async emitSerial(e,t){if(Re(e),Pe(e)&&!St)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const n=ke(this,e)??new Set,i=re.get(this),o=[...n],s=[...i];await Bn;for(const a of o)n.has(a)&&await a(t);for(const a of s)i.has(a)&&await a(e,t)}onAny(e,{signal:t}={}){Rt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),re.get(this).add(e),kt(this,At,{listener:e});const n=()=>{this.offAny(e),t?.removeEventListener("abort",n)};return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),n}anyEvent(){return Dn(this)}offAny(e){Rt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),kt(this,Tt,{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),It(t)){const n=ke(this,t);n&&n.clear();const i=Ye(this,t);if(i){for(const o of i)o.finish();i.clear()}}else{re.get(this).clear();for(const[n,i]of pe.get(this).entries())i.clear(),pe.get(this).delete(n);for(const[n,i]of X.get(this).entries()){for(const o of i)o.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(It(n)){t+=re.get(this).size+(ke(this,n)?.size??0)+(Ye(this,n)?.size??0)+(Ye(this)?.size??0);continue}n!==void 0&&Re(n),t+=re.get(this).size;for(const i of pe.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=Un(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 Ln=Object.getOwnPropertyNames(Qe.prototype).filter(r=>r!=="constructor");Object.defineProperty(Qe,"listenerAdded",{value:At,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Qe,"listenerRemoved",{value:Tt,writable:!1,enumerable:!0,configurable:!1});function vr(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 Fe=vr("globals",{});var z=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r.EVENT="EVENT",r))(z||{});function zn(r){return[ImageBitmap,ReadableStream,WritableStream].some(t=>r instanceof t)}let xs=0;function Pt(r,e,t,n,i){const o=xs++;return r.postMessage({id:o,type:e,functionName:t,args:n},n.filter(a=>zn(a))),new Promise(a=>{i?.set(o,a)})}function Ce(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(o=>zn(o)))}const Ft=vr("workerized",{});function _r(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function vs(){if(_r())Ce({type:z.GLOBALS_SYNC},Fe);else{const r=[];for(const e in Ft){const{worker:t,resolvers:n}=Ft[e].workerContext;t&&r.push(Pt(t,z.GLOBALS_SYNC,"",[Fe],n))}await Promise.all(r)}}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]}async function _s(r,e,t,n){const i=new e;if(i.addEventListener("message",async({data:s})=>{var a,c,u,f,m,p,b;switch(s.type){case z.GLOBALS_SYNC:s.id?((c=t.get((a=s.id)!=null?a:-1))==null||c(s.result),t.delete((u=s.id)!=null?u:-1)):(qe((f=s.result)!=null?f:{},Fe),await vs());break;case z.EVENT:const{result:d}=s,g=d;if(g?.name==null)throw"Missing event name";n(g.name,g.data);break;default:(p=t.get((m=s.id)!=null?m:-1))==null||p(s.result),t.delete((b=s.id)!=null?b:-1)}}),!await Pt(i,z.INIT,"",[r.workerId,Fe],t))throw"Failed to instantiate workerized class";return i}const ne=new WeakMap,ge=new WeakMap,K=new WeakMap,Ct=Symbol("anyProducer"),Nn=Promise.resolve(),Mt=Symbol("listenerAdded"),Ot=Symbol("listenerRemoved");let Bt=!1,Er=!1;function Me(r){if(typeof r!="string"&&typeof r!="symbol"&&typeof r!="number")throw new TypeError("`eventName` must be a string, symbol, or number")}function Dt(r){if(typeof r!="function")throw new TypeError("listener must be a function")}function Oe(r,e){const t=ge.get(r);if(t.has(e))return t.get(e)}function Xe(r,e){const t=typeof e=="string"||typeof e=="symbol"||typeof e=="number"?e:Ct,n=K.get(r);if(n.has(t))return n.get(t)}function Es(r,e,t){const n=K.get(r);if(n.has(e))for(const i of n.get(e))i.enqueue(t);if(n.has(Ct)){const i=Promise.all([e,t]);for(const o of n.get(Ct))o.enqueue(i)}}function $n(r,e){e=Array.isArray(e)?e:[e];let t=!1,n=()=>{},i=[];const o={enqueue(s){i.push(s),n()},finish(){t=!0,n()}};for(const s of e){let a=Xe(r,s);a||(a=new Set,K.get(r).set(s,a)),a.add(o)}return{async next(){return i?i.length===0?t?(i=void 0,this.next()):(await new Promise(s=>{n=s}),this.next()):{done:!1,value:await i.shift()}:{done:!0}},async return(s){i=void 0;for(const a of e){const c=Xe(r,a);c&&(c.delete(o),c.size===0&&K.get(r).delete(a))}return n(),arguments.length>0?{done:!0,value:await s}:{done:!0}},[Symbol.asyncIterator](){return this}}}function Wn(r){if(r===void 0)return Gn;if(!Array.isArray(r))throw new TypeError("`methodNames` must be an array of strings");for(const e of r)if(!Gn.includes(e))throw typeof e!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${e} is not Emittery method`);return r}const Be=r=>r===Mt||r===Ot;function Ut(r,e,t){if(Be(e))try{Bt=!0,r.emit(e,t)}finally{Bt=!1}}class ye{static mixin(e,t){return t=Wn(t),n=>{if(typeof n!="function")throw new TypeError("`target` must be function");for(const s of t)if(n.prototype[s]!==void 0)throw new Error(`The property \`${s}\` already exists on \`target\``);function i(){return Object.defineProperty(this,e,{enumerable:!1,value:new ye}),this[e]}Object.defineProperty(n.prototype,e,{enumerable:!1,get:i});const o=s=>function(...a){return this[e][s](...a)};for(const s of t)Object.defineProperty(n.prototype,s,{enumerable:!1,value:o(s)});return n}}static get isDebugEnabled(){var e,t;if(typeof((e=globalThis.process)==null?void 0:e.env)!="object")return Er;const{env:n}=(t=globalThis.process)!=null?t:{env:{}};return n.DEBUG==="emittery"||n.DEBUG==="*"||Er}static set isDebugEnabled(e){Er=e}constructor(e={}){var t;ne.set(this,new Set),ge.set(this,new Map),K.set(this,new Map),K.get(this).set(Ct,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,o,s)=>{try{s=JSON.stringify(s)}catch{s=`Object with the following keys failed to stringify: ${Object.keys(s).join(",")}`}(typeof o=="symbol"||typeof o=="number")&&(o=o.toString());const a=new Date,c=`${a.getHours()}:${a.getMinutes()}:${a.getSeconds()}.${a.getMilliseconds()}`;console.log(`[${c}][emittery:${n}][${i}] Event Name: ${o}
|
|
4
|
+
data: ${s}`)})}logIfDebugEnabled(e,t,n){(ye.isDebugEnabled||this.debug.enabled)&&this.debug.logger(e,this.debug.name,t,n)}on(e,t){Dt(t),e=Array.isArray(e)?e:[e];for(const n of e){Me(n);let i=Oe(this,n);i||(i=new Set,ge.get(this).set(n,i)),i.add(t),this.logIfDebugEnabled("subscribe",n,void 0),Be(n)||Ut(this,Mt,{eventName:n,listener:t})}return this.off.bind(this,e,t)}off(e,t){Dt(t),e=Array.isArray(e)?e:[e];for(const n of e){Me(n);const i=Oe(this,n);i&&(i.delete(t),i.size===0&&ge.get(this).delete(n)),this.logIfDebugEnabled("unsubscribe",n,void 0),Be(n)||Ut(this,Ot,{eventName:n,listener:t})}}once(e){let t;const n=new Promise(i=>{t=this.on(e,o=>{t(),i(o)})});return n.off=t,n}events(e){e=Array.isArray(e)?e:[e];for(const t of e)Me(t);return $n(this,e)}async emit(e,t){var n;if(Me(e),Be(e)&&!Bt)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",e,t),Es(this,e,t);const i=(n=Oe(this,e))!=null?n:new Set,o=ne.get(this),s=[...i],a=Be(e)?[]:[...o];await Nn,await Promise.all([...s.map(async c=>{if(i.has(c))return c(t)}),...a.map(async c=>{if(o.has(c))return c(e,t)})])}async emitSerial(e,t){var n;if(Me(e),Be(e)&&!Bt)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",e,t);const i=(n=Oe(this,e))!=null?n:new Set,o=ne.get(this),s=[...i],a=[...o];await Nn;for(const c of s)i.has(c)&&await c(t);for(const c of a)o.has(c)&&await c(e,t)}onAny(e){return Dt(e),this.logIfDebugEnabled("subscribeAny",void 0,void 0),ne.get(this).add(e),Ut(this,Mt,{listener:e}),this.offAny.bind(this,e)}anyEvent(){return $n(this)}offAny(e){Dt(e),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),Ut(this,Ot,{listener:e}),ne.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=Oe(this,t);n&&n.clear();const i=Xe(this,t);if(i){for(const o of i)o.finish();i.clear()}}else{ne.get(this).clear();for(const[n,i]of ge.get(this).entries())i.clear(),ge.get(this).delete(n);for(const[n,i]of K.get(this).entries()){for(const o of i)o.finish();i.clear(),K.get(this).delete(n)}}}listenerCount(e){var t,n,i,o,s,a;e=Array.isArray(e)?e:[e];let c=0;for(const u of e){if(typeof u=="string"){c+=ne.get(this).size+((n=(t=Oe(this,u))==null?void 0:t.size)!=null?n:0)+((o=(i=Xe(this,u))==null?void 0:i.size)!=null?o:0)+((a=(s=Xe(this))==null?void 0:s.size)!=null?a:0);continue}typeof u<"u"&&Me(u),c+=ne.get(this).size;for(const f of ge.get(this).values())c+=f.size;for(const f of K.get(this).values())c+=f.size}return c}bindMethods(e,t){if(typeof e!="object"||e===null)throw new TypeError("`target` must be an object");t=Wn(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 Gn=Object.getOwnPropertyNames(ye.prototype).filter(r=>r!=="constructor");Object.defineProperty(ye,"listenerAdded",{value:Mt,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(ye,"listenerRemoved",{value:Ot,writable:!1,enumerable:!0,configurable:!1});function As(r){return r.onAny&&r.emit}function Ts(r){return r.prototype.onAny&&r.prototype.emit}let Ss=0;async function Is(r,e,t){const i=Ts(r)?new ye:{},o=Ss++;return Object.getOwnPropertyNames(r.prototype).forEach(s=>{i[s]=(...a)=>Pt(e,z.FORWARD,s,a,t)}),i.terminate=async(...s)=>{const a=await Pt(e,z.TERMINATE,"",s,t);return delete Ft[o],e.terminate(),i.workerContext.worker=void 0,a},i.workerContext={id:o,worker:e,resolvers:t},Ft[o]=i,i}async function Rs(r,e){const t=new Map;let n;const i=await _s(r,e,t,(o,s)=>{n?.emit&&n?.emit(o,s)});return n=await Is(r,i,t),n}async function ks(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}`;Ce(r,await e.instance[t](...n??[]))}const Vn=vr("registeredWorkers",{});function Ps(r,e){e.workerId=r,_r()&&(Vn[e.workerId]=e)}function Fs(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Vn[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;qe(n,Fe),As(e.instance)&&e.instance.onAny((o,s)=>{Ce({type:z.EVENT},{name:o,data:s})}),Ce(r,typeof e.instance!==void 0)}async function Cs(r,e){const{args:t}=r;if(!e.instance)throw"instance not initialized";let n;e.instance.terminate&&(n=await e.instance.terminate(...t??[])),Ce(r,n)}function Ms(r){if(!r.args)throw"Missing globals while syncing";qe(r.args[0],Fe),Ce(r,{})}function Os(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case z.INIT:Fs(t,r);break;case z.FORWARD:ks(t,r);break;case z.TERMINATE:Cs(t,r);break;case z.GLOBALS_SYNC:Ms(t);break}}}_r()&&Os();class Hn{static async createVideoReadable(e){return new Promise((t,n)=>{const i=document.createElement("video");let o=new AbortController,s=new AbortController;i.addEventListener("canplay",()=>{o.abort(),i.muted=!0,i.loop=!0,i.play().then(()=>{try{const a=i.captureStream(),c=new MediaStreamTrackProcessor(a.getVideoTracks()[0]);t(c.readable)}catch(a){n(a)}})},{once:!0,signal:s.signal}),i.addEventListener("error",a=>{s.abort(),n("loading error:"+a)},{once:!0,signal:o.signal}),i.crossOrigin="anonymous",i.src=e})}static async createImageCanvas(e){const n=await(await fetch(e)).blob();return await createImageBitmap(n)}}var Bs=Object.defineProperty,Ds=(r,e,t)=>e in r?Bs(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Us=(r,e,t)=>(Ds(r,e+"",t),t);const Ls="hlg.tokbox.com/prod/logging/vcp_webrtc",zs="https://",Ns=1e4;let Lt;const $s=new Uint8Array(16);function Ws(){if(!Lt&&(Lt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Lt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Lt($s)}const F=[];for(let r=0;r<256;++r)F.push((r+256).toString(16).slice(1));function Gs(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 Vs=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),jn={randomUUID:Vs};function Hs(r,e,t){if(jn.randomUUID&&!e&&!r)return jn.randomUUID();r=r||{};const n=r.random||(r.rng||Ws)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Gs(n)}function Ar(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 ie=Ar("globals",{});var be=(r=>(r.INIT="INIT",r.FORWARD="FORWARD",r.TERMINATE="TERMINATE",r.GLOBALS_SYNC="GLOBALS_SYNC",r))(be||{});function Yn(r){return[ImageBitmap,ReadableStream,WritableStream].some(e=>r instanceof e)}let js=0;function Ys(r,e,t,n,i){const o=js++;return r.postMessage({id:o,type:e,functionName:t,args:n},n.filter(s=>Yn(s))),new Promise(s=>{i?.set(o,s)})}function Ke(r,e){const{id:t,type:n}=r,i=Array.isArray(e)?e:[e];postMessage({id:t,type:n,result:e},i.filter(o=>Yn(o)))}const Qn=Ar("workerized",{});function qn(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}async function Qs(){if(qn())Ke({type:be.GLOBALS_SYNC},ie);else{const r=[];for(const e in Qn){const{worker:t,resolvers:n}=Qn[e].workerContext;t&&r.push(Ys(t,be.GLOBALS_SYNC,"",[ie],n))}await Promise.all(r)}}function zt(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]=[],zt(r[t],e[t])):typeof r[t]=="object"?(e[t]={},zt(r[t],e[t])):e[t]=r[t]}async function qs(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}`;Ke(r,await e.instance[t](...n??[]))}const Xs=Ar("registeredWorkers",{});function Ks(r,e){if(!r.args)throw"Missing className while initializing worker";const[t,n]=r.args,i=Xs[t];if(i)e.instance=new i(r.args.slice(1));else throw`unknown worker class ${t}`;zt(n,ie),Ke(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??[])),Ke(r,n)}function Zs(r){if(!r.args)throw"Missing globals while syncing";zt(r.args[0],ie),Ke(r,{})}function ea(){const r={};onmessage=async e=>{const t=e.data;switch(t.type){case be.INIT:Ks(t,r);break;case be.FORWARD:qs(t,r);break;case be.TERMINATE:Js(t,r);break;case be.GLOBALS_SYNC:Zs(t);break}}}qn()&&ea();function ta(r,e){return ie[r]||(ie[r]=e),[()=>ie[r],async t=>{ie[r]=t,await Qs()}]}function ra(r,e){return ta(r,e)}const[na]=ra("metadata");function Tr(){return na()}class ia{constructor(e){Us(this,"uuid",Hs()),this.config=e}async send(e){var t,n,i;const{appId:o,sourceType:s}=(t=Tr())!=null?t:{};if(!o||!s)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=Tr().proxyUrl)!=null?e:zs;return t+=(t.at(-1)==="/"?"":"/")+Ls,t}getHeaders(){return{"Content-Type":"application/json"}}buildReport(e){const t=Tr();return{guid:this.uuid,...e,applicationId:t.appId,timestamp:Date.now(),proxyUrl:t.proxyUrl,source:t.sourceType}}}const oa="7.0.0-alpha.3";class Sr{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:o}=e;this.context.save(),this.context.drawImage(t,0,0,t.width,t.height,0,0,i,o),this.context.filter="blur(5px)",this.context.globalCompositeOperation="source-in",this.context.drawImage(t,0,0,t.width,t.height,0,0,i,o),this.context.globalCompositeOperation="source-in",this.context.filter=n,this.context.drawImage(e,0,0,i,o,0,0,this.canvas.width,this.canvas.height),this.context.restore()}destroy(){}}class sa extends Sr{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 aa extends Sr{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 ca extends Sr{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 Ir=5120,Je=5121,Rr=5122,kr=5123,Pr=5124,Fr=5125,Cr=5126,ua=32819,la=32820,fa=33635,da=5131,ha=33640,ma=35899,pa=35902,ga=36269,ya=34042,Xn={};{const r=Xn;r[Ir]=Int8Array,r[Je]=Uint8Array,r[Rr]=Int16Array,r[kr]=Uint16Array,r[Pr]=Int32Array,r[Fr]=Uint32Array,r[Cr]=Float32Array,r[ua]=Uint16Array,r[la]=Uint16Array,r[fa]=Uint16Array,r[da]=Uint16Array,r[ha]=Uint32Array,r[ma]=Uint32Array,r[pa]=Uint32Array,r[ga]=Uint32Array,r[ya]=Uint32Array}function Mr(r){if(r instanceof Int8Array)return Ir;if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return Je;if(r instanceof Int16Array)return Rr;if(r instanceof Uint16Array)return kr;if(r instanceof Int32Array)return Pr;if(r instanceof Uint32Array)return Fr;if(r instanceof Float32Array)return Cr;throw new Error("unsupported typed array type")}function Kn(r){if(r===Int8Array)return Ir;if(r===Uint8Array||r===Uint8ClampedArray)return Je;if(r===Int16Array)return Rr;if(r===Uint16Array)return kr;if(r===Int32Array)return Pr;if(r===Uint32Array)return Fr;if(r===Float32Array)return Cr;throw new Error("unsupported typed array type")}function Jn(r){const e=Xn[r];if(!e)throw new Error("unknown gl type");return e}const Nt=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 Zn(...r){console.error(...r)}const ei=new Map;function $t(r,e){if(!r||typeof r!="object")return!1;let t=ei.get(e);t||(t=new WeakMap,ei.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 ba(r,e){return typeof WebGLBuffer<"u"&&$t(e,"WebGLBuffer")}function wa(r,e){return typeof WebGLRenderbuffer<"u"&&$t(e,"WebGLRenderbuffer")}function Or(r,e){return typeof WebGLTexture<"u"&&$t(e,"WebGLTexture")}function xa(r,e){return typeof WebGLSampler<"u"&&$t(e,"WebGLSampler")}const ti=35044,we=34962,va=34963,_a=34660,Ea=5120,Aa=5121,Ta=5122,Sa=5123,Ia=5124,Ra=5125,ri=5126,ni={attribPrefix:""};function ka(r,e,t,n,i){r.bindBuffer(e,t),r.bufferData(e,n,i||ti)}function ii(r,e,t,n){if(ba(r,e))return e;t=t||we;const i=r.createBuffer();return ka(r,t,i,e,n),i}function oi(r){return r==="indices"}function Pa(r){return r===Int8Array||r===Uint8Array}function Fa(r){return r.length?r:r.data}const Ca=/coord|texture/i,Ma=/color|colour/i;function Oa(r,e){let t;if(Ca.test(r)?t=2:Ma.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 Ba(r,e,t){return r.numComponents||r.size||Oa(e,t||Fa(r).length)}function si(r,e){if(Nt(r))return r;if(Nt(r.data))return r.data;Array.isArray(r)&&(r={data:r});let t=r.type?Br(r.type):void 0;return t||(oi(e)?t=Uint16Array:t=Float32Array),new t(r.data)}function Da(r){return typeof r=="number"?r:r?Kn(r):ri}function Br(r){return typeof r=="number"?Jn(r):r||Float32Array}function Ua(r,e){return{buffer:e.buffer,numValues:24,type:Da(e.type),arrayType:Br(e.type)}}function La(r,e){const t=e.data||e,n=Br(e.type),i=t*n.BYTES_PER_ELEMENT,o=r.createBuffer();return r.bindBuffer(we,o),r.bufferData(we,i,e.drawType||ti),{buffer:o,numValues:t,type:Kn(n),arrayType:n}}function za(r,e,t){const n=si(e,t);return{arrayType:n.constructor,buffer:ii(r,n,void 0,e.drawType),type:Mr(n),numValues:0}}function Na(r,e){const t={};return Object.keys(e).forEach(function(n){if(!oi(n)){const i=e[n],o=i.attrib||i.name||i.attribName||ni.attribPrefix+n;if(i.value){if(!Array.isArray(i.value)&&!Nt(i.value))throw new Error("array.value is not array or typedarray");t[o]={value:i.value}}else{let s;i.buffer&&i.buffer instanceof WebGLBuffer?s=Ua:typeof i=="number"||typeof i.data=="number"?s=La:s=za;const{buffer:a,type:c,numValues:u,arrayType:f}=s(r,i,n),m=i.normalize!==void 0?i.normalize:Pa(f),p=Ba(i,n,u);t[o]={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(we,null),t}function $a(r,e){return e===Ea||e===Aa?1:e===Ta||e===Sa?2:e===Ia||e===Ra||e===ri?4:0}const Dr=["position","positions","a_position"];function Wa(r,e){let t,n;for(n=0;n<Dr.length&&(t=Dr[n],!(t in e||(t=ni.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(we,i.buffer);const o=r.getBufferParameter(we,_a);r.bindBuffer(we,null);const s=$a(r,i.type),a=o/s,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 Ga(r,e,t){const n=Na(r,e),i=Object.assign({},t||{});i.attribs=Object.assign({},t?t.attribs:{},n);const o=e.indices;if(o){const s=si(o,"indices");i.indices=ii(r,s,va),i.numElements=s.length,i.elementType=Mr(s)}else i.numElements||(i.numElements=Wa(r,i.attribs));return i}function Ze(r){return!!r.texStorage2D}const ai=(function(){const r={},e={};function t(n){const i=n.constructor.name;if(!r[i]){for(const o in n)if(typeof n[o]=="number"){const s=e[n[o]];e[n[o]]=s?`${s} | ${o}`:o}r[i]=!0}}return function(i,o){return t(i),e[o]||(typeof o=="number"?`0x${o.toString(16)}`:o)}})(),oe={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},et=Nt,ci=(function(){let r;return function(){return r=r||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),r}})(),ui=6406,j=6407,T=6408,li=6409,fi=6410,tt=6402,di=34041,Wt=33071,Va=9728,Ha=9729,se=3553,ae=34067,xe=32879,ve=35866,Ur=34069,ja=34070,Ya=34071,Qa=34072,qa=34073,Xa=34074,Lr=10241,zr=10240,Gt=10242,Vt=10243,hi=32882,Ka=33082,Ja=33083,Za=33084,ec=33085,tc=34892,rc=34893,Nr=3317,mi=3314,pi=32878,gi=3316,yi=3315,bi=32877,nc=37443,ic=37441,oc=37440,sc=33321,ac=36756,cc=33325,uc=33326,lc=33330,fc=33329,dc=33338,hc=33337,mc=33340,pc=33339,gc=33323,yc=36757,bc=33327,wc=33328,xc=33336,vc=33335,_c=33332,Ec=33331,Ac=33334,Tc=33333,Sc=32849,Ic=35905,Rc=36194,kc=36758,Pc=35898,Fc=35901,Cc=34843,Mc=34837,Oc=36221,Bc=36239,Dc=36215,Uc=36233,Lc=36209,zc=36227,Nc=32856,$c=35907,Wc=36759,Gc=32855,Vc=32854,Hc=32857,jc=34842,Yc=34836,Qc=36220,qc=36238,Xc=36975,Kc=36214,Jc=36232,Zc=36226,eu=36208,tu=33189,ru=33190,nu=36012,iu=36013,ou=35056,ce=5120,A=5121,Ht=5122,De=5123,jt=5124,_e=5125,O=5126,wi=32819,xi=32820,vi=33635,W=5131,rt=36193,$r=33640,su=35899,au=35902,cu=36269,uu=34042,Yt=33319,Ue=33320,Qt=6403,Le=36244,ze=36248,Ee=36249;let Wr;function qt(r){if(!Wr){const e={};e[ui]={textureFormat:ui,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,W,rt,O]},e[li]={textureFormat:li,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,W,rt,O]},e[fi]={textureFormat:fi,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[A,W,rt,O]},e[j]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[A,W,rt,O,vi]},e[T]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[A,W,rt,O,wi,xi]},e[tt]={textureFormat:tt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[_e,De]},e[sc]={textureFormat:Qt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[A]},e[ac]={textureFormat:Qt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[ce]},e[cc]={textureFormat:Qt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[O,W]},e[uc]={textureFormat:Qt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[O]},e[lc]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[A]},e[fc]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[ce]},e[_c]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[De]},e[Ec]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Ht]},e[Ac]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[_e]},e[Tc]={textureFormat:Le,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[jt]},e[gc]={textureFormat:Yt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[A]},e[yc]={textureFormat:Yt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[ce]},e[bc]={textureFormat:Yt,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[O,W]},e[wc]={textureFormat:Yt,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[O]},e[xc]={textureFormat:Ue,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[A]},e[vc]={textureFormat:Ue,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[ce]},e[dc]={textureFormat:Ue,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[De]},e[hc]={textureFormat:Ue,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ht]},e[mc]={textureFormat:Ue,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[_e]},e[pc]={textureFormat:Ue,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[jt]},e[Sc]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[A]},e[Ic]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[A]},e[Rc]={textureFormat:j,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[A,vi]},e[kc]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[ce]},e[Pc]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[O,W,su]},e[Fc]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[O,W,au]},e[Cc]={textureFormat:j,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[O,W]},e[Mc]={textureFormat:j,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[O]},e[Oc]={textureFormat:ze,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[A]},e[Bc]={textureFormat:ze,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[ce]},e[Dc]={textureFormat:ze,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[De]},e[Uc]={textureFormat:ze,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Ht]},e[Lc]={textureFormat:ze,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[_e]},e[zc]={textureFormat:ze,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[jt]},e[Nc]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},e[$c]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},e[Wc]={textureFormat:T,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[ce]},e[Gc]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[A,xi,$r]},e[Vc]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[A,wi]},e[Hc]={textureFormat:T,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[$r]},e[jc]={textureFormat:T,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[O,W]},e[Yc]={textureFormat:T,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[O]},e[Qc]={textureFormat:Ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[A]},e[qc]={textureFormat:Ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[ce]},e[Xc]={textureFormat:Ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[$r]},e[Kc]={textureFormat:Ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[De]},e[Jc]={textureFormat:Ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Ht]},e[Zc]={textureFormat:Ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[jt]},e[eu]={textureFormat:Ee,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[_e]},e[tu]={textureFormat:tt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[De,_e]},e[ru]={textureFormat:tt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[_e]},e[nu]={textureFormat:tt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[O]},e[ou]={textureFormat:di,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[uu]},e[iu]={textureFormat:di,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[cu]},Object.keys(e).forEach(function(t){const n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(i,o){const s=n.type[o];n.bytesPerElementMap[s]=i})}),Wr=e}return Wr[r]}function lu(r,e){const t=qt(r);if(!t)throw"unknown internal format";const n=t.bytesPerElementMap[e];if(n===void 0)throw"unknown internal format";return n}function nt(r){const e=qt(r);if(!e)throw"unknown internal format";return{format:e.textureFormat,type:e.type[0]}}function _i(r){return(r&r-1)===0}function fu(r,e,t,n){if(!Ze(r))return _i(e)&&_i(t);const i=qt(n);if(!i)throw"unknown internal format";return i.colorRenderable&&i.textureFilterable}function du(r){const e=qt(r);if(!e)throw"unknown internal format";return e.textureFilterable}function hu(r,e,t){return et(e)?Mr(e):t||A}function Xt(r,e,t,n,i){if(i%1!==0)throw"can't guess dimensions";if(!t&&!n){const o=Math.sqrt(i/(e===ae?6:1));o%1===0?(t=o,n=o):(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 Ne(r,e){e.colorspaceConversion!==void 0&&r.pixelStorei(nc,e.colorspaceConversion),e.premultiplyAlpha!==void 0&&r.pixelStorei(ic,e.premultiplyAlpha),e.flipY!==void 0&&r.pixelStorei(oc,e.flipY)}function Ei(r){r.pixelStorei(Nr,4),Ze(r)&&(r.pixelStorei(mi,0),r.pixelStorei(pi,0),r.pixelStorei(gi,0),r.pixelStorei(yi,0),r.pixelStorei(bi,0))}function mu(r,e,t,n){n.minMag&&(t.call(r,e,Lr,n.minMag),t.call(r,e,zr,n.minMag)),n.min&&t.call(r,e,Lr,n.min),n.mag&&t.call(r,e,zr,n.mag),n.wrap&&(t.call(r,e,Gt,n.wrap),t.call(r,e,Vt,n.wrap),(e===xe||xa(r,e))&&t.call(r,e,hi,n.wrap)),n.wrapR&&t.call(r,e,hi,n.wrapR),n.wrapS&&t.call(r,e,Gt,n.wrapS),n.wrapT&&t.call(r,e,Vt,n.wrapT),n.minLod!==void 0&&t.call(r,e,Ka,n.minLod),n.maxLod!==void 0&&t.call(r,e,Ja,n.maxLod),n.baseLevel!==void 0&&t.call(r,e,Za,n.baseLevel),n.maxLevel!==void 0&&t.call(r,e,ec,n.maxLevel),n.compareFunc!==void 0&&t.call(r,e,rc,n.compareFunc),n.compareMode!==void 0&&t.call(r,e,tc,n.compareMode)}function Ai(r,e,t){const n=t.target||se;r.bindTexture(n,e),mu(r,n,r.texParameteri,t)}function pu(r){return r=r||oe.textureColor,et(r)?r:new Uint8Array([r[0]*255,r[1]*255,r[2]*255,r[3]*255])}function Gr(r,e,t,n,i,o){t=t||oe.textureOptions,o=o||T;const s=t.target||se;if(n=n||t.width,i=i||t.height,r.bindTexture(s,e),fu(r,n,i,o))r.generateMipmap(s);else{const a=du(o)?Ha:Va;r.texParameteri(s,Lr,a),r.texParameteri(s,zr,a),r.texParameteri(s,Gt,Wt),r.texParameteri(s,Vt,Wt)}}function it(r){return r.auto===!0||r.auto===void 0&&r.level===void 0}function Vr(r,e){return e=e||{},e.cubeFaceOrder||[Ur,ja,Ya,Qa,qa,Xa]}function Hr(r,e){const n=Vr(r,e).map(function(i,o){return{face:i,ndx:o}});return n.sort(function(i,o){return i.face-o.face}),n}function Ti(r,e,t,n){n=n||oe.textureOptions;const i=n.target||se,o=n.level||0;let s=t.width,a=t.height;const c=n.internalFormat||n.format||T,u=nt(c),f=n.format||u.format,m=n.type||u.type;if(Ne(r,n),r.bindTexture(i,e),i===ae){const p=t.width,b=t.height;let d,g;if(p/6===b)d=b,g=[0,0,1,0,2,0,3,0,4,0,5,0];else if(b/6===p)d=p,g=[0,0,0,1,0,2,0,3,0,4,0,5];else if(p/3===b/2)d=p/3,g=[0,0,1,0,2,0,0,1,1,1,2,1];else if(p/2===b/3)d=p/2,g=[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 x=ci();x?(x.canvas.width=d,x.canvas.height=d,s=d,a=d,Hr(r,n).forEach(function(v){const R=g[v.ndx*2+0]*d,C=g[v.ndx*2+1]*d;x.drawImage(t,R,C,d,d,0,0,d,d),r.texImage2D(v.face,o,c,f,m,x.canvas)}),x.canvas.width=1,x.canvas.height=1):typeof createImageBitmap<"u"&&(s=d,a=d,Hr(r,n).forEach(function(v){const R=g[v.ndx*2+0]*d,C=g[v.ndx*2+1]*d;r.texImage2D(v.face,o,c,d,d,0,f,m,null),createImageBitmap(t,R,C,d,d,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(N){Ne(r,n),r.bindTexture(i,e),r.texImage2D(v.face,o,c,f,m,N),it(n)&&Gr(r,e,n,s,a,c)})}))}else if(i===xe||i===ve){const p=Math.min(t.width,t.height),b=Math.max(t.width,t.height),d=b/p;if(d%1!==0)throw"can not compute 3D dimensions of element";const g=t.width===b?1:0,x=t.height===b?1:0;r.pixelStorei(Nr,1),r.pixelStorei(mi,t.width),r.pixelStorei(pi,0),r.pixelStorei(bi,0),r.texImage3D(i,o,c,p,p,p,0,f,m,null);for(let v=0;v<d;++v){const R=v*p*g,C=v*p*x;r.pixelStorei(gi,R),r.pixelStorei(yi,C),r.texSubImage3D(i,o,0,0,v,p,p,1,f,m,t)}Ei(r)}else r.texImage2D(i,o,c,f,m,t);it(n)&&Gr(r,e,n,s,a,c),Ai(r,e,n)}function ot(){}function gu(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 yu(r,e){return e===void 0&&!gu(r)?"anonymous":e}function bu(r,e,t){t=t||ot;let n;if(e=e!==void 0?e:oe.crossOrigin,e=yu(r,e),typeof Image<"u"){n=new Image,e!==void 0&&(n.crossOrigin=e);const i=function(){n.removeEventListener("error",o),n.removeEventListener("load",s),n=null},o=function(){const c="couldn't load image: "+r;Zn(c),t(c,n),i()},s=function(){t(null,n),i()};return n.addEventListener("error",o),n.addEventListener("load",s),n.src=r,n}else if(typeof ImageBitmap<"u"){let i,o;const s=function(){t(i,o)},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){o=c,setTimeout(s)}).catch(function(c){i=c,setTimeout(s)}),n=null}return n}function Si(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof ImageData<"u"&&r instanceof ImageData||typeof HTMLElement<"u"&&r instanceof HTMLElement}function jr(r,e,t){return Si(r)?(setTimeout(function(){t(null,r)}),r):bu(r,e,t)}function Yr(r,e,t){t=t||oe.textureOptions;const n=t.target||se;if(r.bindTexture(n,e),t.color===!1)return;const i=pu(t.color);if(n===ae)for(let o=0;o<6;++o)r.texImage2D(Ur+o,0,T,1,1,0,T,A,i);else n===xe||n===ve?r.texImage3D(n,0,T,1,1,1,0,T,A,i):r.texImage2D(n,0,T,1,1,0,T,A,i)}function wu(r,e,t,n){return n=n||ot,t=t||oe.textureOptions,Yr(r,e,t),t=Object.assign({},t),jr(t.src,t.crossOrigin,function(o,s){o?n(o,e,s):(Ti(r,e,s,t),n(null,e,s))})}function xu(r,e,t,n){n=n||ot;const i=t.src;if(i.length!==6)throw"there must be 6 urls for a cubemap";const o=t.level||0,s=t.internalFormat||t.format||T,a=nt(s),c=t.format||a.format,u=t.type||A,f=t.target||se;if(f!==ae)throw"target must be TEXTURE_CUBE_MAP";Yr(r,e,t),t=Object.assign({},t);let m=6;const p=[],b=Vr(r,t);let d;function g(x){return function(v,R){--m,v?p.push(v):R.width!==R.height?p.push("cubemap face img is not a square: "+R.src):(Ne(r,t),r.bindTexture(f,e),m===5?Vr().forEach(function(C){r.texImage2D(C,o,s,c,u,R)}):r.texImage2D(x,o,s,c,u,R),it(t)&&r.generateMipmap(f)),m===0&&n(p.length?p:void 0,e,d)}}d=i.map(function(x,v){return jr(x,t.crossOrigin,g(b[v]))})}function vu(r,e,t,n){n=n||ot;const i=t.src,o=t.internalFormat||t.format||T,s=nt(o),a=t.format||s.format,c=t.type||A,u=t.target||ve;if(u!==xe&&u!==ve)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";Yr(r,e,t),t=Object.assign({},t);let f=i.length;const m=[];let p;const b=t.level||0;let d=t.width,g=t.height;const x=i.length;let v=!0;function R(C){return function(N,J){if(--f,N)m.push(N);else{if(Ne(r,t),r.bindTexture(u,e),v){v=!1,d=t.width||J.width,g=t.height||J.height,r.texImage3D(u,b,o,d,g,x,0,a,c,null);for(let Z=0;Z<x;++Z)r.texSubImage3D(u,b,0,0,Z,d,g,1,a,c,J)}else{let Z=J,$;(J.width!==d||J.height!==g)&&($=ci(),Z=$.canvas,$.canvas.width=d,$.canvas.height=g,$.drawImage(J,0,0,d,g)),r.texSubImage3D(u,b,0,0,C,d,g,1,a,c,Z),$&&Z===$.canvas&&($.canvas.width=0,$.canvas.height=0)}it(t)&&r.generateMipmap(u)}f===0&&n(m.length?m:void 0,e,p)}}p=i.map(function(C,N){return jr(C,t.crossOrigin,R(N))})}function _u(r,e,t,n){n=n||oe.textureOptions;const i=n.target||se;r.bindTexture(i,e);let o=n.width,s=n.height,a=n.depth;const c=n.level||0,u=n.internalFormat||n.format||T,f=nt(u),m=n.format||f.format,p=n.type||hu(r,t,f.type);if(et(t))t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));else{const x=Jn(p);t=new x(t)}const b=lu(u,p),d=t.byteLength/b;if(d%1)throw"length wrong size for format: "+ai(r,m);let g;if(i===xe||i===ve)if(!o&&!s&&!a){const x=Math.cbrt(d);if(x%1!==0)throw"can't guess cube size of array of numElements: "+d;o=x,s=x,a=x}else o&&(!s||!a)?(g=Xt(r,i,s,a,d/o),s=g.width,a=g.height):s&&(!o||!a)?(g=Xt(r,i,o,a,d/s),o=g.width,a=g.height):(g=Xt(r,i,o,s,d/a),o=g.width,s=g.height);else g=Xt(r,i,o,s,d),o=g.width,s=g.height;if(Ei(r),r.pixelStorei(Nr,n.unpackAlignment||1),Ne(r,n),i===ae){const x=b/t.BYTES_PER_ELEMENT,v=d/6*x;Hr(r,n).forEach(R=>{const C=v*R.ndx,N=t.subarray(C,C+v);r.texImage2D(R.face,c,u,o,s,0,m,p,N)})}else i===xe||i===ve?r.texImage3D(i,c,u,o,s,a,0,m,p,t):r.texImage2D(i,c,u,o,s,0,m,p,t);return{width:o,height:s,depth:a,type:p}}function Eu(r,e,t){const n=t.target||se;r.bindTexture(n,e);const i=t.level||0,o=t.internalFormat||t.format||T,s=nt(o),a=t.format||s.format,c=t.type||s.type;if(Ne(r,t),n===ae)for(let u=0;u<6;++u)r.texImage2D(Ur+u,i,o,t.width,t.height,0,a,c,null);else n===xe||n===ve?r.texImage3D(n,i,o,t.width,t.height,t.depth,0,a,c,null):r.texImage2D(n,i,o,t.width,t.height,0,a,c,null)}function Ii(r,e,t){t=t||ot,e=e||oe.textureOptions;const n=r.createTexture(),i=e.target||se;let o=e.width||1,s=e.height||1;const a=e.internalFormat||T;r.bindTexture(i,n),i===ae&&(r.texParameteri(i,Gt,Wt),r.texParameteri(i,Vt,Wt));let c=e.src;if(c)if(typeof c=="function"&&(c=c(r,e)),typeof c=="string")wu(r,n,e,t);else if(et(c)||Array.isArray(c)&&(typeof c[0]=="number"||Array.isArray(c[0])||et(c[0]))){const u=_u(r,n,c,e);o=u.width,s=u.height}else Array.isArray(c)&&(typeof c[0]=="string"||Si(c[0]))?i===ae?xu(r,n,e,t):vu(r,n,e,t):(Ti(r,n,c,e),o=c.width,s=c.height);else Eu(r,n,e);return it(e)&&Gr(r,n,e,o,s,a),Ai(r,n,e),n}const Qr=Zn;function Ri(r){return typeof document<"u"&&document.getElementById?document.getElementById(r):null}const Kt=33984,Jt=34962,Au=34963,Tu=35713,Su=35714,Iu=35632,Ru=35633,ku=35981,ki=35718,Pu=35721,Fu=35971,Cu=35382,Mu=35396,Ou=35398,Bu=35392,Du=35395,Zt=5126,Pi=35664,Fi=35665,Ci=35666,qr=5124,Mi=35667,Oi=35668,Bi=35669,Di=35670,Ui=35671,Li=35672,zi=35673,Ni=35674,$i=35675,Wi=35676,Uu=35678,Lu=35680,zu=35679,Nu=35682,$u=35685,Wu=35686,Gu=35687,Vu=35688,Hu=35689,ju=35690,Yu=36289,Qu=36292,qu=36293,Xr=5125,Gi=36294,Vi=36295,Hi=36296,Xu=36298,Ku=36299,Ju=36300,Zu=36303,el=36306,tl=36307,rl=36308,nl=36311,er=3553,tr=34067,Kr=32879,rr=35866,w={};function ji(r,e){return w[e].bindPoint}function il(r,e){return function(t){r.uniform1f(e,t)}}function ol(r,e){return function(t){r.uniform1fv(e,t)}}function sl(r,e){return function(t){r.uniform2fv(e,t)}}function al(r,e){return function(t){r.uniform3fv(e,t)}}function cl(r,e){return function(t){r.uniform4fv(e,t)}}function Yi(r,e){return function(t){r.uniform1i(e,t)}}function Qi(r,e){return function(t){r.uniform1iv(e,t)}}function qi(r,e){return function(t){r.uniform2iv(e,t)}}function Xi(r,e){return function(t){r.uniform3iv(e,t)}}function Ki(r,e){return function(t){r.uniform4iv(e,t)}}function ul(r,e){return function(t){r.uniform1ui(e,t)}}function ll(r,e){return function(t){r.uniform1uiv(e,t)}}function fl(r,e){return function(t){r.uniform2uiv(e,t)}}function dl(r,e){return function(t){r.uniform3uiv(e,t)}}function hl(r,e){return function(t){r.uniform4uiv(e,t)}}function ml(r,e){return function(t){r.uniformMatrix2fv(e,!1,t)}}function pl(r,e){return function(t){r.uniformMatrix3fv(e,!1,t)}}function gl(r,e){return function(t){r.uniformMatrix4fv(e,!1,t)}}function yl(r,e){return function(t){r.uniformMatrix2x3fv(e,!1,t)}}function bl(r,e){return function(t){r.uniformMatrix3x2fv(e,!1,t)}}function wl(r,e){return function(t){r.uniformMatrix2x4fv(e,!1,t)}}function xl(r,e){return function(t){r.uniformMatrix4x2fv(e,!1,t)}}function vl(r,e){return function(t){r.uniformMatrix3x4fv(e,!1,t)}}function _l(r,e){return function(t){r.uniformMatrix4x3fv(e,!1,t)}}function U(r,e,t,n){const i=ji(r,e);return Ze(r)?function(o){let s,a;!o||Or(r,o)?(s=o,a=null):(s=o.texture,a=o.sampler),r.uniform1i(n,t),r.activeTexture(Kt+t),r.bindTexture(i,s),r.bindSampler(t,a)}:function(o){r.uniform1i(n,t),r.activeTexture(Kt+t),r.bindTexture(i,o)}}function L(r,e,t,n,i){const o=ji(r,e),s=new Int32Array(i);for(let a=0;a<i;++a)s[a]=t+a;return Ze(r)?function(a){r.uniform1iv(n,s),a.forEach(function(c,u){r.activeTexture(Kt+s[u]);let f,m;!c||Or(r,c)?(f=c,m=null):(f=c.texture,m=c.sampler),r.bindSampler(t,m),r.bindTexture(o,f)})}:function(a){r.uniform1iv(n,s),a.forEach(function(c,u){r.activeTexture(Kt+s[u]),r.bindTexture(o,c)})}}w[Zt]={Type:Float32Array,size:4,setter:il,arraySetter:ol},w[Pi]={Type:Float32Array,size:8,setter:sl,cols:2},w[Fi]={Type:Float32Array,size:12,setter:al,cols:3},w[Ci]={Type:Float32Array,size:16,setter:cl,cols:4},w[qr]={Type:Int32Array,size:4,setter:Yi,arraySetter:Qi},w[Mi]={Type:Int32Array,size:8,setter:qi,cols:2},w[Oi]={Type:Int32Array,size:12,setter:Xi,cols:3},w[Bi]={Type:Int32Array,size:16,setter:Ki,cols:4},w[Xr]={Type:Uint32Array,size:4,setter:ul,arraySetter:ll},w[Gi]={Type:Uint32Array,size:8,setter:fl,cols:2},w[Vi]={Type:Uint32Array,size:12,setter:dl,cols:3},w[Hi]={Type:Uint32Array,size:16,setter:hl,cols:4},w[Di]={Type:Uint32Array,size:4,setter:Yi,arraySetter:Qi},w[Ui]={Type:Uint32Array,size:8,setter:qi,cols:2},w[Li]={Type:Uint32Array,size:12,setter:Xi,cols:3},w[zi]={Type:Uint32Array,size:16,setter:Ki,cols:4},w[Ni]={Type:Float32Array,size:32,setter:ml,rows:2,cols:2},w[$i]={Type:Float32Array,size:48,setter:pl,rows:3,cols:3},w[Wi]={Type:Float32Array,size:64,setter:gl,rows:4,cols:4},w[$u]={Type:Float32Array,size:32,setter:yl,rows:2,cols:3},w[Wu]={Type:Float32Array,size:32,setter:wl,rows:2,cols:4},w[Gu]={Type:Float32Array,size:48,setter:bl,rows:3,cols:2},w[Vu]={Type:Float32Array,size:48,setter:vl,rows:3,cols:4},w[Hu]={Type:Float32Array,size:64,setter:xl,rows:4,cols:2},w[ju]={Type:Float32Array,size:64,setter:_l,rows:4,cols:3},w[Uu]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:er},w[Lu]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:tr},w[zu]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:Kr},w[Nu]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:er},w[Yu]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:rr},w[Qu]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:rr},w[qu]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:tr},w[Xu]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:er},w[Ku]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:Kr},w[Ju]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:tr},w[Zu]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:rr},w[el]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:er},w[tl]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:Kr},w[rl]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:tr},w[nl]={Type:null,size:0,setter:U,arraySetter:L,bindPoint:rr};function nr(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(Jt,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribPointer(e,t.numComponents||t.size,t.type||Zt,t.normalize||!1,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function ue(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(Jt,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||qr,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function ir(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(Jt,t.buffer),r.enableVertexAttribArray(e),r.vertexAttribIPointer(e,t.numComponents||t.size,t.type||Xr,t.stride||0,t.offset||0),r.vertexAttribDivisor&&r.vertexAttribDivisor(e,t.divisor||0)}}function Jr(r,e,t){const n=t.size,i=t.count;return function(o){r.bindBuffer(Jt,o.buffer);const s=o.size||o.numComponents||n,a=s/i,c=o.type||Zt,f=w[c].size*s,m=o.normalize||!1,p=o.offset||0,b=f/i;for(let d=0;d<i;++d)r.enableVertexAttribArray(e+d),r.vertexAttribPointer(e+d,a,c,m,f,p+b*d),r.vertexAttribDivisor&&r.vertexAttribDivisor(e+d,o.divisor||0)}}const S={};S[Zt]={size:4,setter:nr},S[Pi]={size:8,setter:nr},S[Fi]={size:12,setter:nr},S[Ci]={size:16,setter:nr},S[qr]={size:4,setter:ue},S[Mi]={size:8,setter:ue},S[Oi]={size:12,setter:ue},S[Bi]={size:16,setter:ue},S[Xr]={size:4,setter:ir},S[Gi]={size:8,setter:ir},S[Vi]={size:12,setter:ir},S[Hi]={size:16,setter:ir},S[Di]={size:4,setter:ue},S[Ui]={size:8,setter:ue},S[Li]={size:12,setter:ue},S[zi]={size:16,setter:ue},S[Ni]={size:4,setter:Jr,count:2},S[$i]={size:9,setter:Jr,count:3},S[Wi]={size:16,setter:Jr,count:4};const El=/ERROR:\s*\d+:(\d+)/gi;function Al(r,e="",t=0){const n=[...e.matchAll(El)],i=new Map(n.map((o,s)=>{const a=parseInt(o[1]),c=n[s+1],u=c?c.index:e.length,f=e.substring(o.index,u);return[a-1,f]}));return r.split(`
|
|
5
|
+
`).map((o,s)=>{const a=i.get(s);return`${s+1+t}: ${o}${a?`
|
|
6
|
+
|
|
7
|
+
^^^ ${a}`:""}`}).join(`
|
|
8
|
+
`)}const Ji=/^[ \t]*\n/;function Zi(r){let e=0;return Ji.test(r)&&(e=1,r=r.replace(Ji,"")),{lineOffset:e,shaderSource:r}}function Tl(r,e){return r.errorCallback(e),r.callback&&setTimeout(()=>{r.callback(`${e}
|
|
9
|
+
${r.errors.join(`
|
|
10
|
+
`)}`)}),null}function Sl(r,e,t,n){if(n=n||Qr,!r.getShaderParameter(t,Tu)){const o=r.getShaderInfoLog(t),{lineOffset:s,shaderSource:a}=Zi(r.getShaderSource(t)),c=`${Al(a,o,s)}
|
|
11
|
+
Error compiling ${ai(r,e)}: ${o}`;return n(c),c}return""}function Zr(r,e,t){let n,i,o;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,o=u.callback}const s=t||Qr,a=[],c={errorCallback(u,...f){a.push(u),s(u,...f)},transformFeedbackVaryings:n,transformFeedbackMode:i,callback:o,errors:a};{let u={};Array.isArray(r)?r.forEach(function(f,m){u[f]=e?e[m]:m}):u=r||{},c.attribLocations=u}return c}const Il=["VERTEX_SHADER","FRAGMENT_SHADER"];function Rl(r,e){if(e.indexOf("frag")>=0)return Iu;if(e.indexOf("vert")>=0)return Ru}function kl(r,e,t){const n=r.getAttachedShaders(e);for(const i of n)t.has(i)&&r.deleteShader(i);r.deleteProgram(e)}const Pl=(r=0)=>new Promise(e=>setTimeout(e,r));function Fl(r,e,t){const n=r.createProgram(),{attribLocations:i,transformFeedbackVaryings:o,transformFeedbackMode:s}=Zr(t);for(let a=0;a<e.length;++a){let c=e[a];if(typeof c=="string"){const u=Ri(c),f=u?u.text:c;let m=r[Il[a]];u&&u.type&&(m=Rl(r,u.type)||m),c=r.createShader(m),r.shaderSource(c,Zi(f).shaderSource),r.compileShader(c),r.attachShader(n,c)}}Object.entries(i).forEach(([a,c])=>r.bindAttribLocation(n,c,a));{let a=o;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),r.transformFeedbackVaryings(n,a,s||ku))}return r.linkProgram(n),n}function Cl(r,e,t,n,i){const o=Zr(t,n,i),s=new Set(e),a=Fl(r,e,o);function c(u,f){const m=Ol(u,f,o.errorCallback);return m&&kl(u,f,s),m}if(o.callback){Ml(r,a).then(()=>{const u=c(r,a);o.callback(u,u?void 0:a)});return}return c(r,a)?void 0:a}async function Ml(r,e){const t=r.getExtension("KHR_parallel_shader_compile"),n=t?(o,s)=>o.getProgramParameter(s,t.COMPLETION_STATUS_KHR):()=>!0;let i=0;do await Pl(i),i=1e3/60;while(!n(r,e))}function Ol(r,e,t){if(t=t||Qr,!r.getProgramParameter(e,Su)){const i=r.getProgramInfoLog(e);t(`Error in program linking: ${i}`);const s=r.getAttachedShaders(e).map(a=>Sl(r,r.getShaderParameter(a,r.SHADER_TYPE),a,t));return`${i}
|
|
12
|
+
${s.filter(a=>a).join(`
|
|
13
|
+
`)}`}}function Bl(r,e,t,n,i){return Cl(r,e,t,n,i)}function eo(r){const e=r.name;return e.startsWith("gl_")||e.startsWith("webgl_")}const Dl=/(\.|\[|]|\w+)/g,Ul=r=>r>="0"&&r<="9";function Ll(r,e,t,n){const i=r.split(Dl).filter(a=>a!=="");let o=0,s="";for(;;){const a=i[o++];s+=a;const c=Ul(a[0]),u=c?parseInt(a):a;if(c&&(s+=i[o++]),o===i.length){t[u]=e;break}else{const m=i[o++],p=m==="[",b=t[u]||(p?[]:{});t[u]=b,t=b,n[s]=n[s]||(function(d){return function(g){to(d,g)}})(b),s+=m}}}function zl(r,e){let t=0;function n(a,c,u){const f=c.name.endsWith("[0]"),m=c.type,p=w[m];if(!p)throw new Error(`unknown type: 0x${m.toString(16)}`);let b;if(p.bindPoint){const d=t;t+=c.size,f?b=p.arraySetter(r,m,d,u,c.size):b=p.setter(r,m,d,u,c.size)}else p.arraySetter&&f?b=p.arraySetter(r,u):b=p.setter(r,u);return b.location=u,b}const i={},o={},s=r.getProgramParameter(e,ki);for(let a=0;a<s;++a){const c=r.getActiveUniform(e,a);if(eo(c))continue;let u=c.name;u.endsWith("[0]")&&(u=u.substr(0,u.length-3));const f=r.getUniformLocation(e,c.name);if(f){const m=n(e,c,f);i[u]=m,Ll(u,m,o,i)}}return i}function Nl(r,e){const t={},n=r.getProgramParameter(e,Fu);for(let i=0;i<n;++i){const o=r.getTransformFeedbackVarying(e,i);t[o.name]={index:i,type:o.type,size:o.size}}return t}function $l(r,e){const t=r.getProgramParameter(e,ki),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(f,m){n[m][u]=f})});const o={},s=r.getProgramParameter(e,Cu);for(let a=0;a<s;++a){const c=r.getActiveUniformBlockName(e,a),u={index:r.getUniformBlockIndex(e,c),usedByVertexShader:r.getActiveUniformBlockParameter(e,a,Mu),usedByFragmentShader:r.getActiveUniformBlockParameter(e,a,Ou),size:r.getActiveUniformBlockParameter(e,a,Bu),uniformIndices:r.getActiveUniformBlockParameter(e,a,Du)};u.used=u.usedByVertexShader||u.usedByFragmentShader,o[c]=u}return{blockSpecs:o,uniformData:n}}function to(r,e){for(const t in e){const n=r[t];typeof n=="function"?n(e[t]):to(r[t],e[t])}}function ro(r,...e){const t=r.uniformSetters||r,n=e.length;for(let i=0;i<n;++i){const o=e[i];if(Array.isArray(o)){const s=o.length;for(let a=0;a<s;++a)ro(t,o[a])}else for(const s in o){const a=t[s];a&&a(o[s])}}}function Wl(r,e){const t={},n=r.getProgramParameter(e,Pu);for(let i=0;i<n;++i){const o=r.getActiveAttrib(e,i);if(eo(o))continue;const s=r.getAttribLocation(e,o.name),a=S[o.type],c=a.setter(r,s,a);c.location=s,t[o.name]=c}return t}function Gl(r,e){for(const t in e){const n=r[t];n&&n(e[t])}}function Vl(r,e,t){t.vertexArrayObject?r.bindVertexArray(t.vertexArrayObject):(Gl(e.attribSetters||e,t.attribs),t.indices&&r.bindBuffer(Au,t.indices))}function no(r,e){const t=zl(r,e),n=Wl(r,e),i={program:e,uniformSetters:t,attribSetters:n};return Ze(r)&&(i.uniformBlockSpec=$l(r,e),i.transformFeedbackInfo=Nl(r,e)),i}const Hl=/\s|{|}|;/;function jl(r,e,t,n,i){const o=Zr(t,n,i),s=[];if(e=e.map(function(u){if(!Hl.test(u)){const f=Ri(u);if(f)u=f.text;else{const m=`no element with id: ${u}`;o.errorCallback(m),s.push(m)}}return u}),s.length)return Tl(o,"");const a=o.callback;a&&(o.callback=(u,f)=>{a(u,u?void 0:no(r,f))});const c=Bl(r,e,o);return c?no(r,c):null}const Yl=4,io=5123;function Ql(r,e,t,n,i,o){t=t===void 0?Yl:t;const s=e.indices,a=e.elementType,c=n===void 0?e.numElements:n;i=i===void 0?0:i,a||s?o!==void 0?r.drawElementsInstanced(t,c,a===void 0?io:e.elementType,i,o):r.drawElements(t,c,a===void 0?io:e.elementType,i):o!==void 0?r.drawArraysInstanced(t,i,c,o):r.drawArrays(t,i,c)}const oo=36160,or=36161,ql=3553,Xl=5121,Kl=6402,Jl=6408,Zl=33190,ef=36012,tf=35056,rf=36013,nf=32854,of=32855,sf=36194,so=33189,ao=6401,co=36168,en=34041,tn=36064,sr=36096,uo=36128,rn=33306,nn=33071,on=9729,af=[{format:Jl,type:Xl,min:on,wrap:nn},{format:en}],G={};G[en]=rn,G[ao]=uo,G[co]=uo,G[Kl]=sr,G[so]=sr,G[Zl]=sr,G[ef]=sr,G[tf]=rn,G[rf]=rn;function cf(r,e){return G[r]||G[e]}const le={};le[nf]=!0,le[of]=!0,le[sf]=!0,le[en]=!0,le[so]=!0,le[ao]=!0,le[co]=!0;function uf(r){return le[r]}const lf=32;function ff(r){return r>=tn&&r<tn+lf}function lo(r,e,t,n){const i=oo,o=r.createFramebuffer();r.bindFramebuffer(i,o),t=t||r.drawingBufferWidth,n=n||r.drawingBufferHeight,e=e||af;const s=[],a={framebuffer:o,attachments:[],width:t,height:n};return e.forEach(function(c,u){let f=c.attachment;const m=c.samples,p=c.format;let b=c.attachmentPoint||cf(p,c.internalFormat);if(b||(b=tn+u),ff(b)&&s.push(b),!f)if(m!==void 0||uf(p))f=r.createRenderbuffer(),r.bindRenderbuffer(or,f),m>1?r.renderbufferStorageMultisample(or,m,p,t,n):r.renderbufferStorage(or,p,t,n);else{const d=Object.assign({},c);d.width=t,d.height=n,d.auto===void 0&&(d.auto=!1,d.min=d.min||d.minMag||on,d.mag=d.mag||d.minMag||on,d.wrapS=d.wrapS||d.wrap||nn,d.wrapT=d.wrapT||d.wrap||nn),f=Ii(r,d)}if(wa(r,f))r.framebufferRenderbuffer(i,b,or,f);else if(Or(r,f))c.layer!==void 0?r.framebufferTextureLayer(i,b,f,c.level||0,c.layer):r.framebufferTexture2D(i,b,c.target||ql,f,c.level||0);else throw new Error("unknown attachment type");a.attachments.push(f)}),r.drawBuffers&&r.drawBuffers(s),a}function df(r,e,t){t=t||oo,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 B(r,e){return()=>e instanceof WebGLTexture?e:Ii(r,{src:e,wrap:r.CLAMP_TO_EDGE})}const $e=2;class st{constructor(e){this.id="_";const{context:t,width:n,height:i}=e;this.context=t,this.options=e;const o=this.buildDefines();this.programInfo=jl(this.context,[o+this.getVertexShader(),o+this.getFragmentShader()]),this.bufferInfo=Ga(this.context,this.getBuffers()),this.fbi=lo(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=lo(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)}
|
|
14
|
+
`;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),Vl(this.context,this.programInfo,this.bufferInfo),ro(this.programInfo,{delta:n,canvas:[this.context.canvas.width,this.context.canvas.height],...e}),df(this.context,this.options.disableFramebuffer?null:this.fbi),Ql(this.context,this.bufferInfo),this.profiler?.popContext(`[${this.id}] PROG : ${this.constructor.name}`)}setProfiler(e){this.profiler=e}}const hf=`precision mediump float;
|
|
134
15
|
|
|
135
16
|
varying vec2 _texture_coord;
|
|
136
17
|
|
|
@@ -145,7 +26,7 @@ void main() {
|
|
|
145
26
|
gl_FragColor = foregroundColor * tresholdColor.a +
|
|
146
27
|
backgroundColor * (1. - tresholdColor.a);
|
|
147
28
|
}
|
|
148
|
-
`,
|
|
29
|
+
`,mf=`varying vec2 _texture_coord;
|
|
149
30
|
|
|
150
31
|
attribute vec2 position;
|
|
151
32
|
attribute vec2 texture_coord;
|
|
@@ -155,13 +36,13 @@ void main() {
|
|
|
155
36
|
_texture_coord = texture_coord;
|
|
156
37
|
_texture_coord.y = 1. - texture_coord.y;
|
|
157
38
|
}
|
|
158
|
-
`;class
|
|
39
|
+
`;class sn extends st{getFragmentShader(){return hf}getVertexShader(){return mf}}class an{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 cn extends an{constructor(){super(...arguments),this.preciseMaskEnabled=!1}}class fo extends cn{constructor(e){super(),this.context=e,this.preciseMaskEnabled=!0;const t={context:e,height:e.canvas.height,width:e.canvas.width},n=new sn({...t,disableFramebuffer:!0});this.addStep({program:n,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 pf=`precision mediump float;
|
|
159
40
|
|
|
160
41
|
varying vec2 _texture_coord;
|
|
161
42
|
uniform sampler2D texture;
|
|
162
43
|
|
|
163
44
|
void main() { gl_FragColor = texture2D(texture, _texture_coord); }
|
|
164
|
-
`,
|
|
45
|
+
`,gf=`varying vec2 _texture_coord;
|
|
165
46
|
|
|
166
47
|
attribute vec2 position;
|
|
167
48
|
attribute vec2 texture_coord;
|
|
@@ -174,7 +55,7 @@ void main() {
|
|
|
174
55
|
_texture_coord.y = 1. - texture_coord.y;
|
|
175
56
|
}
|
|
176
57
|
}
|
|
177
|
-
`;class
|
|
58
|
+
`;class yf extends st{getFragmentShader(){return pf}getVertexShader(){return gf}}class bf extends an{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t};this.addStep({program:new yf({...i,disableFramebuffer:!0}),getUniforms:()=>({texture:B(e,this.inputImage),invert_y:!0})})}setData(e){this.inputImage=e}}async function ho(r){return new Promise(e=>{setTimeout(()=>{e()},r)})}const wf=`precision mediump float;
|
|
178
59
|
|
|
179
60
|
varying vec2 _texture_coord;
|
|
180
61
|
|
|
@@ -184,7 +65,7 @@ uniform sampler2D texture;
|
|
|
184
65
|
vec4 loop();
|
|
185
66
|
|
|
186
67
|
void main() { gl_FragColor = loop(); }
|
|
187
|
-
`,
|
|
68
|
+
`,xf=`varying vec2 _texture_coord;
|
|
188
69
|
|
|
189
70
|
attribute vec2 position;
|
|
190
71
|
attribute vec2 texture_coord;
|
|
@@ -193,18 +74,18 @@ void main() {
|
|
|
193
74
|
gl_Position = vec4(position, 0., 1.);
|
|
194
75
|
_texture_coord = texture_coord;
|
|
195
76
|
}
|
|
196
|
-
`;var
|
|
77
|
+
`;var un=(r=>(r[r.LINEAR=0]="LINEAR",r[r.GAUSSIAN=1]="GAUSSIAN",r))(un||{});class mo extends st{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return wf+this.createLoopFunction()}getVertexShader(){return xf}createLoopFunction(){let e=this.options.radius??1;return`
|
|
197
78
|
|
|
198
79
|
vec4 loop() {
|
|
199
80
|
vec4 result = vec4(0,0,0,0);
|
|
200
81
|
float factorSum = 0.;
|
|
201
82
|
|
|
202
|
-
vec2 normalizedRadius = vec2(-${
|
|
83
|
+
vec2 normalizedRadius = vec2(-${e}.) / canvas;
|
|
203
84
|
vec2 normalizedIncrement = vec2(1.) / canvas;
|
|
204
85
|
vec2 diff = normalizedRadius;
|
|
205
86
|
|
|
206
|
-
for(int y=-${
|
|
207
|
-
for(int x=-${
|
|
87
|
+
for(int y=-${e}; y<${e+1}; ++y) {
|
|
88
|
+
for(int x=-${e}; x<${e+1}; ++x) {
|
|
208
89
|
float factor = 1.;
|
|
209
90
|
result += factor * texture2D(texture, _texture_coord + diff);
|
|
210
91
|
factorSum += factor;
|
|
@@ -214,7 +95,7 @@ void main() {
|
|
|
214
95
|
diff.x = normalizedRadius.x;
|
|
215
96
|
}
|
|
216
97
|
return result / factorSum;
|
|
217
|
-
}`}
|
|
98
|
+
}`}}const vf=`#version 300 es
|
|
218
99
|
// https://github.com/Volcomix/virtual-background/blob/main/src/pipelines/webgl2/jointBilateralFilterStage.ts
|
|
219
100
|
|
|
220
101
|
precision highp float;
|
|
@@ -260,14 +141,14 @@ void main() {
|
|
|
260
141
|
}
|
|
261
142
|
newVal /= totalWeight;
|
|
262
143
|
outColor = vec4(vec3(0.), newVal);
|
|
263
|
-
}`,
|
|
144
|
+
}`,_f=`#version 300 es
|
|
264
145
|
in vec2 position;
|
|
265
146
|
in vec2 texture_coord;
|
|
266
147
|
out vec2 _texture_coord;
|
|
267
148
|
void main() {
|
|
268
149
|
gl_Position = vec4(position, 0.0, 1.0);
|
|
269
150
|
_texture_coord = texture_coord;
|
|
270
|
-
}`;class
|
|
151
|
+
}`;class Ef extends st{getFragmentShader(){return vf}getVertexShader(){return _f}}class Af extends an{constructor(e,t,n){super(),this.context=e;const i={context:e,height:n,width:t},o=new mo({...i,radius:1,type:un.GAUSSIAN});this.jointBilateral=new Ef(i),this.addStep({program:o,getUniforms:()=>({inputs:B(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,f=Math.max(1,Math.sqrt(u)*.66),m=1/a,p=1/c;return{input_frame:B(e,this.inputImage),segmentation_mask:B(e,this.inputMask),texel_size:[m,p],step:f,radius:u,offset:f>1?f*.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}}var po=(r=>(r.PUSH="PUSH",r.POP="POP",r))(po||{});class Tf{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 ho(200)}}}class ar{constructor(){this.previousImageWidth=0,this.previousImageHeight=0,this.previousMaskWidth=$e,this.previousMaskHeight=$e,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 Af(this.context,$e,$e)}enablePostProcessing(){this.postProcessingEnabled=!0}disablePostProcessing(){this.postProcessingEnabled=!1}async profileWebgl(e){const t=new Tf(this.context);return this.profiler=t,t.start(),await ho(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 o=i;return this.postProcessingEnabled&&(this.improveMask.setData(e,i),this.improveMask.run(),o=this.improveMask.output),this.pipeline.setData(e,o),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 go extends ar{constructor(){super(),this.pipeline=new fo(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 bf(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 Sf extends go{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 yo{blurBackground(e){return new sa(e)}blurSilhouette(e){return new aa(e)}imageBackground(){return new ca}videoBackground(){return new Sf}}const If=`precision mediump float;
|
|
271
152
|
|
|
272
153
|
varying vec2 _texture_coord;
|
|
273
154
|
|
|
@@ -278,7 +159,7 @@ uniform sampler2D mask;
|
|
|
278
159
|
vec4 loop();
|
|
279
160
|
|
|
280
161
|
void main() { gl_FragColor = loop(); }
|
|
281
|
-
`,
|
|
162
|
+
`,Rf=`varying vec2 _texture_coord;
|
|
282
163
|
|
|
283
164
|
attribute vec2 position;
|
|
284
165
|
attribute vec2 texture_coord;
|
|
@@ -287,19 +168,19 @@ void main() {
|
|
|
287
168
|
gl_Position = vec4(position, 0., 1.);
|
|
288
169
|
_texture_coord = texture_coord;
|
|
289
170
|
}
|
|
290
|
-
`;class
|
|
171
|
+
`;class kf extends st{getDefines(){return{RADIUS:this.options.radius??1}}getFragmentShader(){return If+this.createLoopFunction()}getVertexShader(){return Rf}createLoopFunction(){let e=this.options.radius??1;return`
|
|
291
172
|
|
|
292
173
|
vec4 loop() {
|
|
293
174
|
vec4 result = vec4(0,0,0,0);
|
|
294
175
|
float factorSum = 0.;
|
|
295
176
|
|
|
296
|
-
vec2 normalizedRadius = vec2(-${
|
|
177
|
+
vec2 normalizedRadius = vec2(-${e}.) / canvas;
|
|
297
178
|
vec2 normalizedIncrement = vec2(1.) / canvas;
|
|
298
179
|
vec2 diff = normalizedRadius;
|
|
299
180
|
float maxLength = length(normalizedRadius);
|
|
300
181
|
|
|
301
|
-
for(int y=-${
|
|
302
|
-
for(int x=-${
|
|
182
|
+
for(int y=-${e}; y<${e+1}; ++y) {
|
|
183
|
+
for(int x=-${e}; x<${e+1}; ++x) {
|
|
303
184
|
float factor = (1.- texture2D(mask, _texture_coord + diff).a) * (maxLength - length(diff)) / maxLength;
|
|
304
185
|
result += factor * texture2D(texture, _texture_coord + diff);
|
|
305
186
|
factorSum += factor;
|
|
@@ -309,5 +190,5 @@ void main() {
|
|
|
309
190
|
diff.x = normalizedRadius.x;
|
|
310
191
|
}
|
|
311
192
|
return result / factorSum;
|
|
312
|
-
}`}}const v3=10,b3=2,w3=8;class x3 extends hs{constructor(t,n){super(),this.context=t,this.radius=n;const p={context:t,height:t.canvas.height,width:t.canvas.width};this.blur=new y3({...p,radius:n,...this.getBlurTextureSize(t.canvas.width,t.canvas.height)});const y=new ls({...p,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:Gr(t,this.inputImage),mask:Gr(t,this.inputMask)})}),this.addStep({program:y,getUniforms:()=>({background:Gr(t,this.blur.output),foreground:Gr(t,this.inputImage),threshold:Gr(t,this.inputMask)})})}getBlurTextureSize(t,n){const p=this.radius>v3?w3:b3;return{width:Math.max(Vn,t/p),height:Math.max(Vn,n/p)}}setData(t,n){this.inputImage=t,this.inputMask=n}resizeOutput(t,n){super.resizeOutput(t,n);const p=this.getBlurTextureSize(t,n);this.blur.resizeOutput(p.width,p.height)}}class _3 extends go{constructor(t){super(),this.pipeline=new x3(this.context,t),this.disablePostProcessing()}}class E3 extends hs{constructor(t,n){super(),this.context=t;const p={context:t,height:t.canvas.height,width:t.canvas.width},y=new du({...p,radius:n,type:ds.GAUSSIAN}),R=new ls({...p,disableFramebuffer:!0});this.addStep({program:y,getUniforms:()=>({texture:Gr(t,this.inputImage)})}),this.addStep({program:R,getUniforms:()=>({background:Gr(t,this.inputImage),foreground:Gr(t,y.output),threshold:Gr(t,this.inputMask)})})}setData(t,n){this.inputImage=t,this.inputMask=n}}class A3 extends go{constructor(t){super(),this.pipeline=new E3(this.context,t),this.disablePostProcessing()}}class T3 extends fu{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 S3 extends go{constructor(){super(),this.pipeline=new T3(this.context)}setBackgroundVideo(t){this.pipeline.reader=t}}class yu{blurBackground(t){return new _3(t)}blurSilhouette(t){return new A3(t)}imageBackground(){return new gu}videoBackground(){return new S3}}class R3{constructor(t){switch(t){case Kn.CANVAS:this.factory=new mu;break;case Kn.WEBGL:this.factory=new yu;break;default:const n=Ms();this.factory=n.supported?new yu:new mu}}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 F3{setBackgroundOptions(t){this.renderer&&this.renderer.destroy();const n=new R3(t.renderingOptions?.type);switch(t.transformerType){case"BackgroundBlur":this.renderer=n.blurBackground(this.getBlurSize(t.radius));break;case"SilhouetteBlur":this.renderer=n.blurSilhouette(this.getBlurSize(t.radius));break;case"VideoBackground":const p=n.videoBackground();this.backgroundVideo&&p.setBackgroundVideo(this.backgroundVideo),this.renderer=p;break;case"VirtualBackground":const y=n.imageBackground();this.backgroundImage&&y.setBackgroundImage(this.backgroundImage),this.renderer=y;break;default:throw`Unknown rendering type [${t.transformerType}]`}t.renderingOptions?.type===Kn.WEBGL&&(t.renderingOptions.selfieSegmentationType===_i.PRECISE?this.renderer.enablePostProcessing():t.renderingOptions.selfieSegmentationType===_i.FAST&&this.renderer.disablePostProcessing())}setVideoBGReadable(t){this.backgroundVideo=t.getReader();const n=this.renderer;n?.setBackgroundVideo&&n.setBackgroundVideo(this.backgroundVideo)}async setVirtualBGImage(t){const n=this.renderer;n?.setBackgroundImage&&n.setBackgroundImage(t),this.backgroundImage=t}async process(t,n){if(this.renderer)return this.renderer.render(t,n)}async resizeForeground(t,n){}getBlurSize(t=Xn.Low){switch(t){case Xn.Low:return 5;case Xn.High:return 12}return t}async profile(t){return this.renderer?.profileWebgl(t)??[]}}var O3=(function(){var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return(function(t){t=t||{};var n=typeof t<"u"?t:{},p,y;n.ready=new Promise(function(ee,ie){p=ee,y=ie});var R={},k;for(k in n)n.hasOwnProperty(k)&&(R[k]=n[k]);var O="./this.program",L=function(ee,ie){throw ie},te=!0,ue="";function pe(ee){return n.locateFile?n.locateFile(ee,ue):ue+ee}var Oe;typeof document<"u"&&document.currentScript&&(ue=document.currentScript.src),i&&(ue=i),ue.indexOf("blob:")!==0?ue=ue.substr(0,ue.replace(/[?#].*/,"").lastIndexOf("/")+1):ue="";var Me=n.print||console.log.bind(console),ce=n.printErr||console.warn.bind(console);for(k in R)R.hasOwnProperty(k)&&(n[k]=R[k]);R=null,n.arguments&&n.arguments,n.thisProgram&&(O=n.thisProgram),n.quit&&(L=n.quit);var he;n.wasmBinary&&(he=n.wasmBinary),n.noExitRuntime,typeof WebAssembly!="object"&&Ct("no native wasm support detected");var Ge,Ve=!1,ct=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function J(ee,ie,ve){for(var He=ie+ve,Ie=ie;ee[Ie]&&!(Ie>=He);)++Ie;if(Ie-ie>16&&ee.subarray&&ct)return ct.decode(ee.subarray(ie,Ie));for(var xe="";ie<Ie;){var Ke=ee[ie++];if(!(Ke&128)){xe+=String.fromCharCode(Ke);continue}var ht=ee[ie++]&63;if((Ke&224)==192){xe+=String.fromCharCode((Ke&31)<<6|ht);continue}var bt=ee[ie++]&63;if((Ke&240)==224?Ke=(Ke&15)<<12|ht<<6|bt:Ke=(Ke&7)<<18|ht<<12|bt<<6|ee[ie++]&63,Ke<65536)xe+=String.fromCharCode(Ke);else{var Qe=Ke-65536;xe+=String.fromCharCode(55296|Qe>>10,56320|Qe&1023)}}return xe}function Jt(ee,ie){return ee?J(at,ee,ie):""}function mr(ee,ie,ve){for(var He=0;He<ee.length;++He)Mr[ie++>>0]=ee.charCodeAt(He);Mr[ie>>0]=0}function At(ee,ie){return ee%ie>0&&(ee+=ie-ee%ie),ee}var Xe,Mr,at,me;function Wr(ee){Xe=ee,n.HEAP8=Mr=new Int8Array(ee),n.HEAP16=new Int16Array(ee),n.HEAP32=me=new Int32Array(ee),n.HEAPU8=at=new Uint8Array(ee),n.HEAPU16=new Uint16Array(ee),n.HEAPU32=new Uint32Array(ee),n.HEAPF32=new Float32Array(ee),n.HEAPF64=new Float64Array(ee)}n.INITIAL_MEMORY;var Br,Tt=[],je=[],Ot=[];function tr(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)wr(n.preRun.shift());_t(Tt)}function yr(){_t(je)}function Or(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)rr(n.postRun.shift());_t(Ot)}function wr(ee){Tt.unshift(ee)}function Pr(ee){je.unshift(ee)}function rr(ee){Ot.unshift(ee)}var Dt=0,xr=null;function Ir(ee){Dt++,n.monitorRunDependencies&&n.monitorRunDependencies(Dt)}function vr(ee){if(Dt--,n.monitorRunDependencies&&n.monitorRunDependencies(Dt),Dt==0&&xr){var ie=xr;xr=null,ie()}}n.preloadedImages={},n.preloadedAudios={};function Ct(ee){n.onAbort&&n.onAbort(ee),ee="Aborted("+ee+")",ce(ee),Ve=!0,ee+=". Build with -s ASSERTIONS=1 for more info.";var ie=new WebAssembly.RuntimeError(ee);throw y(ie),ie}var _r="data:application/octet-stream;base64,";function lr(ee){return ee.startsWith(_r)}var ut;ut="tflite-simd.wasm",lr(ut)||(ut=pe(ut));function St(ee){try{if(ee==ut&&he)return new Uint8Array(he);if(!Oe)throw"both async and sync fetching of the wasm failed"}catch(ie){Ct(ie)}}function Ht(){return!he&&te&&typeof fetch=="function"?fetch(ut,{credentials:"same-origin"}).then(function(ee){if(!ee.ok)throw"failed to load wasm binary file at '"+ut+"'";return ee.arrayBuffer()}).catch(function(){return St(ut)}):Promise.resolve().then(function(){return St(ut)})}function xt(){var ee={a:tt};function ie(Ke,ht){var bt=Ke.exports;n.asm=bt,Ge=n.asm.q,Wr(Ge.buffer),Br=n.asm.E,Pr(n.asm.r),vr()}Ir();function ve(Ke){ie(Ke.instance)}function He(Ke){return Ht().then(function(ht){return WebAssembly.instantiate(ht,ee)}).then(function(ht){return ht}).then(Ke,function(ht){ce("failed to asynchronously prepare wasm: "+ht),Ct(ht)})}function Ie(){return!he&&typeof WebAssembly.instantiateStreaming=="function"&&!lr(ut)&&typeof fetch=="function"?fetch(ut,{credentials:"same-origin"}).then(function(Ke){var ht=WebAssembly.instantiateStreaming(Ke,ee);return ht.then(ve,function(bt){return ce("wasm streaming compile failed: "+bt),ce("falling back to ArrayBuffer instantiation"),He(ve)})}):He(ve)}if(n.instantiateWasm)try{var xe=n.instantiateWasm(ee,ie);return xe}catch(Ke){return ce("Module.instantiateWasm callback failed with error: "+Ke),!1}return Ie().catch(y),{}}function _t(ee){for(;ee.length>0;){var ie=ee.shift();if(typeof ie=="function"){ie(n);continue}var ve=ie.func;typeof ve=="number"?ie.arg===void 0?Br.get(ve)():Br.get(ve)(ie.arg):ve(ie.arg===void 0?null:ie.arg)}}function Zt(ee,ie,ve,He){Ct("Assertion failed: "+Jt(ee)+", at: "+[ie?Jt(ie):"unknown filename",ve,He?Jt(He):"unknown function"])}function Gt(ee,ie){Ct("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function qe(ee,ie){Ct("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function mt(){Ct("")}var Rt;Rt=function(){return performance.now()};var We=!0;function Ft(ee){return me[$e()>>2]=ee,ee}function et(ee,ie){var ve;if(ee===0)ve=Date.now();else if((ee===1||ee===4)&&We)ve=Rt();else return Ft(28),-1;return me[ie>>2]=ve/1e3|0,me[ie+4>>2]=ve%1e3*1e3*1e3|0,0}function pt(){return 2147483648}function It(ee,ie,ve){at.copyWithin(ee,ie,ie+ve)}function Vt(ee){try{return Ge.grow(ee-Xe.byteLength+65535>>>16),Wr(Ge.buffer),1}catch{}}function wt(ee){var ie=at.length;ee=ee>>>0;var ve=2147483648;if(ee>ve)return!1;for(var He=1;He<=4;He*=2){var Ie=ie*(1+.2/He);Ie=Math.min(Ie,ee+100663296);var xe=Math.min(ve,At(Math.max(ee,Ie),65536)),Ke=Vt(xe);if(Ke)return!0}return!1}function Ye(ee){for(var ie=Rt();Rt()-ie<ee;);}var Lt={};function zt(){return O||"./this.program"}function Et(){if(!Et.strings){var ee=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",ie={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:ee,_:zt()};for(var ve in Lt)Lt[ve]===void 0?delete ie[ve]:ie[ve]=Lt[ve];var He=[];for(var ve in ie)He.push(ve+"="+ie[ve]);Et.strings=He}return Et.strings}var fr={mappings:{},buffers:[null,[],[]],printChar:function(ee,ie){var ve=fr.buffers[ee];ie===0||ie===10?((ee===1?Me:ce)(J(ve,0)),ve.length=0):ve.push(ie)},varargs:void 0,get:function(){fr.varargs+=4;var ee=me[fr.varargs-4>>2];return ee},getStr:function(ee){var ie=Jt(ee);return ie},get64:function(ee,ie){return ee}};function qt(ee,ie){var ve=0;return Et().forEach(function(He,Ie){var xe=ie+ve;me[ee+Ie*4>>2]=xe,mr(He,xe),ve+=He.length+1}),0}function sr(ee,ie){var ve=Et();me[ee>>2]=ve.length;var He=0;return ve.forEach(function(Ie){He+=Ie.length+1}),me[ie>>2]=He,0}function hr(ee){Se(ee)}function yt(ee){return 0}function kt(ee,ie,ve,He,Ie){}function vt(ee,ie,ve,He){for(var Ie=0,xe=0;xe<ve;xe++){for(var Ke=me[ie+xe*8>>2],ht=me[ie+(xe*8+4)>>2],bt=0;bt<ht;bt++)fr.printChar(ee,at[Ke+bt]);Ie+=ht}return me[He>>2]=Ie,0}function rt(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var ee=new Uint8Array(1);return function(){return crypto.getRandomValues(ee),ee[0]}}else return function(){Ct("randomDevice")}}function Ut(ee,ie){Ut.randomDevice||(Ut.randomDevice=rt());for(var ve=0;ve<ie;ve++)Mr[ee+ve>>0]=Ut.randomDevice();return 0}var tt={a:Zt,e:Gt,d:qe,b:mt,n:et,h:pt,l:It,m:wt,p:Ye,f:qt,g:sr,j:hr,i:yt,k:kt,c:vt,o:Ut};xt(),n.___wasm_call_ctors=function(){return(n.___wasm_call_ctors=n.asm.r).apply(null,arguments)},n._getModelBufferMemoryOffset=function(){return(n._getModelBufferMemoryOffset=n.asm.s).apply(null,arguments)},n._getInputMemoryOffset=function(){return(n._getInputMemoryOffset=n.asm.t).apply(null,arguments)},n._getInputHeight=function(){return(n._getInputHeight=n.asm.u).apply(null,arguments)},n._getInputWidth=function(){return(n._getInputWidth=n.asm.v).apply(null,arguments)},n._getInputChannelCount=function(){return(n._getInputChannelCount=n.asm.w).apply(null,arguments)},n._getOutputMemoryOffset=function(){return(n._getOutputMemoryOffset=n.asm.x).apply(null,arguments)},n._getOutputHeight=function(){return(n._getOutputHeight=n.asm.y).apply(null,arguments)},n._getOutputWidth=function(){return(n._getOutputWidth=n.asm.z).apply(null,arguments)},n._getOutputChannelCount=function(){return(n._getOutputChannelCount=n.asm.A).apply(null,arguments)},n._loadModel=function(){return(n._loadModel=n.asm.B).apply(null,arguments)},n._runInference=function(){return(n._runInference=n.asm.C).apply(null,arguments)},n._isGPUEnabled=function(){return(n._isGPUEnabled=n.asm.D).apply(null,arguments)};var $e=n.___errno_location=function(){return($e=n.___errno_location=n.asm.F).apply(null,arguments)},nr;function lt(ee){this.name="ExitStatus",this.message="Program terminated with exit("+ee+")",this.status=ee}xr=function ee(){nr||Ce(),nr||(xr=ee)};function Ce(ee){if(Dt>0||(tr(),Dt>0))return;function ie(){nr||(nr=!0,n.calledRun=!0,!Ve&&(yr(),p(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),Or()))}n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),ie()},1)):ie()}n.run=Ce;function Se(ee,ie){nt(ee)}function nt(ee){L(ee,new lt(ee))}if(n.preInit)for(typeof n.preInit=="function"&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return Ce(),t.ready})})();class I3{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 k3="https://d3opqjmqzxf057.cloudfront.net/vonage-tensorflow-wasm/tflite-simd-wasm/1.1.3/",P3="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function C3(i=k3,t=P3){let n=new I3;var p=new Promise(function(y,R){async function k(){return O3({locateFile:function(te){return i+te}})}async function O(L){return new Promise(async(te,ue)=>{const pe=L;if(typeof pe>"u")return ue("TFLite backend unavailable: wasmSimd");let Oe=t;console.log("TFLite modelUrl: "+Oe);try{const ce=await(await fetch(Oe)).arrayBuffer();console.log("Model buffer size:",ce.byteLength);const he=pe._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",he),console.log("Loading model buffer..."),pe.HEAPU8.set(new Uint8Array(ce),he);const Ge=pe._loadModel(ce.byteLength);if(console.log("Load model result:",Ge),Ge!==0){ue("Cannot load model");return}n.inputWidth=pe._getInputWidth(),n.inputHeight=pe._getInputHeight(),n.inputChannelCount=pe._getInputChannelCount(),n.inputMemoryOffset=pe._getInputMemoryOffset(),console.log("Input memory offset:",n.inputMemoryOffset),console.log("Input height:",n.inputHeight),console.log("Input width:",n.inputWidth),console.log("Input channels:",n.inputChannelCount),n.outputMemoryOffset=pe._getOutputMemoryOffset(),n.outputWidth=pe._getOutputWidth(),n.outputHeight=pe._getOutputHeight(),n.outputChannelCount=pe._getOutputChannelCount(),console.log("Output memory offset:",n.outputMemoryOffset),console.log("Output height:",n.outputHeight),console.log("Output width:",n.outputWidth),console.log("Output channels:",n.outputChannelCount),n.selectedTFLite=pe}catch(Me){ue(Me);return}te()})}k().then(L=>{if(L===null)throw console.error("loadTFLite null"),"loadTFLite null";O(L).then(te=>{y(n)}).catch(te=>{console.error("loadTFLiteModel error"),R("loadTFLiteModel error")})}).catch(L=>{console.error("loadTFLite error:",L),R("loadTFLite error:"+L)})});return p}const M3=.1,j3=.7,L3="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class U3{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(t,n){this.modelAssetUriPath=t||L3;const p=n?`${n}/task-vision.js`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/+esm",y=n?`${n}/wasm`:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.20/wasm",{FilesetResolver:R,ImageSegmenter:k}=await import(p);this.ImageSegmenter=k,this.wasmFileset=await R.forVisionTasks(y)}async init(t,n,p){p===!1&&(this.gpuDelegate=!1),await this.loadMediapipeAssets(t,n),globalThis.document={},await this.createImageSegmenter()}async process(t){if(!this.imageSegmenter){console.warn("ImageSegmenter instance not available");return}(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 n=Date.now();let p;try{this.imageSegmenter?.segmentForVideo(this.context.getImageData(0,0,t.width,t.height),n,k=>{p=k.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{await this.createImageSegmenter();return}if(!p)return;if(!this.previousConfidenceMask){this.previousConfidenceMask=p.slice();return}const y=p.map((k,O)=>{const L=this.previousConfidenceMask?.[O];return L!==void 0?this.blend(L,k):k}),R=[255,0,0];for(let k=0;k<y?.length;k++){const O=1-y[k];O>M3?(O<j3?(this.mask.data[k*4]=R[0]*O,this.mask.data[k*4+3]=255*O):(this.mask.data[k*4]=R[0],this.mask.data[k*4+3]=255),this.mask.data[k*4+1]=R[1],this.mask.data[k*4+2]=R[2]):this.mask.data[k*4]=this.mask.data[k*4+1]=this.mask.data[k*4+2]=this.mask.data[k*4+3]=0}return this.previousConfidenceMask=y.slice(),this.mask}isGpuSupported(){return!0}blend(t,n){const y=-.748699,R=-57.8051,k=291.309,O=-624.717,L=n-.5,te=L*L,ue=1-Math.min(1,te*(5.68842+te*(y+te*(R+te*(k+te*O)))));return n+(t-n)*(ue*.9)}}class B3{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,n,p){await this.initWasm(n,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,n){this.infos=await C3(t,n)}async process(t){if(!this.mask||!this.infos)return;const n=this.infos.inputWidth,p=this.infos.inputHeight;this.context.drawImage(t,0,0,t.width,t.height,0,0,n,p);const y=this.context.getImageData(0,0,n,p),R=this.infos.selectedTFLite.HEAPF32;for(let k=0;k<this.pixelCount;k++){const O=this.inputOffset+k*3;R[O]=y.data[k*4]/255,R[O+1]=y.data[k*4+1]/255,R[O+2]=y.data[k*4+2]/255}this.infos.selectedTFLite._runInference();for(let k=0;k<this.pixelCount;k++){const O=this.infos.selectedTFLite.HEAPF32[this.outputOffset+k];this.mask.data[k*4]=this.mask.data[k*4+3]=255*O}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class vu{constructor(){this.reporter=new $c,this.isEnabled=!0}async init(t,n){n.segmentationOptions?.lightWeightEngine===!0?this.selfieSegmentation=new B3:this.selfieSegmentation=new U3,await this.selfieSegmentation?.init(n.modelAssetUriPath,n.mediapipeBaseAssetsUri,n.segmentationOptions?.gpuSupport),this.backgroundFilter=new F3,this.report({variation:"Create"})}async transform(t,n){if(!this.isEnabled)return n.enqueue(t);let p;const y=t.timestamp??0,R=await createImageBitmap(t),k=await this.selfieSegmentation?.process(R);k&&(p=await this.backgroundFilter?.process(R,k)),p?(t.close(),n.enqueue(new VideoFrame(p,{timestamp:y,alpha:"discard"}))):n.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:Yc,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...t})}}const ms=class ms{constructor(){this.backgroundTransformer=new vu,this.mediaProcessor=new ks,this.rate=30,this.eventsQueue=[],this.frameTransformLatencyMs=[]}async init(t,n){this.frameTransformLatencyMs=[],await this.backgroundTransformer.init(t,n),await this.mediaProcessor.setTransformers([this.backgroundTransformer]),this.mediaProcessor.setTrackExpectedRate(this.rate),this.mediaProcessor.onAny((p,y)=>{this.resolveOnMediaProcessor?(this.resolveOnMediaProcessor({name:p,data:y}),this.resolveOnMediaProcessor=void 0):this.eventsQueue.push({name:p,data:y})})}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,n){let p=this.mediaProcessor.transform(t,n),y=performance.now();return this.frameTransformLatencyMs.push(performance.now()-y),p}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 n=this.frameTransformLatencyMs.reduce((p,y)=>p+y,0)/this.frameTransformLatencyMs.length||0;console.log(`Transform latency average is: ${n} ms`)}setVonageMetadata(t){Xu(t)}async profile(t){return JSON.stringify(await this.backgroundTransformer.profile(t))}};vc("ProcessorWorker",ms);let ps=ms;const bu='(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 data: ${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 data: ${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',wu=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",bu],{type:"text/javascript;charset=utf-8"});function N3(i){let t;try{if(t=wu&&(self.URL||self.webkitURL).createObjectURL(wu),!t)throw"";const n=new Worker(t,{name:i?.name});return n.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(bu),{name:i?.name})}}const yo=class yo extends Jn{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,n){return await this.startWorker(),await this.worker?.transform(t,n)}async destroy(){await this.worker?.terminate(),this.worker=void 0}async profile(t){const n=await this.worker?.profile(t);return JSON.parse(n??"[]")}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:n}=await this.worker?.onMediaProcessorEvent();switch(t){case"error":case"warn":this.emit(t,n);break;case"pipelineInfo":switch(this.emit(t,n),n){case"pipeline_ended":case"pipeline_ended_with_error":await this.destroy();return}break}}}async startWorker(){!this.config||this.worker||(this.worker=await mc(ps,N3),this.isEnabled||await this.worker.disable(),await this.worker.init(`worker_${yo.initCount++}`,this.config),await this.worker.setVonageMetadata(bi()),this.backgroundOptions?await this.setBackgroundOptions(this.backgroundOptions):await this.setBackgroundOptions(this.config),this.listenWorker())}async updateBackgroundOptions(t){await this.startWorker();const{transformerType:n}=t;switch(n){case"VideoBackground":await this.worker?.setVideoBGReadable(await Vs.createVideoReadable(t.backgroundAssetUri));break;case"VirtualBackground":await this.worker?.setVirtualBGImage(await Vs.createImageCanvas(t.backgroundAssetUri));break}await this.worker?.setBackgroundOptions(t)}};yo.initCount=0;let gs=yo;class D3{constructor(t){this.queries=t}async downloadSpeedscope(){this.download(await this.convertToSpeedscope())}download(t){const n=document.createElement("a");n.href=URL.createObjectURL(new Blob([t],{type:"application/json"})),n.download=`profile-${+new Date}.speedscope.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n)}convertToSpeedscope(){const t=[],n={},p=[];let y=0;for(const k of this.queries){const O=[];for(const L of k)n[L.name]===void 0&&(n[L.name]=t.length,t.push({name:L.name})),O.push({type:L.action==pu.PUSH?"O":"C",frame:n[L.name],at:L.timestamp}),y=Math.max(y,L.timestamp+L.duration);p.push({events:O,type:"evented",name:"GPU Profile",unit:"nanoseconds",startValue:0,endValue:y})}return JSON.stringify({$schema:"https://www.speedscope.app/file-format-schema.json",shared:{frames:t},profiles:p},null,2)}}const ys=class ys extends Jn{constructor(t){super(),this.worker=new gs(t),this.connector=new nc(this.worker),this.worker.onAny((n,p)=>this.emit(n,p))}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 n=await Promise.all(this.instances.map(p=>p.profile(t)));return new D3(n)}static async create(t){const n=new this(t);return this.instances.push(n),n}};ys.instances=[];let mo=ys;function G3(){return Ei}function W3(){return Ai}function z3(){return Ti}function H3(){return Si}function V3(){return Ri}function $3(){return Fi}function Y3(){return Oi}async function X3(i){return await mo.create(i)}or.BackgroundTransformer=vu,or.BackgroundTransformerType=Ps,or.BlurRadius=Xn,or.ErrorFunction=Is,or.MediapipeHelper=Ao,or.PipelineInfoData=xi,or.RenderingType=Kn,or.VonageMediaProcessor=mo,or.WarningType=Os,or.WebglSelfieSegmentationType=_i,or.createVonageMediaProcessor=X3,or.getSupportedBrowserFeatures=Cs,or.getVonageFaceDetection=H3,or.getVonageFaceMash=V3,or.getVonageHands=W3,or.getVonageHolistic=z3,or.getVonageObjectron=$3,or.getVonagePose=Y3,or.getVonageSelfieSegmentation=G3,or.isSupported=oc,Object.defineProperty(or,Symbol.toStringTag,{value:"Module"})}));
|
|
193
|
+
}`}}const Pf=10,Ff=2,Cf=8;class Mf extends cn{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 kf({...n,radius:t,...this.getBlurTextureSize(e.canvas.width,e.canvas.height)});const i=new sn({...n,disableFramebuffer:!0});this.addStep({program:this.blur,preventResize:!0,getUniforms:()=>({texture:B(e,this.inputImage),mask:B(e,this.inputMask)})}),this.addStep({program:i,getUniforms:()=>({background:B(e,this.blur.output),foreground:B(e,this.inputImage),threshold:B(e,this.inputMask)})})}getBlurTextureSize(e,t){const n=this.radius>Pf?Cf:Ff;return{width:Math.max($e,e/n),height:Math.max($e,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 Of extends ar{constructor(e){super(),this.pipeline=new Mf(this.context,e),this.disablePostProcessing()}}class Bf extends cn{constructor(e,t){super(),this.context=e;const n={context:e,height:e.canvas.height,width:e.canvas.width},i=new mo({...n,radius:t,type:un.GAUSSIAN}),o=new sn({...n,disableFramebuffer:!0});this.addStep({program:i,getUniforms:()=>({texture:B(e,this.inputImage)})}),this.addStep({program:o,getUniforms:()=>({background:B(e,this.inputImage),foreground:B(e,i.output),threshold:B(e,this.inputMask)})})}setData(e,t){this.inputImage=e,this.inputMask=t}}class Df extends ar{constructor(e){super(),this.pipeline=new Bf(this.context,e),this.disablePostProcessing()}}class Uf extends fo{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 Lf extends ar{constructor(){super(),this.pipeline=new Uf(this.context)}setBackgroundVideo(e){this.pipeline.reader=e}}class bo{blurBackground(e){return new Of(e)}blurSilhouette(e){return new Df(e)}imageBackground(){return new go}videoBackground(){return new Lf}}class zf{constructor(e){switch(e){case je.CANVAS:this.factory=new yo;break;case je.WEBGL:this.factory=new bo;break;default:const t=On();this.factory=t.supported?new bo:new yo}}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 zf(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===je.WEBGL&&(e.renderingOptions.selfieSegmentationType===_t.PRECISE?this.renderer.enablePostProcessing():e.renderingOptions.selfieSegmentationType===_t.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=He.Low){switch(e){case He.Low:return 5;case He.High:return 12}return e}async profile(e){return this.renderer?.profileWebgl(e)??[]}}var $f=(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(l,h){n=l,i=h});var o={},s;for(s in t)t.hasOwnProperty(s)&&(o[s]=t[s]);var a="./this.program",c=function(l,h){throw h},u=!0,f="";function m(l){return t.locateFile?t.locateFile(l,f):f+l}var p;typeof document<"u"&&document.currentScript&&(f=document.currentScript.src),r&&(f=r),f.indexOf("blob:")!==0?f=f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1):f="";var b=t.print||console.log.bind(console),d=t.printErr||console.warn.bind(console);for(s in o)o.hasOwnProperty(s)&&(t[s]=o[s]);o=null,t.arguments&&t.arguments,t.thisProgram&&(a=t.thisProgram),t.quit&&(c=t.quit);var g;t.wasmBinary&&(g=t.wasmBinary),t.noExitRuntime,typeof WebAssembly!="object"&&fe("no native wasm support detected");var x,v=!1,R=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function C(l,h,y){for(var _=h+y,I=h;l[I]&&!(I>=_);)++I;if(I-h>16&&l.subarray&&R)return R.decode(l.subarray(h,I));for(var M="";h<I;){var E=l[h++];if(!(E&128)){M+=String.fromCharCode(E);continue}var D=l[h++]&63;if((E&224)==192){M+=String.fromCharCode((E&31)<<6|D);continue}var Y=l[h++]&63;if((E&240)==224?E=(E&15)<<12|D<<6|Y:E=(E&7)<<18|D<<12|Y<<6|l[h++]&63,E<65536)M+=String.fromCharCode(E);else{var ko=E-65536;M+=String.fromCharCode(55296|ko>>10,56320|ko&1023)}}return M}function N(l,h){return l?C(at,l,h):""}function J(l,h,y){for(var _=0;_<l.length;++_)lr[h++>>0]=l.charCodeAt(_);lr[h>>0]=0}function Z(l,h){return l%h>0&&(l+=h-l%h),l}var $,lr,at,V;function _o(l){$=l,t.HEAP8=lr=new Int8Array(l),t.HEAP16=new Int16Array(l),t.HEAP32=V=new Int32Array(l),t.HEAPU8=at=new Uint8Array(l),t.HEAPU16=new Uint16Array(l),t.HEAPU32=new Uint32Array(l),t.HEAPF32=new Float32Array(l),t.HEAPF64=new Float64Array(l)}t.INITIAL_MEMORY;var mn,Eo=[],Ao=[],To=[];function ed(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)nd(t.preRun.shift());pn(Eo)}function td(){pn(Ao)}function rd(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)od(t.postRun.shift());pn(To)}function nd(l){Eo.unshift(l)}function id(l){Ao.unshift(l)}function od(l){To.unshift(l)}var Ae=0,ct=null;function sd(l){Ae++,t.monitorRunDependencies&&t.monitorRunDependencies(Ae)}function ad(l){if(Ae--,t.monitorRunDependencies&&t.monitorRunDependencies(Ae),Ae==0&&ct){var h=ct;ct=null,h()}}t.preloadedImages={},t.preloadedAudios={};function fe(l){t.onAbort&&t.onAbort(l),l="Aborted("+l+")",d(l),v=!0,l+=". Build with -s ASSERTIONS=1 for more info.";var h=new WebAssembly.RuntimeError(l);throw i(h),h}var cd="data:application/octet-stream;base64,";function So(l){return l.startsWith(cd)}var H;H="tflite-simd.wasm",So(H)||(H=m(H));function Io(l){try{if(l==H&&g)return new Uint8Array(g);if(!p)throw"both async and sync fetching of the wasm failed"}catch(h){fe(h)}}function ud(){return!g&&u&&typeof fetch=="function"?fetch(H,{credentials:"same-origin"}).then(function(l){if(!l.ok)throw"failed to load wasm binary file at '"+H+"'";return l.arrayBuffer()}).catch(function(){return Io(H)}):Promise.resolve().then(function(){return Io(H)})}function ld(){var l={a:Fd};function h(E,D){var Y=E.exports;t.asm=Y,x=t.asm.q,_o(x.buffer),mn=t.asm.E,id(t.asm.r),ad()}sd();function y(E){h(E.instance)}function _(E){return ud().then(function(D){return WebAssembly.instantiate(D,l)}).then(function(D){return D}).then(E,function(D){d("failed to asynchronously prepare wasm: "+D),fe(D)})}function I(){return!g&&typeof WebAssembly.instantiateStreaming=="function"&&!So(H)&&typeof fetch=="function"?fetch(H,{credentials:"same-origin"}).then(function(E){var D=WebAssembly.instantiateStreaming(E,l);return D.then(y,function(Y){return d("wasm streaming compile failed: "+Y),d("falling back to ArrayBuffer instantiation"),_(y)})}):_(y)}if(t.instantiateWasm)try{var M=t.instantiateWasm(l,h);return M}catch(E){return d("Module.instantiateWasm callback failed with error: "+E),!1}return I().catch(i),{}}function pn(l){for(;l.length>0;){var h=l.shift();if(typeof h=="function"){h(t);continue}var y=h.func;typeof y=="number"?h.arg===void 0?mn.get(y)():mn.get(y)(h.arg):y(h.arg===void 0?null:h.arg)}}function fd(l,h,y,_){fe("Assertion failed: "+N(l)+", at: "+[h?N(h):"unknown filename",y,_?N(_):"unknown function"])}function dd(l,h){fe("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function hd(l,h){fe("To use dlopen, you need to use Emscripten's linking support, see https://github.com/emscripten-core/emscripten/wiki/Linking")}function md(){fe("")}var fr;fr=function(){return performance.now()};var pd=!0;function gd(l){return V[Ro()>>2]=l,l}function yd(l,h){var y;if(l===0)y=Date.now();else if((l===1||l===4)&&pd)y=fr();else return gd(28),-1;return V[h>>2]=y/1e3|0,V[h+4>>2]=y%1e3*1e3*1e3|0,0}function bd(){return 2147483648}function wd(l,h,y){at.copyWithin(l,h,h+y)}function xd(l){try{return x.grow(l-$.byteLength+65535>>>16),_o(x.buffer),1}catch{}}function vd(l){var h=at.length;l=l>>>0;var y=2147483648;if(l>y)return!1;for(var _=1;_<=4;_*=2){var I=h*(1+.2/_);I=Math.min(I,l+100663296);var M=Math.min(y,Z(Math.max(l,I),65536)),E=xd(M);if(E)return!0}return!1}function _d(l){for(var h=fr();fr()-h<l;);}var gn={};function Ed(){return a||"./this.program"}function ut(){if(!ut.strings){var l=(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:l,_:Ed()};for(var y in gn)gn[y]===void 0?delete h[y]:h[y]=gn[y];var _=[];for(var y in h)_.push(y+"="+h[y]);ut.strings=_}return ut.strings}var dr={mappings:{},buffers:[null,[],[]],printChar:function(l,h){var y=dr.buffers[l];h===0||h===10?((l===1?b:d)(C(y,0)),y.length=0):y.push(h)},varargs:void 0,get:function(){dr.varargs+=4;var l=V[dr.varargs-4>>2];return l},getStr:function(l){var h=N(l);return h},get64:function(l,h){return l}};function Ad(l,h){var y=0;return ut().forEach(function(_,I){var M=h+y;V[l+I*4>>2]=M,J(_,M),y+=_.length+1}),0}function Td(l,h){var y=ut();V[l>>2]=y.length;var _=0;return y.forEach(function(I){_+=I.length+1}),V[h>>2]=_,0}function Sd(l){Md(l)}function Id(l){return 0}function Rd(l,h,y,_,I){}function kd(l,h,y,_){for(var I=0,M=0;M<y;M++){for(var E=V[h+M*8>>2],D=V[h+(M*8+4)>>2],Y=0;Y<D;Y++)dr.printChar(l,at[E+Y]);I+=D}return V[_>>2]=I,0}function Pd(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var l=new Uint8Array(1);return function(){return crypto.getRandomValues(l),l[0]}}else return function(){fe("randomDevice")}}function hr(l,h){hr.randomDevice||(hr.randomDevice=Pd());for(var y=0;y<h;y++)lr[l+y>>0]=hr.randomDevice();return 0}var Fd={a:fd,e:dd,d:hd,b:md,n:yd,h:bd,l:wd,m:vd,p:_d,f:Ad,g:Td,j:Sd,i:Id,k:Rd,c:kd,o:hr};ld(),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 Ro=t.___errno_location=function(){return(Ro=t.___errno_location=t.asm.F).apply(null,arguments)},mr;function Cd(l){this.name="ExitStatus",this.message="Program terminated with exit("+l+")",this.status=l}ct=function l(){mr||yn(),mr||(ct=l)};function yn(l){if(Ae>0||(ed(),Ae>0))return;function h(){mr||(mr=!0,t.calledRun=!0,!v&&(td(),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),rd()))}t.setStatus?(t.setStatus("Running..."),setTimeout(function(){setTimeout(function(){t.setStatus("")},1),h()},1)):h()}t.run=yn;function Md(l,h){Od(l)}function Od(l){c(l,new Cd(l))}if(t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.pop()();return yn(),e.ready})})();class Wf{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/",Vf="https://d3opqjmqzxf057.cloudfront.net/ml/selfie_segmentation/4.0.0/selfie_segmentation_landscape.tflite";async function Hf(r=Gf,e=Vf){let t=new Wf;var n=new Promise(function(i,o){async function s(){return $f({locateFile:function(u){return r+u}})}async function a(c){return new Promise(async(u,f)=>{const m=c;if(typeof m>"u")return f("TFLite backend unavailable: wasmSimd");let p=e;console.log("TFLite modelUrl: "+p);try{const d=await(await fetch(p)).arrayBuffer();console.log("Model buffer size:",d.byteLength);const g=m._getModelBufferMemoryOffset();console.log("Model buffer memory offset:",g),console.log("Loading model buffer..."),m.HEAPU8.set(new Uint8Array(d),g);const x=m._loadModel(d.byteLength);if(console.log("Load model result:",x),x!==0){f("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(b){f(b);return}u()})}s().then(c=>{if(c===null)throw console.error("loadTFLite null"),"loadTFLite null";a(c).then(u=>{i(t)}).catch(u=>{console.error("loadTFLiteModel error"),o("loadTFLiteModel error")})}).catch(c=>{console.error("loadTFLite error:",c),o("loadTFLite error:"+c)})});return n}const jf=.1,Yf=.7,Qf="https://d3opqjmqzxf057.cloudfront.net/ml/vonage_selfie_segmenter/float16/v1/vonage_selfie_segmenter.tflite";class qf{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||Qf;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:o,ImageSegmenter:s}=await import(n);this.ImageSegmenter=s,this.wasmFileset=await o.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,s=>{n=s.confidenceMasks?.[0]?.getAsFloat32Array()})}catch{await this.createImageSegmenter();return}if(!n)return;if(!this.previousConfidenceMask){this.previousConfidenceMask=n.slice();return}const i=n.map((s,a)=>{const c=this.previousConfidenceMask?.[a];return c!==void 0?this.blend(c,s):s}),o=[255,0,0];for(let s=0;s<i?.length;s++){const a=1-i[s];a>jf?(a<Yf?(this.mask.data[s*4]=o[0]*a,this.mask.data[s*4+3]=255*a):(this.mask.data[s*4]=o[0],this.mask.data[s*4+3]=255),this.mask.data[s*4+1]=o[1],this.mask.data[s*4+2]=o[2]):this.mask.data[s*4]=this.mask.data[s*4+1]=this.mask.data[s*4+2]=this.mask.data[s*4+3]=0}return this.previousConfidenceMask=i.slice(),this.mask}isGpuSupported(){return!0}blend(e,t){const i=-.748699,o=-57.8051,s=291.309,a=-624.717,c=t-.5,u=c*c,f=1-Math.min(1,u*(5.68842+u*(i+u*(o+u*(s+u*a)))));return t+(e-t)*(f*.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 Hf(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),o=this.infos.selectedTFLite.HEAPF32;for(let s=0;s<this.pixelCount;s++){const a=this.inputOffset+s*3;o[a]=i.data[s*4]/255,o[a+1]=i.data[s*4+1]/255,o[a+2]=i.data[s*4+2]/255}this.infos.selectedTFLite._runInference();for(let s=0;s<this.pixelCount;s++){const a=this.infos.selectedTFLite.HEAPF32[this.outputOffset+s];this.mask.data[s*4]=this.mask.data[s*4+3]=255*a}return this.mask}isGpuSupported(){return this.infos?.selectedTFLite?._isGPUEnabled()??!1}}class wo{constructor(){this.reporter=new ia,this.isEnabled=!0}async init(e,t){t.segmentationOptions?.lightWeightEngine===!0?this.selfieSegmentation=new Xf:this.selfieSegmentation=new qf,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,o=await createImageBitmap(e),s=await this.selfieSegmentation?.process(o);s&&(n=await this.backgroundFilter?.process(o,s)),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:oa,action:"MlTransformers",transformerType:this.backgroundOptions?.transformerType,config:JSON.stringify(this.backgroundOptions),...e})}}const dn=class dn{constructor(){this.backgroundTransformer=new wo,this.mediaProcessor=new Fn,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){rs(e)}async profile(e){return JSON.stringify(await this.backgroundTransformer.profile(e))}};Ps("ProcessorWorker",dn);let ln=dn;const xo='(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 data: ${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 data: ${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',vo=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",xo],{type:"text/javascript;charset=utf-8"});function Kf(r){let e;try{if(e=vo&&(self.URL||self.webkitURL).createObjectURL(vo),!e)throw"";const t=new Worker(e,{name:r?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(xo),{name:r?.name})}}const ur=class ur extends Qe{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":await this.destroy();return}break}}}async startWorker(){!this.config||this.worker||(this.worker=await Rs(ln,Kf),this.isEnabled||await this.worker.disable(),await this.worker.init(`worker_${ur.initCount++}`,this.config),await this.worker.setVonageMetadata(wt()),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 Hn.createVideoReadable(e.backgroundAssetUri));break;case"VirtualBackground":await this.worker?.setVirtualBGImage(await Hn.createImageCanvas(e.backgroundAssetUri));break}await this.worker?.setBackgroundOptions(e)}};ur.initCount=0;let fn=ur;class Jf{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={},n=[];let i=0;for(const s of this.queries){const a=[];for(const c of s)t[c.name]===void 0&&(t[c.name]=e.length,e.push({name:c.name})),a.push({type:c.action==po.PUSH?"O":"C",frame:t[c.name],at:c.timestamp}),i=Math.max(i,c.timestamp+c.duration);n.push({events:a,type:"evented",name:"GPU Profile",unit:"nanoseconds",startValue:0,endValue:i})}return JSON.stringify({$schema:"https://www.speedscope.app/file-format-schema.json",shared:{frames:e},profiles:n},null,2)}}const hn=class hn extends Qe{constructor(e){super(),this.worker=new fn(e),this.connector=new ps(this.worker),this.worker.onAny((t,n)=>this.emit(t,n))}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(n=>n.profile(e)));return new Jf(t)}static async create(e){const t=new this(e);return this.instances.push(t),t}};hn.instances=[];let cr=hn;async function Zf(r){return await cr.create(r)}k.BackgroundTransformer=wo,k.BackgroundTransformerType=Cn,k.BlurRadius=He,k.ErrorFunction=Pn,k.PipelineInfoData=vt,k.RenderingType=je,k.VonageMediaProcessor=cr,k.WarningType=kn,k.WebglSelfieSegmentationType=_t,k.createVonageMediaProcessor=Zf,k.getSupportedBrowserFeatures=Mn,k.isSupported=ys,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})}));
|
|
313
194
|
//# sourceMappingURL=ml-transformers.umd.js.map
|