diff --git "a/face-canvas.js" "b/face-canvas.js" --- "a/face-canvas.js" +++ "b/face-canvas.js" @@ -16,4 +16,4 @@ gl_FragColor = texture2D(sampler0, vTex); }`,1),u=n.createProgram();if(n.attachShader(u,r),n.attachShader(u,i),n.linkProgram(u),!n.getProgramParameter(u,n.LINK_STATUS))throw Error(`Could not compile WebGL program. -`+n.getProgramInfoLog(u));r=t.m=u,n.useProgram(r),i=n.getUniformLocation(r,"sampler0"),t.j={I:n.getAttribLocation(r,"aVertex"),H:n.getAttribLocation(r,"aTex"),da:i},t.s=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,t.s),n.enableVertexAttribArray(t.j.I),n.vertexAttribPointer(t.j.I,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),t.o=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,t.o),n.enableVertexAttribArray(t.j.H),n.vertexAttribPointer(t.j.H,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.uniform1i(i,0)}r=t.j,n.useProgram(t.m),n.canvas.width=e.width,n.canvas.height=e.height,n.viewport(0,0,e.width,e.height),n.activeTexture(n.TEXTURE0),t.h.bindTexture2d(e.glName),n.enableVertexAttribArray(r.I),n.bindBuffer(n.ARRAY_BUFFER,t.s),n.vertexAttribPointer(r.I,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(r.H),n.bindBuffer(n.ARRAY_BUFFER,t.o),n.vertexAttribPointer(r.H,2,n.FLOAT,!1,0,0),n.bindFramebuffer(n.DRAW_FRAMEBUFFER?n.DRAW_FRAMEBUFFER:n.FRAMEBUFFER,null),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.colorMask(!0,!0,!0,!0),n.drawArrays(n.TRIANGLE_FAN,0,4),n.disableVertexAttribArray(r.I),n.disableVertexAttribArray(r.H),n.bindBuffer(n.ARRAY_BUFFER,null),t.h.bindTexture2d(0)}function gn(t){this.g=t}var dn=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 pn(t,e){return e+t}function Ie(t,e){window[t]=e}function vn(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(n){e.addEventListener("load",function(){n()},!1),e.addEventListener("error",function(){n()},!1),document.body.appendChild(e)})}function yn(){return rt(this,function t(){return Y(t,function(e){switch(e.g){case 1:return e.m=2,m(e,WebAssembly.instantiate(dn),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 fe(t){if(this.g=t,this.listeners={},this.j={},this.F={},this.m={},this.s={},this.G=this.o=this.R=!0,this.C=Promise.resolve(),this.P="",this.B={},this.locateFile=t&&t.locateFile||pn,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,t.options){e=B(Object.keys(t.options));for(var n=e.next();!n.done;n=e.next()){n=n.value;var r=t.options[n].default;r!==void 0&&(this.j[n]=typeof r=="function"?r():r)}}}a=fe.prototype,a.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function mn(t,e){return t.g.files===void 0?[]:typeof t.g.files=="function"?t.g.files(e):t.g.files}function wn(t){return rt(t,function e(){var n=this,r,i,u,o,c,h,d,_,z,T,k;return Y(e,function(v){switch(v.g){case 1:return r=n,n.R?(i=mn(n,n.j),m(v,yn(),2)):v.return();case 2:if(u=v.h,typeof window=="object")return Ie("createMediapipeSolutionsWasm",{locateFile:n.locateFile}),Ie("createMediapipeSolutionsPackedAssets",{locateFile:n.locateFile}),h=i.filter(function(E){return E.data!==void 0}),d=i.filter(function(E){return E.data===void 0}),_=Promise.all(h.map(function(E){var S=he(r,E.url);if(E.path!==void 0){var M=E.path;S=S.then(function(tt){return r.overrideFile(M,tt),Promise.resolve(tt)})}return S})),z=Promise.all(d.map(function(E){return E.simd===void 0||E.simd&&u||!E.simd&&!u?vn(r.locateFile(E.url,r.S)):Promise.resolve()})).then(function(){return rt(r,function E(){var S,M,tt=this;return Y(E,function(X){if(X.g==1)return S=window.createMediapipeSolutionsWasm,M=window.createMediapipeSolutionsPackedAssets,m(X,S(M),2);tt.h=X.h,X.g=0})})}),T=function(){return rt(r,function E(){var S=this;return Y(E,function(M){return S.g.graph&&S.g.graph.url?M=m(M,he(S,S.g.graph.url),0):(M.g=0,M=void 0),M})})}(),m(v,Promise.all([z,_,T]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return o=i.filter(function(E){return E.simd===void 0||E.simd&&u||!E.simd&&!u}).map(function(E){return r.locateFile(E.url,r.S)}),importScripts.apply(null,$(o)),m(v,createMediapipeSolutionsWasm(Module),6);case 6:n.h=v.h,n.l=new OffscreenCanvas(1,1),n.h.canvas=n.l,c=n.h.GL.createContext(n.l,{antialias:!1,alpha:!1,ba:typeof WebGL2RenderingContext<"u"?2:1}),n.h.GL.makeContextCurrent(c),v.g=4;break;case 7:if(n.l=document.createElement("canvas"),k=n.l.getContext("webgl2",{}),!k&&(k=n.l.getContext("webgl",{}),!k))return alert("Failed to create WebGL canvas context when passing video frame."),v.return();n.D=k,n.h.canvas=n.l,n.h.createContext(n.l,!0,!0,{});case 4:n.i=new n.h.SolutionWasm,n.R=!1,v.g=0}})})}function bn(t){return rt(t,function e(){var n=this,r,i,u,o,c,h,d,_;return Y(e,function(z){if(z.g==1){if(n.g.graph&&n.g.graph.url&&n.P===n.g.graph.url)return z.return();if(n.o=!0,!n.g.graph||!n.g.graph.url){z.g=2;return}return n.P=n.g.graph.url,m(z,he(n,n.g.graph.url),3)}for(z.g!=2&&(r=z.h,n.i.loadGraph(r)),i=B(Object.keys(n.B)),u=i.next();!u.done;u=i.next())o=u.value,n.i.overrideFile(o,n.B[o]);if(n.B={},n.g.listeners)for(c=B(n.g.listeners),h=c.next();!h.done;h=c.next())d=h.value,kn(n,d);_=n.j,n.j={},n.setOptions(_),z.g=0})})}a.reset=function(){return rt(this,function t(){var e=this;return Y(t,function(n){e.i&&(e.i.reset(),e.m={},e.s={}),n.g=0})})},a.setOptions=function(t,e){var n=this;if(e=e||this.g.options){for(var r=[],i=[],u={},o=B(Object.keys(t)),c=o.next();!c.done;u={K:u.K,L:u.L},c=o.next()){var h=c.value;h in this.j&&this.j[h]===t[h]||(this.j[h]=t[h],c=e[h],c!==void 0&&(c.onChange&&(u.K=c.onChange,u.L=t[h],r.push(function(d){return function(){return rt(n,function _(){var z,T=this;return Y(_,function(k){if(k.g==1)return m(k,d.K(d.L),2);z=k.h,z===!0&&(T.o=!0),k.g=0})})}}(u))),c.graphOptionXref&&(h={valueNumber:c.type===1?t[h]:0,valueBoolean:c.type===0?t[h]:!1,valueString:c.type===2?t[h]:""},c=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),c.graphOptionXref),h),i.push(c))))}(r.length!==0||i.length!==0)&&(this.o=!0,this.A=(this.A===void 0?[]:this.A).concat(i),this.u=(this.u===void 0?[]:this.u).concat(r))}};function xn(t){return rt(t,function e(){var n=this,r,i,u,o,c,h,d;return Y(e,function(_){switch(_.g){case 1:if(!n.o)return _.return();if(!n.u){_.g=2;break}r=B(n.u),i=r.next();case 3:if(i.done){_.g=5;break}return u=i.value,m(_,u(),4);case 4:i=r.next(),_.g=3;break;case 5:n.u=void 0;case 2:if(n.A){for(o=new n.h.GraphOptionChangeRequestList,c=B(n.A),h=c.next();!h.done;h=c.next())d=h.value,o.push_back(d);n.i.changeOptions(o),o.delete(),n.A=void 0}n.o=!1,_.g=0}})})}a.initialize=function(){return rt(this,function t(){var e=this;return Y(t,function(n){return n.g==1?m(n,wn(e),2):n.g!=3?m(n,bn(e),3):m(n,xn(e),0)})})};function he(t,e){return rt(t,function n(){var r=this,i,u;return Y(n,function(o){return e in r.F?o.return(r.F[e]):(i=r.locateFile(e,""),u=fetch(i).then(function(c){return c.arrayBuffer()}),r.F[e]=u,o.return(u))})})}a.overrideFile=function(t,e){this.i?this.i.overrideFile(t,e):this.B[t]=e},a.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},a.send=function(t,e){return rt(this,function n(){var r=this,i,u,o,c,h,d,_,z,T;return Y(n,function(k){switch(k.g){case 1:return r.g.inputs?(i=1e3*(e??performance.now()),m(k,r.C,2)):k.return();case 2:return m(k,r.initialize(),3);case 3:for(u=new r.h.PacketDataList,o=B(Object.keys(t)),c=o.next();!c.done;c=o.next())if(h=c.value,d=r.g.inputs[h]){t:{var v=r,E=t[h];switch(d.type){case"video":var S=v.m[d.stream];if(S||(S=new le(v.h,v.D),v.m[d.stream]=S),v=S,v.l===0&&(v.l=v.h.createTexture()),typeof HTMLVideoElement<"u"&&E instanceof HTMLVideoElement){var M=E.videoWidth;S=E.videoHeight}else typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(M=E.naturalWidth,S=E.naturalHeight):(M=E.width,S=E.height);S={glName:v.l,width:M,height:S},M=v.g,M.canvas.width=S.width,M.canvas.height=S.height,M.activeTexture(M.TEXTURE0),v.h.bindTexture2d(v.l),M.texImage2D(M.TEXTURE_2D,0,M.RGBA,M.RGBA,M.UNSIGNED_BYTE,E),v.h.bindTexture2d(0),v=S;break t;case"detections":for(S=v.m[d.stream],S||(S=new gn(v.h),v.m[d.stream]=S),v=S,v.data||(v.data=new v.g.DetectionListData),v.data.reset(E.length),S=0;SN,N=Math.abs(N);var I=N>>>0;for(N=Math.floor((N-I)/4294967296),N>>>=0,U&&(N=~N>>>0,I=(~I>>>0)+1,4294967295>>7|I<<25)>>>0,I>>>=7;R.push(U)}if(ae(j,P),Z=se(Z),X.call(tt,it,Z),M.O)for(tt=0;ttN;N++)U.push(I&127|128),I>>=7;U.push(1)}ht(R,2,D(P,2)),U=D(P,3),U!=null&&(U=K(U),_t(R.g,26),_t(R.g,U.length),Nt(R,R.g.end()),Nt(R,U)),U=D(P,4),U!=null&&(U=K(U),_t(R.g,34),_t(R.g,U.length),Nt(R,R.g.end()),Nt(R,U)),ae(P,R),j=se(j),it.call(X,Z,j)}}v=v.data;break t;default:v={}}}switch(_=v,z=d.stream,d.type){case"video":u.pushTexture2d(Object.assign(Object.assign({},_),{stream:z,timestamp:i}));break;case"detections":T=_,T.stream=z,T.timestamp=i,u.pushDetectionList(T);break;default:throw Error("Unknown input config type: '"+d.type+"'")}}return r.i.send(u),m(k,r.C,4);case 4:u.delete(),k.g=0}})})};function _n(t,e,n){return rt(t,function r(){var i,u,o,c,h,d,_=this,z,T,k,v,E,S,M,tt;return Y(r,function(X){switch(X.g){case 1:if(!n)return X.return(e);for(i={},u=0,o=B(Object.keys(n)),c=o.next();!c.done;c=o.next())h=c.value,d=n[h],typeof d!="string"&&d.type==="texture"&&e[d.stream]!==void 0&&++u;1>>0)+"_",W=0;return l}),w("Symbol.iterator",function(s){if(s)return s;s=Symbol("Symbol.iterator");for(var l="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),x=0;x"u"?!0:(typeof g=="function"?g=new g("unhandledrejection",{cancelable:!0}):typeof b=="function"?g=new b("unhandledrejection",{cancelable:!0}):(g=A.document.createEvent("CustomEvent"),g.initCustomEvent("unhandledrejection",!1,!0,g)),g.promise=this,g.reason=this.i,G(g))},l.prototype.H=function(){if(this.g!=null){for(var g=0;g"u"||ot.execScript("var "+ut[0]);for(var Y;ut.length&&(Y=ut.shift());)ut.length||m===void 0?ot[Y]&&ot[Y]!==Object.prototype[Y]?ot=ot[Y]:ot=ot[Y]={}:ot[Y]=m}).call(Vt);const qn=[33,7,163,144,145,153,154,155,133,173,157,157,158,159,160,161,246],t1=[263,249,390,373,374,380,381,382,362,398,384,384,385,386,387,388,466],e1=[156,70,63,105,66,107],n1=[383,300,293,334,296,336],r1=[78,191,80,81,82,13,312,311,310,415,308,324,318,402,317,14,87,178,88,95,78],i1=[61,185,40,39,37,0,267,269,270,409,291,375,321,405,314,17,84,181,91,146],o1=[6,197,195,5,4],s1=[98,97,2,328,327],a1=[454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234];function u1(a){Fn(a,"svelte-39b13y","canvas.svelte-39b13y{border-radius:0.5rem;--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.capture-btn.svelte-39b13y{z-index:10;border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(248 250 252 / var(--tw-bg-opacity));padding-left:0.5rem;padding-right:0.5rem;padding-top:0.25rem;padding-bottom:0.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(0 0 0 / var(--tw-text-opacity));--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.capture-btn.svelte-39b13y:hover{--tw-bg-opacity:1;background-color:rgb(207 250 254 / var(--tw-bg-opacity))}.container.svelte-39b13y *{color:black !important}")}function c1(a){let f,y,A,w,L,O,B,$,C,J,V;return{c(){f=Lt("div"),y=Lt("video"),A=ge(),w=Lt("canvas"),L=ge(),O=Lt("div"),B=Lt("button"),B.textContent="Snap",$=ge(),C=Lt("canvas"),dt(y,"class","hidden"),dt(w,"width","720px"),dt(w,"height","720px"),dt(w,"class","w-full svelte-39b13y"),dt(B,"class","capture-btn svelte-39b13y"),dt(C,"width","720px"),dt(C,"height","720px"),dt(C,"class","w-32 svelte-39b13y"),dt(O,"class","flex absolute bottom-1 left-1 items-end"),dt(f,"class","relative container svelte-39b13y")},m(et,H){Cn(et,f,H),wt(f,y),a[4](y),wt(f,A),wt(f,w),a[5](w),wt(f,L),wt(f,O),wt(O,B),wt(O,$),wt(O,C),a[6](C),J||(V=Nn(B,"click",a[3]),J=!0)},p:$t,i:$t,o:$t,d(et){et&&Ke(f),a[4](null),a[5](null),a[6](null),J=!1,V()}}}function l1(a,f,y){const A=Zn.FaceMesh||window.FaceMesh,w=Qn.Camera||window.Camera;let L,O,B,$,C,J,V,et;Gn(()=>{et=document.getElementById("canvas-root"),et._data||(et._data={image:null}),B=O.getContext("2d"),J=document.createElement("canvas"),V=J.getContext("2d"),J.width=O.width,J.height=O.height;const m=new A({locateFile:Ot=>`https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/${Ot}`});m.setOptions({maxNumFaces:1,refineLandmarks:!0,minDetectionConfidence:.5,minTrackingConfidence:.5}),m.onResults(ct),new w(L,{onFrame:async()=>{await m.send({image:L})},width:720,height:720}).start()});function H(m,Q,Ot,bt="lime",ut=4,ot=!1){m.save(),m.beginPath(),m.strokeStyle=bt,m.fillStyle=bt,m.lineWidth=ut;for(const[Y,s]of Ot.entries()){const l=Q[s];Y===0?m.moveTo(l.x*O.width,l.y*O.height):m.lineTo(l.x*O.width,l.y*O.height)}ot?(m.closePath(),m.fill()):m.stroke(),m.restore()}function ct(m){if(B.save(),B.clearRect(0,0,O.width,O.height),B.drawImage(m.image,0,0,O.width,O.height),V.clearRect(0,0,J.width,J.height),m.multiFaceLandmarks)for(const Q of m.multiFaceLandmarks)H(V,Q,t1,"magenta",8,!0),H(V,Q,qn,"magenta",8,!0),H(V,Q,e1,"yellow",8,!1),H(V,Q,n1,"yellow",8,!1),H(V,Q,i1,"cyan",8,!0),H(V,Q,r1,"blue",8,!0),H(V,Q,o1,"orange",8,!1),H(V,Q,s1,"orange",8,!1),H(V,Q,a1,"lime",8,!1);B.drawImage(J,0,0,O.width,O.height)}function at(){C=$.getContext("2d"),C.fillStyle="black",C.fillRect(0,0,$.width,$.height),C.drawImage(J,0,0,$.width,$.height),et._data.image=$.toDataURL()}function kt(m){Jt[m?"unshift":"push"](()=>{L=m,y(0,L)})}function jt(m){Jt[m?"unshift":"push"](()=>{O=m,y(1,O)})}function At(m){Jt[m?"unshift":"push"](()=>{$=m,y(2,$)})}return[L,O,$,at,kt,jt,At]}class f1 extends Kn{constructor(f){super(),Jn(this,f,l1,c1,Tn,{},u1)}}class h1 extends HTMLElement{constructor(){super()}connectedCallback(){const f=this.attachShadow({mode:"open"}),y=document.createElement("style");y.appendChild(document.createTextNode(Sn)),f.appendChild(y),new f1({target:f})}}customElements.define("face-canvas",h1); +`+n.getProgramInfoLog(u));r=t.m=u,n.useProgram(r),i=n.getUniformLocation(r,"sampler0"),t.j={I:n.getAttribLocation(r,"aVertex"),H:n.getAttribLocation(r,"aTex"),da:i},t.s=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,t.s),n.enableVertexAttribArray(t.j.I),n.vertexAttribPointer(t.j.I,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),t.o=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,t.o),n.enableVertexAttribArray(t.j.H),n.vertexAttribPointer(t.j.H,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.uniform1i(i,0)}r=t.j,n.useProgram(t.m),n.canvas.width=e.width,n.canvas.height=e.height,n.viewport(0,0,e.width,e.height),n.activeTexture(n.TEXTURE0),t.h.bindTexture2d(e.glName),n.enableVertexAttribArray(r.I),n.bindBuffer(n.ARRAY_BUFFER,t.s),n.vertexAttribPointer(r.I,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(r.H),n.bindBuffer(n.ARRAY_BUFFER,t.o),n.vertexAttribPointer(r.H,2,n.FLOAT,!1,0,0),n.bindFramebuffer(n.DRAW_FRAMEBUFFER?n.DRAW_FRAMEBUFFER:n.FRAMEBUFFER,null),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.colorMask(!0,!0,!0,!0),n.drawArrays(n.TRIANGLE_FAN,0,4),n.disableVertexAttribArray(r.I),n.disableVertexAttribArray(r.H),n.bindBuffer(n.ARRAY_BUFFER,null),t.h.bindTexture2d(0)}function gn(t){this.g=t}var dn=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 pn(t,e){return e+t}function Ie(t,e){window[t]=e}function vn(t){var e=document.createElement("script");return e.setAttribute("src",t),e.setAttribute("crossorigin","anonymous"),new Promise(function(n){e.addEventListener("load",function(){n()},!1),e.addEventListener("error",function(){n()},!1),document.body.appendChild(e)})}function yn(){return rt(this,function t(){return Y(t,function(e){switch(e.g){case 1:return e.m=2,m(e,WebAssembly.instantiate(dn),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 fe(t){if(this.g=t,this.listeners={},this.j={},this.F={},this.m={},this.s={},this.G=this.o=this.R=!0,this.C=Promise.resolve(),this.P="",this.B={},this.locateFile=t&&t.locateFile||pn,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,t.options){e=B(Object.keys(t.options));for(var n=e.next();!n.done;n=e.next()){n=n.value;var r=t.options[n].default;r!==void 0&&(this.j[n]=typeof r=="function"?r():r)}}}a=fe.prototype,a.close=function(){return this.i&&this.i.delete(),Promise.resolve()};function mn(t,e){return t.g.files===void 0?[]:typeof t.g.files=="function"?t.g.files(e):t.g.files}function wn(t){return rt(t,function e(){var n=this,r,i,u,o,c,h,d,_,z,T,k;return Y(e,function(v){switch(v.g){case 1:return r=n,n.R?(i=mn(n,n.j),m(v,yn(),2)):v.return();case 2:if(u=v.h,typeof window=="object")return Ie("createMediapipeSolutionsWasm",{locateFile:n.locateFile}),Ie("createMediapipeSolutionsPackedAssets",{locateFile:n.locateFile}),h=i.filter(function(E){return E.data!==void 0}),d=i.filter(function(E){return E.data===void 0}),_=Promise.all(h.map(function(E){var S=he(r,E.url);if(E.path!==void 0){var M=E.path;S=S.then(function(tt){return r.overrideFile(M,tt),Promise.resolve(tt)})}return S})),z=Promise.all(d.map(function(E){return E.simd===void 0||E.simd&&u||!E.simd&&!u?vn(r.locateFile(E.url,r.S)):Promise.resolve()})).then(function(){return rt(r,function E(){var S,M,tt=this;return Y(E,function(X){if(X.g==1)return S=window.createMediapipeSolutionsWasm,M=window.createMediapipeSolutionsPackedAssets,m(X,S(M),2);tt.h=X.h,X.g=0})})}),T=function(){return rt(r,function E(){var S=this;return Y(E,function(M){return S.g.graph&&S.g.graph.url?M=m(M,he(S,S.g.graph.url),0):(M.g=0,M=void 0),M})})}(),m(v,Promise.all([z,_,T]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return o=i.filter(function(E){return E.simd===void 0||E.simd&&u||!E.simd&&!u}).map(function(E){return r.locateFile(E.url,r.S)}),importScripts.apply(null,$(o)),m(v,createMediapipeSolutionsWasm(Module),6);case 6:n.h=v.h,n.l=new OffscreenCanvas(1,1),n.h.canvas=n.l,c=n.h.GL.createContext(n.l,{antialias:!1,alpha:!1,ba:typeof WebGL2RenderingContext<"u"?2:1}),n.h.GL.makeContextCurrent(c),v.g=4;break;case 7:if(n.l=document.createElement("canvas"),k=n.l.getContext("webgl2",{}),!k&&(k=n.l.getContext("webgl",{}),!k))return alert("Failed to create WebGL canvas context when passing video frame."),v.return();n.D=k,n.h.canvas=n.l,n.h.createContext(n.l,!0,!0,{});case 4:n.i=new n.h.SolutionWasm,n.R=!1,v.g=0}})})}function bn(t){return rt(t,function e(){var n=this,r,i,u,o,c,h,d,_;return Y(e,function(z){if(z.g==1){if(n.g.graph&&n.g.graph.url&&n.P===n.g.graph.url)return z.return();if(n.o=!0,!n.g.graph||!n.g.graph.url){z.g=2;return}return n.P=n.g.graph.url,m(z,he(n,n.g.graph.url),3)}for(z.g!=2&&(r=z.h,n.i.loadGraph(r)),i=B(Object.keys(n.B)),u=i.next();!u.done;u=i.next())o=u.value,n.i.overrideFile(o,n.B[o]);if(n.B={},n.g.listeners)for(c=B(n.g.listeners),h=c.next();!h.done;h=c.next())d=h.value,kn(n,d);_=n.j,n.j={},n.setOptions(_),z.g=0})})}a.reset=function(){return rt(this,function t(){var e=this;return Y(t,function(n){e.i&&(e.i.reset(),e.m={},e.s={}),n.g=0})})},a.setOptions=function(t,e){var n=this;if(e=e||this.g.options){for(var r=[],i=[],u={},o=B(Object.keys(t)),c=o.next();!c.done;u={K:u.K,L:u.L},c=o.next()){var h=c.value;h in this.j&&this.j[h]===t[h]||(this.j[h]=t[h],c=e[h],c!==void 0&&(c.onChange&&(u.K=c.onChange,u.L=t[h],r.push(function(d){return function(){return rt(n,function _(){var z,T=this;return Y(_,function(k){if(k.g==1)return m(k,d.K(d.L),2);z=k.h,z===!0&&(T.o=!0),k.g=0})})}}(u))),c.graphOptionXref&&(h={valueNumber:c.type===1?t[h]:0,valueBoolean:c.type===0?t[h]:!1,valueString:c.type===2?t[h]:""},c=Object.assign(Object.assign(Object.assign({},{calculatorName:"",calculatorIndex:0}),c.graphOptionXref),h),i.push(c))))}(r.length!==0||i.length!==0)&&(this.o=!0,this.A=(this.A===void 0?[]:this.A).concat(i),this.u=(this.u===void 0?[]:this.u).concat(r))}};function xn(t){return rt(t,function e(){var n=this,r,i,u,o,c,h,d;return Y(e,function(_){switch(_.g){case 1:if(!n.o)return _.return();if(!n.u){_.g=2;break}r=B(n.u),i=r.next();case 3:if(i.done){_.g=5;break}return u=i.value,m(_,u(),4);case 4:i=r.next(),_.g=3;break;case 5:n.u=void 0;case 2:if(n.A){for(o=new n.h.GraphOptionChangeRequestList,c=B(n.A),h=c.next();!h.done;h=c.next())d=h.value,o.push_back(d);n.i.changeOptions(o),o.delete(),n.A=void 0}n.o=!1,_.g=0}})})}a.initialize=function(){return rt(this,function t(){var e=this;return Y(t,function(n){return n.g==1?m(n,wn(e),2):n.g!=3?m(n,bn(e),3):m(n,xn(e),0)})})};function he(t,e){return rt(t,function n(){var r=this,i,u;return Y(n,function(o){return e in r.F?o.return(r.F[e]):(i=r.locateFile(e,""),u=fetch(i).then(function(c){return c.arrayBuffer()}),r.F[e]=u,o.return(u))})})}a.overrideFile=function(t,e){this.i?this.i.overrideFile(t,e):this.B[t]=e},a.clearOverriddenFiles=function(){this.B={},this.i&&this.i.clearOverriddenFiles()},a.send=function(t,e){return rt(this,function n(){var r=this,i,u,o,c,h,d,_,z,T;return Y(n,function(k){switch(k.g){case 1:return r.g.inputs?(i=1e3*(e??performance.now()),m(k,r.C,2)):k.return();case 2:return m(k,r.initialize(),3);case 3:for(u=new r.h.PacketDataList,o=B(Object.keys(t)),c=o.next();!c.done;c=o.next())if(h=c.value,d=r.g.inputs[h]){t:{var v=r,E=t[h];switch(d.type){case"video":var S=v.m[d.stream];if(S||(S=new le(v.h,v.D),v.m[d.stream]=S),v=S,v.l===0&&(v.l=v.h.createTexture()),typeof HTMLVideoElement<"u"&&E instanceof HTMLVideoElement){var M=E.videoWidth;S=E.videoHeight}else typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(M=E.naturalWidth,S=E.naturalHeight):(M=E.width,S=E.height);S={glName:v.l,width:M,height:S},M=v.g,M.canvas.width=S.width,M.canvas.height=S.height,M.activeTexture(M.TEXTURE0),v.h.bindTexture2d(v.l),M.texImage2D(M.TEXTURE_2D,0,M.RGBA,M.RGBA,M.UNSIGNED_BYTE,E),v.h.bindTexture2d(0),v=S;break t;case"detections":for(S=v.m[d.stream],S||(S=new gn(v.h),v.m[d.stream]=S),v=S,v.data||(v.data=new v.g.DetectionListData),v.data.reset(E.length),S=0;SN,N=Math.abs(N);var I=N>>>0;for(N=Math.floor((N-I)/4294967296),N>>>=0,U&&(N=~N>>>0,I=(~I>>>0)+1,4294967295>>7|I<<25)>>>0,I>>>=7;R.push(U)}if(ae(j,P),Z=se(Z),X.call(tt,it,Z),M.O)for(tt=0;ttN;N++)U.push(I&127|128),I>>=7;U.push(1)}ht(R,2,D(P,2)),U=D(P,3),U!=null&&(U=K(U),_t(R.g,26),_t(R.g,U.length),Nt(R,R.g.end()),Nt(R,U)),U=D(P,4),U!=null&&(U=K(U),_t(R.g,34),_t(R.g,U.length),Nt(R,R.g.end()),Nt(R,U)),ae(P,R),j=se(j),it.call(X,Z,j)}}v=v.data;break t;default:v={}}}switch(_=v,z=d.stream,d.type){case"video":u.pushTexture2d(Object.assign(Object.assign({},_),{stream:z,timestamp:i}));break;case"detections":T=_,T.stream=z,T.timestamp=i,u.pushDetectionList(T);break;default:throw Error("Unknown input config type: '"+d.type+"'")}}return r.i.send(u),m(k,r.C,4);case 4:u.delete(),k.g=0}})})};function _n(t,e,n){return rt(t,function r(){var i,u,o,c,h,d,_=this,z,T,k,v,E,S,M,tt;return Y(r,function(X){switch(X.g){case 1:if(!n)return X.return(e);for(i={},u=0,o=B(Object.keys(n)),c=o.next();!c.done;c=o.next())h=c.value,d=n[h],typeof d!="string"&&d.type==="texture"&&e[d.stream]!==void 0&&++u;1>>0)+"_",W=0;return l}),w("Symbol.iterator",function(s){if(s)return s;s=Symbol("Symbol.iterator");for(var l="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),x=0;x"u"?!0:(typeof g=="function"?g=new g("unhandledrejection",{cancelable:!0}):typeof b=="function"?g=new b("unhandledrejection",{cancelable:!0}):(g=A.document.createEvent("CustomEvent"),g.initCustomEvent("unhandledrejection",!1,!0,g)),g.promise=this,g.reason=this.i,G(g))},l.prototype.H=function(){if(this.g!=null){for(var g=0;g"u"||ot.execScript("var "+ut[0]);for(var Y;ut.length&&(Y=ut.shift());)ut.length||m===void 0?ot[Y]&&ot[Y]!==Object.prototype[Y]?ot=ot[Y]:ot=ot[Y]={}:ot[Y]=m}).call(Vt);const qn=[33,7,163,144,145,153,154,155,133,173,157,157,158,159,160,161,246],t1=[263,249,390,373,374,380,381,382,362,398,384,384,385,386,387,388,466],e1=[156,70,63,105,66,107],n1=[383,300,293,334,296,336],r1=[78,191,80,81,82,13,312,311,310,415,308,324,318,402,317,14,87,178,88,95,78],i1=[61,185,40,39,37,0,267,269,270,409,291,375,321,405,314,17,84,181,91,146],o1=[6,197,195,5,4],s1=[98,97,2,328,327],a1=[454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234];function u1(a){Fn(a,"svelte-39b13y","canvas.svelte-39b13y{border-radius:0.5rem;--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.capture-btn.svelte-39b13y{z-index:10;border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(248 250 252 / var(--tw-bg-opacity));padding-left:0.5rem;padding-right:0.5rem;padding-top:0.25rem;padding-bottom:0.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(0 0 0 / var(--tw-text-opacity));--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.capture-btn.svelte-39b13y:hover{--tw-bg-opacity:1;background-color:rgb(207 250 254 / var(--tw-bg-opacity))}.container.svelte-39b13y *{color:black !important}")}function c1(a){let f,y,A,w,L,O,B,$,C,J,V;return{c(){f=Lt("div"),y=Lt("video"),A=ge(),w=Lt("canvas"),L=ge(),O=Lt("div"),B=Lt("button"),B.textContent="Snap",$=ge(),C=Lt("canvas"),dt(y,"class","hidden"),y.muted=!0,y.playsInline=!0,dt(w,"width","720px"),dt(w,"height","720px"),dt(w,"class","w-full svelte-39b13y"),dt(B,"class","capture-btn svelte-39b13y"),dt(C,"width","720px"),dt(C,"height","720px"),dt(C,"class","w-32 svelte-39b13y"),dt(O,"class","flex absolute bottom-1 left-1 items-end"),dt(f,"class","relative container svelte-39b13y")},m(et,H){Cn(et,f,H),wt(f,y),a[4](y),wt(f,A),wt(f,w),a[5](w),wt(f,L),wt(f,O),wt(O,B),wt(O,$),wt(O,C),a[6](C),J||(V=Nn(B,"click",a[3]),J=!0)},p:$t,i:$t,o:$t,d(et){et&&Ke(f),a[4](null),a[5](null),a[6](null),J=!1,V()}}}function l1(a,f,y){const A=Zn.FaceMesh||window.FaceMesh,w=Qn.Camera||window.Camera;let L,O,B,$,C,J,V,et;Gn(()=>{et=document.getElementById("canvas-root"),et._data||(et._data={image:null}),B=O.getContext("2d"),J=document.createElement("canvas"),V=J.getContext("2d"),J.width=O.width,J.height=O.height;const m=new A({locateFile:Ot=>`https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/${Ot}`});m.setOptions({maxNumFaces:1,refineLandmarks:!0,minDetectionConfidence:.5,minTrackingConfidence:.5}),m.onResults(ct),new w(L,{onFrame:async()=>{await m.send({image:L})},width:720,height:720}).start()});function H(m,Q,Ot,bt="lime",ut=4,ot=!1){m.save(),m.beginPath(),m.strokeStyle=bt,m.fillStyle=bt,m.lineWidth=ut;for(const[Y,s]of Ot.entries()){const l=Q[s];Y===0?m.moveTo(l.x*O.width,l.y*O.height):m.lineTo(l.x*O.width,l.y*O.height)}ot?(m.closePath(),m.fill()):m.stroke(),m.restore()}function ct(m){if(B.save(),B.clearRect(0,0,O.width,O.height),B.drawImage(m.image,0,0,O.width,O.height),V.clearRect(0,0,J.width,J.height),m.multiFaceLandmarks)for(const Q of m.multiFaceLandmarks)H(V,Q,t1,"magenta",8,!0),H(V,Q,qn,"magenta",8,!0),H(V,Q,e1,"yellow",8,!1),H(V,Q,n1,"yellow",8,!1),H(V,Q,i1,"cyan",8,!0),H(V,Q,r1,"blue",8,!0),H(V,Q,o1,"orange",8,!1),H(V,Q,s1,"orange",8,!1),H(V,Q,a1,"lime",8,!1);B.drawImage(J,0,0,O.width,O.height)}function at(){C=$.getContext("2d"),C.fillStyle="black",C.fillRect(0,0,$.width,$.height),C.drawImage(J,0,0,$.width,$.height),et._data.image=$.toDataURL()}function kt(m){Jt[m?"unshift":"push"](()=>{L=m,y(0,L)})}function jt(m){Jt[m?"unshift":"push"](()=>{O=m,y(1,O)})}function At(m){Jt[m?"unshift":"push"](()=>{$=m,y(2,$)})}return[L,O,$,at,kt,jt,At]}class f1 extends Kn{constructor(f){super(),Jn(this,f,l1,c1,Tn,{},u1)}}class h1 extends HTMLElement{constructor(){super()}connectedCallback(){const f=this.attachShadow({mode:"open"}),y=document.createElement("style");y.appendChild(document.createTextNode(Sn)),f.appendChild(y),new f1({target:f})}}customElements.define("face-canvas",h1);