interview-widget 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +364 -364
- package/dist/components/ui/standalone-dialog.d.ts +13 -0
- package/dist/widget.es.js +869 -770
- package/dist/widget.umd.js +5 -5
- package/package.json +67 -66
package/dist/widget.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
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,Bt){"use strict";var Oh=Object.defineProperty;var Bh=(we,d,Bt)=>d in we?Oh(we,d,{enumerable:!0,configurable:!0,writable:!0,value:Bt}):we[d]=Bt;var Oe=(we,d,Bt)=>Bh(we,typeof d!="symbol"?d+"":d,Bt);var tn=typeof document<"u"?document.currentScript:null,Ks={exports:{}},ei={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
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 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&>(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&>(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`
|
|
9
|
+
*/var Sl=Symbol.for("react.transitional.element"),Tl=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=Tl,ei.jsx=Xs,ei.jsxs=Xs,Ks.exports=ei;var o=Ks.exports;const rn={},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}}},nn="iw-storage";function jl(){if(!(typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:tn&&tn.tagName.toUpperCase()==="SCRIPT"&&tn.src||new URL("widget.umd.js",document.baseURI).href}<"u"&&(rn!=null&&rn.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=jl(),ti=30,Al={SCREENSHOT:"screenshot"},sn="AES-GCM",on=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,sn,!1,["encrypt","decrypt"])}function Nl(){return crypto.getRandomValues(new Uint8Array(on))}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:sn,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,on),s=i.slice(on),a=await Js(t),c=await crypto.subtle.decrypt({name:sn,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(nn);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(nn,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 an(){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})},cn=({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 Bt.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(cn,{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 Ut(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 Gt={v2:"/v2"},Vt={GENERATE_QUESTION:e=>`${Gt.v2}/interviews/${e}/next-question`,SCREENSHOT_UPLOAD:e=>`${Gt.v2}/interviews/${e}/assets/upload-url`,CONFIRM_UPLOAD:e=>`${Gt.v2}/interviews/assets/${e}/confirm`,TRANSCRIBE_ANSWER:e=>`${Gt.v2}/interviews/${e}/transcribe-answer`,SUBMIT_ANSWER:e=>`${Gt.v2}/interviews/${e}/submit-answer`,EXIT:e=>`${Gt.v2}/interviews/${e}/exit`,CONFIG:e=>`${Gt.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 Ut(`${this.getBaseUrl()}${Vt.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 Ut(`${this.getBaseUrl()}${Vt.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 Ut(`${this.getBaseUrl()}${Vt.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 Ut(`${this.getBaseUrl()}${Vt.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 Ut(`${this.getBaseUrl()}${Vt.SCREENSHOT_UPLOAD(t)}`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({filename:r,mime_type:"image/jpeg",asset_type:Al.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 Ut(`${this.getBaseUrl()}${Vt.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(cn,{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 $t(){throw Error("Invalid UTF8")}function ho(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}let ii,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,ni;e:{for(var wo=["CLOSURE_FLAGS"],fn=ir,wn=0;wn<wo.length;wn++)if((fn=fn[wo[wn]])==null){ni=null;break e}ni=fn}var Pr,mo=ni&&ni[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 si(e){return si[" "](e),e}Pr=go&&go.userAgentData||null,si[" "]=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 Wt(e){return yo&&e!=null&&e instanceof Uint8Array}var nr={};function zt(){return pu||(pu=new wt(null,nr))}function pn(e){Eo(nr);var t=e.g;return(t=t==null||Wt(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 oi=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),To=sr(void 0,"0di"),Rr=sr(void 0,"1oa"),or=sr(void 0,Symbol()),bu=sr(void 0,"0actk"),jo=sr(void 0,"8utk");const k=oi?yu:"Ea",Ao={Ea:{value:0,configurable:!0,writable:!0,enumerable:!1}},No=Object.defineProperties;function ai(e,t){oi||k in e||No(e,Ao),e[k]|=t}function ae(e,t){oi||k in e||No(e,Ao),e[k]=t}function ar(e){return ai(e,34),e}function vu(e,t){ae(t,-15615&(0|e))}function bn(e,t){ae(t,-15581&(34|e))}function ci(){return typeof BigInt=="function"}function ke(e){return Array.prototype.slice.call(e)}var vn,Or={};function li(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):zt();else if(e.constructor!==wt)if(Wt(e))e=e.length?new wt(new Uint8Array(e),nr):zt();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 ui(e){return e.Na=!0,e}var ku=ui(e=>typeof e=="number"),Mo=ui(e=>typeof e=="string"),Eu=ui(e=>typeof e=="boolean"),di=typeof ir.BigInt=="function"&&typeof ir.BigInt(0)=="bigint";function Tt(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 di?BigInt(e):e=Eu(e)?e?"1":"0":Mo(e)?e.trim()||"0":String(e)}var En=ui(e=>di?e>=Tu&&e<=Au:e[0]==="-"?Lo(e,Su):Lo(e,ju));const Su=Number.MIN_SAFE_INTEGER.toString(),Tu=di?BigInt(Number.MIN_SAFE_INTEGER):void 0,ju=Number.MAX_SAFE_INTEGER.toString(),Au=di?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 Ht(e){if(e<0){Po(-e);const[t,r]=An(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 Tn(e,t){const r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Br(e,t)}function jn(e,t){const r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Tn(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 ci()?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(ci())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{const[r,i]=An(e,t);e="-"+Br(r,i)}else e=Br(e,t);return e}function hi(e){if(e.length<16)Ht(Number(e));else if(ci())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]=An(U,Z);U=i,Z=n}}}function An(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,jt=Number.isSafeInteger,fi=Number.isFinite,cr=Math.trunc,Iu=Tt(0);function At(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 fi(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 fi(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 fi(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:(hi(e),Ro())}function Nn(e){return e=cr(e),jt(e)||(Ht(e),e=jn(U,Z)),e}function $o(e){var t=cr(Number(e));return jt(t)?String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Vo(e))}function Wo(e){var t=cr(Number(e));return jt(t)?Tt(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),ci()?Tt(Ur(64,BigInt(e))):Tt(Vo(e)))}function zo(e){if(jt(e))e=Tt(Nn(e));else{if(e=cr(e),jt(e))e=String(e);else{const t=String(e);Go(t)?e=t:(Ht(e),e=Ro())}e=Tt(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)),jt(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),Uo(e)||(hi(e),e=Br(U,Z))),e;if(t==="number")return(e=cr(e))>=0&&jt(e)?e:function(r){if(r<0){Ht(r);var i=Br(U,Z);return r=Number(i),jt(r)?r:i}return Uo(i=String(r))?i:(Ht(r),Tn(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[To])||(ar((e=new t).u),e=t[To]=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=Tt(Ur(64,t));break e;default:t=zo(t)}}else e=typeof(t=e),t=t==null?t:e==="bigint"?Tt(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 si(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=gi(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:wi(e,t,r,i!==void 0,n)}return t(e,i)}}function wi(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&&li(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(Wt(e))return Wt(e)&&yn(jo),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=wi(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;li(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&&ai(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(li(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):wi(e,Dn,4&i?bn:r,!0,!0))}return e.W===Or?e=2&(i=0|(r=e.u)[k])?e:new e.constructor(mi(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 mi(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)),ai(e,32|(r?2:0)),e}function gi(e){const t=e.u,r=0|t[k];return 2&r?new e.constructor(mi(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 pi(e,t){let r=0|(e=e.u)[k];const i=mt(e,r,t),n=At(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 qt(){return _u===void 0?2:4}function Yt(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&>(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(oi)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=gi(n))!==n&&K(e,i,r,t),t.u;if(Array.isArray(n)){const a=0|n[k];s=2&a?Nt(mi(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=gi(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 T=!!(2&(0|p.u[k]));m&&(m=!T),g&&(g=T)}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=gi(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&>(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,qt(),!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 xi(e,t,r){St(0|e.u[k]),Yt(e,t,dr,2,!0).push(Ho(r))}function yi(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 pi(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"||!fi(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 bi(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(Kt(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 Kt(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 Kt(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],Kt(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 Kt(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 zt();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?zt():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 vi(e){switch(e.h){case 0:e.h!=0?vi(e):qn(e.g);break;case 1:Kt(e=e.g,e.g+8);break;case 2:if(e.h!=2)vi(e);else{var t=yt(e.g);Kt(e=e.g,e.g+t)}break;case 5:Kt(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}vi(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(ii===void 0){try{i.decode(new Uint8Array([128]))}catch{}try{i.decode(new Uint8Array([97])),ii=!0}catch{ii=!1}}throw!ii&&(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?$t():(c=e[s++],a<194||(192&c)!=128?(s--,$t()):r.push((31&a)<<6|63&c)):a<240?s>=t-1?$t():(c=e[s++],(192&c)!=128||a===224&&c<160||a===237&&c>=160||(192&(i=e[s++]))!=128?(s--,$t()):r.push((15&a)<<12|(63&c)<<6|63&i)):a<=244?s>=t-2?$t():(c=e[s++],(192&c)!=128||c-144+(a<<28)>>30||(192&(i=e[s++]))!=128||(192&(n=e[s++]))!=128?(s--,$t()):(a=(7&a)<<18|(63&c)<<12|(63&i)<<6|63&n,a-=65536,r.push(55296+(a>>10&1023),56320+(1023&a)))):$t(),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 _i(e,t,r){var i=yt(e.g);for(i=e.g.g+i;e.g.g<i;)r.push(t(e.g))}var ki=[];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=jd;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(mi(e,0|e[k],!1))}O(){return!!(2&(0|this.u[k]))}};function da(e){return e?/^\d+$/.test(e)?(hi(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)?(hi(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 Ei(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 Si(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 Ai=Symbol(),os=Symbol(),ya=Symbol(),ba=Symbol();let va,_a;function Xt(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=Xt(os,as,cs,i).T),a||(a=ls(i)),n)}function ls(e){let t=e[ya];if(t!=null)return t;const r=Xt(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,vi(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=Xt(os,as,cs,e).T;return(n,s,a)=>t(n,s,a,i,r)}return t}function Ni(e,t,r){e[t]=r.h}function Ci(e,t,r,i){let n,s;const a=r.h;e[t]=(c,l,u)=>a(c,l,u,s||(s=Xt(Ai,Ni,Ci,i).T),n||(n=Sa(i)))}function Sa(e){let t=e[ba];if(!t){const r=Xt(Ai,Ni,Ci,e);t=(i,n)=>Ta(i,n,r),e[ba]=t}return t}function Ta(e,t,r){(function(i,n,s){const a=512&n?0:-1,c=i.length,l=c+((n=64&n?256&n:!!c&&li(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=Xt(Ai,Ni,Ci,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 ja(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,Ht(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 Aa(e,t,r){(t=lr(t))!=null&&t!=null&&(Ne(e,r,0),Ei(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&&Si(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||(Wt(t)?Wt(t)&&yn(jo):t=void 0),t!=null&&Si(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?_i(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=At(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=At(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(At,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(At,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,jn)),!0)},ja,ma),ds=pe(function(e,t,r){return e.h===0&&(xe(t,r,(e=Hn(e.g,jn))===0?void 0:e),!0)},ja,ma),Zu=pe(function(e,t,r){return e.h===0&&(xe(t,r,Hn(e.g,Tn)),!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,Ht(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)},Aa,ns),Ii=yr(function(e,t,r){return(e.h===0||e.h===2)&&(t=fr(t,0|t[k],r,!1),e.h==2?_i(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++)Ei(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)},Aa,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&&Si(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?_i(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),Ei(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(){si(this)}}function et(e,t){return new rd(e,t)}function Ft(e,t){return(r,i)=>{if(ki.length){const s=ki.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,ki.length<100&&ki.push(r)}return n}}function Mi(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}}}};Ta(this.u,t,Xt(Ai,Ni,Ci,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))===zt()?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&&Si(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,Ii,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?_i(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++)Ei(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,Ii],-1,O,[0,me],-1,ue,[0,R,-1]],R];var za=[0,ds,-1,vr,-3,ds,Ii,Lt,br,ds,-1,vr,br,vr,-2,Lt];function Me(e,t){Bn(e,2,ur(t),"")}function W(e,t){xi(e,3,t)}function L(e,t){xi(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){yi(e,1,ye,t)}function z(e,t){xi(e,10,t)}function D(e,t){xi(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=Mi(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]],Li=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,Ii,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=Mi([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??zt()}},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)}},Fi=[1,2,3,4,5],Pi=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,Fi,O,Wa,O,Ua,O,Ba,O,$a,O,Ga],Ce],Di=class extends y{constructor(e){super(e)}},ms=[0,ne,ce,-1,ee],pd=et(502141897,Di);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=Mi([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)}},Td=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],jd=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&&ai(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 Tc=class extends y{constructor(e){super(e)}},Ad=et(443442058,Tc);le[443442058]=[0,ne,R,ee,ce,me,-1,H,ce],le[514774813]=bs;var jc=class extends y{constructor(e){super(e)}},Nd=et(516587230,jc);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?bi(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&$(t,4),e.categoryDenylist!==void 0?bi(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 Ac(e){var a,c;var t=Yt(e,3,At,qt()),r=Yt(e,2,lr,qt()),i=Yt(e,1,dr,qt()),n=Yt(e,9,dr,qt());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:pi(l,1)??0,y:pi(l,2)??0,score:pi(l,4)??0,label:Ge(l,3)??""});return s}function Ri(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 Oi;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(Oi===void 0)try{await WebAssembly.instantiate(Cd),Oi=!0}catch{Oi=!1}return Oi}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 Qt=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)}}Qt.forVisionTasks=function(e){return Kr("vision",e)},Qt.forTextTasks=function(e){return Kr("text",e)},Qt.forGenAiExperimentalTasks=function(e){return Kr("genai_experimental",e)},Qt.forGenAiTasks=function(e){return Kr("genai",e)},Qt.forAudioTasks=function(e){return Kr("audio",e)},Qt.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,Pi,1)||new Pi;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 Bi(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 Ui(e){e.g.addBoolToStream(!0,"free_memory",e.B)}var Ts=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,Pi,1))!=null&&n.g()||(s=P(this.baseOptions,Pi,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,Fi,m)}"delegate"in h&&(h.delegate==="GPU"?(h=f,w=new nd,Vr(h,2,Fi,w)):(h=f,w=new Va,Vr(h,4,Fi,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}Ts.prototype.close=Ts.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 js(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 js(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 Gi(e,t,r){return js(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 Vi(e,t,r){js(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;
|
|
@@ -20,7 +20,7 @@
|
|
|
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=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=`
|
|
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(Vi(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),!$i)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))$i=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");$i=e.R16F}return $i}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=Gi(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 $i,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=Gi(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),Vi(n,i,r),As(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=Tr(e);const r=zi(e),i=new Uint8Array(e.width*e.height*4);Vi(r,t,Wi(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 Wi(e){let t=at(e,2);if(!t){const r=Tr(e);t=Hi(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 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=vt(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function zi(e){return e.l||(e.l=new Cs),e.l}function Hi(e){const t=Tr(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=at(e,2);return r||(r=Gi(zi(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=Tr(e);return As(zi(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||(Wi(this),Hi(this),e=zc(this),Xr(this),this.g.push(e),this.j=!0),e}N(){return Wi(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=Tr(this),n=zi(this);i.activeTexture(i.TEXTURE1),r=Gi(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),Vi(n,i,r),As(n,i,!1,()=>{Hi(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}`);Wi(this),Hi(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&&Tr(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 jr(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 Ts{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 Di,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(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 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 Di,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(Ri(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=Li(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:Yt(i,3,At,qt()).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=Li(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(Ri(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=Li(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{Ui(e)}}function qi(e,t){e=qr(e),t.push(Ri(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 Di,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,wi(s,Pn,void 0,void 0,!1));else{if(!(typeof s=="string"||s instanceof wt||Wt(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),zt())}}(r,this.j.g());const i=new ye;Me(i,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),yi(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),Bi(this,e),this.g.attachProtoListener("pose_landmarks",(n,s)=>{qi(n,this.h.poseLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("pose_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("pose_world_landmarks",(n,s)=>{var a=this.h.poseWorldLandmarks;n=_r(n),a.push(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=[jr(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)=>{qi(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=Li(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)=>{qi(n,this.h.leftHandLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("left_hand_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("left_hand_world_landmarks",(n,s)=>{var a=this.h.leftHandWorldLandmarks;n=_r(n),a.push(Yr(n)),x(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("right_hand_landmarks",(n,s)=>{qi(n,this.h.rightHandLandmarks),x(this,s)}),this.g.attachEmptyPacketListener("right_hand_landmarks",n=>{x(this,n)}),this.g.attachProtoListener("right_hand_world_landmarks",(n,s)=>{var a=this.h.rightHandWorldLandmarks;n=_r(n),a.push(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,Td,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=Yt(a=P(a,tc,Un(a,1)),1,At,qt()),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{Ui(e)}}Gs.prototype.close=Gs.prototype.close;var Te=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),Bi(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=>jr(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=jr(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)}};Te.prototype.getLabels=Te.prototype.Ba,Te.prototype.segmentForVideo=Te.prototype.Ia,Te.prototype.segment=Te.prototype.segment,Te.prototype.setOptions=Te.prototype.o,Te.createFromModelPath=function(e,t){return I(Te,e,{baseOptions:{modelAssetPath:t}})},Te.createFromModelBuffer=function(e,t){return I(Te,e,{baseOptions:{modelAssetBuffer:t}})},Te.createFromOptions=function(e,t){return I(Te,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)}},Ar=[0,ee,-2],Yi=[0,bt,-3,H,bt,-1],ll=[0,Yi],ul=[0,Yi,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=Mi([0,ue,[0,Ws,O,Yi,O,[0,Yi,Ar],O,ll,O,[0,ll,Ar],O,dl,O,[0,bt,-3,H,Ce],O,[0,bt,-3,H],O,[0,R,bt,-2,H,ee,H,-1,2,bt,Ar],O,ul,O,[0,ul,Ar],bt,Ar,R,O,[0,bt,-3,H,Ar,-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),yi(a,1,$s,t);Vr(s,15,Ws,a)}yi(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{Ui(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),Bi(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=>jr(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=jr(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 Tc,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?bi(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&$(this.h,5),e.categoryDenylist!==void 0?bi(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,Ad,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(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 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{Ui(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 jc,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),Bi(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(i,n)=>{this.landmarks=[];for(const s of i)i=qr(s),this.landmarks.push(Ri(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=>jr(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 Ki="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(Ki)!==void 0:!1,h=async()=>{try{const w=await fetch(Ki),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:T,value:F}=await b.read();if(T)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(Ki,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 Qt.forVisionTasks(Dd);n("Creating face landmarker...");const b=await X.createFromOptions(g,{baseOptions:{modelAssetPath:Ki,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=20,h=40;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=50,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,T=Math.abs(f.x-c.noseX)*100,F=Math.max(0,100-(_*200+p+T)),j=F<Ud,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}},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 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)<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 Ut(`${this.config.baseUrl}${Vt.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 j;const p=e.current,T=t.current,F=r.current;if(!p||p.readyState<2||!F||!T){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(T,p,B,h,f,w,l),l&&w&&c(B,u.current,w)):a(T,p)}else a(T,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],T=b[1];_&&p&&T&&(c.current={x:(_.x+p.x)*.5,y:(_.y+p.y)*.5,noseX:T.x,noseY:T.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}=an(),w=!!(f!=null&&f.gazeAnalysisEnabled),[m,g]=d.useState(!1),[b,_]=d.useState((f==null?void 0:f.showLandmarks)??!1),[p,T]=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),G=d.useRef(null),Q=d.useCallback(async ft=>{var en;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(tr=>ve.toBlob(tr,"image/jpeg"));if(Zr&&t)try{const tr=`${ft}-${Date.now()}.jpeg`,_e=await l.requestScreenshotUploadUrl(t,tr);_e.data&&_e.data.upload_url&&(await l.uploadScreenshot((en=_e==null?void 0:_e.data)==null?void 0:en.upload_url,Zr),_e.data.asset_id&&await l.confirmScreenshotUpload(_e.data.asset_id))}catch(tr){console.error(`Failed to upload screenshot for ${ft}:`,tr)}},[l,t]),{faceLandmarkerRef:oe,isModelLoaded:qe,statusMessage:de,setStatusMessage:Ye,loadingProgress:je,permissionDenied:be,clearCache:kt}=Rd(),{fps:dt,updateFPS:ge}=Od(),{drawWithEngagementBar:Jt,clearCanvas:Ke,engagementRef:re}=Bd(),{engagement:Xe,isLookingAway:V,analyzeGaze:ht,setEngagement:A,setIsLookingAway:J}=Gd(),{multipleFacesDetected:Dt,referenceFaceNotDetected:Rt,analyzeFace:Zt,setMultipleFacesDetected:Qi,setReferenceFaceNotDetected:er}=$d(),{referenceSet:Qr,referenceRef:Ji,setReference:N,syncReference:Ae}=Kd(oe,C,Ye,n),rt={multipleFacesDetected:Dt,referenceFaceNotDetected:Rt,isLookingAway:V},{showGazeWarningModal:Zi,getWarningType:Ih,closeWarningModal:vl,setShowGazeWarningModal:_l,setFaceDetectionState:kl}=zd(rt,w),{renderLoop:Mh}=Yd(C,M,oe,ge,Zt,Jt,Ke,ht,Qr,Ji,b,p,w,Ye,er);qd(C,qe,Mh,Ye),d.useEffect(()=>{Ae()},[Ae]),d.useEffect(()=>{re&&re.current&&(re.current.value=Xe,re.current.isLookingAway=V)},[Xe,V,re]);const Lh=d.useCallback(ft=>{j(ft),ft||(A(100),J(!1))},[A,J]),Fh=d.useCallback(()=>{J(!1),Qi(!1),er(!1),kl("face_detected"),_l(!1),vl()},[J,Qi,er,kl,_l,vl]),Ph={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,en=[0,1,2].map((_e,Ot)=>({label:`capture-${Ot+1}`,start:Ot*Zr,end:(Ot+1)*Zr})),tr=(_e,Ot)=>_e===Ot?_e:Math.random()*(Ot-_e)+_e;en.forEach(({label:_e,start:Ot,end:Dh},Rh)=>{let Ys;Rh===0?Ys=3e3:Ys=tr(Ot,Dh),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:320,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:T,handleToggleGazeAnalysis:Lh,stats:Ph,statusMessage:de,loadingProgress:je})})]})}),w&&Zi&&o.jsx(au,{isOpen:Zi,onClose:Fh,warningType:Ih()})]})}),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,T]=d.useState(!1),[F,j]=d.useState(!1),[C,M]=d.useState(null),[B,G]=d.useState(!1),Q=d.useRef(null),oe=d.useRef(null),qe=A=>{Q.current=A,n&&(typeof n=="function"?n(A):n.current=A)},de=u??"#2563eb",Ye=oo(de),je=h??18,be=(A,J)=>A.startsWith("#")&&A.length===7?`${A}${J}`:A,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."},Jt=[{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(A=>A.stop()),l.current=null)},re=async()=>{G(!0),M(null);try{const A=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:!0});l.current=A,c.current&&(c.current.srcObject=A),w(!0)}catch(A){console.error("Media permission error:",A);let J="Unable to access camera or microphone.";(A==null?void 0:A.name)==="NotAllowedError"?J="Permissions denied. Please allow access to camera and microphone.":(A==null?void 0:A.name)==="NotFoundError"?J="No camera/microphone found. Please connect a device and retry.":A!=null&&A.message&&(J=A.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()=>{T(!0);const A=()=>{var J;return(J=Q.current)==null?void 0:J.setReference()};A(),oe.current&&clearInterval(oe.current),oe.current=setInterval(A,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((A,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:A})]})},A))})]})}),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:je},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),T(!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:je}})}),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:je,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:Jt.map(({Icon:A,label:J,description:Dt,status:Rt,toneClass:Zt})=>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(A,{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 ${Zt}`,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(),j(!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 T=p instanceof te?p:new te(p.message,"RECORDING_ERROR",!0);l(T),r(!1),(F=e.onError)==null||F.call(e,T)}})}catch(p){const T=p instanceof te?p:new te(p instanceof Error?p.message:String(p),"START_FAILED",!1);throw l(T),r(!1),(_=e.onError)==null||_.call(e,T),T}},[]),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 T=p instanceof te?p:new te(p instanceof Error?p.message:String(p),"STOP_FAILED",!1);throw l(T),r(!1),(_=e.onError)==null||_.call(e,T),T}},[]),m=d.useCallback(async(b,_={})=>{var p,T;try{l(null),n(!0);const F={audioBlob:b,..._},j=await Nr.transcribe(F);return a(j.transcript),n(!1),(p=e.onTranscriptionComplete)==null||p.call(e,j),j}catch(F){const j=F instanceof te?F:new te(F instanceof Error?F.message:String(F),"TRANSCRIPTION_FAILED",!0);throw l(j),n(!1),(T=e.onError)==null||T.call(e,j),j}},[]),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;
|
|
@@ -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}},[])},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:`
|
|
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,T=r/2+(p?.5:0);return{radius:g,circumference:b,dashOffset:_,center:T}},[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=({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:"interview-widget-container",style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",transition:"opacity 0.2s"},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?"standalone-dialog-title":void 0,style:{zIndex:1e4},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:"standalone-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 Bt.createPortal(u,document.body)},ph=({confirmExitInterview:e,isOpen:t,onClose:r})=>o.jsx(gh,{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(ph,{isOpen:n,confirmExitInterview:()=>{r(),s(!1)},onClose:()=>s(!1)})]})},xh=({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,T]=d.useState(null);d.useEffect(()=>{if(t||!f.current)return;const j=f.current,C=()=>{const B=h.current;if(!B)return;const G=j.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(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 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){T((M==null?void 0:M.message)||"Failed to initialize microphone")}})(),()=>{var M,B,G,Q;j=!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 j=h.current,C=m.current;if(!j||!C)return;const M=j.getContext("2d");if(!M)return;const B=window.devicePixelRatio||1,G=j.width,Q=j.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)),je=Math.max(1,Math.floor(n*B)),be=Ye+je,kt=Math.max(8,Math.floor((G+je)/be)),dt=Math.floor(qe.length/kt);for(let ge=0;ge<kt;ge++){const Jt=Math.min(qe.length-1,ge*dt),Ke=qe[Jt]/128-1,re=Math.abs(Ke),Xe=Math.pow(re,.6),V=Math.max(Q*.06,Xe*(Q*.9)),ht=ge*be,A=(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 Zt=Math.min(Ye/2,V/2);yh(M,ht,A,Ye,V,Zt),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 yh(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 bh=({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(xh,{}),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 vh(){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 _h=({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 _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"}})});
|
|
187
|
+
`})})};function kh({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(_h,{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 Eh=({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"})})]}),Sh=({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)"]})]}),Xi=5;function Th({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=Xi-r,f=()=>{r+1>Xi?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:Xi}).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,"/",Xi,")"]})]})]})]}),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 jh=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(cn,{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(jh,{className:"iw-size-4"}),"Continue Session"]})})]})},Nh=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(Th,{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})]})}),Ch=({interviewTitle:e,brandName:t="Novara",interviewId:r,onComplete:i,onDisqualify:n,className:s="",videoFeedRef:a})=>{var Ji;const c=lo(),{baseUrl:l,authToken:u}=ro(),{timers:h,stt:f,proctoring:w}=an(),m=d.useRef(null),[g,b]=d.useState(null),[_,p]=d.useState(""),[T,F]=d.useState(ti),j=d.useRef(""),C=d.useRef(null);d.useEffect(()=>{(async()=>{var Ae;try{const rt=await c.getInterviewConfig(r);(Ae=rt==null?void 0:rt.data)!=null&&Ae.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(()=>{j.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())}}),je=d.useRef(!1),be=d.useRef(!1),{startRecording:kt,stopRecording:dt,transcribe:ge,cancelRecording:Jt,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:((Ji=C.current)==null?void 0:Ji.qna_id)||"",interviewId:r},onStart:()=>{je.current=!1,be.current=!1},onStop:()=>{},onTranscriptionComplete:N=>{p(N.transcript),be.current||(be.current=!0,V())},onError:N=>{console.error("STT Error:",N),je.current||(je.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:A();break;case se.READING_QUESTION:Rt();break;case se.ANSWERING:Zt();break;case se.TRANSCRIBING:Qi();break;case se.SUBMITTING:Dt();break}},onInterviewEnd:()=>{i==null||i()}}});d.useEffect(()=>{Xe()},[]);const{execute:A,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:j.current})}catch(Ae){console.error("Failed to submit answer:",Ae)}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(Ae){console.error("Failed to speak question:",Ae),V()}else console.warn("No audio data available for question"),await Vl(2e3),V();else V()},[qe,V,ht]),Zt=d.useCallback(async()=>{try{await kt(G)}catch(N){console.error("Failed to start recording:",N),V()}},[kt,V]),Qi=d.useCallback(async()=>{try{const N=await dt();await ge(N)}catch(N){console.error("STT processing failed:",N),!je.current&&!be.current&&(je.current=!0,V())}},[dt,ge,V]),er=d.useCallback(async N=>{var Ae,rt;de(),Jt(),a&&"current"in a&&((Ae=a.current)==null||Ae.stopCamera()),await((rt=m.current)==null?void 0:rt.exitFullScreenIntentionally());try{await c.exitInterview(r)}catch(Zi){console.error("API call failed:",Zi)}finally{N==null||N(),ht(),sessionStorage.removeItem(nn)}},[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(vh,{});case se.READING_QUESTION:return o.jsx(kh,{ttsError:Ye});case se.THINKING:return o.jsx(Eh,{state:re,thinkingTime:B,nextPhase:V});case se.ANSWERING:return o.jsx(bh,{state:re,answeringTime:G,nextPhase:V,sttError:Ke});case se.TRANSCRIBING:return o.jsx(Sh,{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:Ae=>p(Ae.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(Nh,{ref:m,onDisqualify:()=>er(n),children:[o.jsx(bl,{title:e,brandName:t,onExit:()=>er()}),o.jsx(yl,{currentQuestion:g,phase:re.phase,className:s,interviewId:r,interview_duration:T,videoFeedRef:a,children:Qr()})]}):o.jsxs(o.Fragment,{children:[o.jsx(bl,{title:e,brandName:t,onExit:()=>er()}),o.jsx(yl,{currentQuestion:g,phase:re.phase,className:s,interviewId:r,interview_duration:T,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}=an(),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(Ch,{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"}})});
|