interview-widget 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(D,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],c):(D=typeof globalThis<"u"?globalThis:D||self,c(D.InterviewWidget={},D.React,D.ReactDOM))})(this,function(D,c,W){"use strict";var Yt=Object.defineProperty;var Qt=(D,c,W)=>c in D?Yt(D,c,{enumerable:!0,configurable:!0,writable:!0,value:W}):D[c]=W;var R=(D,c,W)=>Qt(D,typeof c!="symbol"?c+"":c,W);var se=typeof document<"u"?document.currentScript:null,pe={exports:{}},X={};/**
1
+ (function(A,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],o):(A=typeof globalThis<"u"?globalThis:A||self,o(A.InterviewWidget={},A.React,A.ReactDOM))})(this,function(A,o,B){"use strict";var Qt=Object.defineProperty;var Kt=(A,o,B)=>o in A?Qt(A,o,{enumerable:!0,configurable:!0,writable:!0,value:B}):A[o]=B;var R=(A,o,B)=>Kt(A,typeof o!="symbol"?o+"":o,B);var ae=typeof document<"u"?document.currentScript:null,ye={exports:{}},ee={};/**
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 Le=Symbol.for("react.transitional.element"),$e=Symbol.for("react.fragment");function be(i,r,t){var s=null;if(t!==void 0&&(s=""+t),r.key!==void 0&&(s=""+r.key),"key"in r){t={};for(var n in r)n!=="key"&&(t[n]=r[n])}else t=r;return r=t.ref,{$$typeof:Le,type:i,key:s,ref:r!==void 0?r:null,props:t}}X.Fragment=$e,X.jsx=be,X.jsxs=be,pe.exports=X;var e=pe.exports;const F={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}}},ne="iw-storage";function Oe(){return typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:se&&se.tagName.toUpperCase()==="SCRIPT"&&se.src||new URL("widget.umd.js",document.baseURI).href}<"u"?"your-secure-encryption-seed-here":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 ye=Oe(),ae="AES-GCM",oe=12;async function ve(i){const t=new TextEncoder().encode(i),s=await crypto.subtle.digest("SHA-256",t);return crypto.subtle.importKey("raw",s,ae,!1,["encrypt","decrypt"])}function Ue(){return crypto.getRandomValues(new Uint8Array(oe))}async function qe(i,r="default-seed"){try{const t=typeof i=="string"?i:JSON.stringify(i),n=new TextEncoder().encode(t),o=await ve(r),a=Ue(),l=await crypto.subtle.encrypt({name:ae,iv:a},o,n),w=new Uint8Array(a.length+l.byteLength);return w.set(new Uint8Array(a),0),w.set(new Uint8Array(l),a.length),btoa(String.fromCharCode(...Array.from(w)))}catch(t){throw console.error("Encryption failed:",t),new Error("Failed to encrypt data")}}async function We(i,r="default-seed"){try{const t=atob(i),s=new Uint8Array(t.length);for(let d=0;d<t.length;d++)s[d]=t.charCodeAt(d);const n=s.slice(0,oe),o=s.slice(oe),a=await ve(r),l=await crypto.subtle.decrypt({name:ae,iv:n},a,o);return new TextDecoder().decode(l)}catch(t){throw console.error("Decryption failed:",t),new Error("Failed to decrypt data")}}async function Be(i,r="default-seed"){return qe(i,r)}async function Ge(i,r="default-seed"){const t=await We(i,r);try{return JSON.parse(t)}catch{return t}}const Z=c.createContext(null),Ve=async()=>{var i,r;try{const t=sessionStorage.getItem(ne);if(t){const s=await Ge(t,ye);return{logViolations:((i=s.state)==null?void 0:i.logViolations)||[],totalViolations:((r=s.state)==null?void 0:r.totalViolations)||0}}}catch(t){console.error("Failed to load proctoring data from session storage:",t)}return{logViolations:[],totalViolations:0}},je=async i=>{try{const r=await Be({state:i,version:0},ye);sessionStorage.setItem(ne,r)}catch(r){console.error("Failed to save proctoring data to session storage:",r)}},ze=({children:i})=>{const r=c.useRef({logViolations:[],totalViolations:0}),t=c.useRef(new Set);c.useEffect(()=>{Ve().then(d=>{r.current=d,s()})},[]);const s=c.useCallback(()=>{t.current.forEach(d=>d())},[]),n=c.useCallback(d=>(t.current.add(d),()=>{t.current.delete(d)}),[]),o=c.useCallback(()=>r.current,[]),a=c.useCallback(d=>{r.current={logViolations:[...r.current.logViolations,d],totalViolations:r.current.totalViolations+1},je(r.current),s()},[s]),l=c.useCallback(()=>{r.current={logViolations:[],totalViolations:0},je(r.current),s()},[s]),w=c.useMemo(()=>({getState:o,addViolation:a,clearViolations:l,subscribe:n}),[o,a,l,n]);return e.jsx(Z.Provider,{value:w,children:i})},He=()=>{const i=c.useContext(Z);if(!i)throw new Error("useViolations must be used within a ProctoringProvider");return c.useSyncExternalStore(i.subscribe,()=>i.getState().logViolations,()=>i.getState().logViolations)},Ye=()=>{const i=c.useContext(Z);if(!i)throw new Error("useTotalViolations must be used within a ProctoringProvider");return c.useSyncExternalStore(i.subscribe,()=>i.getState().totalViolations,()=>i.getState().totalViolations)},Qe=()=>{const i=c.useContext(Z);if(!i)throw new Error("useProctoringActions must be used within a ProctoringProvider");return{addViolation:i.addViolation,clearViolations:i.clearViolations}},ke=c.createContext(null);function Ne({config:i={},children:r}){var s,n,o,a;const t={api:{...F.api,...i.api,retryConfig:{...F.api.retryConfig,...(s=i.api)==null?void 0:s.retryConfig}},ui:{...F.ui,...i.ui},interview:{...F.interview,...i.interview,timers:{...F.interview.timers,...(n=i.interview)==null?void 0:n.timers},stt:{...F.interview.stt,...(o=i.interview)==null?void 0:o.stt},tts:{...F.interview.tts,...(a=i.interview)==null?void 0:a.tts}}};return e.jsx(ke.Provider,{value:t,children:e.jsx(ze,{children:r})})}function ee(){const i=c.useContext(ke);if(!i)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return i}function Ee(){return ee().api||F.api}function V(){return ee().ui||F.ui}function Ke(){return ee().interview||F.interview}const Ce=({className:i,...r})=>e.jsx("div",{children:e.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 ${i}`,...r,children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M12 6l0 -3"}),e.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),e.jsx("path",{d:"M18 12l3 0"}),e.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),e.jsx("path",{d:"M12 18l0 3"}),e.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),e.jsx("path",{d:"M6 12l-3 0"}),e.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),Se=({children:i,variant:r="primary",size:t="md",fullWidth:s=!1,isLoading:n=!1,disabled:o,className:a="",...l})=>{const w="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",d={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"},m="iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none",f=s?"iw-w-full":"";return e.jsxs("button",{className:`${w} ${d[r]} ${h[t]} ${f} ${m} ${a}`,disabled:o||n,...l,children:[n&&e.jsx(Ce,{height:16,width:16,style:{marginRight:"3px"}}),i]})};function Je(i){const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:null}function Xe(i,r,t){return"#"+[i,r,t].map(s=>{const n=Math.round(s).toString(16);return n.length===1?"0"+n:n}).join("")}function Te(i,r){const t=Je(i);if(!t)return i;const s=t.r+(255-t.r)*r,n=t.g+(255-t.g)*r,o=t.b+(255-t.b)*r;return Xe(s,n,o)}function Ze(i,r=.8){return{background:`linear-gradient(to bottom, ${Te(i,r)}, #ffffff)`,color:"#1f2937"}}function et(i){return new Promise(r=>setTimeout(r,i))}function Ie(i){return`linear-gradient(to left, ${Te(i,.4)}, ${i})`}const tt=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);function it(i){try{const r=i.split(".");if(r.length!==3||!r[1])throw new Error("Invalid JWT token");const s=r[1].replace(/-/g,"+").replace(/_/g,"/"),n=s.padEnd(s.length+(4-s.length%4)%4,"="),o=atob(n);return JSON.parse(o)}catch(r){return console.error("Error decoding JWT:",r),null}}const Me=i=>e.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",...i,children:[e.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"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]}),Ae=i=>e.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",...i,children:[e.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),e.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),rt=i=>e.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",...i,children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M15 8a5 5 0 0 1 0 8"}),e.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"})]}),B=i=>{const{baseColor:r,borderRadius:t}=V(),{loading:s,children:n,...o}=i;return e.jsx(Se,{style:{background:Ie(r),borderRadius:t},...o,children:s?e.jsx(Ce,{}):n})},st=["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"],nt=({isOpen:i,onStart:r,onClose:t})=>{var T;const s=c.useRef(null),n=c.useRef(null),{baseColor:o,borderRadius:a}=V(),[l,w]=c.useState(!1),[d,h]=c.useState(null),[m,f]=c.useState(!1),u=o??"#2563eb",x=Ie(u),j=a??18,k=(g,S)=>g.startsWith("#")&&g.length===7?`${g}${S}`:g,p=[`radial-gradient(120% 85% at 50% 125%, ${k(u,"34")} 0%, transparent 70%)`,`radial-gradient(90% 70% at 10% 130%, ${k(u,"24")} 0%, transparent 72%)`,`radial-gradient(90% 70% at 90% 130%, ${k(u,"24")} 0%, transparent 72%)`,`repeating-linear-gradient(135deg, ${k(u,"14")} 0, ${k(u,"14")} 16px, transparent 16px, transparent 32px)`].join(", "),N=l?{label:"Camera & microphone ready",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-emerald-400"}:m?{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"},E=l?{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."}:m?{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."},v=[{label:"Camera feed",description:E.cameraCopy,status:E.badge,toneClass:E.toneClass,Icon:Ae},{label:"Microphone input",description:E.micCopy,status:E.badge,toneClass:E.toneClass,Icon:rt}],_=()=>{n.current&&(n.current.getTracks().forEach(g=>g.stop()),n.current=null)},y=async()=>{f(!0),h(null);try{const g=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:!0});n.current=g,s.current&&(s.current.srcObject=g),w(!0)}catch(g){console.error("Media permission error:",g);let S="Unable to access camera or microphone.";(g==null?void 0:g.name)==="NotAllowedError"?S="Permissions denied. Please allow access to camera and microphone.":(g==null?void 0:g.name)==="NotFoundError"?S="No camera/microphone found. Please connect a device and retry.":g!=null&&g.message&&(S=g.message),w(!1),h(S)}finally{f(!1)}};if(c.useEffect(()=>{if(!i){_();return}return y(),()=>{_()}},[i]),!i)return null;const M=()=>{r(),_()};return e.jsx("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:e.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:[e.jsxs("div",{className:"iw-relative iw-overflow-hidden",style:{background:x},children:[e.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)"}}),e.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)"}}),e.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:[e.jsx("div",{className:"iw-flex iw-flex-col iw-gap-4 iw-text-white",children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[e.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:e.jsx(Me,{className:"iw-h-6 iw-w-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-white/70",children:"Pre-interview checklist"}),e.jsx("h2",{className:"iw-mt-1 iw-text-xl iw-font-semibold iw-leading-tight",children:"Final checks before you go live"}),e.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."})]})]})}),e.jsx("div",{className:"iw-flex iw-items-start iw-justify-end",children:e.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 ${N.toneClass}`,children:[e.jsx("span",{className:`iw-inline-flex iw-h-2 iw-w-2 iw-rounded-full ${N.dotClass}`}),N.label]})}),t&&e.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:()=>{_(),t==null||t()},children:"✕"})]})]}),e.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-px-6 iw-pb-8 iw-pt-6",children:[e.jsxs("div",{className:"iw-grid xl:iw-grid-cols-[0.95fr_1.05fr] iw-gap-6",children:[e.jsx("section",{className:"iw-flex iw-flex-col iw-gap-5",children:e.jsxs("div",{className:"iw-rounded-2xl iw-border iw-border-slate-100 iw-bg-white iw-p-5 iw-shadow-sm",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-sm iw-font-semibold iw-text-slate-900",children:"Proctoring guidelines"}),e.jsx("span",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-slate-400",children:"Required"})]}),e.jsx("ul",{className:"iw-mt-5 iw-flex iw-flex-col iw-gap-4",children:st.map((g,S)=>e.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:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[e.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:x},children:S+1}),e.jsx("span",{className:"iw-text-sm iw-text-slate-600",children:g})]})},g))})]})}),e.jsxs("section",{className:"iw-flex iw-flex-col iw-gap-5",children:[e.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-overflow-hidden iw-rounded-3xl iw-bg-white ",style:{borderRadius:j},children:[e.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:e.jsx("video",{ref:s,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-h-64 iw-w-full iw-rounded-2xl iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:j}})}),e.jsxs("div",{className:"iw-relative iw-grid iw-grid-cols-2 iw-gap-4 iw-px-1",children:[e.jsx(Se,{onClick:y,disabled:m,variant:"outline",size:"sm",className:"iw-font-medium",style:{borderColor:u,borderRadius:j,color:u},children:l?"Recheck permissions":"Enable camera & mic"}),e.jsx(B,{onClick:M,disabled:!l,className:"iw-h-10 iw-px-6 iw-text-sm",style:{backgroundColor:u},children:"Proceed"})]})]}),e.jsx("ul",{className:"iw-grid sm:iw-grid-cols-1 iw-gap-3",children:v.map(({Icon:g,label:S,description:P,status:U,toneClass:O})=>e.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:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[e.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:e.jsx(g,{className:"iw-h-5 iw-w-5 iw-text-slate-600"})}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-gap-3",children:[e.jsx("p",{className:"iw-text-sm iw-font-medium iw-text-slate-800",children:S}),e.jsx("span",{className:`iw-rounded-full iw-px-3 iw-py-1 iw-text-[11px] iw-font-semibold ${O}`,children:U})]}),e.jsx("p",{className:"iw-mt-1.5 iw-text-xs iw-text-slate-500",children:P})]})]})},S))}),d&&e.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:d}),!((T=navigator.mediaDevices)!=null&&T.getUserMedia)&&e.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."})]})]}),e.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:e.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."})}),e.jsx("div",{"aria-hidden":!0,className:"iw-pointer-events-none iw-absolute iw-inset-x-0 iw-bottom-1 iw-h-20",style:{backgroundImage:p,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)"}})]})]})})};var A=(i=>(i.IDLE="idle",i.FETCHING_QUESTION="fetching_question",i.READING_QUESTION="reading_question",i.THINKING="thinking",i.ANSWERING="answering",i.TRANSCRIBING="transcribing",i.EDITING="editing",i.SUBMITTING="submitting",i.COMPLETED="completed",i))(A||{});const at={thinkingDuration:30,answeringDuration:120,editingDuration:30},ot={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 lt{constructor(r={},t={}){R(this,"config");R(this,"state");R(this,"phaseIntervalId",null);R(this,"globalIntervalId",null);R(this,"callbacks");this.config={...at,...r},this.callbacks=t,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 r=this.state.phase,t=ot[r];if(!t)return;this.stopPhaseTimer(),this.state.phase=t.next;const s=this.getDurationForPhase(t.next);s>0?(this.state.currentPhaseTimeRemaining=s,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}completeInterview(){var r,t;this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(t=(r=this.callbacks).onInterviewEnd)==null||t.call(r),this.notifyChange()}destroy(){this.stopPhaseTimer(),this.stopGlobalTimer()}getDurationForPhase(r){switch(r){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 r,t;this.state.totalTimeElapsed++,(t=(r=this.callbacks).onTick)==null||t.call(r,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 r,t;(t=(r=this.callbacks).onPhaseChange)==null||t.call(r,this.state.phase,this.getState())}}function ct(i={}){const{config:r={},callbacks:t={}}=i,s=c.useRef(null);s.current||(s.current=new lt(r,{}));const n=s.current,[o,a]=c.useState(n.getState()),l=c.useCallback(()=>{a(n.getState())},[n]);c.useEffect(()=>{const m={onPhaseChange:(f,u)=>{var x;l(),(x=t.onPhaseChange)==null||x.call(t,f,u)},onTick:f=>{var u;l(),(u=t.onTick)==null||u.call(t,f)},onInterviewEnd:()=>{var f;l(),(f=t.onInterviewEnd)==null||f.call(t)}};n.callbacks=m},[n,t,l]),c.useEffect(()=>()=>{n.destroy()},[n]);const w=c.useCallback(()=>{n.startQuestion(),l()},[n,l]),d=c.useCallback(()=>{n.nextPhase(),l()},[n,l]),h=c.useCallback(()=>{n.completeInterview(),l()},[n,l]);return{state:o,startQuestion:w,nextPhase:d,completeInterview:h,timerService:n}}function dt(i,r={}){const[t,s]=c.useState({data:null,loading:!1,error:null}),n=c.useCallback(async(...o)=>{var a,l,w,d;s(h=>({...h,loading:!0,error:null}));try{const h=await i(...o);s(m=>({...m,data:h,loading:!1,error:null})),(a=r.onSuccess)==null||a.call(r,h),(l=r.onSettled)==null||l.call(r,h,null)}catch(h){const m=h.type?h:{type:"unknown",message:h.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:h};s(f=>({...f,loading:!1,error:m})),(w=r.onError)==null||w.call(r,m),(d=r.onSettled)==null||d.call(r,null,m)}},[i,r]);return{...t,execute:n}}const wt=i=>{const[r,t]=c.useState(null),[s,n]=c.useState(!1),o=document,a=()=>!!(o.fullscreenEnabled||o.webkitFullscreenEnabled||o.mozFullScreenEnabled||o.msFullscreenEnabled),l=()=>o.fullscreenElement||o.webkitFullscreenElement||o.mozFullScreenElement||o.msFullscreenElement,w=async u=>{var x;try{if(!a())throw new Error("Fullscreen is not supported in this environment");u.requestFullscreen?await u.requestFullscreen():u.webkitRequestFullscreen?await u.webkitRequestFullscreen():u.mozRequestFullScreen?await u.mozRequestFullScreen():u.msRequestFullscreen&&await u.msRequestFullscreen()}catch(j){const k={name:"FullscreenError",message:j instanceof Error?j.message:"Failed to enter fullscreen"};t(k),(x=i==null?void 0:i.onError)==null||x.call(i,k)}},d=async()=>{var u;try{o.exitFullscreen?await o.exitFullscreen():o.webkitExitFullscreen?await o.webkitExitFullscreen():o.mozCancelFullScreen?await o.mozCancelFullScreen():o.msExitFullscreen&&await o.msExitFullscreen()}catch(x){const j={name:"FullscreenError",message:x instanceof Error?x.message:"Failed to exit fullscreen"};t(j),(u=i==null?void 0:i.onError)==null||u.call(i,j)}},h=c.useCallback(()=>{var x;const u=!!l();n(u),(x=i==null?void 0:i.onFullScreenChange)==null||x.call(i,u)},[i]);c.useEffect(()=>{const u=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return u.forEach(x=>{document.addEventListener(x,h)}),()=>{u.forEach(x=>{document.removeEventListener(x,h)})}},[h]);const m=async u=>{t(null);const x=u??document.documentElement;await w(x)};return{isFullScreen:s,toggleFullScreen:async u=>{s?await d():await m(u)},enterFullScreen:m,exitFullScreen:d,error:r}};function ut(i){var r;if(!navigator.onLine)return{type:"network",message:"No internet connection",retryable:!0,userMessage:"Please check your internet connection and try again."};if(i.name==="AbortError"||(r=i.message)!=null&&r.includes("timeout"))return{type:"timeout",message:"Request timed out",retryable:!0,userMessage:"The request is taking longer than expected. Please try again."};if(i.status){const{status:t}=i;if(t===401||t===403)return{type:"auth",status:t,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(t===429)return{type:"rate-limit",status:t,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(t>=500)return{type:"server",status:t,message:`Server error: ${t}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(t>=400)return{type:"client",status:t,message:`Client error: ${t}`,retryable:!1,userMessage:"There was an issue with your request. Please check your input."}}return{type:"unknown",message:i.message||"Unknown error occurred",retryable:!0,userMessage:"Something unexpected happened. Please try again.",originalError:i}}async function le(i,r={},t={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let s;for(let n=1;n<=t.attempts;n++)try{const o=new AbortController,a=setTimeout(()=>o.abort(),6e4),l=await fetch(i,{...r,signal:o.signal});if(clearTimeout(a),l.status>=400&&l.status<500&&l.status!==429)return l;if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);return l}catch(o){s=o;const a=ut(o);if(!a.retryable||n===t.attempts)throw a;const l=ht(n,t);console.warn(`API request failed (attempt ${n}/${t.attempts}), retrying in ${l}ms:`,a.message),await new Promise(w=>setTimeout(w,l))}throw s}function ht(i,r){let t;return r.backoff==="exponential"?t=r.baseDelay*Math.pow(2,i-1):t=r.baseDelay,t=Math.min(t,r.maxDelay),r.jitter&&(t=t*(.5+Math.random()*.5)),Math.round(t)}class mt{constructor(r={}){R(this,"config");this.config=r}updateConfig(r){this.config={...this.config,...r}}getHeaders(){var t;const r={"Content-Type":"application/json"};return(t=this.config)!=null&&t.authToken&&(r.Authorization=`Bearer ${this.config.authToken}`),r}getBaseUrl(){var r;return((r=this.config)==null?void 0:r.baseUrl)||"/api"}async generateQuestion({interviewId:r,isInterviewDone:t=!1,qnaId:s,question:n,answer:o,answerDuration:a}){const l=await le(`${this.getBaseUrl()}/questions/next`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:r,is_interview_done:t,qna_id:s,question:n,answer:o,answer_duration:a??"00:00:30"})});if(!l.ok)throw new Error(`Failed to get questions: ${l.status}`);return await l.json()}}function ft(){const i=ee();return c.useMemo(()=>{const t=i.api||{};return new mt(t)},[i.api])}const gt=i=>{c.useEffect(()=>{const r=s=>{(s.ctrlKey||s.metaKey)&&["c","v","a","t","n","w","r","s","p"].includes(s.key.toLowerCase())&&(s.preventDefault(),i({type:"blocked_shortcut",severity:"low",details:{action:"shortcut_pressed",reason:`Attempted to use a blocked keyboard shortcut: Ctrl + ${s.key}`}})),s.key.startsWith("F")&&s.key.length<=3&&(s.preventDefault(),i({type:"blocked_function_key",severity:"low",details:{action:"function_key_pressed",reason:`Attempted to use a blocked function key: ${s.key}`}})),s.altKey&&s.key==="Tab"&&(s.preventDefault(),i({type:"alt_tab_attempt",severity:"medium",details:{action:"alt_tab",reason:"Attempted to use the Alt + Tab shortcut"}}))},t=s=>{s.preventDefault(),i({type:"right_click_attempt",severity:"low",details:{action:"right_click",reason:"Attempted to use the right click"}})};return document.addEventListener("keydown",r),document.addEventListener("contextmenu",t),()=>{document.removeEventListener("keydown",r),document.removeEventListener("contextmenu",t)}},[i])};class C extends Error{constructor(r,t,s=!1){super(r),this.code=t,this.recoverable=s,this.name="STTError"}}class xt{constructor(r={}){R(this,"config");R(this,"mediaRecorder",null);R(this,"audioChunks",[]);R(this,"recordingStream",null);R(this,"autoStopTimeoutId",null);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...r}}updateConfig(r){this.config={...this.config,...r}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(r,t){var s;if(!this.isRecordingSupported())throw new C("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new C("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=o=>{var a;o.data.size>0&&(this.audioChunks.push(o.data),(a=t==null?void 0:t.onDataAvailable)==null||a.call(t,o.data))},this.mediaRecorder.onstop=()=>{var o;(o=t==null?void 0:t.onStop)==null||o.call(t)},this.mediaRecorder.onerror=o=>{var l;const a=new C(`Recording failed: ${o.error}`,"RECORDING_ERROR",!0);(l=t==null?void 0:t.onError)==null||l.call(t,a),this.cleanup()},this.mediaRecorder.start(100),(s=t==null?void 0:t.onStart)==null||s.call(t),r&&r>0&&(this.autoStopTimeoutId=setTimeout(()=>{this.isRecording()&&this.stopRecording()},r*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new C("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new C("No microphone found","NO_MICROPHONE",!1)}throw new C(`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 C("No active recording to stop","NO_ACTIVE_RECORDING",!1);return new Promise((r,t)=>{if(!this.mediaRecorder){t(new C("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const s=this.mediaRecorder,n=()=>{try{const o=s.mimeType||"audio/webm",a=new Blob(this.audioChunks,{type:o});this.cleanup(),r(a)}catch(o){t(new C(`Failed to create audio blob: ${o instanceof Error?o.message:String(o)}`,"BLOB_CREATION_FAILED",!1))}};s.addEventListener("stop",n,{once:!0}),s.stop()})}async transcribe(r){const{audioBlob:t,model:s=this.config.model,language:n=this.config.language,includeTimestamps:o=this.config.includeTimestamps,temperature:a=this.config.temperature}=r;if(!t||t.size===0)throw new C("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const l=new FormData,w=new File([t],"recording.wav",{type:t.type||"audio/wav"});l.append("file",w),l.append("model",s||"whisper-large-v3-turbo"),l.append("language",n||"en"),l.append("include_timestamps",String(o||!1)),l.append("temperature",String(a||0));const d=await le(`${this.config.baseUrl}/speech/transcribe`,{method:"POST",headers:{accept:"application/json","X-STT-Provider":this.config.provider||"groq",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:l},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!d.ok){const m=await d.text();let f=`STT request failed: ${d.status} ${d.statusText}`;try{const u=JSON.parse(m);f=u.message||u.error||f}catch{f=m||f}throw new C(f,`HTTP_${d.status}`,d.status>=500)}return{transcript:(await d.json()).data.text??""}}catch(l){throw l instanceof C?l:new C(`Transcription failed: ${l instanceof Error?l.message:String(l)}`,"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 r=["audio/webm","audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4","audio/wav"];for(const t of r)if(MediaRecorder.isTypeSupported(t))return t;return"audio/webm"}cleanup(){this.recordingStream&&(this.recordingStream.getTracks().forEach(r=>r.stop()),this.recordingStream=null),this.mediaRecorder=null,this.audioChunks=[],this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}}const z=new xt,pt=(i={})=>{const[r,t]=c.useState(!1),[s,n]=c.useState(!1),[o,a]=c.useState(null),[l,w]=c.useState(null),[d,h]=c.useState(null);i.config&&z.updateConfig(i.config);const m=c.useCallback(async j=>{var k;try{w(null),a(null),h(null),await z.startRecording(j,{onStart:()=>{var p;t(!0),(p=i.onStart)==null||p.call(i)},onStop:()=>{var p;t(!1),(p=i.onStop)==null||p.call(i)},onError:p=>{var E;const N=p instanceof C?p:new C(p.message,"RECORDING_ERROR",!0);w(N),t(!1),(E=i.onError)==null||E.call(i,N)}})}catch(p){const N=p instanceof C?p:new C(p instanceof Error?p.message:String(p),"START_FAILED",!1);throw w(N),t(!1),(k=i.onError)==null||k.call(i,N),N}},[]),f=c.useCallback(async()=>{var j,k;try{const p=await z.stopRecording();return h(p),t(!1),(j=i.onStop)==null||j.call(i),p}catch(p){const N=p instanceof C?p:new C(p instanceof Error?p.message:String(p),"STOP_FAILED",!1);throw w(N),t(!1),(k=i.onError)==null||k.call(i,N),N}},[]),u=c.useCallback(async(j,k={})=>{var p,N;try{w(null),n(!0);const E={audioBlob:j,...k},v=await z.transcribe(E);return a(v.transcript),n(!1),(p=i.onTranscriptionComplete)==null||p.call(i,v),v}catch(E){const v=E instanceof C?E:new C(E instanceof Error?E.message:String(E),"TRANSCRIPTION_FAILED",!0);throw w(v),n(!1),(N=i.onError)==null||N.call(i,v),v}},[]),x=c.useCallback(()=>{z.cancelRecording(),t(!1),h(null)},[]);return{startRecording:m,stopRecording:f,transcribe:u,cancelRecording:x,isRecording:r,isTranscribing:s,transcript:o,error:l,audioBlob:d}},bt=i=>{const r=c.useRef(null),t=c.useRef(!1);c.useEffect(()=>{const s=()=>{document.hidden&&(t.current=!0,r.current&&(clearTimeout(r.current),r.current=null),i({type:"tab_switch",severity:"high",details:{action:"tab_hidden",reason:"Attempted to switch tabs or applications"}}),setTimeout(()=>{t.current=!1},100))},n=()=>{t.current||(r.current=setTimeout(()=>{t.current||i({type:"focus_loss",severity:"medium",details:{action:"window_blur",reason:"Focus lost from the interview window"}}),r.current=null},50))};return document.addEventListener("visibilitychange",s),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("blur",n),r.current&&clearTimeout(r.current)}},[i])},yt=()=>{c.useEffect(()=>{const i=document.createElement("style");return i.textContent=`
9
+ */var $e=Symbol.for("react.transitional.element"),Oe=Symbol.for("react.fragment");function ve(i,r,t){var s=null;if(t!==void 0&&(s=""+t),r.key!==void 0&&(s=""+r.key),"key"in r){t={};for(var n in r)n!=="key"&&(t[n]=r[n])}else t=r;return r=t.ref,{$$typeof:$e,type:i,key:s,ref:r!==void 0?r:null,props:t}}ee.Fragment=Oe,ee.jsx=ve,ee.jsxs=ve,ye.exports=ee;var e=ye.exports;const F={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}}},oe="iw-storage";function Ue(){return typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ae&&ae.tagName.toUpperCase()==="SCRIPT"&&ae.src||new URL("widget.umd.js",document.baseURI).href}<"u"?"your-secure-encryption-seed-here":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 je=Ue(),le="AES-GCM",ce=12;async function ke(i){const t=new TextEncoder().encode(i),s=await crypto.subtle.digest("SHA-256",t);return crypto.subtle.importKey("raw",s,le,!1,["encrypt","decrypt"])}function qe(){return crypto.getRandomValues(new Uint8Array(ce))}async function We(i,r="default-seed"){try{const t=typeof i=="string"?i:JSON.stringify(i),n=new TextEncoder().encode(t),l=await ke(r),a=qe(),c=await crypto.subtle.encrypt({name:le,iv:a},l,n),u=new Uint8Array(a.length+c.byteLength);return u.set(new Uint8Array(a),0),u.set(new Uint8Array(c),a.length),btoa(String.fromCharCode(...Array.from(u)))}catch(t){throw console.error("Encryption failed:",t),new Error("Failed to encrypt data")}}async function Be(i,r="default-seed"){try{const t=atob(i),s=new Uint8Array(t.length);for(let w=0;w<t.length;w++)s[w]=t.charCodeAt(w);const n=s.slice(0,ce),l=s.slice(ce),a=await ke(r),c=await crypto.subtle.decrypt({name:le,iv:n},a,l);return new TextDecoder().decode(c)}catch(t){throw console.error("Decryption failed:",t),new Error("Failed to decrypt data")}}async function Ge(i,r="default-seed"){return We(i,r)}async function Ve(i,r="default-seed"){const t=await Be(i,r);try{return JSON.parse(t)}catch{return t}}const te=o.createContext(null),ze=async()=>{var i,r;try{const t=sessionStorage.getItem(oe);if(t){const s=await Ve(t,je);return{logViolations:((i=s.state)==null?void 0:i.logViolations)||[],totalViolations:((r=s.state)==null?void 0:r.totalViolations)||0}}}catch(t){console.error("Failed to load proctoring data from session storage:",t)}return{logViolations:[],totalViolations:0}},Ne=async i=>{try{const r=await Ge({state:i,version:0},je);sessionStorage.setItem(oe,r)}catch(r){console.error("Failed to save proctoring data to session storage:",r)}},He=({children:i})=>{const r=o.useRef({logViolations:[],totalViolations:0}),t=o.useRef(new Set);o.useEffect(()=>{ze().then(w=>{r.current=w,s()})},[]);const s=o.useCallback(()=>{t.current.forEach(w=>w())},[]),n=o.useCallback(w=>(t.current.add(w),()=>{t.current.delete(w)}),[]),l=o.useCallback(()=>r.current,[]),a=o.useCallback(w=>{r.current={logViolations:[...r.current.logViolations,w],totalViolations:r.current.totalViolations+1},Ne(r.current),s()},[s]),c=o.useCallback(()=>{r.current={logViolations:[],totalViolations:0},Ne(r.current),s()},[s]),u=o.useMemo(()=>({getState:l,addViolation:a,clearViolations:c,subscribe:n}),[l,a,c,n]);return e.jsx(te.Provider,{value:u,children:i})},Ye=()=>{const i=o.useContext(te);if(!i)throw new Error("useViolations must be used within a ProctoringProvider");return o.useSyncExternalStore(i.subscribe,()=>i.getState().logViolations,()=>i.getState().logViolations)},Qe=()=>{const i=o.useContext(te);if(!i)throw new Error("useTotalViolations must be used within a ProctoringProvider");return o.useSyncExternalStore(i.subscribe,()=>i.getState().totalViolations,()=>i.getState().totalViolations)},Ke=()=>{const i=o.useContext(te);if(!i)throw new Error("useProctoringActions must be used within a ProctoringProvider");return{addViolation:i.addViolation,clearViolations:i.clearViolations}},Ee=o.createContext(null);function Ce({config:i={},children:r}){var s,n,l,a;const t={api:{...F.api,...i.api,retryConfig:{...F.api.retryConfig,...(s=i.api)==null?void 0:s.retryConfig}},ui:{...F.ui,...i.ui},interview:{...F.interview,...i.interview,timers:{...F.interview.timers,...(n=i.interview)==null?void 0:n.timers},stt:{...F.interview.stt,...(l=i.interview)==null?void 0:l.stt},tts:{...F.interview.tts,...(a=i.interview)==null?void 0:a.tts}}};return e.jsx(Ee.Provider,{value:t,children:e.jsx(He,{children:r})})}function ie(){const i=o.useContext(Ee);if(!i)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return i}function Se(){return ie().api||F.api}function V(){return ie().ui||F.ui}function Je(){return ie().interview||F.interview}const Te=({className:i,...r})=>e.jsx("div",{children:e.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 ${i}`,...r,children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M12 6l0 -3"}),e.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),e.jsx("path",{d:"M18 12l3 0"}),e.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),e.jsx("path",{d:"M12 18l0 3"}),e.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),e.jsx("path",{d:"M6 12l-3 0"}),e.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),Ie=({children:i,variant:r="primary",size:t="md",fullWidth:s=!1,isLoading:n=!1,disabled:l,className:a="",...c})=>{const u="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",w={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"},m="iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none",f=s?"iw-w-full":"";return e.jsxs("button",{className:`${u} ${w[r]} ${h[t]} ${f} ${m} ${a}`,disabled:l||n,...c,children:[n&&e.jsx(Te,{height:16,width:16,style:{marginRight:"3px"}}),i]})};function Xe(i){const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:null}function Ze(i,r,t){return"#"+[i,r,t].map(s=>{const n=Math.round(s).toString(16);return n.length===1?"0"+n:n}).join("")}function Me(i,r){const t=Xe(i);if(!t)return i;const s=t.r+(255-t.r)*r,n=t.g+(255-t.g)*r,l=t.b+(255-t.b)*r;return Ze(s,n,l)}function et(i,r=.8){return{background:`linear-gradient(to bottom, ${Me(i,r)}, #ffffff)`,color:"#1f2937"}}function tt(i){return new Promise(r=>setTimeout(r,i))}function Ae(i){return`linear-gradient(to left, ${Me(i,.4)}, ${i})`}const it=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);function rt(i){try{const r=i.split(".");if(r.length!==3||!r[1])throw new Error("Invalid JWT token");const s=r[1].replace(/-/g,"+").replace(/_/g,"/"),n=s.padEnd(s.length+(4-s.length%4)%4,"="),l=atob(n);return JSON.parse(l)}catch(r){return console.error("Error decoding JWT:",r),null}}const De=i=>e.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",...i,children:[e.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"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]}),_e=i=>e.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",...i,children:[e.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),e.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),st=i=>e.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",...i,children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M15 8a5 5 0 0 1 0 8"}),e.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"})]}),G=i=>{const{baseColor:r,borderRadius:t}=V(),{loading:s,children:n,...l}=i;return e.jsx(Ie,{style:{background:Ae(r),borderRadius:t},...l,children:s?e.jsx(Te,{}):n})},nt=["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"],at=({isOpen:i,onStart:r,onClose:t})=>{var T;const s=o.useRef(null),n=o.useRef(null),{baseColor:l,borderRadius:a}=V(),[c,u]=o.useState(!1),[w,h]=o.useState(null),[m,f]=o.useState(!1),d=l??"#2563eb",p=Ae(d),y=a??18,k=(x,M)=>x.startsWith("#")&&x.length===7?`${x}${M}`:x,g=[`radial-gradient(120% 85% at 50% 125%, ${k(d,"34")} 0%, transparent 70%)`,`radial-gradient(90% 70% at 10% 130%, ${k(d,"24")} 0%, transparent 72%)`,`radial-gradient(90% 70% at 90% 130%, ${k(d,"24")} 0%, transparent 72%)`,`repeating-linear-gradient(135deg, ${k(d,"14")} 0, ${k(d,"14")} 16px, transparent 16px, transparent 32px)`].join(", "),j=c?{label:"Camera & microphone ready",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-emerald-400"}:m?{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"},C=c?{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."}:m?{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."},N=[{label:"Camera feed",description:C.cameraCopy,status:C.badge,toneClass:C.toneClass,Icon:_e},{label:"Microphone input",description:C.micCopy,status:C.badge,toneClass:C.toneClass,Icon:st}],D=()=>{n.current&&(n.current.getTracks().forEach(x=>x.stop()),n.current=null)},v=async()=>{f(!0),h(null);try{const x=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:!0});n.current=x,s.current&&(s.current.srcObject=x),u(!0)}catch(x){console.error("Media permission error:",x);let M="Unable to access camera or microphone.";(x==null?void 0:x.name)==="NotAllowedError"?M="Permissions denied. Please allow access to camera and microphone.":(x==null?void 0:x.name)==="NotFoundError"?M="No camera/microphone found. Please connect a device and retry.":x!=null&&x.message&&(M=x.message),u(!1),h(M)}finally{f(!1)}};if(o.useEffect(()=>{if(!i){D();return}return v(),()=>{D()}},[i]),!i)return null;const S=()=>{r(),D()};return e.jsx("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:e.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:[e.jsxs("div",{className:"iw-relative iw-overflow-hidden",style:{background:p},children:[e.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)"}}),e.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)"}}),e.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:[e.jsx("div",{className:"iw-flex iw-flex-col iw-gap-4 iw-text-white",children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[e.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:e.jsx(De,{className:"iw-h-6 iw-w-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-white/70",children:"Pre-interview checklist"}),e.jsx("h2",{className:"iw-mt-1 iw-text-xl iw-font-semibold iw-leading-tight",children:"Final checks before you go live"}),e.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."})]})]})}),e.jsx("div",{className:"iw-flex iw-items-start iw-justify-end",children:e.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 ${j.toneClass}`,children:[e.jsx("span",{className:`iw-inline-flex iw-h-2 iw-w-2 iw-rounded-full ${j.dotClass}`}),j.label]})}),t&&e.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:()=>{D(),t==null||t()},children:"✕"})]})]}),e.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-px-6 iw-pb-8 iw-pt-6",children:[e.jsxs("div",{className:"iw-grid xl:iw-grid-cols-[0.95fr_1.05fr] iw-gap-6",children:[e.jsx("section",{className:"iw-flex iw-flex-col iw-gap-5",children:e.jsxs("div",{className:"iw-rounded-2xl iw-border iw-border-slate-100 iw-bg-white iw-p-5 iw-shadow-sm",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-sm iw-font-semibold iw-text-slate-900",children:"Proctoring guidelines"}),e.jsx("span",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-slate-400",children:"Required"})]}),e.jsx("ul",{className:"iw-mt-5 iw-flex iw-flex-col iw-gap-4",children:nt.map((x,M)=>e.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:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[e.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:p},children:M+1}),e.jsx("span",{className:"iw-text-sm iw-text-slate-600",children:x})]})},x))})]})}),e.jsxs("section",{className:"iw-flex iw-flex-col iw-gap-5",children:[e.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-overflow-hidden iw-rounded-3xl iw-bg-white ",style:{borderRadius:y},children:[e.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:e.jsx("video",{ref:s,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-h-64 iw-w-full iw-rounded-2xl iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:y}})}),e.jsxs("div",{className:"iw-relative iw-grid iw-grid-cols-2 iw-gap-4 iw-px-1",children:[e.jsx(Ie,{onClick:v,disabled:m,variant:"outline",size:"sm",className:"iw-font-medium",style:{borderColor:d,borderRadius:y,color:d},children:c?"Recheck permissions":"Enable camera & mic"}),e.jsx(G,{onClick:S,disabled:!c,className:"iw-h-10 iw-px-6 iw-text-sm",style:{backgroundColor:d},children:"Proceed"})]})]}),e.jsx("ul",{className:"iw-grid sm:iw-grid-cols-1 iw-gap-3",children:N.map(({Icon:x,label:M,description:P,status:L,toneClass:O})=>e.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:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[e.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:e.jsx(x,{className:"iw-h-5 iw-w-5 iw-text-slate-600"})}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-gap-3",children:[e.jsx("p",{className:"iw-text-sm iw-font-medium iw-text-slate-800",children:M}),e.jsx("span",{className:`iw-rounded-full iw-px-3 iw-py-1 iw-text-[11px] iw-font-semibold ${O}`,children:L})]}),e.jsx("p",{className:"iw-mt-1.5 iw-text-xs iw-text-slate-500",children:P})]})]})},M))}),w&&e.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:w}),!((T=navigator.mediaDevices)!=null&&T.getUserMedia)&&e.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."})]})]}),e.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:e.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."})}),e.jsx("div",{"aria-hidden":!0,className:"iw-pointer-events-none iw-absolute iw-inset-x-0 iw-bottom-1 iw-h-20",style:{backgroundImage:g,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)"}})]})]})})};var I=(i=>(i.IDLE="idle",i.FETCHING_QUESTION="fetching_question",i.READING_QUESTION="reading_question",i.THINKING="thinking",i.ANSWERING="answering",i.TRANSCRIBING="transcribing",i.EDITING="editing",i.SUBMITTING="submitting",i.COMPLETED="completed",i))(I||{});const ot={thinkingDuration:30,answeringDuration:120,editingDuration:30},lt={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 ct{constructor(r={},t={}){R(this,"config");R(this,"state");R(this,"phaseIntervalId",null);R(this,"globalIntervalId",null);R(this,"callbacks");this.config={...ot,...r},this.callbacks=t,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 r=this.state.phase,t=lt[r];if(!t)return;this.stopPhaseTimer(),this.state.phase=t.next;const s=this.getDurationForPhase(t.next);s>0?(this.state.currentPhaseTimeRemaining=s,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}completeInterview(){var r,t;this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(t=(r=this.callbacks).onInterviewEnd)==null||t.call(r),this.notifyChange()}destroy(){this.stopPhaseTimer(),this.stopGlobalTimer()}getDurationForPhase(r){switch(r){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 r,t;this.state.totalTimeElapsed++,(t=(r=this.callbacks).onTick)==null||t.call(r,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 r,t;(t=(r=this.callbacks).onPhaseChange)==null||t.call(r,this.state.phase,this.getState())}}function dt(i={}){const{config:r={},callbacks:t={}}=i,s=o.useRef(null);s.current||(s.current=new ct(r,{}));const n=s.current,[l,a]=o.useState(n.getState()),c=o.useCallback(()=>{a(n.getState())},[n]);o.useEffect(()=>{const m={onPhaseChange:(f,d)=>{var p;c(),(p=t.onPhaseChange)==null||p.call(t,f,d)},onTick:f=>{var d;c(),(d=t.onTick)==null||d.call(t,f)},onInterviewEnd:()=>{var f;c(),(f=t.onInterviewEnd)==null||f.call(t)}};n.callbacks=m},[n,t,c]),o.useEffect(()=>()=>{n.destroy()},[n]);const u=o.useCallback(()=>{n.startQuestion(),c()},[n,c]),w=o.useCallback(()=>{n.nextPhase(),c()},[n,c]),h=o.useCallback(()=>{n.completeInterview(),c()},[n,c]);return{state:l,startQuestion:u,nextPhase:w,completeInterview:h,timerService:n}}function wt(i,r={}){const[t,s]=o.useState({data:null,loading:!1,error:null}),n=o.useCallback(async(...l)=>{var a,c,u,w;s(h=>({...h,loading:!0,error:null}));try{const h=await i(...l);s(m=>({...m,data:h,loading:!1,error:null})),(a=r.onSuccess)==null||a.call(r,h),(c=r.onSettled)==null||c.call(r,h,null)}catch(h){const m=h.type?h:{type:"unknown",message:h.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:h};s(f=>({...f,loading:!1,error:m})),(u=r.onError)==null||u.call(r,m),(w=r.onSettled)==null||w.call(r,null,m)}},[i,r]);return{...t,execute:n}}const ut=i=>{const[r,t]=o.useState(null),[s,n]=o.useState(!1),l=document,a=()=>!!(l.fullscreenEnabled||l.webkitFullscreenEnabled||l.mozFullScreenEnabled||l.msFullscreenEnabled),c=()=>l.fullscreenElement||l.webkitFullscreenElement||l.mozFullScreenElement||l.msFullscreenElement,u=async d=>{var p;try{if(!a())throw new Error("Fullscreen is not supported in this environment");d.requestFullscreen?await d.requestFullscreen():d.webkitRequestFullscreen?await d.webkitRequestFullscreen():d.mozRequestFullScreen?await d.mozRequestFullScreen():d.msRequestFullscreen&&await d.msRequestFullscreen()}catch(y){const k={name:"FullscreenError",message:y instanceof Error?y.message:"Failed to enter fullscreen"};t(k),(p=i==null?void 0:i.onError)==null||p.call(i,k)}},w=async()=>{var d;try{l.exitFullscreen?await l.exitFullscreen():l.webkitExitFullscreen?await l.webkitExitFullscreen():l.mozCancelFullScreen?await l.mozCancelFullScreen():l.msExitFullscreen&&await l.msExitFullscreen()}catch(p){const y={name:"FullscreenError",message:p instanceof Error?p.message:"Failed to exit fullscreen"};t(y),(d=i==null?void 0:i.onError)==null||d.call(i,y)}},h=o.useCallback(()=>{var p;const d=!!c();n(d),(p=i==null?void 0:i.onFullScreenChange)==null||p.call(i,d)},[i]);o.useEffect(()=>{const d=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return d.forEach(p=>{document.addEventListener(p,h)}),()=>{d.forEach(p=>{document.removeEventListener(p,h)})}},[h]);const m=async d=>{t(null);const p=d??document.documentElement;await u(p)};return{isFullScreen:s,toggleFullScreen:async d=>{s?await w():await m(d)},enterFullScreen:m,exitFullScreen:w,error:r}};function ht(i){var r;if(!navigator.onLine)return{type:"network",message:"No internet connection",retryable:!0,userMessage:"Please check your internet connection and try again."};if(i.name==="AbortError"||(r=i.message)!=null&&r.includes("timeout"))return{type:"timeout",message:"Request timed out",retryable:!0,userMessage:"The request is taking longer than expected. Please try again."};if(i.status){const{status:t}=i;if(t===401||t===403)return{type:"auth",status:t,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(t===429)return{type:"rate-limit",status:t,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(t>=500)return{type:"server",status:t,message:`Server error: ${t}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(t>=400)return{type:"client",status:t,message:`Client error: ${t}`,retryable:!1,userMessage:"There was an issue with your request. Please check your input."}}return{type:"unknown",message:i.message||"Unknown error occurred",retryable:!0,userMessage:"Something unexpected happened. Please try again.",originalError:i}}async function de(i,r={},t={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let s;for(let n=1;n<=t.attempts;n++)try{const l=new AbortController,a=setTimeout(()=>l.abort(),6e4),c=await fetch(i,{...r,signal:l.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(l){s=l;const a=ht(l);if(!a.retryable||n===t.attempts)throw a;const c=mt(n,t);console.warn(`API request failed (attempt ${n}/${t.attempts}), retrying in ${c}ms:`,a.message),await new Promise(u=>setTimeout(u,c))}throw s}function mt(i,r){let t;return r.backoff==="exponential"?t=r.baseDelay*Math.pow(2,i-1):t=r.baseDelay,t=Math.min(t,r.maxDelay),r.jitter&&(t=t*(.5+Math.random()*.5)),Math.round(t)}class ft{constructor(r={}){R(this,"config");this.config=r}updateConfig(r){this.config={...this.config,...r}}getHeaders(){var t;const r={"Content-Type":"application/json"};return(t=this.config)!=null&&t.authToken&&(r.Authorization=`Bearer ${this.config.authToken}`),r}getBaseUrl(){var r;return((r=this.config)==null?void 0:r.baseUrl)||"/api"}async generateQuestion({interviewId:r,isInterviewDone:t=!1,qnaId:s,question:n,answer:l,answerDuration:a}){const c=await de(`${this.getBaseUrl()}/questions/next`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:r,is_interview_done:t,qna_id:s,question:n,answer:l,answer_duration:a??"00:00:30"})});if(!c.ok)throw new Error(`Failed to get questions: ${c.status}`);return await c.json()}}function gt(){const i=ie();return o.useMemo(()=>{const t=i.api||{};return new ft(t)},[i.api])}const xt=i=>{o.useEffect(()=>{const r=s=>{(s.ctrlKey||s.metaKey)&&["c","v","a","t","n","w","r","s","p"].includes(s.key.toLowerCase())&&(s.preventDefault(),i({type:"blocked_shortcut",severity:"low",details:{action:"shortcut_pressed",reason:`Attempted to use a blocked keyboard shortcut: Ctrl + ${s.key}`}})),s.key.startsWith("F")&&s.key.length<=3&&(s.preventDefault(),i({type:"blocked_function_key",severity:"low",details:{action:"function_key_pressed",reason:`Attempted to use a blocked function key: ${s.key}`}})),s.altKey&&s.key==="Tab"&&(s.preventDefault(),i({type:"alt_tab_attempt",severity:"medium",details:{action:"alt_tab",reason:"Attempted to use the Alt + Tab shortcut"}}))},t=s=>{s.preventDefault(),i({type:"right_click_attempt",severity:"low",details:{action:"right_click",reason:"Attempted to use the right click"}})};return document.addEventListener("keydown",r),document.addEventListener("contextmenu",t),()=>{document.removeEventListener("keydown",r),document.removeEventListener("contextmenu",t)}},[i])};class E extends Error{constructor(r,t,s=!1){super(r),this.code=t,this.recoverable=s,this.name="STTError"}}class pt{constructor(r={}){R(this,"config");R(this,"mediaRecorder",null);R(this,"audioChunks",[]);R(this,"recordingStream",null);R(this,"autoStopTimeoutId",null);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...r}}updateConfig(r){this.config={...this.config,...r}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(r,t){var s;if(!this.isRecordingSupported())throw new E("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new E("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=l=>{var a;l.data.size>0&&(this.audioChunks.push(l.data),(a=t==null?void 0:t.onDataAvailable)==null||a.call(t,l.data))},this.mediaRecorder.onstop=()=>{var l;(l=t==null?void 0:t.onStop)==null||l.call(t)},this.mediaRecorder.onerror=l=>{var c;const a=new E(`Recording failed: ${l.error}`,"RECORDING_ERROR",!0);(c=t==null?void 0:t.onError)==null||c.call(t,a),this.cleanup()},this.mediaRecorder.start(100),(s=t==null?void 0:t.onStart)==null||s.call(t),r&&r>0&&(this.autoStopTimeoutId=setTimeout(()=>{this.isRecording()&&this.stopRecording()},r*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new E("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new E("No microphone found","NO_MICROPHONE",!1)}throw new E(`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 E("No active recording to stop","NO_ACTIVE_RECORDING",!1);return new Promise((r,t)=>{if(!this.mediaRecorder){t(new E("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const s=this.mediaRecorder,n=()=>{try{const l=s.mimeType||"audio/webm",a=new Blob(this.audioChunks,{type:l});this.cleanup(),r(a)}catch(l){t(new E(`Failed to create audio blob: ${l instanceof Error?l.message:String(l)}`,"BLOB_CREATION_FAILED",!1))}};s.addEventListener("stop",n,{once:!0}),s.stop()})}async transcribe(r){const{audioBlob:t,model:s=this.config.model,language:n=this.config.language,includeTimestamps:l=this.config.includeTimestamps,temperature:a=this.config.temperature}=r;if(!t||t.size===0)throw new E("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const c=new FormData,u=new File([t],"recording.wav",{type:t.type||"audio/wav"});c.append("file",u),c.append("model",s||"whisper-large-v3-turbo"),c.append("language",n||"en"),c.append("include_timestamps",String(l||!1)),c.append("temperature",String(a||0));const w=await de(`${this.config.baseUrl}/speech/transcribe`,{method:"POST",headers:{accept:"application/json","X-STT-Provider":this.config.provider||"groq",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:c},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!w.ok){const m=await w.text();let f=`STT request failed: ${w.status} ${w.statusText}`;try{const d=JSON.parse(m);f=d.message||d.error||f}catch{f=m||f}throw new E(f,`HTTP_${w.status}`,w.status>=500)}return{transcript:(await w.json()).data.text??""}}catch(c){throw c instanceof E?c:new E(`Transcription failed: ${c instanceof Error?c.message:String(c)}`,"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 r=["audio/webm","audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4","audio/wav"];for(const t of r)if(MediaRecorder.isTypeSupported(t))return t;return"audio/webm"}cleanup(){this.recordingStream&&(this.recordingStream.getTracks().forEach(r=>r.stop()),this.recordingStream=null),this.mediaRecorder=null,this.audioChunks=[],this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}}const z=new pt,bt=(i={})=>{const[r,t]=o.useState(!1),[s,n]=o.useState(!1),[l,a]=o.useState(null),[c,u]=o.useState(null),[w,h]=o.useState(null);i.config&&z.updateConfig(i.config);const m=o.useCallback(async y=>{var k;try{u(null),a(null),h(null),await z.startRecording(y,{onStart:()=>{var g;t(!0),(g=i.onStart)==null||g.call(i)},onStop:()=>{var g;t(!1),(g=i.onStop)==null||g.call(i)},onError:g=>{var C;const j=g instanceof E?g:new E(g.message,"RECORDING_ERROR",!0);u(j),t(!1),(C=i.onError)==null||C.call(i,j)}})}catch(g){const j=g instanceof E?g:new E(g instanceof Error?g.message:String(g),"START_FAILED",!1);throw u(j),t(!1),(k=i.onError)==null||k.call(i,j),j}},[]),f=o.useCallback(async()=>{var y,k;try{const g=await z.stopRecording();return h(g),t(!1),(y=i.onStop)==null||y.call(i),g}catch(g){const j=g instanceof E?g:new E(g instanceof Error?g.message:String(g),"STOP_FAILED",!1);throw u(j),t(!1),(k=i.onError)==null||k.call(i,j),j}},[]),d=o.useCallback(async(y,k={})=>{var g,j;try{u(null),n(!0);const C={audioBlob:y,...k},N=await z.transcribe(C);return a(N.transcript),n(!1),(g=i.onTranscriptionComplete)==null||g.call(i,N),N}catch(C){const N=C instanceof E?C:new E(C instanceof Error?C.message:String(C),"TRANSCRIPTION_FAILED",!0);throw u(N),n(!1),(j=i.onError)==null||j.call(i,N),N}},[]),p=o.useCallback(()=>{z.cancelRecording(),t(!1),h(null)},[]);return{startRecording:m,stopRecording:f,transcribe:d,cancelRecording:p,isRecording:r,isTranscribing:s,transcript:l,error:c,audioBlob:w}},yt=i=>{const r=o.useRef(null),t=o.useRef(!1);o.useEffect(()=>{const s=()=>{document.hidden&&(t.current=!0,r.current&&(clearTimeout(r.current),r.current=null),i({type:"tab_switch",severity:"high",details:{action:"tab_hidden",reason:"Attempted to switch tabs or applications"}}),setTimeout(()=>{t.current=!1},100))},n=()=>{t.current||(r.current=setTimeout(()=>{t.current||i({type:"focus_loss",severity:"medium",details:{action:"window_blur",reason:"Focus lost from the interview window"}}),r.current=null},50))};return document.addEventListener("visibilitychange",s),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("blur",n),r.current&&clearTimeout(r.current)}},[i])},vt=()=>{o.useEffect(()=>{const i=document.createElement("style");return i.textContent=`
10
10
  * {
11
11
  -webkit-user-select: none !important;
12
12
  -moz-user-select: none !important;
@@ -19,7 +19,7 @@
19
19
  -ms-user-select: text !important;
20
20
  user-select: text !important;
21
21
  }
22
- `,document.head.appendChild(i),()=>{document.head.removeChild(i)}},[])};class vt{constructor(r={}){R(this,"config");R(this,"currentAudio",null);this.config={baseUrl:"http://localhost:8000",provider:"piper",voice:"string",speed:1,...r}}updateConfig(r){this.config={...this.config,...r}}async synthesizeSpeech(r){const{text:t,voice:s=this.config.voice,speed:n=this.config.speed}=r,o=new URLSearchParams;o.append("text",t),o.append("voice",s||"string"),o.append("speed",(n==null?void 0:n.toString())||"1");const a=await le(`${this.config.baseUrl}/speech/synthesize`,{method:"POST",headers:{accept:"application/json","X-TTS-Provider":this.config.provider||"piper","Content-Type":"application/x-www-form-urlencoded",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:o},{attempts:1,backoff:"fixed",baseDelay:1e3,maxDelay:1e3,jitter:!1});if(!a.ok)throw new Error(`TTS request failed: ${a.status} ${a.statusText}`);const l=a.headers.get("content-type");if(l&&l.includes("audio/"))return a.blob();try{const w=await a.json();throw new Error(`TTS Error: ${JSON.stringify(w)}`)}catch{throw new Error("TTS request failed with unknown error")}}async speak(r,t){var s,n;try{this.stop(),(s=t==null?void 0:t.onStart)==null||s.call(t);const o=await this.synthesizeSpeech(r),a=URL.createObjectURL(o);return this.currentAudio=new Audio(a),new Promise((l,w)=>{if(!this.currentAudio){w(new Error("Audio element not created"));return}const d=this.currentAudio;d.onended=()=>{var h;URL.revokeObjectURL(a),this.currentAudio=null,(h=t==null?void 0:t.onEnd)==null||h.call(t),l()},d.onerror=h=>{var f;URL.revokeObjectURL(a),this.currentAudio=null;const m=new Error(`Audio playback failed: ${h}`);(f=t==null?void 0:t.onError)==null||f.call(t,m),w(m)},d.play().catch(h=>{var f;URL.revokeObjectURL(a),this.currentAudio=null;const m=new Error(`Failed to play audio: ${h.message}`);(f=t==null?void 0:t.onError)==null||f.call(t,m),w(m)})})}catch(o){const a=o instanceof Error?o:new Error(`TTS Error: ${String(o)}`);throw(n=t==null?void 0:t.onError)==null||n.call(t,a),a}}stop(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.currentTime=0,this.currentAudio=null)}isPlaying(){return this.currentAudio!==null&&!this.currentAudio.paused}}const ce=new vt,jt=(i={})=>{const[r,t]=c.useState(!1),[s,n]=c.useState(!1),[o,a]=c.useState(null);i.config&&ce.updateConfig(i.config);const l=c.useCallback(async(d,h={})=>{var m;try{a(null),n(!0);const f={text:d,...h};await ce.speak(f,{onStart:()=>{var u;n(!1),t(!0),(u=i.onStart)==null||u.call(i)},onEnd:()=>{var u;t(!1),(u=i.onEnd)==null||u.call(i)},onError:u=>{var x;t(!1),n(!1),a(u),(x=i.onError)==null||x.call(i,u)}})}catch(f){const u=f instanceof Error?f:new Error(String(f));throw a(u),t(!1),n(!1),(m=i.onError)==null||m.call(i,u),u}},[i]),w=c.useCallback(()=>{ce.stop(),t(!1),n(!1)},[]);return{speak:l,stop:w,isPlaying:r,isLoading:s,error:o}},kt=({onViolation:i,onEnd:r,maxViolations:t=5})=>{const{addViolation:s}=Qe(),n=He(),o=Ye(),a=c.useRef(o);c.useEffect(()=>{a.current=o},[o]);const l=c.useCallback(d=>{r&&r(d,a.current)},[r]);return{logViolation:c.useCallback(({type:d,severity:h,details:m})=>{const f={id:tt(),type:d,severity:h,details:m,timestamp:Date.now()};s(f);const u=a.current+1;i&&i(f,u),u>=t&&l("excessive_violations")},[s,i,t,l]),onInterviewEnd:l,violationCount:o,logList:n}},Nt=()=>{c.useEffect(()=>{function i(){console.clear(),console.log(`
22
+ `,document.head.appendChild(i),()=>{document.head.removeChild(i)}},[])};class jt{constructor(r={}){R(this,"config");R(this,"currentAudio",null);this.config={baseUrl:"http://localhost:8000",provider:"piper",voice:"string",speed:1,...r}}updateConfig(r){this.config={...this.config,...r}}async synthesizeSpeech(r){const{text:t,voice:s=this.config.voice,speed:n=this.config.speed}=r,l=new URLSearchParams;l.append("text",t),l.append("voice",s||"string"),l.append("speed",(n==null?void 0:n.toString())||"1");const a=await de(`${this.config.baseUrl}/speech/synthesize`,{method:"POST",headers:{accept:"application/json","X-TTS-Provider":this.config.provider||"piper","Content-Type":"application/x-www-form-urlencoded",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:l},{attempts:1,backoff:"fixed",baseDelay:1e3,maxDelay:1e3,jitter:!1});if(!a.ok)throw new Error(`TTS request failed: ${a.status} ${a.statusText}`);const c=a.headers.get("content-type");if(c&&c.includes("audio/"))return a.blob();try{const u=await a.json();throw new Error(`TTS Error: ${JSON.stringify(u)}`)}catch{throw new Error("TTS request failed with unknown error")}}async speak(r,t){var s,n;try{this.stop(),(s=t==null?void 0:t.onStart)==null||s.call(t);const l=await this.synthesizeSpeech(r),a=URL.createObjectURL(l);return this.currentAudio=new Audio(a),new Promise((c,u)=>{if(!this.currentAudio){u(new Error("Audio element not created"));return}const w=this.currentAudio;w.onended=()=>{var h;URL.revokeObjectURL(a),this.currentAudio=null,(h=t==null?void 0:t.onEnd)==null||h.call(t),c()},w.onerror=h=>{var f;URL.revokeObjectURL(a),this.currentAudio=null;const m=new Error(`Audio playback failed: ${h}`);(f=t==null?void 0:t.onError)==null||f.call(t,m),u(m)},w.play().catch(h=>{var f;URL.revokeObjectURL(a),this.currentAudio=null;const m=new Error(`Failed to play audio: ${h.message}`);(f=t==null?void 0:t.onError)==null||f.call(t,m),u(m)})})}catch(l){const a=l instanceof Error?l:new Error(`TTS Error: ${String(l)}`);throw(n=t==null?void 0:t.onError)==null||n.call(t,a),a}}stop(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.currentTime=0,this.currentAudio=null)}isPlaying(){return this.currentAudio!==null&&!this.currentAudio.paused}}const we=new jt,kt=(i={})=>{const[r,t]=o.useState(!1),[s,n]=o.useState(!1),[l,a]=o.useState(null);i.config&&we.updateConfig(i.config);const c=o.useCallback(async(w,h={})=>{var m;try{a(null),n(!0);const f={text:w,...h};await we.speak(f,{onStart:()=>{var d;n(!1),t(!0),(d=i.onStart)==null||d.call(i)},onEnd:()=>{var d;t(!1),(d=i.onEnd)==null||d.call(i)},onError:d=>{var p;t(!1),n(!1),a(d),(p=i.onError)==null||p.call(i,d)}})}catch(f){const d=f instanceof Error?f:new Error(String(f));throw a(d),t(!1),n(!1),(m=i.onError)==null||m.call(i,d),d}},[i]),u=o.useCallback(()=>{we.stop(),t(!1),n(!1)},[]);return{speak:c,stop:u,isPlaying:r,isLoading:s,error:l}},Nt=({onViolation:i,onEnd:r,maxViolations:t=5})=>{const{addViolation:s}=Ke(),n=Ye(),l=Qe(),a=o.useRef(l);o.useEffect(()=>{a.current=l},[l]);const c=o.useCallback(w=>{r&&r(w,a.current)},[r]);return{logViolation:o.useCallback(({type:w,severity:h,details:m})=>{const f={id:it(),type:w,severity:h,details:m,timestamp:Date.now()};s(f);const d=a.current+1;i&&i(f,d),d>=t&&c("excessive_violations")},[s,i,t,c]),onInterviewEnd:c,violationCount:l,logList:n}},Et=()=>{o.useEffect(()=>{function i(){console.clear(),console.log(`
23
23
  %c
24
24
  ╔═══════════════════════════════════════════════════════════════════════╗
25
25
  ║ ║
@@ -65,7 +65,7 @@
65
65
  │ │
66
66
  │ 💡 IMMEDIATE ACTION REQUIRED: │
67
67
  │ Close developer tools to continue interview │
68
- └─────────────────────────────────────────────────────────────┘`,"color: #ffd93d; font-size: 14px; font-family: monospace; background: rgba(255, 217, 61, 0.1); padding: 10px;")}const r={open:!1,orientation:null},t=160,s=setInterval(()=>{window.outerHeight-window.innerHeight>t||window.outerWidth-window.innerWidth>t?r.open||(r.open=!0,r.orientation=window.outerWidth-window.innerWidth>t?"vertical":"horizontal",i()):r.open&&(r.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},o=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",o),()=>{clearInterval(s),document.removeEventListener("keydown",n),document.removeEventListener("contextmenu",o),delete window.showStats,delete window.interviewTips}},[])},de=i=>e.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",...i,children:[e.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),e.jsx("path",{d:"M12 6v6l4 2"}),e.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),e.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),e.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),e.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),Et=(i,r,t)=>Math.max(r,Math.min(t,i)),De=i=>{const r=Math.max(0,Math.floor(i)),t=Math.floor(r/60).toString().padStart(2,"0"),s=(r%60).toString().padStart(2,"0");return`${t}:${s}`},we=({total:i,remaining:r,size:t=64,strokeWidth:s=6,className:n="",showLabel:o=!0})=>{const a=Math.max(1,i||1),l=Et(r/a,0,1),{radius:w,circumference:d,dashOffset:h,center:m}=c.useMemo(()=>{const x=(t-s)/2,j=2*Math.PI*x,k=j*(1-l),p=Math.round(s)%2===1,N=t/2+(p?.5:0);return{radius:x,circumference:j,dashOffset:k,center:N}},[t,s,l]),f=c.useMemo(()=>l<=.25?"iw-stroke-red-500":l<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[l]),u=l<=.25?"iw-animate-pulse":"";return e.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${n}`,style:{width:t,height:t},"aria-label":`Time remaining ${De(r)}`,role:"timer","aria-live":"polite",children:[e.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,preserveAspectRatio:"xMidYMid meet",children:e.jsxs("g",{transform:`rotate(-90 ${m} ${m})`,children:[e.jsx("circle",{cx:m,cy:m,r:w,className:"iw-stroke-gray-200",strokeWidth:s,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),e.jsx("circle",{cx:m,cy:m,r:w,className:`${f} ${u}`,strokeWidth:s,strokeLinecap:"round",fill:"none",strokeDasharray:d,strokeDashoffset:h,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),o&&e.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:e.jsx("span",{className:`iw-text-[11px] iw-font-semibold iw-tabular-nums ${l<=.25?"iw-text-red-600":l<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:De(r)})})]})},Ct=({label:i,error:r,fullWidth:t=!1,className:s="",id:n,...o})=>{const a=n||`textarea-${Math.random().toString(36).substring(2,9)}`,l="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",w=r?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",d=t?"iw-w-full":"",h=s.includes("iw-h-full")||t?"iw-h-full":"";return e.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${t?"iw-w-full":""}`,children:[i&&e.jsx("label",{htmlFor:a,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:i}),e.jsx("textarea",{id:a,className:`${l} ${w} ${d} ${h} ${s}`,"aria-invalid":r?"true":"false",...o}),r&&e.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:r})]})},St=({value:i,onChange:r,onSubmit:t,isSubmitDisabled:s,state:n,editingTime:o})=>{const a=l=>{l.key==="Enter"&&(l.ctrlKey||l.metaKey)&&!s&&(l.preventDefault(),t())};return e.jsxs("div",{className:"iw-flex iw-flex-col iw-h-full ",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Your Answer"}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(de,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to edit: "})]}),e.jsx(we,{total:o,remaining:n.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),e.jsxs("div",{className:" iw-overflow-hidden iw-flex iw-flex-col iw-h-full iw-mt-2",children:[e.jsx(Ct,{value:i,onChange:r,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:l=>l.preventDefault(),onCopy:l=>l.preventDefault(),onCut:l=>l.preventDefault(),onDrop:l=>l.preventDefault(),onDragOver:l=>l.preventDefault()}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1 iw-mt-4",children:e.jsx(B,{onClick:t,disabled:s,children:"Submit Answer"})})]})]})},Tt=({className:i=""})=>{var n;const{authToken:r}=Ee(),t=r?it(r):null,s=c.useRef(null);return c.useEffect(()=>{let o=null;return(async()=>{try{o=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1}),s.current&&(s.current.srcObject=o)}catch(l){console.error("Error accessing camera:",l)}})(),()=>{o&&o.getTracks().forEach(l=>l.stop())}},[]),e.jsxs("div",{className:`iw-relative ${i}`,children:[e.jsx("video",{ref:s,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-[400px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)"}}),e.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:[e.jsx("div",{className:"iw-size-2 iw-animate-pulse iw-rounded-full iw-bg-red-500"}),e.jsx("span",{className:"iw-font-medium iw-text-white",children:"Recording"})]}),((n=t==null?void 0:t.data)==null?void 0:n.user_name)&&e.jsx("div",{className:"iw-absolute 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:e.jsx("span",{className:"iw-font-medium iw-text-white",children:t.data.user_name})})]})},It=({question:i,isLoading:r=!1})=>{const{baseColor:t}=V();return e.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-p-6 ",style:Ze(t,.85),children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-8",children:[e.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:e.jsx("div",{className:"iw-mt-2",children:e.jsx("img",{src:"https://duf9q5sx7u.ufs.sh/f/va7H6eSeKAux755zByRN5Nq9LZurgIoJGYX6c0CEdRSDm8y2",alt:"brand_logo",className:"iw-h-28 iw-w-28"})})}),r?e.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[e.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),e.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]}):e.jsx("p",{className:"iw-text-lg iw-leading-8",children:i==null?void 0:i.question})]})})},_e=({currentQuestion:i,phase:r,className:t="",children:s})=>e.jsxs("div",{className:`iw-p-4 iw-space-y-4 iw-pb-6 ${t} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,children:[e.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3",children:e.jsx("div",{className:"iw-flex-1",children:e.jsx(It,{question:i,isLoading:r===A.FETCHING_QUESTION||r===A.IDLE})})}),e.jsxs("div",{className:"iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-[14px] iw-p-6",children:[e.jsx("div",{className:"iw-min-h-[400px] iw-max-h-[600px]",children:e.jsx(Tt,{})}),e.jsx("div",{className:"iw-bg-white iw-rounded-r-xl iw-shadow iw-p-6",children:s})]})]}),Re=({isOpen:i,onClose:r,children:t,title:s,showCloseButton:n=!0,closeOnOverlayClick:o=!0,closeOnEscape:a=!0,className:l=""})=>{if(c.useEffect(()=>{if(!i||!a)return;const h=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[i,a,r]),c.useEffect(()=>(i?(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")}),[i]),!i)return null;const w=h=>{o&&h.target===h.currentTarget&&r()},d=e.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center",children:[e.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",onClick:w}),e.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 ${l}`,role:"dialog","aria-modal":"true","aria-labelledby":s?"dialog-title":void 0,children:[(s||n)&&e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[s&&e.jsx("h2",{id:"dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:s}),n&&e.jsx("button",{onClick:r,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:e.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:t})]})]});return W.createPortal(d,document.body)},Mt=({confirmExitInterview:i,isOpen:r,onClose:t})=>e.jsx(Re,{isOpen:r,onClose:t,title:"Exit Interview",closeOnOverlayClick:!1,children:e.jsxs("div",{className:"iw-space-y-5",children:[e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-rounded-xl iw-p-2",children:[e.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:"!"}),e.jsxs("div",{className:"iw-space-y-2",children:[e.jsx("p",{className:"iw-text-sm iw-font-semibold iw-text-rose-600",children:"Leaving now will end your interview !"}),e.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."})]})]}),e.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:[e.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:t,children:"Stay in interview"}),e.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:i,children:"Confirm exit"})]})]})}),Pe=({title:i,onExit:r})=>{const{baseColor:t}=V(),[s,n]=c.useState(!1);return e.jsxs("header",{className:"iw-w-full iw-text-gray-900",children:[e.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-pb-4 iw-pt-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[e.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:t},children:"N"}),e.jsx("p",{className:"iw-text-sm iw-font-medium",children:"Novara"})]}),e.jsx("h1",{className:"iw-text-base iw-font-bold",children:i}),e.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:()=>n(!0),children:"Exit Interview"})]}),e.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),e.jsx(Mt,{isOpen:s,confirmExitInterview:()=>{r(),n(!1)},onClose:()=>n(!1)})]})},At=({className:i="",width:r,height:t=56,barWidth:s=3,gap:n=2,fftSize:o=1024,smoothingTimeConstant:a=.8,mediaStream:l,startOnMount:w=!0})=>{const{baseColor:d}=V(),h=c.useRef(null),m=c.useRef(null),f=c.useRef(null),u=c.useRef(null),x=c.useRef(null),j=c.useRef(null),k=c.useRef(!1),[p,N]=c.useState(null);c.useEffect(()=>{if(r||!m.current)return;const v=m.current,_=()=>{const M=h.current;if(!M)return;const T=v.clientWidth,g=t;M.width=Math.max(1,Math.floor(T*window.devicePixelRatio||1)),M.height=Math.max(1,Math.floor(g*window.devicePixelRatio||1))},y=new ResizeObserver(_);return y.observe(v),_(),()=>y.disconnect()},[r,t]),c.useEffect(()=>{if(!r)return;const v=h.current;v&&(v.width=Math.max(1,Math.floor(r*(window.devicePixelRatio||1))),v.height=Math.max(1,Math.floor(t*(window.devicePixelRatio||1))))},[r,t]),c.useEffect(()=>{let v=!1;return(async()=>{try{const y=new(window.AudioContext||window.webkitAudioContext);f.current=y;let M=l;if(!M){if(!w)return;M=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),k.current=!0}if(v)return;const T=y.createAnalyser();T.fftSize=o,T.smoothingTimeConstant=a,u.current=T;const g=y.createMediaStreamSource(M);x.current=g,g.connect(T),E()}catch(y){N((y==null?void 0:y.message)||"Failed to initialize microphone")}})(),()=>{var y,M,T,g;v=!0,j.current&&cancelAnimationFrame(j.current);try{(y=x.current)==null||y.disconnect()}catch{}try{(M=u.current)==null||M.disconnect()}catch{}k.current&&((g=((T=x.current)==null?void 0:T.mediaStream)||void 0)==null||g.getTracks().forEach(S=>S.stop())),f.current&&f.current.state!=="closed"&&f.current.close()}},[l,o,a,w]);const E=()=>{const v=h.current,_=u.current;if(!v||!_)return;const y=v.getContext("2d");if(!y)return;const M=window.devicePixelRatio||1,T=v.width,g=v.height,S=_.frequencyBinCount,P=new Uint8Array(S),U=()=>{j.current=requestAnimationFrame(U),_.getByteTimeDomainData(P),y.clearRect(0,0,T,g),y.fillStyle="rgba(0,0,0,0)",y.fillRect(0,0,T,g);const O=Math.max(1,Math.floor(s*M)),H=Math.max(1,Math.floor(n*M)),Y=O+H,L=Math.max(8,Math.floor((T+H)/Y)),G=Math.floor(P.length/L);for(let I=0;I<L;I++){const Q=Math.min(P.length-1,I*G),me=P[Q]/128-1,q=Math.abs(me),fe=Math.pow(q,.6),K=Math.max(g*.06,fe*(g*.9)),ge=I*Y,xe=(g-K)/2,J=140-Math.min(140,140*q),re=85,b=48+Math.floor(12*(1-q));y.fillStyle=`${d}`,y.shadowColor=`hsla(${J}, ${re}%, ${b}%, ${.25*q})`,y.shadowBlur=8*q;const $=Math.min(O/2,K/2);Dt(y,ge,xe,O,K,$),y.fill()}};U()};return e.jsxs("div",{ref:m,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${i}`,style:{height:t},children:[e.jsx("canvas",{ref:h,className:"iw-w-full iw-h-full"}),p&&e.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:e.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 Dt(i,r,t,s,n,o){const a=Math.min(o,s/2,n/2);i.beginPath(),i.moveTo(r+a,t),i.lineTo(r+s-a,t),i.quadraticCurveTo(r+s,t,r+s,t+a),i.lineTo(r+s,t+n-a),i.quadraticCurveTo(r+s,t+n,r+s-a,t+n),i.lineTo(r+a,t+n),i.quadraticCurveTo(r,t+n,r,t+n-a),i.lineTo(r,t+a),i.quadraticCurveTo(r,t,r+a,t),i.closePath()}const _t=({state:i,answeringTime:r,nextPhase:t,sttError:s})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.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...."}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(de,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),e.jsx(we,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),e.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."})]}),e.jsxs("div",{children:[e.jsx(At,{}),s&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",s.message]})]}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:e.jsx(B,{onClick:()=>{t()},children:"Transcribe My Answer"})})]});function Rt(){const[i,r]=c.useState(!0),t=c.useMemo(()=>[0,1,2].map(s=>({id:s})),[]);return c.useEffect(()=>{const s=setInterval(()=>{r(n=>!n)},1500);return()=>clearInterval(s)},[]),e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[e.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:t.map((s,n)=>{const o=n*50,a=i?o:o+12,l=i?1:.08,w=n*140;return e.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:l,transition:`transform 600ms cubic-bezier(.2,.9,.3,1) ${w}ms, opacity 400ms ease ${w}ms`},children:e.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[e.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),e.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[e.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),e.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},s.id)})}),e.jsx("div",{className:"iw-text-center",children:e.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const Pt=({size:i="192px",className:r,colors:t,animationDuration:s=20})=>{const o={...{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)"},...t},a=parseInt(i.replace("px",""),10),l=a<50?Math.max(a*.008,1):Math.max(a*.015,4),w=a<50?Math.max(a*.004,1.2):Math.max(a*.008,1.5),d=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),m=a<30?"0%":a<50?"5%":a<100?"15%":"25%",f=a<30?1.1:a<50?Math.max(w*1.2,1.3):w;return e.jsx("div",{className:`siri-orb ${r}`,style:{width:i,height:i,"--bg":o.bg,"--c1":o.c1,"--c2":o.c2,"--c3":o.c3,"--animation-duration":`${s}s`,"--blur-amount":`${l}px`,"--contrast-amount":f,"--dot-size":`${d}px`,"--shadow-spread":`${h}px`,"--mask-radius":m},children:e.jsx("style",{children:`
68
+ └─────────────────────────────────────────────────────────────┘`,"color: #ffd93d; font-size: 14px; font-family: monospace; background: rgba(255, 217, 61, 0.1); padding: 10px;")}const r={open:!1,orientation:null},t=160,s=setInterval(()=>{window.outerHeight-window.innerHeight>t||window.outerWidth-window.innerWidth>t?r.open||(r.open=!0,r.orientation=window.outerWidth-window.innerWidth>t?"vertical":"horizontal",i()):r.open&&(r.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},l=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",l),()=>{clearInterval(s),document.removeEventListener("keydown",n),document.removeEventListener("contextmenu",l),delete window.showStats,delete window.interviewTips}},[])},ue=i=>e.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",...i,children:[e.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),e.jsx("path",{d:"M12 6v6l4 2"}),e.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),e.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),e.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),e.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),Ct=(i,r,t)=>Math.max(r,Math.min(t,i)),Re=i=>{const r=Math.max(0,Math.floor(i)),t=Math.floor(r/60).toString().padStart(2,"0"),s=(r%60).toString().padStart(2,"0");return`${t}:${s}`},he=({total:i,remaining:r,size:t=64,strokeWidth:s=6,className:n="",showLabel:l=!0})=>{const a=Math.max(1,i||1),c=Ct(r/a,0,1),{radius:u,circumference:w,dashOffset:h,center:m}=o.useMemo(()=>{const p=(t-s)/2,y=2*Math.PI*p,k=y*(1-c),g=Math.round(s)%2===1,j=t/2+(g?.5:0);return{radius:p,circumference:y,dashOffset:k,center:j}},[t,s,c]),f=o.useMemo(()=>c<=.25?"iw-stroke-red-500":c<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[c]),d=c<=.25?"iw-animate-pulse":"";return e.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${n}`,style:{width:t,height:t},"aria-label":`Time remaining ${Re(r)}`,role:"timer","aria-live":"polite",children:[e.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,preserveAspectRatio:"xMidYMid meet",children:e.jsxs("g",{transform:`rotate(-90 ${m} ${m})`,children:[e.jsx("circle",{cx:m,cy:m,r:u,className:"iw-stroke-gray-200",strokeWidth:s,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),e.jsx("circle",{cx:m,cy:m,r:u,className:`${f} ${d}`,strokeWidth:s,strokeLinecap:"round",fill:"none",strokeDasharray:w,strokeDashoffset:h,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),l&&e.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:e.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:Re(r)})})]})},St=({label:i,error:r,fullWidth:t=!1,className:s="",id:n,...l})=>{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",u=r?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",w=t?"iw-w-full":"",h=s.includes("iw-h-full")||t?"iw-h-full":"";return e.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${t?"iw-w-full":""}`,children:[i&&e.jsx("label",{htmlFor:a,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:i}),e.jsx("textarea",{id:a,className:`${c} ${u} ${w} ${h} ${s}`,"aria-invalid":r?"true":"false",...l}),r&&e.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:r})]})},Tt=({value:i,onChange:r,onSubmit:t,isSubmitDisabled:s,state:n,editingTime:l})=>{const a=c=>{c.key==="Enter"&&(c.ctrlKey||c.metaKey)&&!s&&(c.preventDefault(),t())};return e.jsxs("div",{className:"iw-flex iw-flex-col iw-h-full ",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Your Answer"}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(ue,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to edit: "})]}),e.jsx(he,{total:l,remaining:n.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),e.jsxs("div",{className:" iw-overflow-hidden iw-flex iw-flex-col iw-h-full iw-mt-2",children:[e.jsx(St,{value:i,onChange:r,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()}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1 iw-mt-4",children:e.jsx(G,{onClick:t,disabled:s,children:"Submit Answer"})})]})]})},It=({className:i=""})=>{var n;const{authToken:r}=Se(),t=r?rt(r):null,s=o.useRef(null);return o.useEffect(()=>{let l=null;return(async()=>{try{l=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1}),s.current&&(s.current.srcObject=l)}catch(c){console.error("Error accessing camera:",c)}})(),()=>{l&&l.getTracks().forEach(c=>c.stop())}},[]),e.jsxs("div",{className:`iw-relative ${i}`,children:[e.jsx("video",{ref:s,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-[400px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)"}}),e.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:[e.jsx("div",{className:"iw-size-2 iw-animate-pulse iw-rounded-full iw-bg-red-500"}),e.jsx("span",{className:"iw-font-medium iw-text-white",children:"Recording"})]}),((n=t==null?void 0:t.data)==null?void 0:n.user_name)&&e.jsx("div",{className:"iw-absolute 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:e.jsx("span",{className:"iw-font-medium iw-text-white",children:t.data.user_name})})]})},Mt=({question:i,isLoading:r=!1})=>{const{baseColor:t}=V();return e.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-p-6 ",style:et(t,.85),children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-8",children:[e.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:e.jsx("div",{className:"iw-mt-2",children:e.jsx("img",{src:"https://duf9q5sx7u.ufs.sh/f/va7H6eSeKAux755zByRN5Nq9LZurgIoJGYX6c0CEdRSDm8y2",alt:"brand_logo",className:"iw-h-28 iw-w-28"})})}),r?e.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[e.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),e.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]}):e.jsx("p",{className:"iw-text-lg iw-leading-8",children:i==null?void 0:i.question})]})})},Pe=({currentQuestion:i,phase:r,className:t="",children:s})=>e.jsxs("div",{className:`iw-p-4 iw-space-y-4 iw-pb-6 ${t} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,children:[e.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3",children:e.jsx("div",{className:"iw-flex-1",children:e.jsx(Mt,{question:i,isLoading:r===I.FETCHING_QUESTION||r===I.IDLE})})}),e.jsxs("div",{className:"iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-[14px] iw-p-6",children:[e.jsx("div",{className:"iw-min-h-[400px] iw-max-h-[600px]",children:e.jsx(It,{})}),e.jsx("div",{className:"iw-bg-white iw-rounded-r-xl iw-shadow iw-p-6",children:s})]})]}),Fe=({isOpen:i,onClose:r,children:t,title:s,showCloseButton:n=!0,closeOnOverlayClick:l=!0,closeOnEscape:a=!0,className:c=""})=>{if(o.useEffect(()=>{if(!i||!a)return;const h=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[i,a,r]),o.useEffect(()=>(i?(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")}),[i]),!i)return null;const u=h=>{l&&h.target===h.currentTarget&&r()},w=e.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center",children:[e.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",onClick:u}),e.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":s?"dialog-title":void 0,children:[(s||n)&&e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[s&&e.jsx("h2",{id:"dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:s}),n&&e.jsx("button",{onClick:r,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:e.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:t})]})]});return B.createPortal(w,document.body)},At=({confirmExitInterview:i,isOpen:r,onClose:t})=>e.jsx(Fe,{isOpen:r,onClose:t,title:"Exit Interview",closeOnOverlayClick:!1,children:e.jsxs("div",{className:"iw-space-y-5",children:[e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-rounded-xl iw-p-2",children:[e.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:"!"}),e.jsxs("div",{className:"iw-space-y-2",children:[e.jsx("p",{className:"iw-text-sm iw-font-semibold iw-text-rose-600",children:"Leaving now will end your interview !"}),e.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."})]})]}),e.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:[e.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:t,children:"Stay in interview"}),e.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:i,children:"Confirm exit"})]})]})}),Le=({title:i,onExit:r})=>{const{baseColor:t}=V(),[s,n]=o.useState(!1);return e.jsxs("header",{className:"iw-w-full iw-text-gray-900",children:[e.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-pb-4 iw-pt-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[e.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:t},children:"N"}),e.jsx("p",{className:"iw-text-sm iw-font-medium",children:"Novara"})]}),e.jsx("h1",{className:"iw-text-base iw-font-bold",children:i}),e.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:()=>n(!0),children:"Exit Interview"})]}),e.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),e.jsx(At,{isOpen:s,confirmExitInterview:()=>{r(),n(!1)},onClose:()=>n(!1)})]})},Dt=({className:i="",width:r,height:t=56,barWidth:s=3,gap:n=2,fftSize:l=1024,smoothingTimeConstant:a=.8,mediaStream:c,startOnMount:u=!0})=>{const{baseColor:w}=V(),h=o.useRef(null),m=o.useRef(null),f=o.useRef(null),d=o.useRef(null),p=o.useRef(null),y=o.useRef(null),k=o.useRef(!1),[g,j]=o.useState(null);o.useEffect(()=>{if(r||!m.current)return;const N=m.current,D=()=>{const S=h.current;if(!S)return;const T=N.clientWidth,x=t;S.width=Math.max(1,Math.floor(T*window.devicePixelRatio||1)),S.height=Math.max(1,Math.floor(x*window.devicePixelRatio||1))},v=new ResizeObserver(D);return v.observe(N),D(),()=>v.disconnect()},[r,t]),o.useEffect(()=>{if(!r)return;const N=h.current;N&&(N.width=Math.max(1,Math.floor(r*(window.devicePixelRatio||1))),N.height=Math.max(1,Math.floor(t*(window.devicePixelRatio||1))))},[r,t]),o.useEffect(()=>{let N=!1;return(async()=>{try{const v=new(window.AudioContext||window.webkitAudioContext);f.current=v;let S=c;if(!S){if(!u)return;S=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),k.current=!0}if(N)return;const T=v.createAnalyser();T.fftSize=l,T.smoothingTimeConstant=a,d.current=T;const x=v.createMediaStreamSource(S);p.current=x,x.connect(T),C()}catch(v){j((v==null?void 0:v.message)||"Failed to initialize microphone")}})(),()=>{var v,S,T,x;N=!0,y.current&&cancelAnimationFrame(y.current);try{(v=p.current)==null||v.disconnect()}catch{}try{(S=d.current)==null||S.disconnect()}catch{}k.current&&((x=((T=p.current)==null?void 0:T.mediaStream)||void 0)==null||x.getTracks().forEach(M=>M.stop())),f.current&&f.current.state!=="closed"&&f.current.close()}},[c,l,a,u]);const C=()=>{const N=h.current,D=d.current;if(!N||!D)return;const v=N.getContext("2d");if(!v)return;const S=window.devicePixelRatio||1,T=N.width,x=N.height,M=D.frequencyBinCount,P=new Uint8Array(M),L=()=>{y.current=requestAnimationFrame(L),D.getByteTimeDomainData(P),v.clearRect(0,0,T,x),v.fillStyle="rgba(0,0,0,0)",v.fillRect(0,0,T,x);const O=Math.max(1,Math.floor(s*S)),H=Math.max(1,Math.floor(n*S)),Y=O+H,Q=Math.max(8,Math.floor((T+H)/Y)),U=Math.floor(P.length/Q);for(let $=0;$<Q;$++){const _=Math.min(P.length-1,$*U),K=P[_]/128-1,q=Math.abs(K),ge=Math.pow(q,.6),J=Math.max(x*.06,ge*(x*.9)),xe=$*Y,pe=(x-J)/2,be=140-Math.min(140,140*q),X=85,ne=48+Math.floor(12*(1-q));v.fillStyle=`${w}`,v.shadowColor=`hsla(${be}, ${X}%, ${ne}%, ${.25*q})`,v.shadowBlur=8*q;const b=Math.min(O/2,J/2);_t(v,xe,pe,O,J,b),v.fill()}};L()};return e.jsxs("div",{ref:m,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${i}`,style:{height:t},children:[e.jsx("canvas",{ref:h,className:"iw-w-full iw-h-full"}),g&&e.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:e.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:g})})]})};function _t(i,r,t,s,n,l){const a=Math.min(l,s/2,n/2);i.beginPath(),i.moveTo(r+a,t),i.lineTo(r+s-a,t),i.quadraticCurveTo(r+s,t,r+s,t+a),i.lineTo(r+s,t+n-a),i.quadraticCurveTo(r+s,t+n,r+s-a,t+n),i.lineTo(r+a,t+n),i.quadraticCurveTo(r,t+n,r,t+n-a),i.lineTo(r,t+a),i.quadraticCurveTo(r,t,r+a,t),i.closePath()}const Rt=({state:i,answeringTime:r,nextPhase:t,sttError:s})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.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...."}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(ue,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),e.jsx(he,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),e.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."})]}),e.jsxs("div",{children:[e.jsx(Dt,{}),s&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",s.message]})]}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:e.jsx(G,{onClick:()=>{t()},children:"Transcribe My Answer"})})]});function Pt(){const[i,r]=o.useState(!0),t=o.useMemo(()=>[0,1,2].map(s=>({id:s})),[]);return o.useEffect(()=>{const s=setInterval(()=>{r(n=>!n)},1500);return()=>clearInterval(s)},[]),e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[e.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:t.map((s,n)=>{const l=n*50,a=i?l:l+12,c=i?1:.08,u=n*140;return e.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) ${u}ms, opacity 400ms ease ${u}ms`},children:e.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[e.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),e.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[e.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),e.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},s.id)})}),e.jsx("div",{className:"iw-text-center",children:e.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const Ft=({size:i="192px",className:r,colors:t,animationDuration:s=20})=>{const l={...{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)"},...t},a=parseInt(i.replace("px",""),10),c=a<50?Math.max(a*.008,1):Math.max(a*.015,4),u=a<50?Math.max(a*.004,1.2):Math.max(a*.008,1.5),w=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),m=a<30?"0%":a<50?"5%":a<100?"15%":"25%",f=a<30?1.1:a<50?Math.max(u*1.2,1.3):u;return e.jsx("div",{className:`siri-orb ${r}`,style:{width:i,height:i,"--bg":l.bg,"--c1":l.c1,"--c2":l.c2,"--c3":l.c3,"--animation-duration":`${s}s`,"--blur-amount":`${c}px`,"--contrast-amount":f,"--dot-size":`${w}px`,"--shadow-spread":`${h}px`,"--mask-radius":m},children:e.jsx("style",{children:`
69
69
  @property --angle {
70
70
  syntax: "<angle>";
71
71
  inherits: false;
@@ -170,4 +170,4 @@
170
170
  animation: none;
171
171
  }
172
172
  }
173
- `})})};function Ft({ttsError:i}){return e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[e.jsx(Pt,{size:"80px"}),i&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",i.message]}),e.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const Lt=({state:i,thinkingTime:r,nextPhase:t})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),e.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."})]}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(de,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),e.jsx(we,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:e.jsx(B,{onClick:()=>{t()},children:"Start Answering"})})]}),$t=({sttError:i})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[e.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),e.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"}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),e.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),e.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"}),e.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After transcription, you'll have 45 sec to review your answer."}),i&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",i.message,i.recoverable&&" (attempting to continue)"]})]}),te=i=>e.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",...i,children:[e.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"}),e.jsx("path",{d:"M12 9v4"}),e.jsx("path",{d:"M12 17h.01"})]}),Ot=i=>e.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",...i,children:[e.jsx("path",{d:"M12 6v6l4 2"}),e.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),Ut=i=>e.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",...i,children:[e.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"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),qt=i=>e.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",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),ue=i=>e.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",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),Wt=i=>e.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",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),ie=5;function Bt({isOpen:i,onClose:r,warningCount:t,violationType:s,onDisqualify:n}){const[o,a]=c.useState(10),l=c.useRef(r);if(c.useEffect(()=>{l.current=r},[r]),c.useEffect(()=>{if(!i)return;const f=setInterval(()=>{a(u=>u<=1?(l.current(),10):u-1)},1e3);return()=>clearInterval(f)},[i]),c.useEffect(()=>{i&&a(10)},[i]),c.useEffect(()=>(i?(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")}),[i]),!i)return null;const d=(()=>{switch(s){case"tab_switch":return{title:"Tab Switch Detected",description:"You attempted to switch to another tab or reload application.",icon:e.jsx(Ut,{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:e.jsx(Ae,{className:"iw-h-5 iw-w-5"})};case"focus_loss":return{title:"Focus Loss Detected",description:"You lost focus from the interview window.",icon:e.jsx(qt,{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:e.jsx(ue,{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:e.jsx(Wt,{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:e.jsx(ue,{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:e.jsx(ue,{className:"iw-h-5 iw-w-5"})};default:return{title:"Violation Detected",description:"You attempted to perform an action that is not allowed.",icon:e.jsx(te,{className:"iw-h-5 iw-w-5"})}}})(),h=ie-t,m=()=>{t+1>ie?n():r()};return e.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:e.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:[e.jsxs("div",{className:"iw-p-6 iw-pb-0",children:[e.jsxs("div",{className:"iw-mb-6 iw-flex iw-items-start iw-gap-4",children:[e.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:e.jsx(te,{className:"iw-h-6 iw-w-6 iw-text-red-500"})}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsx("h2",{className:"iw-mb-1 iw-text-xl iw-font-semibold iw-text-gray-900",children:"Security Violation"}),e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[e.jsx("span",{className:"iw-text-sm iw-text-gray-500",children:"Warning"}),e.jsx("div",{className:"iw-flex iw-gap-1",children:Array.from({length:ie}).map((f,u)=>e.jsx("div",{className:`iw-h-2 iw-w-2 iw-rounded-full ${u<=t-1?"iw-bg-red-500":"iw-bg-gray-200"}`},u))}),e.jsxs("span",{className:"iw-text-sm iw-text-gray-500",children:["(",t,"/",ie,")"]})]})]})]}),e.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:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[e.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:d.icon}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsx("h3",{className:"iw-mb-2 iw-font-semibold iw-text-gray-900",children:d.title}),e.jsx("p",{className:"iw-text-sm iw-leading-relaxed iw-text-gray-700",children:d.description}),e.jsxs("div",{className:"iw-mt-3 iw-flex iw-items-center iw-gap-2 iw-text-xs iw-text-red-600",children:[e.jsx(Me,{className:"iw-h-3 iw-w-3"}),e.jsx("span",{children:"This action is monitored for interview integrity"})]})]})]})}),e.jsxs("div",{className:"iw-mb-5 iw-grid iw-grid-cols-2 iw-gap-3",children:[e.jsx("div",{className:"iw-rounded-xl iw-border iw-border-amber-200 iw-bg-amber-50 iw-p-4",children:e.jsxs("div",{className:"iw-text-center",children:[e.jsx("div",{className:"iw-mb-1 iw-text-2xl iw-font-bold iw-text-amber-600",children:h}),e.jsx("div",{className:"iw-text-xs iw-font-medium iw-text-amber-700",children:"Warnings Left"})]})}),e.jsx("div",{className:"iw-border-primary-100 iw-bg-primary-50 iw-rounded-xl iw-border iw-p-4",children:e.jsxs("div",{className:"iw-text-center",children:[e.jsxs("div",{className:"iw-mb-1 iw-flex iw-items-center iw-justify-center iw-gap-1.5",children:[e.jsx(Ot,{className:"iw-text-primary-600 iw-h-4 iw-w-4"}),e.jsx("span",{className:"iw-text-primary-600 iw-text-2xl iw-font-bold",children:o})]}),e.jsx("div",{className:"iw-text-primary-700 iw-text-xs iw-font-medium",children:"Auto Close"})]})})]}),h===1&&e.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:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[e.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:e.jsx(te,{className:"iw-h-4 iw-w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"iw-text-sm iw-font-semibold",children:"Final Warning"}),e.jsx("div",{className:"iw-text-xs iw-text-red-100",children:"Next violation will disqualify you from this interview"})]})]})})]}),e.jsxs("div",{className:"iw-p-6 iw-pt-0",children:[e.jsx(B,{onClick:m,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"}),e.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 Gt=i=>e.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",...i,children:[e.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"}),e.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),Vt=({showHardReloadWarning:i,onContinue:r})=>{const t=()=>{r()};return e.jsxs(Re,{isOpen:i,onClose:t,closeOnOverlayClick:!1,closeOnEscape:!1,showCloseButton:!1,className:"iw-max-w-lg iw-px-2 iw-rounded-xl",children:[e.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"}),e.jsx("div",{className:"iw-space-y-1 iw-pb-2 iw-pt-3",children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[e.jsx(te,{className:"iw-w-5 iw-h-5 iw-text-red-500"}),e.jsx("h3",{className:"iw-text-xl iw-font-semibold iw-text-red-500",children:"Full Screen Exit Detected"})]})}),e.jsx("div",{className:"iw-pt-4 iw-pb-6",children:e.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."})}),e.jsx("div",{className:"iw-pt-2 iw-pb-4",children:e.jsxs("button",{onClick:t,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:[e.jsx(Gt,{className:"iw-size-4"}),"Continue Session"]})})]})},zt=({children:i,onDisqualify:r})=>{const[t,s]=c.useState(!1),[n,o]=c.useState(!1),[a,l]=c.useState("fullscreen_exit"),{logViolation:w,violationCount:d}=kt({maxViolations:5,onViolation:x=>{n||(s(!0),l(x.type))}}),{enterFullScreen:h,isFullScreen:m,exitFullScreen:f}=wt({onFullScreenChange(x){!x&&!n&&(s(!0),w({type:"fullscreen_exit",severity:"high",details:{action:"fullscreen_exit",reason:"Attempted to exit full screen mode"}}))}});c.useEffect(()=>{h()},[]),bt(w),gt(w),yt(),Nt();const u=()=>{o(!0),f(),s(!1),r==null||r()};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"iw-relative iw-h-full iw-w-full",children:i}),e.jsx(Bt,{warningCount:d,isOpen:t,violationType:a,onClose:()=>{s(!1),h()},onDisqualify:u}),!t&&d>0&&!n&&e.jsx(Vt,{showHardReloadWarning:!m,logViolation:w,onContinue:h})]})},Ht=({interviewTitle:i,interviewId:r,onComplete:t,onDisqualify:s,className:n=""})=>{const o=ft(),{baseUrl:a,authToken:l}=Ee(),{timers:w,stt:d,tts:h,proctoring:m}=Ke(),[f,u]=c.useState(null),[x,j]=c.useState(""),k=c.useRef(""),p=c.useRef(null),N={thinkingTime:(w==null?void 0:w.thinkingDuration)||30,answeringTime:(w==null?void 0:w.answeringDuration)||120,editingTime:(w==null?void 0:w.editingDuration)||30},{thinkingTime:E,answeringTime:v,editingTime:_}=N;c.useEffect(()=>{k.current=x},[x]);const y=c.useRef(!1),{speak:M,stop:T,error:g}=jt({config:{baseUrl:a,provider:h==null?void 0:h.provider,authToken:l},onEnd:()=>{y.current=!1,I()},onError:()=>{y.current||(y.current=!0,I())}}),S=c.useRef(!1),P=c.useRef(!1),{startRecording:U,stopRecording:O,transcribe:H,error:Y}=pt({config:{baseUrl:a,provider:d==null?void 0:d.provider,model:d==null?void 0:d.model,language:d==null?void 0:d.language,authToken:l},onStart:()=>{S.current=!1,P.current=!1},onStop:()=>{},onTranscriptionComplete:b=>{j(b.transcript),P.current||(P.current=!0,I())},onError:b=>{console.error("STT Error:",b),S.current||(S.current=!0,I())}}),{state:L,startQuestion:G,nextPhase:I,completeInterview:Q}=ct({config:{thinkingDuration:E,answeringDuration:v,editingDuration:_},callbacks:{onPhaseChange:b=>{switch(b){case A.FETCHING_QUESTION:me();break;case A.READING_QUESTION:K();break;case A.ANSWERING:ge();break;case A.TRANSCRIBING:xe();break;case A.SUBMITTING:fe();break}},onInterviewEnd:()=>{t==null||t()}}});c.useEffect(()=>{G()},[]);const{execute:me,loading:q}=dt(async()=>{var $,Fe;const b=await o.generateQuestion({interviewId:r,question:(($=p.current)==null?void 0:$.question)||"",qnaId:((Fe=p.current)==null?void 0:Fe.qna_id)||"",answer:k.current});return p.current=b.data,b},{onSuccess:async b=>{b&&b.data&&(j(""),u(b.data),I())},onError:b=>{console.error("Failed to fetch questions:",b)}}),fe=c.useCallback(async()=>{G()},[G]),K=c.useCallback(async()=>{var b;if((b=p.current)!=null&&b.question)try{y.current=!1,await M(p.current.question),p.current.is_interview_done&&(await et(2e3),Q())}catch($){console.error("Failed to speak question:",$)}else I()},[M,I,Q]),ge=c.useCallback(async()=>{try{await U(v)}catch(b){console.error("Failed to start recording:",b),I()}},[U,I]),xe=c.useCallback(async()=>{try{const b=await O();await H(b)}catch(b){console.error("STT processing failed:",b),!S.current&&!P.current&&(S.current=!0,I())}},[O,H,I]),J=c.useCallback(async b=>{T(),(await o.generateQuestion({interviewId:r,isInterviewDone:!0})).success&&(b==null||b(),Q(),sessionStorage.removeItem(ne))},[r,T,o]),re=()=>{const{phase:b}=L;switch(b){case A.IDLE:return e.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),e.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.`}),e.jsx(B,{onClick:G,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case A.FETCHING_QUESTION:return e.jsx(Rt,{});case A.READING_QUESTION:return e.jsx(Ft,{ttsError:g});case A.THINKING:return e.jsx(Lt,{state:L,thinkingTime:E,nextPhase:I});case A.ANSWERING:return e.jsx(_t,{state:L,answeringTime:v,nextPhase:I,sttError:Y});case A.TRANSCRIBING:return e.jsx($t,{sttError:Y});case A.EDITING:case A.SUBMITTING:return e.jsx("div",{className:"iw-space-y-4 iw-h-full",children:e.jsx(St,{value:x,onChange:$=>j($.target.value),onSubmit:()=>I(),isSubmitDisabled:!x.trim()||q,state:L,editingTime:_})});case A.COMPLETED:return null;default:return null}};return e.jsx(e.Fragment,{children:m!=null&&m.enabled?e.jsxs(zt,{onDisqualify:()=>J(s),children:[e.jsx(Pe,{title:i,onExit:()=>J()}),e.jsx(_e,{currentQuestion:f,phase:L.phase,className:n,children:re()})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{title:i,onExit:()=>J()}),e.jsx(_e,{currentQuestion:f,phase:L.phase,className:n,children:re()})]})})},he=({title:i,interviewId:r,onInterviewEnd:t,onInterviewDisqualify:s,className:n=""})=>{const[o,a]=c.useState(!1),[l,w]=c.useState(!0),d=c.useRef(null);return o?e.jsx("div",{className:"interview-widget-container",children:e.jsx("div",{ref:d,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${n}`,children:e.jsx("div",{className:" iw-h-full iw-flex iw-flex-col",children:e.jsx(Ht,{interviewTitle:i??"Interview",interviewId:r,className:n,onComplete:t||(()=>{}),onDisqualify:s})})})}):e.jsx("div",{className:"interview-widget-container",children:e.jsx(nt,{isOpen:l,onStart:()=>{a(!0),w(!1)}})})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:he,InterviewWidgetProvider:Ne}),D.InterviewWidget=he,D.InterviewWidgetProvider=Ne,D.default=he,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
173
+ `})})};function Lt({ttsError:i}){return e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[e.jsx(Ft,{size:"80px"}),i&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",i.message]}),e.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const $t=({state:i,thinkingTime:r,nextPhase:t})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),e.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."})]}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(ue,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),e.jsx(he,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:e.jsx(G,{onClick:()=>{t()},children:"Start Answering"})})]}),Ot=({sttError:i})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[e.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),e.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"}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),e.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),e.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"}),e.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After transcription, you'll have 45 sec to review your answer."}),i&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",i.message,i.recoverable&&" (attempting to continue)"]})]}),re=i=>e.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",...i,children:[e.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"}),e.jsx("path",{d:"M12 9v4"}),e.jsx("path",{d:"M12 17h.01"})]}),Ut=i=>e.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",...i,children:[e.jsx("path",{d:"M12 6v6l4 2"}),e.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),qt=i=>e.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",...i,children:[e.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"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Wt=i=>e.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",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),me=i=>e.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",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),Bt=i=>e.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",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),se=5;function Gt({isOpen:i,onClose:r,warningCount:t,violationType:s,onDisqualify:n}){const[l,a]=o.useState(10),c=o.useRef(r);if(o.useEffect(()=>{c.current=r},[r]),o.useEffect(()=>{if(!i)return;const f=setInterval(()=>{a(d=>d<=1?(c.current(),10):d-1)},1e3);return()=>clearInterval(f)},[i]),o.useEffect(()=>{i&&a(10)},[i]),o.useEffect(()=>(i?(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")}),[i]),!i)return null;const w=(()=>{switch(s){case"tab_switch":return{title:"Tab Switch Detected",description:"You attempted to switch to another tab or reload application.",icon:e.jsx(qt,{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:e.jsx(_e,{className:"iw-h-5 iw-w-5"})};case"focus_loss":return{title:"Focus Loss Detected",description:"You lost focus from the interview window.",icon:e.jsx(Wt,{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:e.jsx(me,{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:e.jsx(Bt,{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:e.jsx(me,{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:e.jsx(me,{className:"iw-h-5 iw-w-5"})};default:return{title:"Violation Detected",description:"You attempted to perform an action that is not allowed.",icon:e.jsx(re,{className:"iw-h-5 iw-w-5"})}}})(),h=se-t,m=()=>{t+1>se?n():r()};return e.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:e.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:[e.jsxs("div",{className:"iw-p-6 iw-pb-0",children:[e.jsxs("div",{className:"iw-mb-6 iw-flex iw-items-start iw-gap-4",children:[e.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:e.jsx(re,{className:"iw-h-6 iw-w-6 iw-text-red-500"})}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsx("h2",{className:"iw-mb-1 iw-text-xl iw-font-semibold iw-text-gray-900",children:"Security Violation"}),e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[e.jsx("span",{className:"iw-text-sm iw-text-gray-500",children:"Warning"}),e.jsx("div",{className:"iw-flex iw-gap-1",children:Array.from({length:se}).map((f,d)=>e.jsx("div",{className:`iw-h-2 iw-w-2 iw-rounded-full ${d<=t-1?"iw-bg-red-500":"iw-bg-gray-200"}`},d))}),e.jsxs("span",{className:"iw-text-sm iw-text-gray-500",children:["(",t,"/",se,")"]})]})]})]}),e.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:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[e.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:w.icon}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsx("h3",{className:"iw-mb-2 iw-font-semibold iw-text-gray-900",children:w.title}),e.jsx("p",{className:"iw-text-sm iw-leading-relaxed iw-text-gray-700",children:w.description}),e.jsxs("div",{className:"iw-mt-3 iw-flex iw-items-center iw-gap-2 iw-text-xs iw-text-red-600",children:[e.jsx(De,{className:"iw-h-3 iw-w-3"}),e.jsx("span",{children:"This action is monitored for interview integrity"})]})]})]})}),e.jsxs("div",{className:"iw-mb-5 iw-grid iw-grid-cols-2 iw-gap-3",children:[e.jsx("div",{className:"iw-rounded-xl iw-border iw-border-amber-200 iw-bg-amber-50 iw-p-4",children:e.jsxs("div",{className:"iw-text-center",children:[e.jsx("div",{className:"iw-mb-1 iw-text-2xl iw-font-bold iw-text-amber-600",children:h}),e.jsx("div",{className:"iw-text-xs iw-font-medium iw-text-amber-700",children:"Warnings Left"})]})}),e.jsx("div",{className:"iw-border-primary-100 iw-bg-primary-50 iw-rounded-xl iw-border iw-p-4",children:e.jsxs("div",{className:"iw-text-center",children:[e.jsxs("div",{className:"iw-mb-1 iw-flex iw-items-center iw-justify-center iw-gap-1.5",children:[e.jsx(Ut,{className:"iw-text-primary-600 iw-h-4 iw-w-4"}),e.jsx("span",{className:"iw-text-primary-600 iw-text-2xl iw-font-bold",children:l})]}),e.jsx("div",{className:"iw-text-primary-700 iw-text-xs iw-font-medium",children:"Auto Close"})]})})]}),h===1&&e.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:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[e.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:e.jsx(re,{className:"iw-h-4 iw-w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"iw-text-sm iw-font-semibold",children:"Final Warning"}),e.jsx("div",{className:"iw-text-xs iw-text-red-100",children:"Next violation will disqualify you from this interview"})]})]})})]}),e.jsxs("div",{className:"iw-p-6 iw-pt-0",children:[e.jsx(G,{onClick:m,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"}),e.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 Vt=i=>e.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",...i,children:[e.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"}),e.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),zt=({showHardReloadWarning:i,onContinue:r})=>{const t=()=>{r()};return e.jsxs(Fe,{isOpen:i,onClose:t,closeOnOverlayClick:!1,closeOnEscape:!1,showCloseButton:!1,className:"iw-max-w-lg iw-px-2 iw-rounded-xl",children:[e.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"}),e.jsx("div",{className:"iw-space-y-1 iw-pb-2 iw-pt-3",children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[e.jsx(re,{className:"iw-w-5 iw-h-5 iw-text-red-500"}),e.jsx("h3",{className:"iw-text-xl iw-font-semibold iw-text-red-500",children:"Full Screen Exit Detected"})]})}),e.jsx("div",{className:"iw-pt-4 iw-pb-6",children:e.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."})}),e.jsx("div",{className:"iw-pt-2 iw-pb-4",children:e.jsxs("button",{onClick:t,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:[e.jsx(Vt,{className:"iw-size-4"}),"Continue Session"]})})]})},Ht=o.forwardRef(({children:i,onDisqualify:r},t)=>{const[s,n]=o.useState(!1),[l,a]=o.useState(!1),[c,u]=o.useState(!1),[w,h]=o.useState("fullscreen_exit"),{logViolation:m,violationCount:f}=Nt({maxViolations:5,onViolation:g=>{l||(n(!0),h(g.type))}}),{enterFullScreen:d,isFullScreen:p,exitFullScreen:y}=ut({onFullScreenChange(g){!g&&!l&&!c&&(n(!0),m({type:"fullscreen_exit",severity:"high",details:{action:"fullscreen_exit",reason:"Attempted to exit full screen mode"}})),g&&u(!1)}});o.useEffect(()=>{d()},[]),o.useImperativeHandle(t,()=>({exitFullScreenIntentionally:async()=>{u(!0),n(!1),a(!1);try{document.fullscreenElement&&await document.exitFullscreen()}catch(g){console.error("Failed to exit fullscreen:",g)}}}),[]),yt(m),xt(m),vt(),Et();const k=()=>{a(!0),y(),n(!1),r==null||r()};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"iw-relative iw-h-full iw-w-full",children:i}),e.jsx(Gt,{warningCount:f,isOpen:s,violationType:w,onClose:()=>{n(!1),d()},onDisqualify:k}),!s&&f>0&&!l&&e.jsx(zt,{showHardReloadWarning:!p,logViolation:m,onContinue:d})]})}),Yt=({interviewTitle:i,interviewId:r,onComplete:t,onDisqualify:s,className:n=""})=>{const l=gt(),{baseUrl:a,authToken:c}=Se(),{timers:u,stt:w,tts:h,proctoring:m}=Je(),f=o.useRef(null),[d,p]=o.useState(null),[y,k]=o.useState(""),g=o.useRef(""),j=o.useRef(null),C={thinkingTime:(u==null?void 0:u.thinkingDuration)||30,answeringTime:(u==null?void 0:u.answeringDuration)||120,editingTime:(u==null?void 0:u.editingDuration)||30},{thinkingTime:N,answeringTime:D,editingTime:v}=C;o.useEffect(()=>{g.current=y},[y]);const S=o.useRef(!1),{speak:T,stop:x,error:M}=kt({config:{baseUrl:a,provider:h==null?void 0:h.provider,authToken:c},onEnd:()=>{S.current=!1,_()},onError:()=>{S.current||(S.current=!0,_())}}),P=o.useRef(!1),L=o.useRef(!1),{startRecording:O,stopRecording:H,transcribe:Y,error:Q}=bt({config:{baseUrl:a,provider:w==null?void 0:w.provider,model:w==null?void 0:w.model,language:w==null?void 0:w.language,authToken:c},onStart:()=>{P.current=!1,L.current=!1},onStop:()=>{},onTranscriptionComplete:b=>{k(b.transcript),L.current||(L.current=!0,_())},onError:b=>{console.error("STT Error:",b),P.current||(P.current=!0,_())}}),{state:U,startQuestion:$,nextPhase:_,completeInterview:K}=dt({config:{thinkingDuration:N,answeringDuration:D,editingDuration:v},callbacks:{onPhaseChange:b=>{switch(b){case I.FETCHING_QUESTION:q();break;case I.READING_QUESTION:xe();break;case I.ANSWERING:pe();break;case I.TRANSCRIBING:be();break;case I.SUBMITTING:J();break}},onInterviewEnd:()=>{t==null||t()}}});o.useEffect(()=>{$()},[]);const{execute:q,loading:ge}=wt(async()=>{var W,Z;const b=await l.generateQuestion({interviewId:r,question:((W=j.current)==null?void 0:W.question)||"",qnaId:((Z=j.current)==null?void 0:Z.qna_id)||"",answer:g.current});return j.current=b.data,b},{onSuccess:async b=>{b&&b.data&&(k(""),p(b.data),_())},onError:b=>{console.error("Failed to fetch questions:",b)}}),J=o.useCallback(async()=>{$()},[$]),xe=o.useCallback(async()=>{var b;if((b=j.current)!=null&&b.question)try{S.current=!1,await T(j.current.question),j.current.is_interview_done&&(await tt(2e3),K())}catch(W){console.error("Failed to speak question:",W)}else _()},[T,_,K]),pe=o.useCallback(async()=>{try{await O(D)}catch(b){console.error("Failed to start recording:",b),_()}},[O,_]),be=o.useCallback(async()=>{try{const b=await H();await Y(b)}catch(b){console.error("STT processing failed:",b),!P.current&&!L.current&&(P.current=!0,_())}},[H,Y,_]),X=o.useCallback(async b=>{var Z;x(),await((Z=f.current)==null?void 0:Z.exitFullScreenIntentionally()),(await l.generateQuestion({interviewId:r,isInterviewDone:!0})).success&&(b==null||b(),K(),sessionStorage.removeItem(oe))},[r,x,l]),ne=()=>{const{phase:b}=U;switch(b){case I.IDLE:return e.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),e.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.`}),e.jsx(G,{onClick:$,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case I.FETCHING_QUESTION:return e.jsx(Pt,{});case I.READING_QUESTION:return e.jsx(Lt,{ttsError:M});case I.THINKING:return e.jsx($t,{state:U,thinkingTime:N,nextPhase:_});case I.ANSWERING:return e.jsx(Rt,{state:U,answeringTime:D,nextPhase:_,sttError:Q});case I.TRANSCRIBING:return e.jsx(Ot,{sttError:Q});case I.EDITING:case I.SUBMITTING:return e.jsx("div",{className:"iw-space-y-4 iw-h-full",children:e.jsx(Tt,{value:y,onChange:W=>k(W.target.value),onSubmit:()=>_(),isSubmitDisabled:!y.trim()||ge,state:U,editingTime:v})});case I.COMPLETED:return null;default:return null}};return e.jsx(e.Fragment,{children:m!=null&&m.enabled?e.jsxs(Ht,{ref:f,onDisqualify:()=>X(s),children:[e.jsx(Le,{title:i,onExit:()=>X()}),e.jsx(Pe,{currentQuestion:d,phase:U.phase,className:n,children:ne()})]}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{title:i,onExit:()=>X()}),e.jsx(Pe,{currentQuestion:d,phase:U.phase,className:n,children:ne()})]})})},fe=({title:i,interviewId:r,onInterviewEnd:t,onInterviewDisqualify:s,className:n=""})=>{const[l,a]=o.useState(!1),[c,u]=o.useState(!0),w=o.useRef(null);return l?e.jsx("div",{className:"interview-widget-container",children:e.jsx("div",{ref:w,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${n}`,children:e.jsx("div",{className:" iw-h-full iw-flex iw-flex-col",children:e.jsx(Yt,{interviewTitle:i??"Interview",interviewId:r,className:n,onComplete:t||(()=>{}),onDisqualify:s})})})}):e.jsx("div",{className:"interview-widget-container",children:e.jsx(at,{isOpen:c,onStart:()=>{a(!0),u(!1)}})})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:fe,InterviewWidgetProvider:Ce}),A.InterviewWidget=fe,A.InterviewWidgetProvider=Ce,A.default=fe,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "interview-widget",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "description": "Advanced React interview widget with STT, TTS, camera access, and ML-powered analysis",
6
6
  "main": "dist/widget.umd.js",
7
7
  "module": "dist/widget.es.js",