1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[25606],{5738:(e,r,t)=>{t.d(r,{bq:()=>m,eb:()=>f,gC:()=>p,l6:()=>c,yv:()=>u});var s=t(23804),a=t(44976),n=t(20568),o=t(64055),l=t(3438),i=t(33731),d=t(87425);let c=n.bL;n.YJ;let u=n.WT,m=a.forwardRef((e,r)=>{let{className:t,children:a,...l}=e;return(0,s.jsxs)(n.l9,{ref:r,className:(0,d.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...l,children:[a,(0,s.jsx)(n.In,{asChild:!0,children:(0,s.jsx)(o.A,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=n.l9.displayName;let x=a.forwardRef((e,r)=>{let{className:t,...a}=e;return(0,s.jsx)(n.PP,{ref:r,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,s.jsx)(l.A,{className:"h-4 w-4"})})});x.displayName=n.PP.displayName;let h=a.forwardRef((e,r)=>{let{className:t,...a}=e;return(0,s.jsx)(n.wn,{ref:r,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,s.jsx)(o.A,{className:"h-4 w-4"})})});h.displayName=n.wn.displayName;let p=a.forwardRef((e,r)=>{let{className:t,children:a,position:o="popper",...l}=e;return(0,s.jsx)(n.ZL,{children:(0,s.jsxs)(n.UC,{ref:r,className:(0,d.cn)("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===o&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:o,...l,children:[(0,s.jsx)(x,{}),(0,s.jsx)(n.LM,{className:(0,d.cn)("p-1","popper"===o&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),(0,s.jsx)(h,{})]})})});p.displayName=n.UC.displayName,a.forwardRef((e,r)=>{let{className:t,...a}=e;return(0,s.jsx)(n.JU,{ref:r,className:(0,d.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...a})}).displayName=n.JU.displayName;let f=a.forwardRef((e,r)=>{let{className:t,children:a,...o}=e;return(0,s.jsxs)(n.q7,{ref:r,className:(0,d.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...o,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(n.VF,{children:(0,s.jsx)(i.A,{className:"h-4 w-4"})})}),(0,s.jsx)(n.p4,{children:a})]})});f.displayName=n.q7.displayName,a.forwardRef((e,r)=>{let{className:t,...a}=e;return(0,s.jsx)(n.wv,{ref:r,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",t),...a})}).displayName=n.wv.displayName},25606:(e,r,t)=>{t.r(r),t.d(r,{AudioRecorder:()=>ef,EvaluationCard:()=>_,IeltsSpeaking:()=>et,PartSelector:()=>en,QuestionCard:()=>eu,apiClient:()=>ey,default:()=>et,formatTime:()=>eb,getBandScoreInfo:()=>ej,getPartInfo:()=>ev,useAudioRecorder:()=>V.C,useIeltsApi:()=>Q,validateAudioFile:()=>eN});var s=t(23804),a=t(44976),n=t(10866),o=t(66139),l=t(44061),i=t(83535),d=t(22660),c=t(60747),u=t(73394),m=t(87172),x=t(84138),h=t(41879),p=t(98635),f=t(71988),g=t(8052),b=t(21739),v=t(54124),j=t(13008),N=t(4464),y=t(83402),w=t(17486),k=t(83275);let _=e=>{var r,t,a,n,l,i,d,c,u,m,x,h,f,_,A,S,C,E,T,R,P,L,W,F,M;let{evaluation:q,conversation:I=[]}=e;if(!q)return null;let D=e=>{if(!e)return"N/A";let r=Math.round(2*parseFloat(e))/2;return r%1==0?r.toFixed(0):r.toFixed(1)},B=e=>(null==e?void 0:e.band_score)?D(e.band_score):"N/A",O=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:80;if(!e)return"";let t=e.split(" "),s=[],a="";
1return t.forEach(e=>{a.length+e.length+1<=r?a+=(a?" ":"")+e:(a&&s.push(a),a=e)}),a&&s.push(a),s.join("\n")},U=(()=>{let e=[],r=null;return I.forEach(t=>{"question"===t.type?r={question:t.content,metadata:t.metadata||{},answer:null}:"answer"===t.type&&r&&(e.push({...r,answer:t.content}),r=null)}),e})(),z=(e=>!e||e<=0?null:e<80?{label:"Too slow",hint:"Aim for 100â160 wpm",color:"text-destructive"}:e<100?{label:"Developing",hint:"Aim for 100â160 wpm",color:"text-warning"}:e<120?{label:"Moderate",hint:"Getting there",color:"text-warning"}:e<160?{label:"Fluent",hint:"Optimal IELTS range",color:"text-success"}:e<185?{label:"Fast",hint:"Slightly above target",color:"text-foreground"}:{label:"Very fast",hint:"May affect clarity",color:"text-brand-orange"})(null==(r=q.fluency_and_coherence)?void 0:r.speech_rate),G=(()=>{var e;let r=null==(e=q.fluency_and_coherence)?void 0:e.speech_rate;return!r||r<=0?"N/A":z?"".concat(r," wpm \xb7 ").concat(z.label):"".concat(r," wpm")})(),$=[{id:"fluency",title:"Fluency & Coherence",icon:g.A,score:B(q.fluency_and_coherence),scoreNum:parseFloat(B(q.fluency_and_coherence))||0,feedback:null==(t=q.fluency_and_coherence)?void 0:t.feedback,description:"Ability to express ideas clearly and effectively",metrics:[{label:"Speech Rate",value:G,valueColor:null==z?void 0:z.color,hint:null==z?void 0:z.hint},{label:"Word Count",value:(null==(a=q.fluency_and_coherence)?void 0:a.word_count)!=null?"".concat(q.fluency_and_coherence.word_count," words"):"N/A"},{label:"Filler Words",value:null!=(P=null!=(R=null==(n=q.fluency_and_coherence)?void 0:n.filler_count)?R:null==(l=q.fluency_and_coherence)?void 0:l.pause_count)?P:0,hint:"um, uh, er, hmmâ¦"},{label:"Discourse Markers",value:null!=(L=null==(i=q.fluency_and_coherence)?void 0:i.discourse_markers)?L:0,hint:"however, therefore, firstlyâ¦"},{label:"Duration",value:(null==(d=q.fluency_and_coherence)?void 0:d.duration_seconds)?"".concat(q.fluency_and_coherence.duration_seconds,"s"):"N/A"}]},{id:"lexical",title:"Lexical Resource",icon:b.A,score:B(q.lexical_resource),scoreNum:parseFloat(B(q.lexical_resource))||0,feedback:null==(c=q.lexical_resource)?void 0:c.feedback,description:"Range and accuracy of vocabulary used",metrics:[{label:"Vocabulary Diversity",value:((null==(u=q.lexical_resource)?void 0:u.type_token_ratio)||0).toFixed(2)},{label:"Advanced Words",value:null!=(W=null==(m=q.lexical_resource)?void 0:m.advanced_words)?W:0},{label:"Word Repetition",value:null!=(F=null==(x=q.lexical_resource)?void 0:x.repeated_words)?F:0}]},{id:"grammar",title:"Grammatical Range & Accuracy",icon:v.A,score:B(q.grammatical_range_and_accuracy),scoreNum:parseFloat(B(q.grammatical_range_and_accuracy))||0,feedback:null==(h=q.grammatical_range_and_accuracy)?void 0:h.feedback,description:"Range and accuracy of grammatical structures",metrics:[{label:"Grammar Errors",value:null!=(M=null==(f=q.grammatical_range_and_accuracy)?void 0:f.error_count)?M:0},{label:"Complex Sentences",value:"".concat((100*((null==(_=q.grammatical_range_and_accuracy)?void 0:_.complex_sentence_ratio)||0)).toFixed(0),"%")},{label:"Average Length",value:((null==(A=q.grammatical_range_and_accuracy)?void 0:A.avg_sentence_length)||0).toFixed(1)}]},{id:"pronunciation",title:"Pronunciation",icon:j.A,score:B(q.pronunciation),scoreNum:parseFloat(B(q.pronunciation))||0,feedback:null==(S=q.pronunciation)?void 0:S.feedback,description:"Ability to use pronunciation features naturally",metrics:[{label:"Confidence Level",value:"".concat((100*((null==(C=q.pronunciation)?void 0:C.avg_confidence)||0)).toFixed(0),"%")}]}];return(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card/60 p-5",children:[(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg border bg-muted border-border flex items-center justify-center",children:(0,s.jsx)(p.A,{className:"w-5 h-5 text-foreground",strokeWidth:1.5})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-bold text-foreground",children:"IELTS Speaking Test Results"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:(e=>e>=8.5?"Expert score":e>=7.5?"Very Good score":e>=6.5?"Better score":e>=5.5?"Good score":e>=4.5?"Limited score":"Extremely Limited score")(q.overall_band_score)})]})]}),(0,s.jsxs)(o.E,{variant:"outline",className:"text-lg font-bold border-border text-foreground px-4 py-2 self-start sm:self-auto",children:["Band ",D(q.overall_band_score)]})]}),(0,s.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Overall Score"}),(0,s.jsxs)("span",{className:"font-bold text-foreground",children:[D(q.overall_band_score)," / 9.0"]})]}),(0,s.jsx)("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden",children:(0,s.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all duration-500",style:{width:"".concat(q.overall_band_score/9*100,"%")}})}),(0,s.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:"0.0"}),(0,s.jsx)("span",{children:"4.5"}),(0,s.jsx)("span",{children:"6.0"}),(0,s.jsx)("span",{children:"7.0"}),(0,s.jsx)("span",{children:"9.0"})]})]}),(0,s.jsx)("div",{className:"mt-3 p-3 rounded-lg border bg-muted/30 border-border",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:q.overall_band_score>=7?"Excellent performance! Good operational command of English with occasional inaccuracies.":q.overall_band_score>=6?"Good performance! Generally effective command of English despite some inaccuracies.":q.overall_band_score>=5?"Modest performance! Partial command of English in most situations.":"Limited performance. Regular practice is recommended."})})]}),(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card/60 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 px-5 py-4 border-b border-border",children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded-lg border bg-muted border-border flex items-center justify-center",children:(0,s.jsx)(N.A,{className:"w-3.5 h-3.5 text-foreground",strokeWidth:1.5})}),(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Detailed Assessment by Criteria"})]}),(0,s.jsx)("div",{className:"p-5 grid gap-4 lg:grid-cols-2",children:$.map(e=>{let r=e.icon;return(0,s.jsxs)("div",{className:"rounded-lg border bg-muted/30 border-border p-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("div",{className:"w-8 h-8 rounded-lg border bg-muted border-border flex items-center justify-center",children:(0,s.jsx)(r,{className:"w-4 h-4 text-foreground",strokeWidth:1.5})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-bold text-foreground",children:e.title}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:e.description})]})]}),(0,s.jsx)(o.E,{variant:"outline",className:"text-sm font-bold border-border text-foreground ml-2 flex-shrink-0",children:e.score})]}),(0,s.jsx)("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden mb-3",children:(0,s.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all duration-500",style:{width:"".concat(e.scoreNum/9*100,"%")}})}),(0,s.jsx)("div",{className:"space-y-1.5 mb-3",children:e.metrics.map((e,r)=>(0,s.jsxs)("div",{className:"flex items-center justify-between text-xs bg-muted/50 rounded px-2.5 py-1.5 gap-2",children:[(0,s.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:e.label}),e.hint&&(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground
1/60 truncate",children:e.hint})]}),(0,s.jsx)("span",{className:"font-semibold flex-shrink-0 ".concat(e.valueColor||"text-foreground"),children:e.value})]},r))}),e.feedback&&(0,s.jsxs)("div",{className:"bg-muted/50 rounded-lg p-2.5",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground mb-1",children:"Feedback"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:e.feedback})]})]},e.id)})})]}),q.detailed_feedback&&(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(null==(E=q.detailed_feedback.strengths)?void 0:E.length)>0&&(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card/60 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 px-5 py-4 border-b border-border",children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded-lg border bg-muted border-border flex items-center justify-center",children:(0,s.jsx)(y.A,{className:"w-3.5 h-3.5 text-foreground",strokeWidth:1.5})}),(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Strengths"})]}),(0,s.jsx)("ul",{className:"p-5 space-y-3",children:q.detailed_feedback.strengths.map((e,r)=>(0,s.jsxs)("li",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"w-5 h-5 rounded-full border bg-muted border-border flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,s.jsx)("span",{className:"text-[10px] font-bold text-foreground",children:r+1})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:e})]},r))})]}),(null==(T=q.detailed_feedback.areas_for_improvement)?void 0:T.length)>0&&(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card/60 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 px-5 py-4 border-b border-border",children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded-lg border bg-muted border-border flex items-center justify-center",children:(0,s.jsx)(w.A,{className:"w-3.5 h-3.5 text-foreground",strokeWidth:1.5})}),(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Areas for Improvement"})]}),(0,s.jsx)("ul",{className:"p-5 space-y-3",children:q.detailed_feedback.areas_for_improvement.map((e,r)=>(0,s.jsxs)("li",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"w-5 h-5 rounded-full border bg-muted border-border flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,s.jsx)("span",{className:"text-[10px] font-bold text-foreground",children:r+1})}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:e})]},r))})]})]}),(q.transcription||U.length>0)&&(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card/60 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 px-5 py-4 border-b border-border",children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded-lg border bg-muted border-border flex items-center justify-center",children:(0,s.jsx)(k.A,{className:"w-3.5 h-3.5 text-foreground",strokeWidth:1.5})}),(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground",children:U.length>0?"Questions & Responses":"Your Complete Response"})]}),(0,s.jsx)("div",{className:"p-5",children:U.length>0?(0,s.jsx)("div",{className:"space-y-4",children:U.map((e,r)=>{var t;return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-muted/30 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)("div",{className:"w-5 h-5 rounded-full bg-foreground flex items-center justify-center flex-shrink-0",children:(0,s.jsx)("span",{className:"text-[10px] font-bold text-background",children:r+1})}),(0,s.jsxs)("p",{className:"text-xs font-bold text-foreground",children:["Question ",r+1]}),(null==(t=e.metadata)?void 0:t.part)&&(0,s.jsx)(o.E,{variant:"outline",className:"text-[10px] border-border text-muted-foreground",children:e.metadata.part.replace("_"," ").toUpperCase()})]}),(0,s.jsx)("div",{className:"bg-muted/50 rounded-lg p-3 mb-3",children:(0,s.jsx)("p",{className:"text-xs font-medium text-foreground leading-relaxed whitespace-pre-line",children:O(e.question)})}),(0,s.jsx)("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1.5 uppercase tracking-wide",children:"Your Answer"}),(0,s.jsx)("div",{className:"bg-muted/50 rounded-lg p-3",children:(0,s.jsxs)("p",{className:"text-xs italic text-foreground leading-relaxed whitespace-pre-line",children:['"',O(e.answer||"No response recorded"),'"']}
1)})]},r)})}):(0,s.jsx)("div",{className:"bg-muted/30 rounded-lg border border-border p-4",children:(0,s.jsxs)("p",{className:"text-xs italic text-foreground leading-relaxed whitespace-pre-line",children:['"',O(q.transcription),'"']})})})]}),(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card/60 overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-5 py-4 border-b border-border text-center",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground",children:"IELTS Band Score Reference"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Understanding the 9-band scoring system"})]}),(0,s.jsx)("div",{className:"p-5 grid grid-cols-2 lg:grid-cols-4 gap-3",children:[{range:"7.0â9.0",label:"Good to Expert",description:"Effective command of English"},{range:"6.0â6.5",label:"Competent",description:"Generally effective command"},{range:"5.0â5.5",label:"Modest",description:"Partial command of English"},{range:"Below 5.0",label:"Limited",description:"Basic competence limited"}].map((e,r)=>(0,s.jsxs)("div",{className:"bg-muted/30 rounded-lg border border-border p-3 text-center",children:[(0,s.jsx)("p",{className:"text-sm font-bold text-foreground mb-1",children:e.range}),(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground mb-1",children:e.label}),(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground",children:e.description})]},r))})]}),(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card/60 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 px-5 py-4 border-b border-border",children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded-lg border bg-muted border-border flex items-center justify-center",children:(0,s.jsx)(v.A,{className:"w-3.5 h-3.5 text-foreground",strokeWidth:1.5})}),(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Recommended Next Steps"})]}),(0,s.jsx)("div",{className:"p-5 grid gap-3 md:grid-cols-3",children:[{num:1,title:"Continue Practice",body:"Regular practice with varied topics will improve your speaking fluency and confidence."},{num:2,title:"Focus on Weaknesses",body:"Review the improvement areas and practice targeted exercises."},{num:3,title:"Take Mock Tests",body:"Complete full mock tests regularly to familiarize yourself with the test format."}].map(e=>{let{num:r,title:t,body:a}=e;return(0,s.jsxs)("div",{className:"bg-muted/30 rounded-lg border border-border p-4 text-center",children:[(0,s.jsx)("div",{className:"w-8 h-8 rounded-lg border bg-muted border-border flex items-center justify-center mx-auto mb-3",children:(0,s.jsx)("span",{className:"text-sm font-bold text-foreground",children:r})}),(0,s.jsx)("p",{className:"text-sm font-bold text-foreground mb-2",children:t}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:a})]},r)})})]})]})};var A=t(45447),S=t(58489),C=t(63728),E=t(3974),T=t(57187),R=t(64146),P=t(32108),L=t(2244),W=t(59607),F=t(42970),M=t(34432),q=t(14643),I=t(79865);let D=e=>{let{testData:r,onClose:t}=e;if(!r)return null;let{testHistory:a}=r,l=(null==a?void 0:a.sessionData)||[],d=(null==a?void 0:a.overall_band_score)||0,c=(null==a?void 0:a.fluency_and_coherence)||0,u=(null==a?void 0:a.lexical_resource)||0,h=(null==a?void 0:a.grammatical_range_and_accuracy)||0,f=(null==a?void 0:a.pronunciation)||0,g=(null==a?void 0:a.questionsAnswered)||0,b=(null==a?void 0:a.metadata)||{},v=b.mode||"practice",j=b.topic||"General",N=b.parts||[];return(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm",children:(0,s.jsx)("div",{className:"bg-background rounded-2xl border border-border w-full max-w-5xl max-h-[90vh] overflow-y-auto shadow-2xl [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:rounded-full",onClick:e=>e.stopPropagation(),children:(0,s.jsxs)("div",{className:"p-6 md:p-8",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 border rounded-lg flex items-center justify-center bg-muted border-border",children:(0,s.jsx)(p.A,{className:"w-5 h-5 text-foreground",strokeWidth:1.5})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-lg font-bold text-foreground",children:"practice"===v?"Practice Session Results":"Mock Test Results"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:new Date(r.completedAt).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})})]})]}),(0,s.jsx)(n.$,{onClick:t,variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(i.A,{className:"w-4 h-4",strokeWidth:1.5})})]}),(0,s.jsxs)("div",{className:"rounded-xl border bg-card/60 border-border p-5 mb-5 text-center",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Overall Band Score"}),(0,s.jsx)("p",{className:"text-5xl font-bold text-foreground mb-1",children:d}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-4",children:"out of 9.0"}),(0,s.jsx)("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden max-w-xs mx-auto mb-4",children:(0,s.jsx)("div",{className:"h-full rounded-full bg-foreground transition-all duration-500",style:{width:"".concat(d/9*100,"%")}})}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[(0,s.jsxs)(o.E,{variant:"outline",className:"text-xs border-border text-foreground",children:[g," Questions"]}),j&&(0,s.jsx)(o.E,{variant:"outline",className:"text-xs border-border text-foreground",children:j}),N.length>0&&(0,s.jsxs)(o.E,{variant:"outline",className:"text-xs border-border text-foreground",children:["Parts: ",N.join(", ")
1]})]})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground mb-3",children:"Score Breakdown"}),(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[{label:"Fluency & Coherence",sub:"Speaking smoothly and logically",score:c},{label:"Lexical Resource",sub:"Vocabulary range and accuracy",score:u},{label:"Grammatical Range & Accuracy",sub:"Grammar complexity and correctness",score:h},{label:"Pronunciation",sub:"Clarity and accent",score:f}].map(e=>(0,s.jsxs)("div",{className:"rounded-xl border bg-card/60 border-border p-4 flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-foreground",children:e.label}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.sub})]}),(0,s.jsx)("p",{className:"text-2xl font-bold text-foreground",children:e.score})]},e.label))})]}),l.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,s.jsx)("div",{className:"h-px flex-1 bg-border"}),(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground",children:"Conversation History"}),(0,s.jsx)("div",{className:"h-px flex-1 bg-border"})]}),(0,s.jsx)("div",{className:"space-y-4 max-h-96 overflow-y-auto pr-1 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:rounded-full",children:l.map((e,r)=>{var t,a,n,l,i,d,c;let u=e.transcript||(null==(t=e.evaluation)?void 0:t.transcription);return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded-lg border bg-muted border-border flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,s.jsx)(m.A,{className:"w-3.5 h-3.5 text-foreground",strokeWidth:1.5})}),(0,s.jsxs)("div",{className:"flex-1 bg-card rounded-lg border border-border p-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-foreground",children:"AI Examiner"}),e.partType&&(0,s.jsxs)(o.E,{variant:"outline",className:"text-xs border-border text-foreground",children:["part_1"===e.partType&&"Part 1","part_2"===e.partType&&"Part 2","part_3"===e.partType&&"Part 3"]})]}),(0,s.jsx)("p",{className:"text-sm text-foreground leading-relaxed",children:e.question}),e.topic&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground mt-1.5",children:["Topic: ",e.topic]})]})]}),u&&(0,s.jsxs)("div",{className:"flex flex-row-reverse gap-3",children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded-lg border bg-muted border-border flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,s.jsx)(x.A,{className:"w-3.5 h-3.5 text-foreground",strokeWidth:1.5})}),(0,s.jsxs)("div",{className:"flex-1 bg-muted/30 rounded-lg border border-border p-3",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground mb-1.5",children:"Your Response"}),(0,s.jsxs)("p",{className:"text-sm text-foreground leading-relaxed italic",children:['"',u,'"']}),e.evaluation&&(0,s.jsxs)("div",{className:"mt-2 bg-card rounded-lg border border-border p-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"Evaluation"}),(0,s.jsxs)(o.E,{variant:"outline",className:"text-xs border-border text-foreground",children:["Band ",e.evaluation.overall_band_score]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-1.5 mb-1.5",children:[(null==(a=e.evaluation.fluency_and_coherence)?void 0:a.band_score)&&(0,s.jsxs)("div",{className:"text-xs",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Fluency: "}),(0,s.jsx)("span",{className:"font-medium text-foreground",children:e.evaluation.fluency_and_coherence.band_score})]}),(null==(n=e.evaluation.lexical_resource)?void 0:n.band_score)&&(0,s.jsxs)("div",{className:"text-xs",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Vocabulary: "}),(0,s.jsx)("span",{className:"font-medium text-foreground",children:e.evaluation.lexical_resource.band_score})]}),(null==(l=e.evaluation.grammatical_range_and_accuracy)?void 0:l.band_score)&&(0,s.jsxs)("div",{className:"text-xs",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Grammar: "}),(0,s.jsx)("span",{className:"font-medium text-foreground",children:e.evaluation.grammatical_range_and_accuracy.band_score})]}),(null==(i=e.evaluation.pronunciation)?void 0:i.band_score)&&(0,s.jsxs)("div",{className:"text-xs",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:"Pronunciation: "}),(0,s.jsx)("span",{className:"font-medium text-foreground",children:e.evaluation.pronunciation.band_score})]})]}),(null==(c=e.evaluation.detailed_feedback)||null==(d=c.areas_for_improvement)?void 0:d[0])&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:[(0,s.jsx)("span",{className:"font-medium",children:"Tip: "}),e.evaluation.detailed_feedback.areas_for_improvement[0]]})]})]})]})]},r)})})]}),(0,s.jsx)("div",{className:"flex justify-center mt-6 pt-5 border-t border-border",children:(0,s.jsx)(n.$,{onClick:t,className:"bg-foreground hover:bg-foreground
1/90 text-background px-8 h-9 text-sm font-semibold",children:"Close"})})]})})})};var B=t(49090);let O=e=>{let{cx:r,cy:t,payload:a,onViewDetails:n,colors:o,selectedIdx:l,onDotHover:i,wrapperRef:d}=e;if(null==r||null==t)return null;let c=l===a.label;return(0,s.jsxs)("g",{style:{cursor:"pointer"},onClick:()=>n(a.item,a.label),onMouseEnter:e=>{if(!(null==d?void 0:d.current))return;let r=d.current.getBoundingClientRect();i({x:e.clientX-r.left,y:e.clientY-r.top,payload:a})},onMouseLeave:()=>i("hide"),children:[(0,s.jsx)("circle",{cx:r,cy:t,r:20,fill:"transparent"}),c&&(0,s.jsx)("circle",{cx:r,cy:t,r:14,fill:o.stroke,fillOpacity:.12}),c&&(0,s.jsx)("circle",{cx:r,cy:t,r:9,fill:o.stroke,fillOpacity:.18}),(0,s.jsx)("circle",{cx:r,cy:t,r:c?7:5,fill:c?o.stroke:o.dotFill,stroke:o.stroke,strokeWidth:2.5})]})},U=e=>{let{cx:r,cy:t,payload:a,onViewDetails:n,colors:o,selectedIdx:l,onDotHover:i,wrapperRef:d}=e;if(null==r||null==t)return null;let c=l===a.label;return(0,s.jsxs)("g",{style:{cursor:"pointer"},onClick:()=>n(a.item,a.label),onMouseEnter:e=>{if(!(null==d?void 0:d.current))return;let r=d.current.getBoundingClientRect();i({x:e.clientX-r.left,y:e.clientY-r.top,payload:a})},onMouseLeave:()=>i("hide"),children:[(0,s.jsx)("circle",{cx:r,cy:t,r:20,fill:"transparent"}),(0,s.jsx)("circle",{cx:r,cy:t,r:18,fill:o.stroke,fillOpacity:.08}),(0,s.jsx)("circle",{cx:r,cy:t,r:11,fill:o.stroke,fillOpacity:.15}),(0,s.jsx)("circle",{cx:r,cy:t,r:c?7:6,fill:o.stroke,stroke:o.dotFill,strokeWidth:2})]})},z=e=>{var r,t,o;let{onStart:l,onStartMock:i,loading:c}=e;(0,R.useRouter)();let[u,m]=(0,a.useState)([]),[x,p]=(0,a.useState)(null),[f,g]=(0,a.useState)(!0),[b,v]=(0,a.useState)(null),[j,N]=(0,a.useState)(!1),[k,_]=(0,a.useState)(null),[z,G]=(0,a.useState)(null),$=(0,a.useRef)(null),H=(0,a.useRef)(null),Q=(0,a.useCallback)(e=>{"hide"===e?H.current=setTimeout(()=>G(null),180):(H.current&&clearTimeout(H.current),G(e))},[]),V=(0,a.useCallback)(()=>{H.current&&clearTimeout(H.current)},[]),Y=(0,a.useCallback)(()=>{H.current=setTimeout(()=>G(null),180)},[]);(0,a.useEffect)(()=>{J()},[]);let J=async()=>{try{let e=await fetch("/api/ielts/history?testType=speaking&limit=10"),r=await e.json();r.success&&(m(r.history),K(r.history))}catch(e){console.error(e)}finally{g(!1)}},K=e=>{if(!(null==e?void 0:e.length))return void p(null);let r=e.map(e=>{var r,t;return(null==(r=e.testHistory)?void 0:r.overall_band_score)||(null==(t=e.testHistory)?void 0:t.overallBand)||0}),t=r.reduce((e,r)=>e+r,0)/r.length;p({totalTests:e.length,average:t.toFixed(1),highest:Math.max(...r).toFixed(1),recent:r[0]||0,improvement:r.length>1?(r[0]-r[r.length-1]).toFixed(1):0})},X=(0,a.useCallback)((e,r)=>{void 0!==r&&_(r),v(e),N(!0)},[]),[Z,ee]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=()=>ee(document.documentElement.classList.contains("active-dark-mode"));e();let r=new MutationObserver(e);return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]);let er={...B.yt[Z?"dark":"light"],gradStart:Z?"rgba(251,250,247,0.18)":"rgba(19,41,77,0.12)",refLine:Z?"rgba(251,250,247,0.25)":"rgba(19,41,77,0.20)"},et=f||c,es=!et&&u.length>0,ea=u.length>1?[...u].reverse().map((e,r)=>{var t,s;return{label:"#".concat(r+1),band:(null==(t=e.testHistory)?void 0:t.overall_band_score)||(null==(s=e.testHistory)?void 0:s.overallBand)||0,date:new Date(e.completedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),item:e}}):[],en=x?parseFloat(x.highest):null;return(0,s.jsxs)("div",{className:"min-h-screen bg-background",style:{"--module-accent":"var(--module-speaking)"},children:[(0,s.jsx)("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 pt-6",children:(0,s.jsx)("div",{className:"relative overflow-hidden rounded-2xl p-6 sm:p-8 border border-module-accent/60 dark:border-module-accent/20",style:{background:"linear-gradient(135deg, rgb(var(--module-accent) / 0.14) 0%, rgb(var(--module-accent) / 0.02) 100%)"},children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-6",children:[(0,s.jsxs)("div",{className:"max-w-lg",children:[(0,s.jsx)("p",{className:"text-xs font-bold uppercase tracking-widest mb-2",style:{color:"rgb(var(--module-accent))"},children:"AI-Powered Practice"}),(0,s.jsx)("h1",{className:"text-3xl sm:text-4xl font-extrabold text-foreground",children:"Speaking"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mt-2 max-w-md",children:"Build fluency across Parts 1, 2 & 3. Speak, record, and get AI feedback on pronunciation, coherence, and vocabulary."}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 mt-5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold",style:{backgroundColor:"rgb(var(--module-accent) / 0.14)",color:"rgb(var(--module-accent))"},children:[(0,s.jsx)(A.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"3 Parts"]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold",style:{backgroundColor:"rgb(var(--module-accent) / 0.14)",color:"rgb(var(--module-accent))"},children:[(0,s.jsx)(S.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"~15 min per test"]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold",style:{backgroundColor:"rgb(var(--module-accent) / 0.14)",color:"rgb(var(--module-accent))"},children:[(0,s.jsx)(y.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"AI fluency & coherence"]})]})]}),(0,s.jsxs)("div",{className:"relative hidden sm:flex items-center justify-center w-20 h-20 flex-shrink-0",children:[(0,s.jsx)("div",{className:"absolute -inset-3.5 rounded-full border-2 border-dashed animate-[spin_8s_linear_infinite]",style:{borderColor:"rgb(var(--module-accent) / 0.35)"}}),(0,s.jsx)("div",{className:"relative flex items-center justify-center w-20 h-20 rounded-2xl",style:{backgroundColor:"rgb(var(--module-accent) / 0.16)"},children:(0,s.jsx)(d.A,{className:"w-9 h-9",style:{color:"rgb(var(--module-accent))"},strokeWidth:1.5})})]})]})})}),(0,s.jsx)("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:(0,s.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[minmax(0,1fr)_300px] gap-4 lg:gap-6",children:[(0,s.jsxs)("div",{className:"py-6 space-y-5",children:[(0,s.jsxs)("div",{className:"relative overflow-hidden flex flex-col items-center justify-center gap-4 py-8 px-7 rounded-2xl border border-border bg-card/60 backdrop-blur-sm",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-gradient-to-b from-foreground
1/[0.04] to-transparent pointer-events-none"}),(0,s.jsx)("p",{className:"text-sm font-medium text-muted-foreground relative z-10 tracking-wide",children:"Ready to practice your speaking?"}),(0,s.jsxs)("div",{className:"relative z-10 flex items-center justify-center",children:[!c&&(0,s.jsx)("span",{className:"absolute inline-flex w-full h-full rounded-2xl bg-foreground/10 animate-ping opacity-50"}),(0,s.jsx)(n.$,{onClick:l,disabled:c,size:"lg",className:"relative px-10 text-sm font-bold h-11 text-white hover:opacity-90 active:scale-95 rounded-xl shadow-lg gap-2 transition-all duration-150 border-0",style:{backgroundColor:"rgb(var(--module-accent))"},children:c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-4 h-4 border-2 rounded-full border-current border-t-transparent animate-spin"})," Loading..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(h.A,{className:"w-[18px] h-[18px]",strokeWidth:0,fill:"currentColor"})," Start New Test"]})})]}),i&&(0,s.jsxs)(n.$,{onClick:i,disabled:c,variant:"outline",size:"sm",className:"relative z-10 text-xs font-semibold gap-1.5 border-2 bg-transparent hover:bg-[var(--accent-c)] hover:text-white transition-colors",style:{"--accent-c":"rgb(var(--module-accent))",borderColor:"rgb(var(--module-accent))",color:"rgb(var(--module-accent))"},children:[(0,s.jsx)(A.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Take Full Mock Interview (3 parts, one band score)"]})]}),et?(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 p-5 border rounded-xl bg-card/60 backdrop-blur-sm border-border",children:Array.from({length:4}).map((e,r)=>(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)(T.E,{className:"w-16 h-6 mx-auto mb-1"}),(0,s.jsx)(T.E,{className:"w-12 h-3 mx-auto"})]},r))}):(0,s.jsx)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 p-5 border rounded-xl bg-card/60 backdrop-blur-sm border-border",children:[{label:"Average",value:null!=(r=null==x?void 0:x.average)?r:"â"},{label:"Best",value:null!=(t=null==x?void 0:x.highest)?t:"â"},{label:"Completed",value:null!=(o=null==x?void 0:x.totalTests)?o:"â"},{label:"Improvement",value:x?x.improvement>=0?"+".concat(x.improvement):x.improvement:"â"}].map(e=>{let{label:r,value:t}=e;return(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-2xl font-bold text-foreground tabular-nums",children:t}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:r})]},r)})}),!et&&ea.length>0&&(0,s.jsxs)("div",{className:"border rounded-2xl bg-card/60 backdrop-blur-sm border-border",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 pt-5 pb-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"flex items-center justify-center w-7 h-7 rounded-lg bg-muted border border-border",children:(0,s.jsx)(w.A,{className:"w-3.5 h-3.5 text-foreground",strokeWidth:1.5})}),(0,s.jsx)("span",{className:"text-sm font-bold text-foreground",children:"Score Progress"})]}),en&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-muted border border-border",children:[(0,s.jsx)(C.A,{className:"w-3 h-3 text-foreground",strokeWidth:1.5}),(0,s.jsxs)("span",{className:"text-xs font-bold text-foreground",children:["Best: ",en]})]})]}),(0,s.jsxs)("div",{ref:$,className:"relative px-2 pb-4",style:{WebkitTapHighlightColor:"transparent",userSelect:"none"},onMouseDown:e=>e.preventDefault(),children:[z&&(0,s.jsx)("div",{style:{position:"absolute",left:z.x,top:z.y-12,transform:"translate(-50%, -100%)",pointerEvents:"all",zIndex:50},onMouseEnter:V,onMouseLeave:Y,children:(0,s.jsxs)("div",{style:{background:er.tooltipBg,border:"1px solid ".concat(er.grid)},className:"rounded-xl shadow-2xl px-4 py-3 text-xs min-w-[148px]",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4 mb-1.5",children:[(0,s.jsxs)("span",{style:{color:er.muted},className:"font-medium",children:["Test ",z.payload.label]}),(0,s.jsx)("span",{style:{color:er.muted,opacity:.7},className:"text-[10px]",children:z.payload.date})]}),(0,s.jsx)("div",{style:{color:er.stroke},className:"text-2xl font-bold leading-none mb-2.5",children:z.payload.band}),(0,s.jsxs)("button",{onClick:()=>{X(z.payload.item,z.payload.label),G(null)},style:{background:er.stroke,color:er.dotFill},className:"w-full flex items-center justify-center gap-1.5 text-[11px] font-semibold rounded-lg px-2 py-1.5 hover:opacity-90 transition-opacity",children:[(0,s.jsx)(E.A,{className:"w-3 h-3"})," View Details"]}
1)]})}),(0,s.jsx)(P.u,{width:"100%",height:200,children:(0,s.jsxs)(L.Q,{data:ea,margin:{top:10,right:16,left:-10,bottom:0},onClick:()=>{},children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("linearGradient",{id:"bandGradient-".concat(Z?"dark":"light"),x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:er.stroke,stopOpacity:.2}),(0,s.jsx)("stop",{offset:"100%",stopColor:er.stroke,stopOpacity:0})]})}),(0,s.jsx)(W.d,{strokeDasharray:"4 4",stroke:er.grid,vertical:!1}),en&&(0,s.jsx)(F.e,{y:en,stroke:er.refLine,strokeDasharray:"6 3",strokeWidth:1.5}),(0,s.jsx)(M.W,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:er.muted,fontWeight:500},dy:6}),(0,s.jsx)(q.h,{domain:[0,9],ticks:[0,3,6,9],axisLine:!1,tickLine:!1,tick:{fontSize:11,fill:er.muted},width:28}),(0,s.jsx)(I.Gk,{type:"monotone",dataKey:"band",stroke:er.stroke,strokeWidth:2.5,strokeOpacity:1,fill:"url(#bandGradient-".concat(Z?"dark":"light",")"),dot:e=>{let{key:r,...t}=e;return(0,s.jsx)(O,{...t,onViewDetails:X,colors:er,selectedIdx:k,onDotHover:Q,wrapperRef:$},r)},activeDot:e=>{let{key:r,...t}=e;return(0,s.jsx)(U,{...t,onViewDetails:X,colors:er,selectedIdx:k,onDotHover:Q,wrapperRef:$},r)},isAnimationActive:!0,animationDuration:800,animationEasing:"ease-out"})]},Z?"dark":"light")})]}),(0,s.jsx)("div",{className:"px-5 pb-4",children:(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground/60 text-center",children:"Hover over a point to see details \xb7 Click to open results"})})]}),(0,s.jsx)("div",{className:"space-y-3",children:et?(0,s.jsx)("div",{className:"py-10 text-center text-sm text-muted-foreground",children:"Loading history..."}):es?u.map((e,r)=>{var t,a;let o=(null==(t=e.testHistory)?void 0:t.overall_band_score)||(null==(a=e.testHistory)?void 0:a.overallBand)||0;return(0,s.jsxs)("div",{className:"flex items-center gap-3 sm:gap-4 p-3 sm:p-5 transition-all duration-200 border rounded-xl bg-card/60 backdrop-blur-sm border-border hover:border-foreground
1/20 hover:shadow-sm",children:[(0,s.jsx)("div",{className:"flex items-center justify-center flex-shrink-0 w-10 h-10 border rounded-lg bg-muted border-border",children:(0,s.jsx)(d.A,{className:"w-4 h-4 text-foreground",strokeWidth:1.5})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("h3",{className:"text-base font-bold text-foreground mb-1",children:["Test #",u.length-r]}),(0,s.jsxs)("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[(0,s.jsx)("span",{className:"font-medium",children:new Date(e.completedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"â¢"}),(0,s.jsxs)("span",{className:"font-bold text-foreground",children:["Band ",o]})]})]}),(0,s.jsxs)(n.$,{onClick:()=>X(e),variant:"outline",size:"sm",className:"px-4 text-sm font-semibold border h-9 hover:bg-muted flex-shrink-0",children:[(0,s.jsx)(E.A,{className:"w-3.5 h-3.5 mr-1.5",strokeWidth:1.5}),"Results"]})]},e.id)}):(0,s.jsx)("div",{className:"py-12 text-center",children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No speaking attempts yet."})})})]}),(0,s.jsx)("div",{className:"bg-muted/10 rounded-card border border-border mt-4 sm:mt-6 mb-4 sm:mb-6",children:(0,s.jsxs)("div",{className:"sticky p-4 sm:p-6 space-y-6 top-20",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 pb-3 border-b border-border",children:[(0,s.jsx)(y.A,{className:"w-4 h-4",style:{color:"rgb(var(--module-accent))"},strokeWidth:1.5}),(0,s.jsx)("h3",{className:"text-sm font-bold text-foreground",children:"Test Format"})]}),(0,s.jsx)("div",{className:"space-y-4",children:[{icon:S.A,label:"Duration",value:"11-14 min"},{icon:y.A,label:"Parts",value:"3"}].map(e=>{let{icon:r,label:t,value:a}=e;return(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg",style:{backgroundColor:"rgb(var(--module-accent) / 0.14)"},children:(0,s.jsx)(r,{className:"w-4 h-4",style:{color:"rgb(var(--module-accent))"},strokeWidth:1.5})}),(0,s.jsx)("span",{className:"text-sm font-medium text-foreground",children:t})]}),(0,s.jsx)("span",{className:"text-sm font-bold text-foreground",children:a})]},t)})})]})})]})}),j&&b&&(0,s.jsx)(D,{testData:b,onClose:()=>{N(!1),v(null)}})]})};var G=t(35004),$=t(33731);let H=e=>{let{isOpen:r,onClose:t,onStart:o,mode:l="practice",topics:d=[],loading:c=!1}=e,u="mock"===l,[p,f]=(0,a.useState)("part_1"),[b,j]=(0,a.useState)(""),[N,k]=(0,a.useState)("aura-2-aurora-en"),[_,S]=(0,a.useState)(!1),[C,E]=(0,a.useState)(""),T=_?C.trim():b,R=[{id:"part_1",number:1,icon:x.A,title:"Introduction & Interview",description:"4-5 minutes: Personal questions about familiar topics like home, family, work, studies",duration:"4-5 minutes",questions:"6 questions"},{id:"part_2",number:2,icon:m.A,title:"Individual Long Turn",description:"3-4 minutes: Speak on a given topic for 2 minutes after 1 minute preparation",duration:"3-4 minutes",questions:"1 topic card"},{id:"part_3",number:3,icon:A.A,title:"Two-way Discussion",description:"4-5 minutes: Abstract questions related to Part 2 topic",duration:"4-5 minutes",questions:"4-6 questions"}],P=[{value:"aura-2-aurora-en",label:"Aurora (American - Female)",accent:"American",gender:"Female"},{value:"aura-2-pluto-en",label:"Pluto (American - Male)",accent:"American",gender:"Male"},{value:"aura-2-pandora-en",label:"Pandora (British - Female)",accent:"British",gender:"Female"},{value:"aura-2-draco-en",label:"Draco (British - Male)",accent:"British",gender:"Male"}];if((0,a.useEffect)(()=>{d.length>0&&!b&&j(d[0])},[d,b]),!r)return null;let L=R.find(e=>e.id===p),W=P.find(e=>e.value===N);return(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm",children:(0,s.jsx)("div",{className:"bg-background rounded-2xl border border-border w-full max-w-2xl max-h-[95vh] overflow-y-auto shadow-2xl",onClick:e=>e.stopPropagation(),children:(0,s.jsxs)("div",{className:"p-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-9 h-9 border rounded-lg flex items-center justify-center bg-muted border-border",children:(0,s.jsx)(G.A,{className:"w-4 h-4 text-foreground",strokeWidth:1.5})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-base font-bold text-foreground",children:u?"Mock Interview":"Practice Mode"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:u?"Full 3-part simulation, one combined band score":"Configure & Practice"})]})]}),(0,s.jsx)(n.$,{onClick:t,variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(i.A,{className:"w-4 h-4",strokeWidth:1.5})})]}),!u&&(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,s.jsx)(G.A,{className:"w-4 h-4 text-foreground",strokeWidth:1.5}),(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground",children:"Select IELTS Part"})]}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",children:R.map(e=>{let r=e.icon,t=p===e.id;return(0,s.jsxs)("button",{onClick:()=>f(e.id),className:"relative p-3 rounded-xl border transition-all duration-200 ".concat(t?"bg-muted/50 border-foreground":"bg-card border-border hover:border-foreground
1/30"),children:[(0,s.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,s.jsx)("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center ".concat(t?"bg-foreground text-background":"bg-muted text-muted-foreground"),children:(0,s.jsx)(r,{className:"w-4 h-4",strokeWidth:1.5})}),(0,s.jsxs)("span",{className:"text-xs font-bold ".concat("text-foreground"),children:["Part ",e.number]})]}),t&&(0,s.jsx)("div",{className:"absolute top-2 right-2",children:(0,s.jsx)($.A,{className:"w-3.5 h-3.5 text-foreground",strokeWidth:1.5})})]},e.id)})}),L&&(0,s.jsx)("div",{className:"mt-3 p-4 rounded-xl border bg-muted/30 border-border",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[a.createElement(L.icon,{className:"w-4 h-4 text-foreground mt-0.5 flex-shrink-0",strokeWidth:1.5}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("p",{className:"text-sm font-bold text-foreground mb-1",children:L.title}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:L.description}),(0,s.jsxs)("div",{className:"flex gap-6 text-xs",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"font-semibold text-foreground",children:"Duration"}),(0,s.jsx)("p",{className:"text-muted-foreground mt-0.5",children:L.duration})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"font-semibold text-foreground",children:"Questions"}),(0,s.jsx)("p",{className:"text-muted-foreground mt-0.5",children:L.questions})]})]})]})]})})]}),!u&&(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(m.A,{className:"w-4 h-4 text-foreground",strokeWidth:1.5}),(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground",children:"Choose Topic"})]}),d.length>0&&(0,s.jsxs)("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded-full",children:[d.length," topics"]})]}),!_&&(d.length>0?(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("select",{value:b,onChange:e=>j(e.target.value),className:"w-full p-3 text-sm font-medium bg-card border border-border rounded-xl text-foreground focus:outline-none focus:ring-1 focus:ring-border appearance-none cursor-pointer",children:d.map((e,r)=>(0,s.jsx)("option",{value:e,className:"bg-card text-foreground",children:e},r))}),(0,s.jsx)("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",children:(0,s.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}):(0,s.jsx)("div",{className:"p-3 bg-muted/30 rounded-xl border border-border",children:(0,s.jsx)("p",{className:"text-xs text-muted-foreground text-center",children:"Loading topics..."})})),_&&(0,s.jsx)("input",{type:"text",value:C,onChange:e=>E(e.target.value),placeholder:"e.g. Renewable energy",maxLength:50,autoFocus:!0,className:"w-full p-3 text-sm font-medium bg-card border border-border rounded-xl text-foreground focus:outline-none focus:ring-1 focus:ring-border placeholder:text-muted-foreground"}),(0,s.jsx)("button",{type:"button",onClick:()=>S(e=>!e),className:"mt-2 text-xs font-medium text-muted-foreground hover:text-foreground underline underline-offset-2",children:_?"â Choose from the list instead":"Or type your own topic"})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,s.jsx)(g.A,{className:"w-4 h-4 text-foreground",strokeWidth:1.5}),(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground",children:"Examiner Voice"})]}),(0,s.jsxs)("div",{className:"relative mb-2",children:[(0,s.jsx)("select",{value:N,onChange:e=>k(e.target.value),className:"w-full p-3 text-sm font-medium bg-card border border-border rounded-xl text-foreground focus:outline-none focus:ring-1 focus:ring-border appearance-none cursor-pointer",children:P.map(e=>(0,s.jsx)("option",{value:e.value,className:"bg-card text-foreground",children:e.label},e.value))}),(0,s.jsx)("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",children:(0,s.jsx)("svg",{className:"w-4 h-4 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),W&&(0,s.jsxs)("div",{className:"flex items-center gap-4 text-xs text-muted-foreground px-1",children:[(0,s.jsxs)("span",{children:["Accent: ",(0,s.jsx)("span",{className:"font-semibold text-foreground",children:W.accent})]}),(0,s.jsxs)("span",{children:["Voice: ",(0,s.jsx)("span",{className:"font-semibold text-foreground",children:W.gender})]})]})]}),(0,s.jsx)("div",{className:"mb-6 p-4 rounded-xl border bg-muted/30 border-border",children:(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[{icon:y.A,label:"Instant AI feedback & band scores"},{icon:v.A,label:"Personalized topic selection"},{icon:w.A,label:"Progress tracking & analytics"}].map(e=>{let{icon:r,label:t}=e;return(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("div",{className:"w-8 h-8 bg-muted border border-border rounded-lg flex items-center justify-center flex-shrink-0",children:(0,s.jsx)(r,{className:"w-4 h-4 text-foreground",strokeWidth:1.5})}),(0,s.jsx)("p",{className:"text-xs font-medium text-foreground pt-1",children:t})]},t)})})}),(0,s.jsx)(n.$,{onClick:()=>{u?o({voice:N}):o({part:p,topic:T,voice:N})},disabled:c||!u&&!T,className:"w-full h-11 text-sm font-bold bg-foreground hover:bg-foreground
1/90 text-background rounded-xl disabled:opacity-50 gap-2",children:c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-4 h-4 border-2 border-background border-t-transparent rounded-full animate-spin"}),"Starting..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(h.A,{className:"w-4 h-4",strokeWidth:1.5}),u?"Start Mock Interview":"Start Practice Session"]})})]})})})},Q=()=>{let[e,r]=(0,a.useState)([]),[t,s]=(0,a.useState)([]),[n,o]=(0,a.useState)(!1),[l,i]=(0,a.useState)(null),d=(0,a.useCallback)(async e=>{try{if(!e)throw Error("No audio file provided");let r=new FormData,t="recording.wav";e.type.includes("webm")?t="recording.webm":e.type.includes("mp3")?t="recording.mp3":e.type.includes("mp4")?t="recording.mp4":e.type.includes("ogg")&&(t="recording.ogg"),r.append("file",e,t);let s=await fetch("/api/ielts-speaking/transcribe",{method:"POST",body:r});if(s.ok){let e=(await s.json()).text||null;if(!e||0===e.trim().length)return console.warn("Empty transcription received"),null;return e.trim()}{let e=await s.text();return console.error("Transcription failed:",s.status,e),null}}catch(e){return console.error("Transcription error:",e),null}},[]),c=(0,a.useCallback)(async e=>{try{o(!0),i(null);let t=await fetch("/api/ielts-speaking/topics/".concat(e));if(!t.ok)return[];{let e=await t.json();return r(e.topics||[]),e.topics||[]}}catch(e){return[]}finally{o(!1)}},[]),u=(0,a.useCallback)(async()=>{try{o(!0),i(null);let e=await fetch("/api/ielts-speaking/voice-options");if(!e.ok)return[];{let r=await e.json();return s(r.voices||[]),r.voices||[]}}catch(e){return[]}finally{o(!1)}},[]),m=(0,a.useCallback)(async function(e,r){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];try{o(!0),i(null);let a=await fetch("/api/ielts-speaking/question",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({task_id:t,part_type:e,topic:r,history:s.length>0?s:null})});if(!a.ok)return null;{let e=await a.json();if(e.question)return e.question;return null}}catch(e){return null}finally{o(!1)}},[]),x=(0,a.useCallback)(async function(e,r){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:60;try{if(o(!0),i(null),!e)throw Error("No audio file provided");if(!r)throw Error("Question text is required for evaluation");if(0===e.size)throw Error("Audio file is empty");let s=new FormData,a="recording.wav";e.type.includes("webm")?a="recording.webm":e.type.includes("mp4")?a="recording.mp4":e.type.includes("ogg")&&(a="recording.ogg"),s.append("file",e,a),s.append("audio_duration",t.toString()),s.append("question",r);let n=await fetch("/api/ielts-speaking/submit-answer",{method:"POST",body:s});if(n.ok){let e=await n.json();if(void 0!==e.overall_band_score)return e;if(e.success&&e.evaluation)return e.evaluation;if(e.evaluation)return e.evaluation;else throw Error("Unexpected API response structure")}{let e=await n.text();throw Error("API Error (".concat(n.status,"): ").concat(e))}}catch(e){return i(e.message),null}finally{o(!1)}},[]),h=(0,a.useCallback)(async e=>{try{o(!0),i(null);let r="mock_test_".concat(Date.now()),t=await fetch("/api/ielts-speaking/mock-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({task_id:r,is_first:!0,complete:!1,part_type:"part_1",history:[],current_answer:"",voice:e})});if(t.ok){let e=await t.json();if(e.question)return{task_id:r,question:e.question,message:e.message||"Welcome to the IELTS Speaking mock test!"};throw Error("No question received from mock test API")}{let e=await t.text();throw Error("Failed to start mock test: ".concat(e))}}catch(e){return i(e.message),null}finally{o(!1)}},[]),p=(0,a.useCallback)(async function(e,r,t){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"part_1";try{o(!0),i(null);let a=await fetch("/api/ielts-speaking/mock-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({task_id:e,is_first:!1,complete:!1,part_type:s,current_answer:r,history:t})});if(a.ok){let e=await a.json();if(e.question)return{success:!0,question:e.question,message:e.message};throw Error("No next question received")}{let e=await a.text();
1throw console.error("Mock test continuation failed:",e),Error("Failed to continue mock test: ".concat(e))}}catch(e){return i(e.message),null}finally{o(!1)}},[]);return{topics:e,voices:t,loading:n,error:l,loadTopics:c,loadVoices:u,generateQuestion:m,submitAnswer:x,startMockTest:h,continueMockTest:p,completeMockTest:(0,a.useCallback)(async(e,r)=>{try{o(!0),i(null);let t=r[r.length-1],s=t?t.answer:"",a={task_id:e,is_first:!1,complete:!0,part_type:t?t.part_type:"part_3",history:r,current_answer:s},n=await fetch("/api/ielts-speaking/mock-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(n.ok){let e=await n.json();if(e.evaluation)return{success:!0,evaluation:e.evaluation,message:e.message||"Mock test completed successfully"};throw Error("No evaluation received")}{let e=await n.text();throw console.error("Mock test completion failed:",e),Error("Failed to complete mock test: ".concat(e))}}catch(e){return i(e.message),null}finally{o(!1)}},[]),transcribeAudio:d,clearError:()=>{i(null)}}};var V=t(26483),Y=t(43074),J=t(36448);let K=[{a:24,f:2,dy:-28,color:"rgba(139,107,240,0.85)",w:1.5,dash:420,dur:3,del:0,ph:0},{a:16,f:3,dy:-12,color:"rgba(107,63,228,0.90)",w:1.5,dash:310,dur:2.5,del:.3,ph:.8},{a:28,f:1.5,dy:4,color:"rgba(169,140,245,0.70)",w:1,dash:520,dur:3.5,del:.1,ph:1.5},{a:8,f:4,dy:18,color:"rgba(90,49,204,0.65)",w:1,dash:360,dur:2.8,del:.5,ph:2.2},{a:20,f:2.5,dy:32,color:"rgba(242,129,30,0.50)",w:1,dash:460,dur:4,del:.2,ph:.4},{a:2,f:1,dy:0,color:"rgba(255,255,255,0.95)",w:2,dash:200,dur:2,del:0,ph:0}];function X(e){let{active:r=!1,size:t=192}=e,a=t/2,n=t/2,o=t/2*.92,l="orb".concat(t);return(0,s.jsxs)("div",{style:{width:t,height:t,position:"relative",flexShrink:0},children:[(0,s.jsxs)("svg",{viewBox:"0 0 ".concat(t," ").concat(t),width:t,height:t,xmlns:"http://www.w3.org/2000/svg",style:{display:"block"},children:[(0,s.jsxs)("defs",{children:[(0,s.jsx)("clipPath",{id:"".concat(l,"-clip"),children:(0,s.jsx)("circle",{cx:a,cy:n,r:o})}),(0,s.jsxs)("radialGradient",{id:"".concat(l,"-bg"),cx:"40%",cy:"38%",r:"72%",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:"#2A1D53"}),(0,s.jsx)("stop",{offset:"55%",stopColor:"#170F30"}),(0,s.jsx)("stop",{offset:"100%",stopColor:"#0B0718"})]}),(0,s.jsxs)("radialGradient",{id:"".concat(l,"-hl"),cx:"32%",cy:"28%",r:"42%",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:"rgba(255,255,255,0.20)"}),(0,s.jsx)("stop",{offset:"100%",stopColor:"rgba(255,255,255,0.00)"})]}),(0,s.jsxs)("filter",{id:"".concat(l,"-glow"),x:"-25%",y:"-25%",width:"150%",height:"150%",children:[(0,s.jsx)("feGaussianBlur",{stdDeviation:"2.5",result:"blur"}),(0,s.jsxs)("feMerge",{children:[(0,s.jsx)("feMergeNode",{in:"blur"}),(0,s.jsx)("feMergeNode",{in:"SourceGraphic"})]})]}),(0,s.jsxs)("filter",{id:"".concat(l,"-outer"),x:"-30%",y:"-30%",width:"160%",height:"160%",children:[(0,s.jsx)("feGaussianBlur",{stdDeviation:"6",result:"blur"}),(0,s.jsx)("feMerge",{children:(0,s.jsx)("feMergeNode",{in:"blur"})})]})]}),r&&(0,s.jsx)("circle",{cx:a,cy:n,r:o+8,fill:"none",stroke:"rgba(107,63,228,0.35)",strokeWidth:"12",filter:"url(#".concat(l,"-outer)")}),(0,s.jsx)("circle",{cx:a,cy:n,r:o,fill:"url(#".concat(l,"-bg)")}),(0,s.jsx)("g",{clipPath:"url(#".concat(l,"-clip)"),filter:"url(#".concat(l,"-glow)"),children:K.map((e,a)=>{let o=function(e,r,t,s){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,n=[];for(let o=0;o<=300;o++){let l=o/300*e,i=s+r*Math.sin(2*Math.PI*t*o/300+a);n.push("".concat(0===o?"M":"L").concat(l.toFixed(2),",").concat(i.toFixed(2)))}return n.join(" ")}(t,e.a,e.f,n+e.dy,e.ph),i=Math.round(.28*e.dash),d=Math.round(.72*e.dash),c=Math.round(.6*e.dash),u=Math.round(5*e.dash);return(0,s.jsx)("path",{d:o,fill:"none",stroke:e.color,strokeWidth:e.w,opacity:r?1:.18,strokeDasharray:r?"".concat(i," ").concat(d):"".concat(c," ").concat(u),style:{animation:r?"".concat(l,"-flow-").concat(a," ").concat(e.dur,"s linear infinite ").concat(e.del,"s"):"none",transition:"opacity 0.6s ease"}},a)})}),(0,s.jsx)("circle",{cx:a,cy:n,r:o,fill:"url(#".concat(l,"-hl)")}),(0,s.jsx)("circle",{cx:a,cy:n,r:o,fill:"none",stroke:"rgba(185,162,250,0.22)",strokeWidth:"1.5"}),(0,s.jsx)("circle",{cx:a,cy:n,r:o-2,fill:"none",stroke:"rgba(255,255,255,0.05)",strokeWidth:"1"})]}),(0,s.jsx)("style",{children:"\n @keyframes ".concat(l,"-flow-0 { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -").concat(Math.round(1176),"; } }\n @keyframes ").concat(l,"-flow-1 { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -").concat(Math.round(868),"; } }\n @keyframes ").concat(l,"-flow-2 { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -").concat(Math.round(1456),"; } }\n @keyframes ").concat(l,"-flow-3 { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -").concat(Math.round(360*2.8),"; } }\n @keyframes ").concat(l,"-flow-4 { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -").concat(Math.round(1288),"; } }\n @keyframes ").concat(l,"-flow-5 { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -").concat(Math.round(560),"; } }\n ")})]})}let Z=()=>new Promise(e=>{if("function"!=typeof window.requestAnimationFrame)return void e();window.requestAnimationFrame(()=>e())}),ee=new Set(["um","uh","er","erm","hmm","uhh","ahh"]),er=["however","furthermore","moreover","in addition","additionally","on the other hand","on the contrary","therefore","consequently","as a result","in conclusion","to sum up","firstly","secondly","thirdly","finally","for example","for instance","in particular","
1in fact","that is to say","in other words","by contrast"],et=function(){let{embedded:e=!1,fullMockSessionId:r=null,onSectionComplete:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[g,b]=(0,a.useState)(null),[v,j]=(0,a.useState)(!1),[N,y]=(0,a.useState)("practice"),[w,k]=(0,a.useState)(!1),[A,S]=(0,a.useState)("part_1"),[C,E]=(0,a.useState)(""),[T,R]=(0,a.useState)("aura-2-aurora-en"),[P,L]=(0,a.useState)([]),[W,F]=(0,a.useState)(""),[M,q]=(0,a.useState)(""),[I,D]=(0,a.useState)(!1),[B,O]=(0,a.useState)(!1),[U,G]=(0,a.useState)(null),[$,K]=(0,a.useState)(null),[et,es]=(0,a.useState)([]),[ea,en]=(0,a.useState)(!1),[eo,el]=(0,a.useState)(!1),[ei,ed]=(0,a.useState)(!1),[ec,eu]=(0,a.useState)(null),[em,ex]=(0,a.useState)([]),[eh,ep]=(0,a.useState)(!1),[ef,eg]=(0,a.useState)(null),[eb,ev]=(0,a.useState)("part_1"),[ej,eN]=(0,a.useState)(!1),[ey,ew]=(0,a.useState)(!1),[ek,e_]=(0,a.useState)(!1),[eA,eS]=(0,a.useState)(!1),eC=(0,a.useRef)(null),eE=(0,a.useRef)(!1),eT=(0,a.useRef)(!1),eR=(0,a.useRef)(null),eP=(0,a.useRef)(null),eL=(0,a.useRef)(null),eW=(0,a.useRef)(null),{topics:eF,voices:eM,loading:eq,loadTopics:eI,loadVoices:eD,generateQuestion:eB,submitAnswer:eO,startMockTest:eU,continueMockTest:ez,completeMockTest:eG,transcribeAudio:e$}=Q(),{isRecording:eH,recordedAudio:eQ,recordingTime:eV,finalDuration:eY,error:eJ,startRecording:eK,stopRecording:eX,clearRecording:eZ,cleanup:e0}=(0,V.C)(),{balance:e1,deductCredits:e5,showInsufficientCreditsModal:e3}=(0,Y.I)(),[e2,e4]=(0,a.useState)(0),[e6,e8]=(0,a.useState)(!1),[e9,e7]=(0,a.useState)([]),re=(0,a.useCallback)(()=>{if(eW.current){let e=eW.current.closest(".overflow-y-auto");e&&(e.scrollTop=e.scrollHeight)}},[]),rr=(0,a.useCallback)(()=>{if(0===et.length)return{totalQuestions:0,averageScore:0,bestScore:0,latestScore:0,averageByCategory:{fluency:0,lexical:0,grammar:0,pronunciation:0}};let e=et.length,r=et.map(e=>e.overallScore),t=r.reduce((e,r)=>e+r,0)/e,s=Math.max(...r),a=r[r.length-1],n=[],o=[],l=[],i=[];et.forEach(e=>{if(e.evaluation){var r,t,s,a;(null==(r=e.evaluation.fluency_and_coherence)?void 0:r.band_score)&&n.push(e.evaluation.fluency_and_coherence.band_score),(null==(t=e.evaluation.lexical_resource)?void 0:t.band_score)&&o.push(e.evaluation.lexical_resource.band_score),(null==(s=e.evaluation.grammatical_range_and_accuracy)?void 0:s.band_score)&&l.push(e.evaluation.grammatical_range_and_accuracy.band_score),(null==(a=e.evaluation.pronunciation)?void 0:a.band_score)&&i.push(e.evaluation.pronunciation.band_score)}});let d={fluency:n.length>0?n.reduce((e,r)=>e+r,0)/n.length:0,lexical:o.length>0?o.reduce((e,r)=>e+r,0)/o.length:0,grammar:l.length>0?l.reduce((e,r)=>e+r,0)/l.length:0,pronunciation:i.length>0?i.reduce((e,r)=>e+r,0)/i.length:0};return{totalQuestions:e,averageScore:Math.round(10*t)/10,bestScore:s,latestScore:a,averageByCategory:{fluency:Math.round(10*d.fluency)/10,lexical:Math.round(10*d.lexical)/10,grammar:Math.round(10*d.grammar)/10,pronunciation:Math.round(10*d.pronunciation)/10}}},[et]),rt=(0,a.useCallback)(()=>{try{let e=sessionStorage.getItem("ielts_speaking_progress");e&&es(JSON.parse(e))}catch(e){console.error("Error loading session progress:",e)}},[]),rs=(0,a.useCallback)(function(e,r,t){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a="practice"===e?J.lg:J.ko;if(t)return a;
1if("practice"===e){let e={part_1:3,part_2:3,part_3:4};if(0===r)return 0;let t={};s.forEach(e=>{t[e]=(t[e]||0)+1});let n={part_1:4,part_2:3,part_3:4},o=0;return Object.entries(t).forEach(r=>{let[t,s]=r,a=e[t]||3,l=n[t]||4;"part_2"===t?o+=Math.min(s,a):s>=l?o+=a:o+=Math.max(1,Math.round(s/l*a))}),Math.min(o,a)}return 0===r?0:r>=15?a:Math.max(1,Math.round(r/15*a))},[]),ra=(0,a.useCallback)(e=>{let r="practice"===e?J.lg:J.ko;return!(e1<r)||(e3(r,"practice"===e?"ielts_speaking_practice":"ielts_speaking_mock"),!1)},[e1,e3]),rn=(0,a.useCallback)(async function(e,r,t){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if(e6)return;let a=rs(e,r,t,s);a>0&&(await e5(a)).success&&e8(!0)},[e6,rs,e5]),ro=(0,a.useCallback)(async function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Celeste-PlayAI",t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;try{eN(!0),e_(!0),eR.current&&eR.current.abort();let s=new AbortController;eR.current=s;let a=await fetch("/api/ielts-speaking/question-audio",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:e,voice:r}),signal:s.signal});if(!eE.current)return eN(!1),e_(!1),!1;if(!a.ok)return eN(!1),ew(!1),e_(!1),!1;{let e=await a.blob();if(!eE.current)return eN(!1),e_(!1),!1;let r=URL.createObjectURL(e),s=new Audio(r);return eC.current=s,s.addEventListener("loadeddata",()=>{eE.current&&s.play()}),s.addEventListener("play",()=>{ew(!0)}),s.addEventListener("ended",()=>{URL.revokeObjectURL(r),eE.current&&(eN(!1),ew(!1),e_(!1),eS(!0),t&&t())}),s.addEventListener("error",()=>{URL.revokeObjectURL(r),eN(!1),ew(!1),e_(!1)}),!0}}catch(e){return eN(!1),ew(!1),e_(!1),!1}},[]),rl=(0,a.useCallback)(()=>{("practice"===g||"mock_interview"===g)&&eA&&!eH&&(eP.current=setTimeout(()=>{eK(),eS(!1)},1500))},[g,eA,eH,eK]);(0,a.useEffect)(()=>(rl(),()=>{eP.current&&clearTimeout(eP.current)}),[rl]),(0,a.useEffect)(()=>{("practice"===g||"mock_interview"===g)&&!eH&&eQ&&setTimeout(()=>{rp()},500)},[eH,eQ,g]);let ri=(0,a.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(eC.current){try{eC.current.pause(),eC.current.currentTime=0,eC.current.src="",eC.current.load(),eC.current.remove()}catch(e){}eC.current=null}if(e)try{document.querySelectorAll("audio").forEach(e=>{e.pause(),e.currentTime=0,e.src="",e.load()})}catch(e){}if(eP.current&&(clearTimeout(eP.current),eP.current=null),eL.current&&(eL.current.getTracks().forEach(e=>{e.stop()}),eL.current=null),e){try{e0()}catch(e){}if(eQ)try{URL.revokeObjectURL(eQ)}catch(e){}try{eZ()}catch(e){}}eN(!1),ew(!1),e_(!1),eS(!1)},[e0,eQ,eZ]);(0,a.useEffect)(()=>{eD(),eI(A),rt();let e=document.body.style.overflow;document.body.style.overflow="hidden auto",document.body.style.paddingRight="0px";let r=e=>{ri(!0)},t=()=>{document.hidden&&ri(!0)},s=()=>{ri(!0)},a=()=>{ri(!0)};return window.addEventListener("beforeunload",r),window.addEventListener("unload",a),window.addEventListener("pagehide",s),document.addEventListener("visibilitychange",t),()=>{document.body.style.overflow=e,window.removeEventListener("beforeunload",r),window.removeEventListener("unload",a),window.removeEventListener("pagehide",s),document.removeEventListener("visibilitychange",t),ri()}},[ri]),(0,a.useEffect)(()=>{A&&(E(""),eI(A))},[A]),(0,a.useEffect)(()=>{eF.length>0&&E(eF[0])},[eF]),(0,a.useEffect)(()=>{P.length>0&&setTimeout(()=>{re()},300)},[P.length,re]),(0,a.useEffect)(()=>{"practice"===g&&et.length>=5&&!ea&&(en(!0),G(null),q("Practice session completed! Here are your comprehensive results."),setTimeout(()=>q(""),5e3))},[et.length,ea,g]);let rd=(0,a.useCallback)(()=>{eo||ei||(y("practice"),j(!0))},[eo,ei]),rc=(0,a.useCallback)(()=>{eo||ei||(y("mock"),j(!0))},[eo,ei]),ru=(0,a.useCallback)(async e=>{if(!eo&&!ei&&ra("practice")){j(!1),S(e.part),E(e.topic),R(e.voice),b("practice"),ed(!0),el(!0),eT.current=!1,eE.current=!0,e4(0),e8(!1),e7([]);try{await Z();let r=await eB(e.part,e.topic);if(null==r?void 0:r.question)G(r),rb("system","Practice session started. Listen to the question and record your answer."),rb("question",r.question,{part:r.part_type,topic:r.topic,timeLimit:r.time_limit}),setTimeout(()=>{ro(r.question,e.voice||T,()=>{eS(!0)})},500);else throw Error("No speaking question received")}catch(e){eE.current=!1,b(null),el(!1),G(null),j(!0),F("Could not start the practice session. Please try again.")}finally{ed(!1)}}},[eo,ei,eB,ra,ro,T]),rm=(0,a.useCallback)(async r=>{if(!eo&&!ei&&(e||ra("mock"))){j(!1),R(r.voice),b("mock_interview"),ed(!0),el(!0),eT.current=!1,eE.current=!0,e4(0),e8(!1),ex([]),ep(!1),eg(null),ev("part_
11");try{await Z();let e=await eU(r.voice);if(null==e?void 0:e.question){let t=e.question;eu(e.task_id),ev(t.part_type||"part_1"),G(t),rb("system",e.message||"Mock test started. Listen to the question and record your answer."),rb("question",t.question,{part:t.part_type,topic:t.topic,timeLimit:t.time_limit}),setTimeout(()=>{ro(t.question,r.voice||T,()=>{eS(!0)})},500)}else throw Error("No question received from mock test")}catch(e){eE.current=!1,b(null),el(!1),G(null),j(!0),F("Could not start the mock interview. Please try again.")}finally{ed(!1)}}},[eo,ei,e,eU,ra,ro,T]),rx=(0,a.useRef)(!1);(0,a.useEffect)(()=>{e&&!rx.current&&(rx.current=!0,rm({voice:"aura-2-aurora-en"}))},[e]);let rh=async(e,t)=>{if(eT.current)return null;eT.current=!0;try{let s=await fetch("/api/ielts/history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({testType:"speaking",serviceTestId:"mock_".concat(Date.now()),testHistory:{...e,questionsAnswered:t.length,sessionData:t,completedAt:new Date().toISOString(),metadata:{mode:"mock_interview",...r?{fullMockSessionId:r}:{}}}})}),a=await s.json();return a.success?a.id:null}catch(e){return console.error("Error saving mock interview result:",e),null}},rp=async()=>{if(!eQ||!U)return void console.error("Missing required data:",{hasAudio:!!eQ,hasQuestion:!!U});F(""),q("");try{if("practice"===g){let e=eY>0?eY:eV||60,t=await eO(eQ,U.question,e);if(t){var r;let s=function(e,r){if(!e||!r||r<=0)return{speechRate:0,wordCount:0,fillerCount:0,discourseMarkers:0,durationSeconds:0};let t=e.trim().split(/\s+/).filter(e=>e.length>0),s=t.length,a=r/60,n=a>0?Math.round(s/a):0,o=t.map(e=>e.toLowerCase().replace(/[^a-z]/g,"")).filter(e=>ee.has(e)).length,l=e.toLowerCase();return{speechRate:n,wordCount:s,fillerCount:o,discourseMarkers:er.reduce((e,r)=>e+(l.split(r).length-1),0),durationSeconds:r}}(t.transcription,e),a=t.fluency_and_coherence||{},n={...t,fluency_and_coherence:{...a,speech_rate:a.speech_rate&&a.speech_rate>0?a.speech_rate:s.speechRate,word_count:s.wordCount,filler_count:s.fillerCount,discourse_markers:null!=(r=a.discourse_markers)?r:s.discourseMarkers,duration_seconds:Math.round(e)}};K(n),rb("answer",t.transcription,{evaluation:t,audioBlob:eQ}),rg(t),eZ(),G(null),setTimeout(async()=>{if(!ea&&et.length<5){ed(!0);let e=await eB(A,C);e&&(G(e),rb("question",e.question,{part:e.part_type,topic:e.topic,timeLimit:e.time_limit}),setTimeout(()=>{ro(e.question,T,()=>{eS(!0)})},500)),ed(!1)}},2e3)}else F("Failed to evaluate your answer. Please check your audio quality and try again.")}else if("mock_interview"===g){q("Processing your answer...");let r=await e$(eQ);if(!r)return void F("Failed to transcribe your audio. Please try recording again.");rb("answer",r,{audioBlob:eQ});let s={question:U.question,answer:r,part_type:U.part_type,topic:U.topic,audio_duration:eY>0?eY:eV||60},a=[...em,s];ex(a),eZ();let n=a.length;if(e4(n),a.length>=15){e||e6||await rn("mock",15,!0);let r=await eG(ec,a);if(r){eg(r.evaluation),ep(!0),G(null),rb("system",r.message||"Mock test completed! Here are your results.");let s=await rh(r.evaluation,a);e?null==t||t(s):(k(!0),q("Mock test completed! Here are your results."))}}else{let e=await ez(ec,r,a,eb);e&&e.question&&(e.question.part_type!==eb&&(ev(e.question.part_type),rb("system","Moving to ".concat({part_1:"Part 1",part_2:"Part 2",part_3:"Part 3"}[e.question.part_type]))),G(e.question),rb("question",e.question.question,{part:e.question.part_type,topic:e.question.topic,timeLimit:e.question.time_limit}),setTimeout(()=>{ro(e.question.question,T,()=>{eS(!0)})},500))}q("")}}catch(e){F("Network error. Please check your connection and try again."),q("")}},rf=async()=>{if(!eo)return;eE.current=!1,eR.current&&(eR.current.abort(),eR.current=null);let r="practice"===g?"practice":"mock",s="practice"===g?et.length:em.length,a="practice"===g?e9:[],n=!e6&&g;if(eC.current){try{eC.current.muted=!0,eC.current.volume=0,eC.current.pause(),eC.current.currentTime=0,eC.current.src="",eC.current.load()}catch(e){console.warn("Error stopping current audio:",e)}eC.current=null}
1try{document.querySelectorAll("audio").forEach(e=>{e.pause(),e.currentTime=0,e.src="",e.load(),e.muted=!0})}catch(e){console.warn("Error stopping all audio elements:",e)}eN(!1),ew(!1),e_(!1),eS(!1),eH&&eX(),ri(!0),ed(!1),G(null);try{if(D(!0),F(""),q("Processing final evaluation..."),"practice"===g){if(en(!0),G(null),q("Practice session completed! Here are your results."),0===et.length)K({overall_band_score:0,fluency_and_coherence:{band_score:0,speech_rate:0,pause_count:0,discourse_markers:0,feedback:"No responses recorded."},lexical_resource:{band_score:0,type_token_ratio:0,advanced_words:0,repeated_words:0,feedback:"No responses recorded."},grammatical_range_and_accuracy:{band_score:0,error_count:0,complex_sentence_ratio:0,avg_sentence_length:0,feedback:"No responses recorded."},pronunciation:{band_score:0,avg_confidence:0,feedback:"No responses recorded."},detailed_feedback:{strengths:[],areas_for_improvement:["Complete at least one question to receive a score."]},transcription:""}),k(!0);else if(et.length>0){let e=et.map(e=>e.overallScore),r=e.reduce((e,r)=>e+r,0)/e.length,t=[],s=[],a=[],n=[];et.forEach(e=>{if(e.evaluation){var r,o,l,i;(null==(r=e.evaluation.fluency_and_coherence)?void 0:r.band_score)&&t.push(e.evaluation.fluency_and_coherence.band_score),(null==(o=e.evaluation.lexical_resource)?void 0:o.band_score)&&s.push(e.evaluation.lexical_resource.band_score),(null==(l=e.evaluation.grammatical_range_and_accuracy)?void 0:l.band_score)&&a.push(e.evaluation.grammatical_range_and_accuracy.band_score),(null==(i=e.evaluation.pronunciation)?void 0:i.band_score)&&n.push(e.evaluation.pronunciation.band_score)}});let o=e=>e.length>0?e.reduce((e,r)=>e+r,0)/e.length:0;if(eT.current)return;eT.current=!0;try{let e=await fetch("/api/ielts/history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({testType:"speaking",serviceTestId:"practice_".concat(Date.now()),testHistory:{overall_band_score:parseFloat(r.toFixed(1)),fluency_and_coherence:parseFloat(o(t).toFixed(1)),lexical_resource:parseFloat(o(s).toFixed(1)),grammatical_range_and_accuracy:parseFloat(o(a).toFixed(1)),pronunciation:parseFloat(o(n).toFixed(1)),questionsAnswered:et.length,sessionData:et,completedAt:new Date().toISOString(),metadata:{mode:"practice",topic:C,parts:[...new Set(et.map(e=>e.partType))]}}})});await e.json()}catch(e){}}k(!0)}else if("mock_interview"===g&&ec){let r=await eG(ec,em);if(r){eg(r.evaluation),ep(!0),G(null),rb("system",r.message||"Mock test completed!");let s=await rh(r.evaluation,em);e?null==t||t(s):(k(!0),q("Mock test completed! Here are your results."))}else F("Failed to complete mock test. Please try again.")}n&&!e&&("practice"===r?await rn(r,s,!1,a):await rn(r,s,s>=15))}catch(e){console.error("Error ending session:",e),F("Failed to complete the session. Please try again.")}finally{D(!1),setTimeout(()=>q(""),3e3)}},rg=(0,a.useCallback)(e=>{let r={id:Date.now(),timestamp:new Date().toISOString(),partType:A,topic:C,question:null==U?void 0:U.question,transcript:e.transcription,evaluation:e,overallScore:e.overall_band_score};es(e=>{let t=[...e,r];try{sessionStorage.setItem("ielts_speaking_progress",JSON.stringify(t))}catch(e){console.error("Error saving session progress:",e)}return e4(t.length),"practice"===g&&e7(t.map(e=>e.partType)),t})},[A,C,U,g,e6,ea,rn]),rb=function(e,r){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s={type:e,content:r,timestamp:Date.now(),...t};L(e=>[...e,s])},rv=()=>{ri(),L([]),K(null),G(null),en(!1),el(!1),ed(!1),eu(null),ex([]),ep(!1),eg(null),ev("part_1"),e4(0),e8(!1),e7([]),b(null),j(!1),k(!1),D(!1),O(!1)},rj=async()=>{let e="practice"===g?"practice":"mock",r="practice"===g?et.length:em.length,t="practice"===g?e9:[],s=!e6&&g&&eo;try{if(O(!0),q("\uD83D\uDD04 Starting new session..."),k(!1),j(!1),eC.current){try{eC.current.pause(),eC.current.currentTime=0,eC.current.src="",eC.current.load(),eC.current.remove&&eC.current.remove()}catch(e){console.warn("Error stopping current audio:",e)}eC.current=null}try{document.querySelectorAll("audio").forEach(e=>{e.pause(),e.currentTime=0,e.src="",e.load(),e.muted=!0}
1)}catch(e){console.warn("Error stopping all audio elements:",e)}if(eN(!1),ew(!1),e_(!1),eS(!1),ri(!0),"practice"===e&&et.length>0){let e=et.map(e=>e.overallScore),r=e.reduce((e,r)=>e+r,0)/e.length,t=[],s=[],a=[],n=[];et.forEach(e=>{if(e.evaluation){var r,o,l,i;(null==(r=e.evaluation.fluency_and_coherence)?void 0:r.band_score)&&t.push(e.evaluation.fluency_and_coherence.band_score),(null==(o=e.evaluation.lexical_resource)?void 0:o.band_score)&&s.push(e.evaluation.lexical_resource.band_score),(null==(l=e.evaluation.grammatical_range_and_accuracy)?void 0:l.band_score)&&a.push(e.evaluation.grammatical_range_and_accuracy.band_score),(null==(i=e.evaluation.pronunciation)?void 0:i.band_score)&&n.push(e.evaluation.pronunciation.band_score)}});let o=e=>e.length>0?e.reduce((e,r)=>e+r,0)/e.length:0;if(eT.current)return;eT.current=!0;try{let e=await fetch("/api/ielts/history",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({testType:"speaking",serviceTestId:"practice_".concat(Date.now()),testHistory:{overall_band_score:parseFloat(r.toFixed(1)),fluency_and_coherence:parseFloat(o(t).toFixed(1)),lexical_resource:parseFloat(o(s).toFixed(1)),grammatical_range_and_accuracy:parseFloat(o(a).toFixed(1)),pronunciation:parseFloat(o(n).toFixed(1)),questionsAnswered:et.length,sessionData:et,completedAt:new Date().toISOString(),metadata:{mode:"practice",topic:C,parts:[...new Set(et.map(e=>e.partType))]}}})});(await e.json()).success}catch(e){}}s&&("practice"===e?await rn(e,r,!1,t):await rn(e,r,r>=15)),rv(),es([]);try{sessionStorage.removeItem("ielts_speaking_progress")}catch(e){}await new Promise(e=>setTimeout(e,1500))}catch(e){console.error("Error starting new session:",e),F("Failed to start new session. Please refresh the page.")}finally{O(!1),setTimeout(()=>q(""),3e3)}},rN=rr();return g?(0,s.jsx)("div",{className:"h-full bg-background lg:bg-muted/20 lg:px-14 lg:py-4",children:(0,s.jsxs)("div",{className:"h-full bg-background text-foreground flex flex-col overflow-hidden lg:rounded-xl lg:border lg:border-border lg:shadow-sm",children:[(0,s.jsxs)("div",{className:"flex flex-col lg:hidden",style:{height:"calc(100dvh - 56px)"},children:[(0,s.jsxs)("header",{className:"flex items-center justify-between border-b border-border bg-card/60 px-4 py-3 backdrop-blur-sm",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-bold text-foreground",children:"IELTS Speaking"}),(0,s.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:U?"".concat("part_1"===U.part_type?"Part 1":"part_2"===U.part_type?"Part 2":"Part 3").concat(U.topic?" \xb7 ".concat(U.topic):""):"practice"===g?"Practice Mode":"Mock Interview"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[eo&&!ea&&!eh&&!eq&&(0,s.jsx)(n.$,{onClick:rf,disabled:I,variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive","aria-label":"End session",children:I?(0,s.jsx)(l.A,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(i.A,{className:"h-4 w-4"})}),(0,s.jsx)(n.$,{onClick:rj,disabled:eq||I||B,variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground","aria-label":"New session",children:(0,s.jsx)(l.A,{className:"h-4 w-4 ".concat(B?"animate-spin":"")})})]})]}),W&&(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-destructive/20 bg-destructive/10 px-4 py-2",children:[(0,s.jsx)("span",{className:"line-clamp-2 text-xs text-destructive",children:W}),(0,s.jsx)("button",{onClick:()=>F(""),"aria-label":"Dismiss error",children:(0,s.jsx)(i.A,{className:"h-4 w-4 text-destructive"})})]}),(0,s.jsxs)("main",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex flex-1 min-h-0 flex-col items-center px-4 pt-3 pb-2 text-center overflow-y-auto",children:[(0,s.jsxs)("div",{className:"relative mb-2 flex-shrink-0 flex h-36 w-36 items-center justify-center",children:[(ey||eH||eq||ei)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"absolute inset-0 rounded-full bg-foreground
1/10 animate-ping"}),(0,s.jsx)("div",{className:"absolute inset-5 rounded-full bg-foreground/10 animate-pulse"})]}),(0,s.jsx)("div",{className:"relative flex h-36 w-36 items-center justify-center",children:(0,s.jsx)(X,{active:ey||eH||eq||ei,size:144})}),(0,s.jsx)("div",{className:"absolute bottom-2 rounded-full border border-border bg-card px-3 py-1 text-[10px] font-semibold text-foreground shadow-sm",children:ey?"Speaking":eH?"Listening":eq?"Thinking":ek?"Preparing":"Ready"})]}),(0,s.jsx)("div",{className:"mb-2 flex h-8 items-center justify-center gap-1 flex-shrink-0",children:Array.from({length:15}).map((e,r)=>{let t=ey||eH||eq||ei;return(0,s.jsx)("span",{className:"w-1.5 rounded-full ".concat(t?"bg-foreground":"bg-border"),style:{height:"".concat([20,36,54,30,68,42,76,48,62,34,58,40,70,32,50][r],"%"),animation:t?"waveAnimation 1s ease-in-out infinite ".concat(.05*r,"s"):"none",transformOrigin:"center"}},r)})}),(0,s.jsxs)("div",{className:"w-full max-w-sm flex flex-col",children:[U?(0,s.jsxs)("div",{className:"rounded-2xl border border-border bg-card/60 p-3 text-left backdrop-blur-sm",children:[(0,s.jsx)("p",{className:"mb-1 text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:"Current question"}),(0,s.jsx)("p",{className:"text-sm font-semibold leading-snug text-foreground",children:U.question}),U.topic&&(0,s.jsxs)("p",{className:"mt-3 border-t border-border pt-3 text-xs text-muted-foreground",children:["Topic: ",(0,s.jsx)("span",{className:"font-semibold text-foreground",children:U.topic})]})]}):(0,s.jsxs)("div",{className:"rounded-2xl border border-border bg-card/60 p-4 backdrop-blur-sm",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground",children:ei?"Generating your next question...":"Waiting for the examiner"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Keep your microphone ready."})]}),(eq||"practice"===g&&eo&&!U&&!ea&&ei)&&(0,s.jsxs)("div",{className:"mt-3 inline-flex items-center gap-2 rounded-full border border-border bg-muted/30 px-3 py-1.5 text-xs text-foreground",children:[(0,s.jsx)(l.A,{className:"h-3.5 w-3.5 animate-spin"}),"mock_interview"===g?"Processing response...":eq?"Evaluating your answer...":"Generating next question..."]})]})]}),(0,s.jsx)("div",{className:"flex-shrink-0 border-t border-border bg-card/80 px-4 py-2 backdrop-blur-sm",children:!U||ea||eh?(0,s.jsxs)("div",{className:"mx-auto flex max-w-sm gap-2",children:[(0,s.jsx)(n.$,{onClick:()=>k(!0),className:"h-11 flex-1 bg-foreground text-background hover:bg-foreground
1/90",children:"View Results"}),(0,s.jsx)(n.$,{onClick:rj,disabled:B,variant:"outline",className:"h-11 flex-1 border-border",children:"New Session"})]}):(0,s.jsxs)("div",{className:"mx-auto flex max-w-sm flex-col items-center gap-1.5",children:[(0,s.jsxs)("div",{className:"text-center",children:[eH&&(0,s.jsxs)("p",{className:"text-xs font-bold text-destructive",children:[(0,s.jsx)("span",{className:"mr-1 inline-block h-2 w-2 rounded-full bg-destructive animate-pulse"}),"Recording your answer"]}),eQ&&!eH&&!eq&&(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Answer recorded. Submit when ready."}),!eH&&!eQ&&!eq&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Tap the microphone when you are ready to answer."})]}),!eH&&!eQ&&!eq&&(0,s.jsx)(n.$,{onClick:async()=>{await eK()||F("Failed to start recording. Please check your microphone permissions.")},className:"h-14 w-14 rounded-full bg-foreground text-background hover:bg-foreground/90","aria-label":"Start recording",children:(0,s.jsx)(d.A,{className:"h-6 w-6"})}),eH&&(0,s.jsx)(n.$,{onClick:()=>{eX()},className:"h-14 w-14 rounded-full bg-destructive text-destructive-foreground hover:bg-destructive/90","aria-label":"Stop recording",children:(0,s.jsx)(c.A,{className:"h-6 w-6"})}),eQ&&!eH&&"mock_interview"!==g&&!eq&&(0,s.jsxs)("div",{className:"grid w-full grid-cols-2 gap-2",children:[(0,s.jsxs)(n.$,{onClick:async()=>{await eK()},variant:"outline",className:"h-11 border-border",children:[(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4"}),"Re-record"]}),(0,s.jsxs)(n.$,{onClick:rp,className:"h-11 bg-foreground text-background hover:bg-foreground
1/90",children:[(0,s.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Submit"]})]}),"mock_interview"===g&&eQ&&!eq&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)(l.A,{className:"h-3.5 w-3.5 animate-spin"}),"Processing automatically..."]}),eJ&&(0,s.jsx)("p",{className:"text-center text-xs text-destructive",children:eJ})]})})]})]}),(0,s.jsxs)("div",{className:"hidden h-full flex-col overflow-hidden lg:flex",children:[(0,s.jsxs)("header",{className:"flex-shrink-0 bg-card border-b border-border",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 md:px-6 h-12",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded bg-foreground flex items-center justify-center flex-shrink-0",children:(0,s.jsx)(d.A,{className:"w-3.5 h-3.5 text-background",strokeWidth:1.5})}),(0,s.jsx)("span",{className:"text-sm font-bold text-foreground tracking-tight hidden sm:block",children:"IELTS Speaking"})]}),(0,s.jsx)("div",{className:"h-4 w-px bg-border hidden sm:block"}),U&&(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"text-xs font-semibold text-foreground bg-muted border border-border px-2 py-0.5 rounded",children:["part_1"===U.part_type&&"Part 1","part_2"===U.part_type&&"Part 2","part_3"===U.part_type&&"Part 3"]}),U.topic&&(0,s.jsxs)("span",{className:"text-xs text-muted-foreground hidden md:block",children:["Topic: ",(0,s.jsx)("span",{className:"text-foreground font-medium",children:U.topic})]})]}),!U&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground hidden sm:block",children:"practice"===g?"Practice Mode":"Mock Interview"})]}),et.length>0&&(0,s.jsxs)("div",{className:"hidden md:flex items-center gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"font-bold text-foreground",children:rN.totalQuestions}),(0,s.jsx)("span",{children:"answered"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"font-bold text-foreground",children:rN.averageScore}),(0,s.jsx)("span",{children:"avg band"})]}),rN.bestScore>0&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"font-bold text-foreground",children:rN.bestScore}),(0,s.jsx)("span",{children:"best"})]}),ea&&(0,s.jsx)(o.E,{variant:"outline",className:"text-[10px] border-border text-foreground",children:"Complete"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[W&&(0,s.jsxs)("div",{className:"hidden sm:flex items-center gap-1.5 bg-destructive/10 border border-destructive/20 rounded px-2 py-1",children:[(0,s.jsx)("div",{className:"w-1.5 h-1.5 bg-destructive rounded-full flex-shrink-0"}),(0,s.jsx)("span",{className:"text-xs text-destructive line-clamp-1 max-w-[200px]",children:W}),(0,s.jsx)("button",{onClick:()=>F(""),className:"text-destructive/70 hover:text-destructive ml-1",children:(0,s.jsx)(i.A,{className:"w-3 h-3",strokeWidth:1.5})})]}),eo&&!ea&&!eh&&!eq&&(0,s.jsxs)(n.$,{onClick:rf,disabled:I,variant:"outline",className:"h-7 px-3 text-xs border-border text-muted-foreground hover:text-destructive hover:border-destructive/50",children:[I?(0,s.jsx)(l.A,{className:"w-3 h-3 animate-spin",strokeWidth:1.5}):(0,s.jsx)(i.A,{className:"w-3 h-3 mr-1",strokeWidth:1.5}),(0,s.jsx)("span",{className:"hidden sm:inline",children:I?"Ending...":"End Session"})]}),(0,s.jsxs)(n.$,{onClick:rj,disabled:eq||I||B,variant:"ghost",className:"h-7 px-3 text-xs text-muted-foreground",children:[(0,s.jsx)(l.A,{className:"w-3 h-3 mr-1 ".concat(B?"animate-spin":""),strokeWidth:1.5}),(0,s.jsx)("span",{className:"hidden sm:inline",children:B?"Starting...":"New Session"})]})]})]}),W&&(0,s.jsxs)("div",{className:"sm:hidden flex items-center justify-between bg-destructive/10 border-t border-destructive/20 px-4 py-1.5",children:[(0,s.jsx)("span",{className:"text-xs text-destructive",children:W}),(0,s.jsx)("button",{onClick:()=>F(""),children:(0,s.jsx)(i.A,{className:"w-3 h-3 text-destructive"})})]})]}),(0,s.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,s.jsxs)("div",{className:"w-[42%] flex-shrink-0 border-r border-border flex flex-col overflow-hidden bg-card",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[(0,s.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-full overflow-hidden border border-border",children:(0,s.jsx)(X,{active:ey||eH||eq||ei,size:40})}),ey&&(0,s.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-foreground border-2 border-card rounded-full animate-pulse"})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-bold text-foreground",children:"AI Examiner"}),(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground truncate",children:ey?"Speaking now...":ek?"Preparing audio...":"Listening"})]}),ey&&(0,s.jsx)("div",{className:"flex items-end gap-0.5 h-5 flex-shrink-0",children:[3,5,4,6,3,5,4].map((e,r)=>(0,s.jsx)("div",{className:"w-1 bg-foreground rounded-full",style:{height:"".concat(3*e,"px"),animation:"waveAnimation 0.8s ease-in-out infinite ".concat(.1*r,"s")}},r))})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:rounded-full",children:U?(0,s.jsxs)("div",{className:"p-4 space-y-4",children:[(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsxs)("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-widest",children:["part_1"===U.part_type&&"PART 1 â Introduction & Interview","part_2"===U.part_type&&"PART 2 â Individual Long Turn","part_3"===U.part_type&&"PART 3 â Two-way Discussion"]})}),(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-background p-4",children:[(0,s.jsx)("p",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-widest mb-3",children:"Question"}),(0,s.jsx)("p",{className:"text-sm leading-relaxed text-foreground font-medium",children:U.question}),U.topic&&(0,s.jsx)("div",{className:"mt-3 pt-3 border-t border-border",children:(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["Topic: ",(0,s.jsx)("span",{className:"text-foreground font-semibold",children:U.topic})]})})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-background p-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(u.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0",strokeWidth:1.5}),(0,s.jsx)("span",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wider",children:ey?"Playing":ek?"Loading":"Audio"})]}),(0,s.jsx)("div",{className:"flex items-center justify-center h-10 gap-0.5",children:ek&&!ey?(0,s.jsx)("div",{className:"w-4 h-4 border-2 border-border border-t-foreground rounded-full animate-spin"}):Array.from({length:28}).map((e,r)=>(0,s.jsx)("div",{className:"w-1 rounded-full transition-colors ".concat(ey?"bg-foreground":"bg-border"),style:{height:"".concat([35,55,30,75,45,85,40,95,60,45,80,30,100,50,70,40,90,55,50,85,35,75,45,90,60,40,80,50][r]||45,"%"),animation:ey?"waveAnimation 1.2s ease-in-out infinite ".concat(.04*r,"s"):"none",transformOrigin:"bottom"}},r))}),(0,s.jsx)("p",{className:"text-center text-[10px] text-muted-foreground mt-1.5",children:ey?"Examiner speaking â listen carefully":ek?"Generating question audio...":eA&&!eH?"Recording begins in 1.5 s...":"Audio ready"})]})]}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full p-6 text-center",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-full bg-muted border border-border flex items-center justify-center mb-3",children:ei?(0,s.jsx)(l.A,{className:"w-5 h-5 text-foreground animate-spin",strokeWidth:1.5}):(0,s.jsx)(d.A,{className:"w-5 h-5 text-muted-foreground",strokeWidth:1.5})}),(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground mb-1",children:ei?"Generating question...":"Waiting for question"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"The examiner will ask a question shortly"})]})})]}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden bg-background",children:[U&&!ea&&!eh&&(0,s.jsxs)("div",{className:"flex-shrink-0 border-b border-border bg-card px-4 py-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-widest",children:"Your Response"}),eH&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-bold text-destructive",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 bg-destructive rounded-full animate-pulse"}),"REC"]}),eQ&&!eH&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-bold text-foreground",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 bg-foreground rounded-full"}),"RECORDED"]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[eq&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,s.jsx)(l.A,{className:"w-3 h-3 animate-spin",strokeWidth:1.5}),(0,s.jsx)("span",{children:"Evaluating..."})]}),!eH&&!eQ&&!eq&&(0,s.jsxs)(n.$,{onClick:async()=>{await eK()||F("Failed to start recording. Please check your microphone permissions.")}
1,className:"h-7 px-3 text-xs bg-foreground hover:bg-foreground/90 text-background gap-1.5",children:[(0,s.jsx)(d.A,{className:"w-3 h-3",strokeWidth:1.5}),"Start Recording"]}),eH&&(0,s.jsxs)(n.$,{onClick:()=>{eX()},className:"h-7 px-3 text-xs bg-destructive hover:bg-destructive/90 text-destructive-foreground gap-1.5",children:[(0,s.jsx)(c.A,{className:"w-3 h-3",strokeWidth:1.5}),"Stop & Submit"]}),eQ&&!eH&&"mock_interview"!==g&&!eq&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(n.$,{onClick:async()=>{await eK()},variant:"outline",className:"h-7 px-3 text-xs border-border",children:[(0,s.jsx)(d.A,{className:"w-3 h-3 mr-1",strokeWidth:1.5}),"Re-record"]}),(0,s.jsxs)(n.$,{onClick:rp,className:"h-7 px-3 text-xs bg-foreground hover:bg-foreground/90 text-background gap-1.5",children:[(0,s.jsx)(c.A,{className:"w-3 h-3",strokeWidth:1.5}),"Submit"]})]}),"mock_interview"===g&&eQ&&!eq&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,s.jsx)(l.A,{className:"w-3 h-3 animate-spin",strokeWidth:1.5}),(0,s.jsx)("span",{children:"Processing..."})]})]})]}),(0,s.jsx)("div",{className:"flex items-center justify-center h-8 gap-0.5",children:eJ?(0,s.jsx)("p",{className:"text-xs text-destructive",children:eJ}):Array.from({length:40}).map((e,r)=>(0,s.jsx)("div",{className:"w-1 rounded-full ".concat(eH?"bg-destructive":eQ?"bg-foreground":"bg-border"),style:{height:"".concat(70*Math.random()+20,"%"),animation:eH?"pulse 0.".concat(r%5+3,"s ease-in-out infinite"):"none"}},r))})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:rounded-full",children:["practice"===g&&eo&&!U&&!ea&&ei&&(0,s.jsx)("div",{className:"flex justify-center py-3",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-muted/30 border border-border rounded-full px-4 py-1.5",children:[(0,s.jsx)(l.A,{className:"w-3.5 h-3.5 text-foreground animate-spin",strokeWidth:1.5}),(0,s.jsx)("span",{className:"text-xs text-foreground",children:"Generating next question..."})]})}),eq&&(0,s.jsx)("div",{className:"flex justify-center py-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-muted/30 border border-border rounded-full px-4 py-2",children:[(0,s.jsx)(l.A,{className:"w-3.5 h-3.5 text-foreground animate-spin",strokeWidth:1.5}),(0,s.jsx)("span",{className:"text-xs text-foreground",children:"mock_interview"===g?"Processing response...":"Evaluating your answer..."})]})}),P.length>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 py-1",children:[(0,s.jsx)("div",{className:"h-px flex-1 bg-border"}),(0,s.jsx)("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:"Session Log"}),(0,s.jsx)("div",{className:"h-px flex-1 bg-border"})]}),P.map((e,r)=>{var t,a,o;return(0,s.jsxs)("div",{children:["system"===e.type&&(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground bg-muted border border-border px-3 py-1 rounded-full",children:e.content})}),"question"===e.type&&(0,s.jsxs)("div",{className:"flex gap-2.5",children:[(0,s.jsx)("div",{className:"w-6 h-6 rounded bg-foreground flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,s.jsx)(m.A,{className:"w-3 h-3 text-background",strokeWidth:1.5})}),(0,s.jsxs)("div",{className:"flex-1 bg-card rounded-lg border border-border p-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-bold text-foreground",children:"Examiner"}),(0,s.jsxs)("span",{className:"text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:["part_1"===e.part&&"Part 1","part_2"===e.part&&"Part 2","part_3"===e.part&&"Part 3"]})]}),(0,s.jsx)("p",{className:"text-xs text-foreground leading-relaxed",children:e.content}),e.topic&&(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground mt-1",children:["Topic: ",e.topic]})]})]}),"answer"===e.type&&(0,s.jsxs)("div",{className:"flex gap-2.5 flex-row-reverse",children:[(0,s.jsx)("div",{className:"w-6 h-6 rounded bg-muted border border-border flex items-center justify-center flex-shrink-0 mt-0.5",children:(0,s.jsx)(x.A,{className:"w-3 h-3 text-foreground",strokeWidth:1.5})}),(0,s.jsxs)("div",{className:"flex-1 bg-muted/30 rounded-lg border border-border p-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("span",{className:"text-xs font-bold text-foreground",children:"You"}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[e.evaluation&&(0,s.jsxs)("span",{className:"text-[10px] font-bold text-foreground bg-muted border border-border px-1.5 py-0.5 rounded",children:["Band ",e.evaluation.overall_band_score]}),e.audioBlob&&(0,s.jsx)(n.$,{onClick:()=>{let r=URL.createObjectURL(e.audioBlob),t=new Audio(r);t.play(),t.addEventListener("ended",()=>URL.revokeObjectURL(r))},variant:"ghost",size:"sm",className:"h-5 w-5 p-0 hover:bg-muted",children:(0,s.jsx)(h.A,{className:"w-3 h-3",strokeWidth:1.5})})]})]}),(0,s.jsxs)("p",{className:"text-xs text-foreground leading-relaxed italic",children:['"',e.content,'"']}),(null==(o=e.evaluation)||null==(a=o.detailed_feedback)||null==(t=a.areas_for_improvement)?void 0:t[0])&&(0,s.jsxs)("p",{className:"text-[10px] text-muted-foreground mt-1.5 leading-relaxed",children:[(0,s.jsx)("span",{className:"font-semibold text-foreground",children:"Tip:"})," ",e.evaluation.detailed_feedback.areas_for_improvement[0]]})]})]})]},r)}),(0,s.jsx)("div",{ref:eW})]}):!eq&&!ei&&(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-center py-12",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-full bg-muted border border-border flex items-center justify-center mb-3",children:(0,s.jsx)(m.A,{className:"w-4 h-4 text-muted-foreground",strokeWidth:1.5})}),(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground mb-1",children:"Session log is empty"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Your questions and responses will appear here"})]})]})]})]})]}),w&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-2 sm:p-4",children:(0,s.jsx)("div",{className:"bg-background rounded-2xl border border-border w-full max-w-[95vw] sm:max-w-[85vw] md:max-w-[80vw] lg:max-w-[75vw] xl:max-w-[1200px] max-h-[95vh] sm:max-h-[90vh] overflow-y-auto shadow-2xl mx-auto
1sm:mr-4 sm:ml-16 md:mr-8 md:ml-24 lg:mr-12 lg:ml-32 xl:mr-16 xl:ml-40 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:rounded-full",onClick:e=>e.stopPropagation(),children:(0,s.jsxs)("div",{className:"p-4 sm:p-6 md:p-8",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-8",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,s.jsx)("div",{className:"w-12 h-12 bg-muted border border-border rounded-xl flex items-center justify-center",children:(0,s.jsx)(p.A,{className:"w-6 h-6 text-foreground",strokeWidth:1.5})}),(0,s.jsx)("div",{className:"pt-0",children:(0,s.jsxs)("h3",{className:"text-lg font-bold text-foreground ",children:["practice"===g?"Practice Session Results":"Mock Test Results",(0,s.jsx)("p",{className:"text-base text-muted-foreground",children:"Your IELTS Speaking Evaluation"})]})})]}),(0,s.jsx)(n.$,{onClick:()=>k(!1),variant:"ghost",className:"p-2 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(i.A,{className:"w-6 h-6"})})]}),(0,s.jsxs)("div",{className:"bg-muted/30 rounded-xl p-4 sm:p-6 md:p-8 border border-border",children:["practice"===g&&$&&(0,s.jsx)(_,{evaluation:$,conversation:P}),"mock_interview"===g&&ef&&(0,s.jsx)(_,{evaluation:ef,conversation:P}),"mock_interview"===g&&!ef&&(0,s.jsxs)("div",{className:"text-center text-foreground",children:[(0,s.jsx)("p",{className:"mb-4 text-base",children:"Loading evaluation results..."}),(0,s.jsx)("div",{className:"w-8 h-8 border-2 border-border border-t-foreground rounded-full animate-spin mx-auto"})]}),"practice"===g&&!$&&(0,s.jsxs)("div",{className:"text-center text-foreground",children:[(0,s.jsx)("p",{className:"mb-4 text-base",children:"Loading evaluation results..."}),(0,s.jsx)("div",{className:"w-8 h-8 border-2 border-border border-t-foreground rounded-full animate-spin mx-auto"})]})]}),(0,s.jsxs)("div",{className:"flex justify-center mt-8 space-x-4",children:[(0,s.jsxs)(n.$,{onClick:()=>{k(!1),rv()}
1,className:"bg-foreground hover:bg-foreground/90 text-background font-bold py-2 px-4 rounded-xl text-base",children:[(0,s.jsx)(f.A,{className:"w-5 h-5 mr-2"}),"Back to Home"]}),(0,s.jsxs)(n.$,{onClick:rj,disabled:B,className:"px-4 py-2 text-base font-bold text-destructive-foreground bg-destructive hover:bg-destructive/90 disabled:opacity-50 rounded-xl",children:[(0,s.jsx)(l.A,{className:"w-5 h-5 mr-2 ".concat(B?"animate-spin":"")}),B?"Starting...":"New Session"]})]})]})})}),B&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/90 backdrop-blur-md",children:(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"w-16 h-16 bg-muted border border-border rounded-full flex items-center justify-center mx-auto mb-6",children:(0,s.jsx)(l.A,{className:"w-8 h-8 text-foreground animate-spin",strokeWidth:1.5})}),(0,s.jsx)("h3",{className:"mb-2 text-lg font-bold text-foreground",children:"Starting New Session"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Cleaning up and preparing fresh environment..."}),(0,s.jsxs)("div",{className:"flex items-center justify-center mt-4 space-x-1",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-foreground rounded-full animate-ping"}),(0,s.jsx)("div",{className:"w-2 h-2 bg-foreground rounded-full animate-ping",style:{animationDelay:"0.2s"}}),(0,s.jsx)("div",{className:"w-2 h-2 bg-foreground rounded-full animate-ping",style:{animationDelay:"0.4s"}})]})]})}),(0,s.jsx)("style",{children:"\n @keyframes waveAnimation {\n 0%, 100% { transform: scaleY(1); opacity: 0.8; }\n 50% { transform: scaleY(1.4); opacity: 1; }\n }\n @keyframes pulse {\n 0%, 100% { transform: scaleY(1); opacity: 0.8; }\n 50% { transform: scaleY(1.5); opacity: 1; }\n }\n "})]})}):e?(0,s.jsxs)("div",{className:"min-h-screen flex flex-col items-center justify-center gap-4 bg-background p-4",children:[(0,s.jsx)("div",{className:"w-6 h-6 border-2 border-foreground border-t-transparent rounded-full animate-spin"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preparing Speaking sectionâ¦"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(z,{onStart:rd,onStartMock:rc,loading:eq||eo||ei}),(0,s.jsx)(H,{isOpen:v,onClose:()=>j(!1),onStart:"mock"===N?rm:ru,mode:N,topics:eF,voices:eM,loading:eq||ei})]})};var es=t(5738),ea=t(53527);let en=e=>{let{currentPart:r,setCurrentPart:t,topics:n,selectedTopic:o,setSelectedTopic:l,voices:i,selectedVoice:d,setSelectedVoice:c,loading:u}=e,m=e=>{let r={part_1:{name:"Part 1 - Introduction & Interview",description:"4-5 minutes: Personal questions about familiar topics like home, family, work, studies",icon:(0,s.jsx)(x.A,{className:"w-4 h-4",strokeWidth:1.5}),duration:"4-5 minutes",questions:"6 questions"},part_2:{name:"Part 2 - Individual Long Turn",description:"3-4 minutes: Individual speech on a given topic with 1 minute preparation time",icon:(0,s.jsx)(ea.A,{className:"w-4 h-4",strokeWidth:1.5}),duration:"3-4 minutes",questions:"1 topic card"},part_3:{name:"Part 3 - Two-way Discussion",description:"4-5 minutes: Abstract discussion related to Part 2 topic with examiner",icon:(0,s.jsx)(A.A,{className:"w-4 h-4",strokeWidth:1.5}),duration:"4-5 minutes",questions:"5-6 questions"}};return r[e]||r.part_1},h=m(r);return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-xs font-bold text-foreground",children:[(0,s.jsx)(G.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Select IELTS Part"]}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-1.5",children:["part_1","part_2","part_3"].map(e=>{let n=m(e),o=r===e;return(0,s.jsx)("button",{onClick:()=>!u&&t(e),disabled:u,className:"p-2 rounded-lg border transition-all disabled:opacity-50 ".concat(o?"bg-foreground text-background border-foreground":"bg-muted border-border hover:border-foreground
1/30 text-foreground"),children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,s.jsx)("div",{className:o?"text-background":"text-muted-foreground",children:a.cloneElement(n.icon,{className:"w-4 h-4",strokeWidth:1.5})}),(0,s.jsxs)("span",{className:"text-xs font-bold ".concat(o?"text-background":"text-foreground"),children:["Part ",e.split("_")[1]]})]})},e)})}),(0,s.jsx)("div",{className:"p-3 border rounded-lg bg-muted/30 border-border",children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("div",{className:"mt-0.5 text-foreground",children:a.cloneElement(h.icon,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("p",{className:"text-xs font-bold text-foreground mb-1",children:h.name}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:h.description}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-1",children:[(0,s.jsxs)("div",{className:"p-1.5 rounded bg-muted/50",children:[(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground",children:"Duration"}),(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground",children:h.duration})]}),(0,s.jsxs)("div",{className:"p-1.5 rounded bg-muted/50",children:[(0,s.jsx)("p",{className:"text-[10px] text-muted-foreground",children:"Questions"}),(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground",children:h.questions})]})]})]})]})})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-xs font-bold text-foreground",children:[(0,s.jsx)(ea.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Choose Topic"]}),(0,s.jsx)("div",{className:"relative",children:(0,s.jsxs)(es.l6,{value:o,onValueChange:l,disabled:u||0===n.length,children:[(0,s.jsx)(es.bq,{className:"h-8 text-xs border rounded-lg bg-popover border-border text-foreground focus:ring-1 focus:ring-border",children:(0,s.jsx)(es.yv,{placeholder:u?"Loading topics...":"Select topic"})}),(0,s.jsx)(es.gC,{className:"rounded-lg shadow-2xl bg-popover border-border",position:"popper",side:"bottom",align:"start",sideOffset:8,style:{position:"fixed",zIndex:9999,maxHeight:"200px",overflow:"auto"},children:n.map(e=>(0,s.jsx)(es.eb,{value:e,className:"h-8 pl-8 pr-2 py-2 text-xs rounded text-foreground hover:bg-muted focus:bg-muted",children:e},e))})]})}),(0,s.jsx)("div",{className:"p-2 border rounded bg-muted/30 border-border",children:(0,s.jsx)("div",{className:"flex items-center gap-1.5",children:u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-foreground
1/40 animate-pulse"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading topics..."})]}):n.length>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)($.A,{className:"w-3 h-3 text-foreground",strokeWidth:1.5}),(0,s.jsxs)("span",{className:"text-xs text-foreground",children:[(0,s.jsx)("span",{className:"font-bold",children:n.length})," topics ready"]})]}):(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"No topics available"})})})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsxs)("label",{className:"flex items-center gap-1.5 text-xs font-bold text-foreground",children:[(0,s.jsx)(g.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Examiner Voice"]}),(0,s.jsx)("div",{className:"relative",children:(0,s.jsxs)(es.l6,{value:d,onValueChange:c,disabled:u||0===i.length,children:[(0,s.jsx)(es.bq,{className:"h-8 text-xs border rounded-lg bg-popover border-border text-foreground focus:ring-1 focus:ring-border",children:(0,s.jsx)(es.yv,{placeholder:u?"Loading voices...":"Select examiner voice"})}),(0,s.jsx)(es.gC,{className:"rounded-lg shadow-2xl bg-popover border-border",position:"popper",side:"bottom",align:"start",sideOffset:8,style:{position:"fixed",zIndex:9999,maxHeight:"200px",overflow:"auto"},children:i.map(e=>(0,s.jsx)(es.eb,{value:e.value,className:"h-8 pl-8 pr-2 py-2 text-xs rounded text-foreground hover:bg-muted focus:bg-muted",children:e.name},e.value))})]})})]})]})};var eo=t(99125),el=t.n(eo),ei=t(26577),ed=t(3438),ec=t(64055);let eu=e=>{let{message:r,onPlayAudio:t,loading:l,showFullEvaluation:i=!1,isPlayingAudio:d=!1,practiceMode:c=null}=e,[m,p]=(0,a.useState)(!1),[f,b]=(0,a.useState)(!1),v=(0,a.useRef)(null),j=e=>{if(!e)return"N/A";let r=Math.round(2*parseFloat(e))/2;return r%1==0?r.toFixed(0):r.toFixed(1)},N=async()=>{try{await t(r.content)}catch(e){console.error("Error playing audio:",e)}};if("question"===r.type){let e=(e=>{let r={part_1:{name:"Part 1 â Introduction & Interview",icon:(0,s.jsx)(x.A,{className:"w-3.5 h-3.5",strokeWidth:1.5})},part_2:{name:"Part 2 â Individual Long Turn",icon:(0,s.jsx)(ea.A,{className:"w-3.5 h-3.5",strokeWidth:1.5})},part_3:{name:"Part 3 â Two-way Discussion",icon:(0,s.jsx)(A.A,{className:"w-3.5 h-3.5",strokeWidth:1.5})}};return r[e]||r.part_1})(r.part);return(0,s.jsxs)("div",{className:"jsx-933cae9e29dc0af4 w-full mb-6",children:[(0,s.jsxs)("div",{className:"jsx-933cae9e29dc0af4 flex flex-wrap items-center gap-2 mb-4",children:[(0,s.jsxs)(o.E,{variant:"outline",className:"text-xs border-border text-foreground gap-1.5",children:[e.icon,e.name]}),r.topic&&(0,s.jsx)(o.E,{variant:"outline",className:"text-xs border-border text-muted-foreground",children:r.topic}),r.timeLimit&&(0,s.jsxs)(o.E,{variant:"outline",className:"text-xs border-border text-muted-foreground gap-1",children:[(0,s.jsx)(S.A,{className:"w-3 h-3",strokeWidth:1.5}),(e=>{let r=Math.floor(e/60);return"".concat(r,":").concat((e%60).toString().padStart(2,"0"))})(r.timeLimit)]})]}),(0,s.jsx)("div",{className:"jsx-933cae9e29dc0af4 "+"rounded-xl border p-5 mb-4 transition-all ".concat(d?"bg-card border-foreground
1/20":"bg-card border-border"),children:(0,s.jsxs)("div",{className:"jsx-933cae9e29dc0af4 flex items-center gap-5",children:[(0,s.jsx)("div",{className:"jsx-933cae9e29dc0af4 flex-shrink-0",children:"mock_interview"!==c?(0,s.jsx)(n.$,{onClick:N,disabled:l||d,className:"w-12 h-12 rounded-full p-0 bg-foreground hover:bg-foreground/90 text-background disabled:opacity-50",children:d?(0,s.jsx)(u.A,{className:"w-5 h-5",strokeWidth:1.5}):(0,s.jsx)(g.A,{className:"w-5 h-5",strokeWidth:1.5})}):(0,s.jsx)("div",{className:"jsx-933cae9e29dc0af4 w-12 h-12 rounded-full bg-muted border border-border flex items-center justify-center",children:(0,s.jsx)(u.A,{className:"w-5 h-5 text-foreground",strokeWidth:1.5})})}),(0,s.jsxs)("div",{className:"jsx-933cae9e29dc0af4 flex-1",children:[(0,s.jsx)("div",{className:"jsx-933cae9e29dc0af4 flex items-center justify-center h-10 mb-3 gap-0.5",children:Array.from({length:28}).map((e,r)=>{let t=[35,55,30,75,45,85,40,95,60,45,80,30,100,50,70,40,90,55,50,85,35,75,45,95,60,40,80,50][r]||45;return(0,s.jsx)("div",{style:{height:"".concat(t,"%"),animation:d?"waveAnimation 1.6s ease-in-out infinite ".concat(.03*r,"s"):"none",transformOrigin:"bottom"},className:"jsx-933cae9e29dc0af4 "+"w-1 rounded-full transition-all duration-300 ".concat(d?"bg-foreground":"bg-muted-foreground/30")},r)})}),(0,s.jsxs)("div",{className:"jsx-933cae9e29dc0af4 text-center",children:[(0,s.jsx)("p",{className:"jsx-933cae9e29dc0af4 text-xs font-semibold text-foreground",children:d?"mock_interview"===c?"Examiner Speaking...":"Playing Question Audio":"mock_interview"===c?"Listen to the Examiner":"Click to hear question"}),(0,s.jsx)("p",{className:"jsx-933cae9e29dc0af4 text-xs text-muted-foreground mt-0.5",children:d?"Listen carefully":"Audio will play the question clearly"})]})]})]})}),(0,s.jsxs)(n.$,{onClick:()=>p(!m),variant:"outline",className:"w-full h-10 border-border justify-between text-sm",children:[(0,s.jsxs)("div",{className:"jsx-933cae9e29dc0af4 flex items-center gap-2",children:[(0,s.jsx)(ei.A,{className:"w-4 h-4",strokeWidth:1.5}),"View Question Text"]}),m?(0,s.jsx)(ed.A,{className:"w-4 h-4",strokeWidth:1.5}):(0,s.jsx)(ec.A,{className:"w-4 h-4",strokeWidth:1.5})]}),m&&(0,s.jsxs)("div",{className:"jsx-933cae9e29dc0af4 mt-2 rounded-xl border border-border bg-card p-4",children:[(0,s.jsx)("p",{className:"jsx-933cae9e29dc0af4 text-xs font-semibold text-foreground mb-2",children:"Question Text"}),(0,s.jsx)("div",{className:"jsx-933cae9e29dc0af4 bg-muted/30 rounded-lg border border-border p-3",children:(0,s.jsx)("p",{className:"jsx-933cae9e29dc0af4 text-sm leading-relaxed text-foreground",children:r.content})})]}),(0,s.jsx)(el(),{id:"933cae9e29dc0af4",children:"@keyframes waveAnimation{0%,100%{transform:scaley(1);opacity:.8}50%{transform:scaley(1.4);opacity:1}}"})]})}if("answer"===r.type){var y,k,_,C,E,T,R,P;return(0,s.jsxs)("div",{className:"w-full mb-6",children:[r.audioBlob&&(0,s.jsx)("div",{className:"rounded-xl border border-border bg-card p-4 mb-3 cursor-pointer hover:border-foreground
1/20 transition-colors",onClick:()=>{if(r.audioBlob){v.current&&v.current.pause();let e=URL.createObjectURL(r.audioBlob);v.current=new Audio(e),v.current.addEventListener("loadeddata",()=>v.current.play()),v.current.addEventListener("ended",()=>URL.revokeObjectURL(e))}},children:(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-full bg-muted border border-border flex items-center justify-center flex-shrink-0",children:(0,s.jsx)(h.A,{className:"w-4 h-4 text-foreground",strokeWidth:1.5})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"flex items-center justify-center h-8 mb-2 gap-0.5",children:Array.from({length:20}).map((e,r)=>(0,s.jsx)("div",{className:"w-1 rounded-full bg-muted-foreground/40",style:{height:"".concat(70*Math.random()+20,"%")}},r))}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Your Recorded Response"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Click to review your answer"})]})]})]})}),r.content&&(0,s.jsxs)("div",{className:"mb-3",children:[(0,s.jsxs)(n.$,{onClick:()=>b(!f),variant:"outline",className:"w-full h-10 border-border justify-between text-sm",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ei.A,{className:"w-4 h-4",strokeWidth:1.5}),"View Response Transcription"]}),f?(0,s.jsx)(ed.A,{className:"w-4 h-4",strokeWidth:1.5}):(0,s.jsx)(ec.A,{className:"w-4 h-4",strokeWidth:1.5})]}),f&&(0,s.jsxs)("div",{className:"mt-2 rounded-xl border border-border bg-card p-4",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground mb-2",children:"Your Transcribed Response"}),(0,s.jsx)("div",{className:"bg-muted/30 rounded-lg border border-border p-3",children:(0,s.jsxs)("p",{className:"text-sm italic leading-relaxed text-foreground",children:['"',r.content,'"']})})]})]}),r.evaluation&&(0,s.jsx)("div",{children:i?(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5 space-y-5",children:[(0,s.jsxs)("div",{className:"text-center bg-muted/30 rounded-lg border border-border p-5",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Overall Band Score"}),(0,s.jsx)("p",{className:"text-4xl font-bold text-foreground mb-1",children:j(r.evaluation.overall_band_score)}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"out of 9.0"}),(0,s.jsx)("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden max-w-xs mx-auto mb-1",children:(0,s.jsx)("div",{className:"h-full rounded-full bg-foreground",style:{width:"".concat(r.evaluation.overall_band_score/9*100,"%")}})}),(0,s.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground max-w-xs mx-auto",children:[(0,s.jsx)("span",{children:"0"}),(0,s.jsx)("span",{children:"4.5"}),(0,s.jsx)("span",{children:"9"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-foreground mb-3 text-center",children:"Assessment by Criteria"}),(0,s.jsx)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[{label:"Fluency & Coherence",value:null==(y=r.evaluation.fluency_and_coherence)?void 0:y.band_score},{label:"Lexical Resource",value:null==(k=r.evaluation.lexical_resource)?void 0:k.band_score},{label:"Grammatical Range",value:null==(_=r.evaluation.grammatical_range_and_accuracy)?void 0:_.band_score},{label:"Pronunciation",value:null==(C=r.evaluation.pronunciation)?void 0:C.band_score}].map(e=>{let{label:r,value:t}=e;return(0,s.jsxs)("div",{className:"bg-muted/30 rounded-lg border border-border p-3 text-center",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:r}),(0,s.jsx)("p",{className:"text-2xl font-bold text-foreground",children:j(t)})]},r)})})]}),r.evaluation.detailed_feedback&&(0,s.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[(null==(E=r.evaluation.detailed_feedback.strengths)?void 0:E.length)>0&&(0,s.jsxs)("div",{className:"bg-muted/30 rounded-lg border border-border p-4",children:[(0,s.jsx)("p",{className:"text-xs font-bold text-foreground mb-3",children:"Strengths"}),(0,s.jsx)("ul",{className:"space-y-2",children:r.evaluation.detailed_feedback.strengths.map((e,r)=>(0,s.jsxs)("li",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"text-foreground mt-0.5",children:"â¢"}),e]},r))})]}),(null==(T=r.evaluation.detailed_feedback.areas_for_improvement)?void 0:T.length)>0&&(0,s.jsxs)("div",{className:"bg-muted/30 rounded-lg border border-border p-4",children:[(0,s.jsx)("p",{className:"text-xs font-bold text-foreground mb-3",children:"Areas for Improvement"}),(0,s.jsx)("ul",{className:"space-y-2",children:r.evaluation.detailed_feedback.areas_for_improvement.map((e,r)=>(0,s.jsxs)("li",{className:"flex items-start gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"text-foreground mt-0.5",children:"â"}),e]},r))})]})]})]}):(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4",children:[(null==(P=r.evaluation.detailed_feedback)||null==(R=P.areas_for_improvement)?void 0:R[0])&&(0,s.jsx)("div",{className:"bg-muted/30 rounded-lg border border-border p-3 mb-3",children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)(w.A,{className:"w-4 h-4 text-foreground mt-0.5 flex-shrink-0",strokeWidth:1.5}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-bold text-foreground mb-1",children:"Key Improvement Area"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:r.evaluation.detailed_feedback.areas_for_improvement[0]})]})]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"Evaluation Complete"}),(0,s.jsxs)(o.E,{variant:"outline",className:"text-sm font-bold border-border text-foreground px-3",children:["Band ",j(r.evaluation.overall_band_score)]})]})]})})]})}return"system"===r.type?(0,s.jsx)("div",{className:"flex justify-center mb-5",children:(0,s.jsx)("div",{className:"bg-muted text-foreground px-5 py-2 rounded-full border border-border text-center max-w-lg",children:(0,s.jsx)("span",{className:"text-xs font-medium",children:r.content})})}):null};var em=t(95428),ex=t(96356),eh=t(85670),ep=t(65781);let ef=e=>{let{isRecording:r,hasRecording:t,recordedAudio:o,onStartRecording:i,onStopRecording:m,onSubmitAnswer:x,onClearRecording:p,loading:f,autoMode:g=!1,isPlayingQuestionAudio:b=!1,waitingForAudio:v=!1}=e,[j,N]=(0,a.useState)(0),[y,w]=(0,a.useState)(0),[k,_]=(0,a.useState)("idle"),[A,C]=(0,a.useState)(0),E=(0,a.useRef)(null),T=(0,a.useRef)(null),R=(0,a.useRef)(null),P=(0,a.useRef)(null);(0,a.useEffect)(()=>{b?_("listening"):v?_("waiting"):r?_("recording"):t?_("recorded"):_("idle")},[b,v,r,t]),(0,a.useEffect)(()=>(r?(w(0),T.current=setInterval(()=>w(e=>e+1),1e3)):T.current&&clearInterval(T.current),()=>{T.current&&clearInterval(T.current)}),[r]),(0,a.useEffect)(()=>
1{if(o&&!P.current){P.current=URL.createObjectURL(o);let e=new Audio(P.current);e.addEventListener("loadedmetadata",()=>C(e.duration))}return()=>{P.current&&(URL.revokeObjectURL(P.current),P.current=null)}},[o]);let L=e=>{let r=Math.floor(e/60);return"".concat(r,":").concat((e%60).toString().padStart(2,"0"))},W=async()=>{w(0),N(0),await i()};if(f)return(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card p-8 text-center",children:[(0,s.jsx)("div",{className:"w-12 h-12 bg-muted border border-border rounded-full flex items-center justify-center mx-auto mb-4",children:(0,s.jsx)(l.A,{className:"w-5 h-5 text-foreground animate-spin",strokeWidth:1.5})}),(0,s.jsx)("p",{className:"text-sm font-semibold text-foreground mb-1",children:g?"Processing Your Response":"Evaluating Your Answer"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:g?"Please wait while we analyze your response and prepare the next question":"Please wait while we analyze your response and generate your band score"})]});let F=(()=>{switch(k){case"listening":return{title:"Listening to Question",subtitle:g?"Recording begins automatically when the question ends":"Listen carefully to the examiner's question",icon:(0,s.jsx)(u.A,{className:"w-5 h-5",strokeWidth:1.5})};case"waiting":return{title:"Prepare to Respond",subtitle:"Get ready to give your answer clearly and confidently",icon:(0,s.jsx)(S.A,{className:"w-5 h-5",strokeWidth:1.5})};case"recording":return{title:"Recording in Progress",subtitle:g?"Speak naturally â recording in progress":"Speak clearly â click Stop when finished",icon:(0,s.jsx)(em.A,{className:"w-5 h-5",strokeWidth:1.5})};case"recorded":return{title:"Response Recorded",subtitle:g?"Processing your response â please wait":"Recorded â review or submit your response",icon:(0,s.jsx)(ex.A,{className:"w-5 h-5",strokeWidth:1.5})};case"playing":return{title:"Playing Response",subtitle:"Listening to your recorded answer",icon:(0,s.jsx)(h.A,{className:"w-5 h-5",strokeWidth:1.5})};default:return{title:"Ready to Record",subtitle:"Click the microphone button to begin recording",icon:(0,s.jsx)(d.A,{className:"w-5 h-5",strokeWidth:1.5})}}})();return(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 rounded-xl border border-border bg-card p-5",children:[(0,s.jsx)("div",{className:"jsx-83a633642bf74098 rounded-lg border border-border bg-muted/30 p-4 mb-5",children:(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 flex items-center gap-3",children:[(0,s.jsx)("div",{className:"jsx-83a633642bf74098 "+"w-9 h-9 rounded-lg border border-border flex items-center justify-center flex-shrink-0 ".concat("recording"===k?"bg-destructive/10":"bg-muted"),children:(0,s.jsx)("div",{className:"jsx-83a633642bf74098 "+(("recording"===k?"text-destructive":"text-foreground")||""),children:F.icon})}),(0,s.jsxs)("div",{className:"jsx-83a633642bf74098",children:[(0,s.jsx)("p",{className:"jsx-83a633642bf74098 "+"text-sm font-bold ".concat("recording"===k?"text-destructive":"text-foreground"),children:F.title}),(0,s.jsx)("p",{className:"jsx-83a633642bf74098 text-xs text-muted-foreground mt-0.5 leading-relaxed",children:F.subtitle})]})]}),("recording"===k||"playing"===k)&&(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 text-right bg-muted rounded-lg border border-border px-3 py-2 flex-shrink-0 ml-3",children:[(0,s.jsx)("p",{className:"jsx-83a633642bf74098 "+"text-base font-mono font-bold ".concat("recording"===k?"text-destructive":"text-foreground"),children:"playing"===k?"".concat(L(Math.floor(j))," / ").concat(L(Math.floor(A||y))):L(y)}),"recording"===k&&(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 flex items-center justify-end gap-1.5 mt-1",children:[(0,s.jsx)("div",{className:"jsx-83a633642bf74098 w-2 h-2 bg-destructive rounded-full animate-pulse"}),(0,s.jsx)("span",{className:"jsx-83a633642bf74098 text-[10px] font-bold text-destructive uppercase tracking-wider",children:"Live"})]})]})]})}),("recording"===k||"recorded"===k||"playing"===k)&&(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 bg-muted/30 rounded-lg border border-border p-4 mb-5",children:[(0,s.jsx)("p",{className:"jsx-83a633642bf74098 text-xs font-semibold text-foreground text-center mb-1",children:"Audio Response"}),(0,s.jsxs)("p",{className:"jsx-83a633642bf74098 text-xs text-muted-foreground text-center mb-3",children:["recording"===k&&"Live audio visualization","playing"===k&&"Playback visualization","recorded"===k&&"Recorded response ready"]}),(0,s.jsx)("div",{className:"jsx-83a633642bf74098 flex items-center justify-center h-12 mb-4 gap-0.5",children:(()=>{let e=[];for(let r=0;r<28;r++){let t=70*Math.random()+20,a=A>0?j/A:0,n="playing"===k?r<28*a:"recording"===k;e.push((0,s.jsx)("div",{className:"w-1 rounded-full transition-all duration-200 ".concat(n?"bg-foreground":"bg-border"),style:{height:"".concat(t,"%"),animation:"recording"===k?"pulse 0.".concat(r%6+4,"s infinite"):"none"}},r))}return e})()}),!g&&"recorded"===k&&(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 flex items-center justify-center gap-3",children:[(0,s.jsxs)(n.$,{onClick:()=>
1{P.current&&(E.current&&E.current.pause(),E.current=new Audio(P.current),E.current.currentTime=j,E.current.addEventListener("loadeddata",()=>{E.current.play(),_("playing"),R.current=setInterval(()=>{E.current&&(N(E.current.currentTime),E.current.ended&&(_("recorded"),N(0),clearInterval(R.current)))},100)}),E.current.addEventListener("ended",()=>{_("recorded"),N(0),R.current&&clearInterval(R.current)}))},className:"bg-foreground hover:bg-foreground/90 text-background text-xs h-9 px-4 gap-2",children:[(0,s.jsx)(h.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Play Recording"]}),(0,s.jsxs)(n.$,{onClick:()=>{E.current&&E.current.pause(),_("idle"),w(0),N(0),C(0),R.current&&clearInterval(R.current),P.current&&(URL.revokeObjectURL(P.current),P.current=null),null==p||p()},variant:"outline",className:"text-xs h-9 px-4 gap-2 border-border text-muted-foreground hover:bg-muted",children:[(0,s.jsx)(eh.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Delete & Re-record"]})]}),"playing"===k&&(0,s.jsx)("div",{className:"jsx-83a633642bf74098 flex justify-center",children:(0,s.jsxs)(n.$,{onClick:()=>{E.current&&E.current.pause(),_("recorded"),R.current&&clearInterval(R.current)},variant:"outline",className:"text-xs h-9 px-4 gap-2 border-border",children:[(0,s.jsx)(ep.A,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Pause Playback"]})})]}),(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 flex items-center justify-center mb-4",children:["listening"===k&&(0,s.jsx)("div",{className:"jsx-83a633642bf74098 flex items-center justify-center w-16 h-16 bg-muted border border-border rounded-full animate-pulse",children:(0,s.jsx)(u.A,{className:"w-7 h-7 text-foreground",strokeWidth:1.5})}),"waiting"===k&&(0,s.jsx)("div",{className:"jsx-83a633642bf74098 flex items-center justify-center w-16 h-16 bg-muted border border-border rounded-full animate-pulse",children:(0,s.jsx)(S.A,{className:"w-7 h-7 text-foreground",strokeWidth:1.5})}),"idle"===k&&!g&&(0,s.jsx)(n.$,{onClick:W,className:"w-16 h-16 rounded-full p-0 bg-muted hover:bg-muted/80 border border-border text-foreground hover:scale-105 transition-all",children:(0,s.jsx)(d.A,{className:"w-7 h-7",strokeWidth:1.5})}),"recording"===k&&(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 relative",children:[(0,s.jsx)(n.$,{onClick:m,className:"w-16 h-16 rounded-full p-0 bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:(0,s.jsx)(ex.A,{className:"w-7 h-7",strokeWidth:1.5})}),(0,s.jsx)("div",{className:"jsx-83a633642bf74098 absolute -top-1 -right-1",children:(0,s.jsx)("div",{className:"jsx-83a633642bf74098 w-4 h-4 bg-destructive rounded-full animate-ping"})})]}),!g&&("recorded"===k||"playing"===k)&&(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 flex items-center gap-5",children:[(0,s.jsx)(n.$,{onClick:W,variant:"outline",className:"w-14 h-14 rounded-full p-0 border-border hover:bg-muted",children:(0,s.jsx)(d.A,{className:"w-6 h-6 text-foreground",strokeWidth:1.5})}),(0,s.jsx)(n.$,{onClick:x,disabled:"playing"===k,className:"w-14 h-14 rounded-full p-0 bg-foreground hover:bg-foreground
1/90 text-background disabled:opacity-50",children:(0,s.jsx)(c.A,{className:"w-6 h-6",strokeWidth:1.5})})]}),g&&"recorded"===k&&(0,s.jsx)("div",{className:"jsx-83a633642bf74098 flex items-center justify-center w-16 h-16 bg-muted border border-border rounded-full",children:(0,s.jsx)(l.A,{className:"w-7 h-7 text-foreground animate-spin",strokeWidth:1.5})})]}),g&&"idle"===k&&(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 text-center space-y-3",children:[(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 inline-flex items-center gap-2 bg-muted/50 px-4 py-2 rounded-full border border-border",children:[(0,s.jsx)("div",{className:"jsx-83a633642bf74098 w-2 h-2 bg-foreground rounded-full animate-pulse"}),(0,s.jsx)("span",{className:"jsx-83a633642bf74098 text-xs font-bold text-foreground",children:"Automatic Mode Active"})]}),(0,s.jsxs)("div",{className:"jsx-83a633642bf74098 bg-muted/30 rounded-lg border border-border p-4 text-left",children:[(0,s.jsx)("p",{className:"jsx-83a633642bf74098 text-xs font-semibold text-foreground mb-1.5",children:"Test Flow"}),(0,s.jsx)("p",{className:"jsx-83a633642bf74098 text-xs text-muted-foreground leading-relaxed",children:"Questions play automatically. Recording begins when each question ends. Responses are submitted automatically to maintain authentic test timing."})]})]}),(0,s.jsx)(el(),{id:"83a633642bf74098",children:"@keyframes pulse{0%,100%{transform:scaley(1);opacity:.8}50%{transform:scaley(1.5);opacity:1}}"})]})};class eg{getUrl(e){return"".concat(this.baseURL,"/api/v1/ielts-speaking").concat(e)}getHeaders(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"application/json",r={Authorization:"Bearer ".concat(this.apiKey)};return e&&(r["Content-Type"]=e),r}async handleResponse(e){if(!e.ok){let r,t=await e.text();try{let s=JSON.parse(t);r=s.message||s.error||"HTTP ".concat(e.status)}catch(s){r=t||"HTTP ".concat(e.status)}throw Error(r)}let r=e.headers.get("content-type");return r&&r.includes("application/json")?await e.json():e}async get(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=new URL(this.getUrl(e));Object.keys(r).forEach(e=>{null!==r[e]&&void 0!==r[e]&&t.searchParams.append(e,r[e])});let s=new AbortController,a=setTimeout(()=>s.abort(),this.timeout);try{let e=await fetch(t.toString(),{method:"GET",headers:this.getHeaders(),signal:s.signal});return clearTimeout(a),await this.handleResponse(e)}catch(e){if(clearTimeout(a),"AbortError"===e.name)throw Error("Request timeout");throw e}}async post(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=new AbortController,a=setTimeout(()=>s.abort(),this.timeout);try{let n={method:"POST",signal:s.signal,...t};r instanceof FormData?(n.body=r,n.headers={Authorization:"Bearer ".concat(this.apiKey)}):r?(n.headers=this.getHeaders("application/json"),n.body=JSON.stringify(r)):n.headers=this.getHeaders();let o=await fetch(this.getUrl(e),n);return clearTimeout(a),await this.handleResponse(o)}catch(e){if(clearTimeout(a),"AbortError"===e.name)throw Error("Request timeout");throw e}}async downloadFile(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=new AbortController,s=setTimeout(()=>t.abort(),this.timeout);try{let a={method:r?"POST":"GET",signal:t.signal,headers:this.getHeaders(r?"application/json":null)};r&&(a.body=JSON.stringify(r));let n=await fetch(this.getUrl(e),a);if(clearTimeout(s),!n.ok)throw Error("HTTP ".concat(n.status));return await n.blob()}catch(e){if(clearTimeout(s),"AbortError"===e.name)throw Error("Request timeout");throw e}}async getTopics(e){return await this.get("/topics-llm/".concat(e))}async getVoiceOptions(){return await this.get("/voice-options")}async generateQuestion(e,r){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return await this.post("/get-question-llm",{task_id:t,part_type:e,topic:r,history:s})}async getSampleQuestions(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5,s={count:t};return r&&(s.topic=r),await this.get("/sample-questions-llm/".concat(e),s)}async generateQuestionAudio(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return await this.downloadFile("/question-audio",{text:e,voice:r})}async submitAnswer(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;try{eN(e)}catch(e){throw Error("Audio validation failed: ".concat(e.message))}let s=new FormData,a="response.wav";e.type&&(e.type.includes("mp3")?a="response.mp3":e.type.includes("webm")?a="response.webm":e.type.includes("m4a")||e.type.includes("mp4")?a="response.m4a":e.type.includes("ogg")&&(a="response.ogg")),s.append("file",e,a),s.append("audio_duration",r.toString()),t&&s.append("question",t);
1try{return await this.post("/submit-answer-v2",s)}catch(e){if(e.message.includes("404"))throw Error("Could not process audio file. Please ensure you recorded valid audio and try again.");if(e.message.includes("413"))throw Error("Audio file is too large. Please record shorter audio or compress the file.");if(e.message.includes("415"))throw Error("Unsupported audio format. Please use WAV, MP3, WebM, M4A, or OGG format.");throw e}}async startMockTest(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=e||"mock_test_".concat(Date.now());return await this.post("/mock-test",{task_id:r,is_first:!0,part_type:"part_1"})}async continueMockTest(e,r,t,s){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n={task_id:e,current_answer:r,history:t,part_type:s};return null!==a&&(n.audio_duration=a),await this.post("/mock-test",n)}async completeMockTest(e,r){return await this.post("/mock-test",{task_id:e,complete:!0,history:r})}async transcribeAudio(e){try{var r;let t=new FormData;return t.append("file",e,"temp_transcribe.wav"),t.append("audio_duration","0"),(null==(r=(await this.post("/submit-answer",t)).evaluation)?void 0:r.transcription)||""}catch(e){return console.error("Transcription failed:",e),""}}constructor(){this.baseURL="https://api.gradmate.ai",this.apiKey="kJ9nXz8yQwRtY2mP3vL5hG7dF4cB2aN8xW6tZ9q",this.timeout=3e4}}let eb=e=>{let r=Math.floor(e/60);return"".concat(r,":").concat((e%60).toString().padStart(2,"0"))},ev=e=>{let r={part_1:{name:"Part 1",description:"Introduction & Personal Questions",duration:"4-5 minutes",color:"bg-brand-navy",instructions:"Answer questions about yourself, your life, and familiar topics."},part_2:{name:"Part 2",description:"Individual Long Turn",duration:"3-4 minutes",color:"bg-brand-navy",instructions:"Speak for 1-2 minutes on a given topic after 1 minute preparation."},part_3:{name:"Part 3",description:"Two-way Discussion",duration:"4-5 minutes",color:"bg-brand-navy-hover",instructions:"Discuss abstract ideas and issues related to Part 2 topic."}};return r[e]||r.part_1},ej=e=>e>=8.5?{level:"Expert",color:"text-success",description:"Very good user"}:e>=7.5?{level:"Very Good",color:"text-success",description:"Good user"}:e>=6.5?{level:"Good",color:"text-success",description:"Competent user"}:e>=5.5?{level:"Competent",color:"text-warning",description:"Modest user"}:e>=4.5?{level:"Modest",color:"text-brand-orange",description:"Limited user"}:{level:"Limited",color:"text-destructive",description:"Extremely limited user"},eN=e=>{if(!e)throw Error("No audio file provided");if(!["audio/wav","audio/mp3","audio/webm","audio/mp4","audio/m4a","audio/ogg"].some(r=>{let t=r.split("/")[1];return e.type.includes(t)||e.name.toLowerCase().endsWith(".".concat(t))}))throw Error("Invalid audio file type. Backend accepts: WAV, MP3, WebM, M4A, or OGG format.");if(e.size>0x3200000)throw Error("Audio file is too large. Maximum size is 50MB.");if(0===e.size)throw Error("Audio file is empty. Please record audio before submitting.");return!0},ey=new eg},26483:(e,r,t)=>{t.d(r,{C:()=>a});var s=t(44976);let a=()=>
1{let[e,r]=(0,s.useState)(!1),[t,a]=(0,s.useState)(null),[n,o]=(0,s.useState)(null),[l,i]=(0,s.useState)(0),d=(0,s.useRef)(null),c=(0,s.useRef)([]),u=(0,s.useRef)(null),m=(0,s.useRef)(null),x=(0,s.useRef)(null),h=(0,s.useRef)(null),p=(0,s.useCallback)(()=>!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),[]),f=(0,s.useCallback)(()=>{i(0),m.current=setInterval(()=>{i(e=>e+1)},1e3)},[]),g=(0,s.useCallback)(()=>{m.current&&(clearInterval(m.current),m.current=null)},[]),b=(0,s.useCallback)(async()=>{if(!p())return o("Recording is not supported in this browser"),!1;try{o(null);let e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:44100,channelCount:1}});u.current=e,c.current=[];let t="audio/wav";return!MediaRecorder.isTypeSupported("audio/wav")&&(MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?t="audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/webm")&&(t="audio/webm")),console.log("Recording with MIME type:",t),d.current=new MediaRecorder(e,{mimeType:t,audioBitsPerSecond:128e3}),d.current.ondataavailable=e=>{e.data.size>0&&c.current.push(e.data)},d.current.onstop=()=>{let e=new Blob(c.current,{type:t});console.log("Audio recorded successfully:",{size:e.size,type:e.type,chunks:c.current.length,duration:l}),a(e),u.current&&(u.current.getTracks().forEach(e=>e.stop()),u.current=null)},d.current.onerror=e=>{console.error("MediaRecorder error:",e),o("Recording error occurred")},x.current=Date.now(),h.current=null,d.current.start(250),r(!0),f(),!0}catch(e){return console.error("Error starting recording:",e),"NotAllowedError"===e.name?o("Microphone access denied. Please allow microphone access and try again."):"NotFoundError"===e.name?o("No microphone found. Please connect a microphone and try again."):"NotSupportedError"===e.name?o("Audio recording is not supported in this browser."):o("Failed to start recording. Please check your microphone and try again."),!1}},[p,f,l]),v=(0,s.useCallback)(()=>{d.current&&e&&(x.current&&(h.current=Date.now()),d.current.stop(),r(!1),g())},[e,g]),j=(0,s.useCallback)(()=>{a(null),i(0),o(null)},[]),N=(0,s.useCallback)(()=>{let e=Math.floor(l/60),r=l%60;return"".concat(e,":").concat(r.toString().padStart(2,"0"))},[l]),y=(0,s.useCallback)(()=>{if(t){let e=URL.createObjectURL(t),r=new Audio(e);return r.play().catch(e=>{console.error("Error playing audio:",e),o("Failed to play recording")}),r.addEventListener("ended",()=>{URL.revokeObjectURL(e)}),r}return null},[t]),w=(0,s.useCallback)(()=>{if(t){let e=(t.size/1048576).toFixed(2);return"".concat(e," MB")}return"0 MB"},[t]),k=(0,s.useCallback)(()=>{e&&v(),u.current&&u.current.getTracks().forEach(e=>e.stop()),m.current&&clearInterval(m.current)},[e,v]),_=x.current&&h.current?(h.current-x.current)/1e3:l;return{isRecording:e,recordedAudio:t,error:n,recordingTime:l,finalDuration:_,formattedTime:N(),audioSize:w(),isSupported:p(),startRecording:b,stopRecording:v,clearRecording:j,playRecording:y,cleanup:k,setError:e=>o(e)}}},49090:(e,r,t)=>{t.d(r,{Hx:()=>s,UW:()=>n,qt:()=>a,yt:()=>o});let s=["#F2811E","#525252","#8B6BF0","#1E9E73","#9A9484","#C25E12","#A98CF5","#CFC9BB"],a={orange:"#F2811E",orangeHover:"#DA7016",navy:"#000000",navyLifted:"#525252",purple:"#6B3FE4",purpleLifted:"#8B6BF0",offWhite:"#FBFAF7",light:"#ECE7DC",warmGray:"#CFC9BB",midGray:"#9A9484",charcoal:"#2E2B25",success:"#12805C",warning:"#B25E02",error:"#D92D20"},n="#9A9484",o={light:{stroke:"#000000",grid:"#E0DACB",muted:"#5F594B",tooltipBg:"#FFFFFF",tooltipBorder:"#E0DACB",dotFill:"#FBFAF7"},dark:{stroke:"#FBFAF7",grid:"#262626",muted:"#A3A3A3",tooltipBg:"#0D0D0D",tooltipBorder:"#262626",dotFill:"#000000"}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.