import{d as U,P as k,q as D,r as R,x as N,af as O,D as p,y as P,a8 as M,a as n,W as Q,A as l,C as T,Q as K,a3 as H,E as $,z as F,$ as z,R as A,S as q}from"./index-521a9826.js";import{e as f,Q as v,C as E,D as W,K as j,P as V,i as G,A as X,a as Y,R as J}from"./index-7695da7e.js";import{M as g}from"./index-c0ea6da9.js";import{u as Z,a as ee}from"./index-fdaad3c0.js";import{S as te,a as ne}from"./index-5b82f39e.js";import{I as se}from"./index-25b5c9d0.js";import"./index-1f2f0321.js";import"./index-544f4e19.js";import"./howler-302efa4a.js";import"./index-1ad6a58d.js";const ie="_unitDetail_13q27_1",oe="_unitSwipe_13q27_9",ae="_questionTitle_13q27_12",ue="_questionNum_13q27_21",le="_questionType_13q27_24",re="_wapList_13q27_31",ce="_btnSection_13q27_37",de="_prevBtn_13q27_42",pe="_nextBtn_13q27_43",fe="_activePrevBtn_13q27_44",ve="_right_13q27_67",we="_error_13q27_70",Ie="_minutes_13q27_73",i={unitDetail:ie,unitSwipe:oe,questionTitle:ae,questionNum:ue,questionType:le,wapList:re,btnSection:ce,prevBtn:de,nextBtn:pe,activePrevBtn:fe,right:ve,error:we,minutes:Ie};function he(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!H(r)}const Se=U({name:"unit-detail",setup(){const r=k(),w=D(),I=R(),e=N({type:r.query.type,knowledgePointIds:r.query.knowledgePointIds,lessonCoursewareId:r.query.lessonCoursewareId,studentUnitExaminationId:"",background:"transparent",color:"#fff",visiableAnswer:!1,examDetail:{},currentIndex:0,time:0,questionList:[],visiableInfo:{show:!1,operationType:"RESULT",type:"DEFAULT",content:"",showCancelButton:!1,confirmButtonText:"",cancelButtonText:"",title:""},nextStatus:!1,swipeHeight:"auto",countDownOver:!1}),u=O({time:e.time,onChange(s){if(3e5>=s.total&&!e.countDownOver){if(e.visiableInfo.show){e.countDownOver=!0;return}e.visiableInfo.show=!0,e.visiableInfo.title="倒计时5分钟",e.visiableInfo.showCancelButton=!1,e.visiableInfo.operationType="TIME",e.visiableInfo.type="COUNTDOWN",e.visiableInfo.confirmButtonText="确认",e.visiableInfo.content="距离交卷时间还剩五分钟哦,请尽快答题~",e.countDownOver=!0}},onFinish:async()=>{f.emit("unitAudioStop"),await m(),window.removeEventListener("popstate",c,!1),w.back()}}),L=async()=>{try{let s={};if(e.type==="ai"){const{data:t}=await p.post("/edu-app/studentUnitExamination/pointRandomSave",{data:{knowledgePointIds:e.knowledgePointIds}});s=t||{}}else{const{data:t}=await p.post("/edu-app/studentUnitExamination/mockExamination",{data:{lessonCoursewareId:e.lessonCoursewareId,knowledgePointIds:e.knowledgePointIds}});s=t||{}}s.examinationQuestionAdds.forEach(t=>{t.showAnalysis=!1,t.analysis={message:t.answerAnalysis,topic:!0,userResult:!1},t.userAnswer=[]}),e.questionList=s.examinationQuestionAdds||[],e.studentUnitExaminationId=s.unitExaminationId,e.examDetail=s||{},S()}catch(s){}},S=async()=>{const t=(e.examDetail||{}).timeMinutes||0;e.time=Math.ceil(t*60*1e3),setTimeout(()=>{u.reset(t*60*1e3),u.start()},10)},_=async()=>{var s,t;e.nextStatus=!0;try{const a=e.questionList||[],o=a[e.currentIndex];if(((s=o==null?void 0:o.userAnswer)==null?void 0:s.length)<=0){$("题目尚未做答"),e.nextStatus=!1;return}const y=[];if(a.forEach((d,x)=>{d.userAnswer&&d.userAnswer.length>0&&y.push({questionId:d.id,details:d.userAnswer})}),e.questionList.length===e.currentIndex+1){f.emit("unitAudioStop"),e.visiableInfo.show=!0,e.visiableInfo.title="测验完成",e.visiableInfo.showCancelButton=!0,e.visiableInfo.operationType="CONTINUE",e.visiableInfo.type="DEFAULT",e.visiableInfo.cancelButtonText="再等等",e.visiableInfo.confirmButtonText="确认完成",e.visiableInfo.content="确认本次测验的题目都完成了吗?",e.nextStatus=!1,window.removeEventListener("popstate",c,!1),w.back();return}await p.post("/edu-app/studentUnitExamination/submitAnswer",{hideLoading:!0,data:{answers:y,studentUnitExaminationId:e.studentUnitExaminationId}}),(t=I.value)==null||t.next()}catch(a){}e.nextStatus=!1};let b=0;const h=(s=!0)=>{F(()=>{s&&window.scrollTo(0,0),setTimeout(()=>{var d;const t=(d=document.querySelectorAll(".van-swipe-item")[e.currentIndex])==null?void 0:d.querySelector(".swipe-item-question"),a=t==null?void 0:t.querySelectorAll(".answerTitleImg img");let o=!0;a==null||a.forEach(x=>{x.complete||(o=!1)}),!o&&b<3&&setTimeout(()=>{b+=1,h(s)},300),o&&(b=0);const y=z(t);e.swipeHeight=y.height},100)})},B=()=>{e.visiableInfo.operationType==="RESULT"?(e.visiableInfo.show=!1,A().isApp&&e.type!=="ai"?q({api:"back"}):(window.removeEventListener("popstate",c,!1),w.go(-2))):e.visiableInfo.operationType==="BACK"||e.visiableInfo.operationType==="CONTINUE"?m():e.visiableInfo.operationType==="TIME"&&(e.visiableInfo.show=!1)},C=async s=>{if(e.visiableInfo.operationType==="BACK"){if(s){e.visiableInfo.show=!1,window.history.pushState(null,"",document.URL),window.addEventListener("popstate",c,!1);return}try{await p.get("/edu-app/studentUnitExamination/dropExamination",{params:{studentUnitExaminationId:e.studentUnitExaminationId}}),e.visiableInfo.show=!1,A().isApp&&e.type!=="ai"?q({api:"back"}):(window.removeEventListener("popstate",c,!1),w.go(-2))}catch(t){}}else e.visiableInfo.operationType==="CONTINUE"&&(e.visiableInfo.show=!1,window.history.pushState(null,"",document.URL),window.addEventListener("popstate",c,!1))},m=async()=>{try{const s=e.questionList||[],t=[];s.forEach(o=>{o.userAnswer&&o.userAnswer.length>0&&t.push({questionId:o.id,details:o.userAnswer})});const{data:a}=await p.post("/edu-app/studentUnitExamination/completionExamination",{hideLoading:!1,data:{answers:t,studentUnitExaminationId:e.studentUnitExaminationId}});e.visiableInfo.show=!0,e.visiableInfo.title=a.score+"分",e.visiableInfo.showCancelButton=!1,e.visiableInfo.operationType="RESULT",e.visiableInfo.confirmButtonText="确认",a.status==="A_EXCELLENT"?(e.visiableInfo.type="GOOD",e.visiableInfo.content="