1import{bf as C,f as O,r as o,bp as J,ab as U,j as e,B as A,c as R,bg as z,am as V,bE as X,bl as Z}from"./index-B4_lKB0j.js";import{u as _,a as ee}from"./mutations-CNPERWhe.js";import{S as se}from"./spinner-BnOsT7Xf.js";import{u as c,a as B,g as te,E as ne,S as ie,s as M,r as oe,b as ae,T as re,c as le,e as ue,f as ce}from"./exam-review-PJcWoxea.js";import{P as de,a as me,b as xe}from"./question-answer-gHDdcCpm.js";import{S as fe}from"./arrow_left-C0ADZkFO.js";import{S as ge}from"./arrow_right-Bw3fXVy3.js";import{b as pe,r as be,C as he,c as L,a as ve,P as je,F as we,S as ye}from"./cursor-memory-B3E6c14Z.js";import{Q as Se}from"./question-navigator-BEs0-vIC.js";import{S as Ne,a as Ie}from"./chevron_right_icon-DvCXrcJA.js";import{S as Ee}from"./list_icon-D1WowWB2.js";import"./poll-DLGsfAr9.js";import"./bookmark_icon-B7uoWVtU.js";import"./search_icon-CSlyrV_Y.js";import"./highlighter_icon-B1RYi46l.js";import"./queries-Bb_Y_seP.js";import"./loading_icon-DpoaPnF2.js";import"./format-timer-time-BD8VfAPb.js";import"./use-exam-instructions-Iy5lyYX3.js";import"./check_icon-DcKto_lO.js";import"./tooltip-wrapper--2PwgTMl.js";import"./marker_icon-C2eBNoGY.js";import"./instruction-html-Bc4py9-C.js";import"./flag_icon-CN-cjVKi.js";import"./proctor-storage-KIziptYz.js";import"./clock_icon-DIppvskh.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"3b04a436aaa09b871bbc9aaf912981fe6a3097f5"};var i=new a.Error().stack;i&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[i]="423d470c-80c5-4d1f-bf0f-df5d58333613",a._sentryDebugIdIdentifier="sentry-dbid-423d470c-80c5-4d1f-bf0f-df5d58333613")}catch{}})();const Ae=({isSubmitOpen:a,setIsSubmitOpen:i})=>{const{assignmentId:r}=C(),x=O(),p=o.useRef(null),f=o.useRef(null),d=o.useRef(null),l=c(n=>n.questions),s=c(M),g=c(n=>n.questionId),v=c(n=>n.updateQuestion),t=c(n=>n.setQuestionId),m=c(n=>n.questions.find(u=>u.id===f.current)||null),y=_(r),h=ee(),{takeAndReset:S}=B(),j=te(),w=o.useRef(!1),[k,P]=o.useState(!1),[T,F]=o.useState(!1),H=()=>{h.mutate(r,{onSuccess:async()=>{await z(),x("/assignments")}})},N=o.useCallback(async()=>{if(s){const n=s.answer||"",u=d.current||"";if(n!==u){const{solveTime:b,activeTime:I}=S();let q=!1;for(let E=1;E<=3&&!q;E++)try{await y.mutateAsync({questionId:s.id,userAnswer:n,isBookmarked:!1,solveTime:b,activeTime:I}),q=!0}catch(D){if(E<3){await new Promise($=>setTimeout($,400*E));continue}D instanceof Error&&J(D,{source:"assignment-footer/autoSubmitFlush",questionId:s.id})}if(!q){P(!0),U.error("Couldn't save your last answer. Please retry before the section is submitted.");return}}}P(!1),H()},[s,y,S]),Q=!s,W=l.filter(n=>n.answer).length,Y=o.useCallback(async()=>{F(!0);try{await N()}finally{F(!1)}},[N]);o.useEffect(()=>{if(f.current&&f.current!==g){const{solveTime:n,activeTime:u}=S();if(m){const b=m.answer||"",I=d.current||"";b!==I&&y.mutate({questionId:m.id,userAnswer:b,isBookmarked:!1,solveTime:n,activeTime:u},{onError:()=>{v(m.id,{answer:I})}})}}f.current=g,d.current=s?.answer||null},[g]),o.useEffect(()=>{j.isRunning||j.totalSeconds>0||w.current||h.status!=="idle"||(w.current=!0,N())},[j.isRunning,j.totalSeconds]);const G=()=>{if(s){const n=s.questionNo-1,u=l.find(b=>b.questionNo===n);u&&t(u.id)}else t(l[l.length-1].id)},K=()=>{if(s)if(s.questionNo===l.length)t(null);else{const n=s.questionNo+1,u=l.find(b=>b.questionNo===n);u&&t(u.id)}else i(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t bg-bg-default py-5 sticky bottom-0",children:e.jsx("div",{className:"max-w-[1282px] mx-auto px-4 relative",children:e.jsxs("div",{ref:p,className:"flex justify-between",children:[e.jsxs(A,{variant:"text",onClick:G,className:R(s?.questionNo===1&&"opacity-0","text-[13px] lg:text-[15px]"),children:[e.jsx(fe,{className:"size-3 lg:size-4 mr-2"}),"Previous"]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden lg:block text-base text-navy-blue font-medium rounded-lg py-[14px] px-[17px]",style:{background:"linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0%, rgba(0, 0, 0, 0.06) 100%), rgba(203, 220, 242, 0.05)"},children:["Question ",s.questionNo," of ",l.length]}),e.jsxs(de,{children:[e.jsx(me,{className:"lg:hidden cursor-pointer",children:e.jsxs("div",{className:"text-[13px] text-navy-blue font-medium rounded-lg py-[11px] px-[13px]",style:{background:"linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0%, rgba(0, 0, 0, 0.06) 100%), rgba(203, 220, 242, 0.05)"},children:["Question ",s.questionNo," of ",l.length]})}),e.jsx(xe,{className:"border border-brand-border p-[20px] shadow-[0px_5px_10px_0px_#30313D1A] rounded-[16px] bg-white",children:e.jsx(ne,{})})]})]}),e.jsxs(A,{onClick:K,disabled:h.status==="pending",className:R("h-[42px] lg:h-[48px] text-[13px] lg:text-base",Q?"px-5 lg:px-6":"w-[82px] lg:w-[108px]"),children:[Q?"Submit Assignment":"Next",!Q&&e.jsx(ge,{className:"size-4 ml-2"})]})]})})}),e.jsx(pe,{isOpen:a,setIsOpen:i,subject:"assignment",answeredCount:W,totalCount:l.length,isSubmitting:h.status==="pending",onConfirm:()=>{i(!1),N()}}),e.jsx(ie,{isOpen:h.status==="pending",setIsOpen:()=>{},container:p,title:"This section is over"}),k&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl bg-white p-6 shadow-xl",children:[e.jsx("h2",{className:"text-lg font-semibold text-navy-blue",children:"We couldn't save your last answer"}),e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Time is up, but your most recent answer hasn't been recorded yet. Please retry so it isn't lost â the section will be submitted once it saves."}),e.jsx("div",{className:"mt-5 flex justify-end",children:e.jsx(A,{onClick:Y,disabled:T,className:"h-[44px] px-6 text-sm",children:T?"Retryingâ¦":"Retry & submit"})})]})})]})},ke="w-[280px]",Qe="w-11",qe=({examId:a,type:i})=>{const r=c(t=>t.questions),x=c(t=>t.questionId),p=c(t=>t.setQuestionId),{data:f}=V({examId:a,questionId:x,type:i}),d=f?oe(f,!1).useResizable:!1,[l,s]=o.useState(!d),g=o.useRef(!1);o.useEffect(()=>{g.current||s(!d)},[d]);const v=()=>{g.current=!0,s(t=>!t)};return x===null?null:e.jsx("aside",{className:R("hidden lg:block shrink-0 transition-[width] duration-300 ease-out",l?ke:Qe),children:e.jsx("div",{className:"sticky top-[103px] mt-12",children:l?e.jsx(Se,{title:"Questions",items:r.map((t,m)=>({id:t.id,label:m+1,isCurrent:t.id===x,isMarked:t.isBookmarked,state:t.answer!==""?"answered":"blank"})),onSelect:p,legendStates:["answered","blank"],headerAction:e.jsx("button",{type:"button","aria-label":"Hide question list",onClick:v,className:"size-6 rounded-md flex items-center justify-center cursor-pointer hover:bg-navy-blue/5 transition-colors",children:e.jsx(Ne,{className:"size-3"})}),footer:e.jsx("div",{className:"flex justify-center",children:e.jsx(A,{variant:"outline",className:"rounded-[16px]",onClick:()=>p(null),children:"Go to Review Page"})})}):e.jsxs("button",{type:"button","aria-label":"Show question list",onClick:v,className:"w-9 py-3 flex flex-col items-center gap-2 rounded-xl border border-brand-border bg-white shadow-card cursor-pointer hover:bg-gray-50 transition-colors",children:[e.jsx(Ie,{className:"size-3"}),e.jsx(Ee,{className:"size-3.5"})]})})})},is=()=>{const{assignmentId:a}=C(),{data:i,status:r}=X(a);if(r==="pending")return e.jsx("div",{className:"flex items-center justify-center h-screen",children:e.jsx(se,{size:"lg"})});if(r==="error")return e.jsx("div",{className:"flex items-center justify-center h-screen",children:e.jsx("p",{className:"text-[22px] font-semibold leading-[31px]",children:"Something went wrong"})});const x=Z({limitSeconds:i.timeLimitSeconds,startedAt:i.startDate,deadline:i.deadline});return e.jsxs(ae,{title:i.title,questionId:be(i.questions,ve(L(a))),questions:i.questions,duration:i.duration,children:[e.jsx(he,{scope:L(a)}),e.jsx(Re,{secondsLeft:x,isTimed:i.timeLimitSeconds!=null})]})},Re=({secondsLeft:a,isTimed:i})=>{const{assignmentId:r}
1=C(),x=O(),p=o.useRef(null),[f,d]=o.useState(!1),[l,s]=o.useState(!1),[g,v]=o.useState(!1),t=c(w=>w.questionId),m=c(M),y=_(r),{takeAndReset:h}=B(),S=t===null,j=async()=>{if(v(!0),m?.answer){const{solveTime:w,activeTime:k}=h();try{await y.mutateAsync({questionId:m.id,userAnswer:m.answer,isBookmarked:!1,solveTime:w,activeTime:k})}catch{}}await z(),x("/assignments")};return e.jsx(je,{sessionId:`assignment:${r}`,subject:"assignment",children:e.jsx(re,{durationInSeconds:a,children:e.jsx(we,{subject:"assignment",actionLabel:"Resume Assignment",children:e.jsxs("div",{className:"flex flex-col min-h-screen",children:[e.jsx(le,{container:p,type:"assignment",examId:r,onExit:()=>d(!0),isExiting:g,onSubmit:()=>s(!0)}),e.jsxs("div",{className:"flex flex-1 mx-auto px-4 max-w-[1250px] w-full gap-5",children:[e.jsx("div",{ref:p,className:"flex flex-col flex-1 min-w-0 relative",children:S?e.jsx(ue,{}):e.jsx(ce,{type:"assignment",examId:r},t)}),e.jsx(qe,{examId:r,type:"assignment"})]}),e.jsx(Ae,{isSubmitOpen:l,setIsSubmitOpen:s}),e.jsx(ye,{isOpen:f,setIsOpen:d,subject:"assignment",isTimed:i,returnNote:"Your answers are saved. You can come back before the due date.",isExiting:g,onConfirm:j})]})})})})};export{is as AssignmentPage,Re as AssignmentQuestion};
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.