1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[29604],{3328:(e,t,s)=>{s.r(t),s.d(t,{default:()=>S});var r=s(23804),a=s(44976),n=s(64146),l=s(56025),i=s(58489),o=s(60747),d=s(52350),c=s(76935),u=s(18270),m=s(33731),h=s(29037),x=s(10866),p=s(87789),g=s(42793),f=s(43074),b=s(61017),v=s(50307),j=s(63749);let N=a.memo(v.NM,(e,t)=>e.passage.id===t.passage.id);function k(e){let{passage:t,highlights:s=[],onAdd:a,onUpdateNote:n,onRemove:l,readOnly:i=!1}=e;return t?(0,r.jsx)(j.A,{sectionKey:t.id,highlights:s,onAdd:a,onUpdateNote:n,onRemove:l,readOnly:i,children:(0,r.jsx)(N,{passage:t})}):null}var y=s(37320),w=s(98918),A=s(47401);function S(e){var t,s,N,S,C,M;let{testSlug:E,embedded:T=!1,presetTestId:q=null,fullMockSessionId:R=null,onSectionComplete:O=null,onExitMock:L=null}=e,P=(0,n.useRouter)(),{showInsufficientCreditsModal:z,showExpiredCreditsModal:I,refresh:Q}=(0,f.I)(),[W,$]=(0,a.useState)(!0),[F,H]=(0,a.useState)(null),[J,K]=(0,a.useState)(null),[V,_]=(0,a.useState)(null),[B,U]=(0,a.useState)({}),[Z,D]=(0,a.useState)(1),[G,Y]=(0,a.useState)(null),[X,ee]=(0,a.useState)(0),[et,es]=(0,a.useState)("idle"),[er,ea]=(0,a.useState)(!1),[en,el]=(0,a.useState)(!1),[ei,eo]=(0,a.useState)(!1),[ed,ec]=(0,a.useState)(null),eu=(0,a.useRef)(new Map),em=(0,a.useRef)(null),eh=(0,a.useRef)({}),ex=(0,a.useRef)(!1),ep=(0,a.useRef)(!1);(0,a.useEffect)(()=>{let e=!1;return(async()=>{try{var t,s,r,a,n;let l=await fetch("/api/ielts/reading/attempt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(q?{testId:q,fullMockSessionId:R}:{testSlug:E,fullMockSessionId:R})});if(401===l.status)return void P.push("/signin");if(402===l.status){let t=await l.json().catch(()=>({}));if(e)return;"expired"===t.reason?I():z(t.required),P.replace(E?"/ielts-reading/tests/".concat(E):"/ielts-reading");return}let i=await l.json();if(e)return;if(!i.success)throw Error(i.error||"Could not open the test");K(i.test),_(i.attempt),(null==(t=i.billing)?void 0:t.charged)&&Q(),U(null!=(s=i.attempt.answers)?s:{}),eh.current=null!=(r=i.attempt.answers)?r:{};let o=T?Math.max(0,Math.round((Date.now()-new Date(i.attempt.startedAt).getTime())/1e3)):Math.max(0,null!=(a=i.attempt.timeTakenSeconds)?a:0);ep.current=!T&&o>=(null!=(n=i.test.durationSeconds)?n:3600),ee(o),ec(new g.A("cambridge-reading",i.test.id)),$(!1)}catch(t){e||(H(t.message),$(!1))}})(),()=>{e=!0}},[E,q,R,T,P]);let eg=null!=(s=null==J?void 0:J.durationSeconds)?s:3600,ef=Math.max(0,eg-X);(0,a.useEffect)(()=>{if(W||er||ex.current)return;let e=setInterval(()=>ee(e=>e+1),1e3);return()=>clearInterval(e)},[W,er]);let eb=(0,a.useRef)(0),ev=(0,a.useRef)(3600);(0,a.useEffect)(()=>{eb.current=X},[X]),(0,a.useEffect)(()=>{ev.current=eg},[eg]);let ej=null!=(N=null==V?void 0:V.id)?N:null,eN=(0,a.useCallback)(()=>({answers:eh.current,timeTakenSeconds:Math.min(eb.current,ev.current)}),[]),ek=(0,a.useCallback)(async()=>{if(ej&&!ex.current){es("saving");try{let e=await fetch("/api/ielts/reading/attempt/".concat(ej),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(eN())}),t=await e.json();es(t.success?"saved":"error")}catch(e){es("error")}}},[ej,eN]),ey=(0,a.useRef)(!1),ew=(0,a.useCallback)((e,t)=>{U(s=>{let r={...s};return(0,A.lq)(t)?r[e]=t:delete r[e],eh.current=r,r}),Y(Number(e)),ey.current=!0,clearTimeout(em.current),em.current=setTimeout(()=>{ey.current=!1,ek()},1200)},[ek]);(0,a.useEffect)(()=>{if(!ej)return;let e=()=>{ex.current||(ey.current=!1,fetch("/api/ielts/reading/attempt/".concat(ej),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(eN()),keepalive:!0}).catch(()=>{}))};return window.addEventListener("pagehide",e),()=>{window.removeEventListener("pagehide",e),clearTimeout(em.current),e()}},[ej,eN]),(0,a.useEffect)(()=>{if(!ej)return;let e=setInterval(()=>{ex.current||fetch("/api/ielts/reading/attempt/".concat(ej),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(eN())}).catch(()=>{})},3e4);return()=>clearInterval(e)},[ej,eN]);let eA=(0,a.useCallback)(async()=>{if(V&&!ex.current){ex.current=!0,ea(!0),el(!1),clearTimeout(em.current);try{let e=await fetch("/api/ielts/reading/attempt/".concat(V.id,"/submit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({answers:eh.current,timeTakenSeconds:Math.min(X,eg)})}),t=await e.json();if(!t.success)throw Error(t.error||"Could not submit the test");
1if(T){null==O||O(t.attemptId);return}P.push("/ielts-reading/result/".concat(t.attemptId))}catch(e){ex.current=!1,ea(!1),h.oR.error(e.message)}}},[V,X,eg,J,P,T,O]),eS=(0,a.useRef)(eA);(0,a.useEffect)(()=>{eS.current=eA},[eA]);let eC=(0,a.useRef)(!1);(0,a.useEffect)(()=>{W||ex.current||ef>0||eC.current||ep.current||(eC.current=!0,h.oR.info("Time is up â submitting your answers."),eS.current())},[ef,W]);let eM=(0,a.useMemo)(()=>{var e;return null!=(e=null==J?void 0:J.passages)?e:[]},[J]),eE=(0,a.useCallback)(e=>"".concat(e,"::questions"),[]),eT=(0,a.useMemo)(()=>eM.flatMap(e=>[{id:e.id,number:e.passageNumber,title:e.title,kind:"passage"},{id:eE(e.id),number:e.passageNumber,title:e.title,kind:"questions",label:"Part ".concat(e.passageNumber," \xb7 Questions")}]),[eM,eE]),eq=(0,w.N)(ed,eT),eR=(0,a.useCallback)(e=>{D(e.number),requestAnimationFrame(()=>{window.dispatchEvent(new CustomEvent("cambridge-reveal-highlight",{detail:e}))})},[]),eO=(0,a.useMemo)(()=>{var e;return null!=(e=eM.find(e=>e.passageNumber===Z))?e:eM[0]},[eM,Z]),eL=(0,a.useMemo)(()=>Object.values(B).filter(A.lq).length,[B]),eP=(0,a.useMemo)(()=>eM.map(e=>{let t=e.groups.flatMap(e=>e.questionNumbers),s=t.filter(e=>(0,A.lq)(B[e])).length;return{passageNumber:e.passageNumber,total:t.length,done:s,numbers:t}}),[eM,B]),ez=(0,a.useCallback)((e,t)=>{t?eu.current.set(Number(e),t):eu.current.delete(Number(e))},[]),eI=(0,a.useCallback)(e=>{let t=eM.find(t=>t.groups.some(t=>t.questionNumbers.includes(e)));t&&t.passageNumber!==Z&&D(t.passageNumber),Y(e),requestAnimationFrame(()=>{var t;null==(t=eu.current.get(e))||t.scrollIntoView({behavior:"smooth",block:"center"})})},[eM,Z]);(0,a.useEffect)(()=>{let e=eu.current,t=new Map;if(e.forEach(e=>{let s=e.querySelector("[data-question-badge]");if(s){let e=Number(s.dataset.questionBadge);t.set(e,s)}}),t.forEach(e=>{e.classList.remove("ring-2","ring-module-accent/70","scale-110")}),t.forEach((e,t)=>{(0,A.lq)(B[t])&&e.classList.add("ring-2","ring-module-accent/40")}),null!=G){let e=t.get(G);e&&e.classList.add("ring-2","ring-module-accent/70","scale-110")}},[G,B]);let eQ=(0,a.useMemo)(()=>({mode:"exam",answers:B,setAnswer:ew,results:null,activeQuestion:G,setActiveQuestion:Y,registerQuestion:ez}),[B,ew,G,ez]);if(W)return(0,r.jsx)("div",{className:"fixed inset-0 z-50 bg-background grid place-items-center",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(l.A,{className:"w-6 h-6 animate-spin mx-auto mb-3 text-module-accent",strokeWidth:1.5}),(0,r.jsx)("p",{className:"text-brand-body text-muted-foreground",children:"Preparing your testâ¦"})]})});if(F)return(0,r.jsx)("div",{className:"fixed inset-0 z-50 bg-background grid place-items-center px-4",children:(0,r.jsxs)("div",{className:"text-center max-w-sm",children:[(0,r.jsx)("p",{className:"text-brand-h3 font-semibold text-foreground mb-2",children:"We couldn't start this test"}),(0,r.jsx)("p",{className:"text-brand-body text-muted-foreground mb-5",children:F}),(0,r.jsx)(x.$,{variant:"outline",onClick:()=>P.push(T?"/ielts-full-mock":"/ielts-reading"),children:"Back"})]})});let eW=ef<=300;return(0,r.jsxs)(b.B6.Provider,{value:eQ,children:[(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col bg-background",children:[(0,r.jsx)("header",{className:"flex-shrink-0 border-b border-border bg-card",children:(0,r.jsxs)("div",{className:"h-14 px-3 sm:px-5 flex items-center gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0 hidden sm:block",children:[(0,r.jsxs)("p",{className:"type-eyebrow text-muted-foreground truncate",children:[null!=(S=null==(t=J.book)?void 0:t.title)?S:J.title," \xb7 Test ",J.testNumber]}),(0,r.jsxs)("p",{className:"text-brand-caption font-semibold text-foreground truncate",children:["Passage ",null==eO?void 0:eO.passageNumber,(0,r.jsxs)("span",{className:"font-normal text-muted-foreground",children:[" \xb7 ",null==eO?void 0:eO.title]}),(0,r.jsxs)("span",{className:"font-normal text-muted-foreground tabular-nums",children:[" ","\xb7 Q",null==eO?void 0:eO.firstQuestion,"â",null==eO?void 0:eO.lastQuestion]})]})]}),(0,r.jsxs)("div",{className:"mx-auto flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-brand-caption text-muted-foreground hidden sm:inline",children:"Time left"}),(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 h-9 px-3 rounded-btn border tabular-nums font-bold ".concat(eW?"border-destructive/40 bg-destructive/10 text-destructive":"border-border bg-muted text-foreground"),role:"timer","aria-live":"off",children:[(0,r.jsx)(i.A,{className:"w-4 h-4",strokeWidth:1.5}),(0,A.ei)(ef)]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,r.jsx)(y.A,{items:eq.all,totals:eq.totals,onGoTo:eR,onRemove:eq.remove}),(0,r.jsxs)("span",{className:"hidden md:inline text-brand-caption text-muted-foreground tabular-nums",children:[eL,"/",J.totalQuestions]}),(0,r.jsxs)("span",{className:"hidden lg:inline text-brand-caption text-muted-foreground w-16",children:["saving"===et&&"Savingâ¦","saved"===et&&"Saved","error"===et&&(0,r.jsx)("span",{className:"text-destructive",children:"Not saved"})]}),(0,r.jsx)(x.$,{variant:"outline",size:"sm",onClick:()=>eo(!0),className:"border-border",children:"Exit"}),(0,r.jsx)(x.$,{size:"sm",onClick:()=>el(!0),disabled:er,children:er?(0,r.jsx)(l.A,{className:"w-4 h-4 animate-spin",strokeWidth:1.5}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.A,{className:"w-4 h-4 mr-1.5",strokeWidth:1.5}),"Submit"]})})]})]})}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col lg:flex-row lg:divide-x divide-border",children:[(0,r.jsx)("div",{className:"lg:w-1/2 min-h-0 flex-1 lg:flex-none border-b lg:border-b-0 border-border",children:(0,r.jsx)(k,{passage:eO,highlights:eO&&null!=(C=eq.bySection[eO.id])?C:[],onAdd:eq.add,onUp
1dateNote:eq.updateNote,onRemove:eq.remove})}),(0,r.jsx)("div",{className:"lg:w-1/2 min-h-0 flex-1 lg:flex-none",children:eO&&(0,r.jsx)(j.A,{sectionKey:eE(eO.id),highlights:null!=(M=eq.bySection[eE(eO.id)])?M:[],onAdd:eq.add,onUpdateNote:eq.updateNote,onRemove:eq.remove,children:eO.groups.map(e=>(0,r.jsx)(v.sK,{group:e},e.id))})})]}),(0,r.jsx)("footer",{className:"flex-shrink-0 border-t border-border bg-card",children:(0,r.jsxs)("div",{className:"px-3 sm:px-5 py-2 flex items-center gap-3 overflow-x-auto",children:[eP.map(e=>{let t=e.passageNumber===Z;return(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>D(e.passageNumber),className:"text-brand-caption font-semibold whitespace-nowrap transition-colors ".concat(t?"text-foreground":"text-muted-foreground hover:text-foreground"),children:["Part ",e.passageNumber,(0,r.jsxs)("span",{className:"ml-1.5 font-normal tabular-nums",children:[e.done," of ",e.total]})]}),t&&(0,r.jsx)("div",{className:"flex items-center gap-1",children:e.numbers.map(e=>{let t=(0,A.lq)(B[e]),s=G===e;return(0,r.jsx)("button",{type:"button",onClick:()=>eI(e),"aria-label":"Go to question ".concat(e).concat(t?" (answered)":""),className:"w-7 h-7 rounded-md border text-[11px] font-bold tabular-nums transition-colors ".concat(t?"border-module-accent bg-module-accent text-white":"border-border bg-background text-muted-foreground hover:border-foreground
1/30"," ").concat(s?"ring-2 ring-module-accent/40":""),children:e},e)})}),e.passageNumber<eP.length&&(0,r.jsx)("span",{className:"w-px h-6 bg-border"})]},e.passageNumber)}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1.5 flex-shrink-0",children:[(0,r.jsx)(x.$,{variant:"outline",size:"sm",disabled:Z<=1,onClick:()=>D(e=>Math.max(1,e-1)),"aria-label":"Previous part",className:"border-border w-9 px-0",children:(0,r.jsx)(d.A,{className:"w-4 h-4",strokeWidth:1.5})}),(0,r.jsx)(x.$,{variant:"outline",size:"sm",disabled:Z>=eM.length,onClick:()=>D(e=>Math.min(eM.length,e+1)),"aria-label":"Next part",className:"border-border w-9 px-0",children:(0,r.jsx)(c.A,{className:"w-4 h-4",strokeWidth:1.5})})]})]})})]}),(0,r.jsx)(p.Lt,{open:en,onOpenChange:el,children:(0,r.jsxs)(p.EO,{children:[(0,r.jsxs)(p.wd,{children:[(0,r.jsx)(p.r7,{children:"Submit your test?"}),(0,r.jsx)(p.$v,{asChild:!0,children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("p",{children:["You've answered ",(0,r.jsx)("strong",{className:"text-foreground",children:eL})," of ",J.totalQuestions," questions with ",(0,r.jsx)("strong",{className:"text-foreground",children:(0,A.ei)(ef)})," left."]}),eL<J.totalQuestions&&(0,r.jsxs)("p",{className:"flex items-start gap-2 text-warning",children:[(0,r.jsx)(u.A,{className:"w-4 h-4 flex-shrink-0 mt-0.5",strokeWidth:1.5}),J.totalQuestions-eL," question",J.totalQuestions-eL==1?"":"s"," left blank. There's no penalty for a
1wrong answer, so it's worth guessing."]}),(0,r.jsx)("p",{children:"Once submitted you can review every answer, but you can't change them."})]})})]}),(0,r.jsxs)(p.ck,{children:[(0,r.jsx)(p.Zr,{children:"Keep working"}),(0,r.jsxs)(p.Rx,{onClick:eA,children:[(0,r.jsx)(m.A,{className:"w-4 h-4 mr-1.5",strokeWidth:1.5}),"Submit"]})]})]})}),(0,r.jsx)(p.Lt,{open:ei,onOpenChange:eo,children:(0,r.jsxs)(p.EO,{children:[(0,r.jsxs)(p.wd,{children:[(0,r.jsx)(p.r7,{children:"Leave this test?"}),(0,r.jsx)(p.$v,{children:T?(0,r.jsx)(r.Fragment,{children:"Leaving ends your full mock. It cannot be resumed, the credits are not refunded, and it will not get an overall band. Sections you have already finished stay in your reports."}):(0,r.jsx)(r.Fragment,{children:"Your answers are saved. The clock pauses while you are away â pick this test up from the library and it continues where you left off."})})]}),(0,r.jsxs)(p.ck,{children:[(0,r.jsx)(p.Zr,{children:"Stay"}),(0,r.jsx)(p.Rx,{onClick:async()=>{if(await ek(),T){null==L||L();return}P.push("/ielts-reading")},children:T?"End the mock":"Leave"})]})]})})]})}},8112:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(74217).A)("highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]])},18270:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(74217).A)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},33731:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(74217).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},52350:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(74217).A)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]])},58489:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(74217).A)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},60747:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(74217).A)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},83535:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(74217).A)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},85670:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(74217).A)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},99485:(e,t,s)=>{s.d(t,{A:()=>r});let r=(0,s(74217).A)("sticky-note",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]])}}]);
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.