interview-widget 2.0.1 → 2.0.2

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.
@@ -1,4 +1,4 @@
1
- (function(me,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],d):(me=typeof globalThis<"u"?globalThis:me||self,d(me.InterviewWidget={},me.React,me.ReactDOM))})(this,function(me,d,ir){"use strict";var Dh=Object.defineProperty;var Rh=(me,d,ir)=>d in me?Dh(me,d,{enumerable:!0,configurable:!0,writable:!0,value:ir}):me[d]=ir;var Oe=(me,d,ir)=>Rh(me,typeof d!="symbol"?d+"":d,ir);var en=typeof document<"u"?document.currentScript:null,qs={exports:{}},ei={};/**
1
+ (function(we,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],d):(we=typeof globalThis<"u"?globalThis:we||self,d(we.InterviewWidget={},we.React,we.ReactDOM))})(this,function(we,d,tr){"use strict";var Rh=Object.defineProperty;var Oh=(we,d,tr)=>d in we?Rh(we,d,{enumerable:!0,configurable:!0,writable:!0,value:tr}):we[d]=tr;var Oe=(we,d,tr)=>Oh(we,typeof d!="symbol"?d+"":d,tr);var rn=typeof document<"u"?document.currentScript:null,Ks={exports:{}},ei={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,21 +6,21 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var El=Symbol.for("react.transitional.element"),Sl=Symbol.for("react.fragment");function Ys(e,t,r){var i=null;if(r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),"key"in t){r={};for(var n in t)n!=="key"&&(r[n]=t[n])}else r=t;return t=r.ref,{$$typeof:El,type:e,key:i,ref:t!==void 0?t:null,props:r}}ei.Fragment=Sl,ei.jsx=Ys,ei.jsxs=Ys,qs.exports=ei;var o=qs.exports;const tn={},et={api:{baseUrl:"/api",retryConfig:{attempts:3,backoff:"exponential",baseDelay:1e3}},ui:{baseColor:"#3B82F6",borderRadius:"8px"},interview:{timers:{thinkingDuration:30,answeringDuration:120,editingDuration:30},stt:{provider:"groq",model:"whisper-large-v3-turbo",language:"en"},tts:{provider:"piper"},proctoring:{enabled:!0,gazeAnalysisEnabled:!0}}},rn="iw-storage";function Al(){if(!(typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:en&&en.tagName.toUpperCase()==="SCRIPT"&&en.src||new URL("widget.umd.js",document.baseURI).href}<"u"&&(tn!=null&&tn.VITE_IW_SECRET)))return typeof process<"u"&&process.env.NEXT_PUBLIC_IW_SECRET?process.env.NEXT_PUBLIC_IW_SECRET:typeof window<"u"&&window.__IW_SECRET__?window.__IW_SECRET__:"proctoring-data-seed"}const Ks=Al(),ti=30,Tl={SCREENSHOT:"screenshot"},nn="AES-GCM",sn=12;async function Xs(e){const r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return crypto.subtle.importKey("raw",i,nn,!1,["encrypt","decrypt"])}function jl(){return crypto.getRandomValues(new Uint8Array(sn))}async function Nl(e,t="default-seed"){try{const r=typeof e=="string"?e:JSON.stringify(e),n=new TextEncoder().encode(r),s=await Xs(t),a=jl(),c=await crypto.subtle.encrypt({name:nn,iv:a},s,n),l=new Uint8Array(a.length+c.byteLength);return l.set(new Uint8Array(a),0),l.set(new Uint8Array(c),a.length),btoa(String.fromCharCode(...Array.from(l)))}catch(r){throw console.error("Encryption failed:",r),new Error("Failed to encrypt data")}}async function Cl(e,t="default-seed"){try{const r=atob(e),i=new Uint8Array(r.length);for(let u=0;u<r.length;u++)i[u]=r.charCodeAt(u);const n=i.slice(0,sn),s=i.slice(sn),a=await Xs(t),c=await crypto.subtle.decrypt({name:nn,iv:n},a,s);return new TextDecoder().decode(c)}catch(r){throw console.error("Decryption failed:",r),new Error("Failed to decrypt data")}}async function Il(e,t="default-seed"){return Nl(e,t)}async function Ml(e,t="default-seed"){const r=await Cl(e,t);try{return JSON.parse(r)}catch{return r}}const Mr=d.createContext(null),Ll=async()=>{try{const e=sessionStorage.getItem(rn);if(e){const r=(await Ml(e,Ks)).state;return{logViolations:(r==null?void 0:r.logViolations)||[],totalViolations:(r==null?void 0:r.totalViolations)||0,gazeViolationCounters:(r==null?void 0:r.gazeViolationCounters)||{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:(r==null?void 0:r.referenceSet)??!1,referenceRef:(r==null?void 0:r.referenceRef)??{x:.5,y:.5,noseX:.5,noseY:.5}}}}catch(e){console.error("Failed to load proctoring data from session storage:",e)}return{logViolations:[],totalViolations:0,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:!1,referenceRef:{x:.5,y:.5,noseX:.5,noseY:.5}}},Lr=async e=>{try{const t=await Il({state:e,version:0},Ks);sessionStorage.setItem(rn,t)}catch(t){console.error("Failed to save proctoring data to session storage:",t)}},Fl=({children:e})=>{const t=d.useRef({logViolations:[],totalViolations:0,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:!1,referenceRef:{x:.5,y:.5,noseX:.5,noseY:.5}}),r=d.useRef(new Set);d.useEffect(()=>{Ll().then(w=>{t.current=w,i()})},[]);const i=d.useCallback(()=>{r.current.forEach(w=>w())},[]),n=d.useCallback(w=>(r.current.add(w),()=>{r.current.delete(w)}),[]),s=d.useCallback(()=>t.current,[]),a=d.useCallback(w=>{t.current={...t.current,logViolations:[...t.current.logViolations,w],totalViolations:t.current.totalViolations+1},Lr(t.current),i()},[i]),c=d.useCallback(w=>{const m={...t.current.gazeViolationCounters};w==="looking_away"&&(m.lookingAwayCount+=1),w==="no_face_detected"&&(m.noFaceDetectedCount+=1),w==="multiple_faces"&&(m.multipleFacesCount+=1),m.totalGazeViolations=m.lookingAwayCount+m.noFaceDetectedCount+m.multipleFacesCount,t.current={...t.current,gazeViolationCounters:m},Lr(t.current),i()},[i]),l=d.useCallback(()=>{t.current={...t.current,logViolations:[],totalViolations:0},Lr(t.current),i()},[i]),u=d.useCallback(()=>{t.current={...t.current,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0}},Lr(t.current),i()},[i]),h=d.useCallback((w,m)=>{t.current={...t.current,referenceSet:w,referenceRef:m},Lr(t.current),i()},[i]),f=d.useMemo(()=>({getState:s,addViolation:a,clearViolations:l,subscribe:n,incrementGazeViolation:c,clearGazeViolationCounters:u,setReferenceData:h}),[s,a,l,n,c,u,h]);return o.jsx(Mr.Provider,{value:f,children:e})},Qs=()=>{const e=d.useContext(Mr);if(!e)throw new Error("useProctoringStore must be used within a ProctoringProvider");const t=d.useSyncExternalStore(e.subscribe,e.getState,e.getState);return{logViolations:t.logViolations,totalViolations:t.totalViolations,addViolation:e.addViolation,clearViolations:e.clearViolations,gazeViolationCounters:t.gazeViolationCounters,referenceSet:t.referenceSet,referenceRef:t.referenceRef,incrementGazeViolation:e.incrementGazeViolation,clearGazeViolationCounters:e.clearGazeViolationCounters,setReferenceData:e.setReferenceData}},Pl=()=>{const e=d.useContext(Mr);if(!e)throw new Error("useViolations must be used within a ProctoringProvider");return d.useSyncExternalStore(e.subscribe,()=>e.getState().logViolations,()=>e.getState().logViolations)},Dl=()=>{const e=d.useContext(Mr);if(!e)throw new Error("useTotalViolations must be used within a ProctoringProvider");return d.useSyncExternalStore(e.subscribe,()=>e.getState().totalViolations,()=>e.getState().totalViolations)},Rl=()=>{const e=d.useContext(Mr);if(!e)throw new Error("useProctoringActions must be used within a ProctoringProvider");return{addViolation:e.addViolation,clearViolations:e.clearViolations}},Js=d.createContext(null);function Zs({config:e={},children:t}){var i,n,s,a;const r={api:{...et.api,...e.api,retryConfig:{...et.api.retryConfig,...(i=e.api)==null?void 0:i.retryConfig}},ui:{...et.ui,...e.ui},interview:{...et.interview,...e.interview,timers:{...et.interview.timers,...(n=e.interview)==null?void 0:n.timers},stt:{...et.interview.stt,...(s=e.interview)==null?void 0:s.stt},tts:{...et.interview.tts,...(a=e.interview)==null?void 0:a.tts}}};return o.jsx(Js.Provider,{value:r,children:o.jsx(Fl,{children:t})})}function ri(){const e=d.useContext(Js);if(!e)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return e}function eo(){return ri().api||et.api}function nr(){return ri().ui||et.ui}function on(){return ri().interview||et.interview}const to=({className:e,...t})=>o.jsx("div",{children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`iw-animate-spin ${e}`,...t,children:[o.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),o.jsx("path",{d:"M12 6l0 -3"}),o.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),o.jsx("path",{d:"M18 12l3 0"}),o.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),o.jsx("path",{d:"M12 18l0 3"}),o.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),o.jsx("path",{d:"M6 12l-3 0"}),o.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),ro=({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",u={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"},h={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} ${u[t]} ${h[r]} ${w} ${f} ${a}`,disabled:s||n,...c,children:[n&&o.jsx(to,{height:16,width:16,style:{marginRight:"3px"}}),e]})};function Ol(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function Bl(e,t,r){return"#"+[e,t,r].map(i=>{const n=Math.round(i).toString(16);return n.length===1?"0"+n:n}).join("")}function io(e,t){const r=Ol(e);if(!r)return e;const i=r.r+(255-r.r)*t,n=r.g+(255-r.g)*t,s=r.b+(255-r.b)*t;return Bl(i,n,s)}function Ul(e,t=.8){return{background:`linear-gradient(to bottom, ${io(e,t)}, #ffffff)`,color:"#1f2937"}}function Gl(e){return new Promise(t=>setTimeout(t,e))}function no(e){return`linear-gradient(to left, ${io(e,.4)}, ${e})`}const Vl=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);function $l(e){try{const t=e.split(".");if(t.length!==3||!t[1])throw new Error("Invalid JWT token");const i=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=i.padEnd(i.length+(4-i.length%4)%4,"="),s=atob(n);return JSON.parse(s)}catch(t){return console.error("Error decoding JWT:",t),null}}const Wl=e=>{var t;return!e||typeof e!="string"?"":(t=e.charAt(0))==null?void 0:t.toUpperCase()},so=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]}),oo=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),o.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),o.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),zl=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),o.jsx("path",{d:"M15 8a5 5 0 0 1 0 8"}),o.jsx("path",{d:"M6 15h-2a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h2l3.5 -4.5a.8 .8 0 0 1 1.5 .5v14a.8 .8 0 0 1 -1.5 .5l-3.5 -4.5"})]}),qe=e=>{const{baseColor:t,borderRadius:r}=nr(),{loading:i,children:n,...s}=e;return o.jsx(ro,{style:{background:no(t),borderRadius:r},...s,children:i?o.jsx(to,{}):n})},ii=({isOpen:e,onClose:t,children:r,title:i,showCloseButton:n=!0,closeOnOverlayClick:s=!0,closeOnEscape:a=!0,className:c=""})=>{if(d.useEffect(()=>{if(!e||!a)return;const h=f=>{f.key==="Escape"&&t()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,a,t]),d.useEffect(()=>(e?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[e]),!e)return null;const l=h=>{s&&h.target===h.currentTarget&&t()},u=o.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center",children:[o.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",onClick:l}),o.jsxs("div",{className:`iw-relative iw-bg-white iw-rounded-lg iw-shadow-xl iw-max-w-md iw-w-full iw-mx-4 iw-max-h-[90vh] iw-overflow-hidden ${c}`,role:"dialog","aria-modal":"true","aria-labelledby":i?"dialog-title":void 0,children:[(i||n)&&o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[i&&o.jsx("h2",{id:"dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:i}),n&&o.jsx("button",{onClick:t,className:"iw-p-1 iw-text-gray-400 iw-hover:text-gray-600 iw-transition-colors iw-rounded iw-hover:bg-gray-100","aria-label":"Close dialog",children:o.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:r})]})]});return ir.createPortal(u,document.body)},Hl=e=>o.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-info-icon prefix__lucide-info",...e,children:[o.jsx("circle",{cx:12,cy:12,r:10}),o.jsx("path",{d:"M12 16v-4M12 8h.01"})]}),ql=e=>o.jsx("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-scan-face-icon prefix__lucide-scan-face",...e,children:o.jsx("path",{d:"M3 7V5a2 2 0 012-2h2M17 3h2a2 2 0 012 2v2M21 17v2a2 2 0 01-2 2h-2M7 21H5a2 2 0 01-2-2v-2M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01"})});function Yl({isOpen:e,onDecline:t,onContinue:r}){return o.jsx(ii,{isOpen:e,showCloseButton:!1,onClose:t,className:"iw-overflow-y-auto",children:e&&o.jsx("div",{className:"iw-bg-white iw-border-slate-200 iw-rounded-2xl iw-p-0 iw-shadow-xl sm:iw-max-w-xl",children:o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-4",children:[o.jsx("div",{className:"iw--mt-0.5 iw-h-2.5 iw-w-full iw-rounded-t-2xl iw-bg-gradient-to-r iw-from-blue-500 iw-to-indigo-500"}),o.jsx("div",{className:"iw-sr-only",children:"Face Data Usage Notice"}),o.jsx("div",{className:"iw-sr-only",children:"Permission to use face data for interview monitoring"}),o.jsxs("div",{className:"iw-px-8 iw-py-8",children:[o.jsxs("div",{className:"iw-text-center",children:[o.jsx("div",{className:"iw-mx-auto iw-mb-6 iw-flex iw-h-16 iw-w-16 iw-items-center iw-justify-center iw-rounded-full iw-border iw-border-blue-200 iw-bg-gradient-to-br iw-from-blue-50 iw-to-blue-100 iw-shadow-sm iw-ring-1 iw-ring-blue-100",children:o.jsx(ql,{className:"iw-text-blue-600"})}),o.jsx("h1",{className:"iw-text-zinc-700 iw-mb-6 iw-text-2xl iw-font-semibold iw-tracking-tight",children:"Face Data Usage Notice"})]}),o.jsxs("ul",{className:"iw-mb-4 iw-list-item iw-space-y-4 iw-text-sm iw-leading-relaxed iw-text-gray-700",children:[o.jsx("li",{children:"To ensure the integrity of the interview process, this platform uses your device's camera to monitor your face and gaze direction."}),o.jsx("li",{children:"Your face data is processed only for proctoring purposes (e.g., detecting if you are looking away or off-screen)."}),o.jsx("li",{children:"All processing is limited to the interview session and is used solely to maintain fairness."})]}),o.jsxs("div",{className:"iw-text-zinc-700 iw-flex iw-items-start iw-gap-2 iw-rounded-md iw-border iw-border-blue-100 iw-bg-blue-50/60 iw-p-3 iw-text-sm iw-font-medium",children:[o.jsx(Hl,{className:"iw-text-neutral-400 iw-mt-0.5 iw-inline-block iw-size-4 iw-flex-shrink-0"}),o.jsx("p",{className:"",children:"Please note that we do not store, share, or use your biometric data beyond the scope of this interview."})]}),o.jsx("p",{className:"iw-text-neutral-400 iw-my-4 iw-text-center iw-text-sm",children:"By continuing, you acknowledge and consent to the use of your face data exclusively for interview monitoring purposes."}),o.jsxs("div",{className:"iw-flex iw-gap-3 iw-border-t iw-border-gray-200/80 iw-pt-6",children:[o.jsx(qe,{onClick:t,className:"iw-flex-1 iw-border",children:"Decline"}),o.jsx(qe,{onClick:r,className:"iw-flex-1",children:"I Understand & Continue"})]})]})]})})})}function Kl(e){var t;if(!navigator.onLine)return{type:"network",message:"No internet connection",retryable:!0,userMessage:"Please check your internet connection and try again."};if(e.name==="AbortError"||(t=e.message)!=null&&t.includes("timeout"))return{type:"timeout",message:"Request timed out",retryable:!0,userMessage:"The request is taking longer than expected. Please try again."};if(e.status){const{status:r}=e;if(r===401||r===403)return{type:"auth",status:r,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(r===429)return{type:"rate-limit",status:r,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(r>=500)return{type:"server",status:r,message:`Server error: ${r}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(r>=400)return{type:"client",status:r,message:`Client error: ${r}`,retryable:!1,userMessage:"There was an issue with your request. Please check your input."}}return{type:"unknown",message:e.message||"Unknown error occurred",retryable:!0,userMessage:"Something unexpected happened. Please try again.",originalError:e}}async function Gt(e,t={},r={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let i;for(let n=1;n<=r.attempts;n++)try{const s=new AbortController,a=setTimeout(()=>s.abort(),6e4),c=await fetch(e,{...t,signal:s.signal});if(clearTimeout(a),c.status>=400&&c.status<500&&c.status!==429)return c;if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);return c}catch(s){i=s;const a=Kl(s);if(!a.retryable||n===r.attempts)throw a;const c=Xl(n,r);console.warn(`API request failed (attempt ${n}/${r.attempts}), retrying in ${c}ms:`,a.message),await new Promise(l=>setTimeout(l,c))}throw i}function Xl(e,t){let r;return t.backoff==="exponential"?r=t.baseDelay*Math.pow(2,e-1):r=t.baseDelay,r=Math.min(r,t.maxDelay),t.jitter&&(r=r*(.5+Math.random()*.5)),Math.round(r)}const Vt={v2:"/v2"},$t={GENERATE_QUESTION:e=>`${Vt.v2}/interviews/${e}/next-question`,SCREENSHOT_UPLOAD:e=>`${Vt.v2}/interviews/${e}/assets/upload-url`,CONFIRM_UPLOAD:e=>`${Vt.v2}/interviews/assets/${e}/confirm`,TRANSCRIBE_ANSWER:e=>`${Vt.v2}/interviews/${e}/transcribe-answer`,SUBMIT_ANSWER:e=>`${Vt.v2}/interviews/${e}/submit-answer`,EXIT:e=>`${Vt.v2}/interviews/${e}/exit`,CONFIG:e=>`${Vt.v2}/interviews/${e}/config`};class Ql{constructor(t={}){Oe(this,"config");this.config=t}updateConfig(t){this.config={...this.config,...t}}getHeaders(){var r;const t={"Content-Type":"application/json"};return(r=this.config)!=null&&r.authToken&&(t.Authorization=`Bearer ${this.config.authToken}`),t}getBaseUrl(){var t;return((t=this.config)==null?void 0:t.baseUrl)||"/api"}async generateQuestion({interviewId:t,isInterviewDone:r=!1}){const i=await Gt(`${this.getBaseUrl()}${$t.GENERATE_QUESTION(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:t,is_interview_done:r})});if(!i.ok)throw new Error(`Failed to get questions: ${i.status}`);return await i.json()}async submitAnswer({interviewId:t,qnaId:r,answer:i}){const n=await Gt(`${this.getBaseUrl()}${$t.SUBMIT_ANSWER(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({qna_id:r,answer_text:i})});if(!n.ok)throw new Error(`Failed to submit answer: ${n.status}`);return await n.json()}async exitInterview(t){const r=await Gt(`${this.getBaseUrl()}${$t.EXIT(t)}`,{method:"POST",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to exit interview: ${r.status}`)}async getInterviewConfig(t){const r=await Gt(`${this.getBaseUrl()}${$t.CONFIG(t)}`,{method:"GET",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to get interview config: ${r.status}`);return await r.json()}async requestScreenshotUploadUrl(t,r=`screenshot-${Date.now()}.jpeg`){const i=await Gt(`${this.getBaseUrl()}${$t.SCREENSHOT_UPLOAD(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({filename:r,mime_type:"image/jpeg",asset_type:Tl.SCREENSHOT})});if(!i.ok)throw new Error(`Failed to request screenshot upload URL: ${i.status}`);return await i.json()}async uploadScreenshot(t,r){const i=await fetch(t,{method:"PUT",body:r,headers:{"Content-Type":"image/jpeg"}});if(!i.ok)throw new Error(`Failed to upload screenshot: ${i.status}`)}async confirmScreenshotUpload(t){const r=await Gt(`${this.getBaseUrl()}${$t.CONFIRM_UPLOAD(t)}`,{method:"POST",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to confirm screenshot upload: ${r.status}`)}}function ao(){const e=ri();return d.useMemo(()=>{const r=e.api||{};return new Ql(r)},[e.api])}const Fr=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),o.jsx("path",{d:"M12 9v4"}),o.jsx("path",{d:"M12 17h.01"})]}),an=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),o.jsx("path",{d:"M12 6v6l4 2"}),o.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),o.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),o.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),o.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),Jl=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M12 6v6l4 2"}),o.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),co=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Zl=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),o.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),o.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),o.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),cn=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),o.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),o.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),o.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),eu=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),o.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),o.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),o.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),tu=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-bolt-icon prefix__lucide-bolt",...e,children:[o.jsx("path",{d:"M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"}),o.jsx("circle",{cx:12,cy:12,r:4})]}),ru=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-camera-off-icon prefix__lucide-camera-off",...e,children:[o.jsx("path",{d:"M14.564 14.558a3 3 0 11-4.122-4.121M2 2l20 20"}),o.jsx("path",{d:"M20 20H4a2 2 0 01-2-2V9a2 2 0 012-2h1.997a2 2 0 00.819-.175M9.695 4.024A2 2 0 0110.004 4h3.993a2 2 0 011.76 1.05l.486.9A2 2 0 0018.003 7H20a2 2 0 012 2v7.344"})]}),iu=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-target-icon prefix__lucide-target",...e,children:[o.jsx("circle",{cx:12,cy:12,r:10}),o.jsx("circle",{cx:12,cy:12,r:6}),o.jsx("circle",{cx:12,cy:12,r:2})]}),nu=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-users-icon prefix__lucide-users",...e,children:[o.jsx("path",{d:"M16 21v-2a4 4 0 00-4-4H6a4 4 0 00-4 4v2M16 3.128a4 4 0 010 7.744M22 21v-2a4 4 0 00-3-3.87"}),o.jsx("circle",{cx:9,cy:7,r:4})]}),Pr={FACE_DETECTED:"face_detected",NO_FACE:"no_face_detected",MULTIPLE_FACES:"multiple_faces",LOOKING_AWAY:"looking_away",CAMERA_ERROR:"camera_error"},su={[Pr.FACE_DETECTED]:{icon:co,iconColor:"iw-text-green-600",iconBg:"iw-bg-green-50",iconBorder:"iw-border-green-100",title:"All Good",subtitle:"Everything looks normal",description:"Your gaze is properly focused on the screen. Continue with your interview.",buttonText:"Continue"},[Pr.NO_FACE]:{icon:ru,iconColor:"iw-text-orange-600",iconBg:"iw-bg-orange-50",iconBorder:"iw-border-orange-100",title:"Face Not Detected",subtitle:"We can't see you in the camera",description:"Please ensure you're positioned properly in front of the camera and that your face is clearly visible.",buttonText:"I Understood"},[Pr.MULTIPLE_FACES]:{icon:nu,iconColor:"iw-text-red-600",iconBg:"iw-bg-red-50",iconBorder:"iw-border-red-100",title:"Multiple People Detected",subtitle:"More than one person is visible",description:"For interview integrity, please ensure you are alone in the room and only your face is visible to the camera.",buttonText:"I Understood"},[Pr.LOOKING_AWAY]:{icon:iu,iconColor:"iw-text-amber-600",iconBg:"iw-bg-amber-50",iconBorder:"iw-border-amber-200/75",title:"Stay Focused",subtitle:"We noticed you looked away from the screen",description:"To ensure interview integrity, please keep your attention on the screen throughout the session.",buttonText:"I Understood"},[Pr.CAMERA_ERROR]:{icon:Fr,iconColor:"iw-text-red-600",iconBg:"iw-bg-red-50",iconBorder:"iw-border-red-100",title:"Camera Issue",subtitle:"There's a problem with your camera",description:"Please check your camera connection and permissions, then refresh the page to continue.",buttonText:"I Understood"}};function ou({isOpen:e,onClose:t,warningType:r}){const i=su[r],n=i.icon,s=()=>{t()};return r==="face_detected"?null:o.jsx(ii,{isOpen:e,onClose:t,children:e&&o.jsx("div",{className:"iw-bg-white iw-border-white iw-border iw-p-0 iw-shadow-lg sm:iw-max-w-md",children:o.jsxs("div",{children:[o.jsx("div",{className:"iw-sr-only",children:i.description}),o.jsxs("div",{className:"iw-px-8 iw-py-8 iw-text-center",children:[o.jsx("div",{className:`iw-mx-auto iw-mb-6 iw-flex iw-h-16 iw-w-16 iw-items-center iw-justify-center iw-rounded-full ${i.iconBg} border ${i.iconBorder}`,children:o.jsx(n,{className:`iw-h-7 iw-w-7 ${i.iconColor}`})}),o.jsx("h1",{className:"iw-text-foreground iw-mb-3 iw-text-2xl iw-font-bold iw-tracking-tight",children:i.title}),o.jsx("h2",{className:"iw-text-gray-500 iw-mb-6 iw-text-base iw-font-medium",children:i.subtitle}),o.jsx("p",{className:"iw-text-neutral-400 iw-mx-auto iw-mb-8 iw-max-w-sm iw-text-sm iw-leading-relaxed",children:i.description}),o.jsx(qe,{onClick:s,className:"iw-w-full iw-bg-gray-800 iw-text-white hover:iw-bg-gray-800",children:i.buttonText})]})]})})})}const au=({gazeAnalysisEnabled:e,isModelLoaded:t,stats:r,statusMessage:i,loadingProgress:n})=>o.jsx("div",{className:"iw-w-full",children:o.jsxs("div",{className:"iw-border-strock iw-rounded-md iw-border iw-bg-gray-50 iw-p-4",children:[o.jsxs("h3",{className:"iw-m-0 iw-mb-2.5",children:["Status: ",i]}),n>0&&n<100&&o.jsxs("div",{className:"iw-mb-2.5",children:[o.jsx("div",{className:"iw-h-2 iw-w-full iw-rounded iw-bg-gray-300",children:o.jsx("div",{className:"iw-h-full iw-rounded iw-bg-blue-600 iw-transition-all iw-duration-300 iw-ease-out",style:{width:`${n}%`}})}),o.jsxs("small",{className:"iw-text-gray-600",children:["Loading model... ",n.toFixed(1),"%"]})]}),o.jsxs("div",{className:"iw-grid iw-grid-cols-2 iw-gap-2.5 iw-text-sm",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"FPS:"})," ",o.jsx("span",{className:r.fps<15?"iw-text-red-600":r.fps<25?"iw-text-orange-500":"iw-text-green-600",children:r.fps})]}),o.jsxs("div",{children:[o.jsx("strong",{children:"Model:"})," ",t?"✓ Loaded":"✗ Loading"]}),e&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("strong",{children:"Engagement:"})," ",r.engagement.toFixed(1),"%"]}),o.jsxs("div",{children:[o.jsx("strong",{children:"Looking:"})," ",o.jsx("span",{className:r.isLookingAway?"iw-text-red-600":"iw-text-green-600",children:r.isLookingAway?"Away":"At Screen"})]})]})]}),r.referenceFaceNotDetected&&o.jsxs("div",{className:"iw-text-gray-dark iw-mt-2.5 iw-w-full iw-rounded-md iw-bg-[#ffeb3b] iw-p-2.5 iw-text-sm",children:[o.jsx("strong",{children:"Reference Face Not Detected"}),o.jsx("br",{}),"The previously set reference face is no longer in view."]}),r.multipleFacesDetected&&o.jsxs("div",{className:"iw-mt-2.5 iw-rounded iw-bg-red-50 iw-p-2.5 iw-text-sm iw-text-red-700",children:[o.jsx("strong",{children:"Multiple Faces Detected"}),o.jsx("br",{}),"Please ensure only one person is in the frame."]}),!e&&o.jsxs("div",{className:"iw-mt-2.5 iw-rounded iw-bg-blue-50 iw-p-2.5 iw-text-sm iw-text-blue-700",children:[o.jsx("strong",{children:"Gaze Analysis Disabled"}),o.jsx("br",{}),"Enable to track engagement and attention levels."]})]})}),cu=({showControls:e,isBubbleOpen:t,setIsBubbleOpen:r,setReference:i,clearCache:n,isModelLoaded:s,gazeAnalysisEnabled:a,referenceSet:c,showLandmarks:l,setShowLandmarks:u,showEngagementBar:h,setShowEngagementBar:f,handleToggleGazeAnalysis:w,stats:m,statusMessage:g,loadingProgress:b})=>e?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>r(!t),className:"iw-absolute iw-right-4 iw-bottom-4 iw-z-10 iw-flex iw-h-10 iw-w-10 iw-items-center iw-justify-center iw-rounded-full iw-text-white",children:o.jsx(tu,{className:"iw-size-4.5"})}),t&&o.jsxs("div",{className:"iw-absolute iw-right-4 iw-bottom-16 iw-z-10 iw-max-h-96 iw-w-80 iw-overflow-y-auto iw-rounded-md iw-bg-gray-50 iw-p-4 iw-shadow-lg",children:[o.jsx("h4",{className:"m-0 mb-2.5",children:"Controls"}),o.jsx("button",{onClick:i,disabled:!s||!a,className:`iw-mb-2.5 iw-block iw-w-full iw-rounded border-none iw-px-4 iw-py-2 iw-text-sm iw-text-white ${!s||!a?"iw-cursor-not-allowed iw-bg-gray-400":"iw-cursor-pointer iw-bg-blue-600 hover:iw-bg-blue-700"}`,children:c?"Reference Set ✓":"Set Reference"}),o.jsx("button",{onClick:n,className:"iw-mb-4 iw-block iw-w-full iw-cursor-pointer iw-rounded iw-border-none iw-bg-red-600 iw-px-4 iw-py-2 iw-text-sm iw-text-white hover:iw-bg-red-700",children:"Clear Model Cache"}),o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-2.5",children:[o.jsxs("label",{className:"iw-flex iw-cursor-pointer iw-items-center iw-gap-2",children:[o.jsx("input",{type:"checkbox",checked:a,onChange:_=>w(_.target.checked)}),o.jsx("strong",{children:"Enable Gaze Analysis"})]}),o.jsxs("label",{className:`iw-flex iw-cursor-pointer iw-items-center iw-gap-2 ${a?"iw-opacity-100":"iw-opacity-60"}`,children:[o.jsx("input",{type:"checkbox",checked:l,onChange:_=>u(_.target.checked),disabled:!a}),"Show Landmarks"]}),o.jsxs("label",{className:`iw-flex iw-cursor-pointer iw-items-center iw-gap-2 ${a?"iw-opacity-100":"iw-opacity-60"}`,children:[o.jsx("input",{type:"checkbox",checked:h,onChange:_=>f(_.target.checked),disabled:!a}),"Show Engagement Bar"]})]}),c&&o.jsx(au,{gazeAnalysisEnabled:a,isModelLoaded:s,loadingProgress:b,stats:m,statusMessage:g})]})]}):null;var sr=typeof self<"u"?self:{};function Wt(){throw Error("Invalid UTF8")}function lo(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}let ni,ln;const lu=typeof TextDecoder<"u";let uu;const du=typeof TextEncoder<"u";function uo(e){if(du)e=(uu||(uu=new TextEncoder)).encode(e);else{let r=0;const i=new Uint8Array(3*e.length);for(let n=0;n<e.length;n++){var t=e.charCodeAt(n);if(t<128)i[r++]=t;else{if(t<2048)i[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&n<e.length){const s=e.charCodeAt(++n);if(s>=56320&&s<=57343){t=1024*(t-55296)+s-56320+65536,i[r++]=t>>18|240,i[r++]=t>>12&63|128,i[r++]=t>>6&63|128,i[r++]=63&t|128;continue}n--}t=65533}i[r++]=t>>12|224,i[r++]=t>>6&63|128}i[r++]=63&t|128}}e=r===i.length?i:i.subarray(0,r)}return e}var un,si;e:{for(var ho=["CLOSURE_FLAGS"],dn=sr,hn=0;hn<ho.length;hn++)if((dn=dn[ho[hn]])==null){si=null;break e}si=dn}var Dr,fo=si&&si[610401301];un=fo!=null&&fo;const wo=sr.navigator;function fn(e){return!!un&&!!Dr&&Dr.brands.some(({brand:t})=>t&&t.indexOf(e)!=-1)}function Be(e){var t;return(t=sr.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function St(){return!!un&&!!Dr&&Dr.brands.length>0}function wn(){return St()?fn("Chromium"):(Be("Chrome")||Be("CriOS"))&&!(!St()&&Be("Edge"))||Be("Silk")}function oi(e){return oi[" "](e),e}Dr=wo&&wo.userAgentData||null,oi[" "]=function(){};var hu=!St()&&(Be("Trident")||Be("MSIE"));!Be("Android")||wn(),wn(),Be("Safari")&&(wn()||!St()&&Be("Coast")||!St()&&Be("Opera")||!St()&&Be("Edge")||(St()?fn("Microsoft Edge"):Be("Edg/"))||St()&&fn("Opera"));var mo={},Rr=null;function fu(e){const t=e.length;let r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);const i=new Uint8Array(r);let n=0;return function(s,a){function c(u){for(;l<s.length;){const h=s.charAt(l++),f=Rr[h];if(f!=null)return f;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return u}go();let l=0;for(;;){const u=c(-1),h=c(0),f=c(64),w=c(64);if(w===64&&u===-1)break;a(u<<2|h>>4),f!=64&&(a(h<<4&240|f>>2),w!=64&&a(f<<6&192|w))}}(e,function(s){i[n++]=s}),n!==r?i.subarray(0,n):i}function go(){if(!Rr){Rr={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const i=e.concat(t[r].split(""));mo[r]=i;for(let n=0;n<i.length;n++){const s=i[n];Rr[s]===void 0&&(Rr[s]=n)}}}}var po=typeof Uint8Array<"u",xo=!hu&&typeof btoa=="function";function yo(e){if(!xo){var t;t===void 0&&(t=0),go(),t=mo[t];var r=Array(Math.floor(e.length/3)),i=t[64]||"";let l=0,u=0;for(;l<e.length-2;l+=3){var n=e[l],s=e[l+1],a=e[l+2],c=t[n>>2];n=t[(3&n)<<4|s>>4],s=t[(15&s)<<2|a>>6],a=t[63&a],r[u++]=c+n+s+a}switch(c=0,a=i,e.length-l){case 2:a=t[(15&(c=e[l+1]))<<2]||i;case 1:e=e[l],r[u]=t[e>>2]+t[(3&e)<<4|c>>4]+a+i}return r.join("")}for(t="",r=0,i=e.length-10240;r<i;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}const bo=/[-_.]/g,wu={"-":"+",_:"/",".":"="};function mu(e){return wu[e]||""}function vo(e){if(!xo)return fu(e);bo.test(e)&&(e=e.replace(bo,mu)),e=atob(e);const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function zt(e){return po&&e!=null&&e instanceof Uint8Array}var or={};function Ht(){return gu||(gu=new ft(null,or))}function mn(e){_o(or);var t=e.g;return(t=t==null||zt(t)?t:typeof t=="string"?vo(t):null)==null?t:e.g=t}var ft=class{h(){return new Uint8Array(mn(this)||0)}constructor(e,t){if(_o(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}};let gu,pu;function _o(e){if(e!==or)throw Error("illegal external caller")}function ko(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function gn(e){return ko(e=Error(e),"warning"),e}function pn(e){if(e!=null){var t=pu??(pu={}),r=t[e]||0;r>=5||(t[e]=r+1,ko(e=Error(),"incident"),function(i){sr.setTimeout(()=>{throw i},0)}(e))}}var ai=typeof Symbol=="function"&&typeof Symbol()=="symbol";function ar(e,t,r=!1){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?r&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t}var xu=ar("jas",void 0,!0),Eo=ar(void 0,"0di"),Or=ar(void 0,"1oa"),cr=ar(void 0,Symbol()),yu=ar(void 0,"0actk"),So=ar(void 0,"8utk");const k=ai?xu:"Ea",Ao={Ea:{value:0,configurable:!0,writable:!0,enumerable:!1}},To=Object.defineProperties;function ci(e,t){ai||k in e||To(e,Ao),e[k]|=t}function ce(e,t){ai||k in e||To(e,Ao),e[k]=t}function lr(e){return ci(e,34),e}function bu(e,t){ce(t,-15615&(0|e))}function xn(e,t){ce(t,-15581&(34|e))}function li(){return typeof BigInt=="function"}function ke(e){return Array.prototype.slice.call(e)}var yn,Br={};function ui(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function bn(e,t){if(e!=null){if(typeof e=="string")e=e?new ft(e,or):Ht();else if(e.constructor!==ft)if(zt(e))e=e.length?new ft(new Uint8Array(e),or):Ht();else{if(!t)throw Error();e=void 0}}return e}const jo=[];function At(e){if(2&e)throw Error()}ce(jo,55),yn=Object.freeze(jo);class No{constructor(t,r,i){this.g=t,this.h=r,this.l=i}next(){const t=this.g.next();return t.done||(t.value=this.h.call(this.l,t.value)),t}[Symbol.iterator](){return this}}function vn(e){return cr?e[cr]:void 0}var vu=Object.freeze({});function di(e){return e.Na=!0,e}var _u=di(e=>typeof e=="number"),Co=di(e=>typeof e=="string"),ku=di(e=>typeof e=="boolean"),hi=typeof sr.BigInt=="function"&&typeof sr.BigInt(0)=="bigint";function Tt(e){var t=e;if(Co(t)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(t))throw Error(String(t))}else if(_u(t)&&!Number.isSafeInteger(t))throw Error(String(t));return hi?BigInt(e):e=ku(e)?e?"1":"0":Co(e)?e.trim()||"0":String(e)}var _n=di(e=>hi?e>=Su&&e<=Tu:e[0]==="-"?Io(e,Eu):Io(e,Au));const Eu=Number.MIN_SAFE_INTEGER.toString(),Su=hi?BigInt(Number.MIN_SAFE_INTEGER):void 0,Au=Number.MAX_SAFE_INTEGER.toString(),Tu=hi?BigInt(Number.MAX_SAFE_INTEGER):void 0;function Io(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){const i=e[r],n=t[r];if(i>n)return!1;if(i<n)return!0}}const ju=typeof Uint8Array.prototype.slice=="function";let Mo,U=0,Q=0;function Lo(e){const t=e>>>0;U=t,Q=(e-t)/4294967296>>>0}function qt(e){if(e<0){Lo(-e);const[t,r]=An(U,Q);U=t>>>0,Q=r>>>0}else Lo(e)}function kn(e){const t=Mo||(Mo=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),Q=0,U=t.getUint32(0,!0)}function En(e,t){const r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Ur(e,t)}function Sn(e,t){const r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=En(e,t))=="number"?r?-e:e:r?"-"+e:e}function Ur(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else li()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+Fo(r)+Fo(e));return r}function Fo(e){return e=String(e),"0000000".slice(e.length)+e}function Po(){var e=U,t=Q;if(2147483648&t)if(li())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{const[r,i]=An(e,t);e="-"+Ur(r,i)}else e=Ur(e,t);return e}function fi(e){if(e.length<16)qt(Number(e));else if(li())e=BigInt(e),U=Number(e&BigInt(4294967295))>>>0,Q=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+(e[0]==="-");Q=U=0;const r=e.length;for(let i=t,n=(r-t)%6+t;n<=r;i=n,n+=6){const s=Number(e.slice(i,n));Q*=1e6,U=1e6*U+s,U>=4294967296&&(Q+=Math.trunc(U/4294967296),Q>>>=0,U>>>=0)}if(t){const[i,n]=An(U,Q);U=i,Q=n}}}function An(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}const Gr=typeof BigInt=="function"?BigInt.asIntN:void 0,Nu=typeof BigInt=="function"?BigInt.asUintN:void 0,jt=Number.isSafeInteger,wi=Number.isFinite,ur=Math.trunc,Cu=Tt(0);function Nt(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function Do(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}const Iu=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Vr(e){switch(typeof e){case"bigint":return!0;case"number":return wi(e);case"string":return Iu.test(e);default:return!1}}function dr(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return wi(e)?0|e:void 0}function Ro(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return wi(e)?e>>>0:void 0}function Oo(e){if(e[0]==="-")return!1;const t=e.length;return t<20||t===20&&Number(e.substring(0,6))<184467}function Bo(e){const t=e.length;return e[0]==="-"?t<20||t===20&&Number(e.substring(0,7))>-922337:t<19||t===19&&Number(e.substring(0,6))<922337}function Uo(e){return Bo(e)?e:(fi(e),Po())}function Tn(e){return e=ur(e),jt(e)||(qt(e),e=Sn(U,Q)),e}function Go(e){var t=ur(Number(e));return jt(t)?String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Uo(e))}function Vo(e){var t=ur(Number(e));return jt(t)?Tt(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),li()?Tt(Gr(64,BigInt(e))):Tt(Uo(e)))}function $o(e){if(jt(e))e=Tt(Tn(e));else{if(e=ur(e),jt(e))e=String(e);else{const t=String(e);Bo(t)?e=t:(qt(e),e=Po())}e=Tt(e)}return e}function jn(e){return e==null?e:typeof e=="bigint"?(_n(e)?e=Number(e):(e=Gr(64,e),e=_n(e)?Number(e):String(e)),e):Vr(e)?typeof e=="number"?Tn(e):Go(e):void 0}function Mu(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(Nu(64,e));if(Vr(e)){if(t==="string")return t=ur(Number(e)),jt(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Oo(e)||(fi(e),e=Ur(U,Q))),e;if(t==="number")return(e=ur(e))>=0&&jt(e)?e:function(r){if(r<0){qt(r);var i=Ur(U,Q);return r=Number(i),jt(r)?r:i}return Oo(i=String(r))?i:(qt(r),En(U,Q))}(e)}}function Wo(e){if(typeof e!="string")throw Error();return e}function hr(e){if(e!=null&&typeof e!="string")throw Error();return e}function fr(e){return e==null||typeof e=="string"?e:void 0}function Nn(e,t,r,i){if(e!=null&&typeof e=="object"&&e.W===Br)return e;if(!Array.isArray(e))return r?2&i?((e=t[Eo])||(lr((e=new t).u),e=t[Eo]=e),t=e):t=new t:t=void 0,t;let n=r=0|e[k];return n===0&&(n|=32&i),n|=2&i,n!==r&&ce(e,n),new t(e)}function Lu(e,t,r){if(t)e:{if(!Vr(t=e))throw gn("int64");switch(typeof t){case"string":t=Vo(t);break e;case"bigint":t=Tt(Gr(64,t));break e;default:t=$o(t)}}else e=typeof(t=e),t=t==null?t:e==="bigint"?Tt(Gr(64,t)):Vr(t)?e==="string"?Vo(t):$o(t):void 0;return(e=t)==null?r?Cu:void 0:e}function Fu(e){return e}const Pu={};let Du=function(){try{return oi(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class Cn{constructor(){this.g=new Map}get(t){return this.g.get(t)}set(t,r){return this.g.set(t,r),this.size=this.g.size,this}delete(t){return t=this.g.delete(t),this.size=this.g.size,t}clear(){this.g.clear(),this.size=this.g.size}has(t){return this.g.has(t)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(t,r){return this.g.forEach(t,r)}[Symbol.iterator](){return this.entries()}}const Ru=Du?(Object.setPrototypeOf(Cn.prototype,Map.prototype),Object.defineProperties(Cn.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Cn):class extends Map{constructor(){super()}};function zo(e){return e}function In(e){if(2&e.M)throw Error("Cannot mutate an immutable Map")}var tt=class extends Ru{constructor(e,t,r=zo,i=zo){super();let n=0|e[k];n|=64,ce(e,n),this.M=n,this.I=t,this.S=r,this.X=this.I?Ou:i;for(let s=0;s<e.length;s++){const a=e[s],c=r(a[0],!1,!0);let l=a[1];t?l===void 0&&(l=null):l=i(a[1],!1,!0,void 0,void 0,n),super.set(c,l)}}La(){var e=$u;if(this.size!==0)return Array.from(super.entries(),t=>(t[0]=e(t[0]),t[1]=e(t[1]),t))}da(e=Bu){const t=[],r=super.entries();for(var i;!(i=r.next()).done;)(i=i.value)[0]=e(i[0]),i[1]=e(i[1]),t.push(i);return t}clear(){In(this),super.clear()}delete(e){return In(this),super.delete(this.S(e,!0,!1))}entries(){if(this.I){var e=super.keys();e=new No(e,Uu,this)}else e=super.entries();return e}values(){if(this.I){var e=super.keys();e=new No(e,tt.prototype.get,this)}else e=super.values();return e}forEach(e,t){this.I?super.forEach((r,i,n)=>{e.call(t,n.get(i),i,n)}):super.forEach(e,t)}set(e,t){return In(this),(e=this.S(e,!0,!1))==null?this:t==null?(super.delete(e),this):super.set(e,this.X(t,!0,!0,this.I,!1,this.M))}Ja(e){const t=this.S(e[0],!1,!0);e=e[1],e=this.I?e===void 0?null:e:this.X(e,!1,!0,void 0,!1,this.M),super.set(t,e)}has(e){return super.has(this.S(e,!1,!1))}get(e){e=this.S(e,!1,!1);const t=super.get(e);if(t!==void 0){var r=this.I;return r?((r=this.X(t,!1,!0,r,this.pa,this.M))!==t&&super.set(e,r),r):t}}[Symbol.iterator](){return this.entries()}};function Ou(e,t,r,i,n,s){return e=Nn(e,i,r,s),n&&(e=pi(e)),e}function Bu(e){return e}function Uu(e){return[e,this.get(e)]}let Gu,Ho,qo,Vu;function Yo(){return Gu||(Gu=new tt(lr([]),void 0,void 0,void 0,Pu))}function Mn(e,t,r,i,n){if(e!=null){if(Array.isArray(e)){const s=0|e[k];return e.length===0&&1&s?void 0:n&&2&s?e:mi(e,t,r,i!==void 0,n)}return t(e,i)}}function mi(e,t,r,i,n){const s=i||r?0|e[k]:0,a=i?!!(32&s):void 0;let c=0;const l=(i=ke(e)).length;for(let g=0;g<l;g++){var u=i[g];if(g===l-1&&ui(u)){var h=t,f=r,w=a,m=n;let b;for(let _ in u){const p=Mn(u[_],h,f,w,m);p!=null&&((b??(b={}))[_]=p)}u=b}else u=Mn(i[g],t,r,a,n);i[g]=u,u!=null&&(c=g+1)}return c<l&&(i.length=c),r&&((e=vn(e))&&(i[cr]=ke(e)),r(s,i)),i}function $u(e){return Mn(e,Ln,void 0,void 0,!1)}function Ln(e){switch(typeof e){case"number":return Number.isFinite(e)?e:""+e;case"bigint":return _n(e)?Number(e):""+e;case"boolean":return e?1:0;case"object":if(zt(e))return zt(e)&&pn(So),yo(e);if(e.W===Br)return Ko(e);if(e instanceof ft){const t=e.g;return t==null?"":typeof t=="string"?t:e.g=yo(t)}return e instanceof tt?e.La():void 0}return e}function Ko(e){var t=e.u;e=mi(t,Ln,void 0,void 0,!1);var r=0|t[k];if((t=e.length)&&!(512&r)){var i=e[t-1],n=!1;ui(i)?(t--,n=!0):i=void 0;var s=t-(r=512&r?0:-1),a=(Ho??Fu)(s,r,e,i);if(i&&(e[t]=void 0),s<a&&i){for(var c in s=!0,i){const l=+c;l<=a?(e[n=l+r]=i[c],t=Math.max(n+1,t),n=!1,delete i[c]):s=!1}s&&(i=void 0)}for(s=t-1;t>0;s=t-1)if((c=e[s])==null)t--,n=!0;else{if(!((s-=r)>=a))break;(i??(i={}))[s]=c,t--,n=!0}n&&(e.length=t),i&&e.push(i)}return e}function Ct(e,t,r){return e=Xo(e,t[0],t[1],r?1:2),t!==qo&&r&&ci(e,8192),e}function Xo(e,t,r,i){if(e==null){var n=96;r?(e=[r],n|=512):e=[],t&&(n=-16760833&n|(1023&t)<<14)}else{if(!Array.isArray(e))throw Error("narr");if(8192&(n=0|e[k])||!(64&n)||2&n||pn(yu),1024&n)throw Error("farr");if(64&n)return e;if(i===1||i===2||(n|=64),r&&(n|=512,r!==e[0]))throw Error("mid");e:{var s=(r=e).length;if(s){var a=s-1;if(ui(i=r[a])){if((a-=t=512&(n|=256)?0:-1)>=1024)throw Error("pvtlmt");for(var c in i)(s=+c)<a&&(r[s+t]=i[c],delete i[c]);n=-16760833&n|(1023&a)<<14;break e}}if(t){if((c=Math.max(t,s-(512&n?0:-1)))>1024)throw Error("spvt");n=-16760833&n|(1023&c)<<14}}}return ce(e,n),e}function Fn(e,t,r=xn){if(e!=null){if(po&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var i=0|e[k];return 2&i?e:(t&&(t=i===0||!!(32&i)&&!(64&i||!(16&i))),t?(ce(e,34|i),4&i&&Object.freeze(e),e):mi(e,Fn,4&i?xn:r,!0,!0))}return e.W===Br?e=2&(i=0|(r=e.u)[k])?e:new e.constructor(gi(r,i,!0)):e instanceof tt&&!(2&e.M)&&(r=lr(e.da(Fn)),e=new tt(r,e.I,e.S,e.X)),e}}function gi(e,t,r){const i=r||2&t?xn:bu,n=!!(32&t);return e=function(s,a,c){const l=ke(s);var u=l.length;const h=256&a?l[u-1]:void 0;for(u+=h?-1:0,a=512&a?1:0;a<u;a++)l[a]=c(l[a]);if(h){a=l[a]={};for(const f in h)a[f]=c(h[f])}return(s=vn(s))&&(l[cr]=ke(s)),l}(e,t,s=>Fn(s,n,i)),ci(e,32|(r?2:0)),e}function pi(e){const t=e.u,r=0|t[k];return 2&r?new e.constructor(gi(t,r,!1)):e}function wr(e,t){return wt(e=e.u,0|e[k],t)}function wt(e,t,r){if(r===-1)return null;const i=r+(512&t?0:-1),n=e.length-1;return i>=n&&256&t?e[n][r]:i<=n?e[i]:void 0}function G(e,t,r){const i=e.u;let n=0|i[k];return At(n),Y(i,n,t,r),e}function Y(e,t,r,i){const n=512&t?0:-1,s=r+n;var a=e.length-1;return s>=a&&256&t?(e[a][r]=i,t):s<=a?(e[s]=i,t):(i!==void 0&&(r>=(a=t>>14&1023||536870912)?i!=null&&(e[a+n]={[r]:i},ce(e,t|=256)):e[s]=i),t)}function xi(e,t){let r=0|(e=e.u)[k];const i=wt(e,r,t),n=Nt(i);return n!=null&&n!==i&&Y(e,r,t,n),n}function Qo(e){let t=0|(e=e.u)[k];const r=wt(e,t,1),i=bn(r,!0);return i!=null&&i!==r&&Y(e,t,1,i),i}function Yt(){return vu===void 0?2:4}function Kt(e,t,r,i,n){const s=e.u,a=2&(e=0|s[k])?1:i;n=!!n;let c=0|(i=Pn(s,e,t))[k];if(!(4&c)){4&c&&(i=ke(i),c=pt(c,e),e=Y(s,e,t,i));let l=0,u=0;for(;l<i.length;l++){const h=r(i[l]);h!=null&&(i[u++]=h)}u<l&&(i.length=u),c=Dn(c,e),r=-2049&(20|c),c=r&=-4097,ce(i,c),2&c&&Object.freeze(i)}return a===1||a===4&&32&c?mt(c)||(n=c,c|=2,c!==n&&ce(i,c),Object.freeze(i)):(a===2&&mt(c)&&(i=ke(i),c=pt(c,e),c=It(c,e,n),ce(i,c),e=Y(s,e,t,i)),mt(c)||(t=c,c=It(c,e,n),c!==t&&ce(i,c))),i}function Pn(e,t,r){return e=wt(e,t,r),Array.isArray(e)?e:yn}function Dn(e,t){return e===0&&(e=pt(e,t)),1|e}function mt(e){return!!(2&e)&&!!(4&e)||!!(1024&e)}function Jo(e){e=ke(e);for(let t=0;t<e.length;t++){const r=e[t]=ke(e[t]);Array.isArray(r[1])&&(r[1]=lr(r[1]))}return e}function Rn(e,t,r,i){let n=0|(e=e.u)[k];At(n),Y(e,n,t,(i==="0"?Number(r)===0:r===i)?void 0:r)}function mr(e,t,r,i){At(t);let n=Pn(e,t,r);const s=n!==yn;if(64&t||!(8192&t)||!s){const a=s?0|n[k]:0;let c=a;(!s||2&c||mt(c)||4&c&&!(32&c))&&(n=ke(n),c=pt(c,t),t=Y(e,t,r,n)),c=-13&Dn(c,t),c=It(i?-17&c:16|c,t,!0),c!==a&&ce(n,c)}return n}function On(e,t){var r=ec;return Un(Bn(e=e.u),e,0|e[k],r)===t?t:-1}function Bn(e){if(ai)return e[Or]??(e[Or]=new Map);if(Or in e)return e[Or];const t=new Map;return Object.defineProperty(e,Or,{value:t}),t}function Zo(e,t,r,i){const n=Bn(e),s=Un(n,e,t,r);return s!==i&&(s&&(t=Y(e,t,s)),n.set(r,i)),t}function Un(e,t,r,i){let n=e.get(i);if(n!=null)return n;n=0;for(let s=0;s<i.length;s++){const a=i[s];wt(t,r,a)!=null&&(n!==0&&(r=Y(t,r,n)),n=a)}return e.set(i,n),n}function Gn(e,t,r){let i=0|e[k];const n=wt(e,i,r);let s;if(n!=null&&n.W===Br)return(t=pi(n))!==n&&Y(e,i,r,t),t.u;if(Array.isArray(n)){const a=0|n[k];s=2&a?Ct(gi(n,a,!1),t,!0):64&a?n:Ct(s,t,!0)}else s=Ct(void 0,t,!0);return s!==n&&Y(e,i,r,s),s}function ea(e,t,r){let i=0|(e=e.u)[k];const n=wt(e,i,r);return(t=Nn(n,t,!1,i))!==n&&t!=null&&Y(e,i,r,t),t}function P(e,t,r){if((t=ea(e,t,r))==null)return t;let i=0|(e=e.u)[k];if(!(2&i)){const n=pi(t);n!==t&&Y(e,i,r,t=n)}return t}function ta(e,t,r,i,n,s,a){e=e.u;var c=!!(2&t);const l=c?1:n;s=!!s,a&&(a=!c);var u=0|(n=Pn(e,t,i))[k];if(!(c=!!(4&u))){var h=n,f=t;const w=!!(2&(u=Dn(u,t)));w&&(f|=2);let m=!w,g=!0,b=0,_=0;for(;b<h.length;b++){const p=Nn(h[b],r,!1,f);if(p instanceof r){if(!w){const A=!!(2&(0|p.u[k]));m&&(m=!A),g&&(g=A)}h[_++]=p}}_<b&&(h.length=_),u|=4,u=g?16|u:-17&u,ce(h,u=m?8|u:-9&u),w&&Object.freeze(h)}if(a&&!(8&u||!n.length&&(l===1||l===4&&32&u))){for(mt(u)&&(n=ke(n),u=pt(u,t),t=Y(e,t,i,n)),r=n,a=u,h=0;h<r.length;h++)(u=r[h])!==(f=pi(u))&&(r[h]=f);a|=8,ce(r,a=r.length?-17&a:16|a),u=a}return l===1||l===4&&32&u?mt(u)||(t=u,(u|=!n.length||16&u&&(!c||32&u)?2:1024)!==t&&ce(n,u),Object.freeze(n)):(l===2&&mt(u)&&(ce(n=ke(n),u=It(u=pt(u,t),t,s)),t=Y(e,t,i,n)),mt(u)||(i=u,(u=It(u,t,s))!==i&&ce(n,u))),n}function gt(e,t,r){const i=0|e.u[k];return ta(e,i,t,r,Yt(),!1,!(2&i))}function S(e,t,r,i){return i==null&&(i=void 0),G(e,r,i)}function $r(e,t,r,i){i==null&&(i=void 0);e:{let n=0|(e=e.u)[k];if(At(n),i==null){const s=Bn(e);if(Un(s,e,n,r)!==t)break e;s.set(r,0)}else n=Zo(e,n,r,t);Y(e,n,t,i)}}function pt(e,t){return-1025&(e=32|(2&t?2|e:-3&e))}function It(e,t,r){return 32&t&&r||(e&=-33),e}function yi(e,t,r){At(0|e.u[k]),Kt(e,t,fr,2,!0).push(Wo(r))}function bi(e,t,r,i){const n=0|e.u[k];At(n),e=ta(e,n,r,t,2,!0),i=i??new r,e.push(i),e[k]=2&(0|i.u[k])?-9&e[k]:-17&e[k]}function Ue(e,t){return dr(wr(e,t))}function Ge(e,t){return fr(wr(e,t))}function te(e,t){return xi(e,t)??0}function Wr(e,t,r){if(r!=null&&typeof r!="boolean")throw e=typeof r,Error(`Expected boolean but got ${e!="object"?e:r?Array.isArray(r)?"array":e:"null"}: ${r}`);G(e,t,r)}function rt(e,t,r){if(r!=null){if(typeof r!="number"||!wi(r))throw gn("int32");r|=0}G(e,t,r)}function v(e,t,r){if(r!=null&&typeof r!="number")throw Error(`Value of float/double field must be a number, found ${typeof r}: ${r}`);G(e,t,r)}function vi(e,t,r){{const a=e.u;let c=0|a[k];if(At(c),r==null)Y(a,c,t);else{var i=e=0|r[k],n=mt(e),s=n||Object.isFrozen(r);for(n||(e=0),s||(r=ke(r),i=0,e=It(e=pt(e,c),c,!0),s=!1),e|=21,n=0;n<r.length;n++){const l=r[n],u=Wo(l);Object.is(l,u)||(s&&(r=ke(r),i=0,e=It(e=pt(e,c),c,!0),s=!1),r[n]=u)}e!==i&&(s&&(r=ke(r),e=It(e=pt(e,c),c,!0)),ce(r,e)),Y(a,c,t,r)}}}function ra(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function Vn(){return Error("Failed to read varint, encoding is invalid.")}function ia(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function $n(e){if(typeof e=="string")return{buffer:vo(e),O:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),O:!1};if(e.constructor===Uint8Array)return{buffer:e,O:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),O:!1};if(e.constructor===ft)return{buffer:mn(e)||new Uint8Array(0),O:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),O:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function Wn(e,t){let r,i=0,n=0,s=0;const a=e.h;let c=e.g;do r=a[c++],i|=(127&r)<<s,s+=7;while(s<32&&128&r);for(s>32&&(n|=(127&r)>>4),s=3;s<32&&128&r;s+=7)r=a[c++],n|=(127&r)<<s;if(Xt(e,c),r<128)return t(i>>>0,n>>>0);throw Vn()}function zn(e){let t=0,r=e.g;const i=r+10,n=e.h;for(;r<i;){const s=n[r++];if(t|=s,(128&s)==0)return Xt(e,r),!!(127&t)}throw Vn()}function Mt(e){const t=e.h;let r=e.g,i=t[r++],n=127&i;if(128&i&&(i=t[r++],n|=(127&i)<<7,128&i&&(i=t[r++],n|=(127&i)<<14,128&i&&(i=t[r++],n|=(127&i)<<21,128&i&&(i=t[r++],n|=i<<28,128&i&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw Vn();return Xt(e,r),n}function xt(e){return Mt(e)>>>0}function Hn(e){var t=e.h;const r=e.g,i=t[r],n=t[r+1],s=t[r+2];return t=t[r+3],Xt(e,e.g+4),(i<<0|n<<8|s<<16|t<<24)>>>0}function qn(e){var t=Hn(e);e=2*(t>>31)+1;const r=t>>>23&255;return t&=8388607,r==255?t?NaN:e*(1/0):r==0?1401298464324817e-60*e*t:e*Math.pow(2,r-150)*(t+8388608)}function Wu(e){return Mt(e)}function Yn(e,t,{aa:r=!1}={}){e.aa=r,t&&(t=$n(t),e.h=t.buffer,e.m=t.O,e.j=0,e.l=e.h.length,e.g=e.j)}function Xt(e,t){if(e.g=t,t>e.l)throw ia(e.l,t)}function na(e,t){if(t<0)throw Error(`Tried to read a negative byte length: ${t}`);const r=e.g,i=r+t;if(i>e.l)throw ia(t,e.l-r);return e.g=i,r}function sa(e,t){if(t==0)return Ht();var r=na(e,t);return e.aa&&e.m?r=e.h.subarray(r,r+t):(e=e.h,r=r===(t=r+t)?new Uint8Array(0):ju?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Ht():new ft(r,or)}tt.prototype.toJSON=void 0;var oa=[];function aa(e){var t=e.g;if(t.g==t.l)return!1;e.l=e.g.g;var r=xt(e.g);if(t=r>>>3,!((r&=7)>=0&&r<=5))throw ra(r,e.l);if(t<1)throw Error(`Invalid field number: ${t} (at position ${e.l})`);return e.m=t,e.h=r,!0}function _i(e){switch(e.h){case 0:e.h!=0?_i(e):zn(e.g);break;case 1:Xt(e=e.g,e.g+8);break;case 2:if(e.h!=2)_i(e);else{var t=xt(e.g);Xt(e=e.g,e.g+t)}break;case 5:Xt(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!aa(e))throw Error("Unmatched start-group tag: stream EOF");if(e.h==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}_i(e)}break;default:throw ra(e.h,e.l)}}function zr(e,t,r){const i=e.g.l,n=xt(e.g),s=e.g.g+n;let a=s-i;if(a<=0&&(e.g.l=s,r(t,e,void 0,void 0,void 0),a=s-e.g.g),a)throw Error(`Message parsing ended unexpectedly. Expected to read ${n} bytes, instead read ${n-a} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=s,e.g.l=i,t}function Kn(e){var t=xt(e.g),r=na(e=e.g,t);if(e=e.h,lu){var i,n=e;(i=ln)||(i=ln=new TextDecoder("utf-8",{fatal:!0})),t=r+t,n=r===0&&t===n.length?n:n.subarray(r,t);try{var s=i.decode(n)}catch(c){if(ni===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),ni=!0}catch{ni=!1}}throw!ni&&(ln=void 0),c}}else{t=(s=r)+t,r=[];let c,l=null;for(;s<t;){var a=e[s++];a<128?r.push(a):a<224?s>=t?Wt():(c=e[s++],a<194||(192&c)!=128?(s--,Wt()):r.push((31&a)<<6|63&c)):a<240?s>=t-1?Wt():(c=e[s++],(192&c)!=128||a===224&&c<160||a===237&&c>=160||(192&(i=e[s++]))!=128?(s--,Wt()):r.push((15&a)<<12|(63&c)<<6|63&i)):a<=244?s>=t-2?Wt():(c=e[s++],(192&c)!=128||c-144+(a<<28)>>30||(192&(i=e[s++]))!=128||(192&(n=e[s++]))!=128?(s--,Wt()):(a=(7&a)<<18|(63&c)<<12|(63&i)<<6|63&n,a-=65536,r.push(55296+(a>>10&1023),56320+(1023&a)))):Wt(),r.length>=8192&&(l=lo(l,r),r.length=0)}s=lo(l,r)}return s}function ca(e){const t=xt(e.g);return sa(e.g,t)}function ki(e,t,r){var i=xt(e.g);for(i=e.g.g+i;e.g.g<i;)r.push(t(e.g))}var Ei=[];function Ye(e,t,r){t.g?t.m(e,t.g,t.h,r):t.m(e,t.h,r)}var y=class{constructor(e,t){this.u=Xo(e,t)}toJSON(){try{var e=Ko(this)}finally{Ho=void 0}return e}l(){var e=Ad;return e.g?e.l(this,e.g,e.h):e.l(this,e.h,e.defaultValue)}clone(){const e=this.u;return new this.constructor(gi(e,0|e[k],!1))}O(){return!!(2&(0|this.u[k]))}};function la(e){return e?/^\d+$/.test(e)?(fi(e),new Xn(U,Q)):null:zu||(zu=new Xn(0,0))}y.prototype.W=Br,y.prototype.toString=function(){return this.u.toString()};var Xn=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let zu;function ua(e){return e?/^-?\d+$/.test(e)?(fi(e),new Qn(U,Q)):null:Hu||(Hu=new Qn(0,0))}var Qn=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let Hu;function gr(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function pr(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function Si(e,t){if(t>=0)pr(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function Hr(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function xr(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function Ne(e,t,r){pr(e.g,8*t+r)}function Jn(e,t){return Ne(e,t,2),t=e.g.end(),xr(e,t),t.push(e.h),t}function Zn(e,t){var r=t.pop();for(r=e.h+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.h++;t.push(r),e.h++}function Ai(e,t,r){Ne(e,t,2),pr(e.g,r.length),xr(e,e.g.end()),xr(e,r)}function Ti(e,t,r,i){r!=null&&(t=Jn(e,t),i(r,e),Zn(e,t))}function Ke(){const e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var es=Ke(),da=Ke(),ts=Ke(),rs=Ke(),ha=Ke(),fa=Ke(),is=Ke(),wa=Ke(),ma=Ke(),yr=class{constructor(e,t,r){this.g=e,this.h=t,e=es,this.l=!!e&&r===e||!1}};function ji(e,t){return new yr(e,t,es)}function ga(e,t,r,i,n){Ti(e,r,_a(t,i),n)}const qu=ji(function(e,t,r,i,n){return e.h===2&&(zr(e,Gn(t,i,r),n),!0)},ga),Yu=ji(function(e,t,r,i,n){return e.h===2&&(zr(e,Gn(t,i,r),n),!0)},ga);var Ni=Symbol(),ns=Symbol(),pa=Symbol(),xa=Symbol();let ya,ba;function Qt(e,t,r,i){var n=i[e];if(n)return n;(n={}).Ma=i,n.T=function(f){switch(typeof f){case"boolean":return qo||(qo=[0,void 0,!0]);case"number":return f>0?void 0:f===0?Vu||(Vu=[0,void 0]):[-f,void 0];case"string":return[0,f];case"object":return f}}(i[0]);var s=i[1];let a=1;s&&s.constructor===Object&&(n.ga=s,typeof(s=i[++a])=="function"&&(n.la=!0,ya??(ya=s),ba??(ba=i[a+1]),s=i[a+=2]));const c={};for(;s&&Array.isArray(s)&&s.length&&typeof s[0]=="number"&&s[0]>0;){for(var l=0;l<s.length;l++)c[s[l]]=s;s=i[++a]}for(l=1;s!==void 0;){let f;typeof s=="number"&&(l+=s,s=i[++a]);var u=void 0;if(s instanceof yr?f=s:(f=qu,a--),f==null?void 0:f.l){s=i[++a],u=i;var h=a;typeof s=="function"&&(s=s(),u[h]=s),u=s}for(h=l+1,typeof(s=i[++a])=="number"&&s<0&&(h-=s,s=i[++a]);l<h;l++){const w=c[l];u?r(n,l,f,u,w):t(n,l,f,w)}}return i[e]=n}function va(e){return Array.isArray(e)?e[0]instanceof yr?e:[Yu,e]:[e,void 0]}function _a(e,t){return e instanceof y?e.u:Array.isArray(e)?Ct(e,t,!1):void 0}function ss(e,t,r,i){const n=r.g;e[t]=i?(s,a,c)=>n(s,a,c,i):n}function os(e,t,r,i,n){const s=r.g;let a,c;e[t]=(l,u,h)=>s(l,u,h,c||(c=Qt(ns,ss,os,i).T),a||(a=as(i)),n)}function as(e){let t=e[pa];if(t!=null)return t;const r=Qt(ns,ss,os,e);return t=r.la?(i,n)=>ya(i,n,r):(i,n)=>{const s=0|i[k];for(;aa(n)&&n.h!=4;){var a=n.m,c=r[a];if(c==null){var l=r.ga;l&&(l=l[a])&&(l=Ku(l))!=null&&(c=r[a]=l)}c!=null&&c(n,i,a)||(a=(c=n).l,_i(c),c.fa?c=void 0:(l=c.g.g-a,c.g.g=a,c=sa(c.g,l)),a=i,c&&((l=a[cr])?l.push(c):a[cr]=[c]))}return 8192&s&&lr(i),!0},e[pa]=t}function Ku(e){const t=(e=va(e))[0].g;if(e=e[1]){const r=as(e),i=Qt(ns,ss,os,e).T;return(n,s,a)=>t(n,s,a,i,r)}return t}function Ci(e,t,r){e[t]=r.h}function Ii(e,t,r,i){let n,s;const a=r.h;e[t]=(c,l,u)=>a(c,l,u,s||(s=Qt(Ni,Ci,Ii,i).T),n||(n=ka(i)))}function ka(e){let t=e[xa];if(!t){const r=Qt(Ni,Ci,Ii,e);t=(i,n)=>Ea(i,n,r),e[xa]=t}return t}function Ea(e,t,r){(function(i,n,s){const a=512&n?0:-1,c=i.length,l=c+((n=64&n?256&n:!!c&&ui(i[c-1]))?-1:0);for(let u=0;u<l;u++)s(u-a,i[u]);if(n){i=i[c-1];for(const u in i)!isNaN(u)&&s(+u,i[u])}})(e,0|e[k]|(r.T[1]?512:0),(i,n)=>{if(n!=null){var s=function(a,c){var l=a[c];if(l)return l;if((l=a.ga)&&(l=l[c])){var u=(l=va(l))[0].h;if(l=l[1]){const h=ka(l),f=Qt(Ni,Ci,Ii,l).T;l=a.la?ba(f,h):(w,m,g)=>u(w,m,g,f,h)}else l=u;return a[c]=l}}(r,i);s&&s(t,n,i)}}),(e=vn(e))&&function(i,n){xr(i,i.g.end());for(let s=0;s<n.length;s++)xr(i,mn(n[s])||new Uint8Array(0))}(t,e)}function br(e,t){if(Array.isArray(t)){var r=0|t[k];if(4&r)return t;for(var i=0,n=0;i<t.length;i++){const s=e(t[i]);s!=null&&(t[n++]=s)}return n<i&&(t.length=n),ce(t,-6145&(5|r)),2&r&&Object.freeze(t),t}}function xe(e,t,r){return new yr(e,t,r)}function vr(e,t,r){return new yr(e,t,r)}function ye(e,t,r){Y(e,0|e[k],t,r)}var Xu=ji(function(e,t,r,i,n){return e.h===2&&(e=zr(e,Ct([void 0,void 0],i,!0),n),At(i=0|t[k]),(n=wt(t,i,r))instanceof tt?2&n.M?((n=n.da()).push(e),Y(t,i,r,n)):n.Ja(e):Array.isArray(n)?(2&(0|n[k])&&Y(t,i,r,n=Jo(n)),n.push(e)):Y(t,i,r,[e]),!0)},function(e,t,r,i,n){if(t instanceof tt)t.forEach((s,a)=>{Ti(e,r,Ct([a,s],i,!1),n)});else if(Array.isArray(t))for(let s=0;s<t.length;s++){const a=t[s];Array.isArray(a)&&Ti(e,r,Ct(a,i,!1),n)}});function Sa(e,t,r){if(t=function(i){if(i==null)return i;const n=typeof i;if(n==="bigint")return String(Gr(64,i));if(Vr(i)){if(n==="string")return Go(i);if(n==="number")return Tn(i)}}(t),t!=null&&(typeof t=="string"&&ua(t),t!=null))switch(Ne(e,r,0),typeof t){case"number":e=e.g,qt(t),gr(e,U,Q);break;case"bigint":r=BigInt.asUintN(64,t),r=new Qn(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),gr(e.g,r.h,r.g);break;default:r=ua(t),gr(e.g,r.h,r.g)}}function Aa(e,t,r){(t=dr(t))!=null&&t!=null&&(Ne(e,r,0),Si(e.g,t))}function Ta(e,t,r){(t=Do(t))!=null&&(Ne(e,r,0),e.g.g.push(t?1:0))}function ja(e,t,r){(t=fr(t))!=null&&Ai(e,r,uo(t))}function Na(e,t,r,i,n){Ti(e,r,_a(t,i),n)}function Ca(e,t,r){t==null||typeof t=="string"||t instanceof ft||(zt(t)?zt(t)&&pn(So):t=void 0),t!=null&&Ai(e,r,$n(t).buffer)}function Ia(e,t,r){return(e.h===5||e.h===2)&&(t=mr(t,0|t[k],r,!1),e.h==2?ki(e,qn,t):t.push(qn(e.g)),!0)}var yt=xe(function(e,t,r){if(e.h!==1)return!1;var i=e.g;e=Hn(i);const n=Hn(i);i=2*(n>>31)+1;const s=n>>>20&2047;return e=4294967296*(1048575&n)+e,ye(t,r,s==2047?e?NaN:i*(1/0):s==0?5e-324*i*e:i*Math.pow(2,s-1075)*(e+4503599627370496)),!0},function(e,t,r){(t=Nt(t))!=null&&(Ne(e,r,1),e=e.g,(r=Mo||(Mo=new DataView(new ArrayBuffer(8)))).setFloat64(0,+t,!0),U=r.getUint32(0,!0),Q=r.getUint32(4,!0),Hr(e,U),Hr(e,Q))},Ke()),le=xe(function(e,t,r){return e.h===5&&(ye(t,r,qn(e.g)),!0)},function(e,t,r){(t=Nt(t))!=null&&(Ne(e,r,5),e=e.g,kn(t),Hr(e,U))},is),Qu=vr(Ia,function(e,t,r){if((t=br(Nt,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&(Ne(i,n,5),i=i.g,kn(s),Hr(i,U))}},is),cs=vr(Ia,function(e,t,r){if((t=br(Nt,t))!=null&&t.length){Ne(e,r,2),pr(e.g,4*t.length);for(let i=0;i<t.length;i++)r=e.g,kn(t[i]),Hr(r,U)}},is),Lt=xe(function(e,t,r){return e.h===0&&(ye(t,r,Wn(e.g,Sn)),!0)},Sa,fa),ls=xe(function(e,t,r){return e.h===0&&(ye(t,r,(e=Wn(e.g,Sn))===0?void 0:e),!0)},Sa,fa),Ju=xe(function(e,t,r){return e.h===0&&(ye(t,r,Wn(e.g,En)),!0)},function(e,t,r){if((t=Mu(t))!=null&&(typeof t=="string"&&la(t),t!=null))switch(Ne(e,r,0),typeof t){case"number":e=e.g,qt(t),gr(e,U,Q);break;case"bigint":r=BigInt.asUintN(64,t),r=new Xn(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),gr(e.g,r.h,r.g);break;default:r=la(t),gr(e.g,r.h,r.g)}},Ke()),J=xe(function(e,t,r){return e.h===0&&(ye(t,r,Mt(e.g)),!0)},Aa,rs),Mi=vr(function(e,t,r){return(e.h===0||e.h===2)&&(t=mr(t,0|t[k],r,!1),e.h==2?ki(e,Mt,t):t.push(Mt(e.g)),!0)},function(e,t,r){if((t=br(dr,t))!=null&&t.length){r=Jn(e,r);for(let i=0;i<t.length;i++)Si(e.g,t[i]);Zn(e,r)}},rs),_r=xe(function(e,t,r){return e.h===0&&(ye(t,r,(e=Mt(e.g))===0?void 0:e),!0)},Aa,rs),z=xe(function(e,t,r){return e.h===0&&(ye(t,r,zn(e.g)),!0)},Ta,da),kr=xe(function(e,t,r){return e.h===0&&(ye(t,r,(e=zn(e.g))===!1?void 0:e),!0)},Ta,da),ge=vr(function(e,t,r){return e.h===2&&(e=Kn(e),mr(t,0|t[k],r,!1).push(e),!0)},function(e,t,r){if((t=br(fr,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&Ai(i,n,uo(s))}},ts),Ft=xe(function(e,t,r){return e.h===2&&(ye(t,r,(e=Kn(e))===""?void 0:e),!0)},ja,ts),R=xe(function(e,t,r){return e.h===2&&(ye(t,r,Kn(e)),!0)},ja,ts),de=function(e,t,r=es){return new yr(e,t,r)}(function(e,t,r,i,n){return e.h===2&&(i=Ct(void 0,i,!0),mr(t,0|t[k],r,!0).push(i),zr(e,i,n),!0)},function(e,t,r,i,n){if(Array.isArray(t))for(let s=0;s<t.length;s++)Na(e,t[s],r,i,n)}),O=ji(function(e,t,r,i,n,s){return e.h===2&&(Zo(t,0|t[k],s,r),zr(e,t=Gn(t,i,r),n),!0)},Na),Ma=xe(function(e,t,r){return e.h===2&&(ye(t,r,ca(e)),!0)},Ca,wa),Zu=vr(function(e,t,r){return(e.h===0||e.h===2)&&(t=mr(t,0|t[k],r,!1),e.h==2?ki(e,xt,t):t.push(xt(e.g)),!0)},function(e,t,r){if((t=br(Ro,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&(Ne(i,n,0),pr(i.g,s))}},ha),ed=xe(function(e,t,r){return e.h===0&&(ye(t,r,(e=xt(e.g))===0?void 0:e),!0)},function(e,t,r){(t=Ro(t))!=null&&t!=null&&(Ne(e,r,0),pr(e.g,t))},ha),Ce=xe(function(e,t,r){return e.h===0&&(ye(t,r,Mt(e.g)),!0)},function(e,t,r){(t=dr(t))!=null&&(t=parseInt(t,10),Ne(e,r,0),Si(e.g,t))},ma);class td{constructor(t,r){this.h=t,this.g=r,this.l=P,this.m=S,this.defaultValue=void 0}register(){oi(this)}}function Xe(e,t){return new td(e,t)}function Pt(e,t){return(r,i)=>{if(Ei.length){const s=Ei.pop();s.o(i),Yn(s.g,r,i),r=s}else r=new class{constructor(s,a){if(oa.length){const c=oa.pop();Yn(c,s,a),s=c}else s=new class{constructor(c,l){this.h=null,this.m=!1,this.g=this.l=this.j=0,Yn(this,c,l)}clear(){this.h=null,this.m=!1,this.g=this.l=this.j=0,this.aa=!1}}(s,a);this.g=s,this.l=this.g.g,this.h=this.m=-1,this.o(a)}o({fa:s=!1}={}){this.fa=s}}(r,i);try{const s=new e,a=s.u;as(t)(a,r);var n=s}finally{r.g.clear(),r.m=-1,r.h=-1,Ei.length<100&&Ei.push(r)}return n}}function Li(e){return function(){const t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const a=this.g;return this.g=[],a}}}};Ea(this.u,t,Qt(Ni,Ci,Ii,e)),xr(t,t.g.end());const r=new Uint8Array(t.h),i=t.l,n=i.length;let s=0;for(let a=0;a<n;a++){const c=i[a];r.set(c,s),s+=c.length}return t.l=[r],r}}var La=class extends y{constructor(e){super(e)}},Fa=[0,Ft,xe(function(e,t,r){return e.h===2&&(ye(t,r,(e=ca(e))===Ht()?void 0:e),!0)},function(e,t,r){if(t!=null){if(t instanceof y){const i=t.Oa;return void(i&&(t=i(t),t!=null&&Ai(e,r,$n(t).buffer)))}if(Array.isArray(t))return}Ca(e,t,r)},wa)];let us,Pa=globalThis.trustedTypes;function Da(e){us===void 0&&(us=function(){let r=null;if(!Pa)return r;try{const i=n=>n;r=Pa.createPolicy("goog#html",{createHTML:i,createScript:i,createScriptURL:i})}catch{}return r}());var t=us;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function rd(e,...t){if(t.length===0)return Da(e[0]);let r=e[0];for(let i=0;i<t.length;i++)r+=encodeURIComponent(t[i])+e[i+1];return Da(r)}var Ra=[0,J,Ce,z,-1,Mi,Ce,-1],id=class extends y{constructor(e){super(e)}},Oa=[0,z,R,z,Ce,-1,vr(function(e,t,r){return(e.h===0||e.h===2)&&(t=mr(t,0|t[k],r,!1),e.h==2?ki(e,Wu,t):t.push(Mt(e.g)),!0)},function(e,t,r){if((t=br(dr,t))!=null&&t.length){r=Jn(e,r);for(let i=0;i<t.length;i++)Si(e.g,t[i]);Zn(e,r)}},ma),R,-1,[0,z,-1],Ce,z,-1],Ba=[0,R,-2],Ua=class extends y{constructor(e){super(e)}},Ga=[0],Va=[0,J,z,1,z,-3],Ie=class extends y{constructor(e){super(e,2)}},ue={};ue[336783863]=[0,R,z,-1,J,[0,[1,2,3,4,5,6,7,8,9],O,Ga,O,Oa,O,Ba,O,Va,O,Ra,O,[0,R,-2],O,[0,R,Ce],O,[0,Ce,R,-1],O,[0,Ce,-1]],[0,R],z,[0,[1,3],[2,4],O,[0,Mi],-1,O,[0,ge],-1,de,[0,R,-1]],R];var $a=[0,ls,-1,kr,-3,ls,Mi,Ft,_r,ls,-1,kr,_r,kr,-2,Ft];function Me(e,t){Rn(e,2,hr(t),"")}function V(e,t){yi(e,3,t)}function L(e,t){yi(e,4,t)}var be=class extends y{constructor(e){super(e,500)}o(e){return S(this,0,7,e)}},qr=[-1,{}],Wa=[0,R,1,qr],za=[0,R,ge,qr];function Le(e,t){bi(e,1,be,t)}function $(e,t){yi(e,10,t)}function D(e,t){yi(e,15,t)}var Ee=class extends y{constructor(e){super(e,500)}o(e){return S(this,0,1001,e)}},Ha=[-500,de,[-500,Ft,-1,ge,-3,[-2,ue,z],de,Fa,_r,-1,Wa,za,de,[0,Ft,kr],Ft,$a,_r,ge,987,ge],4,de,[-500,R,-1,[-1,{}],998,R],de,[-500,R,ge,-1,[-2,{},z],997,ge,-1],_r,de,[-500,R,ge,qr,998,ge],ge,_r,Wa,za,de,[0,Ft,-1,qr],ge,-2,$a,Ft,-1,kr,[0,kr,ed],978,qr,de,Fa];Ee.prototype.g=Li(Ha);var nd=Pt(Ee,Ha),sd=class extends y{constructor(e){super(e)}},qa=class extends y{constructor(e){super(e)}g(){return gt(this,sd,1)}},Ya=[0,de,[0,J,le,R,-1]],Fi=Pt(qa,Ya),od=class extends y{constructor(e){super(e)}},ad=class extends y{constructor(e){super(e)}},ds=class extends y{constructor(e){super(e)}h(){return P(this,od,2)}g(){return gt(this,ad,5)}},Ka=Pt(class extends y{constructor(e){super(e)}},[0,ge,Mi,cs,[0,Ce,[0,J,-3],[0,le,-3],[0,J,-1,[0,de,[0,J,-2]]],de,[0,le,-1,R,le]],R,-1,Lt,de,[0,J,le],ge,Lt]),Xa=class extends y{constructor(e){super(e)}},Er=Pt(class extends y{constructor(e){super(e)}},[0,de,[0,le,-4]]),Qa=class extends y{constructor(e){super(e)}},Yr=Pt(class extends y{constructor(e){super(e)}},[0,de,[0,le,-4]]),cd=class extends y{constructor(e){super(e)}},ld=[0,J,-1,cs,Ce],Ja=class extends y{constructor(e){super(e)}};Ja.prototype.g=Li([0,le,-4,Lt]);var ud=class extends y{constructor(e){super(e)}},dd=Pt(class extends y{constructor(e){super(e)}},[0,de,[0,1,J,R,Ya],Lt]),Za=class extends y{constructor(e){super(e)}},hd=class extends y{constructor(e){super(e)}ma(){const e=Qo(this);return e??Ht()}},fd=class extends y{constructor(e){super(e)}},ec=[1,2],wd=Pt(class extends y{constructor(e){super(e)}},[0,de,[0,ec,O,[0,cs],O,[0,Ma],J,R],Lt]),hs=class extends y{constructor(e){super(e)}},tc=[0,R,J,le,ge,-1],rc=class extends y{constructor(e){super(e)}},md=[0,z,-1],ic=class extends y{constructor(e){super(e)}},Pi=[1,2,3,4,5],Di=class extends y{constructor(e){super(e)}g(){return Qo(this)!=null}h(){return Ge(this,2)!=null}},H=class extends y{constructor(e){super(e)}g(){return Do(wr(this,2))??!1}},nc=[0,Ma,R,[0,J,Lt,-1],[0,Ju,Lt]],re=[0,nc,z,[0,Pi,O,Va,O,Oa,O,Ra,O,Ga,O,Ba],Ce],Ri=class extends y{constructor(e){super(e)}},fs=[0,re,le,-1,J],gd=Xe(502141897,Ri);ue[502141897]=fs;var pd=Pt(class extends y{constructor(e){super(e)}},[0,[0,Ce,-1,Qu,Zu],ld]),sc=class extends y{constructor(e){super(e)}},oc=class extends y{constructor(e){super(e)}},ws=[0,re,le,[0,re],z],ac=[0,re,fs,ws,le,[0,[0,nc]]],xd=Xe(508968150,oc);ue[508968150]=ac,ue[508968149]=ws;var cc=class extends y{constructor(e){super(e)}},yd=Xe(513916220,cc);ue[513916220]=[0,re,ac,J];var Sr=class extends y{constructor(e){super(e)}h(){return P(this,hs,2)}g(){G(this,2)}},lc=[0,re,tc];ue[478825465]=lc;var bd=class extends y{constructor(e){super(e)}},uc=class extends y{constructor(e){super(e)}},ms=class extends y{constructor(e){super(e)}},gs=class extends y{constructor(e){super(e)}},dc=class extends y{constructor(e){super(e)}},hc=[0,re,[0,re],lc,-1],fc=[0,re,le,J],ps=[0,re,le],wc=[0,re,fc,ps,le],vd=Xe(479097054,dc);ue[479097054]=[0,re,wc,hc],ue[463370452]=hc,ue[464864288]=fc;var _d=Xe(462713202,gs);ue[462713202]=wc,ue[474472470]=ps;var kd=class extends y{constructor(e){super(e)}},mc=class extends y{constructor(e){super(e)}},gc=class extends y{constructor(e){super(e)}},pc=class extends y{constructor(e){super(e)}},xs=[0,re,le,-1,J],ys=[0,re,le,z];pc.prototype.g=Li([0,re,ps,[0,re],fs,ws,xs,ys]);var xc=class extends y{constructor(e){super(e)}},Ed=Xe(456383383,xc);ue[456383383]=[0,re,tc];var yc=class extends y{constructor(e){super(e)}},Sd=Xe(476348187,yc);ue[476348187]=[0,re,md];var bc=class extends y{constructor(e){super(e)}},vc=class extends y{constructor(e){super(e)}},_c=[0,Ce,-1],Ad=Xe(458105876,class extends y{constructor(e){super(e)}g(){var e=this.u;const t=0|e[k],r=2&t;return e=function(i,n,s){var a=vc;const c=2&n;let l=!1;if(s==null){if(c)return Yo();s=[]}else if(s.constructor===tt){if(!(2&s.M)||c)return s;s=s.da()}else Array.isArray(s)?l=!!(2&(0|s[k])):s=[];if(c){if(!s.length)return Yo();l||(l=!0,lr(s))}else l&&(l=!1,s=Jo(s));return l||(64&(0|s[k])?s[k]&=-33:32&n&&ci(s,32)),Y(i,n,2,a=new tt(s,a,Lu,void 0)),a}(e,t,wt(e,t,2)),!r&&vc&&(e.pa=!0),e}});ue[458105876]=[0,_c,Xu,[!0,Lt,[0,R,-1,ge]]];var bs=class extends y{constructor(e){super(e)}},kc=Xe(458105758,bs);ue[458105758]=[0,re,R,_c];var Ec=class extends y{constructor(e){super(e)}},Td=Xe(443442058,Ec);ue[443442058]=[0,re,R,J,le,ge,-1,z,le],ue[514774813]=xs;var Sc=class extends y{constructor(e){super(e)}},jd=Xe(516587230,Sc);function vs(e,t){return t=t?t.clone():new hs,e.displayNamesLocale!==void 0?G(t,1,hr(e.displayNamesLocale)):e.displayNamesLocale===void 0&&G(t,1),e.maxResults!==void 0?rt(t,2,e.maxResults):"maxResults"in e&&G(t,2),e.scoreThreshold!==void 0?v(t,3,e.scoreThreshold):"scoreThreshold"in e&&G(t,3),e.categoryAllowlist!==void 0?vi(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&G(t,4),e.categoryDenylist!==void 0?vi(t,5,e.categoryDenylist):"categoryDenylist"in e&&G(t,5),t}function _s(e,t=-1,r=""){return{categories:e.map(i=>({index:Ue(i,1)??0??-1,score:te(i,2)??0,categoryName:Ge(i,3)??""??"",displayName:Ge(i,4)??""??""})),headIndex:t,headName:r}}function Ac(e){var a,c;var t=Kt(e,3,Nt,Yt()),r=Kt(e,2,dr,Yt()),i=Kt(e,1,fr,Yt()),n=Kt(e,9,fr,Yt());const s={categories:[],keypoints:[]};for(let l=0;l<t.length;l++)s.categories.push({score:t[l],index:r[l]??-1,categoryName:i[l]??"",displayName:n[l]??""});if((t=(a=P(e,ds,4))==null?void 0:a.h())&&(s.boundingBox={originX:Ue(t,1)??0,originY:Ue(t,2)??0,width:Ue(t,3)??0,height:Ue(t,4)??0,angle:0}),(c=P(e,ds,4))==null?void 0:c.g().length)for(const l of P(e,ds,4).g())s.keypoints.push({x:xi(l,1)??0,y:xi(l,2)??0,score:xi(l,4)??0,label:Ge(l,3)??""});return s}function Oi(e){const t=[];for(const r of gt(e,Qa,1))t.push({x:te(r,1)??0,y:te(r,2)??0,z:te(r,3)??0,visibility:te(r,4)??0});return t}function Kr(e){const t=[];for(const r of gt(e,Xa,1))t.push({x:te(r,1)??0,y:te(r,2)??0,z:te(r,3)??0,visibility:te(r,4)??0});return t}function Tc(e){return Array.from(e,t=>t>127?t-256:t)}function jc(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let r=0,i=0,n=0;for(let s=0;s<e.length;s++)r+=e[s]*t[s],i+=e[s]*e[s],n+=t[s]*t[s];if(i<=0||n<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(i*n)}let Bi;ue[516587230]=[0,re,xs,ys,le],ue[518928384]=ys;const Nd=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function Nc(){if(Bi===void 0)try{await WebAssembly.instantiate(Nd),Bi=!0}catch{Bi=!1}return Bi}async function Xr(e,t=rd``){const r=await Nc()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var Jt=class{};function Cc(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function Ic(e){if(typeof importScripts!="function"){const t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise((r,i)=>{t.addEventListener("load",()=>{r()},!1),t.addEventListener("error",n=>{i(n)},!1),document.body.appendChild(t)})}importScripts(e.toString())}function Mc(e){return e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height]}function E(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function Lc(e,t,r){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(r?e.i._bindTextureToStream(r):e.i._bindTextureToCanvas(),!(r=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const[i,n]=Mc(t);return!e.l||i===e.i.canvas.width&&n===e.i.canvas.height||(e.i.canvas.width=i,e.i.canvas.height=n),[i,n]}function Fc(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const i=new Uint32Array(t.length);for(let n=0;n<t.length;n++)i[n]=e.i.stringToNewUTF8(t[n]);t=e.i._malloc(4*i.length),e.i.HEAPU32.set(i,t>>2),r(t);for(const n of i)e.i._free(n);e.i._free(t)}function it(e,t,r){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=r}function Dt(e,t,r){let i=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(n,s,a)=>{s?(r(i,a),i=[]):i.push(n)}}Jt.forVisionTasks=function(e){return Xr("vision",e)},Jt.forTextTasks=function(e){return Xr("text",e)},Jt.forGenAiExperimentalTasks=function(e){return Xr("genai_experimental",e)},Jt.forGenAiTasks=function(e){return Xr("genai",e)},Jt.forAudioTasks=function(e){return Xr("audio",e)},Jt.isSimdSupported=function(){return Nc()};async function Cd(e,t,r,i){return e=await(async(n,s,a,c,l)=>{if(s&&await Ic(s),!self.ModuleFactory||a&&(await Ic(a),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&l&&((s=self.Module).locateFile=l.locateFile,l.mainScriptUrlOrBlob&&(s.mainScriptUrlOrBlob=l.mainScriptUrlOrBlob)),l=await self.ModuleFactory(self.Module||l),self.ModuleFactory=self.Module=void 0,new n(l,c)})(e,r.wasmLoaderPath,r.assetLoaderPath,t,{locateFile:n=>n.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&n.endsWith(".data")?r.assetBinaryPath.toString():n}),await e.o(i),e}function ks(e,t){const r=P(e.baseOptions,Di,1)||new Di;typeof t=="string"?(G(r,2,hr(t)),G(r,1)):t instanceof Uint8Array&&(G(r,1,bn(t,!1)),G(r,2)),S(e.baseOptions,0,1,r)}function Pc(e){try{const t=e.G.length;if(t===1)throw Error(e.G[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.G.map(r=>r.message).join(", "))}finally{e.G=[]}}function x(e,t){e.B=Math.max(e.B,t)}function Ui(e,t){e.A=new be,Me(e.A,"PassThroughCalculator"),V(e.A,"free_memory"),L(e.A,"free_memory_unused_out"),$(t,"free_memory"),Le(t,e.A)}function Ar(e,t){V(e.A,t),L(e.A,t+"_unused_out")}function Gi(e){e.g.addBoolToStream(!0,"free_memory",e.B)}var Es=class{constructor(e){this.g=e,this.G=[],this.B=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){var r,i,n,s,a,c;if(t){const l=e.baseOptions||{};if((r=e.baseOptions)!=null&&r.modelAssetBuffer&&((i=e.baseOptions)!=null&&i.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((n=P(this.baseOptions,Di,1))!=null&&n.g()||(s=P(this.baseOptions,Di,1))!=null&&s.h()||(a=e.baseOptions)!=null&&a.modelAssetBuffer||(c=e.baseOptions)!=null&&c.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(u,h){let f=P(u.baseOptions,ic,3);if(!f){var w=f=new ic,m=new Ua;$r(w,4,Pi,m)}"delegate"in h&&(h.delegate==="GPU"?(h=f,w=new id,$r(h,2,Pi,w)):(h=f,w=new Ua,$r(h,4,Pi,w))),S(u.baseOptions,0,3,f)}(this,l),l.modelAssetPath)return fetch(l.modelAssetPath.toString()).then(u=>{if(u.ok)return u.arrayBuffer();throw Error(`Failed to fetch model: ${l.modelAssetPath} (${u.status})`)}).then(u=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(u),!0,!1,!1),ks(this,"/model.dat"),this.m(),this.J()});if(l.modelAssetBuffer instanceof Uint8Array)ks(this,l.modelAssetBuffer);else if(l.modelAssetBuffer)return async function(u){const h=[];for(var f=0;;){const{done:w,value:m}=await u.read();if(w)break;h.push(m),f+=m.length}if(h.length===0)return new Uint8Array(0);if(h.length===1)return h[0];u=new Uint8Array(f),f=0;for(const w of h)u.set(w,f),f+=w.length;return u}(l.modelAssetBuffer).then(u=>{ks(this,u),this.m(),this.J()})}return this.m(),this.J(),Promise.resolve()}J(){}ca(){let e;if(this.g.ca(t=>{e=nd(t)}),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener((r,i)=>{this.G.push(Error(i))}),this.g.Ha(),this.g.setGraph(e,t),this.A=void 0,Pc(this)}finishProcessing(){this.g.finishProcessing(),Pc(this)}close(){this.A=void 0,this.g.closeGraph()}};function bt(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}Es.prototype.close=Es.prototype.close;class Id{constructor(t,r,i,n){this.g=t,this.h=r,this.m=i,this.l=n}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function Dc(e,t,r){const i=e.g;if(r=bt(i.createShader(r),"Failed to create WebGL shader"),i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${i.getShaderInfoLog(r)}`);return i.attachShader(e.h,r),r}function Rc(e,t){const r=e.g,i=bt(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(i);const n=bt(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,n),r.enableVertexAttribArray(e.P),r.vertexAttribPointer(e.P,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);const s=bt(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,s),r.enableVertexAttribArray(e.J),r.vertexAttribPointer(e.J,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.bindVertexArray(null),new Id(r,i,n,s)}function Ss(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function As(e,t,r,i){return Ss(e,t),e.h||(e.m(),e.C()),r?(e.s||(e.s=Rc(e,!0)),r=e.s):(e.v||(e.v=Rc(e,!1)),r=e.v),t.useProgram(e.h),r.bind(),e.l(),e=i(),r.g.bindVertexArray(null),e}function Vi(e,t,r){return Ss(e,t),e=bt(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r??t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r??t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),e}function $i(e,t,r){Ss(e,t),e.A||(e.A=bt(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.A),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0)}function Ts(e){var t;(t=e.g)==null||t.bindFramebuffer(e.g.FRAMEBUFFER,null)}var js=class{G(){return`
9
+ */var Sl=Symbol.for("react.transitional.element"),Al=Symbol.for("react.fragment");function Xs(e,t,r){var i=null;if(r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),"key"in t){r={};for(var n in t)n!=="key"&&(r[n]=t[n])}else r=t;return t=r.ref,{$$typeof:Sl,type:e,key:i,ref:t!==void 0?t:null,props:r}}ei.Fragment=Al,ei.jsx=Xs,ei.jsxs=Xs,Ks.exports=ei;var o=Ks.exports;const nn={},it={api:{baseUrl:"/api",retryConfig:{attempts:3,backoff:"exponential",baseDelay:1e3}},ui:{baseColor:"#3B82F6",borderRadius:"8px"},interview:{timers:{thinkingDuration:30,answeringDuration:120,editingDuration:30},stt:{provider:"groq",model:"whisper-large-v3-turbo",language:"en"},tts:{provider:"piper"},proctoring:{enabled:!0,gazeAnalysisEnabled:!0}}},sn="iw-storage";function Tl(){if(!(typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:rn&&rn.tagName.toUpperCase()==="SCRIPT"&&rn.src||new URL("widget.umd.js",document.baseURI).href}<"u"&&(nn!=null&&nn.VITE_IW_SECRET)))return typeof process<"u"&&process.env.NEXT_PUBLIC_IW_SECRET?process.env.NEXT_PUBLIC_IW_SECRET:typeof window<"u"&&window.__IW_SECRET__?window.__IW_SECRET__:"proctoring-data-seed"}const Qs=Tl(),ti=30,jl={SCREENSHOT:"screenshot"},on="AES-GCM",an=12;async function Js(e){const r=new TextEncoder().encode(e),i=await crypto.subtle.digest("SHA-256",r);return crypto.subtle.importKey("raw",i,on,!1,["encrypt","decrypt"])}function Nl(){return crypto.getRandomValues(new Uint8Array(an))}async function Cl(e,t="default-seed"){try{const r=typeof e=="string"?e:JSON.stringify(e),n=new TextEncoder().encode(r),s=await Js(t),a=Nl(),c=await crypto.subtle.encrypt({name:on,iv:a},s,n),l=new Uint8Array(a.length+c.byteLength);return l.set(new Uint8Array(a),0),l.set(new Uint8Array(c),a.length),btoa(String.fromCharCode(...Array.from(l)))}catch(r){throw console.error("Encryption failed:",r),new Error("Failed to encrypt data")}}async function Il(e,t="default-seed"){try{const r=atob(e),i=new Uint8Array(r.length);for(let u=0;u<r.length;u++)i[u]=r.charCodeAt(u);const n=i.slice(0,an),s=i.slice(an),a=await Js(t),c=await crypto.subtle.decrypt({name:on,iv:n},a,s);return new TextDecoder().decode(c)}catch(r){throw console.error("Decryption failed:",r),new Error("Failed to decrypt data")}}async function Ml(e,t="default-seed"){return Cl(e,t)}async function Ll(e,t="default-seed"){const r=await Il(e,t);try{return JSON.parse(r)}catch{return r}}const Ir=d.createContext(null),Fl=async()=>{try{const e=sessionStorage.getItem(sn);if(e){const r=(await Ll(e,Qs)).state;return{logViolations:(r==null?void 0:r.logViolations)||[],totalViolations:(r==null?void 0:r.totalViolations)||0,gazeViolationCounters:(r==null?void 0:r.gazeViolationCounters)||{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:(r==null?void 0:r.referenceSet)??!1,referenceRef:(r==null?void 0:r.referenceRef)??{x:.5,y:.5,noseX:.5,noseY:.5}}}}catch(e){console.error("Failed to load proctoring data from session storage:",e)}return{logViolations:[],totalViolations:0,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:!1,referenceRef:{x:.5,y:.5,noseX:.5,noseY:.5}}},Mr=async e=>{try{const t=await Ml({state:e,version:0},Qs);sessionStorage.setItem(sn,t)}catch(t){console.error("Failed to save proctoring data to session storage:",t)}},Pl=({children:e})=>{const t=d.useRef({logViolations:[],totalViolations:0,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0},referenceSet:!1,referenceRef:{x:.5,y:.5,noseX:.5,noseY:.5}}),r=d.useRef(new Set);d.useEffect(()=>{Fl().then(w=>{t.current=w,i()})},[]);const i=d.useCallback(()=>{r.current.forEach(w=>w())},[]),n=d.useCallback(w=>(r.current.add(w),()=>{r.current.delete(w)}),[]),s=d.useCallback(()=>t.current,[]),a=d.useCallback(w=>{t.current={...t.current,logViolations:[...t.current.logViolations,w],totalViolations:t.current.totalViolations+1},Mr(t.current),i()},[i]),c=d.useCallback(w=>{const m={...t.current.gazeViolationCounters};w==="looking_away"&&(m.lookingAwayCount+=1),w==="no_face_detected"&&(m.noFaceDetectedCount+=1),w==="multiple_faces"&&(m.multipleFacesCount+=1),m.totalGazeViolations=m.lookingAwayCount+m.noFaceDetectedCount+m.multipleFacesCount,t.current={...t.current,gazeViolationCounters:m},Mr(t.current),i()},[i]),l=d.useCallback(()=>{t.current={...t.current,logViolations:[],totalViolations:0},Mr(t.current),i()},[i]),u=d.useCallback(()=>{t.current={...t.current,gazeViolationCounters:{lookingAwayCount:0,noFaceDetectedCount:0,multipleFacesCount:0,totalGazeViolations:0}},Mr(t.current),i()},[i]),h=d.useCallback((w,m)=>{t.current={...t.current,referenceSet:w,referenceRef:m},Mr(t.current),i()},[i]),f=d.useMemo(()=>({getState:s,addViolation:a,clearViolations:l,subscribe:n,incrementGazeViolation:c,clearGazeViolationCounters:u,setReferenceData:h}),[s,a,l,n,c,u,h]);return o.jsx(Ir.Provider,{value:f,children:e})},Zs=()=>{const e=d.useContext(Ir);if(!e)throw new Error("useProctoringStore must be used within a ProctoringProvider");const t=d.useSyncExternalStore(e.subscribe,e.getState,e.getState);return{logViolations:t.logViolations,totalViolations:t.totalViolations,addViolation:e.addViolation,clearViolations:e.clearViolations,gazeViolationCounters:t.gazeViolationCounters,referenceSet:t.referenceSet,referenceRef:t.referenceRef,incrementGazeViolation:e.incrementGazeViolation,clearGazeViolationCounters:e.clearGazeViolationCounters,setReferenceData:e.setReferenceData}},Dl=()=>{const e=d.useContext(Ir);if(!e)throw new Error("useViolations must be used within a ProctoringProvider");return d.useSyncExternalStore(e.subscribe,()=>e.getState().logViolations,()=>e.getState().logViolations)},Rl=()=>{const e=d.useContext(Ir);if(!e)throw new Error("useTotalViolations must be used within a ProctoringProvider");return d.useSyncExternalStore(e.subscribe,()=>e.getState().totalViolations,()=>e.getState().totalViolations)},Ol=()=>{const e=d.useContext(Ir);if(!e)throw new Error("useProctoringActions must be used within a ProctoringProvider");return{addViolation:e.addViolation,clearViolations:e.clearViolations}},eo=d.createContext(null);function to({config:e={},children:t}){var i,n,s,a;const r={api:{...it.api,...e.api,retryConfig:{...it.api.retryConfig,...(i=e.api)==null?void 0:i.retryConfig}},ui:{...it.ui,...e.ui},interview:{...it.interview,...e.interview,timers:{...it.interview.timers,...(n=e.interview)==null?void 0:n.timers},stt:{...it.interview.stt,...(s=e.interview)==null?void 0:s.stt},tts:{...it.interview.tts,...(a=e.interview)==null?void 0:a.tts}}};return o.jsx(eo.Provider,{value:r,children:o.jsx(Pl,{children:t})})}function ri(){const e=d.useContext(eo);if(!e)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return e}function ro(){return ri().api||it.api}function rr(){return ri().ui||it.ui}function cn(){return ri().interview||it.interview}const io=({className:e,...t})=>o.jsx("div",{children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`iw-animate-spin ${e}`,...t,children:[o.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),o.jsx("path",{d:"M12 6l0 -3"}),o.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),o.jsx("path",{d:"M18 12l3 0"}),o.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),o.jsx("path",{d:"M12 18l0 3"}),o.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),o.jsx("path",{d:"M6 12l-3 0"}),o.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),no=({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",u={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"},h={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} ${u[t]} ${h[r]} ${w} ${f} ${a}`,disabled:s||n,...c,children:[n&&o.jsx(io,{height:16,width:16,style:{marginRight:"3px"}}),e]})};function Bl(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function Ul(e,t,r){return"#"+[e,t,r].map(i=>{const n=Math.round(i).toString(16);return n.length===1?"0"+n:n}).join("")}function so(e,t){const r=Bl(e);if(!r)return e;const i=r.r+(255-r.r)*t,n=r.g+(255-r.g)*t,s=r.b+(255-r.b)*t;return Ul(i,n,s)}function Gl(e,t=.8){return{background:`linear-gradient(to bottom, ${so(e,t)}, #ffffff)`,color:"#1f2937"}}function Vl(e){return new Promise(t=>setTimeout(t,e))}function oo(e){return`linear-gradient(to left, ${so(e,.4)}, ${e})`}const $l=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);function Wl(e){try{const t=e.split(".");if(t.length!==3||!t[1])throw new Error("Invalid JWT token");const i=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=i.padEnd(i.length+(4-i.length%4)%4,"="),s=atob(n);return JSON.parse(s)}catch(t){return console.error("Error decoding JWT:",t),null}}const zl=e=>{var t;return!e||typeof e!="string"?"":(t=e.charAt(0))==null?void 0:t.toUpperCase()},ao=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]}),co=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),o.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),o.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),Hl=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),o.jsx("path",{d:"M15 8a5 5 0 0 1 0 8"}),o.jsx("path",{d:"M6 15h-2a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h2l3.5 -4.5a.8 .8 0 0 1 1.5 .5v14a.8 .8 0 0 1 -1.5 .5l-3.5 -4.5"})]}),Qe=e=>{const{baseColor:t,borderRadius:r}=rr(),{loading:i,children:n,...s}=e;return o.jsx(no,{style:{background:oo(t),borderRadius:r},...s,children:i?o.jsx(io,{}):n})},ii=({isOpen:e,onClose:t,children:r,title:i,showCloseButton:n=!0,closeOnOverlayClick:s=!0,closeOnEscape:a=!0,className:c=""})=>{if(d.useEffect(()=>{if(!e||!a)return;const h=f=>{f.key==="Escape"&&t()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,a,t]),d.useEffect(()=>(e?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[e]),!e)return null;const l=h=>{s&&h.target===h.currentTarget&&t()},u=o.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center",children:[o.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",onClick:l}),o.jsxs("div",{className:`iw-relative iw-bg-white iw-rounded-lg iw-shadow-xl iw-max-w-md iw-w-full iw-mx-4 iw-max-h-[90vh] iw-overflow-hidden ${c}`,role:"dialog","aria-modal":"true","aria-labelledby":i?"dialog-title":void 0,children:[(i||n)&&o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[i&&o.jsx("h2",{id:"dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:i}),n&&o.jsx("button",{onClick:t,className:"iw-p-1 iw-text-gray-400 iw-hover:text-gray-600 iw-transition-colors iw-rounded iw-hover:bg-gray-100","aria-label":"Close dialog",children:o.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),o.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:r})]})]});return tr.createPortal(u,document.body)},ql=e=>o.jsxs("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-info-icon prefix__lucide-info",...e,children:[o.jsx("circle",{cx:12,cy:12,r:10}),o.jsx("path",{d:"M12 16v-4M12 8h.01"})]}),Yl=e=>o.jsx("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-scan-face-icon prefix__lucide-scan-face",...e,children:o.jsx("path",{d:"M3 7V5a2 2 0 012-2h2M17 3h2a2 2 0 012 2v2M21 17v2a2 2 0 01-2 2h-2M7 21H5a2 2 0 01-2-2v-2M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01"})});function Kl({isOpen:e,onDecline:t,onContinue:r}){return o.jsx(ii,{isOpen:e,showCloseButton:!1,onClose:t,className:"iw-overflow-y-auto",children:e&&o.jsx("div",{className:"iw-bg-white iw-border-slate-200 iw-rounded-2xl iw-p-0 iw-shadow-xl sm:iw-max-w-xl",children:o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-4",children:[o.jsx("div",{className:"iw--mt-0.5 iw-h-2.5 iw-w-full iw-rounded-t-2xl iw-bg-gradient-to-r iw-from-blue-500 iw-to-indigo-500"}),o.jsx("div",{className:"iw-sr-only",children:"Face Data Usage Notice"}),o.jsx("div",{className:"iw-sr-only",children:"Permission to use face data for interview monitoring"}),o.jsxs("div",{className:"iw-px-8 iw-py-8",children:[o.jsxs("div",{className:"iw-text-center",children:[o.jsx("div",{className:"iw-mx-auto iw-mb-6 iw-flex iw-h-16 iw-w-16 iw-items-center iw-justify-center iw-rounded-full iw-border iw-border-blue-200 iw-bg-gradient-to-br iw-from-blue-50 iw-to-blue-100 iw-shadow-sm iw-ring-1 iw-ring-blue-100",children:o.jsx(Yl,{className:"iw-text-blue-600"})}),o.jsx("h1",{className:"iw-text-zinc-700 iw-mb-6 iw-text-2xl iw-font-semibold iw-tracking-tight",children:"Face Data Usage Notice"})]}),o.jsxs("ul",{className:"iw-mb-4 iw-list-item iw-space-y-4 iw-text-sm iw-leading-relaxed iw-text-gray-700",children:[o.jsx("li",{children:"To ensure the integrity of the interview process, this platform uses your device's camera to monitor your face and gaze direction."}),o.jsx("li",{children:"Your face data is processed only for proctoring purposes (e.g., detecting if you are looking away or off-screen)."}),o.jsx("li",{children:"All processing is limited to the interview session and is used solely to maintain fairness."})]}),o.jsxs("div",{className:"iw-text-zinc-700 iw-flex iw-items-start iw-gap-2 iw-rounded-md iw-border iw-border-blue-100 iw-bg-blue-50/60 iw-p-3 iw-text-sm iw-font-medium",children:[o.jsx(ql,{className:"iw-text-neutral-400 iw-mt-0.5 iw-inline-block iw-size-4 iw-flex-shrink-0"}),o.jsx("p",{className:"",children:"Please note that we do not store, share, or use your biometric data beyond the scope of this interview."})]}),o.jsx("p",{className:"iw-text-neutral-400 iw-my-4 iw-text-center iw-text-sm",children:"By continuing, you acknowledge and consent to the use of your face data exclusively for interview monitoring purposes."}),o.jsxs("div",{className:"iw-flex iw-gap-3 iw-border-t iw-border-gray-200/80 iw-pt-6",children:[o.jsx(Qe,{onClick:t,className:"iw-flex-1 iw-border",children:"Decline"}),o.jsx(Qe,{onClick:r,className:"iw-flex-1",children:"I Understand & Continue"})]})]})]})})})}function Xl(e){var t;if(!navigator.onLine)return{type:"network",message:"No internet connection",retryable:!0,userMessage:"Please check your internet connection and try again."};if(e.name==="AbortError"||(t=e.message)!=null&&t.includes("timeout"))return{type:"timeout",message:"Request timed out",retryable:!0,userMessage:"The request is taking longer than expected. Please try again."};if(e.status){const{status:r}=e;if(r===401||r===403)return{type:"auth",status:r,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(r===429)return{type:"rate-limit",status:r,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(r>=500)return{type:"server",status:r,message:`Server error: ${r}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(r>=400)return{type:"client",status:r,message:`Client error: ${r}`,retryable:!1,userMessage:"There was an issue with your request. Please check your input."}}return{type:"unknown",message:e.message||"Unknown error occurred",retryable:!0,userMessage:"Something unexpected happened. Please try again.",originalError:e}}async function Bt(e,t={},r={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let i;for(let n=1;n<=r.attempts;n++)try{const s=new AbortController,a=setTimeout(()=>s.abort(),6e4),c=await fetch(e,{...t,signal:s.signal});if(clearTimeout(a),c.status>=400&&c.status<500&&c.status!==429)return c;if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);return c}catch(s){i=s;const a=Xl(s);if(!a.retryable||n===r.attempts)throw a;const c=Ql(n,r);console.warn(`API request failed (attempt ${n}/${r.attempts}), retrying in ${c}ms:`,a.message),await new Promise(l=>setTimeout(l,c))}throw i}function Ql(e,t){let r;return t.backoff==="exponential"?r=t.baseDelay*Math.pow(2,e-1):r=t.baseDelay,r=Math.min(r,t.maxDelay),t.jitter&&(r=r*(.5+Math.random()*.5)),Math.round(r)}const Ut={v2:"/v2"},Gt={GENERATE_QUESTION:e=>`${Ut.v2}/interviews/${e}/next-question`,SCREENSHOT_UPLOAD:e=>`${Ut.v2}/interviews/${e}/assets/upload-url`,CONFIRM_UPLOAD:e=>`${Ut.v2}/interviews/assets/${e}/confirm`,TRANSCRIBE_ANSWER:e=>`${Ut.v2}/interviews/${e}/transcribe-answer`,SUBMIT_ANSWER:e=>`${Ut.v2}/interviews/${e}/submit-answer`,EXIT:e=>`${Ut.v2}/interviews/${e}/exit`,CONFIG:e=>`${Ut.v2}/interviews/${e}/config`};class Jl{constructor(t={}){Oe(this,"config");this.config=t}updateConfig(t){this.config={...this.config,...t}}getHeaders(){var r;const t={"Content-Type":"application/json"};return(r=this.config)!=null&&r.authToken&&(t.Authorization=`Bearer ${this.config.authToken}`),t}getBaseUrl(){var t;return((t=this.config)==null?void 0:t.baseUrl)||"/api"}async generateQuestion({interviewId:t,isInterviewDone:r=!1}){const i=await Bt(`${this.getBaseUrl()}${Gt.GENERATE_QUESTION(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:t,is_interview_done:r})});if(!i.ok)throw new Error(`Failed to get questions: ${i.status}`);return await i.json()}async submitAnswer({interviewId:t,qnaId:r,answer:i}){const n=await Bt(`${this.getBaseUrl()}${Gt.SUBMIT_ANSWER(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({qna_id:r,answer_text:i})});if(!n.ok)throw new Error(`Failed to submit answer: ${n.status}`);return await n.json()}async exitInterview(t){const r=await Bt(`${this.getBaseUrl()}${Gt.EXIT(t)}`,{method:"POST",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to exit interview: ${r.status}`)}async getInterviewConfig(t){const r=await Bt(`${this.getBaseUrl()}${Gt.CONFIG(t)}`,{method:"GET",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to get interview config: ${r.status}`);return await r.json()}async requestScreenshotUploadUrl(t,r=`screenshot-${Date.now()}.jpeg`){const i=await Bt(`${this.getBaseUrl()}${Gt.SCREENSHOT_UPLOAD(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({filename:r,mime_type:"image/jpeg",asset_type:jl.SCREENSHOT})});if(!i.ok)throw new Error(`Failed to request screenshot upload URL: ${i.status}`);return await i.json()}async uploadScreenshot(t,r){const i=await fetch(t,{method:"PUT",body:r,headers:{"Content-Type":"image/jpeg"}});if(!i.ok)throw new Error(`Failed to upload screenshot: ${i.status}`)}async confirmScreenshotUpload(t){const r=await Bt(`${this.getBaseUrl()}${Gt.CONFIRM_UPLOAD(t)}`,{method:"POST",headers:this.getHeaders()});if(!r.ok)throw new Error(`Failed to confirm screenshot upload: ${r.status}`)}}function lo(){const e=ri();return d.useMemo(()=>{const r=e.api||{};return new Jl(r)},[e.api])}const Lr=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),o.jsx("path",{d:"M12 9v4"}),o.jsx("path",{d:"M12 17h.01"})]}),ln=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),o.jsx("path",{d:"M12 6v6l4 2"}),o.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),o.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),o.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),o.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),Zl=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M12 6v6l4 2"}),o.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),uo=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),o.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),eu=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),o.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),o.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),o.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),un=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),o.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),o.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),o.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),tu=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("circle",{cx:"12",cy:"12",r:"3"}),o.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),o.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),o.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),o.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),ru=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-bolt-icon prefix__lucide-bolt",...e,children:[o.jsx("path",{d:"M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"}),o.jsx("circle",{cx:12,cy:12,r:4})]}),iu=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-camera-off-icon prefix__lucide-camera-off",...e,children:[o.jsx("path",{d:"M14.564 14.558a3 3 0 11-4.122-4.121M2 2l20 20"}),o.jsx("path",{d:"M20 20H4a2 2 0 01-2-2V9a2 2 0 012-2h1.997a2 2 0 00.819-.175M9.695 4.024A2 2 0 0110.004 4h3.993a2 2 0 011.76 1.05l.486.9A2 2 0 0018.003 7H20a2 2 0 012 2v7.344"})]}),nu=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-target-icon prefix__lucide-target",...e,children:[o.jsx("circle",{cx:12,cy:12,r:10}),o.jsx("circle",{cx:12,cy:12,r:6}),o.jsx("circle",{cx:12,cy:12,r:2})]}),su=e=>o.jsxs("svg",{width:24,height:24,fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"prefix__lucide prefix__lucide-users-icon prefix__lucide-users",...e,children:[o.jsx("path",{d:"M16 21v-2a4 4 0 00-4-4H6a4 4 0 00-4 4v2M16 3.128a4 4 0 010 7.744M22 21v-2a4 4 0 00-3-3.87"}),o.jsx("circle",{cx:9,cy:7,r:4})]}),Fr={FACE_DETECTED:"face_detected",NO_FACE:"no_face_detected",MULTIPLE_FACES:"multiple_faces",LOOKING_AWAY:"looking_away",CAMERA_ERROR:"camera_error"},ou={[Fr.FACE_DETECTED]:{icon:uo,iconColor:"iw-text-green-600",iconBg:"iw-bg-green-50",iconBorder:"iw-border-green-100",title:"All Good",subtitle:"Everything looks normal",description:"Your gaze is properly focused on the screen. Continue with your interview.",buttonText:"Continue"},[Fr.NO_FACE]:{icon:iu,iconColor:"iw-text-orange-600",iconBg:"iw-bg-orange-50",iconBorder:"iw-border-orange-100",title:"Face Not Detected",subtitle:"We can't see you in the camera",description:"Please ensure you're positioned properly in front of the camera and that your face is clearly visible.",buttonText:"I Understood"},[Fr.MULTIPLE_FACES]:{icon:su,iconColor:"iw-text-red-600",iconBg:"iw-bg-red-50",iconBorder:"iw-border-red-100",title:"Multiple People Detected",subtitle:"More than one person is visible",description:"For interview integrity, please ensure you are alone in the room and only your face is visible to the camera.",buttonText:"I Understood"},[Fr.LOOKING_AWAY]:{icon:nu,iconColor:"iw-text-amber-600",iconBg:"iw-bg-amber-50",iconBorder:"iw-border-amber-200/75",title:"Stay Focused",subtitle:"We noticed you looked away from the screen",description:"To ensure interview integrity, please keep your attention on the screen throughout the session.",buttonText:"I Understood"},[Fr.CAMERA_ERROR]:{icon:Lr,iconColor:"iw-text-red-600",iconBg:"iw-bg-red-50",iconBorder:"iw-border-red-100",title:"Camera Issue",subtitle:"There's a problem with your camera",description:"Please check your camera connection and permissions, then refresh the page to continue.",buttonText:"I Understood"}};function au({isOpen:e,onClose:t,warningType:r}){const i=ou[r],n=i.icon,s=()=>{t()};return r==="face_detected"?null:o.jsx(ii,{isOpen:e,onClose:t,children:e&&o.jsx("div",{className:"iw-bg-white iw-border-white iw-border iw-p-0 iw-shadow-lg sm:iw-max-w-md",children:o.jsxs("div",{children:[o.jsx("div",{className:"iw-sr-only",children:i.description}),o.jsxs("div",{className:"iw-px-8 iw-py-8 iw-text-center",children:[o.jsx("div",{className:`iw-mx-auto iw-mb-6 iw-flex iw-h-16 iw-w-16 iw-items-center iw-justify-center iw-rounded-full ${i.iconBg} border ${i.iconBorder}`,children:o.jsx(n,{className:`iw-h-7 iw-w-7 ${i.iconColor}`})}),o.jsx("h1",{className:"iw-text-foreground iw-mb-3 iw-text-2xl iw-font-bold iw-tracking-tight",children:i.title}),o.jsx("h2",{className:"iw-text-gray-500 iw-mb-6 iw-text-base iw-font-medium",children:i.subtitle}),o.jsx("p",{className:"iw-text-neutral-400 iw-mx-auto iw-mb-8 iw-max-w-sm iw-text-sm iw-leading-relaxed",children:i.description}),o.jsx(Qe,{onClick:s,className:"iw-w-full iw-bg-gray-800 iw-text-white hover:iw-bg-gray-800",children:i.buttonText})]})]})})})}const cu=({gazeAnalysisEnabled:e,isModelLoaded:t,stats:r,statusMessage:i,loadingProgress:n})=>o.jsx("div",{className:"iw-w-full",children:o.jsxs("div",{className:"iw-border-strock iw-rounded-md iw-border iw-bg-gray-50 iw-p-4",children:[o.jsxs("h3",{className:"iw-m-0 iw-mb-2.5",children:["Status: ",i]}),n>0&&n<100&&o.jsxs("div",{className:"iw-mb-2.5",children:[o.jsx("div",{className:"iw-h-2 iw-w-full iw-rounded iw-bg-gray-300",children:o.jsx("div",{className:"iw-h-full iw-rounded iw-bg-blue-600 iw-transition-all iw-duration-300 iw-ease-out",style:{width:`${n}%`}})}),o.jsxs("small",{className:"iw-text-gray-600",children:["Loading model... ",n.toFixed(1),"%"]})]}),o.jsxs("div",{className:"iw-grid iw-grid-cols-2 iw-gap-2.5 iw-text-sm",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"FPS:"})," ",o.jsx("span",{className:r.fps<15?"iw-text-red-600":r.fps<25?"iw-text-orange-500":"iw-text-green-600",children:r.fps})]}),o.jsxs("div",{children:[o.jsx("strong",{children:"Model:"})," ",t?"✓ Loaded":"✗ Loading"]}),e&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("strong",{children:"Engagement:"})," ",r.engagement.toFixed(1),"%"]}),o.jsxs("div",{children:[o.jsx("strong",{children:"Looking:"})," ",o.jsx("span",{className:r.isLookingAway?"iw-text-red-600":"iw-text-green-600",children:r.isLookingAway?"Away":"At Screen"})]})]})]}),r.referenceFaceNotDetected&&o.jsxs("div",{className:"iw-text-gray-dark iw-mt-2.5 iw-w-full iw-rounded-md iw-bg-[#ffeb3b] iw-p-2.5 iw-text-sm",children:[o.jsx("strong",{children:"Reference Face Not Detected"}),o.jsx("br",{}),"The previously set reference face is no longer in view."]}),r.multipleFacesDetected&&o.jsxs("div",{className:"iw-mt-2.5 iw-rounded iw-bg-red-50 iw-p-2.5 iw-text-sm iw-text-red-700",children:[o.jsx("strong",{children:"Multiple Faces Detected"}),o.jsx("br",{}),"Please ensure only one person is in the frame."]}),!e&&o.jsxs("div",{className:"iw-mt-2.5 iw-rounded iw-bg-blue-50 iw-p-2.5 iw-text-sm iw-text-blue-700",children:[o.jsx("strong",{children:"Gaze Analysis Disabled"}),o.jsx("br",{}),"Enable to track engagement and attention levels."]})]})}),lu=({showControls:e,isBubbleOpen:t,setIsBubbleOpen:r,setReference:i,clearCache:n,isModelLoaded:s,gazeAnalysisEnabled:a,referenceSet:c,showLandmarks:l,setShowLandmarks:u,showEngagementBar:h,setShowEngagementBar:f,handleToggleGazeAnalysis:w,stats:m,statusMessage:g,loadingProgress:b})=>e?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>r(!t),className:"iw-absolute iw-right-4 iw-bottom-4 iw-z-10 iw-flex iw-h-10 iw-w-10 iw-items-center iw-justify-center iw-rounded-full iw-text-white",children:o.jsx(ru,{className:"iw-size-4.5"})}),t&&o.jsxs("div",{className:"iw-absolute iw-right-4 iw-bottom-16 iw-z-10 iw-max-h-96 iw-w-80 iw-overflow-y-auto iw-rounded-md iw-bg-gray-50 iw-p-4 iw-shadow-lg",children:[o.jsx("h4",{className:"m-0 mb-2.5",children:"Controls"}),o.jsx("button",{onClick:i,disabled:!s||!a,className:`iw-mb-2.5 iw-block iw-w-full iw-rounded border-none iw-px-4 iw-py-2 iw-text-sm iw-text-white ${!s||!a?"iw-cursor-not-allowed iw-bg-gray-400":"iw-cursor-pointer iw-bg-blue-600 hover:iw-bg-blue-700"}`,children:c?"Reference Set ✓":"Set Reference"}),o.jsx("button",{onClick:n,className:"iw-mb-4 iw-block iw-w-full iw-cursor-pointer iw-rounded iw-border-none iw-bg-red-600 iw-px-4 iw-py-2 iw-text-sm iw-text-white hover:iw-bg-red-700",children:"Clear Model Cache"}),o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-2.5",children:[o.jsxs("label",{className:"iw-flex iw-cursor-pointer iw-items-center iw-gap-2",children:[o.jsx("input",{type:"checkbox",checked:a,onChange:_=>w(_.target.checked)}),o.jsx("strong",{children:"Enable Gaze Analysis"})]}),o.jsxs("label",{className:`iw-flex iw-cursor-pointer iw-items-center iw-gap-2 ${a?"iw-opacity-100":"iw-opacity-60"}`,children:[o.jsx("input",{type:"checkbox",checked:l,onChange:_=>u(_.target.checked),disabled:!a}),"Show Landmarks"]}),o.jsxs("label",{className:`iw-flex iw-cursor-pointer iw-items-center iw-gap-2 ${a?"iw-opacity-100":"iw-opacity-60"}`,children:[o.jsx("input",{type:"checkbox",checked:h,onChange:_=>f(_.target.checked),disabled:!a}),"Show Engagement Bar"]})]}),c&&o.jsx(cu,{gazeAnalysisEnabled:a,isModelLoaded:s,loadingProgress:b,stats:m,statusMessage:g})]})]}):null;var ir=typeof self<"u"?self:{};function Vt(){throw Error("Invalid UTF8")}function ho(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}let ni,dn;const uu=typeof TextDecoder<"u";let du;const hu=typeof TextEncoder<"u";function fo(e){if(hu)e=(du||(du=new TextEncoder)).encode(e);else{let r=0;const i=new Uint8Array(3*e.length);for(let n=0;n<e.length;n++){var t=e.charCodeAt(n);if(t<128)i[r++]=t;else{if(t<2048)i[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&n<e.length){const s=e.charCodeAt(++n);if(s>=56320&&s<=57343){t=1024*(t-55296)+s-56320+65536,i[r++]=t>>18|240,i[r++]=t>>12&63|128,i[r++]=t>>6&63|128,i[r++]=63&t|128;continue}n--}t=65533}i[r++]=t>>12|224,i[r++]=t>>6&63|128}i[r++]=63&t|128}}e=r===i.length?i:i.subarray(0,r)}return e}var hn,si;e:{for(var wo=["CLOSURE_FLAGS"],fn=ir,wn=0;wn<wo.length;wn++)if((fn=fn[wo[wn]])==null){si=null;break e}si=fn}var Pr,mo=si&&si[610401301];hn=mo!=null&&mo;const go=ir.navigator;function mn(e){return!!hn&&!!Pr&&Pr.brands.some(({brand:t})=>t&&t.indexOf(e)!=-1)}function Be(e){var t;return(t=ir.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function Et(){return!!hn&&!!Pr&&Pr.brands.length>0}function gn(){return Et()?mn("Chromium"):(Be("Chrome")||Be("CriOS"))&&!(!Et()&&Be("Edge"))||Be("Silk")}function oi(e){return oi[" "](e),e}Pr=go&&go.userAgentData||null,oi[" "]=function(){};var fu=!Et()&&(Be("Trident")||Be("MSIE"));!Be("Android")||gn(),gn(),Be("Safari")&&(gn()||!Et()&&Be("Coast")||!Et()&&Be("Opera")||!Et()&&Be("Edge")||(Et()?mn("Microsoft Edge"):Be("Edg/"))||Et()&&mn("Opera"));var po={},Dr=null;function wu(e){const t=e.length;let r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);const i=new Uint8Array(r);let n=0;return function(s,a){function c(u){for(;l<s.length;){const h=s.charAt(l++),f=Dr[h];if(f!=null)return f;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return u}xo();let l=0;for(;;){const u=c(-1),h=c(0),f=c(64),w=c(64);if(w===64&&u===-1)break;a(u<<2|h>>4),f!=64&&(a(h<<4&240|f>>2),w!=64&&a(f<<6&192|w))}}(e,function(s){i[n++]=s}),n!==r?i.subarray(0,n):i}function xo(){if(!Dr){Dr={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const i=e.concat(t[r].split(""));po[r]=i;for(let n=0;n<i.length;n++){const s=i[n];Dr[s]===void 0&&(Dr[s]=n)}}}}var yo=typeof Uint8Array<"u",bo=!fu&&typeof btoa=="function";function vo(e){if(!bo){var t;t===void 0&&(t=0),xo(),t=po[t];var r=Array(Math.floor(e.length/3)),i=t[64]||"";let l=0,u=0;for(;l<e.length-2;l+=3){var n=e[l],s=e[l+1],a=e[l+2],c=t[n>>2];n=t[(3&n)<<4|s>>4],s=t[(15&s)<<2|a>>6],a=t[63&a],r[u++]=c+n+s+a}switch(c=0,a=i,e.length-l){case 2:a=t[(15&(c=e[l+1]))<<2]||i;case 1:e=e[l],r[u]=t[e>>2]+t[(3&e)<<4|c>>4]+a+i}return r.join("")}for(t="",r=0,i=e.length-10240;r<i;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}const _o=/[-_.]/g,mu={"-":"+",_:"/",".":"="};function gu(e){return mu[e]||""}function ko(e){if(!bo)return wu(e);_o.test(e)&&(e=e.replace(_o,gu)),e=atob(e);const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function $t(e){return yo&&e!=null&&e instanceof Uint8Array}var nr={};function Wt(){return pu||(pu=new wt(null,nr))}function pn(e){Eo(nr);var t=e.g;return(t=t==null||$t(t)?t:typeof t=="string"?ko(t):null)==null?t:e.g=t}var wt=class{h(){return new Uint8Array(pn(this)||0)}constructor(e,t){if(Eo(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}};let pu,xu;function Eo(e){if(e!==nr)throw Error("illegal external caller")}function So(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function xn(e){return So(e=Error(e),"warning"),e}function yn(e){if(e!=null){var t=xu??(xu={}),r=t[e]||0;r>=5||(t[e]=r+1,So(e=Error(),"incident"),function(i){ir.setTimeout(()=>{throw i},0)}(e))}}var ai=typeof Symbol=="function"&&typeof Symbol()=="symbol";function sr(e,t,r=!1){return typeof Symbol=="function"&&typeof Symbol()=="symbol"?r&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t}var yu=sr("jas",void 0,!0),Ao=sr(void 0,"0di"),Rr=sr(void 0,"1oa"),or=sr(void 0,Symbol()),bu=sr(void 0,"0actk"),To=sr(void 0,"8utk");const k=ai?yu:"Ea",jo={Ea:{value:0,configurable:!0,writable:!0,enumerable:!1}},No=Object.defineProperties;function ci(e,t){ai||k in e||No(e,jo),e[k]|=t}function ae(e,t){ai||k in e||No(e,jo),e[k]=t}function ar(e){return ci(e,34),e}function vu(e,t){ae(t,-15615&(0|e))}function bn(e,t){ae(t,-15581&(34|e))}function li(){return typeof BigInt=="function"}function ke(e){return Array.prototype.slice.call(e)}var vn,Or={};function ui(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function _n(e,t){if(e!=null){if(typeof e=="string")e=e?new wt(e,nr):Wt();else if(e.constructor!==wt)if($t(e))e=e.length?new wt(new Uint8Array(e),nr):Wt();else{if(!t)throw Error();e=void 0}}return e}const Co=[];function St(e){if(2&e)throw Error()}ae(Co,55),vn=Object.freeze(Co);class Io{constructor(t,r,i){this.g=t,this.h=r,this.l=i}next(){const t=this.g.next();return t.done||(t.value=this.h.call(this.l,t.value)),t}[Symbol.iterator](){return this}}function kn(e){return or?e[or]:void 0}var _u=Object.freeze({});function di(e){return e.Na=!0,e}var ku=di(e=>typeof e=="number"),Mo=di(e=>typeof e=="string"),Eu=di(e=>typeof e=="boolean"),hi=typeof ir.BigInt=="function"&&typeof ir.BigInt(0)=="bigint";function At(e){var t=e;if(Mo(t)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(t))throw Error(String(t))}else if(ku(t)&&!Number.isSafeInteger(t))throw Error(String(t));return hi?BigInt(e):e=Eu(e)?e?"1":"0":Mo(e)?e.trim()||"0":String(e)}var En=di(e=>hi?e>=Au&&e<=ju:e[0]==="-"?Lo(e,Su):Lo(e,Tu));const Su=Number.MIN_SAFE_INTEGER.toString(),Au=hi?BigInt(Number.MIN_SAFE_INTEGER):void 0,Tu=Number.MAX_SAFE_INTEGER.toString(),ju=hi?BigInt(Number.MAX_SAFE_INTEGER):void 0;function Lo(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){const i=e[r],n=t[r];if(i>n)return!1;if(i<n)return!0}}const Nu=typeof Uint8Array.prototype.slice=="function";let Fo,U=0,Z=0;function Po(e){const t=e>>>0;U=t,Z=(e-t)/4294967296>>>0}function zt(e){if(e<0){Po(-e);const[t,r]=jn(U,Z);U=t>>>0,Z=r>>>0}else Po(e)}function Sn(e){const t=Fo||(Fo=new DataView(new ArrayBuffer(8)));t.setFloat32(0,+e,!0),Z=0,U=t.getUint32(0,!0)}function An(e,t){const r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Br(e,t)}function Tn(e,t){const r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=An(e,t))=="number"?r?-e:e:r?"-"+e:e}function Br(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else li()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+Do(r)+Do(e));return r}function Do(e){return e=String(e),"0000000".slice(e.length)+e}function Ro(){var e=U,t=Z;if(2147483648&t)if(li())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{const[r,i]=jn(e,t);e="-"+Br(r,i)}else e=Br(e,t);return e}function fi(e){if(e.length<16)zt(Number(e));else if(li())e=BigInt(e),U=Number(e&BigInt(4294967295))>>>0,Z=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+(e[0]==="-");Z=U=0;const r=e.length;for(let i=t,n=(r-t)%6+t;n<=r;i=n,n+=6){const s=Number(e.slice(i,n));Z*=1e6,U=1e6*U+s,U>=4294967296&&(Z+=Math.trunc(U/4294967296),Z>>>=0,U>>>=0)}if(t){const[i,n]=jn(U,Z);U=i,Z=n}}}function jn(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}const Ur=typeof BigInt=="function"?BigInt.asIntN:void 0,Cu=typeof BigInt=="function"?BigInt.asUintN:void 0,Tt=Number.isSafeInteger,wi=Number.isFinite,cr=Math.trunc,Iu=At(0);function jt(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function Oo(e){return e==null||typeof e=="boolean"?e:typeof e=="number"?!!e:void 0}const Mu=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Gr(e){switch(typeof e){case"bigint":return!0;case"number":return wi(e);case"string":return Mu.test(e);default:return!1}}function lr(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return wi(e)?0|e:void 0}function Bo(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return wi(e)?e>>>0:void 0}function Uo(e){if(e[0]==="-")return!1;const t=e.length;return t<20||t===20&&Number(e.substring(0,6))<184467}function Go(e){const t=e.length;return e[0]==="-"?t<20||t===20&&Number(e.substring(0,7))>-922337:t<19||t===19&&Number(e.substring(0,6))<922337}function Vo(e){return Go(e)?e:(fi(e),Ro())}function Nn(e){return e=cr(e),Tt(e)||(zt(e),e=Tn(U,Z)),e}function $o(e){var t=cr(Number(e));return Tt(t)?String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Vo(e))}function Wo(e){var t=cr(Number(e));return Tt(t)?At(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),li()?At(Ur(64,BigInt(e))):At(Vo(e)))}function zo(e){if(Tt(e))e=At(Nn(e));else{if(e=cr(e),Tt(e))e=String(e);else{const t=String(e);Go(t)?e=t:(zt(e),e=Ro())}e=At(e)}return e}function Cn(e){return e==null?e:typeof e=="bigint"?(En(e)?e=Number(e):(e=Ur(64,e),e=En(e)?Number(e):String(e)),e):Gr(e)?typeof e=="number"?Nn(e):$o(e):void 0}function Lu(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(Cu(64,e));if(Gr(e)){if(t==="string")return t=cr(Number(e)),Tt(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Uo(e)||(fi(e),e=Br(U,Z))),e;if(t==="number")return(e=cr(e))>=0&&Tt(e)?e:function(r){if(r<0){zt(r);var i=Br(U,Z);return r=Number(i),Tt(r)?r:i}return Uo(i=String(r))?i:(zt(r),An(U,Z))}(e)}}function Ho(e){if(typeof e!="string")throw Error();return e}function ur(e){if(e!=null&&typeof e!="string")throw Error();return e}function dr(e){return e==null||typeof e=="string"?e:void 0}function In(e,t,r,i){if(e!=null&&typeof e=="object"&&e.W===Or)return e;if(!Array.isArray(e))return r?2&i?((e=t[Ao])||(ar((e=new t).u),e=t[Ao]=e),t=e):t=new t:t=void 0,t;let n=r=0|e[k];return n===0&&(n|=32&i),n|=2&i,n!==r&&ae(e,n),new t(e)}function Fu(e,t,r){if(t)e:{if(!Gr(t=e))throw xn("int64");switch(typeof t){case"string":t=Wo(t);break e;case"bigint":t=At(Ur(64,t));break e;default:t=zo(t)}}else e=typeof(t=e),t=t==null?t:e==="bigint"?At(Ur(64,t)):Gr(t)?e==="string"?Wo(t):zo(t):void 0;return(e=t)==null?r?Iu:void 0:e}function Pu(e){return e}const Du={};let Ru=function(){try{return oi(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class Mn{constructor(){this.g=new Map}get(t){return this.g.get(t)}set(t,r){return this.g.set(t,r),this.size=this.g.size,this}delete(t){return t=this.g.delete(t),this.size=this.g.size,t}clear(){this.g.clear(),this.size=this.g.size}has(t){return this.g.has(t)}entries(){return this.g.entries()}keys(){return this.g.keys()}values(){return this.g.values()}forEach(t,r){return this.g.forEach(t,r)}[Symbol.iterator](){return this.entries()}}const Ou=Ru?(Object.setPrototypeOf(Mn.prototype,Map.prototype),Object.defineProperties(Mn.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),Mn):class extends Map{constructor(){super()}};function qo(e){return e}function Ln(e){if(2&e.M)throw Error("Cannot mutate an immutable Map")}var nt=class extends Ou{constructor(e,t,r=qo,i=qo){super();let n=0|e[k];n|=64,ae(e,n),this.M=n,this.I=t,this.S=r,this.X=this.I?Bu:i;for(let s=0;s<e.length;s++){const a=e[s],c=r(a[0],!1,!0);let l=a[1];t?l===void 0&&(l=null):l=i(a[1],!1,!0,void 0,void 0,n),super.set(c,l)}}La(){var e=Wu;if(this.size!==0)return Array.from(super.entries(),t=>(t[0]=e(t[0]),t[1]=e(t[1]),t))}da(e=Uu){const t=[],r=super.entries();for(var i;!(i=r.next()).done;)(i=i.value)[0]=e(i[0]),i[1]=e(i[1]),t.push(i);return t}clear(){Ln(this),super.clear()}delete(e){return Ln(this),super.delete(this.S(e,!0,!1))}entries(){if(this.I){var e=super.keys();e=new Io(e,Gu,this)}else e=super.entries();return e}values(){if(this.I){var e=super.keys();e=new Io(e,nt.prototype.get,this)}else e=super.values();return e}forEach(e,t){this.I?super.forEach((r,i,n)=>{e.call(t,n.get(i),i,n)}):super.forEach(e,t)}set(e,t){return Ln(this),(e=this.S(e,!0,!1))==null?this:t==null?(super.delete(e),this):super.set(e,this.X(t,!0,!0,this.I,!1,this.M))}Ja(e){const t=this.S(e[0],!1,!0);e=e[1],e=this.I?e===void 0?null:e:this.X(e,!1,!0,void 0,!1,this.M),super.set(t,e)}has(e){return super.has(this.S(e,!1,!1))}get(e){e=this.S(e,!1,!1);const t=super.get(e);if(t!==void 0){var r=this.I;return r?((r=this.X(t,!1,!0,r,this.pa,this.M))!==t&&super.set(e,r),r):t}}[Symbol.iterator](){return this.entries()}};function Bu(e,t,r,i,n,s){return e=In(e,i,r,s),n&&(e=pi(e)),e}function Uu(e){return e}function Gu(e){return[e,this.get(e)]}let Vu,Yo,Ko,$u;function Xo(){return Vu||(Vu=new nt(ar([]),void 0,void 0,void 0,Du))}function Fn(e,t,r,i,n){if(e!=null){if(Array.isArray(e)){const s=0|e[k];return e.length===0&&1&s?void 0:n&&2&s?e:mi(e,t,r,i!==void 0,n)}return t(e,i)}}function mi(e,t,r,i,n){const s=i||r?0|e[k]:0,a=i?!!(32&s):void 0;let c=0;const l=(i=ke(e)).length;for(let g=0;g<l;g++){var u=i[g];if(g===l-1&&ui(u)){var h=t,f=r,w=a,m=n;let b;for(let _ in u){const p=Fn(u[_],h,f,w,m);p!=null&&((b??(b={}))[_]=p)}u=b}else u=Fn(i[g],t,r,a,n);i[g]=u,u!=null&&(c=g+1)}return c<l&&(i.length=c),r&&((e=kn(e))&&(i[or]=ke(e)),r(s,i)),i}function Wu(e){return Fn(e,Pn,void 0,void 0,!1)}function Pn(e){switch(typeof e){case"number":return Number.isFinite(e)?e:""+e;case"bigint":return En(e)?Number(e):""+e;case"boolean":return e?1:0;case"object":if($t(e))return $t(e)&&yn(To),vo(e);if(e.W===Or)return Qo(e);if(e instanceof wt){const t=e.g;return t==null?"":typeof t=="string"?t:e.g=vo(t)}return e instanceof nt?e.La():void 0}return e}function Qo(e){var t=e.u;e=mi(t,Pn,void 0,void 0,!1);var r=0|t[k];if((t=e.length)&&!(512&r)){var i=e[t-1],n=!1;ui(i)?(t--,n=!0):i=void 0;var s=t-(r=512&r?0:-1),a=(Yo??Pu)(s,r,e,i);if(i&&(e[t]=void 0),s<a&&i){for(var c in s=!0,i){const l=+c;l<=a?(e[n=l+r]=i[c],t=Math.max(n+1,t),n=!1,delete i[c]):s=!1}s&&(i=void 0)}for(s=t-1;t>0;s=t-1)if((c=e[s])==null)t--,n=!0;else{if(!((s-=r)>=a))break;(i??(i={}))[s]=c,t--,n=!0}n&&(e.length=t),i&&e.push(i)}return e}function Nt(e,t,r){return e=Jo(e,t[0],t[1],r?1:2),t!==Ko&&r&&ci(e,8192),e}function Jo(e,t,r,i){if(e==null){var n=96;r?(e=[r],n|=512):e=[],t&&(n=-16760833&n|(1023&t)<<14)}else{if(!Array.isArray(e))throw Error("narr");if(8192&(n=0|e[k])||!(64&n)||2&n||yn(bu),1024&n)throw Error("farr");if(64&n)return e;if(i===1||i===2||(n|=64),r&&(n|=512,r!==e[0]))throw Error("mid");e:{var s=(r=e).length;if(s){var a=s-1;if(ui(i=r[a])){if((a-=t=512&(n|=256)?0:-1)>=1024)throw Error("pvtlmt");for(var c in i)(s=+c)<a&&(r[s+t]=i[c],delete i[c]);n=-16760833&n|(1023&a)<<14;break e}}if(t){if((c=Math.max(t,s-(512&n?0:-1)))>1024)throw Error("spvt");n=-16760833&n|(1023&c)<<14}}}return ae(e,n),e}function Dn(e,t,r=bn){if(e!=null){if(yo&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var i=0|e[k];return 2&i?e:(t&&(t=i===0||!!(32&i)&&!(64&i||!(16&i))),t?(ae(e,34|i),4&i&&Object.freeze(e),e):mi(e,Dn,4&i?bn:r,!0,!0))}return e.W===Or?e=2&(i=0|(r=e.u)[k])?e:new e.constructor(gi(r,i,!0)):e instanceof nt&&!(2&e.M)&&(r=ar(e.da(Dn)),e=new nt(r,e.I,e.S,e.X)),e}}function gi(e,t,r){const i=r||2&t?bn:vu,n=!!(32&t);return e=function(s,a,c){const l=ke(s);var u=l.length;const h=256&a?l[u-1]:void 0;for(u+=h?-1:0,a=512&a?1:0;a<u;a++)l[a]=c(l[a]);if(h){a=l[a]={};for(const f in h)a[f]=c(h[f])}return(s=kn(s))&&(l[or]=ke(s)),l}(e,t,s=>Dn(s,n,i)),ci(e,32|(r?2:0)),e}function pi(e){const t=e.u,r=0|t[k];return 2&r?new e.constructor(gi(t,r,!1)):e}function hr(e,t){return mt(e=e.u,0|e[k],t)}function mt(e,t,r){if(r===-1)return null;const i=r+(512&t?0:-1),n=e.length-1;return i>=n&&256&t?e[n][r]:i<=n?e[i]:void 0}function $(e,t,r){const i=e.u;let n=0|i[k];return St(n),K(i,n,t,r),e}function K(e,t,r,i){const n=512&t?0:-1,s=r+n;var a=e.length-1;return s>=a&&256&t?(e[a][r]=i,t):s<=a?(e[s]=i,t):(i!==void 0&&(r>=(a=t>>14&1023||536870912)?i!=null&&(e[a+n]={[r]:i},ae(e,t|=256)):e[s]=i),t)}function xi(e,t){let r=0|(e=e.u)[k];const i=mt(e,r,t),n=jt(i);return n!=null&&n!==i&&K(e,r,t,n),n}function Zo(e){let t=0|(e=e.u)[k];const r=mt(e,t,1),i=_n(r,!0);return i!=null&&i!==r&&K(e,t,1,i),i}function Ht(){return _u===void 0?2:4}function qt(e,t,r,i,n){const s=e.u,a=2&(e=0|s[k])?1:i;n=!!n;let c=0|(i=Rn(s,e,t))[k];if(!(4&c)){4&c&&(i=ke(i),c=xt(c,e),e=K(s,e,t,i));let l=0,u=0;for(;l<i.length;l++){const h=r(i[l]);h!=null&&(i[u++]=h)}u<l&&(i.length=u),c=On(c,e),r=-2049&(20|c),c=r&=-4097,ae(i,c),2&c&&Object.freeze(i)}return a===1||a===4&&32&c?gt(c)||(n=c,c|=2,c!==n&&ae(i,c),Object.freeze(i)):(a===2&&gt(c)&&(i=ke(i),c=xt(c,e),c=Ct(c,e,n),ae(i,c),e=K(s,e,t,i)),gt(c)||(t=c,c=Ct(c,e,n),c!==t&&ae(i,c))),i}function Rn(e,t,r){return e=mt(e,t,r),Array.isArray(e)?e:vn}function On(e,t){return e===0&&(e=xt(e,t)),1|e}function gt(e){return!!(2&e)&&!!(4&e)||!!(1024&e)}function ea(e){e=ke(e);for(let t=0;t<e.length;t++){const r=e[t]=ke(e[t]);Array.isArray(r[1])&&(r[1]=ar(r[1]))}return e}function Bn(e,t,r,i){let n=0|(e=e.u)[k];St(n),K(e,n,t,(i==="0"?Number(r)===0:r===i)?void 0:r)}function fr(e,t,r,i){St(t);let n=Rn(e,t,r);const s=n!==vn;if(64&t||!(8192&t)||!s){const a=s?0|n[k]:0;let c=a;(!s||2&c||gt(c)||4&c&&!(32&c))&&(n=ke(n),c=xt(c,t),t=K(e,t,r,n)),c=-13&On(c,t),c=Ct(i?-17&c:16|c,t,!0),c!==a&&ae(n,c)}return n}function Un(e,t){var r=rc;return Vn(Gn(e=e.u),e,0|e[k],r)===t?t:-1}function Gn(e){if(ai)return e[Rr]??(e[Rr]=new Map);if(Rr in e)return e[Rr];const t=new Map;return Object.defineProperty(e,Rr,{value:t}),t}function ta(e,t,r,i){const n=Gn(e),s=Vn(n,e,t,r);return s!==i&&(s&&(t=K(e,t,s)),n.set(r,i)),t}function Vn(e,t,r,i){let n=e.get(i);if(n!=null)return n;n=0;for(let s=0;s<i.length;s++){const a=i[s];mt(t,r,a)!=null&&(n!==0&&(r=K(t,r,n)),n=a)}return e.set(i,n),n}function $n(e,t,r){let i=0|e[k];const n=mt(e,i,r);let s;if(n!=null&&n.W===Or)return(t=pi(n))!==n&&K(e,i,r,t),t.u;if(Array.isArray(n)){const a=0|n[k];s=2&a?Nt(gi(n,a,!1),t,!0):64&a?n:Nt(s,t,!0)}else s=Nt(void 0,t,!0);return s!==n&&K(e,i,r,s),s}function ra(e,t,r){let i=0|(e=e.u)[k];const n=mt(e,i,r);return(t=In(n,t,!1,i))!==n&&t!=null&&K(e,i,r,t),t}function P(e,t,r){if((t=ra(e,t,r))==null)return t;let i=0|(e=e.u)[k];if(!(2&i)){const n=pi(t);n!==t&&K(e,i,r,t=n)}return t}function ia(e,t,r,i,n,s,a){e=e.u;var c=!!(2&t);const l=c?1:n;s=!!s,a&&(a=!c);var u=0|(n=Rn(e,t,i))[k];if(!(c=!!(4&u))){var h=n,f=t;const w=!!(2&(u=On(u,t)));w&&(f|=2);let m=!w,g=!0,b=0,_=0;for(;b<h.length;b++){const p=In(h[b],r,!1,f);if(p instanceof r){if(!w){const A=!!(2&(0|p.u[k]));m&&(m=!A),g&&(g=A)}h[_++]=p}}_<b&&(h.length=_),u|=4,u=g?16|u:-17&u,ae(h,u=m?8|u:-9&u),w&&Object.freeze(h)}if(a&&!(8&u||!n.length&&(l===1||l===4&&32&u))){for(gt(u)&&(n=ke(n),u=xt(u,t),t=K(e,t,i,n)),r=n,a=u,h=0;h<r.length;h++)(u=r[h])!==(f=pi(u))&&(r[h]=f);a|=8,ae(r,a=r.length?-17&a:16|a),u=a}return l===1||l===4&&32&u?gt(u)||(t=u,(u|=!n.length||16&u&&(!c||32&u)?2:1024)!==t&&ae(n,u),Object.freeze(n)):(l===2&&gt(u)&&(ae(n=ke(n),u=Ct(u=xt(u,t),t,s)),t=K(e,t,i,n)),gt(u)||(i=u,(u=Ct(u,t,s))!==i&&ae(n,u))),n}function pt(e,t,r){const i=0|e.u[k];return ia(e,i,t,r,Ht(),!1,!(2&i))}function S(e,t,r,i){return i==null&&(i=void 0),$(e,r,i)}function Vr(e,t,r,i){i==null&&(i=void 0);e:{let n=0|(e=e.u)[k];if(St(n),i==null){const s=Gn(e);if(Vn(s,e,n,r)!==t)break e;s.set(r,0)}else n=ta(e,n,r,t);K(e,n,t,i)}}function xt(e,t){return-1025&(e=32|(2&t?2|e:-3&e))}function Ct(e,t,r){return 32&t&&r||(e&=-33),e}function yi(e,t,r){St(0|e.u[k]),qt(e,t,dr,2,!0).push(Ho(r))}function bi(e,t,r,i){const n=0|e.u[k];St(n),e=ia(e,n,r,t,2,!0),i=i??new r,e.push(i),e[k]=2&(0|i.u[k])?-9&e[k]:-17&e[k]}function Ue(e,t){return lr(hr(e,t))}function Ge(e,t){return dr(hr(e,t))}function ie(e,t){return xi(e,t)??0}function $r(e,t,r){if(r!=null&&typeof r!="boolean")throw e=typeof r,Error(`Expected boolean but got ${e!="object"?e:r?Array.isArray(r)?"array":e:"null"}: ${r}`);$(e,t,r)}function st(e,t,r){if(r!=null){if(typeof r!="number"||!wi(r))throw xn("int32");r|=0}$(e,t,r)}function v(e,t,r){if(r!=null&&typeof r!="number")throw Error(`Value of float/double field must be a number, found ${typeof r}: ${r}`);$(e,t,r)}function vi(e,t,r){{const a=e.u;let c=0|a[k];if(St(c),r==null)K(a,c,t);else{var i=e=0|r[k],n=gt(e),s=n||Object.isFrozen(r);for(n||(e=0),s||(r=ke(r),i=0,e=Ct(e=xt(e,c),c,!0),s=!1),e|=21,n=0;n<r.length;n++){const l=r[n],u=Ho(l);Object.is(l,u)||(s&&(r=ke(r),i=0,e=Ct(e=xt(e,c),c,!0),s=!1),r[n]=u)}e!==i&&(s&&(r=ke(r),e=Ct(e=xt(e,c),c,!0)),ae(r,e)),K(a,c,t,r)}}}function na(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function Wn(){return Error("Failed to read varint, encoding is invalid.")}function sa(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function zn(e){if(typeof e=="string")return{buffer:ko(e),O:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),O:!1};if(e.constructor===Uint8Array)return{buffer:e,O:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),O:!1};if(e.constructor===wt)return{buffer:pn(e)||new Uint8Array(0),O:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),O:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function Hn(e,t){let r,i=0,n=0,s=0;const a=e.h;let c=e.g;do r=a[c++],i|=(127&r)<<s,s+=7;while(s<32&&128&r);for(s>32&&(n|=(127&r)>>4),s=3;s<32&&128&r;s+=7)r=a[c++],n|=(127&r)<<s;if(Yt(e,c),r<128)return t(i>>>0,n>>>0);throw Wn()}function qn(e){let t=0,r=e.g;const i=r+10,n=e.h;for(;r<i;){const s=n[r++];if(t|=s,(128&s)==0)return Yt(e,r),!!(127&t)}throw Wn()}function It(e){const t=e.h;let r=e.g,i=t[r++],n=127&i;if(128&i&&(i=t[r++],n|=(127&i)<<7,128&i&&(i=t[r++],n|=(127&i)<<14,128&i&&(i=t[r++],n|=(127&i)<<21,128&i&&(i=t[r++],n|=i<<28,128&i&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw Wn();return Yt(e,r),n}function yt(e){return It(e)>>>0}function Yn(e){var t=e.h;const r=e.g,i=t[r],n=t[r+1],s=t[r+2];return t=t[r+3],Yt(e,e.g+4),(i<<0|n<<8|s<<16|t<<24)>>>0}function Kn(e){var t=Yn(e);e=2*(t>>31)+1;const r=t>>>23&255;return t&=8388607,r==255?t?NaN:e*(1/0):r==0?1401298464324817e-60*e*t:e*Math.pow(2,r-150)*(t+8388608)}function zu(e){return It(e)}function Xn(e,t,{aa:r=!1}={}){e.aa=r,t&&(t=zn(t),e.h=t.buffer,e.m=t.O,e.j=0,e.l=e.h.length,e.g=e.j)}function Yt(e,t){if(e.g=t,t>e.l)throw sa(e.l,t)}function oa(e,t){if(t<0)throw Error(`Tried to read a negative byte length: ${t}`);const r=e.g,i=r+t;if(i>e.l)throw sa(t,e.l-r);return e.g=i,r}function aa(e,t){if(t==0)return Wt();var r=oa(e,t);return e.aa&&e.m?r=e.h.subarray(r,r+t):(e=e.h,r=r===(t=r+t)?new Uint8Array(0):Nu?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Wt():new wt(r,nr)}nt.prototype.toJSON=void 0;var ca=[];function la(e){var t=e.g;if(t.g==t.l)return!1;e.l=e.g.g;var r=yt(e.g);if(t=r>>>3,!((r&=7)>=0&&r<=5))throw na(r,e.l);if(t<1)throw Error(`Invalid field number: ${t} (at position ${e.l})`);return e.m=t,e.h=r,!0}function _i(e){switch(e.h){case 0:e.h!=0?_i(e):qn(e.g);break;case 1:Yt(e=e.g,e.g+8);break;case 2:if(e.h!=2)_i(e);else{var t=yt(e.g);Yt(e=e.g,e.g+t)}break;case 5:Yt(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!la(e))throw Error("Unmatched start-group tag: stream EOF");if(e.h==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}_i(e)}break;default:throw na(e.h,e.l)}}function Wr(e,t,r){const i=e.g.l,n=yt(e.g),s=e.g.g+n;let a=s-i;if(a<=0&&(e.g.l=s,r(t,e,void 0,void 0,void 0),a=s-e.g.g),a)throw Error(`Message parsing ended unexpectedly. Expected to read ${n} bytes, instead read ${n-a} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=s,e.g.l=i,t}function Qn(e){var t=yt(e.g),r=oa(e=e.g,t);if(e=e.h,uu){var i,n=e;(i=dn)||(i=dn=new TextDecoder("utf-8",{fatal:!0})),t=r+t,n=r===0&&t===n.length?n:n.subarray(r,t);try{var s=i.decode(n)}catch(c){if(ni===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),ni=!0}catch{ni=!1}}throw!ni&&(dn=void 0),c}}else{t=(s=r)+t,r=[];let c,l=null;for(;s<t;){var a=e[s++];a<128?r.push(a):a<224?s>=t?Vt():(c=e[s++],a<194||(192&c)!=128?(s--,Vt()):r.push((31&a)<<6|63&c)):a<240?s>=t-1?Vt():(c=e[s++],(192&c)!=128||a===224&&c<160||a===237&&c>=160||(192&(i=e[s++]))!=128?(s--,Vt()):r.push((15&a)<<12|(63&c)<<6|63&i)):a<=244?s>=t-2?Vt():(c=e[s++],(192&c)!=128||c-144+(a<<28)>>30||(192&(i=e[s++]))!=128||(192&(n=e[s++]))!=128?(s--,Vt()):(a=(7&a)<<18|(63&c)<<12|(63&i)<<6|63&n,a-=65536,r.push(55296+(a>>10&1023),56320+(1023&a)))):Vt(),r.length>=8192&&(l=ho(l,r),r.length=0)}s=ho(l,r)}return s}function ua(e){const t=yt(e.g);return aa(e.g,t)}function ki(e,t,r){var i=yt(e.g);for(i=e.g.g+i;e.g.g<i;)r.push(t(e.g))}var Ei=[];function Je(e,t,r){t.g?t.m(e,t.g,t.h,r):t.m(e,t.h,r)}var y=class{constructor(e,t){this.u=Jo(e,t)}toJSON(){try{var e=Qo(this)}finally{Yo=void 0}return e}l(){var e=Td;return e.g?e.l(this,e.g,e.h):e.l(this,e.h,e.defaultValue)}clone(){const e=this.u;return new this.constructor(gi(e,0|e[k],!1))}O(){return!!(2&(0|this.u[k]))}};function da(e){return e?/^\d+$/.test(e)?(fi(e),new Jn(U,Z)):null:Hu||(Hu=new Jn(0,0))}y.prototype.W=Or,y.prototype.toString=function(){return this.u.toString()};var Jn=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let Hu;function ha(e){return e?/^-?\d+$/.test(e)?(fi(e),new Zn(U,Z)):null:qu||(qu=new Zn(0,0))}var Zn=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let qu;function wr(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function mr(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function Si(e,t){if(t>=0)mr(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function zr(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function gr(e,t){t.length!==0&&(e.l.push(t),e.h+=t.length)}function Ne(e,t,r){mr(e.g,8*t+r)}function es(e,t){return Ne(e,t,2),t=e.g.end(),gr(e,t),t.push(e.h),t}function ts(e,t){var r=t.pop();for(r=e.h+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.h++;t.push(r),e.h++}function Ai(e,t,r){Ne(e,t,2),mr(e.g,r.length),gr(e,e.g.end()),gr(e,r)}function Ti(e,t,r,i){r!=null&&(t=es(e,t),i(r,e),ts(e,t))}function Ze(){const e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var rs=Ze(),fa=Ze(),is=Ze(),ns=Ze(),wa=Ze(),ma=Ze(),ss=Ze(),ga=Ze(),pa=Ze(),pr=class{constructor(e,t,r){this.g=e,this.h=t,e=rs,this.l=!!e&&r===e||!1}};function ji(e,t){return new pr(e,t,rs)}function xa(e,t,r,i,n){Ti(e,r,Ea(t,i),n)}const Yu=ji(function(e,t,r,i,n){return e.h===2&&(Wr(e,$n(t,i,r),n),!0)},xa),Ku=ji(function(e,t,r,i,n){return e.h===2&&(Wr(e,$n(t,i,r),n),!0)},xa);var Ni=Symbol(),os=Symbol(),ya=Symbol(),ba=Symbol();let va,_a;function Kt(e,t,r,i){var n=i[e];if(n)return n;(n={}).Ma=i,n.T=function(f){switch(typeof f){case"boolean":return Ko||(Ko=[0,void 0,!0]);case"number":return f>0?void 0:f===0?$u||($u=[0,void 0]):[-f,void 0];case"string":return[0,f];case"object":return f}}(i[0]);var s=i[1];let a=1;s&&s.constructor===Object&&(n.ga=s,typeof(s=i[++a])=="function"&&(n.la=!0,va??(va=s),_a??(_a=i[a+1]),s=i[a+=2]));const c={};for(;s&&Array.isArray(s)&&s.length&&typeof s[0]=="number"&&s[0]>0;){for(var l=0;l<s.length;l++)c[s[l]]=s;s=i[++a]}for(l=1;s!==void 0;){let f;typeof s=="number"&&(l+=s,s=i[++a]);var u=void 0;if(s instanceof pr?f=s:(f=Yu,a--),f==null?void 0:f.l){s=i[++a],u=i;var h=a;typeof s=="function"&&(s=s(),u[h]=s),u=s}for(h=l+1,typeof(s=i[++a])=="number"&&s<0&&(h-=s,s=i[++a]);l<h;l++){const w=c[l];u?r(n,l,f,u,w):t(n,l,f,w)}}return i[e]=n}function ka(e){return Array.isArray(e)?e[0]instanceof pr?e:[Ku,e]:[e,void 0]}function Ea(e,t){return e instanceof y?e.u:Array.isArray(e)?Nt(e,t,!1):void 0}function as(e,t,r,i){const n=r.g;e[t]=i?(s,a,c)=>n(s,a,c,i):n}function cs(e,t,r,i,n){const s=r.g;let a,c;e[t]=(l,u,h)=>s(l,u,h,c||(c=Kt(os,as,cs,i).T),a||(a=ls(i)),n)}function ls(e){let t=e[ya];if(t!=null)return t;const r=Kt(os,as,cs,e);return t=r.la?(i,n)=>va(i,n,r):(i,n)=>{const s=0|i[k];for(;la(n)&&n.h!=4;){var a=n.m,c=r[a];if(c==null){var l=r.ga;l&&(l=l[a])&&(l=Xu(l))!=null&&(c=r[a]=l)}c!=null&&c(n,i,a)||(a=(c=n).l,_i(c),c.fa?c=void 0:(l=c.g.g-a,c.g.g=a,c=aa(c.g,l)),a=i,c&&((l=a[or])?l.push(c):a[or]=[c]))}return 8192&s&&ar(i),!0},e[ya]=t}function Xu(e){const t=(e=ka(e))[0].g;if(e=e[1]){const r=ls(e),i=Kt(os,as,cs,e).T;return(n,s,a)=>t(n,s,a,i,r)}return t}function Ci(e,t,r){e[t]=r.h}function Ii(e,t,r,i){let n,s;const a=r.h;e[t]=(c,l,u)=>a(c,l,u,s||(s=Kt(Ni,Ci,Ii,i).T),n||(n=Sa(i)))}function Sa(e){let t=e[ba];if(!t){const r=Kt(Ni,Ci,Ii,e);t=(i,n)=>Aa(i,n,r),e[ba]=t}return t}function Aa(e,t,r){(function(i,n,s){const a=512&n?0:-1,c=i.length,l=c+((n=64&n?256&n:!!c&&ui(i[c-1]))?-1:0);for(let u=0;u<l;u++)s(u-a,i[u]);if(n){i=i[c-1];for(const u in i)!isNaN(u)&&s(+u,i[u])}})(e,0|e[k]|(r.T[1]?512:0),(i,n)=>{if(n!=null){var s=function(a,c){var l=a[c];if(l)return l;if((l=a.ga)&&(l=l[c])){var u=(l=ka(l))[0].h;if(l=l[1]){const h=Sa(l),f=Kt(Ni,Ci,Ii,l).T;l=a.la?_a(f,h):(w,m,g)=>u(w,m,g,f,h)}else l=u;return a[c]=l}}(r,i);s&&s(t,n,i)}}),(e=kn(e))&&function(i,n){gr(i,i.g.end());for(let s=0;s<n.length;s++)gr(i,pn(n[s])||new Uint8Array(0))}(t,e)}function xr(e,t){if(Array.isArray(t)){var r=0|t[k];if(4&r)return t;for(var i=0,n=0;i<t.length;i++){const s=e(t[i]);s!=null&&(t[n++]=s)}return n<i&&(t.length=n),ae(t,-6145&(5|r)),2&r&&Object.freeze(t),t}}function pe(e,t,r){return new pr(e,t,r)}function yr(e,t,r){return new pr(e,t,r)}function xe(e,t,r){K(e,0|e[k],t,r)}var Qu=ji(function(e,t,r,i,n){return e.h===2&&(e=Wr(e,Nt([void 0,void 0],i,!0),n),St(i=0|t[k]),(n=mt(t,i,r))instanceof nt?2&n.M?((n=n.da()).push(e),K(t,i,r,n)):n.Ja(e):Array.isArray(n)?(2&(0|n[k])&&K(t,i,r,n=ea(n)),n.push(e)):K(t,i,r,[e]),!0)},function(e,t,r,i,n){if(t instanceof nt)t.forEach((s,a)=>{Ti(e,r,Nt([a,s],i,!1),n)});else if(Array.isArray(t))for(let s=0;s<t.length;s++){const a=t[s];Array.isArray(a)&&Ti(e,r,Nt(a,i,!1),n)}});function Ta(e,t,r){if(t=function(i){if(i==null)return i;const n=typeof i;if(n==="bigint")return String(Ur(64,i));if(Gr(i)){if(n==="string")return $o(i);if(n==="number")return Nn(i)}}(t),t!=null&&(typeof t=="string"&&ha(t),t!=null))switch(Ne(e,r,0),typeof t){case"number":e=e.g,zt(t),wr(e,U,Z);break;case"bigint":r=BigInt.asUintN(64,t),r=new Zn(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),wr(e.g,r.h,r.g);break;default:r=ha(t),wr(e.g,r.h,r.g)}}function ja(e,t,r){(t=lr(t))!=null&&t!=null&&(Ne(e,r,0),Si(e.g,t))}function Na(e,t,r){(t=Oo(t))!=null&&(Ne(e,r,0),e.g.g.push(t?1:0))}function Ca(e,t,r){(t=dr(t))!=null&&Ai(e,r,fo(t))}function Ia(e,t,r,i,n){Ti(e,r,Ea(t,i),n)}function Ma(e,t,r){t==null||typeof t=="string"||t instanceof wt||($t(t)?$t(t)&&yn(To):t=void 0),t!=null&&Ai(e,r,zn(t).buffer)}function La(e,t,r){return(e.h===5||e.h===2)&&(t=fr(t,0|t[k],r,!1),e.h==2?ki(e,Kn,t):t.push(Kn(e.g)),!0)}var bt=pe(function(e,t,r){if(e.h!==1)return!1;var i=e.g;e=Yn(i);const n=Yn(i);i=2*(n>>31)+1;const s=n>>>20&2047;return e=4294967296*(1048575&n)+e,xe(t,r,s==2047?e?NaN:i*(1/0):s==0?5e-324*i*e:i*Math.pow(2,s-1075)*(e+4503599627370496)),!0},function(e,t,r){(t=jt(t))!=null&&(Ne(e,r,1),e=e.g,(r=Fo||(Fo=new DataView(new ArrayBuffer(8)))).setFloat64(0,+t,!0),U=r.getUint32(0,!0),Z=r.getUint32(4,!0),zr(e,U),zr(e,Z))},Ze()),ce=pe(function(e,t,r){return e.h===5&&(xe(t,r,Kn(e.g)),!0)},function(e,t,r){(t=jt(t))!=null&&(Ne(e,r,5),e=e.g,Sn(t),zr(e,U))},ss),Ju=yr(La,function(e,t,r){if((t=xr(jt,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&(Ne(i,n,5),i=i.g,Sn(s),zr(i,U))}},ss),us=yr(La,function(e,t,r){if((t=xr(jt,t))!=null&&t.length){Ne(e,r,2),mr(e.g,4*t.length);for(let i=0;i<t.length;i++)r=e.g,Sn(t[i]),zr(r,U)}},ss),Mt=pe(function(e,t,r){return e.h===0&&(xe(t,r,Hn(e.g,Tn)),!0)},Ta,ma),ds=pe(function(e,t,r){return e.h===0&&(xe(t,r,(e=Hn(e.g,Tn))===0?void 0:e),!0)},Ta,ma),Zu=pe(function(e,t,r){return e.h===0&&(xe(t,r,Hn(e.g,An)),!0)},function(e,t,r){if((t=Lu(t))!=null&&(typeof t=="string"&&da(t),t!=null))switch(Ne(e,r,0),typeof t){case"number":e=e.g,zt(t),wr(e,U,Z);break;case"bigint":r=BigInt.asUintN(64,t),r=new Jn(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),wr(e.g,r.h,r.g);break;default:r=da(t),wr(e.g,r.h,r.g)}},Ze()),ee=pe(function(e,t,r){return e.h===0&&(xe(t,r,It(e.g)),!0)},ja,ns),Mi=yr(function(e,t,r){return(e.h===0||e.h===2)&&(t=fr(t,0|t[k],r,!1),e.h==2?ki(e,It,t):t.push(It(e.g)),!0)},function(e,t,r){if((t=xr(lr,t))!=null&&t.length){r=es(e,r);for(let i=0;i<t.length;i++)Si(e.g,t[i]);ts(e,r)}},ns),br=pe(function(e,t,r){return e.h===0&&(xe(t,r,(e=It(e.g))===0?void 0:e),!0)},ja,ns),H=pe(function(e,t,r){return e.h===0&&(xe(t,r,qn(e.g)),!0)},Na,fa),vr=pe(function(e,t,r){return e.h===0&&(xe(t,r,(e=qn(e.g))===!1?void 0:e),!0)},Na,fa),me=yr(function(e,t,r){return e.h===2&&(e=Qn(e),fr(t,0|t[k],r,!1).push(e),!0)},function(e,t,r){if((t=xr(dr,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&Ai(i,n,fo(s))}},is),Lt=pe(function(e,t,r){return e.h===2&&(xe(t,r,(e=Qn(e))===""?void 0:e),!0)},Ca,is),R=pe(function(e,t,r){return e.h===2&&(xe(t,r,Qn(e)),!0)},Ca,is),ue=function(e,t,r=rs){return new pr(e,t,r)}(function(e,t,r,i,n){return e.h===2&&(i=Nt(void 0,i,!0),fr(t,0|t[k],r,!0).push(i),Wr(e,i,n),!0)},function(e,t,r,i,n){if(Array.isArray(t))for(let s=0;s<t.length;s++)Ia(e,t[s],r,i,n)}),O=ji(function(e,t,r,i,n,s){return e.h===2&&(ta(t,0|t[k],s,r),Wr(e,t=$n(t,i,r),n),!0)},Ia),Fa=pe(function(e,t,r){return e.h===2&&(xe(t,r,ua(e)),!0)},Ma,ga),ed=yr(function(e,t,r){return(e.h===0||e.h===2)&&(t=fr(t,0|t[k],r,!1),e.h==2?ki(e,yt,t):t.push(yt(e.g)),!0)},function(e,t,r){if((t=xr(Bo,t))!=null)for(let a=0;a<t.length;a++){var i=e,n=r,s=t[a];s!=null&&(Ne(i,n,0),mr(i.g,s))}},wa),td=pe(function(e,t,r){return e.h===0&&(xe(t,r,(e=yt(e.g))===0?void 0:e),!0)},function(e,t,r){(t=Bo(t))!=null&&t!=null&&(Ne(e,r,0),mr(e.g,t))},wa),Ce=pe(function(e,t,r){return e.h===0&&(xe(t,r,It(e.g)),!0)},function(e,t,r){(t=lr(t))!=null&&(t=parseInt(t,10),Ne(e,r,0),Si(e.g,t))},pa);class rd{constructor(t,r){this.h=t,this.g=r,this.l=P,this.m=S,this.defaultValue=void 0}register(){oi(this)}}function et(e,t){return new rd(e,t)}function Ft(e,t){return(r,i)=>{if(Ei.length){const s=Ei.pop();s.o(i),Xn(s.g,r,i),r=s}else r=new class{constructor(s,a){if(ca.length){const c=ca.pop();Xn(c,s,a),s=c}else s=new class{constructor(c,l){this.h=null,this.m=!1,this.g=this.l=this.j=0,Xn(this,c,l)}clear(){this.h=null,this.m=!1,this.g=this.l=this.j=0,this.aa=!1}}(s,a);this.g=s,this.l=this.g.g,this.h=this.m=-1,this.o(a)}o({fa:s=!1}={}){this.fa=s}}(r,i);try{const s=new e,a=s.u;ls(t)(a,r);var n=s}finally{r.g.clear(),r.m=-1,r.h=-1,Ei.length<100&&Ei.push(r)}return n}}function Li(e){return function(){const t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const a=this.g;return this.g=[],a}}}};Aa(this.u,t,Kt(Ni,Ci,Ii,e)),gr(t,t.g.end());const r=new Uint8Array(t.h),i=t.l,n=i.length;let s=0;for(let a=0;a<n;a++){const c=i[a];r.set(c,s),s+=c.length}return t.l=[r],r}}var Pa=class extends y{constructor(e){super(e)}},Da=[0,Lt,pe(function(e,t,r){return e.h===2&&(xe(t,r,(e=ua(e))===Wt()?void 0:e),!0)},function(e,t,r){if(t!=null){if(t instanceof y){const i=t.Oa;return void(i&&(t=i(t),t!=null&&Ai(e,r,zn(t).buffer)))}if(Array.isArray(t))return}Ma(e,t,r)},ga)];let hs,Ra=globalThis.trustedTypes;function Oa(e){hs===void 0&&(hs=function(){let r=null;if(!Ra)return r;try{const i=n=>n;r=Ra.createPolicy("goog#html",{createHTML:i,createScript:i,createScriptURL:i})}catch{}return r}());var t=hs;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function id(e,...t){if(t.length===0)return Oa(e[0]);let r=e[0];for(let i=0;i<t.length;i++)r+=encodeURIComponent(t[i])+e[i+1];return Oa(r)}var Ba=[0,ee,Ce,H,-1,Mi,Ce,-1],nd=class extends y{constructor(e){super(e)}},Ua=[0,H,R,H,Ce,-1,yr(function(e,t,r){return(e.h===0||e.h===2)&&(t=fr(t,0|t[k],r,!1),e.h==2?ki(e,zu,t):t.push(It(e.g)),!0)},function(e,t,r){if((t=xr(lr,t))!=null&&t.length){r=es(e,r);for(let i=0;i<t.length;i++)Si(e.g,t[i]);ts(e,r)}},pa),R,-1,[0,H,-1],Ce,H,-1],Ga=[0,R,-2],Va=class extends y{constructor(e){super(e)}},$a=[0],Wa=[0,ee,H,1,H,-3],Ie=class extends y{constructor(e){super(e,2)}},le={};le[336783863]=[0,R,H,-1,ee,[0,[1,2,3,4,5,6,7,8,9],O,$a,O,Ua,O,Ga,O,Wa,O,Ba,O,[0,R,-2],O,[0,R,Ce],O,[0,Ce,R,-1],O,[0,Ce,-1]],[0,R],H,[0,[1,3],[2,4],O,[0,Mi],-1,O,[0,me],-1,ue,[0,R,-1]],R];var za=[0,ds,-1,vr,-3,ds,Mi,Lt,br,ds,-1,vr,br,vr,-2,Lt];function Me(e,t){Bn(e,2,ur(t),"")}function W(e,t){yi(e,3,t)}function L(e,t){yi(e,4,t)}var ye=class extends y{constructor(e){super(e,500)}o(e){return S(this,0,7,e)}},Hr=[-1,{}],Ha=[0,R,1,Hr],qa=[0,R,me,Hr];function Le(e,t){bi(e,1,ye,t)}function z(e,t){yi(e,10,t)}function D(e,t){yi(e,15,t)}var Ee=class extends y{constructor(e){super(e,500)}o(e){return S(this,0,1001,e)}},Ya=[-500,ue,[-500,Lt,-1,me,-3,[-2,le,H],ue,Da,br,-1,Ha,qa,ue,[0,Lt,vr],Lt,za,br,me,987,me],4,ue,[-500,R,-1,[-1,{}],998,R],ue,[-500,R,me,-1,[-2,{},H],997,me,-1],br,ue,[-500,R,me,Hr,998,me],me,br,Ha,qa,ue,[0,Lt,-1,Hr],me,-2,za,Lt,-1,vr,[0,vr,td],978,Hr,ue,Da];Ee.prototype.g=Li(Ya);var sd=Ft(Ee,Ya),od=class extends y{constructor(e){super(e)}},Ka=class extends y{constructor(e){super(e)}g(){return pt(this,od,1)}},Xa=[0,ue,[0,ee,ce,R,-1]],Fi=Ft(Ka,Xa),ad=class extends y{constructor(e){super(e)}},cd=class extends y{constructor(e){super(e)}},fs=class extends y{constructor(e){super(e)}h(){return P(this,ad,2)}g(){return pt(this,cd,5)}},Qa=Ft(class extends y{constructor(e){super(e)}},[0,me,Mi,us,[0,Ce,[0,ee,-3],[0,ce,-3],[0,ee,-1,[0,ue,[0,ee,-2]]],ue,[0,ce,-1,R,ce]],R,-1,Mt,ue,[0,ee,ce],me,Mt]),Ja=class extends y{constructor(e){super(e)}},_r=Ft(class extends y{constructor(e){super(e)}},[0,ue,[0,ce,-4]]),Za=class extends y{constructor(e){super(e)}},qr=Ft(class extends y{constructor(e){super(e)}},[0,ue,[0,ce,-4]]),ld=class extends y{constructor(e){super(e)}},ud=[0,ee,-1,us,Ce],ec=class extends y{constructor(e){super(e)}};ec.prototype.g=Li([0,ce,-4,Mt]);var dd=class extends y{constructor(e){super(e)}},hd=Ft(class extends y{constructor(e){super(e)}},[0,ue,[0,1,ee,R,Xa],Mt]),tc=class extends y{constructor(e){super(e)}},fd=class extends y{constructor(e){super(e)}ma(){const e=Zo(this);return e??Wt()}},wd=class extends y{constructor(e){super(e)}},rc=[1,2],md=Ft(class extends y{constructor(e){super(e)}},[0,ue,[0,rc,O,[0,us],O,[0,Fa],ee,R],Mt]),ws=class extends y{constructor(e){super(e)}},ic=[0,R,ee,ce,me,-1],nc=class extends y{constructor(e){super(e)}},gd=[0,H,-1],sc=class extends y{constructor(e){super(e)}},Pi=[1,2,3,4,5],Di=class extends y{constructor(e){super(e)}g(){return Zo(this)!=null}h(){return Ge(this,2)!=null}},q=class extends y{constructor(e){super(e)}g(){return Oo(hr(this,2))??!1}},oc=[0,Fa,R,[0,ee,Mt,-1],[0,Zu,Mt]],ne=[0,oc,H,[0,Pi,O,Wa,O,Ua,O,Ba,O,$a,O,Ga],Ce],Ri=class extends y{constructor(e){super(e)}},ms=[0,ne,ce,-1,ee],pd=et(502141897,Ri);le[502141897]=ms;var xd=Ft(class extends y{constructor(e){super(e)}},[0,[0,Ce,-1,Ju,ed],ud]),ac=class extends y{constructor(e){super(e)}},cc=class extends y{constructor(e){super(e)}},gs=[0,ne,ce,[0,ne],H],lc=[0,ne,ms,gs,ce,[0,[0,oc]]],yd=et(508968150,cc);le[508968150]=lc,le[508968149]=gs;var uc=class extends y{constructor(e){super(e)}},bd=et(513916220,uc);le[513916220]=[0,ne,lc,ee];var kr=class extends y{constructor(e){super(e)}h(){return P(this,ws,2)}g(){$(this,2)}},dc=[0,ne,ic];le[478825465]=dc;var vd=class extends y{constructor(e){super(e)}},hc=class extends y{constructor(e){super(e)}},ps=class extends y{constructor(e){super(e)}},xs=class extends y{constructor(e){super(e)}},fc=class extends y{constructor(e){super(e)}},wc=[0,ne,[0,ne],dc,-1],mc=[0,ne,ce,ee],ys=[0,ne,ce],gc=[0,ne,mc,ys,ce],_d=et(479097054,fc);le[479097054]=[0,ne,gc,wc],le[463370452]=wc,le[464864288]=mc;var kd=et(462713202,xs);le[462713202]=gc,le[474472470]=ys;var Ed=class extends y{constructor(e){super(e)}},pc=class extends y{constructor(e){super(e)}},xc=class extends y{constructor(e){super(e)}},yc=class extends y{constructor(e){super(e)}},bs=[0,ne,ce,-1,ee],vs=[0,ne,ce,H];yc.prototype.g=Li([0,ne,ys,[0,ne],ms,gs,bs,vs]);var bc=class extends y{constructor(e){super(e)}},Sd=et(456383383,bc);le[456383383]=[0,ne,ic];var vc=class extends y{constructor(e){super(e)}},Ad=et(476348187,vc);le[476348187]=[0,ne,gd];var _c=class extends y{constructor(e){super(e)}},kc=class extends y{constructor(e){super(e)}},Ec=[0,Ce,-1],Td=et(458105876,class extends y{constructor(e){super(e)}g(){var e=this.u;const t=0|e[k],r=2&t;return e=function(i,n,s){var a=kc;const c=2&n;let l=!1;if(s==null){if(c)return Xo();s=[]}else if(s.constructor===nt){if(!(2&s.M)||c)return s;s=s.da()}else Array.isArray(s)?l=!!(2&(0|s[k])):s=[];if(c){if(!s.length)return Xo();l||(l=!0,ar(s))}else l&&(l=!1,s=ea(s));return l||(64&(0|s[k])?s[k]&=-33:32&n&&ci(s,32)),K(i,n,2,a=new nt(s,a,Fu,void 0)),a}(e,t,mt(e,t,2)),!r&&kc&&(e.pa=!0),e}});le[458105876]=[0,Ec,Qu,[!0,Mt,[0,R,-1,me]]];var _s=class extends y{constructor(e){super(e)}},Sc=et(458105758,_s);le[458105758]=[0,ne,R,Ec];var Ac=class extends y{constructor(e){super(e)}},jd=et(443442058,Ac);le[443442058]=[0,ne,R,ee,ce,me,-1,H,ce],le[514774813]=bs;var Tc=class extends y{constructor(e){super(e)}},Nd=et(516587230,Tc);function ks(e,t){return t=t?t.clone():new ws,e.displayNamesLocale!==void 0?$(t,1,ur(e.displayNamesLocale)):e.displayNamesLocale===void 0&&$(t,1),e.maxResults!==void 0?st(t,2,e.maxResults):"maxResults"in e&&$(t,2),e.scoreThreshold!==void 0?v(t,3,e.scoreThreshold):"scoreThreshold"in e&&$(t,3),e.categoryAllowlist!==void 0?vi(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&$(t,4),e.categoryDenylist!==void 0?vi(t,5,e.categoryDenylist):"categoryDenylist"in e&&$(t,5),t}function Es(e,t=-1,r=""){return{categories:e.map(i=>({index:Ue(i,1)??0??-1,score:ie(i,2)??0,categoryName:Ge(i,3)??""??"",displayName:Ge(i,4)??""??""})),headIndex:t,headName:r}}function jc(e){var a,c;var t=qt(e,3,jt,Ht()),r=qt(e,2,lr,Ht()),i=qt(e,1,dr,Ht()),n=qt(e,9,dr,Ht());const s={categories:[],keypoints:[]};for(let l=0;l<t.length;l++)s.categories.push({score:t[l],index:r[l]??-1,categoryName:i[l]??"",displayName:n[l]??""});if((t=(a=P(e,fs,4))==null?void 0:a.h())&&(s.boundingBox={originX:Ue(t,1)??0,originY:Ue(t,2)??0,width:Ue(t,3)??0,height:Ue(t,4)??0,angle:0}),(c=P(e,fs,4))==null?void 0:c.g().length)for(const l of P(e,fs,4).g())s.keypoints.push({x:xi(l,1)??0,y:xi(l,2)??0,score:xi(l,4)??0,label:Ge(l,3)??""});return s}function Oi(e){const t=[];for(const r of pt(e,Za,1))t.push({x:ie(r,1)??0,y:ie(r,2)??0,z:ie(r,3)??0,visibility:ie(r,4)??0});return t}function Yr(e){const t=[];for(const r of pt(e,Ja,1))t.push({x:ie(r,1)??0,y:ie(r,2)??0,z:ie(r,3)??0,visibility:ie(r,4)??0});return t}function Nc(e){return Array.from(e,t=>t>127?t-256:t)}function Cc(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let r=0,i=0,n=0;for(let s=0;s<e.length;s++)r+=e[s]*t[s],i+=e[s]*e[s],n+=t[s]*t[s];if(i<=0||n<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(i*n)}let Bi;le[516587230]=[0,ne,bs,vs,ce],le[518928384]=vs;const Cd=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function Ic(){if(Bi===void 0)try{await WebAssembly.instantiate(Cd),Bi=!0}catch{Bi=!1}return Bi}async function Kr(e,t=id``){const r=await Ic()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var Xt=class{};function Mc(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")}(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function Lc(e){if(typeof importScripts!="function"){const t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise((r,i)=>{t.addEventListener("load",()=>{r()},!1),t.addEventListener("error",n=>{i(n)},!1),document.body.appendChild(t)})}importScripts(e.toString())}function Fc(e){return e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height]}function E(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function Pc(e,t,r){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(r?e.i._bindTextureToStream(r):e.i._bindTextureToCanvas(),!(r=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1);const[i,n]=Fc(t);return!e.l||i===e.i.canvas.width&&n===e.i.canvas.height||(e.i.canvas.width=i,e.i.canvas.height=n),[i,n]}function Dc(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const i=new Uint32Array(t.length);for(let n=0;n<t.length;n++)i[n]=e.i.stringToNewUTF8(t[n]);t=e.i._malloc(4*i.length),e.i.HEAPU32.set(i,t>>2),r(t);for(const n of i)e.i._free(n);e.i._free(t)}function ot(e,t,r){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=r}function Pt(e,t,r){let i=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(n,s,a)=>{s?(r(i,a),i=[]):i.push(n)}}Xt.forVisionTasks=function(e){return Kr("vision",e)},Xt.forTextTasks=function(e){return Kr("text",e)},Xt.forGenAiExperimentalTasks=function(e){return Kr("genai_experimental",e)},Xt.forGenAiTasks=function(e){return Kr("genai",e)},Xt.forAudioTasks=function(e){return Kr("audio",e)},Xt.isSimdSupported=function(){return Ic()};async function Id(e,t,r,i){return e=await(async(n,s,a,c,l)=>{if(s&&await Lc(s),!self.ModuleFactory||a&&(await Lc(a),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&l&&((s=self.Module).locateFile=l.locateFile,l.mainScriptUrlOrBlob&&(s.mainScriptUrlOrBlob=l.mainScriptUrlOrBlob)),l=await self.ModuleFactory(self.Module||l),self.ModuleFactory=self.Module=void 0,new n(l,c)})(e,r.wasmLoaderPath,r.assetLoaderPath,t,{locateFile:n=>n.endsWith(".wasm")?r.wasmBinaryPath.toString():r.assetBinaryPath&&n.endsWith(".data")?r.assetBinaryPath.toString():n}),await e.o(i),e}function Ss(e,t){const r=P(e.baseOptions,Di,1)||new Di;typeof t=="string"?($(r,2,ur(t)),$(r,1)):t instanceof Uint8Array&&($(r,1,_n(t,!1)),$(r,2)),S(e.baseOptions,0,1,r)}function Rc(e){try{const t=e.G.length;if(t===1)throw Error(e.G[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.G.map(r=>r.message).join(", "))}finally{e.G=[]}}function x(e,t){e.B=Math.max(e.B,t)}function Ui(e,t){e.A=new ye,Me(e.A,"PassThroughCalculator"),W(e.A,"free_memory"),L(e.A,"free_memory_unused_out"),z(t,"free_memory"),Le(t,e.A)}function Er(e,t){W(e.A,t),L(e.A,t+"_unused_out")}function Gi(e){e.g.addBoolToStream(!0,"free_memory",e.B)}var As=class{constructor(e){this.g=e,this.G=[],this.B=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){var r,i,n,s,a,c;if(t){const l=e.baseOptions||{};if((r=e.baseOptions)!=null&&r.modelAssetBuffer&&((i=e.baseOptions)!=null&&i.modelAssetPath))throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!((n=P(this.baseOptions,Di,1))!=null&&n.g()||(s=P(this.baseOptions,Di,1))!=null&&s.h()||(a=e.baseOptions)!=null&&a.modelAssetBuffer||(c=e.baseOptions)!=null&&c.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(u,h){let f=P(u.baseOptions,sc,3);if(!f){var w=f=new sc,m=new Va;Vr(w,4,Pi,m)}"delegate"in h&&(h.delegate==="GPU"?(h=f,w=new nd,Vr(h,2,Pi,w)):(h=f,w=new Va,Vr(h,4,Pi,w))),S(u.baseOptions,0,3,f)}(this,l),l.modelAssetPath)return fetch(l.modelAssetPath.toString()).then(u=>{if(u.ok)return u.arrayBuffer();throw Error(`Failed to fetch model: ${l.modelAssetPath} (${u.status})`)}).then(u=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(u),!0,!1,!1),Ss(this,"/model.dat"),this.m(),this.J()});if(l.modelAssetBuffer instanceof Uint8Array)Ss(this,l.modelAssetBuffer);else if(l.modelAssetBuffer)return async function(u){const h=[];for(var f=0;;){const{done:w,value:m}=await u.read();if(w)break;h.push(m),f+=m.length}if(h.length===0)return new Uint8Array(0);if(h.length===1)return h[0];u=new Uint8Array(f),f=0;for(const w of h)u.set(w,f),f+=w.length;return u}(l.modelAssetBuffer).then(u=>{Ss(this,u),this.m(),this.J()})}return this.m(),this.J(),Promise.resolve()}J(){}ca(){let e;if(this.g.ca(t=>{e=sd(t)}),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener((r,i)=>{this.G.push(Error(i))}),this.g.Ha(),this.g.setGraph(e,t),this.A=void 0,Rc(this)}finishProcessing(){this.g.finishProcessing(),Rc(this)}close(){this.A=void 0,this.g.closeGraph()}};function vt(e,t){if(!e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}As.prototype.close=As.prototype.close;class Md{constructor(t,r,i,n){this.g=t,this.h=r,this.m=i,this.l=n}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function Oc(e,t,r){const i=e.g;if(r=vt(i.createShader(r),"Failed to create WebGL shader"),i.shaderSource(r,t),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${i.getShaderInfoLog(r)}`);return i.attachShader(e.h,r),r}function Bc(e,t){const r=e.g,i=vt(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(i);const n=vt(r.createBuffer(),"Failed to create buffer");r.bindBuffer(r.ARRAY_BUFFER,n),r.enableVertexAttribArray(e.P),r.vertexAttribPointer(e.P,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),r.STATIC_DRAW);const s=vt(r.createBuffer(),"Failed to create buffer");return r.bindBuffer(r.ARRAY_BUFFER,s),r.enableVertexAttribArray(e.J),r.vertexAttribPointer(e.J,2,r.FLOAT,!1,0,0),r.bufferData(r.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,null),r.bindVertexArray(null),new Md(r,i,n,s)}function Ts(e,t){if(e.g){if(t!==e.g)throw Error("Cannot change GL context once initialized")}else e.g=t}function js(e,t,r,i){return Ts(e,t),e.h||(e.m(),e.C()),r?(e.s||(e.s=Bc(e,!0)),r=e.s):(e.v||(e.v=Bc(e,!1)),r=e.v),t.useProgram(e.h),r.bind(),e.l(),e=i(),r.g.bindVertexArray(null),e}function Vi(e,t,r){return Ts(e,t),e=vt(t.createTexture(),"Failed to create texture"),t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,r??t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,r??t.LINEAR),t.bindTexture(t.TEXTURE_2D,null),e}function $i(e,t,r){Ts(e,t),e.A||(e.A=vt(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.A),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0)}function Ns(e){var t;(t=e.g)==null||t.bindFramebuffer(e.g.FRAMEBUFFER,null)}var Cs=class{G(){return`
10
10
  precision mediump float;
11
11
  varying vec2 vTex;
12
12
  uniform sampler2D inputTexture;
13
13
  void main() {
14
14
  gl_FragColor = texture2D(inputTexture, vTex);
15
15
  }
16
- `}m(){const e=this.g;if(this.h=bt(e.createProgram(),"Failed to create WebGL program"),this.Z=Dc(this,`
16
+ `}m(){const e=this.g;if(this.h=vt(e.createProgram(),"Failed to create WebGL program"),this.Z=Oc(this,`
17
17
  attribute vec2 aVertex;
18
18
  attribute vec2 aTex;
19
19
  varying vec2 vTex;
20
20
  void main(void) {
21
21
  gl_Position = vec4(aVertex, 0.0, 1.0);
22
22
  vTex = aTex;
23
- }`,e.VERTEX_SHADER),this.Y=Dc(this,this.G(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.P=e.getAttribLocation(this.h,"aVertex"),this.J=e.getAttribLocation(this.h,"aTex")}C(){}l(){}close(){if(this.h){const e=this.g;e.deleteProgram(this.h),e.deleteShader(this.Z),e.deleteShader(this.Y)}this.A&&this.g.deleteFramebuffer(this.A),this.v&&this.v.close(),this.s&&this.s.close()}};function vt(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 Ns(e){var t=vt(e,1);if(!t){if(t=vt(e,0))t=new Float32Array(t).map(i=>i/255);else{t=new Float32Array(e.width*e.height);const i=Tr(e);var r=Cs(e);if($i(r,i,Oc(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 Oc(e){let t=vt(e,2);if(!t){const r=Tr(e);t=Uc(e);const i=Ns(e),n=Bc(e);r.texImage2D(r.TEXTURE_2D,0,n,e.width,e.height,0,r.RED,r.FLOAT,i),Is(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=bt(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Bc(e){if(e=Tr(e),!Wi)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Wi=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Wi=e.R16F}return Wi}function Cs(e){return e.l||(e.l=new js),e.l}function Uc(e){const t=Tr(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=vt(e,2);return r||(r=Vi(Cs(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Is(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Wi,he=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&&--Gc===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Da(){return!!vt(this,0)}ja(){return!!vt(this,1)}R(){return!!vt(this,2)}ia(){return(t=vt(e=this,0))||(t=Ns(e),t=new Uint8Array(t.map(r=>255*r)),e.g.push(t)),t;var e,t}ha(){return Ns(this)}N(){return Oc(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=Cs(this);i.activeTexture(i.TEXTURE1),r=Vi(n,i,this.m?i.LINEAR:i.NEAREST),i.bindTexture(i.TEXTURE_2D,r);const s=Bc(this);i.texImage2D(i.TEXTURE_2D,0,s,this.width,this.height,0,i.RED,i.FLOAT,null),i.bindTexture(i.TEXTURE_2D,null),$i(n,i,r),As(n,i,!1,()=>{Uc(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),Is(this)}),Ts(n),Is(this)}}e.push(r)}return new he(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Tr(this).deleteTexture(vt(this,2)),Gc=-1}};he.prototype.close=he.prototype.close,he.prototype.clone=he.prototype.clone,he.prototype.getAsWebGLTexture=he.prototype.N,he.prototype.getAsFloat32Array=he.prototype.ha,he.prototype.getAsUint8Array=he.prototype.ia,he.prototype.hasWebGLTexture=he.prototype.R,he.prototype.hasFloat32Array=he.prototype.ja,he.prototype.hasUint8Array=he.prototype.Da;var Gc=250;function nt(e,t){switch(t){case 0:return e.g.find(r=>r instanceof ImageData);case 1:return e.g.find(r=>typeof ImageBitmap<"u"&&r instanceof ImageBitmap);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function Vc(e){var t=nt(e,0);if(!t){t=jr(e);const r=Hi(e),i=new Uint8Array(e.width*e.height*4);$i(r,t,zi(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,i),Ts(r),t=new ImageData(new Uint8ClampedArray(i.buffer),e.width,e.height),e.g.push(t)}return t}function zi(e){let t=nt(e,2);if(!t){const r=jr(e);t=qi(e);const i=nt(e,1)||Vc(e);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,i),Qr(e)}return t}function jr(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=bt(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Hi(e){return e.l||(e.l=new js),e.l}function qi(e){const t=jr(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=nt(e,2);return r||(r=Vi(Hi(e),t),e.g.push(r),e.m=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Qr(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function $c(e){const t=jr(e);return As(Hi(e),t,!0,()=>function(r,i){const n=r.canvas;if(n.width===r.width&&n.height===r.height)return i();const s=n.width,a=n.height;return n.width=r.width,n.height=r.height,r=i(),n.width=s,n.height=a,r}(e,()=>{if(t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),!(e.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return e.canvas.transferToImageBitmap()}))}var fe=class{constructor(e,t,r,i,n,s,a){this.g=e,this.j=t,this.m=r,this.canvas=i,this.l=n,this.width=s,this.height=a,(this.j||this.m)&&--Wc===0&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Ca(){return!!nt(this,0)}ka(){return!!nt(this,1)}R(){return!!nt(this,2)}Aa(){return Vc(this)}za(){var e=nt(this,1);return e||(zi(this),qi(this),e=$c(this),Qr(this),this.g.push(e),this.j=!0),e}N(){return zi(this)}clone(){const e=[];for(const t of this.g){let r;if(t instanceof ImageData)r=new ImageData(t.data,this.width,this.height);else if(t instanceof WebGLTexture){const i=jr(this),n=Hi(this);i.activeTexture(i.TEXTURE1),r=Vi(n,i),i.bindTexture(i.TEXTURE_2D,r),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.bindTexture(i.TEXTURE_2D,null),$i(n,i,r),As(n,i,!1,()=>{qi(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),Qr(this)}),Ts(n),Qr(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);zi(this),qi(this),r=$c(this),Qr(this)}e.push(r)}return new fe(e,this.ka(),this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&nt(this,1).close(),this.m&&jr(this).deleteTexture(nt(this,2)),Wc=-1}};fe.prototype.close=fe.prototype.close,fe.prototype.clone=fe.prototype.clone,fe.prototype.getAsWebGLTexture=fe.prototype.N,fe.prototype.getAsImageBitmap=fe.prototype.za,fe.prototype.getAsImageData=fe.prototype.Aa,fe.prototype.hasWebGLTexture=fe.prototype.R,fe.prototype.hasImageBitmap=fe.prototype.ka,fe.prototype.hasImageData=fe.prototype.Ca;var Wc=250;function Qe(...e){return e.map(([t,r])=>({start:t,end:r}))}const Md=function(e){return class extends e{Ha(){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?'),E(this,i||"input_audio",s=>{E(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){it(this,"__graph_config__",t=>{e(t)}),E(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),E(this,i,a=>{this.i._addAudioToInputStream(this.g,t,r,a,n)})}addGpuBufferToStream(e,t,r){E(this,t,i=>{const[n,s]=Lc(this,e,i);this.i._addBoundTextureToStream(i,n,s,r)})}addBoolToStream(e,t,r){E(this,t,i=>{this.i._addBoolToInputStream(e,i,r)})}addDoubleToStream(e,t,r){E(this,t,i=>{this.i._addDoubleToInputStream(e,i,r)})}addFloatToStream(e,t,r){E(this,t,i=>{this.i._addFloatToInputStream(e,i,r)})}addIntToStream(e,t,r){E(this,t,i=>{this.i._addIntToInputStream(e,i,r)})}addUintToStream(e,t,r){E(this,t,i=>{this.i._addUintToInputStream(e,i,r)})}addStringToStream(e,t,r){E(this,t,i=>{E(this,e,n=>{this.i._addStringToInputStream(n,i,r)})})}addStringRecordToStream(e,t,r){E(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){E(this,r,n=>{E(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){E(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){E(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){E(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){E(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){E(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){E(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){E(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)E(this,s,a=>{this.i._addStringVectorEntry(n,a)});this.i._addStringVectorToInputStream(n,i,r)})}addBoolToInputSidePacket(e,t){E(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){E(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){E(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){E(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){E(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){E(this,t,r=>{E(this,e,i=>{this.i._addStringToInputSidePacket(i,r)})})}addProtoToInputSidePacket(e,t,r){E(this,r,i=>{E(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){E(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){E(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){E(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){E(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){E(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){E(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)E(this,n,s=>{this.i._addStringVectorEntry(i,s)});this.i._addStringVectorToInputSidePacket(i,r)})}attachBoolListener(e,t){it(this,e,t),E(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){Dt(this,e,t),E(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){it(this,e,t),E(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){Dt(this,e,t),E(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){it(this,e,t),E(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){Dt(this,e,t),E(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){it(this,e,t),E(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){Dt(this,e,t),E(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){it(this,e,t),E(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){Dt(this,e,t),E(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){it(this,e,t),E(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){Dt(this,e,t),E(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){it(this,e,t),E(this,e,i=>{this.i._attachProtoListener(i,r||!1)})}attachProtoVectorListener(e,t,r){Dt(this,e,t),E(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?'),it(this,e,(i,n)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,n)}),E(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 ea(){return this.i}oa(e,t,r){E(this,t,i=>{const[n,s]=Lc(this,e,i);this.ea._addBoundTextureAsImageToStream(i,n,s,r)})}V(e,t){it(this,e,t),E(this,e,r=>{this.ea._attachImageListener(r)})}ba(e,t){Dt(this,e,t),E(this,e,r=>{this.ea._attachImageVectorListener(r)})}}));var zc,Ve=class extends Md{};async function I(e,t,r){return async function(i,n,s,a){return Cd(i,n,s,a)}(e,r.canvas??(Cc()?void 0:document.createElement("canvas")),t,r)}function Hc(e,t,r,i){if(e.U){const s=new Ja;if(r!=null&&r.regionOfInterest){if(!e.na)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].");v(s,1,(n.left+n.right)/2),v(s,2,(n.top+n.bottom)/2),v(s,4,n.right-n.left),v(s,3,n.bottom-n.top)}else v(s,1,.5),v(s,2,.5),v(s,4,1),v(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(v(s,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[a,c]=Mc(t);r=te(s,3)*c/a,n=te(s,4)*a/c,v(s,4,r),v(s,3,n)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,i)}e.g.oa(t,e.Z,i??performance.now()),e.finishProcessing()}function $e(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'.");Hc(e,t,r,e.B+1)}function st(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'.");Hc(e,t,r,i)}function Nr(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 he([n],r,!1,e.g.i.canvas,e.P,s,t),i?e.clone():e}var Se=class extends Es{constructor(e,t,r,i){super(e),this.g=e,this.Z=t,this.U=r,this.na=i,this.P=new js}l(e,t=!0){if("runningMode"in e&&Wr(this.baseOptions,2,!!e.runningMode&&e.runningMode!=="IMAGE"),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Se.prototype.close=Se.prototype.close;var We=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},S(e=this.h=new Ri,0,1,t=new H),v(this.h,2,.5),v(this.h,3,.3)}get baseOptions(){return P(this.h,H,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&v(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&v(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}D(e,t){return this.j={detections:[]},$e(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},st(this,e,r,t),this.j}m(){var e=new Ee;$(e,"image_in"),$(e,"norm_rect_in"),D(e,"detections");const t=new Ie;Ye(t,gd,this.h);const r=new be;Me(r,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),V(r,"IMAGE:image_in"),V(r,"NORM_RECT:norm_rect_in"),L(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Ka(s),this.j.detections.push(Ac(i));x(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};We.prototype.detectForVideo=We.prototype.F,We.prototype.detect=We.prototype.D,We.prototype.setOptions=We.prototype.o,We.createFromModelPath=async function(e,t){return I(We,e,{baseOptions:{modelAssetPath:t}})},We.createFromModelBuffer=function(e,t){return I(We,e,{baseOptions:{modelAssetBuffer:t}})},We.createFromOptions=function(e,t){return I(We,e,t)};var Ms=Qe([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]),Ls=Qe([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]),Fs=Qe([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),qc=Qe([474,475],[475,476],[476,477],[477,474]),Ps=Qe([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]),Ds=Qe([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Yc=Qe([469,470],[470,471],[471,472],[472,469]),Rs=Qe([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]),Kc=[...Ms,...Ls,...Fs,...Ps,...Ds,...Rs],Xc=Qe([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 Qc(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var K=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,S(e=this.h=new oc,0,1,t=new H),this.v=new sc,S(this.h,0,3,this.v),this.s=new Ri,S(this.h,0,2,this.s),rt(this.s,4,1),v(this.s,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return P(this.h,H,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return"numFaces"in e&&rt(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&v(this.v,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}D(e,t){return Qc(this),$e(this,e,t),this.j}F(e,t,r){return Qc(this),st(this,e,r,t),this.j}m(){var e=new Ee;$(e,"image_in"),$(e,"norm_rect"),D(e,"face_landmarks");const t=new Ie;Ye(t,xd,this.h);const r=new be;Me(r,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),V(r,"IMAGE:image_in"),V(r,"NORM_RECT:norm_rect"),L(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("face_landmarks",(i,n)=>{for(const s of i)i=Yr(s),this.j.faceLandmarks.push(Oi(i));x(this,n)}),this.g.attachEmptyPacketListener("face_landmarks",i=>{x(this,i)}),this.outputFaceBlendshapes&&(D(e,"blendshapes"),L(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(i,n)=>{if(this.outputFaceBlendshapes)for(const s of i)i=Fi(s),this.j.faceBlendshapes.push(_s(i.g()??[]));x(this,n)}),this.g.attachEmptyPacketListener("blendshapes",i=>{x(this,i)})),this.outputFacialTransformationMatrixes&&(D(e,"face_geometry"),L(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(i,n)=>{if(this.outputFacialTransformationMatrixes)for(const s of i)(i=P(pd(s),cd,2))&&this.j.facialTransformationMatrixes.push({rows:Ue(i,1)??0??0,columns:Ue(i,2)??0??0,data:Kt(i,3,Nt,Yt()).slice()??[]});x(this,n)}),this.g.attachEmptyPacketListener("face_geometry",i=>{x(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};K.prototype.detectForVideo=K.prototype.F,K.prototype.detect=K.prototype.D,K.prototype.setOptions=K.prototype.o,K.createFromModelPath=function(e,t){return I(K,e,{baseOptions:{modelAssetPath:t}})},K.createFromModelBuffer=function(e,t){return I(K,e,{baseOptions:{modelAssetBuffer:t}})},K.createFromOptions=function(e,t){return I(K,e,t)},K.FACE_LANDMARKS_LIPS=Ms,K.FACE_LANDMARKS_LEFT_EYE=Ls,K.FACE_LANDMARKS_LEFT_EYEBROW=Fs,K.FACE_LANDMARKS_LEFT_IRIS=qc,K.FACE_LANDMARKS_RIGHT_EYE=Ps,K.FACE_LANDMARKS_RIGHT_EYEBROW=Ds,K.FACE_LANDMARKS_RIGHT_IRIS=Yc,K.FACE_LANDMARKS_FACE_OVAL=Rs,K.FACE_LANDMARKS_CONTOURS=Kc,K.FACE_LANDMARKS_TESSELATION=Xc;var ot=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!0),S(e=this.j=new cc,0,1,t=new H)}get baseOptions(){return P(this.j,H,1)}set baseOptions(e){S(this.j,0,1,e)}o(e){return super.l(e)}Ka(e,t,r){const i=typeof t!="function"?t:{};if(this.h=typeof t=="function"?t:r,$e(this,e,i??{}),!this.h)return this.s}m(){var e=new Ee;$(e,"image_in"),$(e,"norm_rect"),D(e,"stylized_image");const t=new Ie;Ye(t,yd,this.j);const r=new be;Me(r,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),V(r,"IMAGE:image_in"),V(r,"NORM_RECT:norm_rect"),L(r,"STYLIZED_IMAGE:stylized_image"),r.o(t),Le(e,r),this.g.V("stylized_image",(i,n)=>{var s=!this.h,a=i.data,c=i.width;const l=c*(i=i.height);if(a instanceof Uint8Array)if(a.length===3*l){const u=new Uint8ClampedArray(4*l);for(let h=0;h<l;++h)u[4*h]=a[3*h],u[4*h+1]=a[3*h+1],u[4*h+2]=a[3*h+2],u[4*h+3]=255;a=new ImageData(u,c,i)}else{if(a.length!==4*l)throw Error("Unsupported channel count: "+a.length/l);a=new ImageData(new Uint8ClampedArray(a.buffer,a.byteOffset,a.length),c,i)}else if(!(a instanceof WebGLTexture))throw Error(`Unsupported format: ${a.constructor.name}`);c=new fe([a],!1,!1,this.g.i.canvas,this.P,c,i),this.s=s=s?c.clone():c,this.h&&this.h(s),x(this,n)}),this.g.attachEmptyPacketListener("stylized_image",i=>{this.s=null,this.h&&this.h(null),x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ot.prototype.stylize=ot.prototype.Ka,ot.prototype.setOptions=ot.prototype.o,ot.createFromModelPath=function(e,t){return I(ot,e,{baseOptions:{modelAssetPath:t}})},ot.createFromModelBuffer=function(e,t){return I(ot,e,{baseOptions:{modelAssetBuffer:t}})},ot.createFromOptions=function(e,t){return I(ot,e,t)};var Os=Qe([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 Jc(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Zc(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 el(e,t=!0){const r=[];for(const n of e){var i=Fi(n);e=[];for(const s of i.g())i=t&&Ue(s,1)!=null?Ue(s,1)??0:-1,e.push({score:te(s,2)??0,index:i,categoryName:Ge(s,3)??""??"",displayName:Ge(s,4)??""??""});r.push(e)}return r}var Fe=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],S(e=this.j=new dc,0,1,t=new H),this.s=new gs,S(this.j,0,2,this.s),this.C=new ms,S(this.s,0,3,this.C),this.v=new uc,S(this.s,0,2,this.v),this.h=new bd,S(this.j,0,3,this.h),v(this.v,2,.5),v(this.s,4,.5),v(this.C,2,.5)}get baseOptions(){return P(this.j,H,1)}set baseOptions(e){S(this.j,0,1,e)}o(e){var n,s,a,c;if(rt(this.v,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.v,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.s,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.C,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Sr,r=t,i=vs(e.cannedGesturesClassifierOptions,(n=P(this.h,Sr,3))==null?void 0:n.h());S(r,0,2,i),S(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&((s=P(this.h,Sr,3))==null||s.g());return e.customGesturesClassifierOptions?(S(r=t=new Sr,0,2,i=vs(e.customGesturesClassifierOptions,(a=P(this.h,Sr,4))==null?void 0:a.h())),S(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&((c=P(this.h,Sr,4))==null||c.g()),this.l(e)}Fa(e,t){return Jc(this),$e(this,e,t),Zc(this)}Ga(e,t,r){return Jc(this),st(this,e,r,t),Zc(this)}m(){var e=new Ee;$(e,"image_in"),$(e,"norm_rect"),D(e,"hand_gestures"),D(e,"hand_landmarks"),D(e,"world_hand_landmarks"),D(e,"handedness");const t=new Ie;Ye(t,vd,this.j);const r=new be;Me(r,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),V(r,"IMAGE:image_in"),V(r,"NORM_RECT:norm_rect"),L(r,"HAND_GESTURES:hand_gestures"),L(r,"LANDMARKS:hand_landmarks"),L(r,"WORLD_LANDMARKS:world_hand_landmarks"),L(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i){i=Yr(s);const a=[];for(const c of gt(i,Qa,1))a.push({x:te(c,1)??0,y:te(c,2)??0,z:te(c,3)??0,visibility:te(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=Er(s);const a=[];for(const c of gt(i,Xa,1))a.push({x:te(c,1)??0,y:te(c,2)??0,z:te(c,3)??0,visibility:te(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(...el(i,!1)),x(this,n)}),this.g.attachEmptyPacketListener("hand_gestures",i=>{x(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{this.handedness.push(...el(i)),x(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function tl(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Fe.prototype.recognizeForVideo=Fe.prototype.Ga,Fe.prototype.recognize=Fe.prototype.Fa,Fe.prototype.setOptions=Fe.prototype.o,Fe.createFromModelPath=function(e,t){return I(Fe,e,{baseOptions:{modelAssetPath:t}})},Fe.createFromModelBuffer=function(e,t){return I(Fe,e,{baseOptions:{modelAssetBuffer:t}})},Fe.createFromOptions=function(e,t){return I(Fe,e,t)},Fe.HAND_CONNECTIONS=Os;var Pe=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],S(e=this.h=new gs,0,1,t=new H),this.s=new ms,S(this.h,0,3,this.s),this.j=new uc,S(this.h,0,2,this.j),rt(this.j,3,1),v(this.j,2,.5),v(this.s,2,.5),v(this.h,4,.5)}get baseOptions(){return P(this.h,H,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return"numHands"in e&&rt(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}D(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],$e(this,e,t),tl(this)}F(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],st(this,e,r,t),tl(this)}m(){var e=new Ee;$(e,"image_in"),$(e,"norm_rect"),D(e,"hand_landmarks"),D(e,"world_hand_landmarks"),D(e,"handedness");const t=new Ie;Ye(t,_d,this.h);const r=new be;Me(r,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),V(r,"IMAGE:image_in"),V(r,"NORM_RECT:norm_rect"),L(r,"LANDMARKS:hand_landmarks"),L(r,"WORLD_LANDMARKS:world_hand_landmarks"),L(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i)i=Yr(s),this.landmarks.push(Oi(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=Er(s),this.worldLandmarks.push(Kr(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=Fi(l);const u=[];for(const h of i.g())u.push({score:te(h,2)??0,index:Ue(h,1)??0??-1,categoryName:Ge(h,3)??""??"",displayName:Ge(h,4)??""??""});c.push(u)}a.call(s,...c),x(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Pe.prototype.detectForVideo=Pe.prototype.F,Pe.prototype.detect=Pe.prototype.D,Pe.prototype.setOptions=Pe.prototype.o,Pe.createFromModelPath=function(e,t){return I(Pe,e,{baseOptions:{modelAssetPath:t}})},Pe.createFromModelBuffer=function(e,t){return I(Pe,e,{baseOptions:{modelAssetBuffer:t}})},Pe.createFromOptions=function(e,t){return I(Pe,e,t)},Pe.HAND_CONNECTIONS=Os;var rl=Qe([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 il(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function nl(e){try{if(!e.C)return e.h;e.C(e.h)}finally{Gi(e)}}function Yi(e,t){e=Yr(e),t.push(Oi(e))}var q=class extends Se{constructor(e,t){super(new Ve(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,S(e=this.j=new pc,0,1,t=new H),this.K=new ms,S(this.j,0,2,this.K),this.Y=new kd,S(this.j,0,3,this.Y),this.s=new Ri,S(this.j,0,4,this.s),this.H=new sc,S(this.j,0,5,this.H),this.v=new mc,S(this.j,0,6,this.v),this.L=new gc,S(this.j,0,7,this.L),v(this.s,2,.5),v(this.s,3,.3),v(this.H,2,.5),v(this.v,2,.5),v(this.v,3,.3),v(this.L,2,.5),v(this.K,2,.5)}get baseOptions(){return P(this.j,H,1)}set baseOptions(e){S(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&v(this.s,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&v(this.H,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&v(this.v,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&v(this.v,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&v(this.L,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&v(this.K,2,e.minHandLandmarksConfidence??.5),this.l(e)}D(e,t,r){const i=typeof t!="function"?t:{};return this.C=typeof t=="function"?t:r,il(this),$e(this,e,i),nl(this)}F(e,t,r,i){const n=typeof r!="function"?r:{};return this.C=typeof r=="function"?r:i,il(this),st(this,e,n,t),nl(this)}m(){var e=new Ee;$(e,"input_frames_image"),D(e,"pose_landmarks"),D(e,"pose_world_landmarks"),D(e,"face_landmarks"),D(e,"left_hand_landmarks"),D(e,"left_hand_world_landmarks"),D(e,"right_hand_landmarks"),D(e,"right_hand_world_landmarks");const t=new Ie,r=new La;Rn(r,1,hr("type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),""),function(n,s){if(s!=null)if(Array.isArray(s))G(n,2,mi(s,Ln,void 0,void 0,!1));else{if(!(typeof s=="string"||s instanceof ft||zt(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Rn(n,2,bn(s,!1),Ht())}}(r,this.j.g());const i=new be;Me(i,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),bi(i,8,La,r),V(i,"IMAGE:input_frames_image"),L(i,"POSE_LANDMARKS:pose_landmarks"),L(i,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),L(i,"FACE_LANDMARKS:face_landmarks"),L(i,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),L(i,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),L(i,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),L(i,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),i.o(t),Le(e,i),Ui(this,e),this.g.attachProtoListener("pose_landmarks",(n,s)=>{Yi(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=Er(n),a.push(Kr(n)),x(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",n=>{x(this,n)}),this.outputPoseSegmentationMasks&&(L(i,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Ar(this,"pose_segmentation_mask"),this.g.V("pose_segmentation_mask",(n,s)=>{this.h.poseSegmentationMasks=[Nr(this,n,!0,!this.C)],x(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",n=>{this.h.poseSegmentationMasks=[],x(this,n)})),this.g.attachProtoListener("face_landmarks",(n,s)=>{Yi(n,this.h.faceLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{x(this,n)}),this.outputFaceBlendshapes&&(D(e,"extra_blendshapes"),L(i,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(n,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(n=Fi(n),a.push(_s(n.g()??[]))),x(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",n=>{x(this,n)})),this.g.attachProtoListener("left_hand_landmarks",(n,s)=>{Yi(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=Er(n),a.push(Kr(n)),x(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("right_hand_landmarks",(n,s)=>{Yi(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=Er(n),a.push(Kr(n)),x(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",n=>{x(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};q.prototype.detectForVideo=q.prototype.F,q.prototype.detect=q.prototype.D,q.prototype.setOptions=q.prototype.o,q.createFromModelPath=function(e,t){return I(q,e,{baseOptions:{modelAssetPath:t}})},q.createFromModelBuffer=function(e,t){return I(q,e,{baseOptions:{modelAssetBuffer:t}})},q.createFromOptions=function(e,t){return I(q,e,t)},q.HAND_CONNECTIONS=Os,q.POSE_CONNECTIONS=rl,q.FACE_LANDMARKS_LIPS=Ms,q.FACE_LANDMARKS_LEFT_EYE=Ls,q.FACE_LANDMARKS_LEFT_EYEBROW=Fs,q.FACE_LANDMARKS_LEFT_IRIS=qc,q.FACE_LANDMARKS_RIGHT_EYE=Ps,q.FACE_LANDMARKS_RIGHT_EYEBROW=Ds,q.FACE_LANDMARKS_RIGHT_IRIS=Yc,q.FACE_LANDMARKS_FACE_OVAL=Rs,q.FACE_LANDMARKS_CONTOURS=Kc,q.FACE_LANDMARKS_TESSELATION=Xc;var ze=class extends Se{constructor(e,t){super(new Ve(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},S(e=this.h=new xc,0,1,t=new H)}get baseOptions(){return P(this.h,H,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return S(this.h,0,2,vs(e,P(this.h,hs,2))),this.l(e)}qa(e,t){return this.j={classifications:[]},$e(this,e,t),this.j}ra(e,t,r){return this.j={classifications:[]},st(this,e,r,t),this.j}m(){var e=new Ee;$(e,"input_image"),$(e,"norm_rect"),D(e,"classifications");const t=new Ie;Ye(t,Ed,this.h);const r=new be;Me(r,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),V(r,"IMAGE:input_image"),V(r,"NORM_RECT:norm_rect"),L(r,"CLASSIFICATIONS:classifications"),r.o(t),Le(e,r),this.g.attachProtoListener("classifications",(i,n)=>{this.j=function(s){const a={classifications:gt(s,ud,1).map(c=>{var l;return _s(((l=P(c,qa,4))==null?void 0:l.g())??[],Ue(c,2)??0,Ge(c,3)??"")})};return jn(wr(s,2))!=null&&(a.timestampMs=jn(wr(s,2))??0),a}(dd(i)),x(this,n)}),this.g.attachEmptyPacketListener("classifications",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ze.prototype.classifyForVideo=ze.prototype.ra,ze.prototype.classify=ze.prototype.qa,ze.prototype.setOptions=ze.prototype.o,ze.createFromModelPath=function(e,t){return I(ze,e,{baseOptions:{modelAssetPath:t}})},ze.createFromModelBuffer=function(e,t){return I(ze,e,{baseOptions:{modelAssetBuffer:t}})},ze.createFromOptions=function(e,t){return I(ze,e,t)};var De=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!0),this.h=new yc,this.embeddings={embeddings:[]},S(e=this.h,0,1,t=new H)}get baseOptions(){return P(this.h,H,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){var t=this.h,r=P(this.h,rc,2);return r=r?r.clone():new rc,e.l2Normalize!==void 0?Wr(r,1,e.l2Normalize):"l2Normalize"in e&&G(r,1),e.quantize!==void 0?Wr(r,2,e.quantize):"quantize"in e&&G(r,2),S(t,0,2,r),this.l(e)}xa(e,t){return $e(this,e,t),this.embeddings}ya(e,t,r){return st(this,e,r,t),this.embeddings}m(){var e=new Ee;$(e,"image_in"),$(e,"norm_rect"),D(e,"embeddings_out");const t=new Ie;Ye(t,Sd,this.h);const r=new be;Me(r,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),V(r,"IMAGE:image_in"),V(r,"NORM_RECT:norm_rect"),L(r,"EMBEDDINGS:embeddings_out"),r.o(t),Le(e,r),this.g.attachProtoListener("embeddings_out",(i,n)=>{i=wd(i),this.embeddings=function(s){return{embeddings:gt(s,fd,1).map(a=>{var l,u;const c={headIndex:Ue(a,3)??0??-1,headName:Ge(a,4)??""??""};if(ea(a,Za,On(a,1))!==void 0)a=Kt(a=P(a,Za,On(a,1)),1,Nt,Yt()),c.floatEmbedding=a.slice();else{const h=new Uint8Array(0);c.quantizedEmbedding=((u=(l=P(a,hd,On(a,2)))==null?void 0:l.ma())==null?void 0:u.h())??h}return c}),timestampMs:jn(wr(s,2))??0}}(i),x(this,n)}),this.g.attachEmptyPacketListener("embeddings_out",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};De.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=jc(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=jc(Tc(e.quantizedEmbedding),Tc(t.quantizedEmbedding))}return e},De.prototype.embedForVideo=De.prototype.ya,De.prototype.embed=De.prototype.xa,De.prototype.setOptions=De.prototype.o,De.createFromModelPath=function(e,t){return I(De,e,{baseOptions:{modelAssetPath:t}})},De.createFromModelBuffer=function(e,t){return I(De,e,{baseOptions:{modelAssetBuffer:t}})},De.createFromOptions=function(e,t){return I(De,e,t)};var Bs=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 sl(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function ol(e){try{const t=new Bs(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{Gi(e)}}Bs.prototype.close=Bs.prototype.close;var Ae=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new bs,this.v=new bc,S(this.h,0,3,this.v),S(e=this.h,0,1,t=new H)}get baseOptions(){return P(this.h,H,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?G(this.h,2,hr(e.displayNamesLocale)):"displayNamesLocale"in e&&G(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}J(){(function(e){var r,i;const t=gt(e.ca(),be,1).filter(n=>(Ge(n,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.s=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(((i=(r=P(t[0],Ie,7))==null?void 0:r.l())==null?void 0:i.g())??new Map).forEach((n,s)=>{e.s[Number(s)]=Ge(n,1)??""})})(this)}segment(e,t,r){const i=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,sl(this),$e(this,e,i),ol(this)}Ia(e,t,r,i){const n=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:i,sl(this),st(this,e,n,t),ol(this)}Ba(){return this.s}m(){var e=new Ee;$(e,"image_in"),$(e,"norm_rect");const t=new Ie;Ye(t,kc,this.h);const r=new be;Me(r,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),V(r,"IMAGE:image_in"),V(r,"NORM_RECT:norm_rect"),r.o(t),Le(e,r),Ui(this,e),this.outputConfidenceMasks&&(D(e,"confidence_masks"),L(r,"CONFIDENCE_MASKS:confidence_masks"),Ar(this,"confidence_masks"),this.g.ba("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Nr(this,s,!0,!this.j)),x(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],x(this,i)})),this.outputCategoryMask&&(D(e,"category_mask"),L(r,"CATEGORY_MASK:category_mask"),Ar(this,"category_mask"),this.g.V("category_mask",(i,n)=>{this.categoryMask=Nr(this,i,!1,!this.j),x(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,x(this,i)})),D(e,"quality_scores"),L(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.Ba,Ae.prototype.segmentForVideo=Ae.prototype.Ia,Ae.prototype.segment=Ae.prototype.segment,Ae.prototype.setOptions=Ae.prototype.o,Ae.createFromModelPath=function(e,t){return I(Ae,e,{baseOptions:{modelAssetPath:t}})},Ae.createFromModelBuffer=function(e,t){return I(Ae,e,{baseOptions:{modelAssetBuffer:t}})},Ae.createFromOptions=function(e,t){return I(Ae,e,t)};var Us=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()}};Us.prototype.close=Us.prototype.close;var Ld=class extends y{constructor(e){super(e)}},Cr=[0,J,-2],Ki=[0,yt,-3,z,yt,-1],al=[0,Ki],cl=[0,Ki,J,-1],Gs=class extends y{constructor(e){super(e)}},ll=[0,yt,-1,z],Fd=class extends y{constructor(e){super(e)}},ul=class extends y{constructor(e){super(e)}},Vs=[1,2,3,4,5,6,7,8,9,10,14,15],dl=class extends y{constructor(e){super(e)}};dl.prototype.g=Li([0,de,[0,Vs,O,Ki,O,[0,Ki,Cr],O,al,O,[0,al,Cr],O,ll,O,[0,yt,-3,z,Ce],O,[0,yt,-3,z],O,[0,R,yt,-2,z,J,z,-1,2,yt,Cr],O,cl,O,[0,cl,Cr],yt,Cr,R,O,[0,yt,-3,z,Cr,-1],O,[0,de,ll]],R,[0,R,J,-1,z]]);var at=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new bs,this.s=new bc,S(this.h,0,3,this.s),S(e=this.h,0,1,t=new H)}get baseOptions(){return P(this.h,H,1)}set baseOptions(e){S(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:{};this.j=typeof r=="function"?r:i,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.B+1,i=new dl;const s=new ul;var a=new Ld;if(rt(a,1,255),S(s,0,12,a),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var c=new Gs;Wr(c,3,!0),v(c,1,t.keypoint.x),v(c,2,t.keypoint.y),$r(s,5,Vs,c)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(c of(a=new Fd,t.scribble))Wr(t=new Gs,3,!0),v(t,1,c.x),v(t,2,c.y),bi(a,1,Gs,t);$r(s,15,Vs,a)}bi(i,1,ul,s),this.g.addProtoToStream(i.g(),"drishti.RenderData","roi_in",r),$e(this,e,n);e:{try{const u=new Us(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=u;break e}this.j(u)}finally{Gi(this)}l=void 0}return l}m(){var e=new Ee;$(e,"image_in"),$(e,"roi_in"),$(e,"norm_rect_in");const t=new Ie;Ye(t,kc,this.h);const r=new be;Me(r,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),V(r,"IMAGE:image_in"),V(r,"ROI:roi_in"),V(r,"NORM_RECT:norm_rect_in"),r.o(t),Le(e,r),Ui(this,e),this.outputConfidenceMasks&&(D(e,"confidence_masks"),L(r,"CONFIDENCE_MASKS:confidence_masks"),Ar(this,"confidence_masks"),this.g.ba("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Nr(this,s,!0,!this.j)),x(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],x(this,i)})),this.outputCategoryMask&&(D(e,"category_mask"),L(r,"CATEGORY_MASK:category_mask"),Ar(this,"category_mask"),this.g.V("category_mask",(i,n)=>{this.categoryMask=Nr(this,i,!1,!this.j),x(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,x(this,i)})),D(e,"quality_scores"),L(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)}};at.prototype.segment=at.prototype.segment,at.prototype.setOptions=at.prototype.o,at.createFromModelPath=function(e,t){return I(at,e,{baseOptions:{modelAssetPath:t}})},at.createFromModelBuffer=function(e,t){return I(at,e,{baseOptions:{modelAssetBuffer:t}})},at.createFromOptions=function(e,t){return I(at,e,t)};var He=class extends Se{constructor(e,t){super(new Ve(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},S(e=this.h=new Ec,0,1,t=new H)}get baseOptions(){return P(this.h,H,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?G(this.h,2,hr(e.displayNamesLocale)):"displayNamesLocale"in e&&G(this.h,2),e.maxResults!==void 0?rt(this.h,3,e.maxResults):"maxResults"in e&&G(this.h,3),e.scoreThreshold!==void 0?v(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&G(this.h,4),e.categoryAllowlist!==void 0?vi(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&G(this.h,5),e.categoryDenylist!==void 0?vi(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&G(this.h,6),this.l(e)}D(e,t){return this.j={detections:[]},$e(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},st(this,e,r,t),this.j}m(){var e=new Ee;$(e,"input_frame_gpu"),$(e,"norm_rect"),D(e,"detections");const t=new Ie;Ye(t,Td,this.h);const r=new be;Me(r,"mediapipe.tasks.vision.ObjectDetectorGraph"),V(r,"IMAGE:input_frame_gpu"),V(r,"NORM_RECT:norm_rect"),L(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Ka(s),this.j.detections.push(Ac(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.F,He.prototype.detect=He.prototype.D,He.prototype.setOptions=He.prototype.o,He.createFromModelPath=async function(e,t){return I(He,e,{baseOptions:{modelAssetPath:t}})},He.createFromModelBuffer=function(e,t){return I(He,e,{baseOptions:{modelAssetBuffer:t}})},He.createFromOptions=function(e,t){return I(He,e,t)};var $s=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 hl(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function fl(e){try{const t=new $s(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.s)return t;e.s(t)}finally{Gi(e)}}$s.prototype.close=$s.prototype.close;var Re=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,S(e=this.h=new Sc,0,1,t=new H),this.v=new gc,S(this.h,0,3,this.v),this.j=new mc,S(this.h,0,2,this.j),rt(this.j,4,1),v(this.j,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return P(this.h,H,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return"numPoses"in e&&rt(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&v(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&v(this.v,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}D(e,t,r){const i=typeof t!="function"?t:{};return this.s=typeof t=="function"?t:r,hl(this),$e(this,e,i),fl(this)}F(e,t,r,i){const n=typeof r!="function"?r:{};return this.s=typeof r=="function"?r:i,hl(this),st(this,e,n,t),fl(this)}m(){var e=new Ee;$(e,"image_in"),$(e,"norm_rect"),D(e,"normalized_landmarks"),D(e,"world_landmarks"),D(e,"segmentation_masks");const t=new Ie;Ye(t,jd,this.h);const r=new be;Me(r,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),V(r,"IMAGE:image_in"),V(r,"NORM_RECT:norm_rect"),L(r,"NORM_LANDMARKS:normalized_landmarks"),L(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),Le(e,r),Ui(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(i,n)=>{this.landmarks=[];for(const s of i)i=Yr(s),this.landmarks.push(Oi(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=Er(s),this.worldLandmarks.push(Kr(i));x(this,n)}),this.g.attachEmptyPacketListener("world_landmarks",i=>{this.worldLandmarks=[],x(this,i)}),this.outputSegmentationMasks&&(L(r,"SEGMENTATION_MASK:segmentation_masks"),Ar(this,"segmentation_masks"),this.g.ba("segmentation_masks",(i,n)=>{this.segmentationMasks=i.map(s=>Nr(this,s,!0,!this.s)),x(this,n)}),this.g.attachEmptyPacketListener("segmentation_masks",i=>{this.segmentationMasks=[],x(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Re.prototype.detectForVideo=Re.prototype.F,Re.prototype.detect=Re.prototype.D,Re.prototype.setOptions=Re.prototype.o,Re.createFromModelPath=function(e,t){return I(Re,e,{baseOptions:{modelAssetPath:t}})},Re.createFromModelBuffer=function(e,t){return I(Re,e,{baseOptions:{modelAssetBuffer:t}})},Re.createFromOptions=function(e,t){return I(Re,e,t)},Re.POSE_CONNECTIONS=rl;const Xi="https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task",Pd="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm",Dd=()=>{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 u=async()=>"caches"in window?await(await caches.open("mediapipe-models-v1")).match(Xi)!==void 0:!1,h=async()=>{try{const w=await fetch(Xi),m=w.headers.get("content-length"),g=m?parseInt(m,10):0;if(!w.body)throw new Error("No response body");const b=w.body.getReader();let _=0;const p=[];for(;;){const{done:A,value:F}=await b.read();if(A)break;if(p.push(F),_+=F.length,g){const j=Math.round(_/g*100);a(j),n(`Downloading model... ${j}%`)}}return"caches"in window&&await(await caches.open("mediapipe-models-v1")).put(Xi,new Response(new Blob(p),{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 u()?n("Using cached model..."):(n("Model not cached. Downloading..."),await h()),n("Loading MediaPipe WASM...");const g=await Jt.forVisionTasks(Pd);n("Creating face landmarker...");const b=await K.createFromOptions(g,{baseOptions:{modelAssetPath:Xi,delegate:"GPU"},runningMode:"VIDEO",outputFaceBlendshapes:!0,numFaces:2});e.current=b,r(!0),n("Model loaded successfully ✅")}catch(m){console.error("Model init error:",m),n(`Error: ${m==null?void 0:m.message}`),(m==null?void 0:m.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."))}}},Rd=()=>{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}},Od=()=>{const e=d.useRef({value:100,isLookingAway:!1}),t=d.useCallback((s,a,c,l)=>{if(!s||!c||!a)return;const u=s.getContext("2d");if(!u)return;const{width:h,height:f}=s;if(u.clearRect(0,0,h,f),u.drawImage(a,0,0,h,f),l){u.fillStyle="#00FF00";for(const w of c)u.fillRect(w.x*h-.5,w.y*f-.5,1,1)}},[]),r=d.useCallback(s=>{const a=e.current.value/100,c=100,l=20,u=10,h=10;s.fillStyle="rgba(0, 0, 0, 0.3)",s.fillRect(u,h,l,c),s.fillStyle=`rgba(${Math.floor(255*(1-a))}, ${Math.floor(255*a)}, 0, 0.8)`;const f=c*a;s.fillRect(u,h+c-f,l,f),s.fillStyle="#FFFFFF",s.fillRect(u,h+c*(1-a),l,2)},[]),i=d.useCallback((s,a,c,l,u,h,f)=>{if(t(s,a,c,l),u&&h&&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}},Bd=70,Ud=()=>{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 u=a[33],h=a[263],f=a[1];if(!u||!h||!f)return;const w=(u.x+h.x)*.5,m=(u.y+h.y)*.5,g=w-c.x,b=m-c.y,_=Math.sqrt(g*g+b*b),p=Math.abs(f.y-c.noseY)*100,A=Math.abs(f.x-c.noseX)*100,F=Math.max(0,100-(_*200+p+A)),j=F<Bd,C=performance.now();return C-n.current>100&&(t(F),i(j),n.current=C),{engagement:F,isLookingAway:j}},[]);return{engagement:e,isLookingAway:r,analyzeGaze:s,setEngagement:t,setIsLookingAway:i}},Gd=.05,Vd=()=>{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 u=[1,33,263,61,291,10,152];let h=0,f=0;const w=l[33],m=l[263],g=c[33],b=c[263];if(!w||!m||!g||!b)return 0;const _=n(w,m),p=n(g,b);if(_===0||p===0)return 0;for(const F of u){const j=l[F],C=c[F];if(j&&C){const M=w.x+(C.x-g.x)*_/p,B=w.y+(C.y-g.y)*_/p;h+=n(j,{x:M,y:B}),f++}}return f===0?0:h/f},[n]),a=d.useCallback((c,l,u,h)=>{if(!c.faceLandmarks||c.faceLandmarks.length===0)return l?(h("Reference face not detected."),i(!0),t(!1)):i(!1),null;if(l&&u){let f=null,w=0;for(const m of c.faceLandmarks)s(m,u)<Gd&&(f=m,w++);return w===1?(t(!1),i(!1),h("Reference face tracked."),f):w>1?(t(!0),i(!1),h("Multiple matching faces detected. Tracking suspended."),null):(t(!1),i(!0),h("Reference face not detected."),null)}else{c.faceLandmarks.length>1?(t(!0),h("Multiple faces detected. Set reference for single face tracking.")):(t(!1),h("No reference set. Detecting first face."));const f=c.faceLandmarks[0];return!f||f.length<468?null:f}},[s]);return{multipleFacesDetected:e,referenceFaceNotDetected:r,analyzeFace:a,setMultipleFacesDetected:t,setReferenceFaceNotDetected:i}},$d=1e3,Wd=(e,t)=>{const[r,i]=d.useState(!1),[n,s]=d.useState("face_detected"),{incrementGazeViolation:a}=Qs(),{multipleFacesDetected:c,referenceFaceNotDetected:l,isLookingAway:u}=e;d.useEffect(()=>{let w;return(u||c||l)&&t?w=setTimeout(()=>{i(!0),u?(s("looking_away"),a("looking_away")):c?(s("multiple_faces"),a("multiple_faces")):l&&(s("no_face_detected"),a("no_face_detected"))},$d):(i(!1),s("face_detected")),()=>{clearTimeout(w)}},[u,c,l,t,a]);const h=d.useCallback(()=>c?"multiple_faces":l?"no_face_detected":u?"looking_away":"face_detected",[c,l,u]),f=d.useCallback(()=>{i(!1),s("face_detected")},[]);return{showGazeWarningModal:r,faceDetectionState:n,getWarningType:h,closeWarningModal:f,setShowGazeWarningModal:i,setFaceDetectionState:s}};class Z extends Error{constructor(t,r,i=!1){super(t),this.code=r,this.recoverable=i,this.name="STTError"}}class zd{constructor(t={}){Oe(this,"config");Oe(this,"mediaRecorder",null);Oe(this,"audioChunks",[]);Oe(this,"recordingStream",null);Oe(this,"autoStopTimeoutId",null);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...t}}updateConfig(t){this.config={...this.config,...t}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(t,r){var i;if(!this.isRecordingSupported())throw new Z("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new Z("Recording is already in progress","ALREADY_RECORDING",!0);try{this.recordingStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:44100}}),this.audioChunks=[];const n=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:n}),this.mediaRecorder.ondataavailable=s=>{var a;s.data.size>0&&(this.audioChunks.push(s.data),(a=r==null?void 0:r.onDataAvailable)==null||a.call(r,s.data))},this.mediaRecorder.onstop=()=>{var s;(s=r==null?void 0:r.onStop)==null||s.call(r)},this.mediaRecorder.onerror=s=>{var c;const a=new Z(`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(()=>{this.isRecording()&&this.stopRecording()},t*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new Z("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new Z("No microphone found","NO_MICROPHONE",!1)}throw new Z(`Failed to start recording: ${n instanceof Error?n.message:String(n)}`,"START_RECORDING_FAILED",!0)}}async stopRecording(){if(this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||!this.isRecording())throw new Z("No active recording to stop","NO_ACTIVE_RECORDING",!1);return new Promise((t,r)=>{if(!this.mediaRecorder){r(new Z("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const i=this.mediaRecorder,n=()=>{try{const s=i.mimeType||"audio/webm",a=new Blob(this.audioChunks,{type:s});this.cleanup(),t(a)}catch(s){r(new Z(`Failed to create audio blob: ${s instanceof Error?s.message:String(s)}`,"BLOB_CREATION_FAILED",!1))}};i.addEventListener("stop",n,{once:!0}),i.stop()})}async transcribe(t){const{audioBlob:r}=t;if(!r||r.size===0)throw new Z("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 Z("Interview ID is missing from configuration","MISSING_INTERVIEW_ID",!1);const s=await Gt(`${this.config.baseUrl}${$t.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 u=JSON.parse(c);l=u.message||u.error||l}catch{l=c||l}throw new Z(l,`HTTP_${s.status}`,s.status>=500)}return{transcript:(await s.json()).data.transcribed_text??""}}catch(i){throw i instanceof Z?i:new Z(`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"}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.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}}const Ir=new zd,Hd=(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(u=>u.stop())}},[t,r]),d.useEffect(()=>{const s=Ir.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(u=>{u.addEventListener("ended",l)})}},[]),{animationFrameRef:n}},qd=(e,t,r,i,n,s,a,c,l,u,h,f,w,m,g)=>{const b=d.useRef(null),_=d.useCallback(()=>{var j;const p=e.current,A=t.current,F=r.current;if(!p||p.readyState<2||!F||!A){b.current=requestAnimationFrame(_);return}i();try{const C=performance.now(),M=F.detectForVideo(p,C);if(((j=M.faceLandmarks)==null?void 0:j.length)>0){g(!1);const B=n(M,l,u.current,m);B?(s(A,p,B,h,f,w,l),l&&w&&c(B,u.current,w)):a(A,p)}else a(A,p),l?(g(!0),m("Reference face not detected.")):g(!1)}catch(C){console.error("Face detection error:",C)}b.current=requestAnimationFrame(_)},[e,t,r,i,n,s,a,c,l,u,h,f,w,m,g]);return{renderLoop:_,animationFrameRef:b}},Yd=(e,t,r,i)=>{const{referenceSet:n,referenceRef:s,setReferenceData:a}=Qs(),c=d.useRef(s),l=d.useCallback(()=>{c.current=s},[s]),u=d.useCallback(()=>{var w;const h=e.current,f=t.current;if(console.log({faceLandmarker:h,video:f}),!(!h||!f))try{const m=performance.now(),g=h.detectForVideo(f,m);if((w=g.faceLandmarks)!=null&&w[0]){const b=g.faceLandmarks[0],_=b[33],p=b[263],A=b[1];_&&p&&A&&(c.current={x:(_.x+p.x)*.5,y:(_.y+p.y)*.5,noseX:A.x,noseY:A.y},a(!0,c.current),r("Reference set. Gaze tracking active."),console.log("Reference set. Gaze tracking active.",c.current),i&&i())}}catch(m){console.error("Set reference error:",m),r("Failed to set reference")}},[e,t,r,a,i]);return{referenceSet:n,referenceRef:c,setReference:u,syncReference:l}},wl=d.forwardRef(({className:e="",interviewId:t="",interview_duration:r,showProctoringUI:i=!0,onSetReference:n},s)=>{var kl;const{authToken:a}=eo(),c=a?$l(a):null,l=ao(),{borderRadius:u}=nr(),h=u??18,{proctoring:f}=on(),w=!!(f!=null&&f.gazeAnalysisEnabled),[m,g]=d.useState(!1),[b,_]=d.useState((f==null?void 0:f.showLandmarks)??!1),[p,A]=d.useState(i&&((f==null?void 0:f.showEngagementBar)??!0)),[F,j]=d.useState(w),C=d.useRef(null),M=d.useRef(null),B=d.useRef(null),X=d.useCallback(async dt=>{var Zi;const tr=C.current,Et=B.current;if(!tr||!Et)return;const ht=Et.getContext("2d");if(!ht)return;Et.width=tr.videoWidth,Et.height=tr.videoHeight,ht.save(),ht.scale(-1,1),ht.drawImage(tr,-Et.width,0,Et.width,Et.height),ht.restore();const Zr=await new Promise(rr=>Et.toBlob(rr,"image/jpeg"));if(Zr&&t)try{const rr=`${dt}-${Date.now()}.jpeg`,_e=await l.requestScreenshotUploadUrl(t,rr);_e.data&&_e.data.upload_url&&(await l.uploadScreenshot((Zi=_e==null?void 0:_e.data)==null?void 0:Zi.upload_url,Zr),_e.data.asset_id&&await l.confirmScreenshotUpload(_e.data.asset_id))}catch(rr){console.error(`Failed to upload screenshot for ${dt}:`,rr)}},[l,t]),{faceLandmarkerRef:ee,isModelLoaded:ne,statusMessage:Je,setStatusMessage:se,loadingProgress:ct,permissionDenied:Te,clearCache:ve}=Dd(),{fps:_t,updateFPS:lt}=Rd(),{drawWithEngagementBar:pe,clearCanvas:Rt,engagementRef:oe}=Od(),{engagement:we,isLookingAway:W,analyzeGaze:Ze,setEngagement:kt,setIsLookingAway:T}=Ud(),{multipleFacesDetected:ae,referenceFaceNotDetected:Ot,analyzeFace:Zt,setMultipleFacesDetected:Bt,setReferenceFaceNotDetected:er}=Vd(),{referenceSet:Jr,referenceRef:Ji,setReference:N,syncReference:je}=Yd(ee,C,se,n),ut={multipleFacesDetected:ae,referenceFaceNotDetected:Ot,isLookingAway:W},{showGazeWarningModal:yl,getWarningType:Nh,closeWarningModal:bl,setShowGazeWarningModal:vl,setFaceDetectionState:_l}=Wd(ut,w),{renderLoop:Ch}=qd(C,M,ee,lt,Zt,pe,Rt,Ze,Jr,Ji,b,p,w,se,er);Hd(C,ne,Ch,se),d.useEffect(()=>{je()},[je]),d.useEffect(()=>{oe&&oe.current&&(oe.current.value=we,oe.current.isLookingAway=W)},[we,W,oe]);const Ih=d.useCallback(dt=>{j(dt),dt||(kt(100),T(!1))},[kt,T]),Mh=d.useCallback(()=>{T(!1),Bt(!1),er(!1),_l("face_detected"),vl(!1),bl()},[T,Bt,er,_l,vl,bl]),Lh={engagement:we,fps:_t,isLookingAway:W,multipleFacesDetected:ae,referenceFaceNotDetected:Ot};return d.useEffect(()=>{let dt=null;const tr=[];return(async()=>{try{dt=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1}),C.current&&(C.current.srcObject=dt);const Zr=(r??ti)*60*1e3/3,Zi=[0,1,2].map((_e,Ut)=>({label:`capture-${Ut+1}`,start:Ut*Zr,end:(Ut+1)*Zr})),rr=(_e,Ut)=>_e===Ut?_e:Math.random()*(Ut-_e)+_e;Zi.forEach(({label:_e,start:Ut,end:Fh},Ph)=>{let Hs;Ph===0?Hs=3e3:Hs=rr(Ut,Fh),tr.push(setTimeout(()=>{X(_e)},Hs))})}catch(ht){console.error("Error accessing camera:",ht)}})(),()=>{dt&&dt.getTracks().forEach(ht=>ht.stop()),tr.forEach(clearTimeout)}},[X]),d.useImperativeHandle(s,()=>({setReference:()=>{N()}}),[N]),o.jsxs("div",{className:`iw-relative iw-h-full ${e}`,children:[Te?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-flex-wrap iw-gap-5",children:o.jsxs("div",{className:"iw-relative iw-flex-1",children:[o.jsx("video",{ref:C,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover iw-scale-75 iw-rounded-r-xl iw-min-h-[200px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)"}}),w&&o.jsx("canvas",{ref:M,width:420,height:240,className:"iw-absolute iw-top-0 iw-left-0 iw-w-full iw-h-full iw-object-cover iw-scale-75 iw-rounded-r-xl iw-min-h-[200px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)",borderRadius:h}}),o.jsx("canvas",{ref:B,style:{display:"none"}}),i&&o.jsxs("div",{className:"iw-absolute iw-top-4 iw-left-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-black/40 iw-px-4 iw-py-2 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-white",children:"Recording"})]}),i&&((kl=c==null?void 0:c.data)==null?void 0:kl.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-black/40 iw-px-4 iw-py-2 iw-backdrop-blur-md",children:o.jsx("span",{className:"iw-font-medium iw-text-white",children:c.data.user_name})}),i&&o.jsx("div",{className:"iw-absolute iw-bottom-4 iw-right-4",children:o.jsx(cu,{showControls:(f==null?void 0:f.showControls)??!1,isBubbleOpen:m,setIsBubbleOpen:g,setReference:N,clearCache:ve,isModelLoaded:ne,gazeAnalysisEnabled:F&&w,referenceSet:Jr,showLandmarks:b,setShowLandmarks:_,showEngagementBar:p,setShowEngagementBar:A,handleToggleGazeAnalysis:Ih,stats:Lh,statusMessage:Je,loadingProgress:ct})})]})}),w&&yl&&o.jsx(ou,{isOpen:yl,onClose:Mh,warningType:Nh()})]})}),Kd=["Do not refresh or reload the page during your assessment","Refrain from switching tabs or opening other applications while the session is in progress","Ensure your face remains clearly visible on camera at all times","Avoid frequent distractions or leaving your seat during the session","Do not disable or interfere with audio/video monitoring"],Xd=({isOpen:e,onStart:t,onClose:r,gazeEnabled:i=!1,videoFeedRef:n,interviewId:s="",interview_duration:a=ti})=>{var kt;const c=d.useRef(null),l=d.useRef(null),{baseColor:u,borderRadius:h}=nr(),[f,w]=d.useState(!1),[m,g]=d.useState(!1),[b,_]=d.useState(!1),[p,A]=d.useState(!1),[F,j]=d.useState(!1),[C,M]=d.useState(null),[B,X]=d.useState(!1),ee=d.useRef(null),ne=d.useRef(null),Je=T=>{ee.current=T,n&&(typeof n=="function"?n(T):n.current=T)},se=u??"#2563eb",ct=no(se),Te=h??18,ve=(T,ae)=>T.startsWith("#")&&T.length===7?`${T}${ae}`:T,_t=[`radial-gradient(120% 85% at 50% 125%, ${ve(se,"34")} 0%, transparent 70%)`,`radial-gradient(90% 70% at 10% 130%, ${ve(se,"24")} 0%, transparent 72%)`,`radial-gradient(90% 70% at 90% 130%, ${ve(se,"24")} 0%, transparent 72%)`,`repeating-linear-gradient(135deg, ${ve(se,"14")} 0, ${ve(se,"14")} 16px, transparent 16px, transparent 32px)`].join(", "),lt=f?{label:"Camera & microphone ready",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-emerald-400"}:B?{label:"Checking device access…",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-amber-300"}:{label:"Allow access to continue",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-rose-300"},pe=f?{badge:"Ready",toneClass:"iw-bg-emerald-50 iw-text-emerald-600",cameraCopy:"Framing looks good for identity verification.",micCopy:"We can hear you clearly for your responses."}:B?{badge:"Checking",toneClass:"iw-bg-amber-50 iw-text-amber-600",cameraCopy:"Hang tight while we confirm camera access.",micCopy:"Listening for microphone permission from your browser."}:{badge:"Action needed",toneClass:"iw-bg-rose-50 iw-text-rose-600",cameraCopy:"Grant camera access to continue with the interview.",micCopy:"Enable microphone access so we can capture your answers."},Rt=[{label:"Camera feed",description:pe.cameraCopy,status:pe.badge,toneClass:pe.toneClass,Icon:oo},{label:"Microphone input",description:pe.micCopy,status:pe.badge,toneClass:pe.toneClass,Icon:zl}],oe=()=>{l.current&&(l.current.getTracks().forEach(T=>T.stop()),l.current=null)},we=async()=>{X(!0),M(null);try{const T=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:!0});l.current=T,c.current&&(c.current.srcObject=T),w(!0)}catch(T){console.error("Media permission error:",T);let ae="Unable to access camera or microphone.";(T==null?void 0:T.name)==="NotAllowedError"?ae="Permissions denied. Please allow access to camera and microphone.":(T==null?void 0:T.name)==="NotFoundError"?ae="No camera/microphone found. Please connect a device and retry.":T!=null&&T.message&&(ae=T.message),w(!1),M(ae)}finally{X(!1)}};if(d.useEffect(()=>{if(!e){oe();return}return we(),()=>oe()},[e]),d.useEffect(()=>()=>{ne.current&&(clearInterval(ne.current),ne.current=null)},[]),!e)return null;const W=()=>{i?_(!0):(t(),oe())},Ze=async()=>{A(!0);const T=()=>{var ae;return(ae=ee.current)==null?void 0:ae.setReference()};T(),ne.current&&clearInterval(ne.current),ne.current=setInterval(T,500)};return o.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-gray-900/25 iw-backdrop-blur-md iw-p-4",children:[o.jsxs("div",{className:" iw-w-full iw-max-w-[920px] iw-max-h-[96vh] iw-overflow-auto iw-rounded-3xl iw-bg-white iw-shadow-[0_40px_80px_-28px_rgba(15,23,42,0.25)]",children:[o.jsxs("div",{className:"iw-relative iw-overflow-hidden",style:{background:ct},children:[o.jsx("div",{"aria-hidden":!0,className:"iw-absolute iw-pointer-events-none",style:{top:-90,right:-100,width:240,height:240,background:"radial-gradient(circle, rgba(255,255,255,0.6), transparent 70%)",filter:"blur(12px)"}}),o.jsx("div",{"aria-hidden":!0,className:"iw-absolute iw-pointer-events-none",style:{bottom:-110,left:-60,width:220,height:220,background:"radial-gradient(circle, rgba(255,255,255,0.35), transparent 70%)",filter:"blur(14px)"}}),o.jsxs("div",{className:"iw-relative iw-grid md:iw-grid-cols-[minmax(0,1fr)_auto] iw-items-start iw-gap-6 iw-px-6 iw-py-7",children:[o.jsx("div",{className:"iw-flex iw-flex-col iw-gap-4 iw-text-white",children:o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-12 iw-w-12 iw-items-center iw-justify-center iw-rounded-2xl iw-bg-white/15 iw-shadow-inner",children:o.jsx(so,{className:"iw-h-6 iw-w-6"})}),o.jsxs("div",{children:[o.jsx("p",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-white/70",children:"Pre-interview checklist"}),o.jsx("h2",{className:"iw-mt-1 iw-text-xl iw-font-semibold iw-leading-tight",children:"Final checks before you go live"}),o.jsx("p",{className:"iw-mt-2 iw-text-sm iw-text-white/80",children:"Align your space, confirm device access, and step confidently into your secure session."})]})]})}),o.jsx("div",{className:"iw-flex iw-items-start iw-justify-end",children:o.jsxs("div",{className:`iw-inline-flex iw-items-center iw-gap-2 iw-rounded-full iw-bg-white/10 iw-px-4 iw-py-1.5 iw-text-xs iw-font-medium iw-text-white/85 iw-backdrop-blur-sm ${lt.toneClass}`,children:[o.jsx("span",{className:`iw-inline-flex iw-h-2 iw-w-2 iw-rounded-full ${lt.dotClass}`}),lt.label]})}),r&&o.jsx("button",{"aria-label":"Close",className:"iw-absolute iw-top-5 iw-right-5 iw-text-white/70 transition-colors hover:iw-text-white",onClick:()=>{oe(),r==null||r()},children:"✕"})]})]}),o.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-px-6 iw-pb-8 iw-pt-6",children:[o.jsxs("div",{className:"iw-grid xl:iw-grid-cols-[0.95fr_1.05fr] iw-gap-6",children:[o.jsx("section",{className:"iw-flex iw-flex-col iw-gap-5",children:o.jsxs("div",{className:"iw-rounded-2xl iw-border iw-border-slate-100 iw-bg-white iw-p-5 iw-shadow-sm",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[o.jsx("h3",{className:"iw-text-sm iw-font-semibold iw-text-slate-900",children:"Proctoring guidelines"}),o.jsx("span",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-slate-400",children:"Required"})]}),o.jsx("ul",{className:"iw-mt-5 iw-flex iw-flex-col iw-gap-4",children:Kd.map((T,ae)=>o.jsx("li",{className:"iw-group iw-overflow-hidden iw-rounded-xl iw-border iw-border-slate-100 iw-bg-slate-50/60 iw-p-4 iw-transition-all hover:iw-border-slate-200 hover:iw-bg-white",children:o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[o.jsx("span",{className:"iw-flex iw-h-8 iw-w-8 iw-flex-none iw-items-center iw-justify-center iw-rounded-full iw-text-sm iw-font-semibold iw-text-white",style:{background:ct},children:ae+1}),o.jsx("span",{className:"iw-text-sm iw-text-slate-600",children:T})]})},T))})]})}),o.jsxs("section",{className:"iw-flex iw-flex-col iw-gap-5",children:[o.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-overflow-hidden iw-rounded-3xl iw-bg-white ",style:{borderRadius:Te},children:[o.jsx("div",{className:"iw-relative iw-z-10 iw-rounded-2xl iw-border iw-border-slate-200 iw-bg-slate-50/80 iw-p-3",children:i&&(F||p)?o.jsx(wl,{ref:Je,interviewId:s,interview_duration:a,showProctoringUI:!1,onSetReference:()=>{ne.current&&(clearInterval(ne.current),ne.current=null),A(!1),t()}}):o.jsx("video",{ref:c,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-h-64 iw-w-full iw-rounded-2xl iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:Te}})}),o.jsx("div",{className:"iw-relative iw-grid iw-grid-cols-2 iw-gap-4 iw-px-1",children:!b&&!F?o.jsxs(o.Fragment,{children:[o.jsx(ro,{onClick:we,disabled:B,variant:"outline",size:"sm",className:"iw-font-medium",style:{borderColor:se,borderRadius:Te,color:se},children:f?"Recheck permissions":"Enable camera & mic"}),o.jsx(qe,{onClick:W,disabled:!f,className:"iw-h-10 iw-px-6 iw-text-sm",style:{backgroundColor:se},children:"Proceed"})]}):i&&(b&&!F?o.jsx(qe,{onClick:()=>g(!0),disabled:!f,className:"iw-h-10 iw-px-6 iw-text-sm iw-col-span-2",style:{backgroundColor:se},children:"Calibrate Face Position"}):o.jsxs(qe,{onClick:Ze,disabled:p||!f,className:"iw-h-10 iw-px-6 iw-text-sm iw-col-span-2",style:{backgroundColor:se},children:[p?"Calibrating":"Start Calibration",p&&o.jsx("span",{className:"iw-ml-2 iw-animate-spin iw-inline-block iw-border-2 iw-border-t-transparent iw-border-stone-200 iw-size-4 iw-rounded-full","aria-label":"loading"})]}))})]}),i&&F?o.jsxs("span",{className:"iw-text-slate-700 iw-text-center iw-text-md",children:["Sit upright and look directly into the camera, then press the",o.jsx("span",{className:"iw-font-semibold",children:" Start Calibration "}),"button. Proper calibration is required and incorrect setup may affect your assessment."]}):o.jsx("ul",{className:"iw-grid sm:iw-grid-cols-1 iw-gap-3",children:Rt.map(({Icon:T,label:ae,description:Ot,status:Zt,toneClass:Bt})=>o.jsx("li",{className:"iw-rounded-2xl iw-border iw-border-slate-200/65 iw-bg-white iw-p-4 iw-shadow-sm iw-transition-all hover:iw-border-slate-200",children:o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[o.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-none iw-items-center iw-justify-center iw-rounded-xl iw-bg-slate-100",children:o.jsx(T,{className:"iw-h-5 iw-w-5 iw-text-slate-600"})}),o.jsxs("div",{className:"iw-flex-1",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-gap-3",children:[o.jsx("p",{className:"iw-text-sm iw-font-medium iw-text-slate-800",children:ae}),o.jsx("span",{className:`iw-rounded-full iw-px-3 iw-py-1 iw-text-[11px] iw-font-semibold ${Bt}`,children:Zt})]}),o.jsx("p",{className:"iw-mt-1.5 iw-text-xs iw-text-slate-500",children:Ot})]})]})},ae))}),C&&o.jsx("div",{className:"iw-rounded-lg iw-border iw-border-rose-200 iw-bg-rose-50 iw-px-3 iw-py-2 iw-text-xs iw-text-rose-600",children:C}),!((kt=navigator.mediaDevices)!=null&&kt.getUserMedia)&&o.jsx("div",{className:"iw-rounded-lg iw-border iw-border-amber-200 iw-bg-amber-50 iw-px-3 iw-py-2 iw-text-xs iw-text-amber-700",children:"Your browser does not support media devices. Please use a modern browser like Chrome, Edge, or Firefox."})]})]}),o.jsx("div",{className:" iw-rounded-2xl iw-border iw-border-dashed iw-border-slate-200 iw-bg-slate-50/85 iw-px-5 iw-py-4 iw-text-center",children:o.jsx("div",{className:"iw-text-xs iw-text-slate-500",children:"Your session is monitored to protect exam integrity. Continuing confirms you have reviewed and accept these safeguards."})}),o.jsx("div",{"aria-hidden":!0,className:"iw-pointer-events-none iw-absolute iw-inset-x-0 iw-bottom-1 iw-h-20",style:{backgroundImage:_t,backgroundSize:"100% 120%, 100% 120%, 100% 120%, 32px 32px",backgroundPosition:"center bottom, left 95% bottom, right 95% bottom, center bottom",backgroundRepeat:"no-repeat, no-repeat, no-repeat, repeat",opacity:.9,transform:"translateY(4px)",maskImage:"linear-gradient(to top, rgba(0,0,0,0.92), transparent)",WebkitMaskImage:"linear-gradient(to top, rgba(0,0,0,0.92), transparent)"}})]})]}),o.jsx(Yl,{isOpen:m,onDecline:()=>g(!1),onContinue:()=>{g(!1),oe(),j(!0)}})]})};var ie=(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))(ie||{});const Qd={thinkingDuration:30,answeringDuration:120,editingDuration:30},Jd={idle:{next:"fetching_question"},fetching_question:{next:"reading_question"},reading_question:{next:"thinking"},thinking:{next:"answering",duration:30},answering:{next:"transcribing",duration:120},transcribing:{next:"editing"},editing:{next:"submitting",duration:30},submitting:{next:"completed"},completed:{next:"completed"}};class Zd{constructor(t={},r={}){Oe(this,"config");Oe(this,"state");Oe(this,"phaseIntervalId",null);Oe(this,"globalIntervalId",null);Oe(this,"callbacks");this.config={...Qd,...t},this.callbacks=r,this.state={phase:"idle",currentPhaseTimeRemaining:0,totalTimeElapsed:0,currentQuestionNumber:0}}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,r=Jd[t];if(!r)return;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()}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 eh(e={}){const{config:t={},callbacks:r={}}=e,i=d.useRef(null);i.current||(i.current=new Zd(t,{}));const n=i.current,[s,a]=d.useState(n.getState()),c=d.useCallback(()=>{a(n.getState())},[n]);d.useEffect(()=>{const f={onPhaseChange:(w,m)=>{var g;c(),(g=r.onPhaseChange)==null||g.call(r,w,m)},onTick:w=>{var m;c(),(m=r.onTick)==null||m.call(r,w)},onInterviewEnd:()=>{var w;c(),(w=r.onInterviewEnd)==null||w.call(r)}};n.callbacks=f},[n,r,c]),d.useEffect(()=>()=>{n.destroy()},[n]);const l=d.useCallback(()=>{n.startQuestion(),c()},[n,c]),u=d.useCallback(()=>{n.nextPhase(),c()},[n,c]),h=d.useCallback(()=>{n.completeInterview(),c()},[n,c]);return{state:s,startQuestion:l,nextPhase:u,completeInterview:h,timerService:n}}function th(e,t={}){const[r,i]=d.useState({data:null,loading:!1,error:null}),n=d.useCallback(async(...s)=>{var a,c,l,u;i(h=>({...h,loading:!0,error:null}));try{const h=await e(...s);i(f=>({...f,data:h,loading:!1,error:null})),(a=t.onSuccess)==null||a.call(t,h),(c=t.onSettled)==null||c.call(t,h,null)}catch(h){const f=h.type?h:{type:"unknown",message:h.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:h};i(w=>({...w,loading:!1,error:f})),(l=t.onError)==null||l.call(t,f),(u=t.onSettled)==null||u.call(t,null,f)}},[e,t]);return{...r,execute:n}}const rh=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 m=>{var g;try{if(!a())throw new Error("Fullscreen is not supported in this environment");m.requestFullscreen?await m.requestFullscreen():m.webkitRequestFullscreen?await m.webkitRequestFullscreen():m.mozRequestFullScreen?await m.mozRequestFullScreen():m.msRequestFullscreen&&await m.msRequestFullscreen()}catch(b){const _={name:"FullscreenError",message:b instanceof Error?b.message:"Failed to enter fullscreen"};r(_),(g=e==null?void 0:e.onError)==null||g.call(e,_)}},u=async()=>{var m;try{s.exitFullscreen?await s.exitFullscreen():s.webkitExitFullscreen?await s.webkitExitFullscreen():s.mozCancelFullScreen?await s.mozCancelFullScreen():s.msExitFullscreen&&await s.msExitFullscreen()}catch(g){const b={name:"FullscreenError",message:g instanceof Error?g.message:"Failed to exit fullscreen"};r(b),(m=e==null?void 0:e.onError)==null||m.call(e,b)}},h=d.useCallback(()=>{var g;const m=!!c();n(m),(g=e==null?void 0:e.onFullScreenChange)==null||g.call(e,m)},[e]);d.useEffect(()=>{const m=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return m.forEach(g=>{document.addEventListener(g,h)}),()=>{m.forEach(g=>{document.removeEventListener(g,h)})}},[h]);const f=async m=>{r(null);const g=m??document.documentElement;await l(g)};return{isFullScreen:i,toggleFullScreen:async m=>{i?await u():await f(m)},enterFullScreen:f,exitFullScreen:u,error:t}},ih=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])},nh=(e={})=>{const[t,r]=d.useState(!1),[i,n]=d.useState(!1),[s,a]=d.useState(null),[c,l]=d.useState(null),[u,h]=d.useState(null);e.config&&Ir.updateConfig(e.config);const f=d.useCallback(async b=>{var _;try{l(null),a(null),h(null),await Ir.startRecording(b,{onStart:()=>{var p;r(!0),(p=e.onStart)==null||p.call(e)},onStop:()=>{var p;r(!1),(p=e.onStop)==null||p.call(e)},onError:p=>{var F;const A=p instanceof Z?p:new Z(p.message,"RECORDING_ERROR",!0);l(A),r(!1),(F=e.onError)==null||F.call(e,A)}})}catch(p){const A=p instanceof Z?p:new Z(p instanceof Error?p.message:String(p),"START_FAILED",!1);throw l(A),r(!1),(_=e.onError)==null||_.call(e,A),A}},[]),w=d.useCallback(async()=>{var b,_;try{const p=await Ir.stopRecording();return h(p),r(!1),(b=e.onStop)==null||b.call(e),p}catch(p){const A=p instanceof Z?p:new Z(p instanceof Error?p.message:String(p),"STOP_FAILED",!1);throw l(A),r(!1),(_=e.onError)==null||_.call(e,A),A}},[]),m=d.useCallback(async(b,_={})=>{var p,A;try{l(null),n(!0);const F={audioBlob:b,..._},j=await Ir.transcribe(F);return a(j.transcript),n(!1),(p=e.onTranscriptionComplete)==null||p.call(e,j),j}catch(F){const j=F instanceof Z?F:new Z(F instanceof Error?F.message:String(F),"TRANSCRIPTION_FAILED",!0);throw l(j),n(!1),(A=e.onError)==null||A.call(e,j),j}},[]),g=d.useCallback(()=>{Ir.cancelRecording(),r(!1),h(null)},[]);return{startRecording:f,stopRecording:w,transcribe:m,cancelRecording:g,isRecording:t,isTranscribing:i,transcript:s,error:c,audioBlob:u}},sh=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])},oh=()=>{d.useEffect(()=>{const e=document.createElement("style");return e.textContent=`
23
+ }`,e.VERTEX_SHADER),this.Y=Oc(this,this.G(),e.FRAGMENT_SHADER),e.linkProgram(this.h),!e.getProgramParameter(this.h,e.LINK_STATUS))throw Error(`Error during program linking: ${e.getProgramInfoLog(this.h)}`);this.P=e.getAttribLocation(this.h,"aVertex"),this.J=e.getAttribLocation(this.h,"aTex")}C(){}l(){}close(){if(this.h){const e=this.g;e.deleteProgram(this.h),e.deleteShader(this.Z),e.deleteShader(this.Y)}this.A&&this.g.deleteFramebuffer(this.A),this.v&&this.v.close(),this.s&&this.s.close()}};function _t(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 Is(e){var t=_t(e,1);if(!t){if(t=_t(e,0))t=new Float32Array(t).map(i=>i/255);else{t=new Float32Array(e.width*e.height);const i=Sr(e);var r=Ms(e);if($i(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=_t(e,2);if(!t){const r=Sr(e);t=Vc(e);const i=Is(e),n=Gc(e);r.texImage2D(r.TEXTURE_2D,0,n,e.width,e.height,0,r.RED,r.FLOAT,i),Ls(e)}return t}function Sr(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=vt(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Gc(e){if(e=Sr(e),!Wi)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Wi=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Wi=e.R16F}return Wi}function Ms(e){return e.l||(e.l=new Cs),e.l}function Vc(e){const t=Sr(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=_t(e,2);return r||(r=Vi(Ms(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Ls(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Wi,he=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&&--$c===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Da(){return!!_t(this,0)}ja(){return!!_t(this,1)}R(){return!!_t(this,2)}ia(){return(t=_t(e=this,0))||(t=Is(e),t=new Uint8Array(t.map(r=>255*r)),e.g.push(t)),t;var e,t}ha(){return Is(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=Sr(this),n=Ms(this);i.activeTexture(i.TEXTURE1),r=Vi(n,i,this.m?i.LINEAR:i.NEAREST),i.bindTexture(i.TEXTURE_2D,r);const s=Gc(this);i.texImage2D(i.TEXTURE_2D,0,s,this.width,this.height,0,i.RED,i.FLOAT,null),i.bindTexture(i.TEXTURE_2D,null),$i(n,i,r),js(n,i,!1,()=>{Vc(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),Ls(this)}),Ns(n),Ls(this)}}e.push(r)}return new he(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Sr(this).deleteTexture(_t(this,2)),$c=-1}};he.prototype.close=he.prototype.close,he.prototype.clone=he.prototype.clone,he.prototype.getAsWebGLTexture=he.prototype.N,he.prototype.getAsFloat32Array=he.prototype.ha,he.prototype.getAsUint8Array=he.prototype.ia,he.prototype.hasWebGLTexture=he.prototype.R,he.prototype.hasFloat32Array=he.prototype.ja,he.prototype.hasUint8Array=he.prototype.Da;var $c=250;function at(e,t){switch(t){case 0:return e.g.find(r=>r instanceof ImageData);case 1:return e.g.find(r=>typeof ImageBitmap<"u"&&r instanceof ImageBitmap);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function Wc(e){var t=at(e,0);if(!t){t=Ar(e);const r=Hi(e),i=new Uint8Array(e.width*e.height*4);$i(r,t,zi(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,i),Ns(r),t=new ImageData(new Uint8ClampedArray(i.buffer),e.width,e.height),e.g.push(t)}return t}function zi(e){let t=at(e,2);if(!t){const r=Ar(e);t=qi(e);const i=at(e,1)||Wc(e);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,i),Xr(e)}return t}function Ar(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=vt(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Hi(e){return e.l||(e.l=new Cs),e.l}function qi(e){const t=Ar(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=at(e,2);return r||(r=Vi(Hi(e),t),e.g.push(r),e.m=!0),t.bindTexture(t.TEXTURE_2D,r),r}function Xr(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function zc(e){const t=Ar(e);return js(Hi(e),t,!0,()=>function(r,i){const n=r.canvas;if(n.width===r.width&&n.height===r.height)return i();const s=n.width,a=n.height;return n.width=r.width,n.height=r.height,r=i(),n.width=s,n.height=a,r}(e,()=>{if(t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),!(e.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return e.canvas.transferToImageBitmap()}))}var fe=class{constructor(e,t,r,i,n,s,a){this.g=e,this.j=t,this.m=r,this.canvas=i,this.l=n,this.width=s,this.height=a,(this.j||this.m)&&--Hc===0&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Ca(){return!!at(this,0)}ka(){return!!at(this,1)}R(){return!!at(this,2)}Aa(){return Wc(this)}za(){var e=at(this,1);return e||(zi(this),qi(this),e=zc(this),Xr(this),this.g.push(e),this.j=!0),e}N(){return zi(this)}clone(){const e=[];for(const t of this.g){let r;if(t instanceof ImageData)r=new ImageData(t.data,this.width,this.height);else if(t instanceof WebGLTexture){const i=Ar(this),n=Hi(this);i.activeTexture(i.TEXTURE1),r=Vi(n,i),i.bindTexture(i.TEXTURE_2D,r),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.bindTexture(i.TEXTURE_2D,null),$i(n,i,r),js(n,i,!1,()=>{qi(this),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLE_FAN,0,4),Xr(this)}),Ns(n),Xr(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);zi(this),qi(this),r=zc(this),Xr(this)}e.push(r)}return new fe(e,this.ka(),this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&at(this,1).close(),this.m&&Ar(this).deleteTexture(at(this,2)),Hc=-1}};fe.prototype.close=fe.prototype.close,fe.prototype.clone=fe.prototype.clone,fe.prototype.getAsWebGLTexture=fe.prototype.N,fe.prototype.getAsImageBitmap=fe.prototype.za,fe.prototype.getAsImageData=fe.prototype.Aa,fe.prototype.hasWebGLTexture=fe.prototype.R,fe.prototype.hasImageBitmap=fe.prototype.ka,fe.prototype.hasImageData=fe.prototype.Ca;var Hc=250;function tt(...e){return e.map(([t,r])=>({start:t,end:r}))}const Ld=function(e){return class extends e{Ha(){this.i._registerModelResourcesGraphService()}}}((qc=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:Mc()?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?'),E(this,i||"input_audio",s=>{E(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){ot(this,"__graph_config__",t=>{e(t)}),E(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),E(this,i,a=>{this.i._addAudioToInputStream(this.g,t,r,a,n)})}addGpuBufferToStream(e,t,r){E(this,t,i=>{const[n,s]=Pc(this,e,i);this.i._addBoundTextureToStream(i,n,s,r)})}addBoolToStream(e,t,r){E(this,t,i=>{this.i._addBoolToInputStream(e,i,r)})}addDoubleToStream(e,t,r){E(this,t,i=>{this.i._addDoubleToInputStream(e,i,r)})}addFloatToStream(e,t,r){E(this,t,i=>{this.i._addFloatToInputStream(e,i,r)})}addIntToStream(e,t,r){E(this,t,i=>{this.i._addIntToInputStream(e,i,r)})}addUintToStream(e,t,r){E(this,t,i=>{this.i._addUintToInputStream(e,i,r)})}addStringToStream(e,t,r){E(this,t,i=>{E(this,e,n=>{this.i._addStringToInputStream(n,i,r)})})}addStringRecordToStream(e,t,r){E(this,t,i=>{Dc(this,Object.keys(e),n=>{Dc(this,Object.values(e),s=>{this.i._addFlatHashMapToInputStream(n,s,Object.keys(e).length,i,r)})})})}addProtoToStream(e,t,r,i){E(this,r,n=>{E(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){E(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){E(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){E(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){E(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){E(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){E(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){E(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)E(this,s,a=>{this.i._addStringVectorEntry(n,a)});this.i._addStringVectorToInputStream(n,i,r)})}addBoolToInputSidePacket(e,t){E(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){E(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){E(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){E(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){E(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){E(this,t,r=>{E(this,e,i=>{this.i._addStringToInputSidePacket(i,r)})})}addProtoToInputSidePacket(e,t,r){E(this,r,i=>{E(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){E(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){E(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){E(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){E(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){E(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){E(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)E(this,n,s=>{this.i._addStringVectorEntry(i,s)});this.i._addStringVectorToInputSidePacket(i,r)})}attachBoolListener(e,t){ot(this,e,t),E(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){Pt(this,e,t),E(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){ot(this,e,t),E(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){Pt(this,e,t),E(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){ot(this,e,t),E(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){Pt(this,e,t),E(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){ot(this,e,t),E(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){Pt(this,e,t),E(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){ot(this,e,t),E(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){Pt(this,e,t),E(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){ot(this,e,t),E(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){Pt(this,e,t),E(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){ot(this,e,t),E(this,e,i=>{this.i._attachProtoListener(i,r||!1)})}attachProtoVectorListener(e,t,r){Pt(this,e,t),E(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?'),ot(this,e,(i,n)=>{i=new Float32Array(i.buffer,i.byteOffset,i.length/4),t(i,n)}),E(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 qc{get ea(){return this.i}oa(e,t,r){E(this,t,i=>{const[n,s]=Pc(this,e,i);this.ea._addBoundTextureAsImageToStream(i,n,s,r)})}V(e,t){ot(this,e,t),E(this,e,r=>{this.ea._attachImageListener(r)})}ba(e,t){Pt(this,e,t),E(this,e,r=>{this.ea._attachImageVectorListener(r)})}}));var qc,Ve=class extends Ld{};async function I(e,t,r){return async function(i,n,s,a){return Id(i,n,s,a)}(e,r.canvas??(Mc()?void 0:document.createElement("canvas")),t,r)}function Yc(e,t,r,i){if(e.U){const s=new ec;if(r!=null&&r.regionOfInterest){if(!e.na)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].");v(s,1,(n.left+n.right)/2),v(s,2,(n.top+n.bottom)/2),v(s,4,n.right-n.left),v(s,3,n.bottom-n.top)}else v(s,1,.5),v(s,2,.5),v(s,4,1),v(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(v(s,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[a,c]=Fc(t);r=ie(s,3)*c/a,n=ie(s,4)*a/c,v(s,4,r),v(s,3,n)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,i)}e.g.oa(t,e.Z,i??performance.now()),e.finishProcessing()}function $e(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'.");Yc(e,t,r,e.B+1)}function ct(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'.");Yc(e,t,r,i)}function Tr(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 he([n],r,!1,e.g.i.canvas,e.P,s,t),i?e.clone():e}var Se=class extends As{constructor(e,t,r,i){super(e),this.g=e,this.Z=t,this.U=r,this.na=i,this.P=new Cs}l(e,t=!0){if("runningMode"in e&&$r(this.baseOptions,2,!!e.runningMode&&e.runningMode!=="IMAGE"),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Se.prototype.close=Se.prototype.close;var We=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},S(e=this.h=new Ri,0,1,t=new q),v(this.h,2,.5),v(this.h,3,.3)}get baseOptions(){return P(this.h,q,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&v(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&v(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}D(e,t){return this.j={detections:[]},$e(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},ct(this,e,r,t),this.j}m(){var e=new Ee;z(e,"image_in"),z(e,"norm_rect_in"),D(e,"detections");const t=new Ie;Je(t,pd,this.h);const r=new ye;Me(r,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),W(r,"IMAGE:image_in"),W(r,"NORM_RECT:norm_rect_in"),L(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Qa(s),this.j.detections.push(jc(i));x(this,n)}),this.g.attachEmptyPacketListener("detections",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};We.prototype.detectForVideo=We.prototype.F,We.prototype.detect=We.prototype.D,We.prototype.setOptions=We.prototype.o,We.createFromModelPath=async function(e,t){return I(We,e,{baseOptions:{modelAssetPath:t}})},We.createFromModelBuffer=function(e,t){return I(We,e,{baseOptions:{modelAssetBuffer:t}})},We.createFromOptions=function(e,t){return I(We,e,t)};var Fs=tt([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]),Ps=tt([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]),Ds=tt([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Kc=tt([474,475],[475,476],[476,477],[477,474]),Rs=tt([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]),Os=tt([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Xc=tt([469,470],[470,471],[471,472],[472,469]),Bs=tt([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=[...Fs,...Ps,...Ds,...Rs,...Os,...Bs],Jc=tt([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 Zc(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var X=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,S(e=this.h=new cc,0,1,t=new q),this.v=new ac,S(this.h,0,3,this.v),this.s=new Ri,S(this.h,0,2,this.s),st(this.s,4,1),v(this.s,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return P(this.h,q,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return"numFaces"in e&&st(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&v(this.v,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}D(e,t){return Zc(this),$e(this,e,t),this.j}F(e,t,r){return Zc(this),ct(this,e,r,t),this.j}m(){var e=new Ee;z(e,"image_in"),z(e,"norm_rect"),D(e,"face_landmarks");const t=new Ie;Je(t,yd,this.h);const r=new ye;Me(r,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),W(r,"IMAGE:image_in"),W(r,"NORM_RECT:norm_rect"),L(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("face_landmarks",(i,n)=>{for(const s of i)i=qr(s),this.j.faceLandmarks.push(Oi(i));x(this,n)}),this.g.attachEmptyPacketListener("face_landmarks",i=>{x(this,i)}),this.outputFaceBlendshapes&&(D(e,"blendshapes"),L(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(i,n)=>{if(this.outputFaceBlendshapes)for(const s of i)i=Fi(s),this.j.faceBlendshapes.push(Es(i.g()??[]));x(this,n)}),this.g.attachEmptyPacketListener("blendshapes",i=>{x(this,i)})),this.outputFacialTransformationMatrixes&&(D(e,"face_geometry"),L(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(i,n)=>{if(this.outputFacialTransformationMatrixes)for(const s of i)(i=P(xd(s),ld,2))&&this.j.facialTransformationMatrixes.push({rows:Ue(i,1)??0??0,columns:Ue(i,2)??0??0,data:qt(i,3,jt,Ht()).slice()??[]});x(this,n)}),this.g.attachEmptyPacketListener("face_geometry",i=>{x(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};X.prototype.detectForVideo=X.prototype.F,X.prototype.detect=X.prototype.D,X.prototype.setOptions=X.prototype.o,X.createFromModelPath=function(e,t){return I(X,e,{baseOptions:{modelAssetPath:t}})},X.createFromModelBuffer=function(e,t){return I(X,e,{baseOptions:{modelAssetBuffer:t}})},X.createFromOptions=function(e,t){return I(X,e,t)},X.FACE_LANDMARKS_LIPS=Fs,X.FACE_LANDMARKS_LEFT_EYE=Ps,X.FACE_LANDMARKS_LEFT_EYEBROW=Ds,X.FACE_LANDMARKS_LEFT_IRIS=Kc,X.FACE_LANDMARKS_RIGHT_EYE=Rs,X.FACE_LANDMARKS_RIGHT_EYEBROW=Os,X.FACE_LANDMARKS_RIGHT_IRIS=Xc,X.FACE_LANDMARKS_FACE_OVAL=Bs,X.FACE_LANDMARKS_CONTOURS=Qc,X.FACE_LANDMARKS_TESSELATION=Jc;var lt=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!0),S(e=this.j=new uc,0,1,t=new q)}get baseOptions(){return P(this.j,q,1)}set baseOptions(e){S(this.j,0,1,e)}o(e){return super.l(e)}Ka(e,t,r){const i=typeof t!="function"?t:{};if(this.h=typeof t=="function"?t:r,$e(this,e,i??{}),!this.h)return this.s}m(){var e=new Ee;z(e,"image_in"),z(e,"norm_rect"),D(e,"stylized_image");const t=new Ie;Je(t,bd,this.j);const r=new ye;Me(r,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),W(r,"IMAGE:image_in"),W(r,"NORM_RECT:norm_rect"),L(r,"STYLIZED_IMAGE:stylized_image"),r.o(t),Le(e,r),this.g.V("stylized_image",(i,n)=>{var s=!this.h,a=i.data,c=i.width;const l=c*(i=i.height);if(a instanceof Uint8Array)if(a.length===3*l){const u=new Uint8ClampedArray(4*l);for(let h=0;h<l;++h)u[4*h]=a[3*h],u[4*h+1]=a[3*h+1],u[4*h+2]=a[3*h+2],u[4*h+3]=255;a=new ImageData(u,c,i)}else{if(a.length!==4*l)throw Error("Unsupported channel count: "+a.length/l);a=new ImageData(new Uint8ClampedArray(a.buffer,a.byteOffset,a.length),c,i)}else if(!(a instanceof WebGLTexture))throw Error(`Unsupported format: ${a.constructor.name}`);c=new fe([a],!1,!1,this.g.i.canvas,this.P,c,i),this.s=s=s?c.clone():c,this.h&&this.h(s),x(this,n)}),this.g.attachEmptyPacketListener("stylized_image",i=>{this.s=null,this.h&&this.h(null),x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};lt.prototype.stylize=lt.prototype.Ka,lt.prototype.setOptions=lt.prototype.o,lt.createFromModelPath=function(e,t){return I(lt,e,{baseOptions:{modelAssetPath:t}})},lt.createFromModelBuffer=function(e,t){return I(lt,e,{baseOptions:{modelAssetBuffer:t}})},lt.createFromOptions=function(e,t){return I(lt,e,t)};var Us=tt([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 el(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function tl(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 rl(e,t=!0){const r=[];for(const n of e){var i=Fi(n);e=[];for(const s of i.g())i=t&&Ue(s,1)!=null?Ue(s,1)??0:-1,e.push({score:ie(s,2)??0,index:i,categoryName:Ge(s,3)??""??"",displayName:Ge(s,4)??""??""});r.push(e)}return r}var Fe=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],S(e=this.j=new fc,0,1,t=new q),this.s=new xs,S(this.j,0,2,this.s),this.C=new ps,S(this.s,0,3,this.C),this.v=new hc,S(this.s,0,2,this.v),this.h=new vd,S(this.j,0,3,this.h),v(this.v,2,.5),v(this.s,4,.5),v(this.C,2,.5)}get baseOptions(){return P(this.j,q,1)}set baseOptions(e){S(this.j,0,1,e)}o(e){var n,s,a,c;if(st(this.v,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.v,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.s,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.C,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new kr,r=t,i=ks(e.cannedGesturesClassifierOptions,(n=P(this.h,kr,3))==null?void 0:n.h());S(r,0,2,i),S(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&((s=P(this.h,kr,3))==null||s.g());return e.customGesturesClassifierOptions?(S(r=t=new kr,0,2,i=ks(e.customGesturesClassifierOptions,(a=P(this.h,kr,4))==null?void 0:a.h())),S(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&((c=P(this.h,kr,4))==null||c.g()),this.l(e)}Fa(e,t){return el(this),$e(this,e,t),tl(this)}Ga(e,t,r){return el(this),ct(this,e,r,t),tl(this)}m(){var e=new Ee;z(e,"image_in"),z(e,"norm_rect"),D(e,"hand_gestures"),D(e,"hand_landmarks"),D(e,"world_hand_landmarks"),D(e,"handedness");const t=new Ie;Je(t,_d,this.j);const r=new ye;Me(r,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),W(r,"IMAGE:image_in"),W(r,"NORM_RECT:norm_rect"),L(r,"HAND_GESTURES:hand_gestures"),L(r,"LANDMARKS:hand_landmarks"),L(r,"WORLD_LANDMARKS:world_hand_landmarks"),L(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i){i=qr(s);const a=[];for(const c of pt(i,Za,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 pt(i,Ja,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(...rl(i,!1)),x(this,n)}),this.g.attachEmptyPacketListener("hand_gestures",i=>{x(this,i)}),this.g.attachProtoVectorListener("handedness",(i,n)=>{this.handedness.push(...rl(i)),x(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function il(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Fe.prototype.recognizeForVideo=Fe.prototype.Ga,Fe.prototype.recognize=Fe.prototype.Fa,Fe.prototype.setOptions=Fe.prototype.o,Fe.createFromModelPath=function(e,t){return I(Fe,e,{baseOptions:{modelAssetPath:t}})},Fe.createFromModelBuffer=function(e,t){return I(Fe,e,{baseOptions:{modelAssetBuffer:t}})},Fe.createFromOptions=function(e,t){return I(Fe,e,t)},Fe.HAND_CONNECTIONS=Us;var Pe=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],S(e=this.h=new xs,0,1,t=new q),this.s=new ps,S(this.h,0,3,this.s),this.j=new hc,S(this.h,0,2,this.j),st(this.j,3,1),v(this.j,2,.5),v(this.s,2,.5),v(this.h,4,.5)}get baseOptions(){return P(this.h,q,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return"numHands"in e&&st(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}D(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],$e(this,e,t),il(this)}F(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ct(this,e,r,t),il(this)}m(){var e=new Ee;z(e,"image_in"),z(e,"norm_rect"),D(e,"hand_landmarks"),D(e,"world_hand_landmarks"),D(e,"handedness");const t=new Ie;Je(t,kd,this.h);const r=new ye;Me(r,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),W(r,"IMAGE:image_in"),W(r,"NORM_RECT:norm_rect"),L(r,"LANDMARKS:hand_landmarks"),L(r,"WORLD_LANDMARKS:world_hand_landmarks"),L(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(i,n)=>{for(const s of i)i=qr(s),this.landmarks.push(Oi(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(Yr(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=Fi(l);const u=[];for(const h of i.g())u.push({score:ie(h,2)??0,index:Ue(h,1)??0??-1,categoryName:Ge(h,3)??""??"",displayName:Ge(h,4)??""??""});c.push(u)}a.call(s,...c),x(this,n)}),this.g.attachEmptyPacketListener("handedness",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Pe.prototype.detectForVideo=Pe.prototype.F,Pe.prototype.detect=Pe.prototype.D,Pe.prototype.setOptions=Pe.prototype.o,Pe.createFromModelPath=function(e,t){return I(Pe,e,{baseOptions:{modelAssetPath:t}})},Pe.createFromModelBuffer=function(e,t){return I(Pe,e,{baseOptions:{modelAssetBuffer:t}})},Pe.createFromOptions=function(e,t){return I(Pe,e,t)},Pe.HAND_CONNECTIONS=Us;var nl=tt([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 sl(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function ol(e){try{if(!e.C)return e.h;e.C(e.h)}finally{Gi(e)}}function Yi(e,t){e=qr(e),t.push(Oi(e))}var Y=class extends Se{constructor(e,t){super(new Ve(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,S(e=this.j=new yc,0,1,t=new q),this.K=new ps,S(this.j,0,2,this.K),this.Y=new Ed,S(this.j,0,3,this.Y),this.s=new Ri,S(this.j,0,4,this.s),this.H=new ac,S(this.j,0,5,this.H),this.v=new pc,S(this.j,0,6,this.v),this.L=new xc,S(this.j,0,7,this.L),v(this.s,2,.5),v(this.s,3,.3),v(this.H,2,.5),v(this.v,2,.5),v(this.v,3,.3),v(this.L,2,.5),v(this.K,2,.5)}get baseOptions(){return P(this.j,q,1)}set baseOptions(e){S(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&v(this.s,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&v(this.H,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&v(this.v,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&v(this.v,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&v(this.L,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&v(this.K,2,e.minHandLandmarksConfidence??.5),this.l(e)}D(e,t,r){const i=typeof t!="function"?t:{};return this.C=typeof t=="function"?t:r,sl(this),$e(this,e,i),ol(this)}F(e,t,r,i){const n=typeof r!="function"?r:{};return this.C=typeof r=="function"?r:i,sl(this),ct(this,e,n,t),ol(this)}m(){var e=new Ee;z(e,"input_frames_image"),D(e,"pose_landmarks"),D(e,"pose_world_landmarks"),D(e,"face_landmarks"),D(e,"left_hand_landmarks"),D(e,"left_hand_world_landmarks"),D(e,"right_hand_landmarks"),D(e,"right_hand_world_landmarks");const t=new Ie,r=new Pa;Bn(r,1,ur("type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),""),function(n,s){if(s!=null)if(Array.isArray(s))$(n,2,mi(s,Pn,void 0,void 0,!1));else{if(!(typeof s=="string"||s instanceof wt||$t(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Bn(n,2,_n(s,!1),Wt())}}(r,this.j.g());const i=new ye;Me(i,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),bi(i,8,Pa,r),W(i,"IMAGE:input_frames_image"),L(i,"POSE_LANDMARKS:pose_landmarks"),L(i,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),L(i,"FACE_LANDMARKS:face_landmarks"),L(i,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),L(i,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),L(i,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),L(i,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),i.o(t),Le(e,i),Ui(this,e),this.g.attachProtoListener("pose_landmarks",(n,s)=>{Yi(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(Yr(n)),x(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",n=>{x(this,n)}),this.outputPoseSegmentationMasks&&(L(i,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Er(this,"pose_segmentation_mask"),this.g.V("pose_segmentation_mask",(n,s)=>{this.h.poseSegmentationMasks=[Tr(this,n,!0,!this.C)],x(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",n=>{this.h.poseSegmentationMasks=[],x(this,n)})),this.g.attachProtoListener("face_landmarks",(n,s)=>{Yi(n,this.h.faceLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{x(this,n)}),this.outputFaceBlendshapes&&(D(e,"extra_blendshapes"),L(i,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(n,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(n=Fi(n),a.push(Es(n.g()??[]))),x(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",n=>{x(this,n)})),this.g.attachProtoListener("left_hand_landmarks",(n,s)=>{Yi(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(Yr(n)),x(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("right_hand_landmarks",(n,s)=>{Yi(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(Yr(n)),x(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",n=>{x(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Y.prototype.detectForVideo=Y.prototype.F,Y.prototype.detect=Y.prototype.D,Y.prototype.setOptions=Y.prototype.o,Y.createFromModelPath=function(e,t){return I(Y,e,{baseOptions:{modelAssetPath:t}})},Y.createFromModelBuffer=function(e,t){return I(Y,e,{baseOptions:{modelAssetBuffer:t}})},Y.createFromOptions=function(e,t){return I(Y,e,t)},Y.HAND_CONNECTIONS=Us,Y.POSE_CONNECTIONS=nl,Y.FACE_LANDMARKS_LIPS=Fs,Y.FACE_LANDMARKS_LEFT_EYE=Ps,Y.FACE_LANDMARKS_LEFT_EYEBROW=Ds,Y.FACE_LANDMARKS_LEFT_IRIS=Kc,Y.FACE_LANDMARKS_RIGHT_EYE=Rs,Y.FACE_LANDMARKS_RIGHT_EYEBROW=Os,Y.FACE_LANDMARKS_RIGHT_IRIS=Xc,Y.FACE_LANDMARKS_FACE_OVAL=Bs,Y.FACE_LANDMARKS_CONTOURS=Qc,Y.FACE_LANDMARKS_TESSELATION=Jc;var ze=class extends Se{constructor(e,t){super(new Ve(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},S(e=this.h=new bc,0,1,t=new q)}get baseOptions(){return P(this.h,q,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return S(this.h,0,2,ks(e,P(this.h,ws,2))),this.l(e)}qa(e,t){return this.j={classifications:[]},$e(this,e,t),this.j}ra(e,t,r){return this.j={classifications:[]},ct(this,e,r,t),this.j}m(){var e=new Ee;z(e,"input_image"),z(e,"norm_rect"),D(e,"classifications");const t=new Ie;Je(t,Sd,this.h);const r=new ye;Me(r,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),W(r,"IMAGE:input_image"),W(r,"NORM_RECT:norm_rect"),L(r,"CLASSIFICATIONS:classifications"),r.o(t),Le(e,r),this.g.attachProtoListener("classifications",(i,n)=>{this.j=function(s){const a={classifications:pt(s,dd,1).map(c=>{var l;return Es(((l=P(c,Ka,4))==null?void 0:l.g())??[],Ue(c,2)??0,Ge(c,3)??"")})};return Cn(hr(s,2))!=null&&(a.timestampMs=Cn(hr(s,2))??0),a}(hd(i)),x(this,n)}),this.g.attachEmptyPacketListener("classifications",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};ze.prototype.classifyForVideo=ze.prototype.ra,ze.prototype.classify=ze.prototype.qa,ze.prototype.setOptions=ze.prototype.o,ze.createFromModelPath=function(e,t){return I(ze,e,{baseOptions:{modelAssetPath:t}})},ze.createFromModelBuffer=function(e,t){return I(ze,e,{baseOptions:{modelAssetBuffer:t}})},ze.createFromOptions=function(e,t){return I(ze,e,t)};var De=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!0),this.h=new vc,this.embeddings={embeddings:[]},S(e=this.h,0,1,t=new q)}get baseOptions(){return P(this.h,q,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){var t=this.h,r=P(this.h,nc,2);return r=r?r.clone():new nc,e.l2Normalize!==void 0?$r(r,1,e.l2Normalize):"l2Normalize"in e&&$(r,1),e.quantize!==void 0?$r(r,2,e.quantize):"quantize"in e&&$(r,2),S(t,0,2,r),this.l(e)}xa(e,t){return $e(this,e,t),this.embeddings}ya(e,t,r){return ct(this,e,r,t),this.embeddings}m(){var e=new Ee;z(e,"image_in"),z(e,"norm_rect"),D(e,"embeddings_out");const t=new Ie;Je(t,Ad,this.h);const r=new ye;Me(r,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),W(r,"IMAGE:image_in"),W(r,"NORM_RECT:norm_rect"),L(r,"EMBEDDINGS:embeddings_out"),r.o(t),Le(e,r),this.g.attachProtoListener("embeddings_out",(i,n)=>{i=md(i),this.embeddings=function(s){return{embeddings:pt(s,wd,1).map(a=>{var l,u;const c={headIndex:Ue(a,3)??0??-1,headName:Ge(a,4)??""??""};if(ra(a,tc,Un(a,1))!==void 0)a=qt(a=P(a,tc,Un(a,1)),1,jt,Ht()),c.floatEmbedding=a.slice();else{const h=new Uint8Array(0);c.quantizedEmbedding=((u=(l=P(a,fd,Un(a,2)))==null?void 0:l.ma())==null?void 0:u.h())??h}return c}),timestampMs:Cn(hr(s,2))??0}}(i),x(this,n)}),this.g.attachEmptyPacketListener("embeddings_out",i=>{x(this,i)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};De.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=Cc(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=Cc(Nc(e.quantizedEmbedding),Nc(t.quantizedEmbedding))}return e},De.prototype.embedForVideo=De.prototype.ya,De.prototype.embed=De.prototype.xa,De.prototype.setOptions=De.prototype.o,De.createFromModelPath=function(e,t){return I(De,e,{baseOptions:{modelAssetPath:t}})},De.createFromModelBuffer=function(e,t){return I(De,e,{baseOptions:{modelAssetBuffer:t}})},De.createFromOptions=function(e,t){return I(De,e,t)};var Gs=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 al(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function cl(e){try{const t=new Gs(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{Gi(e)}}Gs.prototype.close=Gs.prototype.close;var Ae=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new _s,this.v=new _c,S(this.h,0,3,this.v),S(e=this.h,0,1,t=new q)}get baseOptions(){return P(this.h,q,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?$(this.h,2,ur(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)}J(){(function(e){var r,i;const t=pt(e.ca(),ye,1).filter(n=>(Ge(n,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.s=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(((i=(r=P(t[0],Ie,7))==null?void 0:r.l())==null?void 0:i.g())??new Map).forEach((n,s)=>{e.s[Number(s)]=Ge(n,1)??""})})(this)}segment(e,t,r){const i=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,al(this),$e(this,e,i),cl(this)}Ia(e,t,r,i){const n=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:i,al(this),ct(this,e,n,t),cl(this)}Ba(){return this.s}m(){var e=new Ee;z(e,"image_in"),z(e,"norm_rect");const t=new Ie;Je(t,Sc,this.h);const r=new ye;Me(r,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),W(r,"IMAGE:image_in"),W(r,"NORM_RECT:norm_rect"),r.o(t),Le(e,r),Ui(this,e),this.outputConfidenceMasks&&(D(e,"confidence_masks"),L(r,"CONFIDENCE_MASKS:confidence_masks"),Er(this,"confidence_masks"),this.g.ba("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Tr(this,s,!0,!this.j)),x(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],x(this,i)})),this.outputCategoryMask&&(D(e,"category_mask"),L(r,"CATEGORY_MASK:category_mask"),Er(this,"category_mask"),this.g.V("category_mask",(i,n)=>{this.categoryMask=Tr(this,i,!1,!this.j),x(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,x(this,i)})),D(e,"quality_scores"),L(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.Ba,Ae.prototype.segmentForVideo=Ae.prototype.Ia,Ae.prototype.segment=Ae.prototype.segment,Ae.prototype.setOptions=Ae.prototype.o,Ae.createFromModelPath=function(e,t){return I(Ae,e,{baseOptions:{modelAssetPath:t}})},Ae.createFromModelBuffer=function(e,t){return I(Ae,e,{baseOptions:{modelAssetBuffer:t}})},Ae.createFromOptions=function(e,t){return I(Ae,e,t)};var Vs=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()}};Vs.prototype.close=Vs.prototype.close;var Fd=class extends y{constructor(e){super(e)}},jr=[0,ee,-2],Ki=[0,bt,-3,H,bt,-1],ll=[0,Ki],ul=[0,Ki,ee,-1],$s=class extends y{constructor(e){super(e)}},dl=[0,bt,-1,H],Pd=class extends y{constructor(e){super(e)}},hl=class extends y{constructor(e){super(e)}},Ws=[1,2,3,4,5,6,7,8,9,10,14,15],fl=class extends y{constructor(e){super(e)}};fl.prototype.g=Li([0,ue,[0,Ws,O,Ki,O,[0,Ki,jr],O,ll,O,[0,ll,jr],O,dl,O,[0,bt,-3,H,Ce],O,[0,bt,-3,H],O,[0,R,bt,-2,H,ee,H,-1,2,bt,jr],O,ul,O,[0,ul,jr],bt,jr,R,O,[0,bt,-3,H,jr,-1],O,[0,ue,dl]],R,[0,R,ee,-1,H]]);var ut=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new _s,this.s=new _c,S(this.h,0,3,this.s),S(e=this.h,0,1,t=new q)}get baseOptions(){return P(this.h,q,1)}set baseOptions(e){S(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:{};this.j=typeof r=="function"?r:i,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.B+1,i=new fl;const s=new hl;var a=new Fd;if(st(a,1,255),S(s,0,12,a),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var c=new $s;$r(c,3,!0),v(c,1,t.keypoint.x),v(c,2,t.keypoint.y),Vr(s,5,Ws,c)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(c of(a=new Pd,t.scribble))$r(t=new $s,3,!0),v(t,1,c.x),v(t,2,c.y),bi(a,1,$s,t);Vr(s,15,Ws,a)}bi(i,1,hl,s),this.g.addProtoToStream(i.g(),"drishti.RenderData","roi_in",r),$e(this,e,n);e:{try{const u=new Vs(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=u;break e}this.j(u)}finally{Gi(this)}l=void 0}return l}m(){var e=new Ee;z(e,"image_in"),z(e,"roi_in"),z(e,"norm_rect_in");const t=new Ie;Je(t,Sc,this.h);const r=new ye;Me(r,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),W(r,"IMAGE:image_in"),W(r,"ROI:roi_in"),W(r,"NORM_RECT:norm_rect_in"),r.o(t),Le(e,r),Ui(this,e),this.outputConfidenceMasks&&(D(e,"confidence_masks"),L(r,"CONFIDENCE_MASKS:confidence_masks"),Er(this,"confidence_masks"),this.g.ba("confidence_masks",(i,n)=>{this.confidenceMasks=i.map(s=>Tr(this,s,!0,!this.j)),x(this,n)}),this.g.attachEmptyPacketListener("confidence_masks",i=>{this.confidenceMasks=[],x(this,i)})),this.outputCategoryMask&&(D(e,"category_mask"),L(r,"CATEGORY_MASK:category_mask"),Er(this,"category_mask"),this.g.V("category_mask",(i,n)=>{this.categoryMask=Tr(this,i,!1,!this.j),x(this,n)}),this.g.attachEmptyPacketListener("category_mask",i=>{this.categoryMask=void 0,x(this,i)})),D(e,"quality_scores"),L(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 I(ut,e,{baseOptions:{modelAssetPath:t}})},ut.createFromModelBuffer=function(e,t){return I(ut,e,{baseOptions:{modelAssetBuffer:t}})},ut.createFromOptions=function(e,t){return I(ut,e,t)};var He=class extends Se{constructor(e,t){super(new Ve(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},S(e=this.h=new Ac,0,1,t=new q)}get baseOptions(){return P(this.h,q,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?$(this.h,2,ur(e.displayNamesLocale)):"displayNamesLocale"in e&&$(this.h,2),e.maxResults!==void 0?st(this.h,3,e.maxResults):"maxResults"in e&&$(this.h,3),e.scoreThreshold!==void 0?v(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&$(this.h,4),e.categoryAllowlist!==void 0?vi(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&$(this.h,5),e.categoryDenylist!==void 0?vi(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&$(this.h,6),this.l(e)}D(e,t){return this.j={detections:[]},$e(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},ct(this,e,r,t),this.j}m(){var e=new Ee;z(e,"input_frame_gpu"),z(e,"norm_rect"),D(e,"detections");const t=new Ie;Je(t,jd,this.h);const r=new ye;Me(r,"mediapipe.tasks.vision.ObjectDetectorGraph"),W(r,"IMAGE:input_frame_gpu"),W(r,"NORM_RECT:norm_rect"),L(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(i,n)=>{for(const s of i)i=Qa(s),this.j.detections.push(jc(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.F,He.prototype.detect=He.prototype.D,He.prototype.setOptions=He.prototype.o,He.createFromModelPath=async function(e,t){return I(He,e,{baseOptions:{modelAssetPath:t}})},He.createFromModelBuffer=function(e,t){return I(He,e,{baseOptions:{modelAssetBuffer:t}})},He.createFromOptions=function(e,t){return I(He,e,t)};var zs=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 wl(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function ml(e){try{const t=new zs(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.s)return t;e.s(t)}finally{Gi(e)}}zs.prototype.close=zs.prototype.close;var Re=class extends Se{constructor(e,t){super(new Ve(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,S(e=this.h=new Tc,0,1,t=new q),this.v=new xc,S(this.h,0,3,this.v),this.j=new pc,S(this.h,0,2,this.j),st(this.j,4,1),v(this.j,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return P(this.h,q,1)}set baseOptions(e){S(this.h,0,1,e)}o(e){return"numPoses"in e&&st(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&v(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&v(this.v,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}D(e,t,r){const i=typeof t!="function"?t:{};return this.s=typeof t=="function"?t:r,wl(this),$e(this,e,i),ml(this)}F(e,t,r,i){const n=typeof r!="function"?r:{};return this.s=typeof r=="function"?r:i,wl(this),ct(this,e,n,t),ml(this)}m(){var e=new Ee;z(e,"image_in"),z(e,"norm_rect"),D(e,"normalized_landmarks"),D(e,"world_landmarks"),D(e,"segmentation_masks");const t=new Ie;Je(t,Nd,this.h);const r=new ye;Me(r,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),W(r,"IMAGE:image_in"),W(r,"NORM_RECT:norm_rect"),L(r,"NORM_LANDMARKS:normalized_landmarks"),L(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),Le(e,r),Ui(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(i,n)=>{this.landmarks=[];for(const s of i)i=qr(s),this.landmarks.push(Oi(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(Yr(i));x(this,n)}),this.g.attachEmptyPacketListener("world_landmarks",i=>{this.worldLandmarks=[],x(this,i)}),this.outputSegmentationMasks&&(L(r,"SEGMENTATION_MASK:segmentation_masks"),Er(this,"segmentation_masks"),this.g.ba("segmentation_masks",(i,n)=>{this.segmentationMasks=i.map(s=>Tr(this,s,!0,!this.s)),x(this,n)}),this.g.attachEmptyPacketListener("segmentation_masks",i=>{this.segmentationMasks=[],x(this,i)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Re.prototype.detectForVideo=Re.prototype.F,Re.prototype.detect=Re.prototype.D,Re.prototype.setOptions=Re.prototype.o,Re.createFromModelPath=function(e,t){return I(Re,e,{baseOptions:{modelAssetPath:t}})},Re.createFromModelBuffer=function(e,t){return I(Re,e,{baseOptions:{modelAssetBuffer:t}})},Re.createFromOptions=function(e,t){return I(Re,e,t)},Re.POSE_CONNECTIONS=nl;const Xi="https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task",Dd="https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm",Rd=()=>{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 u=async()=>"caches"in window?await(await caches.open("mediapipe-models-v1")).match(Xi)!==void 0:!1,h=async()=>{try{const w=await fetch(Xi),m=w.headers.get("content-length"),g=m?parseInt(m,10):0;if(!w.body)throw new Error("No response body");const b=w.body.getReader();let _=0;const p=[];for(;;){const{done:A,value:F}=await b.read();if(A)break;if(p.push(F),_+=F.length,g){const T=Math.round(_/g*100);a(T),n(`Downloading model... ${T}%`)}}return"caches"in window&&await(await caches.open("mediapipe-models-v1")).put(Xi,new Response(new Blob(p),{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 u()?n("Using cached model..."):(n("Model not cached. Downloading..."),await h()),n("Loading MediaPipe WASM...");const g=await Xt.forVisionTasks(Dd);n("Creating face landmarker...");const b=await X.createFromOptions(g,{baseOptions:{modelAssetPath:Xi,delegate:"GPU"},runningMode:"VIDEO",outputFaceBlendshapes:!0,numFaces:2});e.current=b,r(!0),n("Model loaded successfully ✅")}catch(m){console.error("Model init error:",m),n(`Error: ${m==null?void 0:m.message}`),(m==null?void 0:m.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."))}}},Od=()=>{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}},Bd=()=>{const e=d.useRef({value:100,isLookingAway:!1}),t=d.useCallback((s,a,c,l)=>{if(!s||!c||!a)return;const u=s.getContext("2d");if(!u)return;const{width:h,height:f}=s;if(u.clearRect(0,0,h,f),u.drawImage(a,0,0,h,f),l){u.fillStyle="#00FF00";for(const w of c)u.fillRect(w.x*h-.5,w.y*f-.5,1,1)}},[]),r=d.useCallback(s=>{const a=e.current.value/100,c=100,l=20,u=10,h=10;s.fillStyle="rgba(0, 0, 0, 0.3)",s.fillRect(u,h,l,c),s.fillStyle=`rgba(${Math.floor(255*(1-a))}, ${Math.floor(255*a)}, 0, 0.8)`;const f=c*a;s.fillRect(u,h+c-f,l,f),s.fillStyle="#FFFFFF",s.fillRect(u,h+c*(1-a),l,2)},[]),i=d.useCallback((s,a,c,l,u,h,f)=>{if(t(s,a,c,l),u&&h&&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}},Ud=70,Gd=()=>{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 u=a[33],h=a[263],f=a[1];if(!u||!h||!f)return;const w=(u.x+h.x)*.5,m=(u.y+h.y)*.5,g=w-c.x,b=m-c.y,_=Math.sqrt(g*g+b*b),p=Math.abs(f.y-c.noseY)*100,A=Math.abs(f.x-c.noseX)*100,F=Math.max(0,100-(_*200+p+A)),T=F<Ud,C=performance.now();return C-n.current>100&&(t(F),i(T),n.current=C),{engagement:F,isLookingAway:T}},[]);return{engagement:e,isLookingAway:r,analyzeGaze:s,setEngagement:t,setIsLookingAway:i}},Vd=.05,$d=()=>{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 u=[1,33,263,61,291,10,152];let h=0,f=0;const w=l[33],m=l[263],g=c[33],b=c[263];if(!w||!m||!g||!b)return 0;const _=n(w,m),p=n(g,b);if(_===0||p===0)return 0;for(const F of u){const T=l[F],C=c[F];if(T&&C){const M=w.x+(C.x-g.x)*_/p,B=w.y+(C.y-g.y)*_/p;h+=n(T,{x:M,y:B}),f++}}return f===0?0:h/f},[n]),a=d.useCallback((c,l,u,h)=>{if(!c.faceLandmarks||c.faceLandmarks.length===0)return l?(h("Reference face not detected."),i(!0),t(!1)):i(!1),null;if(l&&u){let f=null,w=0;for(const m of c.faceLandmarks)s(m,u)<Vd&&(f=m,w++);return w===1?(t(!1),i(!1),h("Reference face tracked."),f):w>1?(t(!0),i(!1),h("Multiple matching faces detected. Tracking suspended."),null):(t(!1),i(!0),h("Reference face not detected."),null)}else{c.faceLandmarks.length>1?(t(!0),h("Multiple faces detected. Set reference for single face tracking.")):(t(!1),h("No reference set. Detecting first face."));const f=c.faceLandmarks[0];return!f||f.length<468?null:f}},[s]);return{multipleFacesDetected:e,referenceFaceNotDetected:r,analyzeFace:a,setMultipleFacesDetected:t,setReferenceFaceNotDetected:i}},Wd=1e3,zd=(e,t)=>{const[r,i]=d.useState(!1),[n,s]=d.useState("face_detected"),{incrementGazeViolation:a}=Zs(),{multipleFacesDetected:c,referenceFaceNotDetected:l,isLookingAway:u}=e;d.useEffect(()=>{let w;return(u||c||l)&&t?w=setTimeout(()=>{i(!0),u?(s("looking_away"),a("looking_away")):c?(s("multiple_faces"),a("multiple_faces")):l&&(s("no_face_detected"),a("no_face_detected"))},Wd):(i(!1),s("face_detected")),()=>{clearTimeout(w)}},[u,c,l,t,a]);const h=d.useCallback(()=>c?"multiple_faces":l?"no_face_detected":u?"looking_away":"face_detected",[c,l,u]),f=d.useCallback(()=>{i(!1),s("face_detected")},[]);return{showGazeWarningModal:r,faceDetectionState:n,getWarningType:h,closeWarningModal:f,setShowGazeWarningModal:i,setFaceDetectionState:s}};class te extends Error{constructor(t,r,i=!1){super(t),this.code=r,this.recoverable=i,this.name="STTError"}}class Hd{constructor(t={}){Oe(this,"config");Oe(this,"mediaRecorder",null);Oe(this,"audioChunks",[]);Oe(this,"recordingStream",null);Oe(this,"autoStopTimeoutId",null);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...t}}updateConfig(t){this.config={...this.config,...t}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(t,r){var i;if(!this.isRecordingSupported())throw new te("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new te("Recording is already in progress","ALREADY_RECORDING",!0);try{this.recordingStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:44100}}),this.audioChunks=[];const n=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:n}),this.mediaRecorder.ondataavailable=s=>{var a;s.data.size>0&&(this.audioChunks.push(s.data),(a=r==null?void 0:r.onDataAvailable)==null||a.call(r,s.data))},this.mediaRecorder.onstop=()=>{var s;(s=r==null?void 0:r.onStop)==null||s.call(r)},this.mediaRecorder.onerror=s=>{var c;const a=new te(`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(()=>{this.isRecording()&&this.stopRecording()},t*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new te("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new te("No microphone found","NO_MICROPHONE",!1)}throw new te(`Failed to start recording: ${n instanceof Error?n.message:String(n)}`,"START_RECORDING_FAILED",!0)}}async stopRecording(){if(this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||!this.isRecording())throw new te("No active recording to stop","NO_ACTIVE_RECORDING",!1);return new Promise((t,r)=>{if(!this.mediaRecorder){r(new te("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const i=this.mediaRecorder,n=()=>{try{const s=i.mimeType||"audio/webm",a=new Blob(this.audioChunks,{type:s});this.cleanup(),t(a)}catch(s){r(new te(`Failed to create audio blob: ${s instanceof Error?s.message:String(s)}`,"BLOB_CREATION_FAILED",!1))}};i.addEventListener("stop",n,{once:!0}),i.stop()})}async transcribe(t){const{audioBlob:r}=t;if(!r||r.size===0)throw new te("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 te("Interview ID is missing from configuration","MISSING_INTERVIEW_ID",!1);const s=await Bt(`${this.config.baseUrl}${Gt.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 u=JSON.parse(c);l=u.message||u.error||l}catch{l=c||l}throw new te(l,`HTTP_${s.status}`,s.status>=500)}return{transcript:(await s.json()).data.transcribed_text??""}}catch(i){throw i instanceof te?i:new te(`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"}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.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}}const Nr=new Hd,qd=(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(u=>u.stop())}},[t,r]),d.useEffect(()=>{const s=Nr.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(u=>{u.addEventListener("ended",l)})}},[]),{animationFrameRef:n}},Yd=(e,t,r,i,n,s,a,c,l,u,h,f,w,m,g)=>{const b=d.useRef(null),_=d.useCallback(()=>{var T;const p=e.current,A=t.current,F=r.current;if(!p||p.readyState<2||!F||!A){b.current=requestAnimationFrame(_);return}i();try{const C=performance.now(),M=F.detectForVideo(p,C);if(((T=M.faceLandmarks)==null?void 0:T.length)>0){g(!1);const B=n(M,l,u.current,m);B?(s(A,p,B,h,f,w,l),l&&w&&c(B,u.current,w)):a(A,p)}else a(A,p),l?(g(!0),m("Reference face not detected.")):g(!1)}catch(C){console.error("Face detection error:",C)}b.current=requestAnimationFrame(_)},[e,t,r,i,n,s,a,c,l,u,h,f,w,m,g]);return{renderLoop:_,animationFrameRef:b}},Kd=(e,t,r,i)=>{const{referenceSet:n,referenceRef:s,setReferenceData:a}=Zs(),c=d.useRef(s),l=d.useCallback(()=>{c.current=s},[s]),u=d.useCallback(()=>{var w;const h=e.current,f=t.current;if(console.log({faceLandmarker:h,video:f}),!(!h||!f))try{const m=performance.now(),g=h.detectForVideo(f,m);if((w=g.faceLandmarks)!=null&&w[0]){const b=g.faceLandmarks[0],_=b[33],p=b[263],A=b[1];_&&p&&A&&(c.current={x:(_.x+p.x)*.5,y:(_.y+p.y)*.5,noseX:A.x,noseY:A.y},a(!0,c.current),r("Reference set. Gaze tracking active."),console.log("Reference set. Gaze tracking active.",c.current),i&&i())}}catch(m){console.error("Set reference error:",m),r("Failed to set reference")}},[e,t,r,a,i]);return{referenceSet:n,referenceRef:c,setReference:u,syncReference:l}},gl=d.forwardRef(({className:e="",interviewId:t="",interview_duration:r,showProctoringUI:i=!0,onSetReference:n},s)=>{var El;const{authToken:a}=ro(),c=a?Wl(a):null,l=lo(),{borderRadius:u}=rr(),h=u??18,{proctoring:f}=cn(),w=!!(f!=null&&f.gazeAnalysisEnabled),[m,g]=d.useState(!1),[b,_]=d.useState((f==null?void 0:f.showLandmarks)??!1),[p,A]=d.useState(i&&((f==null?void 0:f.showEngagementBar)??!0)),[F,T]=d.useState(w),C=d.useRef(null),M=d.useRef(null),B=d.useRef(null),G=d.useRef(null),Q=d.useCallback(async ft=>{var tn;const Jr=C.current,ve=B.current;if(!Jr||!ve)return;const Cr=ve.getContext("2d");if(!Cr)return;ve.width=Jr.videoWidth,ve.height=Jr.videoHeight,Cr.save(),Cr.scale(-1,1),Cr.drawImage(Jr,-ve.width,0,ve.width,ve.height),Cr.restore();const Zr=await new Promise(er=>ve.toBlob(er,"image/jpeg"));if(Zr&&t)try{const er=`${ft}-${Date.now()}.jpeg`,_e=await l.requestScreenshotUploadUrl(t,er);_e.data&&_e.data.upload_url&&(await l.uploadScreenshot((tn=_e==null?void 0:_e.data)==null?void 0:tn.upload_url,Zr),_e.data.asset_id&&await l.confirmScreenshotUpload(_e.data.asset_id))}catch(er){console.error(`Failed to upload screenshot for ${ft}:`,er)}},[l,t]),{faceLandmarkerRef:oe,isModelLoaded:qe,statusMessage:de,setStatusMessage:Ye,loadingProgress:Te,permissionDenied:be,clearCache:kt}=Rd(),{fps:dt,updateFPS:ge}=Od(),{drawWithEngagementBar:Qt,clearCanvas:Ke,engagementRef:re}=Bd(),{engagement:Xe,isLookingAway:V,analyzeGaze:ht,setEngagement:j,setIsLookingAway:J}=Gd(),{multipleFacesDetected:Dt,referenceFaceNotDetected:Rt,analyzeFace:Jt,setMultipleFacesDetected:Ji,setReferenceFaceNotDetected:Zt}=$d(),{referenceSet:Qr,referenceRef:Zi,setReference:N,syncReference:je}=Kd(oe,C,Ye,n),rt={multipleFacesDetected:Dt,referenceFaceNotDetected:Rt,isLookingAway:V},{showGazeWarningModal:en,getWarningType:Ch,closeWarningModal:vl,setShowGazeWarningModal:_l,setFaceDetectionState:kl}=zd(rt,w),{renderLoop:Ih}=Yd(C,M,oe,ge,Jt,Qt,Ke,ht,Qr,Zi,b,p,w,Ye,Zt);qd(C,qe,Ih,Ye),d.useEffect(()=>{je()},[je]),d.useEffect(()=>{re&&re.current&&(re.current.value=Xe,re.current.isLookingAway=V)},[Xe,V,re]);const Mh=d.useCallback(ft=>{T(ft),ft||(j(100),J(!1))},[j,J]),Lh=d.useCallback(()=>{J(!1),Ji(!1),Zt(!1),kl("face_detected"),_l(!1),vl()},[J,Ji,Zt,kl,_l,vl]),Fh={engagement:Xe,fps:dt,isLookingAway:V,multipleFacesDetected:Dt,referenceFaceNotDetected:Rt};return d.useEffect(()=>{const ft=[];return(async()=>{try{const ve=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1});G.current=ve,C.current&&(C.current.srcObject=ve);const Zr=(r??ti)*60*1e3/3,tn=[0,1,2].map((_e,Ot)=>({label:`capture-${Ot+1}`,start:Ot*Zr,end:(Ot+1)*Zr})),er=(_e,Ot)=>_e===Ot?_e:Math.random()*(Ot-_e)+_e;tn.forEach(({label:_e,start:Ot,end:Ph},Dh)=>{let Ys;Dh===0?Ys=3e3:Ys=er(Ot,Ph),ft.push(setTimeout(()=>{Q(_e)},Ys))})}catch(ve){console.error("Error accessing camera:",ve)}})(),()=>{G.current&&G.current.getTracks().forEach(ve=>ve.stop()),ft.forEach(clearTimeout)}},[Q]),d.useImperativeHandle(s,()=>({setReference:()=>{N()},stopCamera:()=>{G.current&&(G.current.getTracks().forEach(ft=>ft.stop()),G.current=null)}}),[N]),o.jsxs("div",{className:`iw-relative iw-h-full ${e}`,children:[be?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-flex-wrap iw-gap-5",children:o.jsxs("div",{className:"iw-relative iw-flex-1",children:[o.jsx("video",{ref:C,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover iw-scale-75 iw-rounded-r-xl iw-min-h-[200px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)"}}),w&&o.jsx("canvas",{ref:M,width:420,height:240,className:"iw-absolute iw-top-0 iw-left-0 iw-w-full iw-h-full iw-object-cover iw-scale-75 iw-rounded-r-xl iw-min-h-[200px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)",borderRadius:h}}),o.jsx("canvas",{ref:B,style:{display:"none"}}),i&&o.jsxs("div",{className:"iw-absolute iw-top-4 iw-left-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-black/40 iw-px-4 iw-py-2 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-white",children:"Recording"})]}),i&&((El=c==null?void 0:c.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-black/40 iw-px-4 iw-py-2 iw-backdrop-blur-md",children:o.jsx("span",{className:"iw-font-medium iw-text-white",children:c.data.user_name})}),i&&o.jsx("div",{className:"iw-absolute iw-bottom-4 iw-right-4",children:o.jsx(lu,{showControls:(f==null?void 0:f.showControls)??!1,isBubbleOpen:m,setIsBubbleOpen:g,setReference:N,clearCache:kt,isModelLoaded:qe,gazeAnalysisEnabled:F&&w,referenceSet:Qr,showLandmarks:b,setShowLandmarks:_,showEngagementBar:p,setShowEngagementBar:A,handleToggleGazeAnalysis:Mh,stats:Fh,statusMessage:de,loadingProgress:Te})})]})}),w&&en&&o.jsx(au,{isOpen:en,onClose:Lh,warningType:Ch()})]})}),Xd=["Do not refresh or reload the page during your assessment","Refrain from switching tabs or opening other applications while the session is in progress","Ensure your face remains clearly visible on camera at all times","Avoid frequent distractions or leaving your seat during the session","Do not disable or interfere with audio/video monitoring"],Qd=({isOpen:e,onStart:t,onClose:r,gazeEnabled:i=!1,videoFeedRef:n,interviewId:s="",interview_duration:a=ti})=>{var ht;const c=d.useRef(null),l=d.useRef(null),{baseColor:u,borderRadius:h}=rr(),[f,w]=d.useState(!1),[m,g]=d.useState(!1),[b,_]=d.useState(!1),[p,A]=d.useState(!1),[F,T]=d.useState(!1),[C,M]=d.useState(null),[B,G]=d.useState(!1),Q=d.useRef(null),oe=d.useRef(null),qe=j=>{Q.current=j,n&&(typeof n=="function"?n(j):n.current=j)},de=u??"#2563eb",Ye=oo(de),Te=h??18,be=(j,J)=>j.startsWith("#")&&j.length===7?`${j}${J}`:j,kt=[`radial-gradient(120% 85% at 50% 125%, ${be(de,"34")} 0%, transparent 70%)`,`radial-gradient(90% 70% at 10% 130%, ${be(de,"24")} 0%, transparent 72%)`,`radial-gradient(90% 70% at 90% 130%, ${be(de,"24")} 0%, transparent 72%)`,`repeating-linear-gradient(135deg, ${be(de,"14")} 0, ${be(de,"14")} 16px, transparent 16px, transparent 32px)`].join(", "),dt=f?{label:"Camera & microphone ready",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-emerald-400"}:B?{label:"Checking device access…",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-amber-300"}:{label:"Allow access to continue",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-rose-300"},ge=f?{badge:"Ready",toneClass:"iw-bg-emerald-50 iw-text-emerald-600",cameraCopy:"Framing looks good for identity verification.",micCopy:"We can hear you clearly for your responses."}:B?{badge:"Checking",toneClass:"iw-bg-amber-50 iw-text-amber-600",cameraCopy:"Hang tight while we confirm camera access.",micCopy:"Listening for microphone permission from your browser."}:{badge:"Action needed",toneClass:"iw-bg-rose-50 iw-text-rose-600",cameraCopy:"Grant camera access to continue with the interview.",micCopy:"Enable microphone access so we can capture your answers."},Qt=[{label:"Camera feed",description:ge.cameraCopy,status:ge.badge,toneClass:ge.toneClass,Icon:co},{label:"Microphone input",description:ge.micCopy,status:ge.badge,toneClass:ge.toneClass,Icon:Hl}],Ke=()=>{l.current&&(l.current.getTracks().forEach(j=>j.stop()),l.current=null)},re=async()=>{G(!0),M(null);try{const j=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:!0});l.current=j,c.current&&(c.current.srcObject=j),w(!0)}catch(j){console.error("Media permission error:",j);let J="Unable to access camera or microphone.";(j==null?void 0:j.name)==="NotAllowedError"?J="Permissions denied. Please allow access to camera and microphone.":(j==null?void 0:j.name)==="NotFoundError"?J="No camera/microphone found. Please connect a device and retry.":j!=null&&j.message&&(J=j.message),w(!1),M(J)}finally{G(!1)}};if(d.useEffect(()=>{if(!e){Ke();return}return re(),()=>Ke()},[e]),d.useEffect(()=>()=>{oe.current&&(clearInterval(oe.current),oe.current=null)},[]),!e)return null;const Xe=()=>{i?_(!0):(t(),Ke())},V=async()=>{A(!0);const j=()=>{var J;return(J=Q.current)==null?void 0:J.setReference()};j(),oe.current&&clearInterval(oe.current),oe.current=setInterval(j,500)};return o.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-gray-900/25 iw-backdrop-blur-md iw-p-4",children:[o.jsxs("div",{className:" iw-w-full iw-max-w-[920px] iw-max-h-[96vh] iw-overflow-auto iw-rounded-3xl iw-bg-white iw-shadow-[0_40px_80px_-28px_rgba(15,23,42,0.25)]",children:[o.jsxs("div",{className:"iw-relative iw-overflow-hidden",style:{background:Ye},children:[o.jsx("div",{"aria-hidden":!0,className:"iw-absolute iw-pointer-events-none",style:{top:-90,right:-100,width:240,height:240,background:"radial-gradient(circle, rgba(255,255,255,0.6), transparent 70%)",filter:"blur(12px)"}}),o.jsx("div",{"aria-hidden":!0,className:"iw-absolute iw-pointer-events-none",style:{bottom:-110,left:-60,width:220,height:220,background:"radial-gradient(circle, rgba(255,255,255,0.35), transparent 70%)",filter:"blur(14px)"}}),o.jsxs("div",{className:"iw-relative iw-grid md:iw-grid-cols-[minmax(0,1fr)_auto] iw-items-start iw-gap-6 iw-px-6 iw-py-7",children:[o.jsx("div",{className:"iw-flex iw-flex-col iw-gap-4 iw-text-white",children:o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-12 iw-w-12 iw-items-center iw-justify-center iw-rounded-2xl iw-bg-white/15 iw-shadow-inner",children:o.jsx(ao,{className:"iw-h-6 iw-w-6"})}),o.jsxs("div",{children:[o.jsx("p",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-white/70",children:"Pre-interview checklist"}),o.jsx("h2",{className:"iw-mt-1 iw-text-xl iw-font-semibold iw-leading-tight",children:"Final checks before you go live"}),o.jsx("p",{className:"iw-mt-2 iw-text-sm iw-text-white/80",children:"Align your space, confirm device access, and step confidently into your secure session."})]})]})}),o.jsx("div",{className:"iw-flex iw-items-start iw-justify-end",children:o.jsxs("div",{className:`iw-inline-flex iw-items-center iw-gap-2 iw-rounded-full iw-bg-white/10 iw-px-4 iw-py-1.5 iw-text-xs iw-font-medium iw-text-white/85 iw-backdrop-blur-sm ${dt.toneClass}`,children:[o.jsx("span",{className:`iw-inline-flex iw-h-2 iw-w-2 iw-rounded-full ${dt.dotClass}`}),dt.label]})}),r&&o.jsx("button",{"aria-label":"Close",className:"iw-absolute iw-top-5 iw-right-5 iw-text-white/70 transition-colors hover:iw-text-white",onClick:()=>{Ke(),r==null||r()},children:"✕"})]})]}),o.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-px-6 iw-pb-8 iw-pt-6",children:[o.jsxs("div",{className:"iw-grid xl:iw-grid-cols-[0.95fr_1.05fr] iw-gap-6",children:[o.jsx("section",{className:"iw-flex iw-flex-col iw-gap-5",children:o.jsxs("div",{className:"iw-rounded-2xl iw-border iw-border-slate-100 iw-bg-white iw-p-5 iw-shadow-sm",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[o.jsx("h3",{className:"iw-text-sm iw-font-semibold iw-text-slate-900",children:"Proctoring guidelines"}),o.jsx("span",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-slate-400",children:"Required"})]}),o.jsx("ul",{className:"iw-mt-5 iw-flex iw-flex-col iw-gap-4",children:Xd.map((j,J)=>o.jsx("li",{className:"iw-group iw-overflow-hidden iw-rounded-xl iw-border iw-border-slate-100 iw-bg-slate-50/60 iw-p-4 iw-transition-all hover:iw-border-slate-200 hover:iw-bg-white",children:o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[o.jsx("span",{className:"iw-flex iw-h-8 iw-w-8 iw-flex-none iw-items-center iw-justify-center iw-rounded-full iw-text-sm iw-font-semibold iw-text-white",style:{background:Ye},children:J+1}),o.jsx("span",{className:"iw-text-sm iw-text-slate-600",children:j})]})},j))})]})}),o.jsxs("section",{className:"iw-flex iw-flex-col iw-gap-5",children:[o.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-overflow-hidden iw-rounded-3xl iw-bg-white ",style:{borderRadius:Te},children:[o.jsx("div",{className:"iw-relative iw-z-10 iw-rounded-2xl iw-border iw-border-slate-200 iw-bg-slate-50/80 iw-p-3",children:i&&(F||p)?o.jsx(gl,{ref:qe,interviewId:s,interview_duration:a,showProctoringUI:!1,onSetReference:()=>{oe.current&&(clearInterval(oe.current),oe.current=null),A(!1),t()}}):o.jsx("video",{ref:c,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-h-64 iw-w-full iw-rounded-2xl iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:Te}})}),o.jsx("div",{className:"iw-relative iw-grid iw-grid-cols-2 iw-gap-4 iw-px-1",children:!b&&!F?o.jsxs(o.Fragment,{children:[o.jsx(no,{onClick:re,disabled:B,variant:"outline",size:"sm",className:"iw-font-medium",style:{borderColor:de,borderRadius:Te,color:de},children:f?"Recheck permissions":"Enable camera & mic"}),o.jsx(Qe,{onClick:Xe,disabled:!f,className:"iw-h-10 iw-px-6 iw-text-sm",style:{backgroundColor:de},children:"Proceed"})]}):i&&(b&&!F?o.jsx(Qe,{onClick:()=>g(!0),disabled:!f,className:"iw-h-10 iw-px-6 iw-text-sm iw-col-span-2",style:{backgroundColor:de},children:"Calibrate Face Position"}):o.jsxs(Qe,{onClick:V,disabled:p||!f,className:"iw-h-10 iw-px-6 iw-text-sm iw-col-span-2",style:{backgroundColor:de},children:[p?"Calibrating":"Start Calibration",p&&o.jsx("span",{className:"iw-ml-2 iw-animate-spin iw-inline-block iw-border-2 iw-border-t-transparent iw-border-stone-200 iw-size-4 iw-rounded-full","aria-label":"loading"})]}))})]}),i&&F?o.jsxs("span",{className:"iw-text-slate-700 iw-text-center iw-text-md",children:["Sit upright and look directly into the camera, then press the",o.jsx("span",{className:"iw-font-semibold",children:" Start Calibration "}),"button. Proper calibration is required and incorrect setup may affect your assessment."]}):o.jsx("ul",{className:"iw-grid sm:iw-grid-cols-1 iw-gap-3",children:Qt.map(({Icon:j,label:J,description:Dt,status:Rt,toneClass:Jt})=>o.jsx("li",{className:"iw-rounded-2xl iw-border iw-border-slate-200/65 iw-bg-white iw-p-4 iw-shadow-sm iw-transition-all hover:iw-border-slate-200",children:o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[o.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-none iw-items-center iw-justify-center iw-rounded-xl iw-bg-slate-100",children:o.jsx(j,{className:"iw-h-5 iw-w-5 iw-text-slate-600"})}),o.jsxs("div",{className:"iw-flex-1",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-gap-3",children:[o.jsx("p",{className:"iw-text-sm iw-font-medium iw-text-slate-800",children:J}),o.jsx("span",{className:`iw-rounded-full iw-px-3 iw-py-1 iw-text-[11px] iw-font-semibold ${Jt}`,children:Rt})]}),o.jsx("p",{className:"iw-mt-1.5 iw-text-xs iw-text-slate-500",children:Dt})]})]})},J))}),C&&o.jsx("div",{className:"iw-rounded-lg iw-border iw-border-rose-200 iw-bg-rose-50 iw-px-3 iw-py-2 iw-text-xs iw-text-rose-600",children:C}),!((ht=navigator.mediaDevices)!=null&&ht.getUserMedia)&&o.jsx("div",{className:"iw-rounded-lg iw-border iw-border-amber-200 iw-bg-amber-50 iw-px-3 iw-py-2 iw-text-xs iw-text-amber-700",children:"Your browser does not support media devices. Please use a modern browser like Chrome, Edge, or Firefox."})]})]}),o.jsx("div",{className:" iw-rounded-2xl iw-border iw-border-dashed iw-border-slate-200 iw-bg-slate-50/85 iw-px-5 iw-py-4 iw-text-center",children:o.jsx("div",{className:"iw-text-xs iw-text-slate-500",children:"Your session is monitored to protect exam integrity. Continuing confirms you have reviewed and accept these safeguards."})}),o.jsx("div",{"aria-hidden":!0,className:"iw-pointer-events-none iw-absolute iw-inset-x-0 iw-bottom-1 iw-h-20",style:{backgroundImage:kt,backgroundSize:"100% 120%, 100% 120%, 100% 120%, 32px 32px",backgroundPosition:"center bottom, left 95% bottom, right 95% bottom, center bottom",backgroundRepeat:"no-repeat, no-repeat, no-repeat, repeat",opacity:.9,transform:"translateY(4px)",maskImage:"linear-gradient(to top, rgba(0,0,0,0.92), transparent)",WebkitMaskImage:"linear-gradient(to top, rgba(0,0,0,0.92), transparent)"}})]})]}),o.jsx(Kl,{isOpen:m,onDecline:()=>g(!1),onContinue:()=>{g(!1),Ke(),T(!0)}})]})};var se=(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))(se||{});const Jd={thinkingDuration:30,answeringDuration:120,editingDuration:30},Zd={idle:{next:"fetching_question"},fetching_question:{next:"reading_question"},reading_question:{next:"thinking"},thinking:{next:"answering",duration:30},answering:{next:"transcribing",duration:120},transcribing:{next:"editing"},editing:{next:"submitting",duration:30},submitting:{next:"completed"},completed:{next:"completed"}};class eh{constructor(t={},r={}){Oe(this,"config");Oe(this,"state");Oe(this,"phaseIntervalId",null);Oe(this,"globalIntervalId",null);Oe(this,"callbacks");this.config={...Jd,...t},this.callbacks=r,this.state={phase:"idle",currentPhaseTimeRemaining:0,totalTimeElapsed:0,currentQuestionNumber:0}}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,r=Zd[t];if(!r)return;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()}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 th(e={}){const{config:t={},callbacks:r={}}=e,i=d.useRef(null);i.current||(i.current=new eh(t,{}));const n=i.current,[s,a]=d.useState(n.getState()),c=d.useCallback(()=>{a(n.getState())},[n]);d.useEffect(()=>{const f={onPhaseChange:(w,m)=>{var g;c(),(g=r.onPhaseChange)==null||g.call(r,w,m)},onTick:w=>{var m;c(),(m=r.onTick)==null||m.call(r,w)},onInterviewEnd:()=>{var w;c(),(w=r.onInterviewEnd)==null||w.call(r)}};n.callbacks=f},[n,r,c]),d.useEffect(()=>()=>{n.destroy()},[n]);const l=d.useCallback(()=>{n.startQuestion(),c()},[n,c]),u=d.useCallback(()=>{n.nextPhase(),c()},[n,c]),h=d.useCallback(()=>{n.completeInterview(),c()},[n,c]);return{state:s,startQuestion:l,nextPhase:u,completeInterview:h,timerService:n}}function rh(e,t={}){const[r,i]=d.useState({data:null,loading:!1,error:null}),n=d.useCallback(async(...s)=>{var a,c,l,u;i(h=>({...h,loading:!0,error:null}));try{const h=await e(...s);i(f=>({...f,data:h,loading:!1,error:null})),(a=t.onSuccess)==null||a.call(t,h),(c=t.onSettled)==null||c.call(t,h,null)}catch(h){const f=h.type?h:{type:"unknown",message:h.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:h};i(w=>({...w,loading:!1,error:f})),(l=t.onError)==null||l.call(t,f),(u=t.onSettled)==null||u.call(t,null,f)}},[e,t]);return{...r,execute:n}}const ih=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 m=>{var g;try{if(!a())throw new Error("Fullscreen is not supported in this environment");m.requestFullscreen?await m.requestFullscreen():m.webkitRequestFullscreen?await m.webkitRequestFullscreen():m.mozRequestFullScreen?await m.mozRequestFullScreen():m.msRequestFullscreen&&await m.msRequestFullscreen()}catch(b){const _={name:"FullscreenError",message:b instanceof Error?b.message:"Failed to enter fullscreen"};r(_),(g=e==null?void 0:e.onError)==null||g.call(e,_)}},u=async()=>{var m;try{s.exitFullscreen?await s.exitFullscreen():s.webkitExitFullscreen?await s.webkitExitFullscreen():s.mozCancelFullScreen?await s.mozCancelFullScreen():s.msExitFullscreen&&await s.msExitFullscreen()}catch(g){const b={name:"FullscreenError",message:g instanceof Error?g.message:"Failed to exit fullscreen"};r(b),(m=e==null?void 0:e.onError)==null||m.call(e,b)}},h=d.useCallback(()=>{var g;const m=!!c();n(m),(g=e==null?void 0:e.onFullScreenChange)==null||g.call(e,m)},[e]);d.useEffect(()=>{const m=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return m.forEach(g=>{document.addEventListener(g,h)}),()=>{m.forEach(g=>{document.removeEventListener(g,h)})}},[h]);const f=async m=>{r(null);const g=m??document.documentElement;await l(g)};return{isFullScreen:i,toggleFullScreen:async m=>{i?await u():await f(m)},enterFullScreen:f,exitFullScreen:u,error:t}},nh=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])},sh=(e={})=>{const[t,r]=d.useState(!1),[i,n]=d.useState(!1),[s,a]=d.useState(null),[c,l]=d.useState(null),[u,h]=d.useState(null);e.config&&Nr.updateConfig(e.config);const f=d.useCallback(async b=>{var _;try{l(null),a(null),h(null),await Nr.startRecording(b,{onStart:()=>{var p;r(!0),(p=e.onStart)==null||p.call(e)},onStop:()=>{var p;r(!1),(p=e.onStop)==null||p.call(e)},onError:p=>{var F;const A=p instanceof te?p:new te(p.message,"RECORDING_ERROR",!0);l(A),r(!1),(F=e.onError)==null||F.call(e,A)}})}catch(p){const A=p instanceof te?p:new te(p instanceof Error?p.message:String(p),"START_FAILED",!1);throw l(A),r(!1),(_=e.onError)==null||_.call(e,A),A}},[]),w=d.useCallback(async()=>{var b,_;try{const p=await Nr.stopRecording();return h(p),r(!1),(b=e.onStop)==null||b.call(e),p}catch(p){const A=p instanceof te?p:new te(p instanceof Error?p.message:String(p),"STOP_FAILED",!1);throw l(A),r(!1),(_=e.onError)==null||_.call(e,A),A}},[]),m=d.useCallback(async(b,_={})=>{var p,A;try{l(null),n(!0);const F={audioBlob:b,..._},T=await Nr.transcribe(F);return a(T.transcript),n(!1),(p=e.onTranscriptionComplete)==null||p.call(e,T),T}catch(F){const T=F instanceof te?F:new te(F instanceof Error?F.message:String(F),"TRANSCRIPTION_FAILED",!0);throw l(T),n(!1),(A=e.onError)==null||A.call(e,T),T}},[]),g=d.useCallback(()=>{Nr.cancelRecording(),r(!1),h(null)},[]);return{startRecording:f,stopRecording:w,transcribe:m,cancelRecording:g,isRecording:t,isTranscribing:i,transcript:s,error:c,audioBlob:u}},oh=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])},ah=()=>{d.useEffect(()=>{const e=document.createElement("style");return e.textContent=`
24
24
  * {
25
25
  -webkit-user-select: none !important;
26
26
  -moz-user-select: none !important;
@@ -33,7 +33,7 @@
33
33
  -ms-user-select: text !important;
34
34
  user-select: text !important;
35
35
  }
36
- `,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[])};class ah{constructor(){Oe(this,"currentAudio",null)}async play(t,r){var i,n;try{if(this.stop(),(i=r==null?void 0:r.onStart)==null||i.call(r),!t)throw new Error("No audio data provided");const s=window.atob(t),a=new Uint8Array(s==null?void 0:s.length);for(let u=0;u<(s==null?void 0:s.length);u++)a[u]=s==null?void 0:s.charCodeAt(u);const c=new Blob([a],{type:"audio/wav"}),l=URL.createObjectURL(c);return this.currentAudio=new Audio(l),new Promise((u,h)=>{if(!this.currentAudio){h(new Error("Audio element not created"));return}const f=this.currentAudio;f.onended=()=>{var w;URL.revokeObjectURL(l),this.currentAudio=null,(w=r==null?void 0:r.onEnd)==null||w.call(r),u()},f.onerror=w=>{var g;URL.revokeObjectURL(l),this.currentAudio=null;const m=new Error(`Audio playback failed: ${w}`);(g=r==null?void 0:r.onError)==null||g.call(r,m),h(m)},f.play().catch(w=>{var g;URL.revokeObjectURL(l),this.currentAudio=null;const m=new Error(`Failed to play audio: ${w.message}`);(g=r==null?void 0:r.onError)==null||g.call(r,m),h(m)})})}catch(s){const a=s instanceof Error?s:new Error(`TTS Error: ${String(s)}`);throw(n=r==null?void 0:r.onError)==null||n.call(r,a),a}}stop(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.currentTime=0,this.currentAudio=null)}isPlaying(){return this.currentAudio!==null&&!this.currentAudio.paused}}const ml=new ah,ch=(e={})=>{const[t,r]=d.useState(!1),[i,n]=d.useState(!1),[s,a]=d.useState(null),c=d.useCallback(async u=>{var h;try{a(null),n(!0),await ml.play(u,{onStart:()=>{var f;n(!1),r(!0),(f=e.onStart)==null||f.call(e)},onEnd:()=>{var f;r(!1),(f=e.onEnd)==null||f.call(e)},onError:f=>{var w;r(!1),n(!1),a(f),(w=e.onError)==null||w.call(e,f)}})}catch(f){const w=f instanceof Error?f:new Error(String(f));throw a(w),r(!1),n(!1),(h=e.onError)==null||h.call(e,w),w}},[e]),l=d.useCallback(()=>{ml.stop(),r(!1),n(!1)},[]);return{speak:c,stop:l,isPlaying:t,isLoading:i,error:s}},lh=({onViolation:e,onEnd:t,maxViolations:r=5})=>{const{addViolation:i}=Rl(),n=Pl(),s=Dl(),a=d.useRef(s);d.useEffect(()=>{a.current=s},[s]);const c=d.useCallback(u=>{t&&t(u,a.current)},[t]);return{logViolation:d.useCallback(({type:u,severity:h,details:f})=>{const w={id:Vl(),type:u,severity:h,details:f,timestamp:Date.now()};i(w);const m=a.current+1;e&&e(w,m),m>=r&&c("excessive_violations")},[i,e,r,c]),onInterviewEnd:c,violationCount:s,logList:n}},uh=()=>{d.useEffect(()=>{function e(){console.clear(),console.log(`
36
+ `,document.head.appendChild(e),()=>{document.head.removeChild(e)}},[])};class ch{constructor(){Oe(this,"currentAudio",null)}async play(t,r){var i,n;try{if(this.stop(),(i=r==null?void 0:r.onStart)==null||i.call(r),!t)throw new Error("No audio data provided");const s=window.atob(t),a=new Uint8Array(s==null?void 0:s.length);for(let u=0;u<(s==null?void 0:s.length);u++)a[u]=s==null?void 0:s.charCodeAt(u);const c=new Blob([a],{type:"audio/wav"}),l=URL.createObjectURL(c);return this.currentAudio=new Audio(l),new Promise((u,h)=>{if(!this.currentAudio){h(new Error("Audio element not created"));return}const f=this.currentAudio;f.onended=()=>{var w;URL.revokeObjectURL(l),this.currentAudio=null,(w=r==null?void 0:r.onEnd)==null||w.call(r),u()},f.onerror=w=>{var g;URL.revokeObjectURL(l),this.currentAudio=null;const m=new Error(`Audio playback failed: ${w}`);(g=r==null?void 0:r.onError)==null||g.call(r,m),h(m)},f.play().catch(w=>{var g;URL.revokeObjectURL(l),this.currentAudio=null;const m=new Error(`Failed to play audio: ${w.message}`);(g=r==null?void 0:r.onError)==null||g.call(r,m),h(m)})})}catch(s){const a=s instanceof Error?s:new Error(`TTS Error: ${String(s)}`);throw(n=r==null?void 0:r.onError)==null||n.call(r,a),a}}stop(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.currentTime=0,this.currentAudio=null)}isPlaying(){return this.currentAudio!==null&&!this.currentAudio.paused}}const pl=new ch,lh=(e={})=>{const[t,r]=d.useState(!1),[i,n]=d.useState(!1),[s,a]=d.useState(null),c=d.useCallback(async u=>{var h;try{a(null),n(!0),await pl.play(u,{onStart:()=>{var f;n(!1),r(!0),(f=e.onStart)==null||f.call(e)},onEnd:()=>{var f;r(!1),(f=e.onEnd)==null||f.call(e)},onError:f=>{var w;r(!1),n(!1),a(f),(w=e.onError)==null||w.call(e,f)}})}catch(f){const w=f instanceof Error?f:new Error(String(f));throw a(w),r(!1),n(!1),(h=e.onError)==null||h.call(e,w),w}},[e]),l=d.useCallback(()=>{pl.stop(),r(!1),n(!1)},[]);return{speak:c,stop:l,isPlaying:t,isLoading:i,error:s}},uh=({onViolation:e,onEnd:t,maxViolations:r=5})=>{const{addViolation:i}=Ol(),n=Dl(),s=Rl(),a=d.useRef(s);d.useEffect(()=>{a.current=s},[s]);const c=d.useCallback(u=>{t&&t(u,a.current)},[t]);return{logViolation:d.useCallback(({type:u,severity:h,details:f})=>{const w={id:$l(),type:u,severity:h,details:f,timestamp:Date.now()};i(w);const m=a.current+1;e&&e(w,m),m>=r&&c("excessive_violations")},[i,e,r,c]),onInterviewEnd:c,violationCount:s,logList:n}},dh=()=>{d.useEffect(()=>{function e(){console.clear(),console.log(`
37
37
  %c
38
38
  ╔═══════════════════════════════════════════════════════════════════════╗
39
39
  ║ ║
@@ -79,7 +79,7 @@
79
79
  │ │
80
80
  │ 💡 IMMEDIATE ACTION REQUIRED: │
81
81
  │ Close developer tools to continue interview │
82
- └─────────────────────────────────────────────────────────────┘`,"color: #ffd93d; font-size: 14px; font-family: monospace; background: rgba(255, 217, 61, 0.1); padding: 10px;")}const t={open:!1,orientation:null},r=160,i=setInterval(()=>{window.outerHeight-window.innerHeight>r||window.outerWidth-window.innerWidth>r?t.open||(t.open=!0,t.orientation=window.outerWidth-window.innerWidth>r?"vertical":"horizontal",e()):t.open&&(t.open=!1,console.log("%c🌟 Developer tools closed. Interview continues smoothly! ✨","color: #4ecdc4; font-weight: bold; text-shadow: 0 0 10px #4ecdc4;"))},500),n=a=>{if(a.keyCode===123||a.ctrlKey&&a.shiftKey&&(a.keyCode===73||a.keyCode===74)||a.ctrlKey&&a.keyCode===85)return a.preventDefault(),console.log("%c🎭 Nice try! Keyboard shortcuts are disabled during interviews ✨","color: #ffd93d; font-weight: bold; text-shadow: 0 0 10px #ffd93d;"),!1},s=a=>(a.preventDefault(),console.log("%c🌈 Right-click menu disabled for interview integrity! 🎪","color: #ff9ff3; font-weight: bold; text-shadow: 0 0 10px #ff9ff3;"),!1);return document.addEventListener("keydown",n),document.addEventListener("contextmenu",s),()=>{clearInterval(i),document.removeEventListener("keydown",n),document.removeEventListener("contextmenu",s),delete window.showStats,delete window.interviewTips}},[])},dh=(e,t,r)=>Math.max(t,Math.min(r,e)),gl=e=>{const t=Math.max(0,Math.floor(e)),r=Math.floor(t/60).toString().padStart(2,"0"),i=(t%60).toString().padStart(2,"0");return`${r}:${i}`},Ws=({total:e,remaining:t,size:r=64,strokeWidth:i=6,className:n="",showLabel:s=!0})=>{const a=Math.max(1,e||1),c=dh(t/a,0,1),{radius:l,circumference:u,dashOffset:h,center:f}=d.useMemo(()=>{const g=(r-i)/2,b=2*Math.PI*g,_=b*(1-c),p=Math.round(i)%2===1,A=r/2+(p?.5:0);return{radius:g,circumference:b,dashOffset:_,center:A}},[r,i,c]),w=d.useMemo(()=>c<=.25?"iw-stroke-red-500":c<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[c]),m=c<=.25?"iw-animate-pulse":"";return o.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${n}`,style:{width:r,height:r},"aria-label":`Time remaining ${gl(t)}`,role:"timer","aria-live":"polite",children:[o.jsx("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,preserveAspectRatio:"xMidYMid meet",children:o.jsxs("g",{transform:`rotate(-90 ${f} ${f})`,children:[o.jsx("circle",{cx:f,cy:f,r:l,className:"iw-stroke-gray-200",strokeWidth:i,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),o.jsx("circle",{cx:f,cy:f,r:l,className:`${w} ${m}`,strokeWidth:i,strokeLinecap:"round",fill:"none",strokeDasharray:u,strokeDashoffset:h,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),s&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:o.jsx("span",{className:`iw-text-[11px] iw-font-semibold iw-tabular-nums ${c<=.25?"iw-text-red-600":c<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:gl(t)})})]})},hh=({label:e,error:t,fullWidth:r=!1,className:i="",id:n,...s})=>{const a=n||`textarea-${Math.random().toString(36).substring(2,9)}`,c="iw-block iw-rounded-md iw-border iw-border-gray-300 iw-shadow-sm iw-px-4 iw-py-2 iw-text-sm iw-transition-all",l=t?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",u=r?"iw-w-full":"",h=i.includes("iw-h-full")||r?"iw-h-full":"";return o.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${r?"iw-w-full":""}`,children:[e&&o.jsx("label",{htmlFor:a,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:e}),o.jsx("textarea",{id:a,className:`${c} ${l} ${u} ${h} ${i}`,"aria-invalid":t?"true":"false",...s}),t&&o.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:t})]})},fh=({value:e,onChange:t,onSubmit:r,isSubmitDisabled:i,state:n,editingTime:s})=>{const a=c=>{c.key==="Enter"&&(c.ctrlKey||c.metaKey)&&!i&&(c.preventDefault(),r())};return o.jsxs("div",{className:"iw-flex iw-flex-col iw-h-full ",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Your Answer"}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(an,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to edit: "})]}),o.jsx(Ws,{total:s,remaining:n.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),o.jsxs("div",{className:" iw-overflow-hidden iw-flex iw-flex-col iw-h-full iw-mt-2",children:[o.jsx(hh,{value:e,onChange:t,onKeyDown:a,placeholder:"Type your answer here...",className:" iw-w-full iw-h-full iw-flex-1 iw-resize-none !iw-p-4 iw-bg-transparent iw-min-h-full focus-visible:iw-outline-0",onPaste:c=>c.preventDefault(),onCopy:c=>c.preventDefault(),onCut:c=>c.preventDefault(),onDrop:c=>c.preventDefault(),onDragOver:c=>c.preventDefault(),disabled:n.phase===ie.SUBMITTING}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1 iw-mt-4",children:o.jsx(qe,{onClick:r,disabled:i,className:n.phase===ie.SUBMITTING?"iw-opacity-75":"",children:n.phase===ie.SUBMITTING?"Submitting...":"Submit Answer"})})]})]})},wh=({question:e,isLoading:t=!1})=>{const{baseColor:r}=nr();return o.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-p-6 ",style:Ul(r,.85),children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-8",children:[o.jsx("div",{className:"iw-flex iw-flex-col iw-items-center iw-relative iw-h-32 iw-w-32 iw-shrink-0 iw-shadow iw-rounded-lg iw-bg-white",children:o.jsx("div",{className:"iw-mt-2",children:o.jsx("img",{src:"https://duf9q5sx7u.ufs.sh/f/va7H6eSeKAux755zByRN5Nq9LZurgIoJGYX6c0CEdRSDm8y2",alt:"brand_logo",className:"iw-h-28 iw-w-28"})})}),t?o.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[o.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),o.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]}):o.jsx("p",{className:"iw-text-lg iw-leading-8",children:e==null?void 0:e.question})]})})},pl=({currentQuestion:e,phase:t,className:r="",children:i,interviewId:n="",interview_duration:s=ti,videoFeedRef:a})=>o.jsxs("div",{className:`iw-p-4 iw-space-y-4 iw-pb-6 ${r} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,children:[o.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3",children:o.jsx("div",{className:"iw-flex-1",children:o.jsx(wh,{question:e,isLoading:t===ie.FETCHING_QUESTION||t===ie.IDLE})})}),o.jsxs("div",{className:"iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-[14px] iw-p-6",children:[o.jsx("div",{className:"iw-min-h-[400px] iw-max-h-[600px]",children:o.jsx(wl,{ref:a,interviewId:n,interview_duration:s})}),o.jsx("div",{className:"iw-bg-white iw-rounded-r-xl iw-shadow iw-p-6",children:i})]})]}),mh=({confirmExitInterview:e,isOpen:t,onClose:r})=>o.jsx(ii,{isOpen:t,onClose:r,title:"Exit Interview",closeOnOverlayClick:!1,children:o.jsxs("div",{className:"iw-space-y-5",children:[o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-rounded-xl iw-p-2",children:[o.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-none iw-items-center iw-justify-center iw-rounded-full iw-bg-rose-100 iw-text-rose-600",children:"!"}),o.jsxs("div",{className:"iw-space-y-2",children:[o.jsx("p",{className:"iw-text-sm iw-font-semibold iw-text-rose-600",children:"Leaving now will end your interview !"}),o.jsx("p",{className:"iw-text-sm iw-text-slate-500",children:"Are you sure you want to exit? All progress will be lost and you will not be able to resume."})]})]}),o.jsxs("div",{className:"iw-flex iw-flex-col-reverse iw-gap-2 sm:iw-flex-row sm:iw-items-center sm:iw-justify-end iw-pb-1",children:[o.jsx("button",{className:"iw-inline-flex iw-items-center iw-justify-center iw-rounded-lg iw-border iw-border-slate-200 iw-bg-white iw-px-4 iw-py-2 iw-text-sm iw-font-medium iw-text-slate-600 iw-shadow-sm iw-transition hover:iw-bg-slate-50",onClick:r,children:"Stay in interview"}),o.jsx("button",{className:"iw-inline-flex iw-items-center iw-justify-center iw-rounded-lg iw-px-4 iw-py-2 iw-text-sm iw-font-semibold iw-text-white iw-transition hover:iw-brightness-110",style:{background:"linear-gradient(to right, rgba(244, 63, 94, 0.8), rgba(225, 29, 72, 0.8))",boxShadow:"0 12px 30px -16px rgba(244, 63, 94, 0.65)"},onClick:e,children:"Confirm exit"})]})]})}),xl=({title:e,brandName:t,onExit:r})=>{const{baseColor:i}=nr(),[n,s]=d.useState(!1);return o.jsxs("header",{className:"iw-w-full iw-text-gray-900",children:[o.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-pb-4 iw-pt-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[o.jsx("div",{className:"iw-h-7 iw-w-7 iw-rounded-md iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold",style:{backgroundColor:i},children:Wl(t)}),o.jsx("p",{className:"iw-text-sm iw-font-medium",children:t})]}),o.jsx("h1",{className:"iw-text-base iw-font-bold",children:e}),o.jsx("button",{className:"iw-text-sm iw-text-white iw-px-4 iw-py-2 iw-rounded-md",style:{background:"linear-gradient(to right, rgba(244, 63, 94, 0.8), rgba(225, 29, 72, 0.8))"},onClick:()=>s(!0),children:"Exit Interview"})]}),o.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),o.jsx(mh,{isOpen:n,confirmExitInterview:()=>{r(),s(!1)},onClose:()=>s(!1)})]})},gh=({className:e="",width:t,height:r=56,barWidth:i=3,gap:n=2,fftSize:s=1024,smoothingTimeConstant:a=.8,mediaStream:c,startOnMount:l=!0})=>{const{baseColor:u}=nr(),h=d.useRef(null),f=d.useRef(null),w=d.useRef(null),m=d.useRef(null),g=d.useRef(null),b=d.useRef(null),_=d.useRef(!1),[p,A]=d.useState(null);d.useEffect(()=>{if(t||!f.current)return;const j=f.current,C=()=>{const B=h.current;if(!B)return;const X=j.clientWidth,ee=r;B.width=Math.max(1,Math.floor(X*window.devicePixelRatio||1)),B.height=Math.max(1,Math.floor(ee*window.devicePixelRatio||1))},M=new ResizeObserver(C);return M.observe(j),C(),()=>M.disconnect()},[t,r]),d.useEffect(()=>{if(!t)return;const j=h.current;j&&(j.width=Math.max(1,Math.floor(t*(window.devicePixelRatio||1))),j.height=Math.max(1,Math.floor(r*(window.devicePixelRatio||1))))},[t,r]),d.useEffect(()=>{let j=!1;return(async()=>{try{const M=new(window.AudioContext||window.webkitAudioContext);w.current=M;let B=c;if(!B){if(!l)return;B=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),_.current=!0}if(j)return;const X=M.createAnalyser();X.fftSize=s,X.smoothingTimeConstant=a,m.current=X;const ee=M.createMediaStreamSource(B);g.current=ee,ee.connect(X),F()}catch(M){A((M==null?void 0:M.message)||"Failed to initialize microphone")}})(),()=>{var M,B,X,ee;j=!0,b.current&&cancelAnimationFrame(b.current);try{(M=g.current)==null||M.disconnect()}catch{}try{(B=m.current)==null||B.disconnect()}catch{}_.current&&((ee=((X=g.current)==null?void 0:X.mediaStream)||void 0)==null||ee.getTracks().forEach(ne=>ne.stop())),w.current&&w.current.state!=="closed"&&w.current.close()}},[c,s,a,l]);const F=()=>{const j=h.current,C=m.current;if(!j||!C)return;const M=j.getContext("2d");if(!M)return;const B=window.devicePixelRatio||1,X=j.width,ee=j.height,ne=C.frequencyBinCount,Je=new Uint8Array(ne),se=()=>{b.current=requestAnimationFrame(se),C.getByteTimeDomainData(Je),M.clearRect(0,0,X,ee),M.fillStyle="rgba(0,0,0,0)",M.fillRect(0,0,X,ee);const ct=Math.max(1,Math.floor(i*B)),Te=Math.max(1,Math.floor(n*B)),ve=ct+Te,_t=Math.max(8,Math.floor((X+Te)/ve)),lt=Math.floor(Je.length/_t);for(let pe=0;pe<_t;pe++){const Rt=Math.min(Je.length-1,pe*lt),oe=Je[Rt]/128-1,we=Math.abs(oe),W=Math.pow(we,.6),Ze=Math.max(ee*.06,W*(ee*.9)),kt=pe*ve,T=(ee-Ze)/2,ae=140-Math.min(140,140*we),Ot=85,Zt=48+Math.floor(12*(1-we));M.fillStyle=`${u}`,M.shadowColor=`hsla(${ae}, ${Ot}%, ${Zt}%, ${.25*we})`,M.shadowBlur=8*we;const Bt=Math.min(ct/2,Ze/2);ph(M,kt,T,ct,Ze,Bt),M.fill()}};se()};return o.jsxs("div",{ref:f,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${e}`,style:{height:r},children:[o.jsx("canvas",{ref:h,className:"iw-w-full iw-h-full"}),p&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:o.jsx("span",{className:"iw-text-xs iw-text-red-600 iw-bg-red-50 iw-border iw-border-red-200 iw-px-2 iw-py-1 iw-rounded",children:p})})]})};function ph(e,t,r,i,n,s){const a=Math.min(s,i/2,n/2);e.beginPath(),e.moveTo(t+a,r),e.lineTo(t+i-a,r),e.quadraticCurveTo(t+i,r,t+i,r+a),e.lineTo(t+i,r+n-a),e.quadraticCurveTo(t+i,r+n,t+i-a,r+n),e.lineTo(t+a,r+n),e.quadraticCurveTo(t,r+n,t,r+n-a),e.lineTo(t,r+a),e.quadraticCurveTo(t,r,t+a,r),e.closePath()}const xh=({state:e,answeringTime:t,nextPhase:r,sttError:i})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"You may start speaking now. We're listening...."}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(an,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),o.jsx(Ws,{total:t,remaining:e.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),o.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"Done talking? Click the button to review your answer."})]}),o.jsxs("div",{children:[o.jsx(gh,{}),i&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",i.message]})]}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:o.jsx(qe,{onClick:()=>{r()},children:"Transcribe My Answer"})})]});function yh(){const[e,t]=d.useState(!0),r=d.useMemo(()=>[0,1,2].map(i=>({id:i})),[]);return d.useEffect(()=>{const i=setInterval(()=>{t(n=>!n)},1500);return()=>clearInterval(i)},[]),o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[o.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:r.map((i,n)=>{const s=n*50,a=e?s:s+12,c=e?1:.08,l=n*140;return o.jsx("div",{role:"presentation",className:"iw-absolute iw-w-full iw-rounded-lg iw-p-4 iw-shadow-md iw-bg-gradient-to-b iw-from-gray-50 iw-to-gray-100 iw-overflow-hidden",style:{top:0,transform:`translateY(${a}px)`,opacity:c,transition:`transform 600ms cubic-bezier(.2,.9,.3,1) ${l}ms, opacity 400ms ease ${l}ms`},children:o.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[o.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),o.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[o.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),o.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},i.id)})}),o.jsx("div",{className:"iw-text-center",children:o.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const bh=({size:e="192px",className:t,colors:r,animationDuration:i=20})=>{const s={...{bg:"oklch(95% 0.02 264.695)",c1:"oklch(75% 0.15 350)",c2:"oklch(80% 0.12 200)",c3:"oklch(78% 0.14 280)"},...r},a=parseInt(e.replace("px",""),10),c=a<50?Math.max(a*.008,1):Math.max(a*.015,4),l=a<50?Math.max(a*.004,1.2):Math.max(a*.008,1.5),u=a<50?Math.max(a*.004,.05):Math.max(a*.008,.1),h=a<50?Math.max(a*.004,.5):Math.max(a*.008,2),f=a<30?"0%":a<50?"5%":a<100?"15%":"25%",w=a<30?1.1:a<50?Math.max(l*1.2,1.3):l;return o.jsx("div",{className:`siri-orb ${t}`,style:{width:e,height:e,"--bg":s.bg,"--c1":s.c1,"--c2":s.c2,"--c3":s.c3,"--animation-duration":`${i}s`,"--blur-amount":`${c}px`,"--contrast-amount":w,"--dot-size":`${u}px`,"--shadow-spread":`${h}px`,"--mask-radius":f},children:o.jsx("style",{children:`
82
+ └─────────────────────────────────────────────────────────────┘`,"color: #ffd93d; font-size: 14px; font-family: monospace; background: rgba(255, 217, 61, 0.1); padding: 10px;")}const t={open:!1,orientation:null},r=160,i=setInterval(()=>{window.outerHeight-window.innerHeight>r||window.outerWidth-window.innerWidth>r?t.open||(t.open=!0,t.orientation=window.outerWidth-window.innerWidth>r?"vertical":"horizontal",e()):t.open&&(t.open=!1,console.log("%c🌟 Developer tools closed. Interview continues smoothly! ✨","color: #4ecdc4; font-weight: bold; text-shadow: 0 0 10px #4ecdc4;"))},500),n=a=>{if(a.keyCode===123||a.ctrlKey&&a.shiftKey&&(a.keyCode===73||a.keyCode===74)||a.ctrlKey&&a.keyCode===85)return a.preventDefault(),console.log("%c🎭 Nice try! Keyboard shortcuts are disabled during interviews ✨","color: #ffd93d; font-weight: bold; text-shadow: 0 0 10px #ffd93d;"),!1},s=a=>(a.preventDefault(),console.log("%c🌈 Right-click menu disabled for interview integrity! 🎪","color: #ff9ff3; font-weight: bold; text-shadow: 0 0 10px #ff9ff3;"),!1);return document.addEventListener("keydown",n),document.addEventListener("contextmenu",s),()=>{clearInterval(i),document.removeEventListener("keydown",n),document.removeEventListener("contextmenu",s),delete window.showStats,delete window.interviewTips}},[])},hh=(e,t,r)=>Math.max(t,Math.min(r,e)),xl=e=>{const t=Math.max(0,Math.floor(e)),r=Math.floor(t/60).toString().padStart(2,"0"),i=(t%60).toString().padStart(2,"0");return`${r}:${i}`},Hs=({total:e,remaining:t,size:r=64,strokeWidth:i=6,className:n="",showLabel:s=!0})=>{const a=Math.max(1,e||1),c=hh(t/a,0,1),{radius:l,circumference:u,dashOffset:h,center:f}=d.useMemo(()=>{const g=(r-i)/2,b=2*Math.PI*g,_=b*(1-c),p=Math.round(i)%2===1,A=r/2+(p?.5:0);return{radius:g,circumference:b,dashOffset:_,center:A}},[r,i,c]),w=d.useMemo(()=>c<=.25?"iw-stroke-red-500":c<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[c]),m=c<=.25?"iw-animate-pulse":"";return o.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${n}`,style:{width:r,height:r},"aria-label":`Time remaining ${xl(t)}`,role:"timer","aria-live":"polite",children:[o.jsx("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,preserveAspectRatio:"xMidYMid meet",children:o.jsxs("g",{transform:`rotate(-90 ${f} ${f})`,children:[o.jsx("circle",{cx:f,cy:f,r:l,className:"iw-stroke-gray-200",strokeWidth:i,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),o.jsx("circle",{cx:f,cy:f,r:l,className:`${w} ${m}`,strokeWidth:i,strokeLinecap:"round",fill:"none",strokeDasharray:u,strokeDashoffset:h,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),s&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:o.jsx("span",{className:`iw-text-[11px] iw-font-semibold iw-tabular-nums ${c<=.25?"iw-text-red-600":c<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:xl(t)})})]})},fh=({label:e,error:t,fullWidth:r=!1,className:i="",id:n,...s})=>{const a=n||`textarea-${Math.random().toString(36).substring(2,9)}`,c="iw-block iw-rounded-md iw-border iw-border-gray-300 iw-shadow-sm iw-px-4 iw-py-2 iw-text-sm iw-transition-all",l=t?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",u=r?"iw-w-full":"",h=i.includes("iw-h-full")||r?"iw-h-full":"";return o.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${r?"iw-w-full":""}`,children:[e&&o.jsx("label",{htmlFor:a,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:e}),o.jsx("textarea",{id:a,className:`${c} ${l} ${u} ${h} ${i}`,"aria-invalid":t?"true":"false",...s}),t&&o.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:t})]})},wh=({value:e,onChange:t,onSubmit:r,isSubmitDisabled:i,state:n,editingTime:s})=>{const a=c=>{c.key==="Enter"&&(c.ctrlKey||c.metaKey)&&!i&&(c.preventDefault(),r())};return o.jsxs("div",{className:"iw-flex iw-flex-col iw-h-full ",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Your Answer"}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(ln,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to edit: "})]}),o.jsx(Hs,{total:s,remaining:n.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),o.jsxs("div",{className:" iw-overflow-hidden iw-flex iw-flex-col iw-h-full iw-mt-2",children:[o.jsx(fh,{value:e,onChange:t,onKeyDown:a,placeholder:"Type your answer here...",className:" iw-w-full iw-h-full iw-flex-1 iw-resize-none !iw-p-4 iw-bg-transparent iw-min-h-full focus-visible:iw-outline-0",onPaste:c=>c.preventDefault(),onCopy:c=>c.preventDefault(),onCut:c=>c.preventDefault(),onDrop:c=>c.preventDefault(),onDragOver:c=>c.preventDefault(),disabled:n.phase===se.SUBMITTING}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1 iw-mt-4",children:o.jsx(Qe,{onClick:r,disabled:i,className:n.phase===se.SUBMITTING?"iw-opacity-75":"",children:n.phase===se.SUBMITTING?"Submitting...":"Submit Answer"})})]})]})},mh=({question:e,isLoading:t=!1})=>{const{baseColor:r}=rr();return o.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-p-6 ",style:Gl(r,.85),children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-8",children:[o.jsx("div",{className:"iw-flex iw-flex-col iw-items-center iw-relative iw-h-32 iw-w-32 iw-shrink-0 iw-shadow iw-rounded-lg iw-bg-white",children:o.jsx("div",{className:"iw-mt-2",children:o.jsx("img",{src:"https://duf9q5sx7u.ufs.sh/f/va7H6eSeKAux755zByRN5Nq9LZurgIoJGYX6c0CEdRSDm8y2",alt:"brand_logo",className:"iw-h-28 iw-w-28"})})}),t?o.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[o.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),o.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]}):o.jsx("p",{className:"iw-text-lg iw-leading-8",children:e==null?void 0:e.question})]})})},yl=({currentQuestion:e,phase:t,className:r="",children:i,interviewId:n="",interview_duration:s=ti,videoFeedRef:a})=>o.jsxs("div",{className:`iw-p-4 iw-space-y-4 iw-pb-6 ${r} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,children:[o.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3",children:o.jsx("div",{className:"iw-flex-1",children:o.jsx(mh,{question:e,isLoading:t===se.FETCHING_QUESTION||t===se.IDLE})})}),o.jsxs("div",{className:"iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-[14px] iw-p-6",children:[o.jsx("div",{className:"iw-min-h-[400px] iw-max-h-[600px]",children:o.jsx(gl,{ref:a,interviewId:n,interview_duration:s})}),o.jsx("div",{className:"iw-bg-white iw-rounded-r-xl iw-shadow iw-p-6",children:i})]})]}),gh=({confirmExitInterview:e,isOpen:t,onClose:r})=>o.jsx(ii,{isOpen:t,onClose:r,title:"Exit Interview",closeOnOverlayClick:!1,children:o.jsxs("div",{className:"iw-space-y-5",children:[o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-rounded-xl iw-p-2",children:[o.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-none iw-items-center iw-justify-center iw-rounded-full iw-bg-rose-100 iw-text-rose-600",children:"!"}),o.jsxs("div",{className:"iw-space-y-2",children:[o.jsx("p",{className:"iw-text-sm iw-font-semibold iw-text-rose-600",children:"Leaving now will end your interview !"}),o.jsx("p",{className:"iw-text-sm iw-text-slate-500",children:"Are you sure you want to exit? All progress will be lost and you will not be able to resume."})]})]}),o.jsxs("div",{className:"iw-flex iw-flex-col-reverse iw-gap-2 sm:iw-flex-row sm:iw-items-center sm:iw-justify-end iw-pb-1",children:[o.jsx("button",{className:"iw-inline-flex iw-items-center iw-justify-center iw-rounded-lg iw-border iw-border-slate-200 iw-bg-white iw-px-4 iw-py-2 iw-text-sm iw-font-medium iw-text-slate-600 iw-shadow-sm iw-transition hover:iw-bg-slate-50",onClick:r,children:"Stay in interview"}),o.jsx("button",{className:"iw-inline-flex iw-items-center iw-justify-center iw-rounded-lg iw-px-4 iw-py-2 iw-text-sm iw-font-semibold iw-text-white iw-transition hover:iw-brightness-110",style:{background:"linear-gradient(to right, rgba(244, 63, 94, 0.8), rgba(225, 29, 72, 0.8))",boxShadow:"0 12px 30px -16px rgba(244, 63, 94, 0.65)"},onClick:e,children:"Confirm exit"})]})]})}),bl=({title:e,brandName:t,onExit:r})=>{const{baseColor:i}=rr(),[n,s]=d.useState(!1);return o.jsxs("header",{className:"iw-w-full iw-text-gray-900",children:[o.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-pb-4 iw-pt-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[o.jsx("div",{className:"iw-h-7 iw-w-7 iw-rounded-md iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold",style:{backgroundColor:i},children:zl(t)}),o.jsx("p",{className:"iw-text-sm iw-font-medium",children:t})]}),o.jsx("h1",{className:"iw-text-base iw-font-bold",children:e}),o.jsx("button",{className:"iw-text-sm iw-text-white iw-px-4 iw-py-2 iw-rounded-md",style:{background:"linear-gradient(to right, rgba(244, 63, 94, 0.8), rgba(225, 29, 72, 0.8))"},onClick:()=>s(!0),children:"Exit Interview"})]}),o.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),o.jsx(gh,{isOpen:n,confirmExitInterview:()=>{r(),s(!1)},onClose:()=>s(!1)})]})},ph=({className:e="",width:t,height:r=56,barWidth:i=3,gap:n=2,fftSize:s=1024,smoothingTimeConstant:a=.8,mediaStream:c,startOnMount:l=!0})=>{const{baseColor:u}=rr(),h=d.useRef(null),f=d.useRef(null),w=d.useRef(null),m=d.useRef(null),g=d.useRef(null),b=d.useRef(null),_=d.useRef(!1),[p,A]=d.useState(null);d.useEffect(()=>{if(t||!f.current)return;const T=f.current,C=()=>{const B=h.current;if(!B)return;const G=T.clientWidth,Q=r;B.width=Math.max(1,Math.floor(G*window.devicePixelRatio||1)),B.height=Math.max(1,Math.floor(Q*window.devicePixelRatio||1))},M=new ResizeObserver(C);return M.observe(T),C(),()=>M.disconnect()},[t,r]),d.useEffect(()=>{if(!t)return;const T=h.current;T&&(T.width=Math.max(1,Math.floor(t*(window.devicePixelRatio||1))),T.height=Math.max(1,Math.floor(r*(window.devicePixelRatio||1))))},[t,r]),d.useEffect(()=>{let T=!1;return(async()=>{try{const M=new(window.AudioContext||window.webkitAudioContext);w.current=M;let B=c;if(!B){if(!l)return;B=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),_.current=!0}if(T)return;const G=M.createAnalyser();G.fftSize=s,G.smoothingTimeConstant=a,m.current=G;const Q=M.createMediaStreamSource(B);g.current=Q,Q.connect(G),F()}catch(M){A((M==null?void 0:M.message)||"Failed to initialize microphone")}})(),()=>{var M,B,G,Q;T=!0,b.current&&cancelAnimationFrame(b.current);try{(M=g.current)==null||M.disconnect()}catch{}try{(B=m.current)==null||B.disconnect()}catch{}_.current&&((Q=((G=g.current)==null?void 0:G.mediaStream)||void 0)==null||Q.getTracks().forEach(oe=>oe.stop())),w.current&&w.current.state!=="closed"&&w.current.close()}},[c,s,a,l]);const F=()=>{const T=h.current,C=m.current;if(!T||!C)return;const M=T.getContext("2d");if(!M)return;const B=window.devicePixelRatio||1,G=T.width,Q=T.height,oe=C.frequencyBinCount,qe=new Uint8Array(oe),de=()=>{b.current=requestAnimationFrame(de),C.getByteTimeDomainData(qe),M.clearRect(0,0,G,Q),M.fillStyle="rgba(0,0,0,0)",M.fillRect(0,0,G,Q);const Ye=Math.max(1,Math.floor(i*B)),Te=Math.max(1,Math.floor(n*B)),be=Ye+Te,kt=Math.max(8,Math.floor((G+Te)/be)),dt=Math.floor(qe.length/kt);for(let ge=0;ge<kt;ge++){const Qt=Math.min(qe.length-1,ge*dt),Ke=qe[Qt]/128-1,re=Math.abs(Ke),Xe=Math.pow(re,.6),V=Math.max(Q*.06,Xe*(Q*.9)),ht=ge*be,j=(Q-V)/2,J=140-Math.min(140,140*re),Dt=85,Rt=48+Math.floor(12*(1-re));M.fillStyle=`${u}`,M.shadowColor=`hsla(${J}, ${Dt}%, ${Rt}%, ${.25*re})`,M.shadowBlur=8*re;const Jt=Math.min(Ye/2,V/2);xh(M,ht,j,Ye,V,Jt),M.fill()}};de()};return o.jsxs("div",{ref:f,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${e}`,style:{height:r},children:[o.jsx("canvas",{ref:h,className:"iw-w-full iw-h-full"}),p&&o.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:o.jsx("span",{className:"iw-text-xs iw-text-red-600 iw-bg-red-50 iw-border iw-border-red-200 iw-px-2 iw-py-1 iw-rounded",children:p})})]})};function xh(e,t,r,i,n,s){const a=Math.min(s,i/2,n/2);e.beginPath(),e.moveTo(t+a,r),e.lineTo(t+i-a,r),e.quadraticCurveTo(t+i,r,t+i,r+a),e.lineTo(t+i,r+n-a),e.quadraticCurveTo(t+i,r+n,t+i-a,r+n),e.lineTo(t+a,r+n),e.quadraticCurveTo(t,r+n,t,r+n-a),e.lineTo(t,r+a),e.quadraticCurveTo(t,r,t+a,r),e.closePath()}const yh=({state:e,answeringTime:t,nextPhase:r,sttError:i})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"You may start speaking now. We're listening...."}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(ln,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),o.jsx(Hs,{total:t,remaining:e.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),o.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"Done talking? Click the button to review your answer."})]}),o.jsxs("div",{children:[o.jsx(ph,{}),i&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",i.message]})]}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:o.jsx(Qe,{onClick:()=>{r()},children:"Transcribe My Answer"})})]});function bh(){const[e,t]=d.useState(!0),r=d.useMemo(()=>[0,1,2].map(i=>({id:i})),[]);return d.useEffect(()=>{const i=setInterval(()=>{t(n=>!n)},1500);return()=>clearInterval(i)},[]),o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[o.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:r.map((i,n)=>{const s=n*50,a=e?s:s+12,c=e?1:.08,l=n*140;return o.jsx("div",{role:"presentation",className:"iw-absolute iw-w-full iw-rounded-lg iw-p-4 iw-shadow-md iw-bg-gradient-to-b iw-from-gray-50 iw-to-gray-100 iw-overflow-hidden",style:{top:0,transform:`translateY(${a}px)`,opacity:c,transition:`transform 600ms cubic-bezier(.2,.9,.3,1) ${l}ms, opacity 400ms ease ${l}ms`},children:o.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[o.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),o.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[o.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),o.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},i.id)})}),o.jsx("div",{className:"iw-text-center",children:o.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const vh=({size:e="192px",className:t,colors:r,animationDuration:i=20})=>{const s={...{bg:"oklch(95% 0.02 264.695)",c1:"oklch(75% 0.15 350)",c2:"oklch(80% 0.12 200)",c3:"oklch(78% 0.14 280)"},...r},a=parseInt(e.replace("px",""),10),c=a<50?Math.max(a*.008,1):Math.max(a*.015,4),l=a<50?Math.max(a*.004,1.2):Math.max(a*.008,1.5),u=a<50?Math.max(a*.004,.05):Math.max(a*.008,.1),h=a<50?Math.max(a*.004,.5):Math.max(a*.008,2),f=a<30?"0%":a<50?"5%":a<100?"15%":"25%",w=a<30?1.1:a<50?Math.max(l*1.2,1.3):l;return o.jsx("div",{className:`siri-orb ${t}`,style:{width:e,height:e,"--bg":s.bg,"--c1":s.c1,"--c2":s.c2,"--c3":s.c3,"--animation-duration":`${i}s`,"--blur-amount":`${c}px`,"--contrast-amount":w,"--dot-size":`${u}px`,"--shadow-spread":`${h}px`,"--mask-radius":f},children:o.jsx("style",{children:`
83
83
  @property --angle {
84
84
  syntax: "<angle>";
85
85
  inherits: false;
@@ -184,4 +184,4 @@
184
184
  animation: none;
185
185
  }
186
186
  }
187
- `})})};function vh({ttsError:e}){return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[o.jsx(bh,{size:"80px"}),e&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",e.message]}),o.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const _h=({state:e,thinkingTime:t,nextPhase:r})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),o.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After 30-seconds thinking time, recording will start automatically, or you can begin recording early by clicking the button below."})]}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(an,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),o.jsx(Ws,{total:t,remaining:e.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:o.jsx(qe,{onClick:()=>{r()},children:"Start Answering"})})]}),kh=({sttError:e})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[o.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[o.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),o.jsx("path",{d:"M28.127 14c.276 7.685 6.442 13.851 14.127 14.127-7.684.276-13.85 6.442-14.127 14.127-.275-7.685-6.442-13.851-14.126-14.127 7.684-.276 13.85-6.442 14.126-14.127zM38.937 31.873A7.331 7.331 0 0046 38.937 7.331 7.331 0 0038.937 46a7.331 7.331 0 00-7.064-7.063 7.331 7.331 0 007.064-7.064z",fill:"#fff"}),o.jsx("defs",{children:o.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),o.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1 iw-mt-3",children:"Just a moment... We're analyzing your response"}),o.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After transcription, you'll have 45 sec to review your answer."}),e&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",e.message,e.recoverable&&" (attempting to continue)"]})]}),Qi=5;function Eh({isOpen:e,onClose:t,warningCount:r,violationType:i,onDisqualify:n}){const[s,a]=d.useState(10),c=d.useRef(t);if(d.useEffect(()=>{c.current=t},[t]),d.useEffect(()=>{if(!e)return;const w=setInterval(()=>{a(m=>m<=1?(c.current(),10):m-1)},1e3);return()=>clearInterval(w)},[e]),d.useEffect(()=>{e&&a(10)},[e]),d.useEffect(()=>(e?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[e]),!e)return null;const u=(()=>{switch(i){case"tab_switch":return{title:"Tab Switch Detected",description:"You attempted to switch to another tab or reload application.",icon:o.jsx(co,{className:"iw-h-5 iw-w-5"})};case"fullscreen_exit":return{title:"Full Screen Exit Detected",description:"You attempted to exit full screen mode.",icon:o.jsx(oo,{className:"iw-h-5 iw-w-5"})};case"focus_loss":return{title:"Focus Loss Detected",description:"You lost focus from the interview window.",icon:o.jsx(Zl,{className:"iw-h-5 iw-w-5"})};case"blocked_shortcut":return{title:"Keyboard Shortcut Blocked",description:"You attempted to use a blocked keyboard shortcut.",icon:o.jsx(cn,{className:"iw-h-5 iw-w-5"})};case"right_click_attempt":return{title:"Right Click Attempted",description:"You attempted to use the right click.",icon:o.jsx(eu,{className:"iw-h-5 iw-w-5"})};case"alt_tab_attempt":return{title:"Alt + Tab Attempted",description:"You attempted to use the Alt + Tab shortcut.",icon:o.jsx(cn,{className:"iw-h-5 iw-w-5"})};case"blocked_function_key":return{title:"Function Key Blocked",description:"You attempted to use a blocked function key.",icon:o.jsx(cn,{className:"iw-h-5 iw-w-5"})};default:return{title:"Violation Detected",description:"You attempted to perform an action that is not allowed.",icon:o.jsx(Fr,{className:"iw-h-5 iw-w-5"})}}})(),h=Qi-r,f=()=>{r+1>Qi?n():t()};return o.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-black/60 iw-p-4 iw-backdrop-blur-sm",children:o.jsxs("div",{className:"iw-w-full iw-max-w-md iw-rounded-2xl iw-border iw-border-gray-100 iw-bg-white iw-shadow-xl",children:[o.jsxs("div",{className:"iw-p-6 iw-pb-0",children:[o.jsxs("div",{className:"iw-mb-6 iw-flex iw-items-start iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-12 iw-w-12 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-2xl iw-bg-red-50",children:o.jsx(Fr,{className:"iw-h-6 iw-w-6 iw-text-red-500"})}),o.jsxs("div",{className:"iw-flex-1",children:[o.jsx("h2",{className:"iw-mb-1 iw-text-xl iw-font-semibold iw-text-gray-900",children:"Security Violation"}),o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsx("span",{className:"iw-text-sm iw-text-gray-500",children:"Warning"}),o.jsx("div",{className:"iw-flex iw-gap-1",children:Array.from({length:Qi}).map((w,m)=>o.jsx("div",{className:`iw-h-2 iw-w-2 iw-rounded-full ${m<=r-1?"iw-bg-red-500":"iw-bg-gray-200"}`},m))}),o.jsxs("span",{className:"iw-text-sm iw-text-gray-500",children:["(",r,"/",Qi,")"]})]})]})]}),o.jsx("div",{className:"iw-mb-5 iw-rounded-2xl iw-border iw-border-red-100 iw-p-5",style:{background:"linear-gradient(to right, rgb(254, 242, 242), rgb(254, 245, 235))",borderColor:"rgb(254, 226, 226)"},children:o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-items-center iw-justify-center iw-rounded-xl iw-bg-white iw-shadow-sm",children:u.icon}),o.jsxs("div",{className:"iw-flex-1",children:[o.jsx("h3",{className:"iw-mb-2 iw-font-semibold iw-text-gray-900",children:u.title}),o.jsx("p",{className:"iw-text-sm iw-leading-relaxed iw-text-gray-700",children:u.description}),o.jsxs("div",{className:"iw-mt-3 iw-flex iw-items-center iw-gap-2 iw-text-xs iw-text-red-600",children:[o.jsx(so,{className:"iw-h-3 iw-w-3"}),o.jsx("span",{children:"This action is monitored for interview integrity"})]})]})]})}),o.jsxs("div",{className:"iw-mb-5 iw-grid iw-grid-cols-2 iw-gap-3",children:[o.jsx("div",{className:"iw-rounded-xl iw-border iw-border-amber-200 iw-bg-amber-50 iw-p-4",children:o.jsxs("div",{className:"iw-text-center",children:[o.jsx("div",{className:"iw-mb-1 iw-text-2xl iw-font-bold iw-text-amber-600",children:h}),o.jsx("div",{className:"iw-text-xs iw-font-medium iw-text-amber-700",children:"Warnings Left"})]})}),o.jsx("div",{className:"iw-border-primary-100 iw-bg-primary-50 iw-rounded-xl iw-border iw-p-4",children:o.jsxs("div",{className:"iw-text-center",children:[o.jsxs("div",{className:"iw-mb-1 iw-flex iw-items-center iw-justify-center iw-gap-1.5",children:[o.jsx(Jl,{className:"iw-text-primary-600 iw-h-4 iw-w-4"}),o.jsx("span",{className:"iw-text-primary-600 iw-text-2xl iw-font-bold",children:s})]}),o.jsx("div",{className:"iw-text-primary-700 iw-text-xs iw-font-medium",children:"Auto Close"})]})})]}),h===1&&o.jsx("div",{className:"iw-mb-5 iw-rounded-2xl iw-p-4 iw-text-white",style:{background:"linear-gradient(to right, rgba(220, 38, 38, 0.9), rgba(239, 68, 68, 0.9))"},children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[o.jsx("div",{className:"iw-flex iw-h-8 iw-w-8 iw-items-center iw-justify-center iw-rounded-full iw-bg-white/20",children:o.jsx(Fr,{className:"iw-h-4 iw-w-4"})}),o.jsxs("div",{children:[o.jsx("div",{className:"iw-text-sm iw-font-semibold",children:"Final Warning"}),o.jsx("div",{className:"iw-text-xs iw-text-red-100",children:"Next violation will disqualify you from this interview"})]})]})})]}),o.jsxs("div",{className:"iw-p-6 iw-pt-0",children:[o.jsx(qe,{onClick:f,className:"iw-h-12 iw-w-full iw-rounded-xl iw-bg-gray-800 iw-text-sm iw-font-medium iw-text-white iw-hover:bg-gray-800",children:"I Understand - Continue Interview"}),o.jsx("p",{className:"iw-text-gray-500 iw-mt-3 iw-text-center iw-text-xs",children:"Please maintain focus and avoid switching tabs, exiting fullscreen, using shortcuts or right-clicking."})]})]})})}const Sh=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z"}),o.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),Ah=({showHardReloadWarning:e,onContinue:t})=>{const r=()=>{t()};return o.jsxs(ii,{isOpen:e,onClose:r,closeOnOverlayClick:!1,closeOnEscape:!1,showCloseButton:!1,className:"iw-max-w-lg iw-px-2 iw-rounded-xl",children:[o.jsx("div",{className:"iw-absolute iw-inset-x-0 iw-top-0 iw-h-1 iw-bg-gradient-to-r iw-from-red-500 iw-to-red-600"}),o.jsx("div",{className:"iw-space-y-1 iw-pb-2 iw-pt-3",children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsx(Fr,{className:"iw-w-5 iw-h-5 iw-text-red-500"}),o.jsx("h3",{className:"iw-text-xl iw-font-semibold iw-text-red-500",children:"Full Screen Exit Detected"})]})}),o.jsx("div",{className:"iw-pt-4 iw-pb-6",children:o.jsx("p",{className:"iw-text-center iw-text-sm iw-leading-relaxed iw-text-gray-500/90",children:"Exiting full screen mode or reloading this page during the session is strictly prohibited. Any attempt to do so will be recorded and may lead to penalties."})}),o.jsx("div",{className:"iw-pt-2 iw-pb-4",children:o.jsxs("button",{onClick:r,className:"iw-w-full iw-flex iw-items-center iw-justify-center iw-gap-2 iw-px-4 iw-py-3 iw-bg-gray-100 iw-text-gray-600 iw-rounded-md iw-font-medium iw-transition-colors hover:iw-bg-gray-200 focus:iw-outline-none focus:iw-ring-2 focus:iw-ring-gray-400 focus:iw-ring-offset-2",children:[o.jsx(Sh,{className:"iw-size-4"}),"Continue Session"]})})]})},Th=d.forwardRef(({children:e,onDisqualify:t},r)=>{const[i,n]=d.useState(!1),[s,a]=d.useState(!1),[c,l]=d.useState(!1),[u,h]=d.useState("fullscreen_exit"),{logViolation:f,violationCount:w}=lh({maxViolations:5,onViolation:p=>{s||(n(!0),h(p.type))}}),{enterFullScreen:m,isFullScreen:g,exitFullScreen:b}=rh({onFullScreenChange(p){!p&&!s&&!c&&(n(!0),f({type:"fullscreen_exit",severity:"high",details:{action:"fullscreen_exit",reason:"Attempted to exit full screen mode"}})),p&&l(!1)}});d.useEffect(()=>{m()},[]),d.useImperativeHandle(r,()=>({exitFullScreenIntentionally:async()=>{l(!0),n(!1),a(!1);try{document.fullscreenElement&&await document.exitFullscreen()}catch(p){console.error("Failed to exit fullscreen:",p)}}}),[]),sh(f),ih(f),oh(),uh();const _=()=>{a(!0),b(),n(!1),t==null||t()};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"iw-relative iw-h-full iw-w-full",children:e}),o.jsx(Eh,{warningCount:w,isOpen:i,violationType:u,onClose:()=>{n(!1),m()},onDisqualify:_}),!i&&w>0&&!s&&!c&&o.jsx(Ah,{showHardReloadWarning:!g,logViolation:f,onContinue:m})]})}),jh=({interviewTitle:e,brandName:t="Novara",interviewId:r,onComplete:i,onDisqualify:n,className:s="",videoFeedRef:a})=>{var Ji;const c=ao(),{baseUrl:l,authToken:u}=eo(),{timers:h,stt:f,proctoring:w}=on(),m=d.useRef(null),[g,b]=d.useState(null),[_,p]=d.useState(""),[A,F]=d.useState(ti),j=d.useRef(""),C=d.useRef(null);d.useEffect(()=>{(async()=>{var je;try{const ut=await c.getInterviewConfig(r);(je=ut==null?void 0:ut.data)!=null&&je.duration_in_minutes&&F(ut.data.duration_in_minutes)}catch(ut){console.error("Failed to fetch interview config:",ut)}})()},[r]);const M={thinkingTime:(h==null?void 0:h.thinkingDuration)||30,answeringTime:(h==null?void 0:h.answeringDuration)||120,editingTime:(h==null?void 0:h.editingDuration)||30},{thinkingTime:B,answeringTime:X,editingTime:ee}=M;d.useEffect(()=>{j.current=_},[_]);const ne=d.useRef(!1),{speak:Je,stop:se,error:ct}=ch({onEnd:()=>{ne.current=!1,W()},onError:()=>{ne.current||(ne.current=!0,W())}}),Te=d.useRef(!1),ve=d.useRef(!1),{startRecording:_t,stopRecording:lt,transcribe:pe,error:Rt}=nh({config:{baseUrl:l,provider:f==null?void 0:f.provider,model:f==null?void 0:f.model,language:f==null?void 0:f.language,authToken:u,qnaId:((Ji=C.current)==null?void 0:Ji.qna_id)||"",interviewId:r},onStart:()=>{Te.current=!1,ve.current=!1},onStop:()=>{},onTranscriptionComplete:N=>{p(N.transcript),ve.current||(ve.current=!0,W())},onError:N=>{console.error("STT Error:",N),Te.current||(Te.current=!0,W())}}),{state:oe,startQuestion:we,nextPhase:W,completeInterview:Ze}=eh({config:{thinkingDuration:B,answeringDuration:X,editingDuration:ee},callbacks:{onPhaseChange:N=>{switch(N){case ie.FETCHING_QUESTION:kt();break;case ie.READING_QUESTION:Ot();break;case ie.ANSWERING:Zt();break;case ie.TRANSCRIBING:Bt();break;case ie.SUBMITTING:ae();break}},onInterviewEnd:()=>{i==null||i()}}});d.useEffect(()=>{we()},[]);const{execute:kt,loading:T}=th(async()=>{const N=await c.generateQuestion({interviewId:r});return C.current=N.data,N},{onSuccess:async N=>{N&&N.data&&(p(""),b(N.data),W())},onError:N=>{console.error("Failed to fetch questions:",N)}}),ae=d.useCallback(async()=>{var N;try{await c.submitAnswer({interviewId:r,qnaId:((N=C.current)==null?void 0:N.qna_id)||"",answer:j.current})}catch(je){console.error("Failed to submit answer:",je)}we()},[c,r,we]),Ot=d.useCallback(async()=>{var N;if((N=C.current)!=null&&N.question)if(C.current.question_audio_data_base64)try{ne.current=!1,await Je(C.current.question_audio_data_base64),C.current.is_interview_done&&Ze()}catch(je){console.error("Failed to speak question:",je),W()}else console.warn("No audio data available for question"),await Gl(2e3),W();else W()},[Je,W,Ze]),Zt=d.useCallback(async()=>{try{await _t(X)}catch(N){console.error("Failed to start recording:",N),W()}},[_t,W]),Bt=d.useCallback(async()=>{try{const N=await lt();await pe(N)}catch(N){console.error("STT processing failed:",N),!Te.current&&!ve.current&&(Te.current=!0,W())}},[lt,pe,W]),er=d.useCallback(async N=>{var je;se(),await((je=m.current)==null?void 0:je.exitFullScreenIntentionally());try{await c.exitInterview(r),await c.generateQuestion({interviewId:r,isInterviewDone:!0})}catch(ut){console.error("API call failed:",ut)}finally{N==null||N(),Ze(),sessionStorage.removeItem(rn)}},[r,se,c]),Jr=()=>{const{phase:N}=oe;switch(N){case ie.IDLE:return o.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),o.jsx("p",{className:"iw-max-w-xl iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:`You will be asked a series of behavioral and technical questions. For each one you'll get a short thinking period, then a timed recording window. We'll transcribe your response so you can review and edit it before submitting. Click "Start Interview" when you're ready.`}),o.jsx(qe,{onClick:we,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case ie.FETCHING_QUESTION:return o.jsx(yh,{});case ie.READING_QUESTION:return o.jsx(vh,{ttsError:ct});case ie.THINKING:return o.jsx(_h,{state:oe,thinkingTime:B,nextPhase:W});case ie.ANSWERING:return o.jsx(xh,{state:oe,answeringTime:X,nextPhase:W,sttError:Rt});case ie.TRANSCRIBING:return o.jsx(kh,{sttError:Rt});case ie.EDITING:case ie.SUBMITTING:return o.jsx("div",{className:"iw-space-y-4 iw-h-full",children:o.jsx(fh,{value:_,onChange:je=>p(je.target.value),onSubmit:()=>W(),isSubmitDisabled:!_.trim()||T||oe.phase===ie.SUBMITTING,state:oe,editingTime:ee})});case ie.COMPLETED:return null;default:return null}};return o.jsx(o.Fragment,{children:w!=null&&w.enabled?o.jsxs(Th,{ref:m,onDisqualify:()=>er(n),children:[o.jsx(xl,{title:e,brandName:t,onExit:()=>er()}),o.jsx(pl,{currentQuestion:g,phase:oe.phase,className:s,interviewId:r,interview_duration:A,videoFeedRef:a,children:Jr()})]}):o.jsxs(o.Fragment,{children:[o.jsx(xl,{title:e,brandName:t,onExit:()=>er()}),o.jsx(pl,{currentQuestion:g,phase:oe.phase,className:s,interviewId:r,interview_duration:A,videoFeedRef:a,children:Jr()})]})})},zs=({title:e,brandName:t,interviewId:r,onInterviewEnd:i,onInterviewDisqualify:n,className:s=""})=>{const[a,c]=d.useState(!1),[l,u]=d.useState(!0),[h,f]=d.useState(!1),{proctoring:w}=on(),m=d.useRef(null),g=d.useRef(null),b=(w==null?void 0:w.gazeAnalysisEnabled)===!0,_=()=>{c(!0),u(!1)};return d.useEffect(()=>{if(a&&h&&g.current&&b)try{g.current.setReference()}finally{f(!1)}},[a,h,b]),a?o.jsx("div",{className:"interview-widget-container",children:o.jsx("div",{ref:m,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${s}`,children:o.jsx("div",{className:"iw-h-full iw-flex iw-flex-col",children:o.jsx(jh,{interviewTitle:e??"Interview",brandName:t??"Novara",interviewId:r,className:s,onComplete:i??(()=>{}),onDisqualify:n,videoFeedRef:g})})})}):o.jsx("div",{className:"interview-widget-container",children:o.jsx(Xd,{isOpen:l,gazeEnabled:b,onStart:_,onRequestCalibration:()=>f(!0),videoFeedRef:g,interviewId:r})})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:zs,InterviewWidgetProvider:Zs}),me.InterviewWidget=zs,me.InterviewWidgetProvider=Zs,me.default=zs,Object.defineProperties(me,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
187
+ `})})};function _h({ttsError:e}){return o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[o.jsx(vh,{size:"80px"}),e&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",e.message]}),o.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const kh=({state:e,thinkingTime:t,nextPhase:r})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),o.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After 30-seconds thinking time, recording will start automatically, or you can begin recording early by clicking the button below."})]}),o.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[o.jsx(ln,{className:"iw-size-4 iw-text-orange-600"}),o.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),o.jsx(Hs,{total:t,remaining:e.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),o.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:o.jsx(Qe,{onClick:()=>{r()},children:"Start Answering"})})]}),Eh=({sttError:e,editingDuration:t})=>o.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[o.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[o.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),o.jsx("path",{d:"M28.127 14c.276 7.685 6.442 13.851 14.127 14.127-7.684.276-13.85 6.442-14.127 14.127-.275-7.685-6.442-13.851-14.126-14.127 7.684-.276 13.85-6.442 14.126-14.127zM38.937 31.873A7.331 7.331 0 0046 38.937 7.331 7.331 0 0038.937 46a7.331 7.331 0 00-7.064-7.063 7.331 7.331 0 007.064-7.064z",fill:"#fff"}),o.jsx("defs",{children:o.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),o.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1 iw-mt-3",children:"Just a moment... We're analyzing your response"}),o.jsxs("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:["After transcription, you'll have ",t||30," sec to review your answer."]}),e&&o.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",e.message,e.recoverable&&" (attempting to continue)"]})]}),Qi=5;function Sh({isOpen:e,onClose:t,warningCount:r,violationType:i,onDisqualify:n}){const[s,a]=d.useState(10),c=d.useRef(t);if(d.useEffect(()=>{c.current=t},[t]),d.useEffect(()=>{if(!e)return;const w=setInterval(()=>{a(m=>m<=1?(c.current(),10):m-1)},1e3);return()=>clearInterval(w)},[e]),d.useEffect(()=>{e&&a(10)},[e]),d.useEffect(()=>(e?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[e]),!e)return null;const u=(()=>{switch(i){case"tab_switch":return{title:"Tab Switch Detected",description:"You attempted to switch to another tab or reload application.",icon:o.jsx(uo,{className:"iw-h-5 iw-w-5"})};case"fullscreen_exit":return{title:"Full Screen Exit Detected",description:"You attempted to exit full screen mode.",icon:o.jsx(co,{className:"iw-h-5 iw-w-5"})};case"focus_loss":return{title:"Focus Loss Detected",description:"You lost focus from the interview window.",icon:o.jsx(eu,{className:"iw-h-5 iw-w-5"})};case"blocked_shortcut":return{title:"Keyboard Shortcut Blocked",description:"You attempted to use a blocked keyboard shortcut.",icon:o.jsx(un,{className:"iw-h-5 iw-w-5"})};case"right_click_attempt":return{title:"Right Click Attempted",description:"You attempted to use the right click.",icon:o.jsx(tu,{className:"iw-h-5 iw-w-5"})};case"alt_tab_attempt":return{title:"Alt + Tab Attempted",description:"You attempted to use the Alt + Tab shortcut.",icon:o.jsx(un,{className:"iw-h-5 iw-w-5"})};case"blocked_function_key":return{title:"Function Key Blocked",description:"You attempted to use a blocked function key.",icon:o.jsx(un,{className:"iw-h-5 iw-w-5"})};default:return{title:"Violation Detected",description:"You attempted to perform an action that is not allowed.",icon:o.jsx(Lr,{className:"iw-h-5 iw-w-5"})}}})(),h=Qi-r,f=()=>{r+1>Qi?n():t()};return o.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-black/60 iw-p-4 iw-backdrop-blur-sm",children:o.jsxs("div",{className:"iw-w-full iw-max-w-md iw-rounded-2xl iw-border iw-border-gray-100 iw-bg-white iw-shadow-xl",children:[o.jsxs("div",{className:"iw-p-6 iw-pb-0",children:[o.jsxs("div",{className:"iw-mb-6 iw-flex iw-items-start iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-12 iw-w-12 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-2xl iw-bg-red-50",children:o.jsx(Lr,{className:"iw-h-6 iw-w-6 iw-text-red-500"})}),o.jsxs("div",{className:"iw-flex-1",children:[o.jsx("h2",{className:"iw-mb-1 iw-text-xl iw-font-semibold iw-text-gray-900",children:"Security Violation"}),o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsx("span",{className:"iw-text-sm iw-text-gray-500",children:"Warning"}),o.jsx("div",{className:"iw-flex iw-gap-1",children:Array.from({length:Qi}).map((w,m)=>o.jsx("div",{className:`iw-h-2 iw-w-2 iw-rounded-full ${m<=r-1?"iw-bg-red-500":"iw-bg-gray-200"}`},m))}),o.jsxs("span",{className:"iw-text-sm iw-text-gray-500",children:["(",r,"/",Qi,")"]})]})]})]}),o.jsx("div",{className:"iw-mb-5 iw-rounded-2xl iw-border iw-border-red-100 iw-p-5",style:{background:"linear-gradient(to right, rgb(254, 242, 242), rgb(254, 245, 235))",borderColor:"rgb(254, 226, 226)"},children:o.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[o.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-items-center iw-justify-center iw-rounded-xl iw-bg-white iw-shadow-sm",children:u.icon}),o.jsxs("div",{className:"iw-flex-1",children:[o.jsx("h3",{className:"iw-mb-2 iw-font-semibold iw-text-gray-900",children:u.title}),o.jsx("p",{className:"iw-text-sm iw-leading-relaxed iw-text-gray-700",children:u.description}),o.jsxs("div",{className:"iw-mt-3 iw-flex iw-items-center iw-gap-2 iw-text-xs iw-text-red-600",children:[o.jsx(ao,{className:"iw-h-3 iw-w-3"}),o.jsx("span",{children:"This action is monitored for interview integrity"})]})]})]})}),o.jsxs("div",{className:"iw-mb-5 iw-grid iw-grid-cols-2 iw-gap-3",children:[o.jsx("div",{className:"iw-rounded-xl iw-border iw-border-amber-200 iw-bg-amber-50 iw-p-4",children:o.jsxs("div",{className:"iw-text-center",children:[o.jsx("div",{className:"iw-mb-1 iw-text-2xl iw-font-bold iw-text-amber-600",children:h}),o.jsx("div",{className:"iw-text-xs iw-font-medium iw-text-amber-700",children:"Warnings Left"})]})}),o.jsx("div",{className:"iw-border-primary-100 iw-bg-primary-50 iw-rounded-xl iw-border iw-p-4",children:o.jsxs("div",{className:"iw-text-center",children:[o.jsxs("div",{className:"iw-mb-1 iw-flex iw-items-center iw-justify-center iw-gap-1.5",children:[o.jsx(Zl,{className:"iw-text-primary-600 iw-h-4 iw-w-4"}),o.jsx("span",{className:"iw-text-primary-600 iw-text-2xl iw-font-bold",children:s})]}),o.jsx("div",{className:"iw-text-primary-700 iw-text-xs iw-font-medium",children:"Auto Close"})]})})]}),h===1&&o.jsx("div",{className:"iw-mb-5 iw-rounded-2xl iw-p-4 iw-text-white",style:{background:"linear-gradient(to right, rgba(220, 38, 38, 0.9), rgba(239, 68, 68, 0.9))"},children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[o.jsx("div",{className:"iw-flex iw-h-8 iw-w-8 iw-items-center iw-justify-center iw-rounded-full iw-bg-white/20",children:o.jsx(Lr,{className:"iw-h-4 iw-w-4"})}),o.jsxs("div",{children:[o.jsx("div",{className:"iw-text-sm iw-font-semibold",children:"Final Warning"}),o.jsx("div",{className:"iw-text-xs iw-text-red-100",children:"Next violation will disqualify you from this interview"})]})]})})]}),o.jsxs("div",{className:"iw-p-6 iw-pt-0",children:[o.jsx(Qe,{onClick:f,className:"iw-h-12 iw-w-full iw-rounded-xl iw-bg-gray-800 iw-text-sm iw-font-medium iw-text-white iw-hover:bg-gray-800",children:"I Understand - Continue Interview"}),o.jsx("p",{className:"iw-text-gray-500 iw-mt-3 iw-text-center iw-text-xs",children:"Please maintain focus and avoid switching tabs, exiting fullscreen, using shortcuts or right-clicking."})]})]})})}const Ah=e=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[o.jsx("path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z"}),o.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),Th=({showHardReloadWarning:e,onContinue:t})=>{const r=()=>{t()};return o.jsxs(ii,{isOpen:e,onClose:r,closeOnOverlayClick:!1,closeOnEscape:!1,showCloseButton:!1,className:"iw-max-w-lg iw-px-2 iw-rounded-xl",children:[o.jsx("div",{className:"iw-absolute iw-inset-x-0 iw-top-0 iw-h-1 iw-bg-gradient-to-r iw-from-red-500 iw-to-red-600"}),o.jsx("div",{className:"iw-space-y-1 iw-pb-2 iw-pt-3",children:o.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[o.jsx(Lr,{className:"iw-w-5 iw-h-5 iw-text-red-500"}),o.jsx("h3",{className:"iw-text-xl iw-font-semibold iw-text-red-500",children:"Full Screen Exit Detected"})]})}),o.jsx("div",{className:"iw-pt-4 iw-pb-6",children:o.jsx("p",{className:"iw-text-center iw-text-sm iw-leading-relaxed iw-text-gray-500/90",children:"Exiting full screen mode or reloading this page during the session is strictly prohibited. Any attempt to do so will be recorded and may lead to penalties."})}),o.jsx("div",{className:"iw-pt-2 iw-pb-4",children:o.jsxs("button",{onClick:r,className:"iw-w-full iw-flex iw-items-center iw-justify-center iw-gap-2 iw-px-4 iw-py-3 iw-bg-gray-100 iw-text-gray-600 iw-rounded-md iw-font-medium iw-transition-colors hover:iw-bg-gray-200 focus:iw-outline-none focus:iw-ring-2 focus:iw-ring-gray-400 focus:iw-ring-offset-2",children:[o.jsx(Ah,{className:"iw-size-4"}),"Continue Session"]})})]})},jh=d.forwardRef(({children:e,onDisqualify:t},r)=>{const[i,n]=d.useState(!1),[s,a]=d.useState(!1),[c,l]=d.useState(!1),[u,h]=d.useState("fullscreen_exit"),{logViolation:f,violationCount:w}=uh({maxViolations:5,onViolation:p=>{s||(n(!0),h(p.type))}}),{enterFullScreen:m,isFullScreen:g,exitFullScreen:b}=ih({onFullScreenChange(p){!p&&!s&&!c&&(n(!0),f({type:"fullscreen_exit",severity:"high",details:{action:"fullscreen_exit",reason:"Attempted to exit full screen mode"}})),p&&l(!1)}});d.useEffect(()=>{m()},[]),d.useImperativeHandle(r,()=>({exitFullScreenIntentionally:async()=>{l(!0),n(!1),a(!1);try{document.fullscreenElement&&await document.exitFullscreen()}catch(p){console.error("Failed to exit fullscreen:",p)}}}),[]),oh(f),nh(f),ah(),dh();const _=()=>{a(!0),b(),n(!1),t==null||t()};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"iw-relative iw-h-full iw-w-full",children:e}),o.jsx(Sh,{warningCount:w,isOpen:i,violationType:u,onClose:()=>{n(!1),m()},onDisqualify:_}),!i&&w>0&&!s&&!c&&o.jsx(Th,{showHardReloadWarning:!g,logViolation:f,onContinue:m})]})}),Nh=({interviewTitle:e,brandName:t="Novara",interviewId:r,onComplete:i,onDisqualify:n,className:s="",videoFeedRef:a})=>{var Zi;const c=lo(),{baseUrl:l,authToken:u}=ro(),{timers:h,stt:f,proctoring:w}=cn(),m=d.useRef(null),[g,b]=d.useState(null),[_,p]=d.useState(""),[A,F]=d.useState(ti),T=d.useRef(""),C=d.useRef(null);d.useEffect(()=>{(async()=>{var je;try{const rt=await c.getInterviewConfig(r);(je=rt==null?void 0:rt.data)!=null&&je.duration_in_minutes&&F(rt.data.duration_in_minutes)}catch(rt){console.error("Failed to fetch interview config:",rt)}})()},[r]);const M={thinkingTime:(h==null?void 0:h.thinkingDuration)||30,answeringTime:(h==null?void 0:h.answeringDuration)||120,editingTime:(h==null?void 0:h.editingDuration)||30},{thinkingTime:B,answeringTime:G,editingTime:Q}=M;d.useEffect(()=>{T.current=_},[_]);const oe=d.useRef(!1),{speak:qe,stop:de,error:Ye}=lh({onEnd:()=>{oe.current=!1,V()},onError:()=>{oe.current||(oe.current=!0,V())}}),Te=d.useRef(!1),be=d.useRef(!1),{startRecording:kt,stopRecording:dt,transcribe:ge,cancelRecording:Qt,error:Ke}=sh({config:{baseUrl:l,provider:f==null?void 0:f.provider,model:f==null?void 0:f.model,language:f==null?void 0:f.language,authToken:u,qnaId:((Zi=C.current)==null?void 0:Zi.qna_id)||"",interviewId:r},onStart:()=>{Te.current=!1,be.current=!1},onStop:()=>{},onTranscriptionComplete:N=>{p(N.transcript),be.current||(be.current=!0,V())},onError:N=>{console.error("STT Error:",N),Te.current||(Te.current=!0,V())}}),{state:re,startQuestion:Xe,nextPhase:V,completeInterview:ht}=th({config:{thinkingDuration:B,answeringDuration:G,editingDuration:Q},callbacks:{onPhaseChange:N=>{switch(N){case se.FETCHING_QUESTION:j();break;case se.READING_QUESTION:Rt();break;case se.ANSWERING:Jt();break;case se.TRANSCRIBING:Ji();break;case se.SUBMITTING:Dt();break}},onInterviewEnd:()=>{i==null||i()}}});d.useEffect(()=>{Xe()},[]);const{execute:j,loading:J}=rh(async()=>{const N=await c.generateQuestion({interviewId:r});return C.current=N.data,N},{onSuccess:async N=>{N&&N.data&&(p(""),b(N.data),V())},onError:N=>{console.error("Failed to fetch questions:",N)}}),Dt=d.useCallback(async()=>{var N;try{await c.submitAnswer({interviewId:r,qnaId:((N=C.current)==null?void 0:N.qna_id)||"",answer:T.current})}catch(je){console.error("Failed to submit answer:",je)}Xe()},[c,r,Xe]),Rt=d.useCallback(async()=>{var N;if((N=C.current)!=null&&N.question)if(C.current.question_audio_data_base64)try{oe.current=!1,await qe(C.current.question_audio_data_base64),C.current.is_interview_done&&ht()}catch(je){console.error("Failed to speak question:",je),V()}else console.warn("No audio data available for question"),await Vl(2e3),V();else V()},[qe,V,ht]),Jt=d.useCallback(async()=>{try{await kt(G)}catch(N){console.error("Failed to start recording:",N),V()}},[kt,V]),Ji=d.useCallback(async()=>{try{const N=await dt();await ge(N)}catch(N){console.error("STT processing failed:",N),!Te.current&&!be.current&&(Te.current=!0,V())}},[dt,ge,V]),Zt=d.useCallback(async N=>{var je,rt;de(),Qt(),a&&"current"in a&&((je=a.current)==null||je.stopCamera()),await((rt=m.current)==null?void 0:rt.exitFullScreenIntentionally());try{await c.exitInterview(r)}catch(en){console.error("API call failed:",en)}finally{N==null||N(),ht(),sessionStorage.removeItem(sn)}},[r,de,c]),Qr=()=>{const{phase:N}=re;switch(N){case se.IDLE:return o.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[o.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),o.jsx("p",{className:"iw-max-w-xl iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:`You will be asked a series of behavioral and technical questions. For each one you'll get a short thinking period, then a timed recording window. We'll transcribe your response so you can review and edit it before submitting. Click "Start Interview" when you're ready.`}),o.jsx(Qe,{onClick:Xe,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case se.FETCHING_QUESTION:return o.jsx(bh,{});case se.READING_QUESTION:return o.jsx(_h,{ttsError:Ye});case se.THINKING:return o.jsx(kh,{state:re,thinkingTime:B,nextPhase:V});case se.ANSWERING:return o.jsx(yh,{state:re,answeringTime:G,nextPhase:V,sttError:Ke});case se.TRANSCRIBING:return o.jsx(Eh,{sttError:Ke,editingDuration:Q});case se.EDITING:case se.SUBMITTING:return o.jsx("div",{className:"iw-space-y-4 iw-h-full",children:o.jsx(wh,{value:_,onChange:je=>p(je.target.value),onSubmit:()=>V(),isSubmitDisabled:!_.trim()||J||re.phase===se.SUBMITTING,state:re,editingTime:Q})});case se.COMPLETED:return null;default:return null}};return o.jsx(o.Fragment,{children:w!=null&&w.enabled?o.jsxs(jh,{ref:m,onDisqualify:()=>Zt(n),children:[o.jsx(bl,{title:e,brandName:t,onExit:()=>Zt()}),o.jsx(yl,{currentQuestion:g,phase:re.phase,className:s,interviewId:r,interview_duration:A,videoFeedRef:a,children:Qr()})]}):o.jsxs(o.Fragment,{children:[o.jsx(bl,{title:e,brandName:t,onExit:()=>Zt()}),o.jsx(yl,{currentQuestion:g,phase:re.phase,className:s,interviewId:r,interview_duration:A,videoFeedRef:a,children:Qr()})]})})},qs=({title:e,brandName:t,interviewId:r,onInterviewEnd:i,onInterviewDisqualify:n,className:s=""})=>{const[a,c]=d.useState(!1),[l,u]=d.useState(!0),[h,f]=d.useState(!1),{proctoring:w}=cn(),m=d.useRef(null),g=d.useRef(null),b=(w==null?void 0:w.gazeAnalysisEnabled)===!0,_=()=>{c(!0),u(!1)};return d.useEffect(()=>{if(a&&h&&g.current&&b)try{g.current.setReference()}finally{f(!1)}},[a,h,b]),a?o.jsx("div",{className:"interview-widget-container",children:o.jsx("div",{ref:m,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${s}`,children:o.jsx("div",{className:"iw-h-full iw-flex iw-flex-col",children:o.jsx(Nh,{interviewTitle:e??"Interview",brandName:t??"Novara",interviewId:r,className:s,onComplete:i??(()=>{}),onDisqualify:n,videoFeedRef:g})})})}):o.jsx("div",{className:"interview-widget-container",children:o.jsx(Qd,{isOpen:l,gazeEnabled:b,onStart:_,onRequestCalibration:()=>f(!0),videoFeedRef:g,interviewId:r})})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:qs,InterviewWidgetProvider:to}),we.InterviewWidget=qs,we.InterviewWidgetProvider=to,we.default=qs,Object.defineProperties(we,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});