interview-widget 3.2.3 → 3.2.4

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/widget.es.js CHANGED
@@ -5182,7 +5182,7 @@ class Al {
5182
5182
  }), this.mediaRecorder.addEventListener("dataavailable", (o) => {
5183
5183
  var s, a, l;
5184
5184
  if (o.data.size > 0) {
5185
- if (console.log(`[STTService] New chunk: ${(o.data.size / 1024).toFixed(2)} KB`), this.audioChunksTotalSize + o.data.size > p2) {
5185
+ if (this.audioChunksTotalSize + o.data.size > p2) {
5186
5186
  console.error(`[STTService] Max size exceeded: ${(this.audioChunksTotalSize / 1024 / 1024).toFixed(2)} MB`);
5187
5187
  const u = new q(
5188
5188
  "Recording exceeded maximum size limit",
@@ -5192,7 +5192,7 @@ class Al {
5192
5192
  (s = i == null ? void 0 : i.onError) == null || s.call(i, u), this.isRecording() && ((a = this.mediaRecorder) == null || a.stop());
5193
5193
  return;
5194
5194
  }
5195
- this.audioChunks.push(o.data), this.audioChunksTotalSize += o.data.size, console.log(`[STTService] Total size: ${(this.audioChunksTotalSize / 1024 / 1024).toFixed(2)} MB (${this.audioChunks.length} chunks)`), (l = i == null ? void 0 : i.onDataAvailable) == null || l.call(i, o.data);
5195
+ this.audioChunks.push(o.data), this.audioChunksTotalSize += o.data.size, (l = i == null ? void 0 : i.onDataAvailable) == null || l.call(i, o.data);
5196
5196
  }
5197
5197
  }), this.mediaRecorder.addEventListener(
5198
5198
  "stop",
@@ -12,7 +12,7 @@
12
12
  void main(void) {
13
13
  gl_Position = vec4(aVertex, 0.0, 1.0);
14
14
  vTex = aTex;
15
- }`,e.VERTEX_SHADER),this.W=Mc(this,this.H(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.O=e.getAttribLocation(this.h,"aVertex"),this.L=e.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){const e=this.g;e.deleteProgram(this.h),e.deleteShader(this.X),e.deleteShader(this.W)}this.B&&this.g.deleteFramebuffer(this.B),this.A&&this.A.close(),this.u&&this.u.close()}};function yt(e,t){switch(t){case 0:return e.g.find(r=>r instanceof Uint8Array);case 1:return e.g.find(r=>r instanceof Float32Array);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function ks(e){var t=yt(e,1);if(!t){if(t=yt(e,0))t=new Float32Array(t).map(i=>i/255);else{t=new Float32Array(e.width*e.height);const i=Tr(e);var r=Ss(e);if(Oc(r,i,Uc(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(e.width*e.height*4),i.readPixels(0,0,e.width,e.height,i.RGBA,i.FLOAT,r);for(let n=0,s=0;n<t.length;++n,s+=4)t[n]=r[s]}else i.readPixels(0,0,e.width,e.height,i.RED,i.FLOAT,t)}e.g.push(t)}return t}function Uc(e){let t=yt(e,2);if(!t){const r=Tr(e);t=Gc(e);const i=ks(e),n=Vc(e);r.texImage2D(r.TEXTURE_2D,0,n,e.width,e.height,0,r.RED,r.FLOAT,i),Ts(e)}return t}function Tr(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return e.h||(e.h=It(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Vc(e){if(e=Tr(e),!Xi)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Xi=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Xi=e.R16F}return Xi}function Ss(e){return e.l||(e.l=new Bc),e.l}function Gc(e){const t=Tr(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=yt(e,2);return r||(r=Pc(Ss(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Ts(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Xi,pe=class{constructor(e,t,r,i,n,s,a){this.g=e,this.m=t,this.j=r,this.canvas=i,this.l=n,this.width=s,this.height=a,this.j&&--jc===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Fa(){return!!yt(this,0)}ka(){return!!yt(this,1)}R(){return!!yt(this,2)}ja(){return(t=yt(e=this,0))||(t=ks(e),t=new Uint8Array(t.map(r=>Math.round(255*r))),e.g.push(t)),t;var e,t}ia(){return ks(this)}N(){return Uc(this)}clone(){const e=[];for(const t of this.g){let r;if(t instanceof Uint8Array)r=new Uint8Array(t);else if(t instanceof Float32Array)r=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{const i=Tr(this),n=Ss(this);i.activeTexture(i.TEXTURE1),r=Pc(n,i,this.m?i.LINEAR:i.NEAREST),i.bindTexture(i.TEXTURE_2D,r);const s=Vc(this);i.texImage2D(i.TEXTURE_2D,0,s,this.width,this.height,0,i.RED,i.FLOAT,null),i.bindTexture(i.TEXTURE_2D,null),Oc(n,i,r),Vu(n,i,!1,()=>{Gc(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),Ts(this)}),Gu(n),Ts(this)}}e.push(r)}return new pe(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Tr(this).deleteTexture(yt(this,2)),jc=-1}};pe.prototype.close=pe.prototype.close,pe.prototype.clone=pe.prototype.clone,pe.prototype.getAsWebGLTexture=pe.prototype.N,pe.prototype.getAsFloat32Array=pe.prototype.ia,pe.prototype.getAsUint8Array=pe.prototype.ja,pe.prototype.hasWebGLTexture=pe.prototype.R,pe.prototype.hasFloat32Array=pe.prototype.ka,pe.prototype.hasUint8Array=pe.prototype.Fa;var jc=250;function Je(...e){return e.map(([t,r])=>({start:t,end:r}))}const ju=function(e){return class extends e{Ja(){this.i._registerModelResourcesGraphService()}}}((zc=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:Cc()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){const t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){const r=e.length,i=this.i._malloc(r);this.i.HEAPU8.set(e,i),t?this.i._changeBinaryGraph(r,i):this.i._changeTextGraph(r,i),this.i._free(i)}configureAudio(e,t,r,i,n){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),S(this,i||"input_audio",s=>{S(this,n=n||"audio_header",a=>{this.i._configureAudio(s,a,e,t??0,r)})})}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ca(e){lt(this,"__graph_config__",t=>{e(t)}),S(this,"__graph_config__",t=>{this.i._getGraphConfig(t,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,i,n){const s=4*e.length;this.h!==s&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(s),this.h=s),this.i.HEAPF32.set(e,this.g/4),S(this,i,a=>{this.i._addAudioToInputStream(this.g,t,r,a,n)})}addGpuBufferToStream(e,t,r){S(this,t,i=>{const[n,s]=Ic(this,e,i);this.i._addBoundTextureToStream(i,n,s,r)})}addBoolToStream(e,t,r){S(this,t,i=>{this.i._addBoolToInputStream(e,i,r)})}addDoubleToStream(e,t,r){S(this,t,i=>{this.i._addDoubleToInputStream(e,i,r)})}addFloatToStream(e,t,r){S(this,t,i=>{this.i._addFloatToInputStream(e,i,r)})}addIntToStream(e,t,r){S(this,t,i=>{this.i._addIntToInputStream(e,i,r)})}addUintToStream(e,t,r){S(this,t,i=>{this.i._addUintToInputStream(e,i,r)})}addStringToStream(e,t,r){S(this,t,i=>{S(this,e,n=>{this.i._addStringToInputStream(n,i,r)})})}addStringRecordToStream(e,t,r){S(this,t,i=>{Fc(this,Object.keys(e),n=>{Fc(this,Object.values(e),s=>{this.i._addFlatHashMapToInputStream(n,s,Object.keys(e).length,i,r)})})})}addProtoToStream(e,t,r,i){S(this,r,n=>{S(this,t,s=>{const a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,s,n,i),this.i._free(a)})})}addEmptyPacketToStream(e,t){S(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const s of e)this.i._addBoolVectorEntry(n,s);this.i._addBoolVectorToInputStream(n,i,r)})}addDoubleVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const s of e)this.i._addDoubleVectorEntry(n,s);this.i._addDoubleVectorToInputStream(n,i,r)})}addFloatVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const s of e)this.i._addFloatVectorEntry(n,s);this.i._addFloatVectorToInputStream(n,i,r)})}addIntVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const s of e)this.i._addIntVectorEntry(n,s);this.i._addIntVectorToInputStream(n,i,r)})}addUintVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const s of e)this.i._addUintVectorEntry(n,s);this.i._addUintVectorToInputStream(n,i,r)})}addStringVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const s of e)S(this,s,a=>{this.i._addStringVectorEntry(n,a)});this.i._addStringVectorToInputStream(n,i,r)})}addBoolToInputSidePacket(e,t){S(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){S(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){S(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){S(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){S(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){S(this,t,r=>{S(this,e,i=>{this.i._addStringToInputSidePacket(i,r)})})}addProtoToInputSidePacket(e,t,r){S(this,r,i=>{S(this,t,n=>{const s=this.i._malloc(e.length);this.i.HEAPU8.set(e,s),this.i._addProtoToInputSidePacket(s,e.length,n,i),this.i._free(s)})})}addBoolVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(const n of e)this.i._addBoolVectorEntry(i,n);this.i._addBoolVectorToInputSidePacket(i,r)})}addDoubleVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(const n of e)this.i._addDoubleVectorEntry(i,n);this.i._addDoubleVectorToInputSidePacket(i,r)})}addFloatVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(const n of e)this.i._addFloatVectorEntry(i,n);this.i._addFloatVectorToInputSidePacket(i,r)})}addIntVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(const n of e)this.i._addIntVectorEntry(i,n);this.i._addIntVectorToInputSidePacket(i,r)})}addUintVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(const n of e)this.i._addUintVectorEntry(i,n);this.i._addUintVectorToInputSidePacket(i,r)})}addStringVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(const n of e)S(this,n,s=>{this.i._addStringVectorEntry(i,s)});this.i._addStringVectorToInputSidePacket(i,r)})}attachBoolListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){lt(this,e,t),S(this,e,i=>{this.i._attachProtoListener(i,r||!1)})}attachProtoVectorListener(e,t,r){Nt(this,e,t),S(this,e,i=>{this.i._attachProtoVectorListener(i,r||!1)})}attachAudioListener(e,t,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),lt(this,e,(i,n)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,n)}),S(this,e,i=>{this.i._attachAudioListener(i,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends zc{get ga(){return this.i}pa(e,t,r){S(this,t,i=>{const[n,s]=Ic(this,e,i);this.ga._addBoundTextureAsImageToStream(i,n,s,r)})}Z(e,t){lt(this,e,t),S(this,e,r=>{this.ga._attachImageListener(r)})}aa(e,t){Nt(this,e,t),S(this,e,r=>{this.ga._attachImageVectorListener(r)})}}));var zc,Ze=class extends ju{};async function O(e,t,r){return async function(i,n,s,a){return Bu(i,n,s,a)}(e,r.canvas??(Cc()?void 0:document.createElement("canvas")),t,r)}function $c(e,t,r,i){if(e.U){const s=new Ya;if(r!=null&&r.regionOfInterest){if(!e.oa)throw Error("This task doesn't support region-of-interest.");var n=r.regionOfInterest;if(n.left>=n.right||n.top>=n.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(n.left<0||n.top<0||n.right>1||n.bottom>1)throw Error("Expected RectF values to be in [0,1].");C(s,1,(n.left+n.right)/2),C(s,2,(n.top+n.bottom)/2),C(s,4,n.right-n.left),C(s,3,n.bottom-n.top)}else C(s,1,.5),C(s,2,.5),C(s,4,1),C(s,3,1);if(r!=null&&r.rotationDegrees){if((r==null?void 0:r.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90°.");if(C(s,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[a,c]=Nc(t);r=ie(s,3)*c/a,n=ie(s,4)*a/c,C(s,4,r),C(s,3,n)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,i)}e.g.pa(t,e.X,i??performance.now()),e.finishProcessing()}function Re(e,t,r){var i;if((i=e.baseOptions)!=null&&i.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");$c(e,t,r,e.C+1)}function dt(e,t,r,i){var n;if(!((n=e.baseOptions)!=null&&n.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");$c(e,t,r,i)}function Cr(e,t,r,i){var n=t.data;const s=t.width,a=s*(t=t.height);if((n instanceof Uint8Array||n instanceof Float32Array)&&n.length!==a)throw Error("Unsupported channel count: "+n.length/a);return e=new pe([n],r,!1,e.g.i.canvas,e.P,s,t),i?e.clone():e}var Be=class extends Es{constructor(e,t,r,i){super(e),this.g=e,this.X=t,this.U=r,this.oa=i,this.P=new Bc}l(e,t=!0){if("runningMode"in e&&$(this.baseOptions,2,Kr(!!e.runningMode&&e.runningMode!=="IMAGE")),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Be.prototype.close=Be.prototype.close;var He=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},I(e=this.h=new Wi,0,1,t=new re),C(this.h,2,.5),C(this.h,3,.3)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&C(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&C(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},Re(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},dt(this,e,r,t),this.j}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect_in"),j(e,"detections");const t=new Pe;at(t,Eu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect_in"),P(r,"DETECTIONS:detections"),r.o(t),We(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Ha(s),this.j.detections.push(_c(i));x(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};He.prototype.detectForVideo=He.prototype.G,He.prototype.detect=He.prototype.F,He.prototype.setOptions=He.prototype.o,He.createFromModelPath=async function(e,t){return O(He,e,{baseOptions:{modelAssetPath:t}})},He.createFromModelBuffer=function(e,t){return O(He,e,{baseOptions:{modelAssetBuffer:t}})},He.createFromOptions=function(e,t){return O(He,e,t)};var Cs=Je([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]),As=Je([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]),Ns=Je([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Wc=Je([474,475],[475,476],[476,477],[477,474]),Is=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]),Fs=Je([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Hc=Je([469,470],[470,471],[471,472],[472,469]),Ls=Je([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]),qc=[...Cs,...As,...Ns,...Is,...Fs,...Ls],Kc=Je([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function Yc(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var te=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,I(e=this.h=new rc,0,1,t=new re),this.A=new tc,I(this.h,0,3,this.A),this.u=new Wi,I(this.h,0,2,this.u),pt(this.u,4,1),C(this.u,2,.5),C(this.A,2,.5),C(this.h,4,.5)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"numFaces"in e&&pt(this.u,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&C(this.u,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&C(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&C(this.A,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}F(e,t){return Yc(this),Re(this,e,t),this.j}G(e,t,r){return Yc(this),dt(this,e,r,t),this.j}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"face_landmarks");const t=new Pe;at(t,ku,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),We(e,r),this.g.attachProtoVectorListener("face_landmarks",(i,n)=>{for(const s of i)i=ti(s),this.j.faceLandmarks.push(Hi(i));x(this,n)}),this.g.attachEmptyPacketListener("face_landmarks",i=>{x(this,i)}),this.outputFaceBlendshapes&&(j(e,"blendshapes"),P(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(i,n)=>{if(this.outputFaceBlendshapes)for(const s of i)i=ji(s),this.j.faceBlendshapes.push(vs(i.g()??[]));x(this,n)}),this.g.attachEmptyPacketListener("blendshapes",i=>{x(this,i)})),this.outputFacialTransformationMatrixes&&(j(e,"face_geometry"),P(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(i,n)=>{if(this.outputFacialTransformationMatrixes)for(const s of i)(i=V(i=_u(s),wu,2))&&this.j.facialTransformationMatrixes.push({rows:ze(i,1)??0??0,columns:ze(i,2)??0??0,data:$t(i,3,st,zt()).slice()??[]});x(this,n)}),this.g.attachEmptyPacketListener("face_geometry",i=>{x(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};te.prototype.detectForVideo=te.prototype.G,te.prototype.detect=te.prototype.F,te.prototype.setOptions=te.prototype.o,te.createFromModelPath=function(e,t){return O(te,e,{baseOptions:{modelAssetPath:t}})},te.createFromModelBuffer=function(e,t){return O(te,e,{baseOptions:{modelAssetBuffer:t}})},te.createFromOptions=function(e,t){return O(te,e,t)},te.FACE_LANDMARKS_LIPS=Cs,te.FACE_LANDMARKS_LEFT_EYE=As,te.FACE_LANDMARKS_LEFT_EYEBROW=Ns,te.FACE_LANDMARKS_LEFT_IRIS=Wc,te.FACE_LANDMARKS_RIGHT_EYE=Is,te.FACE_LANDMARKS_RIGHT_EYEBROW=Fs,te.FACE_LANDMARKS_RIGHT_IRIS=Hc,te.FACE_LANDMARKS_FACE_OVAL=Ls,te.FACE_LANDMARKS_CONTOURS=qc,te.FACE_LANDMARKS_TESSELATION=Kc;var Ms=Je([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function Xc(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Qc(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function Jc(e,t=!0){const r=[];for(const n of e){var i=ji(n);e=[];for(const s of i.g())i=t&&ze(s,1)!=null?ze(s,1)??0:-1,e.push({score:ie(s,2)??0,index:i,categoryName:ye(K(s,3))??""??"",displayName:ye(K(s,4))??""??""});r.push(e)}return r}var Ue=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],I(e=this.j=new sc,0,1,t=new re),this.u=new hs,I(this.j,0,2,this.u),this.D=new us,I(this.u,0,3,this.D),this.A=new nc,I(this.u,0,2,this.A),this.h=new Su,I(this.j,0,3,this.h),C(this.A,2,.5),C(this.u,4,.5),C(this.D,2,.5)}get baseOptions(){return V(this.j,re,1)}set baseOptions(e){I(this.j,0,1,e)}o(e){var n,s,a,c;if(pt(this.A,3,e.numHands??1),"minHandDetectionConfidence"in e&&C(this.A,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&C(this.u,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&C(this.D,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new kr,r=t,i=bs(e.cannedGesturesClassifierOptions,(n=V(this.h,kr,3))==null?void 0:n.l());I(r,0,2,i),I(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&((s=V(this.h,kr,3))==null||s.g());return e.customGesturesClassifierOptions?(I(r=t=new kr,0,2,i=bs(e.customGesturesClassifierOptions,(a=V(this.h,kr,4))==null?void 0:a.l())),I(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&((c=V(this.h,kr,4))==null||c.g()),this.l(e)}Ha(e,t){return Xc(this),Re(this,e,t),Qc(this)}Ia(e,t,r){return Xc(this),dt(this,e,r,t),Qc(this)}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"hand_gestures"),j(e,"hand_landmarks"),j(e,"world_hand_landmarks"),j(e,"handedness");const t=new Pe;at(t,Tu,this.j);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"HAND_GESTURES:hand_gestures"),P(r,"LANDMARKS:hand_landmarks"),P(r,"WORLD_LANDMARKS:world_hand_landmarks"),P(r,"HANDEDNESS:handedness"),r.o(t),We(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i){i=ti(s);const a=[];for(const c of gt(i,Ka,1))a.push({x:ie(c,1)??0,y:ie(c,2)??0,z:ie(c,3)??0,visibility:ie(c,4)??0});this.landmarks.push(a)}x(this,n)}),this.g.attachEmptyPacketListener("hand_landmarks",i=>{x(this,i)}),this.g.attachProtoVectorListener("world_hand_landmarks",(i,n)=>{for(const s of i){i=_r(s);const a=[];for(const c of gt(i,qa,1))a.push({x:ie(c,1)??0,y:ie(c,2)??0,z:ie(c,3)??0,visibility:ie(c,4)??0});this.worldLandmarks.push(a)}x(this,n)}),this.g.attachEmptyPacketListener("world_hand_landmarks",i=>{x(this,i)}),this.g.attachProtoVectorListener("hand_gestures",(i,n)=>{this.gestures.push(...Jc(i,!1)),x(this,n)}),this.g.attachEmptyPacketListener("hand_gestures",i=>{x(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{this.handedness.push(...Jc(i)),x(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Zc(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Ue.prototype.recognizeForVideo=Ue.prototype.Ia,Ue.prototype.recognize=Ue.prototype.Ha,Ue.prototype.setOptions=Ue.prototype.o,Ue.createFromModelPath=function(e,t){return O(Ue,e,{baseOptions:{modelAssetPath:t}})},Ue.createFromModelBuffer=function(e,t){return O(Ue,e,{baseOptions:{modelAssetBuffer:t}})},Ue.createFromOptions=function(e,t){return O(Ue,e,t)},Ue.HAND_CONNECTIONS=Ms;var Ve=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],I(e=this.h=new hs,0,1,t=new re),this.u=new us,I(this.h,0,3,this.u),this.j=new nc,I(this.h,0,2,this.j),pt(this.j,3,1),C(this.j,2,.5),C(this.u,2,.5),C(this.h,4,.5)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"numHands"in e&&pt(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&C(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&C(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&C(this.u,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Re(this,e,t),Zc(this)}G(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],dt(this,e,r,t),Zc(this)}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"hand_landmarks"),j(e,"world_hand_landmarks"),j(e,"handedness");const t=new Pe;at(t,Cu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"LANDMARKS:hand_landmarks"),P(r,"WORLD_LANDMARKS:world_hand_landmarks"),P(r,"HANDEDNESS:handedness"),r.o(t),We(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i)i=ti(s),this.landmarks.push(Hi(i));x(this,n)}),this.g.attachEmptyPacketListener("hand_landmarks",i=>{x(this,i)}),this.g.attachProtoVectorListener("world_hand_landmarks",(i,n)=>{for(const s of i)i=_r(s),this.worldLandmarks.push(ri(i));x(this,n)}),this.g.attachEmptyPacketListener("world_hand_landmarks",i=>{x(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{var s=this.handedness,a=s.push;const c=[];for(const l of i){i=ji(l);const h=[];for(const u of i.g())h.push({score:ie(u,2)??0,index:ze(u,1)??0??-1,categoryName:ye(K(u,3))??""??"",displayName:ye(K(u,4))??""??""});c.push(h)}a.call(s,...c),x(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ve.prototype.detectForVideo=Ve.prototype.G,Ve.prototype.detect=Ve.prototype.F,Ve.prototype.setOptions=Ve.prototype.o,Ve.createFromModelPath=function(e,t){return O(Ve,e,{baseOptions:{modelAssetPath:t}})},Ve.createFromModelBuffer=function(e,t){return O(Ve,e,{baseOptions:{modelAssetBuffer:t}})},Ve.createFromOptions=function(e,t){return O(Ve,e,t)},Ve.HAND_CONNECTIONS=Ms;var Rc=Je([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function el(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function tl(e){try{if(!e.D)return e.h;e.D(e.h)}finally{Yi(e)}}function Qi(e,t){e=ti(e),t.push(Hi(e))}var X=class extends Be{constructor(e,t){super(new Ze(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,I(e=this.j=new uc,0,1,t=new re),this.I=new us,I(this.j,0,2,this.I),this.W=new Au,I(this.j,0,3,this.W),this.u=new Wi,I(this.j,0,4,this.u),this.O=new tc,I(this.j,0,5,this.O),this.A=new lc,I(this.j,0,6,this.A),this.M=new dc,I(this.j,0,7,this.M),C(this.u,2,.5),C(this.u,3,.3),C(this.O,2,.5),C(this.A,2,.5),C(this.A,3,.3),C(this.M,2,.5),C(this.I,2,.5)}get baseOptions(){return V(this.j,re,1)}set baseOptions(e){I(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&C(this.u,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&C(this.u,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&C(this.O,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&C(this.A,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&C(this.A,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&C(this.M,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&C(this.I,2,e.minHandLandmarksConfidence??.5),this.l(e)}F(e,t,r){const i=typeof t!="function"?t:{};return this.D=typeof t=="function"?t:r,el(this),Re(this,e,i),tl(this)}G(e,t,r,i){const n=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:i,el(this),dt(this,e,n,t),tl(this)}m(){var e=new Oe;ee(e,"input_frames_image"),j(e,"pose_landmarks"),j(e,"pose_world_landmarks"),j(e,"face_landmarks"),j(e,"left_hand_landmarks"),j(e,"left_hand_world_landmarks"),j(e,"right_hand_landmarks"),j(e,"right_hand_world_landmarks");const t=new Pe,r=new Aa;Me(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(n,s){if(s!=null)if(Array.isArray(s))$(n,2,ki(s,0,Qr));else{if(!(typeof s=="string"||s instanceof it||mn(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");kt(n,2,xn(s,!1),Ot())}}(r,this.j.g());const i=new Ce;Me(i,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),zn(i,8,Aa,r),Y(i,"IMAGE:input_frames_image"),P(i,"POSE_LANDMARKS:pose_landmarks"),P(i,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),P(i,"FACE_LANDMARKS:face_landmarks"),P(i,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),P(i,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),P(i,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),P(i,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),i.o(t),We(e,i),Ki(this,e),this.g.attachProtoListener("pose_landmarks",(n,s)=>{Qi(n,this.h.poseLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("pose_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("pose_world_landmarks",(n,s)=>{var a=this.h.poseWorldLandmarks;n=_r(n),a.push(ri(n)),x(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",n=>{x(this,n)}),this.outputPoseSegmentationMasks&&(P(i,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Sr(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(n,s)=>{this.h.poseSegmentationMasks=[Cr(this,n,!0,!this.D)],x(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",n=>{this.h.poseSegmentationMasks=[],x(this,n)})),this.g.attachProtoListener("face_landmarks",(n,s)=>{Qi(n,this.h.faceLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{x(this,n)}),this.outputFaceBlendshapes&&(j(e,"extra_blendshapes"),P(i,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(n,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(n=ji(n),a.push(vs(n.g()??[]))),x(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",n=>{x(this,n)})),this.g.attachProtoListener("left_hand_landmarks",(n,s)=>{Qi(n,this.h.leftHandLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("left_hand_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("left_hand_world_landmarks",(n,s)=>{var a=this.h.leftHandWorldLandmarks;n=_r(n),a.push(ri(n)),x(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("right_hand_landmarks",(n,s)=>{Qi(n,this.h.rightHandLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("right_hand_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("right_hand_world_landmarks",(n,s)=>{var a=this.h.rightHandWorldLandmarks;n=_r(n),a.push(ri(n)),x(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",n=>{x(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};X.prototype.detectForVideo=X.prototype.G,X.prototype.detect=X.prototype.F,X.prototype.setOptions=X.prototype.o,X.createFromModelPath=function(e,t){return O(X,e,{baseOptions:{modelAssetPath:t}})},X.createFromModelBuffer=function(e,t){return O(X,e,{baseOptions:{modelAssetBuffer:t}})},X.createFromOptions=function(e,t){return O(X,e,t)},X.HAND_CONNECTIONS=Ms,X.POSE_CONNECTIONS=Rc,X.FACE_LANDMARKS_LIPS=Cs,X.FACE_LANDMARKS_LEFT_EYE=As,X.FACE_LANDMARKS_LEFT_EYEBROW=Ns,X.FACE_LANDMARKS_LEFT_IRIS=Wc,X.FACE_LANDMARKS_RIGHT_EYE=Is,X.FACE_LANDMARKS_RIGHT_EYEBROW=Fs,X.FACE_LANDMARKS_RIGHT_IRIS=Hc,X.FACE_LANDMARKS_FACE_OVAL=Ls,X.FACE_LANDMARKS_CONTOURS=qc,X.FACE_LANDMARKS_TESSELATION=Kc;var qe=class extends Be{constructor(e,t){super(new Ze(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},I(e=this.h=new hc,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return I(this.h,0,2,bs(e,V(this.h,cs,2))),this.l(e)}sa(e,t){return this.j={classifications:[]},Re(this,e,t),this.j}ta(e,t,r){return this.j={classifications:[]},dt(this,e,r,t),this.j}m(){var e=new Oe;ee(e,"input_image"),ee(e,"norm_rect"),j(e,"classifications");const t=new Pe;at(t,Nu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Y(r,"IMAGE:input_image"),Y(r,"NORM_RECT:norm_rect"),P(r,"CLASSIFICATIONS:classifications"),r.o(t),We(e,r),this.g.attachProtoListener("classifications",(i,n)=>{this.j=Pu(mu(i)),x(this,n)}),this.g.attachEmptyPacketListener("classifications",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};qe.prototype.classifyForVideo=qe.prototype.ta,qe.prototype.classify=qe.prototype.sa,qe.prototype.setOptions=qe.prototype.o,qe.createFromModelPath=function(e,t){return O(qe,e,{baseOptions:{modelAssetPath:t}})},qe.createFromModelBuffer=function(e,t){return O(qe,e,{baseOptions:{modelAssetBuffer:t}})},qe.createFromOptions=function(e,t){return O(qe,e,t)};var Ge=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!0),this.h=new fc,this.embeddings={embeddings:[]},I(e=this.h,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){var t=this.h,r=V(this.h,Za,2);return r=r?r.clone():new Za,e.l2Normalize!==void 0?$(r,1,Kr(e.l2Normalize)):"l2Normalize"in e&&$(r,1),e.quantize!==void 0?$(r,2,Kr(e.quantize)):"quantize"in e&&$(r,2),I(t,0,2,r),this.l(e)}za(e,t){return Re(this,e,t),this.embeddings}Aa(e,t,r){return dt(this,e,r,t),this.embeddings}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"embeddings_out");const t=new Pe;at(t,Iu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"EMBEDDINGS:embeddings_out"),r.o(t),We(e,r),this.g.attachProtoListener("embeddings_out",(i,n)=>{i=vu(i),this.embeddings=function(s){return{embeddings:gt(s,bu,1).map(a=>{var h,u;const c={headIndex:ze(a,3)??0??-1,headName:ye(K(a,4))??""??""};var l=a.v;return qo(l,0|l[_],Xa,Un(a,1))!==void 0?(a=$t(a=V(a,Xa,Un(a,1),void 0),1,st,zt()),c.floatEmbedding=a.slice()):(l=new Uint8Array(0),c.quantizedEmbedding=((u=(h=V(a,yu,Un(a,2),void 0))==null?void 0:h.na())==null?void 0:u.h())??l),c}),timestampMs:Ec(Xo(s))}}(i),x(this,n)}),this.g.attachEmptyPacketListener("embeddings_out",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ge.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Sc(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Sc(kc(e.quantizedEmbedding),kc(t.quantizedEmbedding))}return e},Ge.prototype.embedForVideo=Ge.prototype.Aa,Ge.prototype.embed=Ge.prototype.za,Ge.prototype.setOptions=Ge.prototype.o,Ge.createFromModelPath=function(e,t){return O(Ge,e,{baseOptions:{modelAssetPath:t}})},Ge.createFromModelBuffer=function(e,t){return O(Ge,e,{baseOptions:{modelAssetBuffer:t}})},Ge.createFromOptions=function(e,t){return O(Ge,e,t)};var Ds=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach(r=>{r.close()}),(t=this.categoryMask)==null||t.close()}};function zu(e){var r,i;const t=function(n){return gt(n,Ce,1)}(e.ca()).filter(n=>(ye(K(n,1))??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.u=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(((i=(r=V(t[0],Pe,7))==null?void 0:r.j())==null?void 0:i.g())??new Map).forEach((n,s)=>{e.u[Number(s)]=ye(K(n,1))??""})}function rl(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function il(e){try{const t=new Ds(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{Yi(e)}}Ds.prototype.close=Ds.prototype.close;var Ae=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ps,this.A=new wc,I(this.h,0,3,this.A),I(e=this.h,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?$(this.h,2,Xr(e.displayNamesLocale)):"displayNamesLocale"in e&&$(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}L(){zu(this)}segment(e,t,r){const i=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,rl(this),Re(this,e,i),il(this)}La(e,t,r,i){const n=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:i,rl(this),dt(this,e,n,t),il(this)}Da(){return this.u}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect");const t=new Pe;at(t,mc,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),r.o(t),We(e,r),Ki(this,e),this.outputConfidenceMasks&&(j(e,"confidence_masks"),P(r,"CONFIDENCE_MASKS:confidence_masks"),Sr(this,"confidence_masks"),this.g.aa("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Cr(this,s,!0,!this.j)),x(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],x(this,i)})),this.outputCategoryMask&&(j(e,"category_mask"),P(r,"CATEGORY_MASK:category_mask"),Sr(this,"category_mask"),this.g.Z("category_mask",(i,n)=>{this.categoryMask=Cr(this,i,!1,!this.j),x(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,x(this,i)})),j(e,"quality_scores"),P(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(i,n)=>{this.qualityScores=i,x(this,n)}),this.g.attachEmptyPacketListener("quality_scores",i=>{this.categoryMask=void 0,x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ae.prototype.getLabels=Ae.prototype.Da,Ae.prototype.segmentForVideo=Ae.prototype.La,Ae.prototype.segment=Ae.prototype.segment,Ae.prototype.setOptions=Ae.prototype.o,Ae.createFromModelPath=function(e,t){return O(Ae,e,{baseOptions:{modelAssetPath:t}})},Ae.createFromModelBuffer=function(e,t){return O(Ae,e,{baseOptions:{modelAssetBuffer:t}})},Ae.createFromOptions=function(e,t){return O(Ae,e,t)};var Ps=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach(r=>{r.close()}),(t=this.categoryMask)==null||t.close()}};Ps.prototype.close=Ps.prototype.close;var ut=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ps,this.u=new wc,I(this.h,0,3,this.u),I(e=this.h,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,r,i){const n=typeof r!="function"?r:{};if(this.j=typeof r=="function"?r:i,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.C+1,i=new bc,t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var s=new ms;kt(s,3,Kr(!0),!1),kt(s,1,qr(t.keypoint.x),0),kt(s,2,qr(t.keypoint.y),0),Jr(i,1,ys,s)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");{const c=new Lu;for(s of t.scribble)kt(t=new ms,3,Kr(!0),!1),kt(t,1,qr(s.x),0),kt(t,2,qr(s.y),0),zn(c,1,ms,t);Jr(i,2,ys,c)}}this.g.addProtoToStream(i.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),Re(this,e,n);e:{try{const c=new Ps(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var a=c;break e}this.j(c)}finally{Yi(this)}a=void 0}return a}m(){var e=new Oe;ee(e,"image_in"),ee(e,"roi_in"),ee(e,"norm_rect_in");const t=new Pe;at(t,mc,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),Y(r,"IMAGE:image_in"),Y(r,"ROI:roi_in"),Y(r,"NORM_RECT:norm_rect_in"),r.o(t),We(e,r),Ki(this,e),this.outputConfidenceMasks&&(j(e,"confidence_masks"),P(r,"CONFIDENCE_MASKS:confidence_masks"),Sr(this,"confidence_masks"),this.g.aa("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Cr(this,s,!0,!this.j)),x(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],x(this,i)})),this.outputCategoryMask&&(j(e,"category_mask"),P(r,"CATEGORY_MASK:category_mask"),Sr(this,"category_mask"),this.g.Z("category_mask",(i,n)=>{this.categoryMask=Cr(this,i,!1,!this.j),x(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,x(this,i)})),j(e,"quality_scores"),P(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(i,n)=>{this.qualityScores=i,x(this,n)}),this.g.attachEmptyPacketListener("quality_scores",i=>{this.categoryMask=void 0,x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ut.prototype.segment=ut.prototype.segment,ut.prototype.setOptions=ut.prototype.o,ut.createFromModelPath=function(e,t){return O(ut,e,{baseOptions:{modelAssetPath:t}})},ut.createFromModelBuffer=function(e,t){return O(ut,e,{baseOptions:{modelAssetBuffer:t}})},ut.createFromOptions=function(e,t){return O(ut,e,t)};var Ke=class extends Be{constructor(e,t){super(new Ze(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},I(e=this.h=new vc,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?$(this.h,2,Xr(e.displayNamesLocale)):"displayNamesLocale"in e&&$(this.h,2),e.maxResults!==void 0?pt(this.h,3,e.maxResults):"maxResults"in e&&$(this.h,3),e.scoreThreshold!==void 0?C(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&$(this.h,4),e.categoryAllowlist!==void 0?Si(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&$(this.h,5),e.categoryDenylist!==void 0?Si(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&$(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},Re(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},dt(this,e,r,t),this.j}m(){var e=new Oe;ee(e,"input_frame_gpu"),ee(e,"norm_rect"),j(e,"detections");const t=new Pe;at(t,Mu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),Y(r,"IMAGE:input_frame_gpu"),Y(r,"NORM_RECT:norm_rect"),P(r,"DETECTIONS:detections"),r.o(t),We(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Ha(s),this.j.detections.push(_c(i));x(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ke.prototype.detectForVideo=Ke.prototype.G,Ke.prototype.detect=Ke.prototype.F,Ke.prototype.setOptions=Ke.prototype.o,Ke.createFromModelPath=async function(e,t){return O(Ke,e,{baseOptions:{modelAssetPath:t}})},Ke.createFromModelBuffer=function(e,t){return O(Ke,e,{baseOptions:{modelAssetBuffer:t}})},Ke.createFromOptions=function(e,t){return O(Ke,e,t)};var Os=class{constructor(e,t,r){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=r}close(){var e;(e=this.segmentationMasks)==null||e.forEach(t=>{t.close()})}};function nl(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function sl(e){try{const t=new Os(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.u)return t;e.u(t)}finally{Yi(e)}}Os.prototype.close=Os.prototype.close;var je=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,I(e=this.h=new xc,0,1,t=new re),this.A=new dc,I(this.h,0,3,this.A),this.j=new lc,I(this.h,0,2,this.j),pt(this.j,4,1),C(this.j,2,.5),C(this.A,2,.5),C(this.h,4,.5)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"numPoses"in e&&pt(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&C(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&C(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&C(this.A,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}F(e,t,r){const i=typeof t!="function"?t:{};return this.u=typeof t=="function"?t:r,nl(this),Re(this,e,i),sl(this)}G(e,t,r,i){const n=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:i,nl(this),dt(this,e,n,t),sl(this)}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"normalized_landmarks"),j(e,"world_landmarks"),j(e,"segmentation_masks");const t=new Pe;at(t,Du,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"NORM_LANDMARKS:normalized_landmarks"),P(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),We(e,r),Ki(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(i,n)=>{this.landmarks=[];for(const s of i)i=ti(s),this.landmarks.push(Hi(i));x(this,n)}),this.g.attachEmptyPacketListener("normalized_landmarks",i=>{this.landmarks=[],x(this,i)}),this.g.attachProtoVectorListener("world_landmarks",(i,n)=>{this.worldLandmarks=[];for(const s of i)i=_r(s),this.worldLandmarks.push(ri(i));x(this,n)}),this.g.attachEmptyPacketListener("world_landmarks",i=>{this.worldLandmarks=[],x(this,i)}),this.outputSegmentationMasks&&(P(r,"SEGMENTATION_MASK:segmentation_masks"),Sr(this,"segmentation_masks"),this.g.aa("segmentation_masks",(i,n)=>{this.segmentationMasks=i.map(s=>Cr(this,s,!0,!this.u)),x(this,n)}),this.g.attachEmptyPacketListener("segmentation_masks",i=>{this.segmentationMasks=[],x(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};je.prototype.detectForVideo=je.prototype.G,je.prototype.detect=je.prototype.F,je.prototype.setOptions=je.prototype.o,je.createFromModelPath=function(e,t){return O(je,e,{baseOptions:{modelAssetPath:t}})},je.createFromModelBuffer=function(e,t){return O(je,e,{baseOptions:{modelAssetBuffer:t}})},je.createFromOptions=function(e,t){return O(je,e,t)},je.POSE_CONNECTIONS=Rc;const Ji="https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task",$u="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm",Wu=()=>{const e=d.useRef(null),[t,r]=d.useState(!1),[i,n]=d.useState("Initializing..."),[s,a]=d.useState(0),[c,l]=d.useState(!1);d.useEffect(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(w=>{console.log("ServiceWorker registered:",w)}).catch(w=>{console.log("ServiceWorker registration failed:",w)})},[]);const h=async()=>"caches"in window?await(await caches.open("mediapipe-models-v1")).match(Ji)!==void 0:!1,u=async()=>{try{const w=await fetch(Ji),g=w.headers.get("content-length"),p=g?parseInt(g,10):0;if(!w.body)throw new Error("No response body");const y=w.body.getReader();let m=0;const b=[];for(;;){const{done:v,value:F}=await y.read();if(v)break;if(b.push(F),m+=F.length,p){const A=Math.round(m/p*100);a(A),n(`Downloading model... ${A}%`)}}return"caches"in window&&await(await caches.open("mediapipe-models-v1")).put(Ji,new Response(new Blob(b),{headers:{"Content-Type":"application/octet-stream"}})),!0}catch(w){return console.error("Failed to preload model:",w),!1}};return d.useEffect(()=>{(async()=>{try{n("Checking cached models..."),await h()?n("Using cached model..."):(n("Model not cached. Downloading..."),await u()),n("Loading MediaPipe WASM...");const p=await Xt.forVisionTasks($u);n("Creating face landmarker...");const y=await te.createFromOptions(p,{baseOptions:{modelAssetPath:Ji,delegate:"GPU"},runningMode:"VIDEO",outputFaceBlendshapes:!0,numFaces:2});e.current=y,r(!0),n("Model loaded successfully ✅")}catch(g){console.error("Model init error:",g),n(`Error: ${g==null?void 0:g.message}`),(g==null?void 0:g.name)==="NotAllowedError"&&l(!0)}})()},[]),{faceLandmarkerRef:e,isModelLoaded:t,statusMessage:i,setStatusMessage:n,loadingProgress:s,permissionDenied:c,clearCache:async()=>{"caches"in window&&(await caches.delete("mediapipe-models-v1"),n("Cache cleared. Please refresh to re-download models."))}}},Hu=()=>{const[e,t]=d.useState(0),r=d.useRef({lastTime:0,frames:0,fps:0}),i=d.useCallback(()=>{const n=performance.now(),s=r.current;if(s.frames++,n-s.lastTime>=1e3){const a=Math.round(s.frames*1e3/(n-s.lastTime));t(a),s.frames=0,s.lastTime=n}},[]);return{fps:e,updateFPS:i}},qu=()=>{const e=d.useRef({value:100,isLookingAway:!1}),t=d.useCallback((s,a,c,l)=>{if(!s||!c||!a)return;const h=s.getContext("2d");if(!h)return;const{width:u,height:f}=s;if(h.clearRect(0,0,u,f),h.drawImage(a,0,0,u,f),l){h.fillStyle="#00FF00";for(const w of c)h.fillRect(w.x*u-.5,w.y*f-.5,1,1)}},[]),r=d.useCallback(s=>{const a=e.current.value/100,c=100,l=20,h=20,u=40;s.fillStyle="rgba(0, 0, 0, 0.3)",s.fillRect(h,u,l,c),s.fillStyle=`rgba(${Math.floor(255*(1-a))}, ${Math.floor(255*a)}, 0, 0.8)`;const f=c*a;s.fillRect(h,u+c-f,l,f),s.fillStyle="#FFFFFF",s.fillRect(h,u+c*(1-a),l,2)},[]),i=d.useCallback((s,a,c,l,h,u,f)=>{if(t(s,a,c,l),h&&u&&f){const w=s.getContext("2d");w&&r(w)}},[t,r]),n=d.useCallback((s,a)=>{const c=s.getContext("2d");c&&(c.clearRect(0,0,s.width,s.height),c.drawImage(a,0,0,s.width,s.height))},[]);return{drawLandmarks:t,drawEngagementBar:r,drawWithEngagementBar:i,clearCanvas:n,engagementRef:e}},Ku=50,Yu=()=>{const[e,t]=d.useState(100),[r,i]=d.useState(!1),n=d.useRef(0),s=d.useCallback((a,c,l)=>{if(!l||a.length<468)return;const h=a[33],u=a[263],f=a[1];if(!h||!u||!f)return;const w=(h.x+u.x)*.5,g=(h.y+u.y)*.5,p=w-c.x,y=g-c.y,m=Math.sqrt(p*p+y*y),b=Math.abs(f.y-c.noseY)*100,v=Math.abs(f.x-c.noseX)*100,F=Math.max(0,100-(m*200+b+v)),A=F<Ku,E=performance.now();return E-n.current>100&&(t(F),i(A),n.current=E),{engagement:F,isLookingAway:A}},[]);return{engagement:e,isLookingAway:r,analyzeGaze:s,setEngagement:t,setIsLookingAway:i}},Xu=.05,Qu=()=>{const[e,t]=d.useState(!1),[r,i]=d.useState(!1),n=d.useCallback((c,l)=>Math.sqrt(Math.pow(c.x-l.x,2)+Math.pow(c.y-l.y,2)),[]),s=d.useCallback((c,l)=>{if(!c||!l)return 0;const h=[1,33,263,61,291,10,152];let u=0,f=0;const w=l[33],g=l[263],p=c[33],y=c[263];if(!w||!g||!p||!y)return 0;const m=n(w,g),b=n(p,y);if(m===0||b===0)return 0;for(const F of h){const A=l[F],E=c[F];if(A&&E){const T=w.x+(E.x-p.x)*m/b,M=w.y+(E.y-p.y)*m/b;u+=n(A,{x:T,y:M}),f++}}return f===0?0:u/f},[n]),a=d.useCallback((c,l,h,u)=>{if(!c.faceLandmarks||c.faceLandmarks.length===0)return u("Face not detected."),i(!0),t(!1),null;if(l&&h){let f=null,w=0;for(const g of c.faceLandmarks)s(g,h)<Xu&&(f=g,w++);return w===1?(t(!1),i(!1),u("Reference face tracked."),f):w>1?(t(!0),i(!1),u("Multiple matching faces detected. Tracking suspended."),null):(t(!1),i(!0),u("Reference face not detected."),null)}else{const f=c.faceLandmarks[0];if(c.faceLandmarks.length>1)return t(!0),i(!1),u("Multiple faces detected. Please ensure only you are visible."),null;if(!f)return i(!0),t(!1),u("Face not detected."),null;const g=f[1],p=f[33],y=f[263];return g&&p&&y&&g.x>.35&&g.x<.65&&g.y>.3&&g.y<.7&&p.x>.2&&p.x<.8&&y.x>.2&&y.x<.8?(i(!1),t(!1),u("Face detected. Ready for calibration."),f):(i(!0),t(!1),u("Please position your face in the center."),null)}},[s]);return{multipleFacesDetected:e,referenceFaceNotDetected:r,analyzeFace:a,setMultipleFacesDetected:t,setReferenceFaceNotDetected:i}},Ju=500,Zu=(e,t)=>{const[r,i]=d.useState(!1),[n,s]=d.useState(Te.MODEL_LOADING),{incrementGazeViolation:a}=Ks(),{multipleFacesDetected:c,referenceFaceNotDetected:l,isLookingAway:h}=e;d.useEffect(()=>{let w;return(h||c||l)&&t?w=setTimeout(()=>{i(!0),h?(s("looking_away"),a("looking_away")):c?(s("multiple_faces"),a("multiple_faces")):l&&(s("no_face_detected"),a("no_face_detected"))},Ju):(i(!1),s("face_detected")),()=>{clearTimeout(w)}},[h,c,l,t,a]);const u=d.useCallback(()=>c?Te.MULTIPLE_FACES:l?"no_face_detected":h?Te.LOOKING_AWAY:n===Te.MODEL_LOADING?Te.MODEL_LOADING:Te.FACE_DETECTED,[c,l,h]),f=d.useCallback(()=>{i(!1),s("face_detected")},[]);return{showGazeWarningModal:r,faceDetectionState:n,getWarningType:u,closeWarningModal:f,setShowGazeWarningModal:i,setFaceDetectionState:s}};class W extends Error{constructor(t,r,i=!1){super(t),this.code=r,this.recoverable=i,this.name="STTError"}}const Ru=50*1024*1024;class ol{constructor(t={}){Se(this,"config");Se(this,"mediaRecorder",null);Se(this,"audioChunks",[]);Se(this,"audioChunksTotalSize",0);Se(this,"recordingStream",null);Se(this,"autoStopTimeoutId",null);Se(this,"disposed",!1);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...t}}updateConfig(t){this.throwIfDisposed(),this.config={...this.config,...t}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(t,r){var i;if(this.throwIfDisposed(),!this.isRecordingSupported())throw new W("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new W("Recording is already in progress","ALREADY_RECORDING",!0);try{this.recordingStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:44100}}),this.audioChunks=[],this.audioChunksTotalSize=0;const n=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:n}),this.mediaRecorder.addEventListener("dataavailable",s=>{var a,c,l;if(s.data.size>0){if(console.log(`[STTService] New chunk: ${(s.data.size/1024).toFixed(2)} KB`),this.audioChunksTotalSize+s.data.size>Ru){console.error(`[STTService] Max size exceeded: ${(this.audioChunksTotalSize/1024/1024).toFixed(2)} MB`);const h=new W("Recording exceeded maximum size limit","MAX_SIZE_EXCEEDED",!1);(a=r==null?void 0:r.onError)==null||a.call(r,h),this.isRecording()&&((c=this.mediaRecorder)==null||c.stop());return}this.audioChunks.push(s.data),this.audioChunksTotalSize+=s.data.size,console.log(`[STTService] Total size: ${(this.audioChunksTotalSize/1024/1024).toFixed(2)} MB (${this.audioChunks.length} chunks)`),(l=r==null?void 0:r.onDataAvailable)==null||l.call(r,s.data)}}),this.mediaRecorder.addEventListener("stop",()=>{var s;(s=r==null?void 0:r.onStop)==null||s.call(r)},{once:!0}),this.mediaRecorder.addEventListener("error",s=>{var c;const a=new W(`Recording failed: ${s.error}`,"RECORDING_ERROR",!0);(c=r==null?void 0:r.onError)==null||c.call(r,a),this.cleanup()}),this.mediaRecorder.start(100),(i=r==null?void 0:r.onStart)==null||i.call(r),t&&t>0&&(this.autoStopTimeoutId=setTimeout(()=>{console.log(`[STTService] Auto-stop triggered after ${t} seconds.`),this.isRecording()?this.stopRecording().catch(s=>{console.error("[STTService] Auto-stop recording failed:",s),s instanceof W&&(console.error("[STTService] Error Name:",s.name),console.error("[STTService] Error Code:",s.code))}):console.log("[STTService] Recording was already stopped before auto-stop timeout.")},t*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new W("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new W("No microphone found","NO_MICROPHONE",!1)}throw new W(`Failed to start recording: ${n instanceof Error?n.message:String(n)}`,"START_RECORDING_FAILED",!0)}}async stopRecording(){var t;if(this.throwIfDisposed(),console.log("[STTService] stopRecording called. Current state:",{hasMediaRecorder:!!this.mediaRecorder,recorderState:(t=this.mediaRecorder)==null?void 0:t.state,isRecording:this.isRecording(),autoStopTimeoutId:!!this.autoStopTimeoutId}),this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||!this.isRecording()){const r=this.mediaRecorder?`State is ${this.mediaRecorder.state}`:"MediaRecorder is null";throw console.warn(`[STTService] Cannot stop recording: ${r}`),new W("No active recording to stop","NO_ACTIVE_RECORDING",!1)}return new Promise((r,i)=>{if(!this.mediaRecorder){i(new W("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const n=this.mediaRecorder,s=()=>{try{const a=n.mimeType||"audio/webm",c=new Blob(this.audioChunks,{type:a}),l=(c.size/1024/1024).toFixed(2);console.log(`[STTService] Recording stopped. Created blob: ${l} MB, Type: ${a}`),this.cleanup(),r(c)}catch(a){this.cleanup(),i(new W(`Failed to create audio blob: ${a instanceof Error?a.message:String(a)}`,"BLOB_CREATION_FAILED",!1))}};n.addEventListener("stop",s,{once:!0}),n.stop()})}async transcribe(t){this.throwIfDisposed();const{audioBlob:r}=t;if(!r||r.size===0)throw new W("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const i=new FormData,n=new File([r],"recording.wav",{type:r.type||"audio/wav"});if(i.append("file",n),i.append("qna_id",this.config.qnaId||""),!this.config.interviewId)throw new W("Interview ID is missing from configuration","MISSING_INTERVIEW_ID",!1);const s=await vt(`${this.config.baseUrl}${Et.TRANSCRIBE_ANSWER(this.config.interviewId)}`,{method:"POST",headers:{accept:"application/json","X-STT-Provider":this.config.provider||"groq",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:i},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!s.ok){const c=await s.text();let l=`STT request failed: ${s.status} ${s.statusText}`;try{const h=JSON.parse(c);l=h.message||h.error||l}catch{l=c||l}throw new W(l,`HTTP_${s.status}`,s.status>=500)}return{transcript:(await s.json()).data.transcribed_text??""}}catch(i){throw i instanceof W?i:new W(`Transcription failed: ${i instanceof Error?i.message:String(i)}`,"TRANSCRIPTION_FAILED",!0)}}cancelRecording(){this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),this.mediaRecorder&&this.isRecording()&&this.mediaRecorder.stop(),this.cleanup()}isRecording(){return this.mediaRecorder!==null&&this.mediaRecorder.state==="recording"}dispose(){this.disposed||(this.cancelRecording(),this.disposed=!0)}isDisposed(){return this.disposed}getSupportedMimeType(){const t=["audio/webm","audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4","audio/wav"];for(const r of t)if(MediaRecorder.isTypeSupported(r))return r;return"audio/webm"}getRecordingStream(){return this.recordingStream}cleanup(){this.recordingStream&&(this.recordingStream.getTracks().forEach(t=>t.stop()),this.recordingStream=null),this.mediaRecorder=null,this.audioChunks=[],this.audioChunksTotalSize=0,this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}throwIfDisposed(){if(this.disposed)throw new W("STTService has been disposed and cannot be reused","SERVICE_DISPOSED",!1)}}const e2=new ol,t2=(e,t,r,i)=>{const n=d.useRef(null);return d.useEffect(()=>{if(!t)return;const s=async()=>{try{const l=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});e.current&&(e.current.srcObject=l,e.current.onloadeddata=()=>{r()})}catch(l){console.error("Camera access error:",l),i("Camera access failed")}},a=n.current,c=e.current;return s(),()=>{a&&cancelAnimationFrame(a),c!=null&&c.srcObject&&c.srcObject.getTracks().forEach(h=>h.stop())}},[t,r]),d.useEffect(()=>{const s=e2.getRecordingStream();if(s&&e.current){e.current.srcObject=s;const a=s.getVideoTracks(),c=s.getAudioTracks(),l=()=>{console.log("Media track ended - permission may have been revoked")};[...a,...c].forEach(h=>{h.addEventListener("ended",l)})}},[]),{animationFrameRef:n}},r2=(e,t,r,i,n,s,a,c,l,h,u,f,w,g,p)=>{const y=d.useRef(null),m=d.useCallback(()=>{const b=e.current,v=t.current,F=r.current;if(!b||b.readyState<2||!F||!v){y.current=requestAnimationFrame(m);return}i();try{const A=performance.now(),E=F.detectForVideo(b,A),T=n(E,l,h.current,g);T?(s(v,b,T,u,f,w,l),l&&w&&c(T,h.current,w)):a(v,b)}catch(A){console.error("Face detection error:",A)}y.current=requestAnimationFrame(m)},[e,t,r,i,n,s,a,c,l,h,u,f,w,g,p]);return{renderLoop:m,animationFrameRef:y}},i2=(e,t,r,i)=>{const{referenceSet:n,referenceRef:s,setReferenceData:a}=Ks(),c=d.useRef(s),l=d.useCallback(()=>{c.current=s},[s]),h=d.useCallback(()=>{var g;const f=e.current,w=t.current;if(console.log({faceLandmarker:f,video:w}),!(!f||!w))try{const p=performance.now(),y=f.detectForVideo(w,p);if((g=y.faceLandmarks)!=null&&g[0]){const m=y.faceLandmarks[0],b=m[33],v=m[263],F=m[1];b&&v&&F&&(c.current={x:(b.x+v.x)*.5,y:(b.y+v.y)*.5,noseX:F.x,noseY:F.y},a(!0,c.current),r("Reference set. Gaze tracking active."),console.log("Reference set. Gaze tracking active.",c.current),i&&i())}}catch(p){console.error("Set reference error:",p),r("Failed to set reference")}},[e,t,r,a,i]),u=d.useCallback(()=>{a(!1,{x:0,y:0,noseX:0,noseY:0}),r("Reference reset. Starting calibration...")},[a,r]);return{referenceSet:n,referenceRef:c,setReference:h,resetReference:u,syncReference:l}};function n2({onClose:e,warningType:t,isCheatingModalOpen:r=!1}){const i=eo[t],n=i.icon;return t==="face_detected"?null:o.jsx("div",{className:"iw-absolute iw-left-4 iw-right-4 md:iw-right-auto md:iw-w-[480px] iw-z-50 iw-animate-in iw-fade-in iw-slide-in-from-bottom-4 iw-duration-300 iw-transition-all",style:{bottom:r?"280px":"5rem"},children:o.jsxs("div",{className:"iw-relative iw-overflow-hidden iw-rounded-xl iw-border iw-border-dashed iw-border-[#5C6686] iw-bg-[#F1F5FE] iw-p-4 iw-shadow-2xl iw-backdrop-blur-sm",children:[o.jsx("button",{onClick:e,className:"iw-absolute iw-right-3 iw-top-3 iw-text-gray-400 iw-transition-colors iw-hover:iw-text-gray-600",children:o.jsx(fi,{className:"iw-h-5 iw-w-5"})}),o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-2",children:[o.jsx("div",{className:"iw-flex iw-size-8 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-full iw-border iw-border-[#5C6686]",children:o.jsx(n,{className:"iw-size-6 iw-text-[#5C6686]"})}),o.jsxs("div",{className:"iw-flex-1 iw-pt-0.5",children:[o.jsx("h2",{className:"iw-text-[20px] iw-font-semibold iw-leading-tight iw-text-[#062260] iw-pr-6",children:i.title}),o.jsx("p",{className:"iw-mt-1.5 iw-text-lg iw-text-[#5C6686]",children:i.subtitle}),i.description&&o.jsx("div",{className:"iw-mt-3 iw-border-t iw-border-dashed iw-border-[#5C6686] iw-pt-3",children:o.jsx("p",{className:"iw-text-[14px] iw-font-bold iw-text-[#062260]",children:i.description})})]})]})]})})}const s2=({status:e})=>{const t=eo[e];if(!t)return null;const r=e!=="face_detected";return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-gap-0.5",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2 iw-px-3 iw-py-1 iw-rounded-full iw-backdrop-blur-md iw-shadow-sm transition-colors duration-300 iw-text-white",children:[o.jsx("div",{className:`iw-flex iw-h-4 iw-w-4 iw-items-center iw-size-2.5 iw-justify-center iw-rounded-full iw-text-white ${e==="face_detected"?"iw-bg-[#22C55E]":e==="model_loading"?"iw-bg-[#062260]":"iw-bg-[#E94315]"}`,children:e==="face_detected"?o.jsx(hi,{}):e==="model_loading"?o.jsx("div",{className:"iw-animate-spin iw-border iw-border-white iw-border-t-transparent iw-rounded-full iw-w-2 iw-h-2"}):o.jsx(fi,{})}),o.jsx("span",{className:"iw-text-sm iw-font-medium",children:e==="face_detected"?"Face detected clearly":e==="camera_error"?"Camera not found":t.title})]}),r&&o.jsx("span",{className:"iw-text-white iw-text-center iw-text-xs iw-drop-shadow-sm iw-max-w-[400px] iw-px-3",children:e==="model_loading"?"Initializing Face models. Please wait...":e==="no_face_detected"?"Face not detected. Please position yourself clearly in the frame.":e==="multiple_faces"?"Multiple faces detected. Please ensure only you are visible.":"Please position your face correctly."})]})},al=d.forwardRef(({className:e="",interviewId:t="",interview_duration:r,showProctoringUI:i=!0,onSetReference:n,isAnswering:s,onProctoringStatusChange:a,showStatusOverlay:c=!1,cheatingWarningVisible:l=!1,isDeviceLoading:h=!1,videoAllowed:u=!0},f)=>{var El;const{authToken:w}=Qs(),g=w?jl(w):null,{borderRadius:p}=Zt(),y=p??18,{proctoring:m,capture_screenshots:b}=dn(),v=!!(m!=null&&m.gazeAnalysisEnabled),[F,A]=d.useState(!1),[E,T]=d.useState((m==null?void 0:m.showLandmarks)??!1),[M,N]=d.useState(i&&((m==null?void 0:m.showEngagementBar)??!0)),[L,z]=d.useState(v),[be,Q]=d.useState(!1),q=d.useRef(null),J=d.useRef(null),U=d.useRef(null),Z=d.useRef(null),et=d.useCallback(async xe=>{var nn;const ai=q.current,_e=U.current;if(!ai||!_e)return;const Pr=_e.getContext("2d");if(!Pr)return;_e.width=ai.videoWidth,_e.height=ai.videoHeight,Pr.save(),Pr.scale(-1,1),Pr.drawImage(ai,-_e.width,0,_e.width,_e.height),Pr.restore();const ci=await new Promise(Jt=>_e.toBlob(Jt,"image/jpeg"));if(ci&&t)try{const Jt=`${xe}-${Date.now()}.jpeg`,ke=await wi.requestScreenshotUploadUrl(t,Jt);ke.data&&ke.data.upload_url&&(await wi.uploadScreenshot((nn=ke==null?void 0:ke.data)==null?void 0:nn.upload_url,ci),ke.data.asset_id&&await wi.confirmScreenshotUpload(ke.data.asset_id))}catch(Jt){console.error(`Failed to upload screenshot for ${xe}:`,Jt)}},[wi,t]);d.useEffect(()=>{let xe;return s&&(Q(!0),xe=setTimeout(()=>Q(!1),1e3)),()=>{xe&&clearTimeout(xe)}},[s]);const{faceLandmarkerRef:bt,isModelLoaded:Ne,statusMessage:Ft,setStatusMessage:Ye,loadingProgress:Ar,permissionDenied:Lt,clearCache:Nr}=Wu(),{fps:Ir,updateFPS:ht}=Hu(),{drawWithEngagementBar:Mt,clearCanvas:le,engagementRef:tt}=qu(),{engagement:Fr,isLookingAway:Qt,analyzeGaze:js,setEngagement:en,setIsLookingAway:Lr}=Yu(),{multipleFacesDetected:ni,referenceFaceNotDetected:Mr,analyzeFace:zs,setMultipleFacesDetected:si,setReferenceFaceNotDetected:Dr}=Qu(),{referenceSet:oi,referenceRef:D,setReference:G,resetReference:Xe,syncReference:tn}=i2(bt,q,Ye,n),r1={multipleFacesDetected:ni,referenceFaceNotDetected:Mr,isLookingAway:Qt},{showGazeWarningModal:yl,getWarningType:rn,closeWarningModal:bl,setShowGazeWarningModal:vl,setFaceDetectionState:xl}=Zu(r1,v&&!c);d.useEffect(()=>{if(a){if(h||!Ne){a("model_loading");return}if(!u){a("camera_error");return}const xe=rn()||Te.NO_FACE;a(xe)}},[Ne,h,u,ni,Mr,Qt,rn,a]);const{renderLoop:i1}=r2(q,J,bt,ht,zs,Mt,le,js,oi,D,E,M,v,Ye,Dr);t2(q,Ne,i1,Ye),d.useEffect(()=>{tn()},[tn]),d.useEffect(()=>{tt&&tt.current&&(tt.current.value=Fr,tt.current.isLookingAway=Qt)},[Fr,Qt,tt]);const n1=d.useCallback(xe=>{z(xe),xe||(en(100),Lr(!1))},[en,Lr]),s1=d.useCallback(()=>{Lr(!1),si(!1),Dr(!1),xl("face_detected"),vl(!1),bl()},[Lr,si,Dr,xl,vl,bl]),o1={engagement:Fr,fps:Ir,isLookingAway:Qt,multipleFacesDetected:ni,referenceFaceNotDetected:Mr};return d.useEffect(()=>{if(!b)return;const xe=[];return(async()=>{try{const _e=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});Z.current=_e,q.current&&(q.current.srcObject=_e);const ci=(r??li)*60*1e3/3,nn=[0,1,2].map((ke,Dt)=>({label:`capture-${Dt+1}`,start:Dt*ci,end:(Dt+1)*ci})),Jt=(ke,Dt)=>ke===Dt?ke:Math.random()*(Dt-ke)+ke;nn.forEach(({label:ke,start:Dt,end:a1},c1)=>{let $s;c1===0?$s=3e3:$s=Jt(Dt,a1),xe.push(setTimeout(()=>{et(ke)},$s))})}catch(_e){console.error("Error accessing camera:",_e)}})(),()=>{Z.current&&Z.current.getTracks().forEach(_e=>_e.stop()),xe.forEach(clearTimeout)}},[et,b]),d.useImperativeHandle(f,()=>({setReference:()=>{G()},resetReference:()=>{Xe()},stopCamera:()=>{Z.current&&(Z.current.getTracks().forEach(xe=>xe.stop()),Z.current=null)}}),[G,Xe]),o.jsxs("div",{className:`iw-relative iw-h-full iw-w-full ${e}`,children:[Lt?o.jsxs("div",{className:"iw-rounded-md iw-border iw-border-red-600 iw-p-5 iw-text-red-600",children:[o.jsx("h2",{children:"Camera Permission Denied"}),o.jsx("p",{children:"Please allow camera access to use this application."})]}):o.jsx("div",{className:"iw-flex iw-w-full iw-h-full iw-justify-start iw-items-start",children:o.jsxs("div",{className:`iw-relative iw-max-w-full iw-max-h-full iw-aspect-video iw-rounded-2xl iw-overflow-hidden iw-bg-black ${be?"iw-animate-answer-start":""} ${s?"iw-border-4 iw-border-[#6296FB]":""}`,style:{width:"100%",height:"auto",minHeight:"0"},children:[o.jsx("video",{ref:q,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-absolute iw-inset-0 iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)"}}),!u&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-flex-col iw-items-center iw-justify-center iw-bg-black/60 iw-z-30",children:h||!Ne?o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-gap-3",children:[o.jsx("div",{className:"iw-w-5 iw-h-5 iw-border-2 iw-border-white/20 iw-border-t-white iw-rounded-full iw-animate-spin"}),o.jsx("span",{className:"iw-text-white/60 iw-text-xs iw-font-medium iw-tracking-wide",children:"Initializing camera..."})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"iw-text-white iw-font-medium iw-text-sm",children:"Camera not found"}),o.jsx("p",{className:"iw-text-white/60 iw-text-xs iw-mt-1",children:"Please ensure your camera is connected and enabled"})]})}),v&&o.jsx("canvas",{ref:J,width:320,height:240,className:"iw-absolute iw-inset-0 iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:y,display:"hidden"}}),o.jsx("canvas",{ref:U,style:{display:"none"}}),i&&o.jsxs("div",{className:"iw-absolute iw-top-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-[#FFEBE6] iw-px-2 iw-py-1 iw-backdrop-blur-md",children:[o.jsx("div",{className:"iw-size-2 iw-animate-pulse iw-rounded-full iw-bg-red-500"}),o.jsx("span",{className:"iw-font-medium iw-text-xs iw-text-[#E94315]",children:"RECORDING"})]}),i&&((El=g==null?void 0:g.data)==null?void 0:El.user_name)&&o.jsx("div",{className:"iw-absolute iw-z-50 iw-bottom-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-[#F1F5FE] iw-px-3 iw-py-1 iw-backdrop-blur-md",children:o.jsx("span",{className:"iw-font-medium iw-text-xs iw-text-[#062260]",children:g.data.user_name})}),i&&o.jsx("div",{className:"iw-absolute iw-bottom-4 iw-right-4",children:o.jsx(rd,{showControls:(m==null?void 0:m.showControls)??!1,isBubbleOpen:F,setIsBubbleOpen:A,setReference:G,clearCache:Nr,isModelLoaded:Ne,gazeAnalysisEnabled:L&&v,referenceSet:oi,showLandmarks:E,setShowLandmarks:T,showEngagementBar:M,setShowEngagementBar:N,handleToggleGazeAnalysis:n1,stats:o1,statusMessage:Ft,loadingProgress:Ar})}),c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"iw-absolute iw-inset-0 iw-pointer-events-none iw-z-10 ",style:{background:"radial-gradient(ellipse 20% 40% at 50% 45%, transparent 99.5%, rgba(0,0,0,0.35) 100%)"}}),o.jsx("div",{className:"iw-absolute iw-bottom-2 iw-inset-x-0 iw-flex iw-justify-center iw-pointer-events-none iw-z-20",children:o.jsx(s2,{status:u?h||!Ne?"model_loading":rn()??"no_face_detected":"camera_error"})})]})]})}),v&&yl&&!c&&o.jsx(n2,{isOpen:yl,onClose:s1,warningType:rn(),isCheatingModalOpen:l})]})}),Zi=({children:e,variant:t="primary",size:r="md",fullWidth:i=!1,isLoading:n=!1,disabled:s,className:a="",...c})=>{const l="iw-inline-flex iw-items-center iw-justify-center iw-rounded-md iw-font-medium iw-transition-colors iw-focus:outline-none iw-focus:ring-2 iw-focus:ring-primary-500 iw-focus:ring-offset-2",h={primary:"iw-bg-primary-600 iw-text-white iw-hover:bg-primary-700 iw-border iw-border-transparent",secondary:"iw-bg-primary-100 iw-text-primary-700 iw-hover:bg-primary-200 iw-border iw-border-transparent",outline:"iw-bg-transparent iw-text-primary-700 iw-border iw-border-primary-500 iw-hover:bg-primary-50",text:"iw-bg-transparent iw-text-primary-600 iw-hover:bg-primary-50 iw-border iw-border-transparent",gradient:"iw-text-white iw-border iw-border-transparent iw-bg-gradient-to-r iw-from-purple-500 iw-to-indigo-500 hover:iw-from-purple-600 hover:iw-to-indigo-600"},u={sm:"iw-px-3 iw-py-1.5 iw-text-sm",md:"iw-px-4 iw-py-2.5 iw-text-sm",lg:"iw-px-5 iw-py-3 iw-text-base"},f="iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none",w=i?"iw-w-full":"";return o.jsxs("button",{className:`${l} ${h[t]} ${u[r]} ${w} ${f} ${a}`,disabled:s||n,...c,children:[n&&o.jsx(Zs,{height:16,width:16,style:{marginRight:"3px"}}),e]})},o2=({stream:e,className:t="",barCount:r=50})=>{const i=d.useRef(null),n=d.useRef(null),s=d.useRef(null),a=d.useRef(null),c=d.useRef(null);d.useEffect(()=>{if(!e||window===void 0)return;a.current||(a.current=new(window.AudioContext||window.webkitAudioContext));const h=a.current;s.current||(s.current=h.createAnalyser(),s.current.fftSize=256,s.current.smoothingTimeConstant=.5);const u=s.current;try{c.current&&c.current.disconnect(),c.current=h.createMediaStreamSource(e),c.current.connect(u)}catch(w){console.error("Error creating media stream source:",w);return}const f=()=>{if(!i.current)return;const w=i.current,g=w.getContext("2d");if(!g)return;const p=u.frequencyBinCount,y=new Uint8Array(p);u.getByteFrequencyData(y);const m=w.width,b=w.height;g.clearRect(0,0,m,b);let v=0;for(let M=0;M<p;M++){const N=y[M]??0;v+=N*N}const F=Math.sqrt(v/p),A=Math.min(1,F/128);g.clearRect(0,0,m,b);const E=r,T=Math.floor(A*E);for(let M=0;M<E;M++){const N=M*(m/E),L=m/E-1.8;M<T?g.fillStyle="#0EB00E":g.fillStyle="#D9D9D9",g.fillRect(N,0,L,b)}n.current=requestAnimationFrame(f)};return f(),()=>{n.current&&cancelAnimationFrame(n.current)}},[e,r]);const l=d.useRef({audioContext:a.current,source:c.current});return l.current={audioContext:a.current,source:c.current},d.useEffect(()=>()=>{l.current.source&&l.current.source.disconnect(),l.current.audioContext&&l.current.audioContext.state!=="closed"&&l.current.audioContext.close()},[]),o.jsx("canvas",{ref:i,className:t,width:300,height:20,style:{width:"100%",height:"16px"}})},cl=({icon:e,devices:t,selectedId:r,onChange:i,label:n,showVisualizer:s=!1,stream:a=null,hasPermission:c=!0})=>{const{baseColor:l}=Zt(),[h,u]=d.useState(!1),f=d.useRef(null);d.useEffect(()=>{const p=y=>{f.current&&!f.current.contains(y.target)&&u(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]);const w=t.find(p=>p.deviceId===r)||t[0],g=c&&(w==null?void 0:w.label)||n;return o.jsxs("div",{className:"iw-relative iw-flex-1 iw-w-1/2 iw-group",ref:f,children:[o.jsxs("div",{className:`iw-max-w-[300px] iw-flex iw-items-center iw-justify-between iw-bg-white iw-border iw-border-gray-200 iw-rounded-xl iw-px-3 iw-py-3 iw-transition-colors ${c?"iw-cursor-pointer hover:iw-border-blue-500":"iw-cursor-not-allowed"}`,onClick:()=>c&&u(!h),title:c?"":"Permission denied or device not found",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3 iw-min-w-0 iw-max-w-[210px]",children:[o.jsx(e,{className:"iw-w-5 iw-h-5 iw-text-[#062260] iw-flex-shrink-0"}),o.jsx("span",{className:"iw-text-sm iw-text-[#062260] iw-font-medium iw-truncate",children:g})]}),o.jsx("div",{className:"iw-flex iw-items-center iw-gap-2",children:c?o.jsxs(o.Fragment,{children:[o.jsx(ql,{className:`iw-w-4 iw-h-4 iw-text-gray-400 iw-transition-transform ${h?"iw-rotate-180":""}`}),r&&o.jsx("div",{className:"iw-bg-[#22C55E] iw-rounded-full iw-p-0.5",children:o.jsx(hi,{className:"iw-w-3 iw-h-3 iw-text-white"})})]}):o.jsx("div",{className:"iw-text-[#E94315] iw-relative",children:o.jsx(ui,{className:"iw-size-5"})})})]}),!c&&o.jsx("div",{className:"iw-hidden group-hover:iw-block iw-absolute iw-bottom-full iw-mb-3 iw-left-1/6 -iw-translate-x-1/2 iw-w-64 iw-z-50",children:o.jsxs("div",{className:"iw-rounded-lg iw-p-3 iw-shadow-lg iw-text-white iw-text-left iw-relative",style:{background:l},children:[o.jsx("div",{className:"iw-flex iw-justify-between iw-items-start iw-mb-1",children:o.jsxs("h4",{className:"iw-text-sm iw-font-bold iw-mr-2",children:["Allow us to access your ",(n==null?void 0:n.split(" ")[1])??"device"]})}),o.jsx("p",{className:"iw-text-xs iw-opacity-90 iw-leading-tight",children:"We need permission to access your device. Go to your browser privacy settings to allow it"}),o.jsx("div",{className:"iw-absolute iw-top-full iw-left-1/2 -iw-translate-x-1/2 -iw-mt-1 iw-border-4 iw-border-transparent iw-border-t-[#5865F2]"})]})}),s&&c&&o.jsxs("div",{className:"iw-mt-2 iw-px-1 iw-flex iw-items-center iw-gap-2 iw-overflow-hidden",children:[o.jsx(Zl,{className:"iw-min-h-5 iw-min-w-5"}),o.jsx(o2,{stream:a,className:"iw-w-full"})]}),h&&c&&o.jsxs("div",{className:"iw-absolute iw-bottom-full iw-left-0 iw-right-0 iw-mb-2 iw-bg-white iw-border iw-border-gray-100 iw-rounded-xl iw-shadow-xl iw-z-50 iw-py-2 iw-max-h-60 iw-overflow-y-auto",children:[t.map(p=>o.jsxs("div",{className:`iw-px-4 iw-py-2.5 iw-text-sm iw-cursor-pointer iw-flex iw-items-center iw-justify-start hover:iw-bg-gray-50 ${r===p.deviceId?"iw-text-[#062260] iw-font-medium iw-bg-blue-50":"iw-text-gray-600"}`,onClick:()=>{i==null||i(p.deviceId),u(!1)},children:[r===p.deviceId&&o.jsx(hi,{className:"iw-w-4 iw-h-4 iw-text-[#062260] iw-mr-1"}),o.jsx("span",{className:"iw-truncate",children:p.label||`Device ${p.deviceId.slice(0,5)}...`})]},p.deviceId)),t.length===0&&o.jsx("div",{className:"iw-px-4 iw-py-2 iw-text-sm iw-text-gray-400",children:"No devices found"})]})]})},ll=({micEnabled:e=!1,videoEnabled:t=!1,buttonText:r,onButtonClick:i,isAgreed:n,onAgreedToggle:s,showCheckbox:a=!0,showMediaIcons:c=!0,disabled:l=!1,audioDevices:h=[],videoDevices:u=[],selectedAudioId:f,selectedVideoId:w,onAudioChange:g,onVideoChange:p,audioStream:y=null,isDeviceLoading:m=!1})=>{const b=l||!n||c&&(!e||!t)||m;return o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-4 iw-w-full",children:[a&&o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-bg-[#F1F5FE] iw-rounded-xl iw-p-3 iw-border iw-border-[#c2c3c7]",children:[o.jsx("div",{className:`iw-mt-0.5 iw-h-5 iw-w-5 iw-min-w-[20px] iw-rounded iw-border iw-flex iw-items-center iw-justify-center iw-cursor-pointer iw-transition-colors ${n?"iw-bg-[#062260] iw-border-[#062260]":"iw-bg-white iw-border-[#062260]"}`,onClick:v=>{v.stopPropagation(),s(!n)},children:n&&o.jsx(hi,{className:"iw-size-3 iw-text-white"})}),o.jsx("label",{onClick:()=>s(!n),className:"iw-text-sm iw-text-[#062260] iw-font-medium iw-cursor-pointer iw-select-none",children:"By continuing, you acknowledge and consent to the use of your face data exclusively for interview monitoring"})]}),o.jsx("div",{className:"iw-flex iw-justify-center iw-items-center iw-gap-4 iw-flex-wrap iw-max-w-[700px] iw-mx-auto",children:c&&o.jsxs("div",{className:"iw-flex iw-gap-4 iw-w-full",children:[o.jsx(cl,{icon:Xl,devices:h,selectedId:f??"",onChange:v=>g&&g(v),label:"Choose mic",showVisualizer:!0,stream:y,hasPermission:e}),o.jsx(cl,{icon:Jl,devices:u,selectedId:w??"",onChange:v=>p&&p(v),label:"Choose camera",hasPermission:t})]})}),o.jsxs("div",{className:"iw-relative iw-group iw-w-full iw-max-w-[280px] iw-mx-auto",children:[o.jsx(Zi,{onClick:i,disabled:b,className:`iw-h-12 iw-w-full !iw-bg-[#F1F5FE] !iw-text-[#062260] !iw-font-bold !iw-border-[#E7EAF1] iw-rounded-lg ${b?"iw-opacity-50":"hover:iw-opacity-75"}`,children:m?"Device Loading...":r}),!n&&(!c||e&&t)&&a2()]})]})},a2=()=>{const{baseColor:e}=Zt();return o.jsx(o.Fragment,{children:o.jsx("div",{className:"iw-hidden group-hover:iw-block iw-absolute iw-bottom-full iw-mb-3 iw-left-1/2 -iw-translate-x-1/2 iw-w-64 iw-z-50",children:o.jsxs("div",{className:"iw-rounded-lg iw-p-3 iw-shadow-lg iw-text-white iw-text-left iw-relative",style:{background:e},children:[o.jsx("div",{className:"iw-flex iw-justify-between iw-items-start iw-mb-1",children:o.jsx("h4",{className:"iw-text-sm iw-font-bold iw-mr-2",children:"Action Required"})}),o.jsx("p",{className:"iw-text-xs iw-opacity-90 iw-leading-tight",children:"Please check the box to acknowledge and consent to continue."}),o.jsx("div",{className:"iw-absolute iw-top-full iw-left-1/2 -iw-translate-x-1/2 -iw-mt-1 iw-border-4 iw-border-transparent iw-border-t-[#5865F2]"})]})})})},c2=({steps:e,currentStepIndex:t})=>o.jsx("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-4 iw-w-full iw-py-3",children:e.map((r,i)=>{const n=i<t,s=i===t;return o.jsxs(d.Fragment,{children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[o.jsx("div",{className:`iw-flex iw-size-9 iw-text-[#062260] iw-items-center iw-justify-center iw-rounded-full iw-font-semibold iw-border ${s||n?"iw-border-[#0EB00E] iw-bg-[#E9FFE6]":"iw-border-[#BDE0FD] iw-bg-[#E6F3FF]"}`,children:n?o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}):i+1}),o.jsx("span",{className:`iw-text-sm iw-font-medium ${s||n?"iw-text-[#062260]":"iw-text-[#5C6686]"}`,children:r.label})]}),i<e.length-1&&o.jsx("div",{className:"iw-flex-1 iw-max-w-[120px] iw-border-t iw-border-dotted iw-border-[#B3B9CB]"})]},i)})}),l2=["Don't refresh or reload the page during your assessment","Don't switch tabs or open other applications while session is ongoing","Don't leave your position during the session","Don't disable or interfere with video/audio monitoring"],d2=({isOpen:e,onStart:t,gazeEnabled:r=!1,videoFeedRef:i,interviewId:n="",interview_duration:s=li})=>{const{audioAllowed:a,videoAllowed:c,videoRef:l,audioDevices:h,videoDevices:u,selectedAudioDeviceId:f,selectedVideoDeviceId:w,isDeviceLoading:g,currentStream:p,handleAudioChange:y,handleVideoChange:m,stopStream:b}=$l(e),[v,F]=d.useState(!1),[A,E]=d.useState(0),[T,M]=d.useState(!1),N=d.useRef(null),L=d.useRef(null),z=U=>{N.current=U,i&&(typeof i=="function"?i(U):i.current=U)};if(d.useEffect(()=>()=>{L.current&&(clearInterval(L.current),L.current=null)},[]),!e)return null;const[be,Q]=d.useState(Te.MODEL_LOADING),q=async()=>{var Z;F(!0),(Z=N.current)==null||Z.resetReference();const U=()=>{var et;return(et=N.current)==null?void 0:et.setReference()};U(),L.current&&clearInterval(L.current),L.current=setInterval(U,500)},J=[{label:r?"Calibrate your camera":"Camera & Mic permission"},{label:"Basic guidelines"}];return o.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-gray-900/40 iw-backdrop-blur-sm iw-p-4 iw-pt-5 iw-overflow-auto",children:o.jsxs("div",{className:"iw-w-full iw-max-w-[700px] iw-max-h-[900px] iw-my-4 iw-bg-white iw-rounded-xl iw-shadow-2xl iw-overflow-auto",children:[o.jsxs("div",{className:"iw-px-5 iw-pt-3",children:[o.jsx("h2",{className:"iw-text-[#062260] iw-text-2xl iw-font-medium iw-tracking-tight",children:"Final checks before you go live"}),o.jsx("div",{className:"iw-mt-2 iw-bg-[#F1F5FE] iw-rounded-xl iw-p-2 iw-border iw-border-[#E7EAF1]",children:o.jsx("p",{className:"iw-text-[#5C6686] iw-text-xs iw-leading-relaxed",children:"To ensure the integrity of the interview process, this platform uses your device’s camera to monitor your face and gaze direction. We do not store any outside this session"})}),o.jsx("div",{className:"iw-mt-3 iw-border-b iw-border-dashed iw-border-[#B3B9CB] iw-w-full"}),o.jsx(c2,{steps:J,currentStepIndex:A})]}),o.jsx("div",{className:"iw-px-5 iw-pb-5 iw-flex iw-flex-col iw-items-center",children:A===0?o.jsxs("div",{className:"iw-w-full iw-flex iw-flex-col iw-items-center iw-gap-4",children:[o.jsx("div",{className:"iw-w-full iw-max-w-[600px] iw-aspect-video iw-bg-slate-100 iw-rounded-2xl iw-overflow-hidden iw-relative iw-border iw-border-slate-200",children:r?o.jsx(al,{ref:z,interviewId:n,interview_duration:s,showProctoringUI:!1,showStatusOverlay:!g&&c,isDeviceLoading:g,videoAllowed:c,onProctoringStatusChange:Q,onSetReference:()=>{L.current&&(clearInterval(L.current),L.current=null),F(!1),E(1)}}):o.jsx("video",{ref:l,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)"}})}),o.jsx(ll,{micEnabled:a,videoEnabled:c,buttonText:r?v?"Calibrating...":be==="model_loading"?"Initialising...":"Start calibrate":"Next",onButtonClick:()=>{r?q():E(1)},disabled:!T||r&&be!=="face_detected"||!r&&(!a||!c),isAgreed:T,onAgreedToggle:M,audioDevices:h,videoDevices:u,selectedAudioId:f,selectedVideoId:w,onAudioChange:y,onVideoChange:m,audioStream:p,isDeviceLoading:g})]}):o.jsxs("div",{className:"iw-w-full iw-flex iw-flex-col iw-gap-6",children:[o.jsx("div",{className:"iw-w-full iw-bg-[#F8FAFF] iw-rounded-2xl iw-p-8 iw-flex iw-flex-col iw-gap-5",children:l2.map((U,Z)=>o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-7 iw-w-7 iw-min-w-[28px] iw-items-center iw-justify-center iw-rounded-full iw-bg-[#DBEAFE] iw-text-[#062260] iw-text-xs iw-font-bold",children:Z+1}),o.jsx("span",{className:"iw-text-[#5C6686] iw-font-medium",children:U})]},Z))}),o.jsx(ll,{buttonText:"Start interview",onButtonClick:()=>{t(),b()},isAgreed:T,onAgreedToggle:M,showMediaIcons:!1})]})})]})})};var B=(e=>(e.IDLE="idle",e.FETCHING_QUESTION="fetching_question",e.READING_QUESTION="reading_question",e.THINKING="thinking",e.ANSWERING="answering",e.TRANSCRIBING="transcribing",e.EDITING="editing",e.SUBMITTING="submitting",e.COMPLETED="completed",e))(B||{});const dl={thinkingDuration:0,answeringDuration:120,editingDuration:30},ul={idle:{next:"fetching_question"},fetching_question:{next:"reading_question"},reading_question:{next:"answering"},thinking:{next:"answering",duration:0},answering:{next:"transcribing",duration:120},transcribing:{next:"editing"},editing:{next:"submitting",duration:30},submitting:{next:"completed"},completed:{next:"completed"}};class u2{constructor(t={},r={}){Se(this,"config");Se(this,"state");Se(this,"phaseIntervalId",null);Se(this,"globalIntervalId",null);Se(this,"callbacks");this.config={...dl,...t},this.callbacks=r,this.state={phase:"idle",currentPhaseTimeRemaining:0,totalTimeElapsed:0,currentQuestionNumber:0}}updateConfig(t){this.config={...this.config,...t}}getState(){return{...this.state}}startQuestion(){this.state.currentQuestionNumber===0&&this.startGlobalTimer(),this.state.currentQuestionNumber=this.state.currentQuestionNumber+1,this.state.phase="fetching_question",this.notifyChange()}nextPhase(){const t=this.state.phase;let r=ul[t];if(!r)return;if(r.next==="editing"&&this.config.editingDuration===0){const n=ul.editing;n&&(r=n)}this.stopPhaseTimer(),this.state.phase=r.next;const i=this.getDurationForPhase(r.next);i>0?(this.state.currentPhaseTimeRemaining=i,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}setTotalTimeElapsed(t){var r,i;this.state.totalTimeElapsed=t,(i=(r=this.callbacks).onTick)==null||i.call(r,this.getState())}completeInterview(){var t,r;this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(r=(t=this.callbacks).onInterviewEnd)==null||r.call(t),this.notifyChange()}destroy(){this.stopPhaseTimer(),this.stopGlobalTimer()}getDurationForPhase(t){switch(t){case"thinking":return this.config.thinkingDuration;case"answering":return this.config.answeringDuration;case"editing":return this.config.editingDuration;default:return 0}}startGlobalTimer(){this.globalIntervalId=setInterval(()=>{var t,r;this.state.totalTimeElapsed++,(r=(t=this.callbacks).onTick)==null||r.call(t,this.getState())},1e3)}stopGlobalTimer(){this.globalIntervalId&&(clearInterval(this.globalIntervalId),this.globalIntervalId=null)}startPhaseTimer(){this.phaseIntervalId=setInterval(()=>{this.state.currentPhaseTimeRemaining--,this.state.currentPhaseTimeRemaining<=0&&this.nextPhase()},1e3)}stopPhaseTimer(){this.phaseIntervalId&&(clearInterval(this.phaseIntervalId),this.phaseIntervalId=null)}notifyChange(){var t,r;(r=(t=this.callbacks).onPhaseChange)==null||r.call(t,this.state.phase,this.getState())}}function h2(e={}){const{config:t={},callbacks:r={}}=e,i=d.useRef(null);i.current||(i.current=new u2(t,{}));const n=i.current,[s,a]=d.useState(n.getState()),c=d.useCallback(()=>{a(n.getState())},[n]);d.useEffect(()=>{const f={onPhaseChange:(w,g)=>{var p;c(),(p=r.onPhaseChange)==null||p.call(r,w,g)},onTick:w=>{var g;c(),(g=r.onTick)==null||g.call(r,w)},onInterviewEnd:()=>{var w;c(),(w=r.onInterviewEnd)==null||w.call(r)}};n.callbacks=f},[n,r,c]),d.useEffect(()=>{n.updateConfig(t)},[n,t]),d.useEffect(()=>()=>{n.destroy()},[n]);const l=d.useCallback(()=>{n.startQuestion(),c()},[n,c]),h=d.useCallback(()=>{n.nextPhase(),c()},[n,c]),u=d.useCallback(()=>{n.completeInterview(),c()},[n,c]);return{state:s,startQuestion:l,nextPhase:h,completeInterview:u,timerService:n}}function f2(e,t={}){const[r,i]=d.useState({data:null,loading:!1,error:null}),n=d.useCallback(async(...s)=>{var a,c,l,h;i(u=>({...u,loading:!0,error:null}));try{const u=await e(...s);i(f=>({...f,data:u,loading:!1,error:null})),(a=t.onSuccess)==null||a.call(t,u),(c=t.onSettled)==null||c.call(t,u,null)}catch(u){const f=u.type?u:{type:"unknown",message:u.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:u};i(w=>({...w,loading:!1,error:f})),(l=t.onError)==null||l.call(t,f),(h=t.onSettled)==null||h.call(t,null,f)}},[e,t]);return{...r,execute:n}}const w2=e=>{const[t,r]=d.useState(null),[i,n]=d.useState(!1),s=document,a=()=>!!(s.fullscreenEnabled||s.webkitFullscreenEnabled||s.mozFullScreenEnabled||s.msFullscreenEnabled),c=()=>s.fullscreenElement||s.webkitFullscreenElement||s.mozFullScreenElement||s.msFullscreenElement,l=async g=>{var p;try{if(!a())throw new Error("Fullscreen is not supported in this environment");g.requestFullscreen?await g.requestFullscreen():g.webkitRequestFullscreen?await g.webkitRequestFullscreen():g.mozRequestFullScreen?await g.mozRequestFullScreen():g.msRequestFullscreen&&await g.msRequestFullscreen()}catch(y){const m={name:"FullscreenError",message:y instanceof Error?y.message:"Failed to enter fullscreen"};r(m),(p=e==null?void 0:e.onError)==null||p.call(e,m)}},h=async()=>{var g;try{s.exitFullscreen?await s.exitFullscreen():s.webkitExitFullscreen?await s.webkitExitFullscreen():s.mozCancelFullScreen?await s.mozCancelFullScreen():s.msExitFullscreen&&await s.msExitFullscreen()}catch(p){const y={name:"FullscreenError",message:p instanceof Error?p.message:"Failed to exit fullscreen"};r(y),(g=e==null?void 0:e.onError)==null||g.call(e,y)}},u=d.useCallback(()=>{var p;const g=!!c();n(g),(p=e==null?void 0:e.onFullScreenChange)==null||p.call(e,g)},[e]);d.useEffect(()=>{const g=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return g.forEach(p=>{document.addEventListener(p,u)}),()=>{g.forEach(p=>{document.removeEventListener(p,u)})}},[u]);const f=async g=>{r(null);const p=g??document.documentElement;await l(p)};return{isFullScreen:i,toggleFullScreen:async g=>{i?await h():await f(g)},enterFullScreen:f,exitFullScreen:h,error:t}};function hl(){const e=di();return d.useMemo(()=>{const r=e.api||{};return new to(r)},[e.api])}const g2=e=>{d.useEffect(()=>{const t=i=>{(i.ctrlKey||i.metaKey)&&["c","v","a","t","n","w","r","s","p"].includes(i.key.toLowerCase())&&(i.preventDefault(),e({type:"blocked_shortcut",severity:"low",details:{action:"shortcut_pressed",reason:`Attempted to use a blocked keyboard shortcut: Ctrl + ${i.key}`}})),i.key.startsWith("F")&&i.key.length<=3&&(i.preventDefault(),e({type:"blocked_function_key",severity:"low",details:{action:"function_key_pressed",reason:`Attempted to use a blocked function key: ${i.key}`}})),i.altKey&&i.key==="Tab"&&(i.preventDefault(),e({type:"alt_tab_attempt",severity:"medium",details:{action:"alt_tab",reason:"Attempted to use the Alt + Tab shortcut"}}))},r=i=>{i.preventDefault(),e({type:"right_click_attempt",severity:"low",details:{action:"right_click",reason:"Attempted to use the right click"}})};return document.addEventListener("keydown",t),document.addEventListener("contextmenu",r),()=>{document.removeEventListener("keydown",t),document.removeEventListener("contextmenu",r)}},[e])},p2=(e={})=>{const[t,r]=d.useState(!1),[i,n]=d.useState(!1),[s,a]=d.useState(null),[c,l]=d.useState(null),[h,u]=d.useState(null),f=d.useRef(e);f.current=e;const w=d.useRef(null);w.current||(w.current=new ol(e.config)),d.useEffect(()=>{var b;e.config&&((b=w.current)==null||b.updateConfig(e.config))},[e.config]),d.useEffect(()=>{const b=w.current;return()=>{b==null||b.dispose(),w.current=null}},[]);const g=d.useCallback(async b=>{var F,A;const v=w.current;if(!v||v.isDisposed())throw new W("STT service is not available","SERVICE_UNAVAILABLE",!1);try{l(null),a(null),u(null),await v.startRecording(b,{onStart:()=>{var E,T;r(!0),(T=(E=f.current).onStart)==null||T.call(E)},onStop:()=>{var E,T;r(!1),(T=(E=f.current).onStop)==null||T.call(E)},onError:E=>{var M,N;const T=E instanceof W?E:new W(E.message,"RECORDING_ERROR",!0);l(T),r(!1),(N=(M=f.current).onError)==null||N.call(M,T)}})}catch(E){const T=E instanceof W?E:new W(E instanceof Error?E.message:String(E),"START_FAILED",!1);throw l(T),r(!1),(A=(F=f.current).onError)==null||A.call(F,T),T}},[]),p=d.useCallback(async()=>{var v,F;const b=w.current;if(!b||b.isDisposed())throw new W("STT service is not available","SERVICE_UNAVAILABLE",!1);try{const A=await b.stopRecording(),E=(A.size/1024/1024).toFixed(2);return console.log(`[useSTT] Received audio blob: ${E} MB`),u(A),A}catch(A){const E=A instanceof W?A:new W(A instanceof Error?A.message:String(A),"STOP_FAILED",!1);throw l(E),r(!1),(F=(v=f.current).onError)==null||F.call(v,E),E}},[]),y=d.useCallback(async(b,v={})=>{var A,E,T,M;const F=w.current;if(!F||F.isDisposed())throw new W("STT service is not available","SERVICE_UNAVAILABLE",!1);try{l(null),n(!0);const N=(b.size/1024/1024).toFixed(2);console.log(`[useSTT] Starting transcription for blob: ${N} MB`);const L={audioBlob:b,...v},z=await F.transcribe(L);return console.log(`[useSTT] Transcription complete. Text length: ${z.transcript.length}`),a(z.transcript),n(!1),(E=(A=f.current).onTranscriptionComplete)==null||E.call(A,z),z}catch(N){const L=N instanceof W?N:new W(N instanceof Error?N.message:String(N),"TRANSCRIPTION_FAILED",!0);throw l(L),n(!1),(M=(T=f.current).onError)==null||M.call(T,L),L}},[]),m=d.useCallback(()=>{var b;(b=w.current)==null||b.cancelRecording(),r(!1),u(null)},[]);return{startRecording:g,stopRecording:p,transcribe:y,cancelRecording:m,isRecording:t,isTranscribing:i,transcript:s,error:c,audioBlob:h}},m2=e=>{const t=d.useRef(null),r=d.useRef(!1);d.useEffect(()=>{const i=()=>{document.hidden&&(r.current=!0,t.current&&(clearTimeout(t.current),t.current=null),e({type:"tab_switch",severity:"high",details:{action:"tab_hidden",reason:"Attempted to switch tabs or applications"}}),setTimeout(()=>{r.current=!1},100))},n=()=>{r.current||(t.current=setTimeout(()=>{r.current||e({type:"focus_loss",severity:"medium",details:{action:"window_blur",reason:"Focus lost from the interview window"}}),t.current=null},50))};return document.addEventListener("visibilitychange",i),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",i),window.removeEventListener("blur",n),t.current&&clearTimeout(t.current)}},[e])},y2=()=>{d.useEffect(()=>{const e=document.createElement("style");return e.textContent=`
15
+ }`,e.VERTEX_SHADER),this.W=Mc(this,this.H(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.O=e.getAttribLocation(this.h,"aVertex"),this.L=e.getAttribLocation(this.h,"aTex")}D(){}l(){}close(){if(this.h){const e=this.g;e.deleteProgram(this.h),e.deleteShader(this.X),e.deleteShader(this.W)}this.B&&this.g.deleteFramebuffer(this.B),this.A&&this.A.close(),this.u&&this.u.close()}};function yt(e,t){switch(t){case 0:return e.g.find(r=>r instanceof Uint8Array);case 1:return e.g.find(r=>r instanceof Float32Array);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function ks(e){var t=yt(e,1);if(!t){if(t=yt(e,0))t=new Float32Array(t).map(i=>i/255);else{t=new Float32Array(e.width*e.height);const i=Tr(e);var r=Ss(e);if(Oc(r,i,Uc(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(e.width*e.height*4),i.readPixels(0,0,e.width,e.height,i.RGBA,i.FLOAT,r);for(let n=0,s=0;n<t.length;++n,s+=4)t[n]=r[s]}else i.readPixels(0,0,e.width,e.height,i.RED,i.FLOAT,t)}e.g.push(t)}return t}function Uc(e){let t=yt(e,2);if(!t){const r=Tr(e);t=Gc(e);const i=ks(e),n=Vc(e);r.texImage2D(r.TEXTURE_2D,0,n,e.width,e.height,0,r.RED,r.FLOAT,i),Ts(e)}return t}function Tr(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return e.h||(e.h=It(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Vc(e){if(e=Tr(e),!Xi)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Xi=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Xi=e.R16F}return Xi}function Ss(e){return e.l||(e.l=new Bc),e.l}function Gc(e){const t=Tr(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=yt(e,2);return r||(r=Pc(Ss(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Ts(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Xi,pe=class{constructor(e,t,r,i,n,s,a){this.g=e,this.m=t,this.j=r,this.canvas=i,this.l=n,this.width=s,this.height=a,this.j&&--jc===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Fa(){return!!yt(this,0)}ka(){return!!yt(this,1)}R(){return!!yt(this,2)}ja(){return(t=yt(e=this,0))||(t=ks(e),t=new Uint8Array(t.map(r=>Math.round(255*r))),e.g.push(t)),t;var e,t}ia(){return ks(this)}N(){return Uc(this)}clone(){const e=[];for(const t of this.g){let r;if(t instanceof Uint8Array)r=new Uint8Array(t);else if(t instanceof Float32Array)r=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{const i=Tr(this),n=Ss(this);i.activeTexture(i.TEXTURE1),r=Pc(n,i,this.m?i.LINEAR:i.NEAREST),i.bindTexture(i.TEXTURE_2D,r);const s=Vc(this);i.texImage2D(i.TEXTURE_2D,0,s,this.width,this.height,0,i.RED,i.FLOAT,null),i.bindTexture(i.TEXTURE_2D,null),Oc(n,i,r),Vu(n,i,!1,()=>{Gc(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),Ts(this)}),Gu(n),Ts(this)}}e.push(r)}return new pe(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Tr(this).deleteTexture(yt(this,2)),jc=-1}};pe.prototype.close=pe.prototype.close,pe.prototype.clone=pe.prototype.clone,pe.prototype.getAsWebGLTexture=pe.prototype.N,pe.prototype.getAsFloat32Array=pe.prototype.ia,pe.prototype.getAsUint8Array=pe.prototype.ja,pe.prototype.hasWebGLTexture=pe.prototype.R,pe.prototype.hasFloat32Array=pe.prototype.ka,pe.prototype.hasUint8Array=pe.prototype.Fa;var jc=250;function Je(...e){return e.map(([t,r])=>({start:t,end:r}))}const ju=function(e){return class extends e{Ja(){this.i._registerModelResourcesGraphService()}}}((zc=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:Cc()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){const t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){const r=e.length,i=this.i._malloc(r);this.i.HEAPU8.set(e,i),t?this.i._changeBinaryGraph(r,i):this.i._changeTextGraph(r,i),this.i._free(i)}configureAudio(e,t,r,i,n){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),S(this,i||"input_audio",s=>{S(this,n=n||"audio_header",a=>{this.i._configureAudio(s,a,e,t??0,r)})})}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ca(e){lt(this,"__graph_config__",t=>{e(t)}),S(this,"__graph_config__",t=>{this.i._getGraphConfig(t,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,i,n){const s=4*e.length;this.h!==s&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(s),this.h=s),this.i.HEAPF32.set(e,this.g/4),S(this,i,a=>{this.i._addAudioToInputStream(this.g,t,r,a,n)})}addGpuBufferToStream(e,t,r){S(this,t,i=>{const[n,s]=Ic(this,e,i);this.i._addBoundTextureToStream(i,n,s,r)})}addBoolToStream(e,t,r){S(this,t,i=>{this.i._addBoolToInputStream(e,i,r)})}addDoubleToStream(e,t,r){S(this,t,i=>{this.i._addDoubleToInputStream(e,i,r)})}addFloatToStream(e,t,r){S(this,t,i=>{this.i._addFloatToInputStream(e,i,r)})}addIntToStream(e,t,r){S(this,t,i=>{this.i._addIntToInputStream(e,i,r)})}addUintToStream(e,t,r){S(this,t,i=>{this.i._addUintToInputStream(e,i,r)})}addStringToStream(e,t,r){S(this,t,i=>{S(this,e,n=>{this.i._addStringToInputStream(n,i,r)})})}addStringRecordToStream(e,t,r){S(this,t,i=>{Fc(this,Object.keys(e),n=>{Fc(this,Object.values(e),s=>{this.i._addFlatHashMapToInputStream(n,s,Object.keys(e).length,i,r)})})})}addProtoToStream(e,t,r,i){S(this,r,n=>{S(this,t,s=>{const a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,s,n,i),this.i._free(a)})})}addEmptyPacketToStream(e,t){S(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(const s of e)this.i._addBoolVectorEntry(n,s);this.i._addBoolVectorToInputStream(n,i,r)})}addDoubleVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(const s of e)this.i._addDoubleVectorEntry(n,s);this.i._addDoubleVectorToInputStream(n,i,r)})}addFloatVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(const s of e)this.i._addFloatVectorEntry(n,s);this.i._addFloatVectorToInputStream(n,i,r)})}addIntVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(const s of e)this.i._addIntVectorEntry(n,s);this.i._addIntVectorToInputStream(n,i,r)})}addUintVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(const s of e)this.i._addUintVectorEntry(n,s);this.i._addUintVectorToInputStream(n,i,r)})}addStringVectorToStream(e,t,r){S(this,t,i=>{const n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(const s of e)S(this,s,a=>{this.i._addStringVectorEntry(n,a)});this.i._addStringVectorToInputStream(n,i,r)})}addBoolToInputSidePacket(e,t){S(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){S(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){S(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){S(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){S(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){S(this,t,r=>{S(this,e,i=>{this.i._addStringToInputSidePacket(i,r)})})}addProtoToInputSidePacket(e,t,r){S(this,r,i=>{S(this,t,n=>{const s=this.i._malloc(e.length);this.i.HEAPU8.set(e,s),this.i._addProtoToInputSidePacket(s,e.length,n,i),this.i._free(s)})})}addBoolVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(const n of e)this.i._addBoolVectorEntry(i,n);this.i._addBoolVectorToInputSidePacket(i,r)})}addDoubleVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(const n of e)this.i._addDoubleVectorEntry(i,n);this.i._addDoubleVectorToInputSidePacket(i,r)})}addFloatVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(const n of e)this.i._addFloatVectorEntry(i,n);this.i._addFloatVectorToInputSidePacket(i,r)})}addIntVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(const n of e)this.i._addIntVectorEntry(i,n);this.i._addIntVectorToInputSidePacket(i,r)})}addUintVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(const n of e)this.i._addUintVectorEntry(i,n);this.i._addUintVectorToInputSidePacket(i,r)})}addStringVectorToInputSidePacket(e,t){S(this,t,r=>{const i=this.i._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(const n of e)S(this,n,s=>{this.i._addStringVectorEntry(i,s)});this.i._addStringVectorToInputSidePacket(i,r)})}attachBoolListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){lt(this,e,t),S(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){Nt(this,e,t),S(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){lt(this,e,t),S(this,e,i=>{this.i._attachProtoListener(i,r||!1)})}attachProtoVectorListener(e,t,r){Nt(this,e,t),S(this,e,i=>{this.i._attachProtoVectorListener(i,r||!1)})}attachAudioListener(e,t,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),lt(this,e,(i,n)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,n)}),S(this,e,i=>{this.i._attachAudioListener(i,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends zc{get ga(){return this.i}pa(e,t,r){S(this,t,i=>{const[n,s]=Ic(this,e,i);this.ga._addBoundTextureAsImageToStream(i,n,s,r)})}Z(e,t){lt(this,e,t),S(this,e,r=>{this.ga._attachImageListener(r)})}aa(e,t){Nt(this,e,t),S(this,e,r=>{this.ga._attachImageVectorListener(r)})}}));var zc,Ze=class extends ju{};async function O(e,t,r){return async function(i,n,s,a){return Bu(i,n,s,a)}(e,r.canvas??(Cc()?void 0:document.createElement("canvas")),t,r)}function $c(e,t,r,i){if(e.U){const s=new Ya;if(r!=null&&r.regionOfInterest){if(!e.oa)throw Error("This task doesn't support region-of-interest.");var n=r.regionOfInterest;if(n.left>=n.right||n.top>=n.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(n.left<0||n.top<0||n.right>1||n.bottom>1)throw Error("Expected RectF values to be in [0,1].");C(s,1,(n.left+n.right)/2),C(s,2,(n.top+n.bottom)/2),C(s,4,n.right-n.left),C(s,3,n.bottom-n.top)}else C(s,1,.5),C(s,2,.5),C(s,4,1),C(s,3,1);if(r!=null&&r.rotationDegrees){if((r==null?void 0:r.rotationDegrees)%90!=0)throw Error("Expected rotation to be a multiple of 90°.");if(C(s,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[a,c]=Nc(t);r=ie(s,3)*c/a,n=ie(s,4)*a/c,C(s,4,r),C(s,3,n)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,i)}e.g.pa(t,e.X,i??performance.now()),e.finishProcessing()}function Re(e,t,r){var i;if((i=e.baseOptions)!=null&&i.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");$c(e,t,r,e.C+1)}function dt(e,t,r,i){var n;if(!((n=e.baseOptions)!=null&&n.g()))throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");$c(e,t,r,i)}function Cr(e,t,r,i){var n=t.data;const s=t.width,a=s*(t=t.height);if((n instanceof Uint8Array||n instanceof Float32Array)&&n.length!==a)throw Error("Unsupported channel count: "+n.length/a);return e=new pe([n],r,!1,e.g.i.canvas,e.P,s,t),i?e.clone():e}var Be=class extends Es{constructor(e,t,r,i){super(e),this.g=e,this.X=t,this.U=r,this.oa=i,this.P=new Bc}l(e,t=!0){if("runningMode"in e&&$(this.baseOptions,2,Kr(!!e.runningMode&&e.runningMode!=="IMAGE")),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Be.prototype.close=Be.prototype.close;var He=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},I(e=this.h=new Wi,0,1,t=new re),C(this.h,2,.5),C(this.h,3,.3)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&C(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&C(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},Re(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},dt(this,e,r,t),this.j}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect_in"),j(e,"detections");const t=new Pe;at(t,Eu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect_in"),P(r,"DETECTIONS:detections"),r.o(t),We(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Ha(s),this.j.detections.push(_c(i));x(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};He.prototype.detectForVideo=He.prototype.G,He.prototype.detect=He.prototype.F,He.prototype.setOptions=He.prototype.o,He.createFromModelPath=async function(e,t){return O(He,e,{baseOptions:{modelAssetPath:t}})},He.createFromModelBuffer=function(e,t){return O(He,e,{baseOptions:{modelAssetBuffer:t}})},He.createFromOptions=function(e,t){return O(He,e,t)};var Cs=Je([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]),As=Je([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]),Ns=Je([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Wc=Je([474,475],[475,476],[476,477],[477,474]),Is=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]),Fs=Je([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Hc=Je([469,470],[470,471],[471,472],[472,469]),Ls=Je([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]),qc=[...Cs,...As,...Ns,...Is,...Fs,...Ls],Kc=Je([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function Yc(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var te=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,I(e=this.h=new rc,0,1,t=new re),this.A=new tc,I(this.h,0,3,this.A),this.u=new Wi,I(this.h,0,2,this.u),pt(this.u,4,1),C(this.u,2,.5),C(this.A,2,.5),C(this.h,4,.5)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"numFaces"in e&&pt(this.u,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&C(this.u,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&C(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&C(this.A,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}F(e,t){return Yc(this),Re(this,e,t),this.j}G(e,t,r){return Yc(this),dt(this,e,r,t),this.j}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"face_landmarks");const t=new Pe;at(t,ku,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),We(e,r),this.g.attachProtoVectorListener("face_landmarks",(i,n)=>{for(const s of i)i=ti(s),this.j.faceLandmarks.push(Hi(i));x(this,n)}),this.g.attachEmptyPacketListener("face_landmarks",i=>{x(this,i)}),this.outputFaceBlendshapes&&(j(e,"blendshapes"),P(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(i,n)=>{if(this.outputFaceBlendshapes)for(const s of i)i=ji(s),this.j.faceBlendshapes.push(vs(i.g()??[]));x(this,n)}),this.g.attachEmptyPacketListener("blendshapes",i=>{x(this,i)})),this.outputFacialTransformationMatrixes&&(j(e,"face_geometry"),P(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(i,n)=>{if(this.outputFacialTransformationMatrixes)for(const s of i)(i=V(i=_u(s),wu,2))&&this.j.facialTransformationMatrixes.push({rows:ze(i,1)??0??0,columns:ze(i,2)??0??0,data:$t(i,3,st,zt()).slice()??[]});x(this,n)}),this.g.attachEmptyPacketListener("face_geometry",i=>{x(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};te.prototype.detectForVideo=te.prototype.G,te.prototype.detect=te.prototype.F,te.prototype.setOptions=te.prototype.o,te.createFromModelPath=function(e,t){return O(te,e,{baseOptions:{modelAssetPath:t}})},te.createFromModelBuffer=function(e,t){return O(te,e,{baseOptions:{modelAssetBuffer:t}})},te.createFromOptions=function(e,t){return O(te,e,t)},te.FACE_LANDMARKS_LIPS=Cs,te.FACE_LANDMARKS_LEFT_EYE=As,te.FACE_LANDMARKS_LEFT_EYEBROW=Ns,te.FACE_LANDMARKS_LEFT_IRIS=Wc,te.FACE_LANDMARKS_RIGHT_EYE=Is,te.FACE_LANDMARKS_RIGHT_EYEBROW=Fs,te.FACE_LANDMARKS_RIGHT_IRIS=Hc,te.FACE_LANDMARKS_FACE_OVAL=Ls,te.FACE_LANDMARKS_CONTOURS=qc,te.FACE_LANDMARKS_TESSELATION=Kc;var Ms=Je([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function Xc(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Qc(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function Jc(e,t=!0){const r=[];for(const n of e){var i=ji(n);e=[];for(const s of i.g())i=t&&ze(s,1)!=null?ze(s,1)??0:-1,e.push({score:ie(s,2)??0,index:i,categoryName:ye(K(s,3))??""??"",displayName:ye(K(s,4))??""??""});r.push(e)}return r}var Ue=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],I(e=this.j=new sc,0,1,t=new re),this.u=new hs,I(this.j,0,2,this.u),this.D=new us,I(this.u,0,3,this.D),this.A=new nc,I(this.u,0,2,this.A),this.h=new Su,I(this.j,0,3,this.h),C(this.A,2,.5),C(this.u,4,.5),C(this.D,2,.5)}get baseOptions(){return V(this.j,re,1)}set baseOptions(e){I(this.j,0,1,e)}o(e){var n,s,a,c;if(pt(this.A,3,e.numHands??1),"minHandDetectionConfidence"in e&&C(this.A,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&C(this.u,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&C(this.D,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new kr,r=t,i=bs(e.cannedGesturesClassifierOptions,(n=V(this.h,kr,3))==null?void 0:n.l());I(r,0,2,i),I(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&((s=V(this.h,kr,3))==null||s.g());return e.customGesturesClassifierOptions?(I(r=t=new kr,0,2,i=bs(e.customGesturesClassifierOptions,(a=V(this.h,kr,4))==null?void 0:a.l())),I(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&((c=V(this.h,kr,4))==null||c.g()),this.l(e)}Ha(e,t){return Xc(this),Re(this,e,t),Qc(this)}Ia(e,t,r){return Xc(this),dt(this,e,r,t),Qc(this)}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"hand_gestures"),j(e,"hand_landmarks"),j(e,"world_hand_landmarks"),j(e,"handedness");const t=new Pe;at(t,Tu,this.j);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"HAND_GESTURES:hand_gestures"),P(r,"LANDMARKS:hand_landmarks"),P(r,"WORLD_LANDMARKS:world_hand_landmarks"),P(r,"HANDEDNESS:handedness"),r.o(t),We(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i){i=ti(s);const a=[];for(const c of gt(i,Ka,1))a.push({x:ie(c,1)??0,y:ie(c,2)??0,z:ie(c,3)??0,visibility:ie(c,4)??0});this.landmarks.push(a)}x(this,n)}),this.g.attachEmptyPacketListener("hand_landmarks",i=>{x(this,i)}),this.g.attachProtoVectorListener("world_hand_landmarks",(i,n)=>{for(const s of i){i=_r(s);const a=[];for(const c of gt(i,qa,1))a.push({x:ie(c,1)??0,y:ie(c,2)??0,z:ie(c,3)??0,visibility:ie(c,4)??0});this.worldLandmarks.push(a)}x(this,n)}),this.g.attachEmptyPacketListener("world_hand_landmarks",i=>{x(this,i)}),this.g.attachProtoVectorListener("hand_gestures",(i,n)=>{this.gestures.push(...Jc(i,!1)),x(this,n)}),this.g.attachEmptyPacketListener("hand_gestures",i=>{x(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{this.handedness.push(...Jc(i)),x(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Zc(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Ue.prototype.recognizeForVideo=Ue.prototype.Ia,Ue.prototype.recognize=Ue.prototype.Ha,Ue.prototype.setOptions=Ue.prototype.o,Ue.createFromModelPath=function(e,t){return O(Ue,e,{baseOptions:{modelAssetPath:t}})},Ue.createFromModelBuffer=function(e,t){return O(Ue,e,{baseOptions:{modelAssetBuffer:t}})},Ue.createFromOptions=function(e,t){return O(Ue,e,t)},Ue.HAND_CONNECTIONS=Ms;var Ve=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],I(e=this.h=new hs,0,1,t=new re),this.u=new us,I(this.h,0,3,this.u),this.j=new nc,I(this.h,0,2,this.j),pt(this.j,3,1),C(this.j,2,.5),C(this.u,2,.5),C(this.h,4,.5)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"numHands"in e&&pt(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&C(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&C(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&C(this.u,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],Re(this,e,t),Zc(this)}G(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],dt(this,e,r,t),Zc(this)}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"hand_landmarks"),j(e,"world_hand_landmarks"),j(e,"handedness");const t=new Pe;at(t,Cu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"LANDMARKS:hand_landmarks"),P(r,"WORLD_LANDMARKS:world_hand_landmarks"),P(r,"HANDEDNESS:handedness"),r.o(t),We(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i)i=ti(s),this.landmarks.push(Hi(i));x(this,n)}),this.g.attachEmptyPacketListener("hand_landmarks",i=>{x(this,i)}),this.g.attachProtoVectorListener("world_hand_landmarks",(i,n)=>{for(const s of i)i=_r(s),this.worldLandmarks.push(ri(i));x(this,n)}),this.g.attachEmptyPacketListener("world_hand_landmarks",i=>{x(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{var s=this.handedness,a=s.push;const c=[];for(const l of i){i=ji(l);const h=[];for(const u of i.g())h.push({score:ie(u,2)??0,index:ze(u,1)??0??-1,categoryName:ye(K(u,3))??""??"",displayName:ye(K(u,4))??""??""});c.push(h)}a.call(s,...c),x(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ve.prototype.detectForVideo=Ve.prototype.G,Ve.prototype.detect=Ve.prototype.F,Ve.prototype.setOptions=Ve.prototype.o,Ve.createFromModelPath=function(e,t){return O(Ve,e,{baseOptions:{modelAssetPath:t}})},Ve.createFromModelBuffer=function(e,t){return O(Ve,e,{baseOptions:{modelAssetBuffer:t}})},Ve.createFromOptions=function(e,t){return O(Ve,e,t)},Ve.HAND_CONNECTIONS=Ms;var Rc=Je([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function el(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function tl(e){try{if(!e.D)return e.h;e.D(e.h)}finally{Yi(e)}}function Qi(e,t){e=ti(e),t.push(Hi(e))}var X=class extends Be{constructor(e,t){super(new Ze(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,I(e=this.j=new uc,0,1,t=new re),this.I=new us,I(this.j,0,2,this.I),this.W=new Au,I(this.j,0,3,this.W),this.u=new Wi,I(this.j,0,4,this.u),this.O=new tc,I(this.j,0,5,this.O),this.A=new lc,I(this.j,0,6,this.A),this.M=new dc,I(this.j,0,7,this.M),C(this.u,2,.5),C(this.u,3,.3),C(this.O,2,.5),C(this.A,2,.5),C(this.A,3,.3),C(this.M,2,.5),C(this.I,2,.5)}get baseOptions(){return V(this.j,re,1)}set baseOptions(e){I(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&C(this.u,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&C(this.u,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&C(this.O,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&C(this.A,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&C(this.A,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&C(this.M,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&C(this.I,2,e.minHandLandmarksConfidence??.5),this.l(e)}F(e,t,r){const i=typeof t!="function"?t:{};return this.D=typeof t=="function"?t:r,el(this),Re(this,e,i),tl(this)}G(e,t,r,i){const n=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:i,el(this),dt(this,e,n,t),tl(this)}m(){var e=new Oe;ee(e,"input_frames_image"),j(e,"pose_landmarks"),j(e,"pose_world_landmarks"),j(e,"face_landmarks"),j(e,"left_hand_landmarks"),j(e,"left_hand_world_landmarks"),j(e,"right_hand_landmarks"),j(e,"right_hand_world_landmarks");const t=new Pe,r=new Aa;Me(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(n,s){if(s!=null)if(Array.isArray(s))$(n,2,ki(s,0,Qr));else{if(!(typeof s=="string"||s instanceof it||mn(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");kt(n,2,xn(s,!1),Ot())}}(r,this.j.g());const i=new Ce;Me(i,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),zn(i,8,Aa,r),Y(i,"IMAGE:input_frames_image"),P(i,"POSE_LANDMARKS:pose_landmarks"),P(i,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),P(i,"FACE_LANDMARKS:face_landmarks"),P(i,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),P(i,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),P(i,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),P(i,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),i.o(t),We(e,i),Ki(this,e),this.g.attachProtoListener("pose_landmarks",(n,s)=>{Qi(n,this.h.poseLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("pose_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("pose_world_landmarks",(n,s)=>{var a=this.h.poseWorldLandmarks;n=_r(n),a.push(ri(n)),x(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",n=>{x(this,n)}),this.outputPoseSegmentationMasks&&(P(i,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Sr(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(n,s)=>{this.h.poseSegmentationMasks=[Cr(this,n,!0,!this.D)],x(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",n=>{this.h.poseSegmentationMasks=[],x(this,n)})),this.g.attachProtoListener("face_landmarks",(n,s)=>{Qi(n,this.h.faceLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{x(this,n)}),this.outputFaceBlendshapes&&(j(e,"extra_blendshapes"),P(i,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(n,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(n=ji(n),a.push(vs(n.g()??[]))),x(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",n=>{x(this,n)})),this.g.attachProtoListener("left_hand_landmarks",(n,s)=>{Qi(n,this.h.leftHandLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("left_hand_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("left_hand_world_landmarks",(n,s)=>{var a=this.h.leftHandWorldLandmarks;n=_r(n),a.push(ri(n)),x(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("right_hand_landmarks",(n,s)=>{Qi(n,this.h.rightHandLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("right_hand_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("right_hand_world_landmarks",(n,s)=>{var a=this.h.rightHandWorldLandmarks;n=_r(n),a.push(ri(n)),x(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",n=>{x(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};X.prototype.detectForVideo=X.prototype.G,X.prototype.detect=X.prototype.F,X.prototype.setOptions=X.prototype.o,X.createFromModelPath=function(e,t){return O(X,e,{baseOptions:{modelAssetPath:t}})},X.createFromModelBuffer=function(e,t){return O(X,e,{baseOptions:{modelAssetBuffer:t}})},X.createFromOptions=function(e,t){return O(X,e,t)},X.HAND_CONNECTIONS=Ms,X.POSE_CONNECTIONS=Rc,X.FACE_LANDMARKS_LIPS=Cs,X.FACE_LANDMARKS_LEFT_EYE=As,X.FACE_LANDMARKS_LEFT_EYEBROW=Ns,X.FACE_LANDMARKS_LEFT_IRIS=Wc,X.FACE_LANDMARKS_RIGHT_EYE=Is,X.FACE_LANDMARKS_RIGHT_EYEBROW=Fs,X.FACE_LANDMARKS_RIGHT_IRIS=Hc,X.FACE_LANDMARKS_FACE_OVAL=Ls,X.FACE_LANDMARKS_CONTOURS=qc,X.FACE_LANDMARKS_TESSELATION=Kc;var qe=class extends Be{constructor(e,t){super(new Ze(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},I(e=this.h=new hc,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return I(this.h,0,2,bs(e,V(this.h,cs,2))),this.l(e)}sa(e,t){return this.j={classifications:[]},Re(this,e,t),this.j}ta(e,t,r){return this.j={classifications:[]},dt(this,e,r,t),this.j}m(){var e=new Oe;ee(e,"input_image"),ee(e,"norm_rect"),j(e,"classifications");const t=new Pe;at(t,Nu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Y(r,"IMAGE:input_image"),Y(r,"NORM_RECT:norm_rect"),P(r,"CLASSIFICATIONS:classifications"),r.o(t),We(e,r),this.g.attachProtoListener("classifications",(i,n)=>{this.j=Pu(mu(i)),x(this,n)}),this.g.attachEmptyPacketListener("classifications",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};qe.prototype.classifyForVideo=qe.prototype.ta,qe.prototype.classify=qe.prototype.sa,qe.prototype.setOptions=qe.prototype.o,qe.createFromModelPath=function(e,t){return O(qe,e,{baseOptions:{modelAssetPath:t}})},qe.createFromModelBuffer=function(e,t){return O(qe,e,{baseOptions:{modelAssetBuffer:t}})},qe.createFromOptions=function(e,t){return O(qe,e,t)};var Ge=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!0),this.h=new fc,this.embeddings={embeddings:[]},I(e=this.h,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){var t=this.h,r=V(this.h,Za,2);return r=r?r.clone():new Za,e.l2Normalize!==void 0?$(r,1,Kr(e.l2Normalize)):"l2Normalize"in e&&$(r,1),e.quantize!==void 0?$(r,2,Kr(e.quantize)):"quantize"in e&&$(r,2),I(t,0,2,r),this.l(e)}za(e,t){return Re(this,e,t),this.embeddings}Aa(e,t,r){return dt(this,e,r,t),this.embeddings}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"embeddings_out");const t=new Pe;at(t,Iu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"EMBEDDINGS:embeddings_out"),r.o(t),We(e,r),this.g.attachProtoListener("embeddings_out",(i,n)=>{i=vu(i),this.embeddings=function(s){return{embeddings:gt(s,bu,1).map(a=>{var h,u;const c={headIndex:ze(a,3)??0??-1,headName:ye(K(a,4))??""??""};var l=a.v;return qo(l,0|l[_],Xa,Un(a,1))!==void 0?(a=$t(a=V(a,Xa,Un(a,1),void 0),1,st,zt()),c.floatEmbedding=a.slice()):(l=new Uint8Array(0),c.quantizedEmbedding=((u=(h=V(a,yu,Un(a,2),void 0))==null?void 0:h.na())==null?void 0:u.h())??l),c}),timestampMs:Ec(Xo(s))}}(i),x(this,n)}),this.g.attachEmptyPacketListener("embeddings_out",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ge.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Sc(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Sc(kc(e.quantizedEmbedding),kc(t.quantizedEmbedding))}return e},Ge.prototype.embedForVideo=Ge.prototype.Aa,Ge.prototype.embed=Ge.prototype.za,Ge.prototype.setOptions=Ge.prototype.o,Ge.createFromModelPath=function(e,t){return O(Ge,e,{baseOptions:{modelAssetPath:t}})},Ge.createFromModelBuffer=function(e,t){return O(Ge,e,{baseOptions:{modelAssetBuffer:t}})},Ge.createFromOptions=function(e,t){return O(Ge,e,t)};var Ds=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach(r=>{r.close()}),(t=this.categoryMask)==null||t.close()}};function zu(e){var r,i;const t=function(n){return gt(n,Ce,1)}(e.ca()).filter(n=>(ye(K(n,1))??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.u=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(((i=(r=V(t[0],Pe,7))==null?void 0:r.j())==null?void 0:i.g())??new Map).forEach((n,s)=>{e.u[Number(s)]=ye(K(n,1))??""})}function rl(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function il(e){try{const t=new Ds(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{Yi(e)}}Ds.prototype.close=Ds.prototype.close;var Ae=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ps,this.A=new wc,I(this.h,0,3,this.A),I(e=this.h,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?$(this.h,2,Xr(e.displayNamesLocale)):"displayNamesLocale"in e&&$(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}L(){zu(this)}segment(e,t,r){const i=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,rl(this),Re(this,e,i),il(this)}La(e,t,r,i){const n=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:i,rl(this),dt(this,e,n,t),il(this)}Da(){return this.u}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect");const t=new Pe;at(t,mc,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),r.o(t),We(e,r),Ki(this,e),this.outputConfidenceMasks&&(j(e,"confidence_masks"),P(r,"CONFIDENCE_MASKS:confidence_masks"),Sr(this,"confidence_masks"),this.g.aa("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Cr(this,s,!0,!this.j)),x(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],x(this,i)})),this.outputCategoryMask&&(j(e,"category_mask"),P(r,"CATEGORY_MASK:category_mask"),Sr(this,"category_mask"),this.g.Z("category_mask",(i,n)=>{this.categoryMask=Cr(this,i,!1,!this.j),x(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,x(this,i)})),j(e,"quality_scores"),P(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(i,n)=>{this.qualityScores=i,x(this,n)}),this.g.attachEmptyPacketListener("quality_scores",i=>{this.categoryMask=void 0,x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ae.prototype.getLabels=Ae.prototype.Da,Ae.prototype.segmentForVideo=Ae.prototype.La,Ae.prototype.segment=Ae.prototype.segment,Ae.prototype.setOptions=Ae.prototype.o,Ae.createFromModelPath=function(e,t){return O(Ae,e,{baseOptions:{modelAssetPath:t}})},Ae.createFromModelBuffer=function(e,t){return O(Ae,e,{baseOptions:{modelAssetBuffer:t}})},Ae.createFromOptions=function(e,t){return O(Ae,e,t)};var Ps=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){var e,t;(e=this.confidenceMasks)==null||e.forEach(r=>{r.close()}),(t=this.categoryMask)==null||t.close()}};Ps.prototype.close=Ps.prototype.close;var ut=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new ps,this.u=new wc,I(this.h,0,3,this.u),I(e=this.h,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,r,i){const n=typeof r!="function"?r:{};if(this.j=typeof r=="function"?r:i,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.C+1,i=new bc,t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var s=new ms;kt(s,3,Kr(!0),!1),kt(s,1,qr(t.keypoint.x),0),kt(s,2,qr(t.keypoint.y),0),Jr(i,1,ys,s)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");{const c=new Lu;for(s of t.scribble)kt(t=new ms,3,Kr(!0),!1),kt(t,1,qr(s.x),0),kt(t,2,qr(s.y),0),zn(c,1,ms,t);Jr(i,2,ys,c)}}this.g.addProtoToStream(i.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),Re(this,e,n);e:{try{const c=new Ps(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var a=c;break e}this.j(c)}finally{Yi(this)}a=void 0}return a}m(){var e=new Oe;ee(e,"image_in"),ee(e,"roi_in"),ee(e,"norm_rect_in");const t=new Pe;at(t,mc,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),Y(r,"IMAGE:image_in"),Y(r,"ROI:roi_in"),Y(r,"NORM_RECT:norm_rect_in"),r.o(t),We(e,r),Ki(this,e),this.outputConfidenceMasks&&(j(e,"confidence_masks"),P(r,"CONFIDENCE_MASKS:confidence_masks"),Sr(this,"confidence_masks"),this.g.aa("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Cr(this,s,!0,!this.j)),x(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],x(this,i)})),this.outputCategoryMask&&(j(e,"category_mask"),P(r,"CATEGORY_MASK:category_mask"),Sr(this,"category_mask"),this.g.Z("category_mask",(i,n)=>{this.categoryMask=Cr(this,i,!1,!this.j),x(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,x(this,i)})),j(e,"quality_scores"),P(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(i,n)=>{this.qualityScores=i,x(this,n)}),this.g.attachEmptyPacketListener("quality_scores",i=>{this.categoryMask=void 0,x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ut.prototype.segment=ut.prototype.segment,ut.prototype.setOptions=ut.prototype.o,ut.createFromModelPath=function(e,t){return O(ut,e,{baseOptions:{modelAssetPath:t}})},ut.createFromModelBuffer=function(e,t){return O(ut,e,{baseOptions:{modelAssetBuffer:t}})},ut.createFromOptions=function(e,t){return O(ut,e,t)};var Ke=class extends Be{constructor(e,t){super(new Ze(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},I(e=this.h=new vc,0,1,t=new re)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?$(this.h,2,Xr(e.displayNamesLocale)):"displayNamesLocale"in e&&$(this.h,2),e.maxResults!==void 0?pt(this.h,3,e.maxResults):"maxResults"in e&&$(this.h,3),e.scoreThreshold!==void 0?C(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&$(this.h,4),e.categoryAllowlist!==void 0?Si(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&$(this.h,5),e.categoryDenylist!==void 0?Si(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&$(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},Re(this,e,t),this.j}G(e,t,r){return this.j={detections:[]},dt(this,e,r,t),this.j}m(){var e=new Oe;ee(e,"input_frame_gpu"),ee(e,"norm_rect"),j(e,"detections");const t=new Pe;at(t,Mu,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),Y(r,"IMAGE:input_frame_gpu"),Y(r,"NORM_RECT:norm_rect"),P(r,"DETECTIONS:detections"),r.o(t),We(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Ha(s),this.j.detections.push(_c(i));x(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ke.prototype.detectForVideo=Ke.prototype.G,Ke.prototype.detect=Ke.prototype.F,Ke.prototype.setOptions=Ke.prototype.o,Ke.createFromModelPath=async function(e,t){return O(Ke,e,{baseOptions:{modelAssetPath:t}})},Ke.createFromModelBuffer=function(e,t){return O(Ke,e,{baseOptions:{modelAssetBuffer:t}})},Ke.createFromOptions=function(e,t){return O(Ke,e,t)};var Os=class{constructor(e,t,r){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=r}close(){var e;(e=this.segmentationMasks)==null||e.forEach(t=>{t.close()})}};function nl(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function sl(e){try{const t=new Os(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.u)return t;e.u(t)}finally{Yi(e)}}Os.prototype.close=Os.prototype.close;var je=class extends Be{constructor(e,t){super(new Ze(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,I(e=this.h=new xc,0,1,t=new re),this.A=new dc,I(this.h,0,3,this.A),this.j=new lc,I(this.h,0,2,this.j),pt(this.j,4,1),C(this.j,2,.5),C(this.A,2,.5),C(this.h,4,.5)}get baseOptions(){return V(this.h,re,1)}set baseOptions(e){I(this.h,0,1,e)}o(e){return"numPoses"in e&&pt(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&C(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&C(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&C(this.A,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}F(e,t,r){const i=typeof t!="function"?t:{};return this.u=typeof t=="function"?t:r,nl(this),Re(this,e,i),sl(this)}G(e,t,r,i){const n=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:i,nl(this),dt(this,e,n,t),sl(this)}m(){var e=new Oe;ee(e,"image_in"),ee(e,"norm_rect"),j(e,"normalized_landmarks"),j(e,"world_landmarks"),j(e,"segmentation_masks");const t=new Pe;at(t,Du,this.h);const r=new Ce;Me(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Y(r,"IMAGE:image_in"),Y(r,"NORM_RECT:norm_rect"),P(r,"NORM_LANDMARKS:normalized_landmarks"),P(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),We(e,r),Ki(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(i,n)=>{this.landmarks=[];for(const s of i)i=ti(s),this.landmarks.push(Hi(i));x(this,n)}),this.g.attachEmptyPacketListener("normalized_landmarks",i=>{this.landmarks=[],x(this,i)}),this.g.attachProtoVectorListener("world_landmarks",(i,n)=>{this.worldLandmarks=[];for(const s of i)i=_r(s),this.worldLandmarks.push(ri(i));x(this,n)}),this.g.attachEmptyPacketListener("world_landmarks",i=>{this.worldLandmarks=[],x(this,i)}),this.outputSegmentationMasks&&(P(r,"SEGMENTATION_MASK:segmentation_masks"),Sr(this,"segmentation_masks"),this.g.aa("segmentation_masks",(i,n)=>{this.segmentationMasks=i.map(s=>Cr(this,s,!0,!this.u)),x(this,n)}),this.g.attachEmptyPacketListener("segmentation_masks",i=>{this.segmentationMasks=[],x(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};je.prototype.detectForVideo=je.prototype.G,je.prototype.detect=je.prototype.F,je.prototype.setOptions=je.prototype.o,je.createFromModelPath=function(e,t){return O(je,e,{baseOptions:{modelAssetPath:t}})},je.createFromModelBuffer=function(e,t){return O(je,e,{baseOptions:{modelAssetBuffer:t}})},je.createFromOptions=function(e,t){return O(je,e,t)},je.POSE_CONNECTIONS=Rc;const Ji="https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task",$u="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm",Wu=()=>{const e=d.useRef(null),[t,r]=d.useState(!1),[i,n]=d.useState("Initializing..."),[s,a]=d.useState(0),[c,l]=d.useState(!1);d.useEffect(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(w=>{console.log("ServiceWorker registered:",w)}).catch(w=>{console.log("ServiceWorker registration failed:",w)})},[]);const h=async()=>"caches"in window?await(await caches.open("mediapipe-models-v1")).match(Ji)!==void 0:!1,u=async()=>{try{const w=await fetch(Ji),g=w.headers.get("content-length"),p=g?parseInt(g,10):0;if(!w.body)throw new Error("No response body");const y=w.body.getReader();let m=0;const b=[];for(;;){const{done:v,value:F}=await y.read();if(v)break;if(b.push(F),m+=F.length,p){const A=Math.round(m/p*100);a(A),n(`Downloading model... ${A}%`)}}return"caches"in window&&await(await caches.open("mediapipe-models-v1")).put(Ji,new Response(new Blob(b),{headers:{"Content-Type":"application/octet-stream"}})),!0}catch(w){return console.error("Failed to preload model:",w),!1}};return d.useEffect(()=>{(async()=>{try{n("Checking cached models..."),await h()?n("Using cached model..."):(n("Model not cached. Downloading..."),await u()),n("Loading MediaPipe WASM...");const p=await Xt.forVisionTasks($u);n("Creating face landmarker...");const y=await te.createFromOptions(p,{baseOptions:{modelAssetPath:Ji,delegate:"GPU"},runningMode:"VIDEO",outputFaceBlendshapes:!0,numFaces:2});e.current=y,r(!0),n("Model loaded successfully ✅")}catch(g){console.error("Model init error:",g),n(`Error: ${g==null?void 0:g.message}`),(g==null?void 0:g.name)==="NotAllowedError"&&l(!0)}})()},[]),{faceLandmarkerRef:e,isModelLoaded:t,statusMessage:i,setStatusMessage:n,loadingProgress:s,permissionDenied:c,clearCache:async()=>{"caches"in window&&(await caches.delete("mediapipe-models-v1"),n("Cache cleared. Please refresh to re-download models."))}}},Hu=()=>{const[e,t]=d.useState(0),r=d.useRef({lastTime:0,frames:0,fps:0}),i=d.useCallback(()=>{const n=performance.now(),s=r.current;if(s.frames++,n-s.lastTime>=1e3){const a=Math.round(s.frames*1e3/(n-s.lastTime));t(a),s.frames=0,s.lastTime=n}},[]);return{fps:e,updateFPS:i}},qu=()=>{const e=d.useRef({value:100,isLookingAway:!1}),t=d.useCallback((s,a,c,l)=>{if(!s||!c||!a)return;const h=s.getContext("2d");if(!h)return;const{width:u,height:f}=s;if(h.clearRect(0,0,u,f),h.drawImage(a,0,0,u,f),l){h.fillStyle="#00FF00";for(const w of c)h.fillRect(w.x*u-.5,w.y*f-.5,1,1)}},[]),r=d.useCallback(s=>{const a=e.current.value/100,c=100,l=20,h=20,u=40;s.fillStyle="rgba(0, 0, 0, 0.3)",s.fillRect(h,u,l,c),s.fillStyle=`rgba(${Math.floor(255*(1-a))}, ${Math.floor(255*a)}, 0, 0.8)`;const f=c*a;s.fillRect(h,u+c-f,l,f),s.fillStyle="#FFFFFF",s.fillRect(h,u+c*(1-a),l,2)},[]),i=d.useCallback((s,a,c,l,h,u,f)=>{if(t(s,a,c,l),h&&u&&f){const w=s.getContext("2d");w&&r(w)}},[t,r]),n=d.useCallback((s,a)=>{const c=s.getContext("2d");c&&(c.clearRect(0,0,s.width,s.height),c.drawImage(a,0,0,s.width,s.height))},[]);return{drawLandmarks:t,drawEngagementBar:r,drawWithEngagementBar:i,clearCanvas:n,engagementRef:e}},Ku=50,Yu=()=>{const[e,t]=d.useState(100),[r,i]=d.useState(!1),n=d.useRef(0),s=d.useCallback((a,c,l)=>{if(!l||a.length<468)return;const h=a[33],u=a[263],f=a[1];if(!h||!u||!f)return;const w=(h.x+u.x)*.5,g=(h.y+u.y)*.5,p=w-c.x,y=g-c.y,m=Math.sqrt(p*p+y*y),b=Math.abs(f.y-c.noseY)*100,v=Math.abs(f.x-c.noseX)*100,F=Math.max(0,100-(m*200+b+v)),A=F<Ku,E=performance.now();return E-n.current>100&&(t(F),i(A),n.current=E),{engagement:F,isLookingAway:A}},[]);return{engagement:e,isLookingAway:r,analyzeGaze:s,setEngagement:t,setIsLookingAway:i}},Xu=.05,Qu=()=>{const[e,t]=d.useState(!1),[r,i]=d.useState(!1),n=d.useCallback((c,l)=>Math.sqrt(Math.pow(c.x-l.x,2)+Math.pow(c.y-l.y,2)),[]),s=d.useCallback((c,l)=>{if(!c||!l)return 0;const h=[1,33,263,61,291,10,152];let u=0,f=0;const w=l[33],g=l[263],p=c[33],y=c[263];if(!w||!g||!p||!y)return 0;const m=n(w,g),b=n(p,y);if(m===0||b===0)return 0;for(const F of h){const A=l[F],E=c[F];if(A&&E){const T=w.x+(E.x-p.x)*m/b,M=w.y+(E.y-p.y)*m/b;u+=n(A,{x:T,y:M}),f++}}return f===0?0:u/f},[n]),a=d.useCallback((c,l,h,u)=>{if(!c.faceLandmarks||c.faceLandmarks.length===0)return u("Face not detected."),i(!0),t(!1),null;if(l&&h){let f=null,w=0;for(const g of c.faceLandmarks)s(g,h)<Xu&&(f=g,w++);return w===1?(t(!1),i(!1),u("Reference face tracked."),f):w>1?(t(!0),i(!1),u("Multiple matching faces detected. Tracking suspended."),null):(t(!1),i(!0),u("Reference face not detected."),null)}else{const f=c.faceLandmarks[0];if(c.faceLandmarks.length>1)return t(!0),i(!1),u("Multiple faces detected. Please ensure only you are visible."),null;if(!f)return i(!0),t(!1),u("Face not detected."),null;const g=f[1],p=f[33],y=f[263];return g&&p&&y&&g.x>.35&&g.x<.65&&g.y>.3&&g.y<.7&&p.x>.2&&p.x<.8&&y.x>.2&&y.x<.8?(i(!1),t(!1),u("Face detected. Ready for calibration."),f):(i(!0),t(!1),u("Please position your face in the center."),null)}},[s]);return{multipleFacesDetected:e,referenceFaceNotDetected:r,analyzeFace:a,setMultipleFacesDetected:t,setReferenceFaceNotDetected:i}},Ju=500,Zu=(e,t)=>{const[r,i]=d.useState(!1),[n,s]=d.useState(Te.MODEL_LOADING),{incrementGazeViolation:a}=Ks(),{multipleFacesDetected:c,referenceFaceNotDetected:l,isLookingAway:h}=e;d.useEffect(()=>{let w;return(h||c||l)&&t?w=setTimeout(()=>{i(!0),h?(s("looking_away"),a("looking_away")):c?(s("multiple_faces"),a("multiple_faces")):l&&(s("no_face_detected"),a("no_face_detected"))},Ju):(i(!1),s("face_detected")),()=>{clearTimeout(w)}},[h,c,l,t,a]);const u=d.useCallback(()=>c?Te.MULTIPLE_FACES:l?"no_face_detected":h?Te.LOOKING_AWAY:n===Te.MODEL_LOADING?Te.MODEL_LOADING:Te.FACE_DETECTED,[c,l,h]),f=d.useCallback(()=>{i(!1),s("face_detected")},[]);return{showGazeWarningModal:r,faceDetectionState:n,getWarningType:u,closeWarningModal:f,setShowGazeWarningModal:i,setFaceDetectionState:s}};class W extends Error{constructor(t,r,i=!1){super(t),this.code=r,this.recoverable=i,this.name="STTError"}}const Ru=50*1024*1024;class ol{constructor(t={}){Se(this,"config");Se(this,"mediaRecorder",null);Se(this,"audioChunks",[]);Se(this,"audioChunksTotalSize",0);Se(this,"recordingStream",null);Se(this,"autoStopTimeoutId",null);Se(this,"disposed",!1);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...t}}updateConfig(t){this.throwIfDisposed(),this.config={...this.config,...t}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(t,r){var i;if(this.throwIfDisposed(),!this.isRecordingSupported())throw new W("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new W("Recording is already in progress","ALREADY_RECORDING",!0);try{this.recordingStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:44100}}),this.audioChunks=[],this.audioChunksTotalSize=0;const n=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:n}),this.mediaRecorder.addEventListener("dataavailable",s=>{var a,c,l;if(s.data.size>0){if(this.audioChunksTotalSize+s.data.size>Ru){console.error(`[STTService] Max size exceeded: ${(this.audioChunksTotalSize/1024/1024).toFixed(2)} MB`);const h=new W("Recording exceeded maximum size limit","MAX_SIZE_EXCEEDED",!1);(a=r==null?void 0:r.onError)==null||a.call(r,h),this.isRecording()&&((c=this.mediaRecorder)==null||c.stop());return}this.audioChunks.push(s.data),this.audioChunksTotalSize+=s.data.size,(l=r==null?void 0:r.onDataAvailable)==null||l.call(r,s.data)}}),this.mediaRecorder.addEventListener("stop",()=>{var s;(s=r==null?void 0:r.onStop)==null||s.call(r)},{once:!0}),this.mediaRecorder.addEventListener("error",s=>{var c;const a=new W(`Recording failed: ${s.error}`,"RECORDING_ERROR",!0);(c=r==null?void 0:r.onError)==null||c.call(r,a),this.cleanup()}),this.mediaRecorder.start(100),(i=r==null?void 0:r.onStart)==null||i.call(r),t&&t>0&&(this.autoStopTimeoutId=setTimeout(()=>{console.log(`[STTService] Auto-stop triggered after ${t} seconds.`),this.isRecording()?this.stopRecording().catch(s=>{console.error("[STTService] Auto-stop recording failed:",s),s instanceof W&&(console.error("[STTService] Error Name:",s.name),console.error("[STTService] Error Code:",s.code))}):console.log("[STTService] Recording was already stopped before auto-stop timeout.")},t*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new W("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new W("No microphone found","NO_MICROPHONE",!1)}throw new W(`Failed to start recording: ${n instanceof Error?n.message:String(n)}`,"START_RECORDING_FAILED",!0)}}async stopRecording(){var t;if(this.throwIfDisposed(),console.log("[STTService] stopRecording called. Current state:",{hasMediaRecorder:!!this.mediaRecorder,recorderState:(t=this.mediaRecorder)==null?void 0:t.state,isRecording:this.isRecording(),autoStopTimeoutId:!!this.autoStopTimeoutId}),this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||!this.isRecording()){const r=this.mediaRecorder?`State is ${this.mediaRecorder.state}`:"MediaRecorder is null";throw console.warn(`[STTService] Cannot stop recording: ${r}`),new W("No active recording to stop","NO_ACTIVE_RECORDING",!1)}return new Promise((r,i)=>{if(!this.mediaRecorder){i(new W("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const n=this.mediaRecorder,s=()=>{try{const a=n.mimeType||"audio/webm",c=new Blob(this.audioChunks,{type:a}),l=(c.size/1024/1024).toFixed(2);console.log(`[STTService] Recording stopped. Created blob: ${l} MB, Type: ${a}`),this.cleanup(),r(c)}catch(a){this.cleanup(),i(new W(`Failed to create audio blob: ${a instanceof Error?a.message:String(a)}`,"BLOB_CREATION_FAILED",!1))}};n.addEventListener("stop",s,{once:!0}),n.stop()})}async transcribe(t){this.throwIfDisposed();const{audioBlob:r}=t;if(!r||r.size===0)throw new W("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const i=new FormData,n=new File([r],"recording.wav",{type:r.type||"audio/wav"});if(i.append("file",n),i.append("qna_id",this.config.qnaId||""),!this.config.interviewId)throw new W("Interview ID is missing from configuration","MISSING_INTERVIEW_ID",!1);const s=await vt(`${this.config.baseUrl}${Et.TRANSCRIBE_ANSWER(this.config.interviewId)}`,{method:"POST",headers:{accept:"application/json","X-STT-Provider":this.config.provider||"groq",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:i},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!s.ok){const c=await s.text();let l=`STT request failed: ${s.status} ${s.statusText}`;try{const h=JSON.parse(c);l=h.message||h.error||l}catch{l=c||l}throw new W(l,`HTTP_${s.status}`,s.status>=500)}return{transcript:(await s.json()).data.transcribed_text??""}}catch(i){throw i instanceof W?i:new W(`Transcription failed: ${i instanceof Error?i.message:String(i)}`,"TRANSCRIPTION_FAILED",!0)}}cancelRecording(){this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),this.mediaRecorder&&this.isRecording()&&this.mediaRecorder.stop(),this.cleanup()}isRecording(){return this.mediaRecorder!==null&&this.mediaRecorder.state==="recording"}dispose(){this.disposed||(this.cancelRecording(),this.disposed=!0)}isDisposed(){return this.disposed}getSupportedMimeType(){const t=["audio/webm","audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4","audio/wav"];for(const r of t)if(MediaRecorder.isTypeSupported(r))return r;return"audio/webm"}getRecordingStream(){return this.recordingStream}cleanup(){this.recordingStream&&(this.recordingStream.getTracks().forEach(t=>t.stop()),this.recordingStream=null),this.mediaRecorder=null,this.audioChunks=[],this.audioChunksTotalSize=0,this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}throwIfDisposed(){if(this.disposed)throw new W("STTService has been disposed and cannot be reused","SERVICE_DISPOSED",!1)}}const e2=new ol,t2=(e,t,r,i)=>{const n=d.useRef(null);return d.useEffect(()=>{if(!t)return;const s=async()=>{try{const l=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}});e.current&&(e.current.srcObject=l,e.current.onloadeddata=()=>{r()})}catch(l){console.error("Camera access error:",l),i("Camera access failed")}},a=n.current,c=e.current;return s(),()=>{a&&cancelAnimationFrame(a),c!=null&&c.srcObject&&c.srcObject.getTracks().forEach(h=>h.stop())}},[t,r]),d.useEffect(()=>{const s=e2.getRecordingStream();if(s&&e.current){e.current.srcObject=s;const a=s.getVideoTracks(),c=s.getAudioTracks(),l=()=>{console.log("Media track ended - permission may have been revoked")};[...a,...c].forEach(h=>{h.addEventListener("ended",l)})}},[]),{animationFrameRef:n}},r2=(e,t,r,i,n,s,a,c,l,h,u,f,w,g,p)=>{const y=d.useRef(null),m=d.useCallback(()=>{const b=e.current,v=t.current,F=r.current;if(!b||b.readyState<2||!F||!v){y.current=requestAnimationFrame(m);return}i();try{const A=performance.now(),E=F.detectForVideo(b,A),T=n(E,l,h.current,g);T?(s(v,b,T,u,f,w,l),l&&w&&c(T,h.current,w)):a(v,b)}catch(A){console.error("Face detection error:",A)}y.current=requestAnimationFrame(m)},[e,t,r,i,n,s,a,c,l,h,u,f,w,g,p]);return{renderLoop:m,animationFrameRef:y}},i2=(e,t,r,i)=>{const{referenceSet:n,referenceRef:s,setReferenceData:a}=Ks(),c=d.useRef(s),l=d.useCallback(()=>{c.current=s},[s]),h=d.useCallback(()=>{var g;const f=e.current,w=t.current;if(console.log({faceLandmarker:f,video:w}),!(!f||!w))try{const p=performance.now(),y=f.detectForVideo(w,p);if((g=y.faceLandmarks)!=null&&g[0]){const m=y.faceLandmarks[0],b=m[33],v=m[263],F=m[1];b&&v&&F&&(c.current={x:(b.x+v.x)*.5,y:(b.y+v.y)*.5,noseX:F.x,noseY:F.y},a(!0,c.current),r("Reference set. Gaze tracking active."),console.log("Reference set. Gaze tracking active.",c.current),i&&i())}}catch(p){console.error("Set reference error:",p),r("Failed to set reference")}},[e,t,r,a,i]),u=d.useCallback(()=>{a(!1,{x:0,y:0,noseX:0,noseY:0}),r("Reference reset. Starting calibration...")},[a,r]);return{referenceSet:n,referenceRef:c,setReference:h,resetReference:u,syncReference:l}};function n2({onClose:e,warningType:t,isCheatingModalOpen:r=!1}){const i=eo[t],n=i.icon;return t==="face_detected"?null:o.jsx("div",{className:"iw-absolute iw-left-4 iw-right-4 md:iw-right-auto md:iw-w-[480px] iw-z-50 iw-animate-in iw-fade-in iw-slide-in-from-bottom-4 iw-duration-300 iw-transition-all",style:{bottom:r?"280px":"5rem"},children:o.jsxs("div",{className:"iw-relative iw-overflow-hidden iw-rounded-xl iw-border iw-border-dashed iw-border-[#5C6686] iw-bg-[#F1F5FE] iw-p-4 iw-shadow-2xl iw-backdrop-blur-sm",children:[o.jsx("button",{onClick:e,className:"iw-absolute iw-right-3 iw-top-3 iw-text-gray-400 iw-transition-colors iw-hover:iw-text-gray-600",children:o.jsx(fi,{className:"iw-h-5 iw-w-5"})}),o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-2",children:[o.jsx("div",{className:"iw-flex iw-size-8 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-full iw-border iw-border-[#5C6686]",children:o.jsx(n,{className:"iw-size-6 iw-text-[#5C6686]"})}),o.jsxs("div",{className:"iw-flex-1 iw-pt-0.5",children:[o.jsx("h2",{className:"iw-text-[20px] iw-font-semibold iw-leading-tight iw-text-[#062260] iw-pr-6",children:i.title}),o.jsx("p",{className:"iw-mt-1.5 iw-text-lg iw-text-[#5C6686]",children:i.subtitle}),i.description&&o.jsx("div",{className:"iw-mt-3 iw-border-t iw-border-dashed iw-border-[#5C6686] iw-pt-3",children:o.jsx("p",{className:"iw-text-[14px] iw-font-bold iw-text-[#062260]",children:i.description})})]})]})]})})}const s2=({status:e})=>{const t=eo[e];if(!t)return null;const r=e!=="face_detected";return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-gap-0.5",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2 iw-px-3 iw-py-1 iw-rounded-full iw-backdrop-blur-md iw-shadow-sm transition-colors duration-300 iw-text-white",children:[o.jsx("div",{className:`iw-flex iw-h-4 iw-w-4 iw-items-center iw-size-2.5 iw-justify-center iw-rounded-full iw-text-white ${e==="face_detected"?"iw-bg-[#22C55E]":e==="model_loading"?"iw-bg-[#062260]":"iw-bg-[#E94315]"}`,children:e==="face_detected"?o.jsx(hi,{}):e==="model_loading"?o.jsx("div",{className:"iw-animate-spin iw-border iw-border-white iw-border-t-transparent iw-rounded-full iw-w-2 iw-h-2"}):o.jsx(fi,{})}),o.jsx("span",{className:"iw-text-sm iw-font-medium",children:e==="face_detected"?"Face detected clearly":e==="camera_error"?"Camera not found":t.title})]}),r&&o.jsx("span",{className:"iw-text-white iw-text-center iw-text-xs iw-drop-shadow-sm iw-max-w-[400px] iw-px-3",children:e==="model_loading"?"Initializing Face models. Please wait...":e==="no_face_detected"?"Face not detected. Please position yourself clearly in the frame.":e==="multiple_faces"?"Multiple faces detected. Please ensure only you are visible.":"Please position your face correctly."})]})},al=d.forwardRef(({className:e="",interviewId:t="",interview_duration:r,showProctoringUI:i=!0,onSetReference:n,isAnswering:s,onProctoringStatusChange:a,showStatusOverlay:c=!1,cheatingWarningVisible:l=!1,isDeviceLoading:h=!1,videoAllowed:u=!0},f)=>{var El;const{authToken:w}=Qs(),g=w?jl(w):null,{borderRadius:p}=Zt(),y=p??18,{proctoring:m,capture_screenshots:b}=dn(),v=!!(m!=null&&m.gazeAnalysisEnabled),[F,A]=d.useState(!1),[E,T]=d.useState((m==null?void 0:m.showLandmarks)??!1),[M,N]=d.useState(i&&((m==null?void 0:m.showEngagementBar)??!0)),[L,z]=d.useState(v),[be,Q]=d.useState(!1),q=d.useRef(null),J=d.useRef(null),U=d.useRef(null),Z=d.useRef(null),et=d.useCallback(async xe=>{var nn;const ai=q.current,_e=U.current;if(!ai||!_e)return;const Pr=_e.getContext("2d");if(!Pr)return;_e.width=ai.videoWidth,_e.height=ai.videoHeight,Pr.save(),Pr.scale(-1,1),Pr.drawImage(ai,-_e.width,0,_e.width,_e.height),Pr.restore();const ci=await new Promise(Jt=>_e.toBlob(Jt,"image/jpeg"));if(ci&&t)try{const Jt=`${xe}-${Date.now()}.jpeg`,ke=await wi.requestScreenshotUploadUrl(t,Jt);ke.data&&ke.data.upload_url&&(await wi.uploadScreenshot((nn=ke==null?void 0:ke.data)==null?void 0:nn.upload_url,ci),ke.data.asset_id&&await wi.confirmScreenshotUpload(ke.data.asset_id))}catch(Jt){console.error(`Failed to upload screenshot for ${xe}:`,Jt)}},[wi,t]);d.useEffect(()=>{let xe;return s&&(Q(!0),xe=setTimeout(()=>Q(!1),1e3)),()=>{xe&&clearTimeout(xe)}},[s]);const{faceLandmarkerRef:bt,isModelLoaded:Ne,statusMessage:Ft,setStatusMessage:Ye,loadingProgress:Ar,permissionDenied:Lt,clearCache:Nr}=Wu(),{fps:Ir,updateFPS:ht}=Hu(),{drawWithEngagementBar:Mt,clearCanvas:le,engagementRef:tt}=qu(),{engagement:Fr,isLookingAway:Qt,analyzeGaze:js,setEngagement:en,setIsLookingAway:Lr}=Yu(),{multipleFacesDetected:ni,referenceFaceNotDetected:Mr,analyzeFace:zs,setMultipleFacesDetected:si,setReferenceFaceNotDetected:Dr}=Qu(),{referenceSet:oi,referenceRef:D,setReference:G,resetReference:Xe,syncReference:tn}=i2(bt,q,Ye,n),r1={multipleFacesDetected:ni,referenceFaceNotDetected:Mr,isLookingAway:Qt},{showGazeWarningModal:yl,getWarningType:rn,closeWarningModal:bl,setShowGazeWarningModal:vl,setFaceDetectionState:xl}=Zu(r1,v&&!c);d.useEffect(()=>{if(a){if(h||!Ne){a("model_loading");return}if(!u){a("camera_error");return}const xe=rn()||Te.NO_FACE;a(xe)}},[Ne,h,u,ni,Mr,Qt,rn,a]);const{renderLoop:i1}=r2(q,J,bt,ht,zs,Mt,le,js,oi,D,E,M,v,Ye,Dr);t2(q,Ne,i1,Ye),d.useEffect(()=>{tn()},[tn]),d.useEffect(()=>{tt&&tt.current&&(tt.current.value=Fr,tt.current.isLookingAway=Qt)},[Fr,Qt,tt]);const n1=d.useCallback(xe=>{z(xe),xe||(en(100),Lr(!1))},[en,Lr]),s1=d.useCallback(()=>{Lr(!1),si(!1),Dr(!1),xl("face_detected"),vl(!1),bl()},[Lr,si,Dr,xl,vl,bl]),o1={engagement:Fr,fps:Ir,isLookingAway:Qt,multipleFacesDetected:ni,referenceFaceNotDetected:Mr};return d.useEffect(()=>{if(!b)return;const xe=[];return(async()=>{try{const _e=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});Z.current=_e,q.current&&(q.current.srcObject=_e);const ci=(r??li)*60*1e3/3,nn=[0,1,2].map((ke,Dt)=>({label:`capture-${Dt+1}`,start:Dt*ci,end:(Dt+1)*ci})),Jt=(ke,Dt)=>ke===Dt?ke:Math.random()*(Dt-ke)+ke;nn.forEach(({label:ke,start:Dt,end:a1},c1)=>{let $s;c1===0?$s=3e3:$s=Jt(Dt,a1),xe.push(setTimeout(()=>{et(ke)},$s))})}catch(_e){console.error("Error accessing camera:",_e)}})(),()=>{Z.current&&Z.current.getTracks().forEach(_e=>_e.stop()),xe.forEach(clearTimeout)}},[et,b]),d.useImperativeHandle(f,()=>({setReference:()=>{G()},resetReference:()=>{Xe()},stopCamera:()=>{Z.current&&(Z.current.getTracks().forEach(xe=>xe.stop()),Z.current=null)}}),[G,Xe]),o.jsxs("div",{className:`iw-relative iw-h-full iw-w-full ${e}`,children:[Lt?o.jsxs("div",{className:"iw-rounded-md iw-border iw-border-red-600 iw-p-5 iw-text-red-600",children:[o.jsx("h2",{children:"Camera Permission Denied"}),o.jsx("p",{children:"Please allow camera access to use this application."})]}):o.jsx("div",{className:"iw-flex iw-w-full iw-h-full iw-justify-start iw-items-start",children:o.jsxs("div",{className:`iw-relative iw-max-w-full iw-max-h-full iw-aspect-video iw-rounded-2xl iw-overflow-hidden iw-bg-black ${be?"iw-animate-answer-start":""} ${s?"iw-border-4 iw-border-[#6296FB]":""}`,style:{width:"100%",height:"auto",minHeight:"0"},children:[o.jsx("video",{ref:q,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-absolute iw-inset-0 iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)"}}),!u&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-flex-col iw-items-center iw-justify-center iw-bg-black/60 iw-z-30",children:h||!Ne?o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-gap-3",children:[o.jsx("div",{className:"iw-w-5 iw-h-5 iw-border-2 iw-border-white/20 iw-border-t-white iw-rounded-full iw-animate-spin"}),o.jsx("span",{className:"iw-text-white/60 iw-text-xs iw-font-medium iw-tracking-wide",children:"Initializing camera..."})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"iw-text-white iw-font-medium iw-text-sm",children:"Camera not found"}),o.jsx("p",{className:"iw-text-white/60 iw-text-xs iw-mt-1",children:"Please ensure your camera is connected and enabled"})]})}),v&&o.jsx("canvas",{ref:J,width:320,height:240,className:"iw-absolute iw-inset-0 iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:y,display:"hidden"}}),o.jsx("canvas",{ref:U,style:{display:"none"}}),i&&o.jsxs("div",{className:"iw-absolute iw-top-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-[#FFEBE6] iw-px-2 iw-py-1 iw-backdrop-blur-md",children:[o.jsx("div",{className:"iw-size-2 iw-animate-pulse iw-rounded-full iw-bg-red-500"}),o.jsx("span",{className:"iw-font-medium iw-text-xs iw-text-[#E94315]",children:"RECORDING"})]}),i&&((El=g==null?void 0:g.data)==null?void 0:El.user_name)&&o.jsx("div",{className:"iw-absolute iw-z-50 iw-bottom-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-[#F1F5FE] iw-px-3 iw-py-1 iw-backdrop-blur-md",children:o.jsx("span",{className:"iw-font-medium iw-text-xs iw-text-[#062260]",children:g.data.user_name})}),i&&o.jsx("div",{className:"iw-absolute iw-bottom-4 iw-right-4",children:o.jsx(rd,{showControls:(m==null?void 0:m.showControls)??!1,isBubbleOpen:F,setIsBubbleOpen:A,setReference:G,clearCache:Nr,isModelLoaded:Ne,gazeAnalysisEnabled:L&&v,referenceSet:oi,showLandmarks:E,setShowLandmarks:T,showEngagementBar:M,setShowEngagementBar:N,handleToggleGazeAnalysis:n1,stats:o1,statusMessage:Ft,loadingProgress:Ar})}),c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"iw-absolute iw-inset-0 iw-pointer-events-none iw-z-10 ",style:{background:"radial-gradient(ellipse 20% 40% at 50% 45%, transparent 99.5%, rgba(0,0,0,0.35) 100%)"}}),o.jsx("div",{className:"iw-absolute iw-bottom-2 iw-inset-x-0 iw-flex iw-justify-center iw-pointer-events-none iw-z-20",children:o.jsx(s2,{status:u?h||!Ne?"model_loading":rn()??"no_face_detected":"camera_error"})})]})]})}),v&&yl&&!c&&o.jsx(n2,{isOpen:yl,onClose:s1,warningType:rn(),isCheatingModalOpen:l})]})}),Zi=({children:e,variant:t="primary",size:r="md",fullWidth:i=!1,isLoading:n=!1,disabled:s,className:a="",...c})=>{const l="iw-inline-flex iw-items-center iw-justify-center iw-rounded-md iw-font-medium iw-transition-colors iw-focus:outline-none iw-focus:ring-2 iw-focus:ring-primary-500 iw-focus:ring-offset-2",h={primary:"iw-bg-primary-600 iw-text-white iw-hover:bg-primary-700 iw-border iw-border-transparent",secondary:"iw-bg-primary-100 iw-text-primary-700 iw-hover:bg-primary-200 iw-border iw-border-transparent",outline:"iw-bg-transparent iw-text-primary-700 iw-border iw-border-primary-500 iw-hover:bg-primary-50",text:"iw-bg-transparent iw-text-primary-600 iw-hover:bg-primary-50 iw-border iw-border-transparent",gradient:"iw-text-white iw-border iw-border-transparent iw-bg-gradient-to-r iw-from-purple-500 iw-to-indigo-500 hover:iw-from-purple-600 hover:iw-to-indigo-600"},u={sm:"iw-px-3 iw-py-1.5 iw-text-sm",md:"iw-px-4 iw-py-2.5 iw-text-sm",lg:"iw-px-5 iw-py-3 iw-text-base"},f="iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none",w=i?"iw-w-full":"";return o.jsxs("button",{className:`${l} ${h[t]} ${u[r]} ${w} ${f} ${a}`,disabled:s||n,...c,children:[n&&o.jsx(Zs,{height:16,width:16,style:{marginRight:"3px"}}),e]})},o2=({stream:e,className:t="",barCount:r=50})=>{const i=d.useRef(null),n=d.useRef(null),s=d.useRef(null),a=d.useRef(null),c=d.useRef(null);d.useEffect(()=>{if(!e||window===void 0)return;a.current||(a.current=new(window.AudioContext||window.webkitAudioContext));const h=a.current;s.current||(s.current=h.createAnalyser(),s.current.fftSize=256,s.current.smoothingTimeConstant=.5);const u=s.current;try{c.current&&c.current.disconnect(),c.current=h.createMediaStreamSource(e),c.current.connect(u)}catch(w){console.error("Error creating media stream source:",w);return}const f=()=>{if(!i.current)return;const w=i.current,g=w.getContext("2d");if(!g)return;const p=u.frequencyBinCount,y=new Uint8Array(p);u.getByteFrequencyData(y);const m=w.width,b=w.height;g.clearRect(0,0,m,b);let v=0;for(let M=0;M<p;M++){const N=y[M]??0;v+=N*N}const F=Math.sqrt(v/p),A=Math.min(1,F/128);g.clearRect(0,0,m,b);const E=r,T=Math.floor(A*E);for(let M=0;M<E;M++){const N=M*(m/E),L=m/E-1.8;M<T?g.fillStyle="#0EB00E":g.fillStyle="#D9D9D9",g.fillRect(N,0,L,b)}n.current=requestAnimationFrame(f)};return f(),()=>{n.current&&cancelAnimationFrame(n.current)}},[e,r]);const l=d.useRef({audioContext:a.current,source:c.current});return l.current={audioContext:a.current,source:c.current},d.useEffect(()=>()=>{l.current.source&&l.current.source.disconnect(),l.current.audioContext&&l.current.audioContext.state!=="closed"&&l.current.audioContext.close()},[]),o.jsx("canvas",{ref:i,className:t,width:300,height:20,style:{width:"100%",height:"16px"}})},cl=({icon:e,devices:t,selectedId:r,onChange:i,label:n,showVisualizer:s=!1,stream:a=null,hasPermission:c=!0})=>{const{baseColor:l}=Zt(),[h,u]=d.useState(!1),f=d.useRef(null);d.useEffect(()=>{const p=y=>{f.current&&!f.current.contains(y.target)&&u(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]);const w=t.find(p=>p.deviceId===r)||t[0],g=c&&(w==null?void 0:w.label)||n;return o.jsxs("div",{className:"iw-relative iw-flex-1 iw-w-1/2 iw-group",ref:f,children:[o.jsxs("div",{className:`iw-max-w-[300px] iw-flex iw-items-center iw-justify-between iw-bg-white iw-border iw-border-gray-200 iw-rounded-xl iw-px-3 iw-py-3 iw-transition-colors ${c?"iw-cursor-pointer hover:iw-border-blue-500":"iw-cursor-not-allowed"}`,onClick:()=>c&&u(!h),title:c?"":"Permission denied or device not found",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3 iw-min-w-0 iw-max-w-[210px]",children:[o.jsx(e,{className:"iw-w-5 iw-h-5 iw-text-[#062260] iw-flex-shrink-0"}),o.jsx("span",{className:"iw-text-sm iw-text-[#062260] iw-font-medium iw-truncate",children:g})]}),o.jsx("div",{className:"iw-flex iw-items-center iw-gap-2",children:c?o.jsxs(o.Fragment,{children:[o.jsx(ql,{className:`iw-w-4 iw-h-4 iw-text-gray-400 iw-transition-transform ${h?"iw-rotate-180":""}`}),r&&o.jsx("div",{className:"iw-bg-[#22C55E] iw-rounded-full iw-p-0.5",children:o.jsx(hi,{className:"iw-w-3 iw-h-3 iw-text-white"})})]}):o.jsx("div",{className:"iw-text-[#E94315] iw-relative",children:o.jsx(ui,{className:"iw-size-5"})})})]}),!c&&o.jsx("div",{className:"iw-hidden group-hover:iw-block iw-absolute iw-bottom-full iw-mb-3 iw-left-1/6 -iw-translate-x-1/2 iw-w-64 iw-z-50",children:o.jsxs("div",{className:"iw-rounded-lg iw-p-3 iw-shadow-lg iw-text-white iw-text-left iw-relative",style:{background:l},children:[o.jsx("div",{className:"iw-flex iw-justify-between iw-items-start iw-mb-1",children:o.jsxs("h4",{className:"iw-text-sm iw-font-bold iw-mr-2",children:["Allow us to access your ",(n==null?void 0:n.split(" ")[1])??"device"]})}),o.jsx("p",{className:"iw-text-xs iw-opacity-90 iw-leading-tight",children:"We need permission to access your device. Go to your browser privacy settings to allow it"}),o.jsx("div",{className:"iw-absolute iw-top-full iw-left-1/2 -iw-translate-x-1/2 -iw-mt-1 iw-border-4 iw-border-transparent iw-border-t-[#5865F2]"})]})}),s&&c&&o.jsxs("div",{className:"iw-mt-2 iw-px-1 iw-flex iw-items-center iw-gap-2 iw-overflow-hidden",children:[o.jsx(Zl,{className:"iw-min-h-5 iw-min-w-5"}),o.jsx(o2,{stream:a,className:"iw-w-full"})]}),h&&c&&o.jsxs("div",{className:"iw-absolute iw-bottom-full iw-left-0 iw-right-0 iw-mb-2 iw-bg-white iw-border iw-border-gray-100 iw-rounded-xl iw-shadow-xl iw-z-50 iw-py-2 iw-max-h-60 iw-overflow-y-auto",children:[t.map(p=>o.jsxs("div",{className:`iw-px-4 iw-py-2.5 iw-text-sm iw-cursor-pointer iw-flex iw-items-center iw-justify-start hover:iw-bg-gray-50 ${r===p.deviceId?"iw-text-[#062260] iw-font-medium iw-bg-blue-50":"iw-text-gray-600"}`,onClick:()=>{i==null||i(p.deviceId),u(!1)},children:[r===p.deviceId&&o.jsx(hi,{className:"iw-w-4 iw-h-4 iw-text-[#062260] iw-mr-1"}),o.jsx("span",{className:"iw-truncate",children:p.label||`Device ${p.deviceId.slice(0,5)}...`})]},p.deviceId)),t.length===0&&o.jsx("div",{className:"iw-px-4 iw-py-2 iw-text-sm iw-text-gray-400",children:"No devices found"})]})]})},ll=({micEnabled:e=!1,videoEnabled:t=!1,buttonText:r,onButtonClick:i,isAgreed:n,onAgreedToggle:s,showCheckbox:a=!0,showMediaIcons:c=!0,disabled:l=!1,audioDevices:h=[],videoDevices:u=[],selectedAudioId:f,selectedVideoId:w,onAudioChange:g,onVideoChange:p,audioStream:y=null,isDeviceLoading:m=!1})=>{const b=l||!n||c&&(!e||!t)||m;return o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-4 iw-w-full",children:[a&&o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-bg-[#F1F5FE] iw-rounded-xl iw-p-3 iw-border iw-border-[#c2c3c7]",children:[o.jsx("div",{className:`iw-mt-0.5 iw-h-5 iw-w-5 iw-min-w-[20px] iw-rounded iw-border iw-flex iw-items-center iw-justify-center iw-cursor-pointer iw-transition-colors ${n?"iw-bg-[#062260] iw-border-[#062260]":"iw-bg-white iw-border-[#062260]"}`,onClick:v=>{v.stopPropagation(),s(!n)},children:n&&o.jsx(hi,{className:"iw-size-3 iw-text-white"})}),o.jsx("label",{onClick:()=>s(!n),className:"iw-text-sm iw-text-[#062260] iw-font-medium iw-cursor-pointer iw-select-none",children:"By continuing, you acknowledge and consent to the use of your face data exclusively for interview monitoring"})]}),o.jsx("div",{className:"iw-flex iw-justify-center iw-items-center iw-gap-4 iw-flex-wrap iw-max-w-[700px] iw-mx-auto",children:c&&o.jsxs("div",{className:"iw-flex iw-gap-4 iw-w-full",children:[o.jsx(cl,{icon:Xl,devices:h,selectedId:f??"",onChange:v=>g&&g(v),label:"Choose mic",showVisualizer:!0,stream:y,hasPermission:e}),o.jsx(cl,{icon:Jl,devices:u,selectedId:w??"",onChange:v=>p&&p(v),label:"Choose camera",hasPermission:t})]})}),o.jsxs("div",{className:"iw-relative iw-group iw-w-full iw-max-w-[280px] iw-mx-auto",children:[o.jsx(Zi,{onClick:i,disabled:b,className:`iw-h-12 iw-w-full !iw-bg-[#F1F5FE] !iw-text-[#062260] !iw-font-bold !iw-border-[#E7EAF1] iw-rounded-lg ${b?"iw-opacity-50":"hover:iw-opacity-75"}`,children:m?"Device Loading...":r}),!n&&(!c||e&&t)&&a2()]})]})},a2=()=>{const{baseColor:e}=Zt();return o.jsx(o.Fragment,{children:o.jsx("div",{className:"iw-hidden group-hover:iw-block iw-absolute iw-bottom-full iw-mb-3 iw-left-1/2 -iw-translate-x-1/2 iw-w-64 iw-z-50",children:o.jsxs("div",{className:"iw-rounded-lg iw-p-3 iw-shadow-lg iw-text-white iw-text-left iw-relative",style:{background:e},children:[o.jsx("div",{className:"iw-flex iw-justify-between iw-items-start iw-mb-1",children:o.jsx("h4",{className:"iw-text-sm iw-font-bold iw-mr-2",children:"Action Required"})}),o.jsx("p",{className:"iw-text-xs iw-opacity-90 iw-leading-tight",children:"Please check the box to acknowledge and consent to continue."}),o.jsx("div",{className:"iw-absolute iw-top-full iw-left-1/2 -iw-translate-x-1/2 -iw-mt-1 iw-border-4 iw-border-transparent iw-border-t-[#5865F2]"})]})})})},c2=({steps:e,currentStepIndex:t})=>o.jsx("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-4 iw-w-full iw-py-3",children:e.map((r,i)=>{const n=i<t,s=i===t;return o.jsxs(d.Fragment,{children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[o.jsx("div",{className:`iw-flex iw-size-9 iw-text-[#062260] iw-items-center iw-justify-center iw-rounded-full iw-font-semibold iw-border ${s||n?"iw-border-[#0EB00E] iw-bg-[#E9FFE6]":"iw-border-[#BDE0FD] iw-bg-[#E6F3FF]"}`,children:n?o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("polyline",{points:"20 6 9 17 4 12"})}):i+1}),o.jsx("span",{className:`iw-text-sm iw-font-medium ${s||n?"iw-text-[#062260]":"iw-text-[#5C6686]"}`,children:r.label})]}),i<e.length-1&&o.jsx("div",{className:"iw-flex-1 iw-max-w-[120px] iw-border-t iw-border-dotted iw-border-[#B3B9CB]"})]},i)})}),l2=["Don't refresh or reload the page during your assessment","Don't switch tabs or open other applications while session is ongoing","Don't leave your position during the session","Don't disable or interfere with video/audio monitoring"],d2=({isOpen:e,onStart:t,gazeEnabled:r=!1,videoFeedRef:i,interviewId:n="",interview_duration:s=li})=>{const{audioAllowed:a,videoAllowed:c,videoRef:l,audioDevices:h,videoDevices:u,selectedAudioDeviceId:f,selectedVideoDeviceId:w,isDeviceLoading:g,currentStream:p,handleAudioChange:y,handleVideoChange:m,stopStream:b}=$l(e),[v,F]=d.useState(!1),[A,E]=d.useState(0),[T,M]=d.useState(!1),N=d.useRef(null),L=d.useRef(null),z=U=>{N.current=U,i&&(typeof i=="function"?i(U):i.current=U)};if(d.useEffect(()=>()=>{L.current&&(clearInterval(L.current),L.current=null)},[]),!e)return null;const[be,Q]=d.useState(Te.MODEL_LOADING),q=async()=>{var Z;F(!0),(Z=N.current)==null||Z.resetReference();const U=()=>{var et;return(et=N.current)==null?void 0:et.setReference()};U(),L.current&&clearInterval(L.current),L.current=setInterval(U,500)},J=[{label:r?"Calibrate your camera":"Camera & Mic permission"},{label:"Basic guidelines"}];return o.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-gray-900/40 iw-backdrop-blur-sm iw-p-4 iw-pt-5 iw-overflow-auto",children:o.jsxs("div",{className:"iw-w-full iw-max-w-[700px] iw-max-h-[900px] iw-my-4 iw-bg-white iw-rounded-xl iw-shadow-2xl iw-overflow-auto",children:[o.jsxs("div",{className:"iw-px-5 iw-pt-3",children:[o.jsx("h2",{className:"iw-text-[#062260] iw-text-2xl iw-font-medium iw-tracking-tight",children:"Final checks before you go live"}),o.jsx("div",{className:"iw-mt-2 iw-bg-[#F1F5FE] iw-rounded-xl iw-p-2 iw-border iw-border-[#E7EAF1]",children:o.jsx("p",{className:"iw-text-[#5C6686] iw-text-xs iw-leading-relaxed",children:"To ensure the integrity of the interview process, this platform uses your device’s camera to monitor your face and gaze direction. We do not store any outside this session"})}),o.jsx("div",{className:"iw-mt-3 iw-border-b iw-border-dashed iw-border-[#B3B9CB] iw-w-full"}),o.jsx(c2,{steps:J,currentStepIndex:A})]}),o.jsx("div",{className:"iw-px-5 iw-pb-5 iw-flex iw-flex-col iw-items-center",children:A===0?o.jsxs("div",{className:"iw-w-full iw-flex iw-flex-col iw-items-center iw-gap-4",children:[o.jsx("div",{className:"iw-w-full iw-max-w-[600px] iw-aspect-video iw-bg-slate-100 iw-rounded-2xl iw-overflow-hidden iw-relative iw-border iw-border-slate-200",children:r?o.jsx(al,{ref:z,interviewId:n,interview_duration:s,showProctoringUI:!1,showStatusOverlay:!g&&c,isDeviceLoading:g,videoAllowed:c,onProctoringStatusChange:Q,onSetReference:()=>{L.current&&(clearInterval(L.current),L.current=null),F(!1),E(1)}}):o.jsx("video",{ref:l,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover",style:{transform:"scaleX(-1)"}})}),o.jsx(ll,{micEnabled:a,videoEnabled:c,buttonText:r?v?"Calibrating...":be==="model_loading"?"Initialising...":"Start calibrate":"Next",onButtonClick:()=>{r?q():E(1)},disabled:!T||r&&be!=="face_detected"||!r&&(!a||!c),isAgreed:T,onAgreedToggle:M,audioDevices:h,videoDevices:u,selectedAudioId:f,selectedVideoId:w,onAudioChange:y,onVideoChange:m,audioStream:p,isDeviceLoading:g})]}):o.jsxs("div",{className:"iw-w-full iw-flex iw-flex-col iw-gap-6",children:[o.jsx("div",{className:"iw-w-full iw-bg-[#F8FAFF] iw-rounded-2xl iw-p-8 iw-flex iw-flex-col iw-gap-5",children:l2.map((U,Z)=>o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-7 iw-w-7 iw-min-w-[28px] iw-items-center iw-justify-center iw-rounded-full iw-bg-[#DBEAFE] iw-text-[#062260] iw-text-xs iw-font-bold",children:Z+1}),o.jsx("span",{className:"iw-text-[#5C6686] iw-font-medium",children:U})]},Z))}),o.jsx(ll,{buttonText:"Start interview",onButtonClick:()=>{t(),b()},isAgreed:T,onAgreedToggle:M,showMediaIcons:!1})]})})]})})};var B=(e=>(e.IDLE="idle",e.FETCHING_QUESTION="fetching_question",e.READING_QUESTION="reading_question",e.THINKING="thinking",e.ANSWERING="answering",e.TRANSCRIBING="transcribing",e.EDITING="editing",e.SUBMITTING="submitting",e.COMPLETED="completed",e))(B||{});const dl={thinkingDuration:0,answeringDuration:120,editingDuration:30},ul={idle:{next:"fetching_question"},fetching_question:{next:"reading_question"},reading_question:{next:"answering"},thinking:{next:"answering",duration:0},answering:{next:"transcribing",duration:120},transcribing:{next:"editing"},editing:{next:"submitting",duration:30},submitting:{next:"completed"},completed:{next:"completed"}};class u2{constructor(t={},r={}){Se(this,"config");Se(this,"state");Se(this,"phaseIntervalId",null);Se(this,"globalIntervalId",null);Se(this,"callbacks");this.config={...dl,...t},this.callbacks=r,this.state={phase:"idle",currentPhaseTimeRemaining:0,totalTimeElapsed:0,currentQuestionNumber:0}}updateConfig(t){this.config={...this.config,...t}}getState(){return{...this.state}}startQuestion(){this.state.currentQuestionNumber===0&&this.startGlobalTimer(),this.state.currentQuestionNumber=this.state.currentQuestionNumber+1,this.state.phase="fetching_question",this.notifyChange()}nextPhase(){const t=this.state.phase;let r=ul[t];if(!r)return;if(r.next==="editing"&&this.config.editingDuration===0){const n=ul.editing;n&&(r=n)}this.stopPhaseTimer(),this.state.phase=r.next;const i=this.getDurationForPhase(r.next);i>0?(this.state.currentPhaseTimeRemaining=i,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}setTotalTimeElapsed(t){var r,i;this.state.totalTimeElapsed=t,(i=(r=this.callbacks).onTick)==null||i.call(r,this.getState())}completeInterview(){var t,r;this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(r=(t=this.callbacks).onInterviewEnd)==null||r.call(t),this.notifyChange()}destroy(){this.stopPhaseTimer(),this.stopGlobalTimer()}getDurationForPhase(t){switch(t){case"thinking":return this.config.thinkingDuration;case"answering":return this.config.answeringDuration;case"editing":return this.config.editingDuration;default:return 0}}startGlobalTimer(){this.globalIntervalId=setInterval(()=>{var t,r;this.state.totalTimeElapsed++,(r=(t=this.callbacks).onTick)==null||r.call(t,this.getState())},1e3)}stopGlobalTimer(){this.globalIntervalId&&(clearInterval(this.globalIntervalId),this.globalIntervalId=null)}startPhaseTimer(){this.phaseIntervalId=setInterval(()=>{this.state.currentPhaseTimeRemaining--,this.state.currentPhaseTimeRemaining<=0&&this.nextPhase()},1e3)}stopPhaseTimer(){this.phaseIntervalId&&(clearInterval(this.phaseIntervalId),this.phaseIntervalId=null)}notifyChange(){var t,r;(r=(t=this.callbacks).onPhaseChange)==null||r.call(t,this.state.phase,this.getState())}}function h2(e={}){const{config:t={},callbacks:r={}}=e,i=d.useRef(null);i.current||(i.current=new u2(t,{}));const n=i.current,[s,a]=d.useState(n.getState()),c=d.useCallback(()=>{a(n.getState())},[n]);d.useEffect(()=>{const f={onPhaseChange:(w,g)=>{var p;c(),(p=r.onPhaseChange)==null||p.call(r,w,g)},onTick:w=>{var g;c(),(g=r.onTick)==null||g.call(r,w)},onInterviewEnd:()=>{var w;c(),(w=r.onInterviewEnd)==null||w.call(r)}};n.callbacks=f},[n,r,c]),d.useEffect(()=>{n.updateConfig(t)},[n,t]),d.useEffect(()=>()=>{n.destroy()},[n]);const l=d.useCallback(()=>{n.startQuestion(),c()},[n,c]),h=d.useCallback(()=>{n.nextPhase(),c()},[n,c]),u=d.useCallback(()=>{n.completeInterview(),c()},[n,c]);return{state:s,startQuestion:l,nextPhase:h,completeInterview:u,timerService:n}}function f2(e,t={}){const[r,i]=d.useState({data:null,loading:!1,error:null}),n=d.useCallback(async(...s)=>{var a,c,l,h;i(u=>({...u,loading:!0,error:null}));try{const u=await e(...s);i(f=>({...f,data:u,loading:!1,error:null})),(a=t.onSuccess)==null||a.call(t,u),(c=t.onSettled)==null||c.call(t,u,null)}catch(u){const f=u.type?u:{type:"unknown",message:u.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:u};i(w=>({...w,loading:!1,error:f})),(l=t.onError)==null||l.call(t,f),(h=t.onSettled)==null||h.call(t,null,f)}},[e,t]);return{...r,execute:n}}const w2=e=>{const[t,r]=d.useState(null),[i,n]=d.useState(!1),s=document,a=()=>!!(s.fullscreenEnabled||s.webkitFullscreenEnabled||s.mozFullScreenEnabled||s.msFullscreenEnabled),c=()=>s.fullscreenElement||s.webkitFullscreenElement||s.mozFullScreenElement||s.msFullscreenElement,l=async g=>{var p;try{if(!a())throw new Error("Fullscreen is not supported in this environment");g.requestFullscreen?await g.requestFullscreen():g.webkitRequestFullscreen?await g.webkitRequestFullscreen():g.mozRequestFullScreen?await g.mozRequestFullScreen():g.msRequestFullscreen&&await g.msRequestFullscreen()}catch(y){const m={name:"FullscreenError",message:y instanceof Error?y.message:"Failed to enter fullscreen"};r(m),(p=e==null?void 0:e.onError)==null||p.call(e,m)}},h=async()=>{var g;try{s.exitFullscreen?await s.exitFullscreen():s.webkitExitFullscreen?await s.webkitExitFullscreen():s.mozCancelFullScreen?await s.mozCancelFullScreen():s.msExitFullscreen&&await s.msExitFullscreen()}catch(p){const y={name:"FullscreenError",message:p instanceof Error?p.message:"Failed to exit fullscreen"};r(y),(g=e==null?void 0:e.onError)==null||g.call(e,y)}},u=d.useCallback(()=>{var p;const g=!!c();n(g),(p=e==null?void 0:e.onFullScreenChange)==null||p.call(e,g)},[e]);d.useEffect(()=>{const g=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return g.forEach(p=>{document.addEventListener(p,u)}),()=>{g.forEach(p=>{document.removeEventListener(p,u)})}},[u]);const f=async g=>{r(null);const p=g??document.documentElement;await l(p)};return{isFullScreen:i,toggleFullScreen:async g=>{i?await h():await f(g)},enterFullScreen:f,exitFullScreen:h,error:t}};function hl(){const e=di();return d.useMemo(()=>{const r=e.api||{};return new to(r)},[e.api])}const g2=e=>{d.useEffect(()=>{const t=i=>{(i.ctrlKey||i.metaKey)&&["c","v","a","t","n","w","r","s","p"].includes(i.key.toLowerCase())&&(i.preventDefault(),e({type:"blocked_shortcut",severity:"low",details:{action:"shortcut_pressed",reason:`Attempted to use a blocked keyboard shortcut: Ctrl + ${i.key}`}})),i.key.startsWith("F")&&i.key.length<=3&&(i.preventDefault(),e({type:"blocked_function_key",severity:"low",details:{action:"function_key_pressed",reason:`Attempted to use a blocked function key: ${i.key}`}})),i.altKey&&i.key==="Tab"&&(i.preventDefault(),e({type:"alt_tab_attempt",severity:"medium",details:{action:"alt_tab",reason:"Attempted to use the Alt + Tab shortcut"}}))},r=i=>{i.preventDefault(),e({type:"right_click_attempt",severity:"low",details:{action:"right_click",reason:"Attempted to use the right click"}})};return document.addEventListener("keydown",t),document.addEventListener("contextmenu",r),()=>{document.removeEventListener("keydown",t),document.removeEventListener("contextmenu",r)}},[e])},p2=(e={})=>{const[t,r]=d.useState(!1),[i,n]=d.useState(!1),[s,a]=d.useState(null),[c,l]=d.useState(null),[h,u]=d.useState(null),f=d.useRef(e);f.current=e;const w=d.useRef(null);w.current||(w.current=new ol(e.config)),d.useEffect(()=>{var b;e.config&&((b=w.current)==null||b.updateConfig(e.config))},[e.config]),d.useEffect(()=>{const b=w.current;return()=>{b==null||b.dispose(),w.current=null}},[]);const g=d.useCallback(async b=>{var F,A;const v=w.current;if(!v||v.isDisposed())throw new W("STT service is not available","SERVICE_UNAVAILABLE",!1);try{l(null),a(null),u(null),await v.startRecording(b,{onStart:()=>{var E,T;r(!0),(T=(E=f.current).onStart)==null||T.call(E)},onStop:()=>{var E,T;r(!1),(T=(E=f.current).onStop)==null||T.call(E)},onError:E=>{var M,N;const T=E instanceof W?E:new W(E.message,"RECORDING_ERROR",!0);l(T),r(!1),(N=(M=f.current).onError)==null||N.call(M,T)}})}catch(E){const T=E instanceof W?E:new W(E instanceof Error?E.message:String(E),"START_FAILED",!1);throw l(T),r(!1),(A=(F=f.current).onError)==null||A.call(F,T),T}},[]),p=d.useCallback(async()=>{var v,F;const b=w.current;if(!b||b.isDisposed())throw new W("STT service is not available","SERVICE_UNAVAILABLE",!1);try{const A=await b.stopRecording(),E=(A.size/1024/1024).toFixed(2);return console.log(`[useSTT] Received audio blob: ${E} MB`),u(A),A}catch(A){const E=A instanceof W?A:new W(A instanceof Error?A.message:String(A),"STOP_FAILED",!1);throw l(E),r(!1),(F=(v=f.current).onError)==null||F.call(v,E),E}},[]),y=d.useCallback(async(b,v={})=>{var A,E,T,M;const F=w.current;if(!F||F.isDisposed())throw new W("STT service is not available","SERVICE_UNAVAILABLE",!1);try{l(null),n(!0);const N=(b.size/1024/1024).toFixed(2);console.log(`[useSTT] Starting transcription for blob: ${N} MB`);const L={audioBlob:b,...v},z=await F.transcribe(L);return console.log(`[useSTT] Transcription complete. Text length: ${z.transcript.length}`),a(z.transcript),n(!1),(E=(A=f.current).onTranscriptionComplete)==null||E.call(A,z),z}catch(N){const L=N instanceof W?N:new W(N instanceof Error?N.message:String(N),"TRANSCRIPTION_FAILED",!0);throw l(L),n(!1),(M=(T=f.current).onError)==null||M.call(T,L),L}},[]),m=d.useCallback(()=>{var b;(b=w.current)==null||b.cancelRecording(),r(!1),u(null)},[]);return{startRecording:g,stopRecording:p,transcribe:y,cancelRecording:m,isRecording:t,isTranscribing:i,transcript:s,error:c,audioBlob:h}},m2=e=>{const t=d.useRef(null),r=d.useRef(!1);d.useEffect(()=>{const i=()=>{document.hidden&&(r.current=!0,t.current&&(clearTimeout(t.current),t.current=null),e({type:"tab_switch",severity:"high",details:{action:"tab_hidden",reason:"Attempted to switch tabs or applications"}}),setTimeout(()=>{r.current=!1},100))},n=()=>{r.current||(t.current=setTimeout(()=>{r.current||e({type:"focus_loss",severity:"medium",details:{action:"window_blur",reason:"Focus lost from the interview window"}}),t.current=null},50))};return document.addEventListener("visibilitychange",i),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",i),window.removeEventListener("blur",n),t.current&&clearTimeout(t.current)}},[e])},y2=()=>{d.useEffect(()=>{const e=document.createElement("style");return e.textContent=`
16
16
  * {
17
17
  -webkit-user-select: none !important;
18
18
  -moz-user-select: none !important;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "interview-widget",
3
3
  "type": "module",
4
- "version": "3.2.3",
4
+ "version": "3.2.4",
5
5
  "description": "Advanced React interview widget with STT, TTS, camera access, and ML-powered analysis",
6
6
  "main": "dist/widget.umd.js",
7
7
  "module": "dist/widget.es.js",