openlearn-next 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/assets/{ActivityWorkspaceWidget-5PzyxF6a.js → ActivityWorkspaceWidget-CMN8elwQ.js} +1 -1
  2. package/dist/assets/{AdminDirectoryView-BCtmQTEK.js → AdminDirectoryView-Dlz7q-xf.js} +1 -1
  3. package/dist/assets/{AssessmentCenter-B43ojHG-.js → AssessmentCenter-CaoAI9Ke.js} +1 -1
  4. package/dist/assets/{BatchPickerModal-CbmjInp7.js → BatchPickerModal-CzutdtIz.js} +1 -1
  5. package/dist/assets/{ClassesView-DEnMaDOt.js → ClassesView-RkFPpWRu.js} +1 -1
  6. package/dist/assets/{ClassroomCountdownWidget-CHq4983w.js → ClassroomCountdownWidget-gs42lIGW.js} +1 -1
  7. package/dist/assets/{CloudDriveModal-D2t3Uyzr.js → CloudDriveModal-C6JtK08M.js} +1 -1
  8. package/dist/assets/{ComputerLabView-YtnoT5Rb.js → ComputerLabView-Dr-g8FrU.js} +1 -1
  9. package/dist/assets/{CourseManagement-DOXyJ_j-.js → CourseManagement-DNeaJcT9.js} +1 -1
  10. package/dist/assets/{CourseWizardModal-Dbi6Caw2.js → CourseWizardModal-vw876VJr.js} +1 -1
  11. package/dist/assets/{Dashboard-2rLu_ZBy.js → Dashboard-C1iYnfCh.js} +1 -1
  12. package/dist/assets/{ExportWeightModal-BrmAh6VX.js → ExportWeightModal-CTZ-O_wi.js} +1 -1
  13. package/dist/assets/{HelpView-CVBrKDrd.js → HelpView-wyKldm_R.js} +1 -1
  14. package/dist/assets/{ImportLessonsModal-PhHtX31R.js → ImportLessonsModal-C09Z-qtx.js} +1 -1
  15. package/dist/assets/{InteractiveCoursewareViewer-Vi6lLz7a.js → InteractiveCoursewareViewer-V97euiJF.js} +1 -1
  16. package/dist/assets/{InteractiveWhiteboard-lTzeayX5.js → InteractiveWhiteboard-COLMh_-w.js} +1 -1
  17. package/dist/assets/{LazyCourseware-KIt0rGtW.js → LazyCourseware-0iFYlRGj.js} +2 -2
  18. package/dist/assets/{LazyWhiteboard-CCN3pYcW.js → LazyWhiteboard-CcoBIx6V.js} +2 -2
  19. package/dist/assets/{LessonEditorView-D_GVhHuM.js → LessonEditorView-BWmtKwmP.js} +1 -1
  20. package/dist/assets/{LiveClassroomView-BRsZ6QEq.js → LiveClassroomView-CaS1DzSS.js} +1 -1
  21. package/dist/assets/{NotificationDetailModal-tY5rxYCN.js → NotificationDetailModal-4MdNF4tw.js} +1 -1
  22. package/dist/assets/{PluginView-CedpAW6d.js → PluginView-BqTbAp30.js} +1 -1
  23. package/dist/assets/{QuizGeneratorModal-bUA002kP.js → QuizGeneratorModal-xTq22vDq.js} +1 -1
  24. package/dist/assets/{StudentAssignmentView-BhAz6Hfk.js → StudentAssignmentView-Cy_JdPYB.js} +1 -1
  25. package/dist/assets/{StudentLessonView-DC1yX4kG.js → StudentLessonView-B3fKejCU.js} +1 -1
  26. package/dist/assets/{StudentView-PHKxIV9T.js → StudentView-CpJsG7FT.js} +2 -2
  27. package/dist/assets/{SystemResourceLibraryModal-DgXYe6_x.js → SystemResourceLibraryModal-YZ85mv_v.js} +1 -1
  28. package/dist/assets/{TeacherView-DscJtOJ9.js → TeacherView-B3zhzd5g.js} +2 -2
  29. package/dist/assets/{TimetableView-D2ozoj_D.js → TimetableView-D_4XmrRN.js} +1 -1
  30. package/dist/assets/{index-2676X8YB.js → index-BzXADCXZ.js} +5 -5
  31. package/dist/assets/{pluginParsers-e4PSm2Iy.js → pluginParsers-PzgFzxS9.js} +1 -1
  32. package/dist/cli-migrator.cjs +18 -1
  33. package/dist/index.html +1 -1
  34. package/dist/server.cjs +339 -249
  35. package/package.json +3 -2
@@ -1 +1 @@
1
- import{r as j,j as e}from"./vendor-react-Kv_JATwr.js";import{u as le}from"./StudentView-PHKxIV9T.js";import{L as Q,f as de,B as ce,l as xe,m as me,q as se,R as G,a8 as te,b3 as be,$ as ge,C as fe,k as pe,O as je,a as ve,w as ye,a3 as ue,p as we,aY as ke,ao as Ne,X as Se,c as Ce,aA as ze,b4 as Le,e as $e}from"./vendor-icons-CXrZ3R2V.js";import{E as B,M as Pe,s as K,f as re}from"./index-2676X8YB.js";import{L as _e}from"./LazyWhiteboard-CCN3pYcW.js";import{L as Ie}from"./LazyCourseware-KIt0rGtW.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-pdf-C1Vh2Aqq.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-SrpBsvM3.js";function Ae({lessonId:r,lang:s,addToast:d}){const[o,p]=j.useState(""),[i,u]=j.useState("idle"),[f,y]=j.useState("");if(j.useEffect(()=>{p(""),u("idle"),y("")},[r]),!r)return null;const c=async()=>{const x=o.trim();if(!x){u("error"),y(s==="zh"?"请先输入签到码":"Enter the check-in code first");return}u("submitting"),y("");try{const C=await fetch(`/api/classroom/sessions/${encodeURIComponent(r)}/checkin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:x})}),h=await C.json().catch(()=>({}));if(!C.ok||!h.success){u("error");const m=h.error==="Invalid checkin code"?s==="zh"?"签到码不正确,请核对大屏后重试":"Wrong code, check the stage display and retry":h.error||(s==="zh"?"签到失败,请稍后重试":"Check-in failed, retry later");y(m);return}u("done");const z=h.attendanceScheduled!==!1;y(z?s==="zh"?"签到成功,出勤已记录":"Checked in, attendance recorded":s==="zh"?"签到成功(本课节未关联排课,未计入正式出勤)":"Checked in (no schedule linked; not counted in official attendance)"),d(s==="zh"?"签到成功":"Checked in",z?s==="zh"?"出勤已记录":"Attendance recorded":s==="zh"?"会话级签到,未计入正式出勤":"Session-level check-in only","success")}catch{u("error"),y(s==="zh"?"网络异常,请稍后重试":"Network error, retry later")}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 bg-surface border border-theme rounded-xl px-3 py-2 shadow-sm text-main",children:[e.jsx("span",{className:"text-xs font-bold",children:s==="zh"?"课堂签到":"Check-in"}),i==="done"?e.jsxs("span",{className:"text-xs font-bold text-emerald-600",children:["✓ ",f]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{value:o,onChange:x=>p(x.target.value.replace(/\s/g,"").slice(0,12)),onKeyDown:x=>{x.key==="Enter"&&c()},placeholder:s==="zh"?"输入大屏 4 位签到码":"4-digit code on stage display",inputMode:"numeric","aria-label":s==="zh"?"课堂签到码":"Class check-in code",className:"w-44 px-2 py-1 text-sm font-mono tracking-widest border border-theme rounded-lg bg-transparent"}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:i==="submitting",className:"px-3 py-1 text-xs font-bold rounded-lg bg-indigo-600 text-white hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:i==="submitting"?s==="zh"?"提交中…":"Submitting…":s==="zh"?"签到":"Check in"})]}),i==="error"&&f&&e.jsx("span",{className:"text-xs text-rose-600",children:f})]})}function Ee(r){const{students:s,activeStudentId:d,isStudentLocked:o=!1,lockMode:p,setStudentViewStatus:i,setSelectedLesson:u,lessons:f,selectedLesson:y,lang:c="zh",addToast:x,onOpenIcebreaker:C}=r,h=le($=>$.activeSession),z=s.find($=>$.id===d),m=o||!!z?.locked_lesson_id,N=(p||z?.lock_mode||"full")==="navigation";return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[m?N?e.jsxs("div",{className:"text-amber-800 font-semibold text-sm flex items-center gap-2 px-3 py-1.5 rounded-lg bg-amber-50 border border-amber-200 shadow-3xs select-none",role:"status",title:c==="zh"?"答题锁定中 · 请完成作答后提交,暂时无法离开本页":"Answer Locked · Complete and submit your work before leaving",children:[e.jsx(Q,{size:15,className:"text-amber-600 shrink-0"}),c==="zh"?"答题锁定中 · 请完成作答后提交,暂时无法离开本页":"Answer Locked · Complete and submit work"]}):e.jsxs("div",{className:"text-indigo-700 font-semibold text-sm flex items-center gap-2 px-3 py-1.5 rounded-lg bg-indigo-50 border border-indigo-200 shadow-3xs select-none",role:"status",title:c==="zh"?"老师已开启全班专注锁定,您暂时无法切换页面":"The teacher locked the class focus. Navigating away is disabled.",children:[e.jsx(Q,{size:15,className:"text-indigo-600 shrink-0"}),c==="zh"?"全班专注锁定 · 跟随教师授课":"Class Focus Locked · Following Teacher"]}):e.jsxs("button",{onClick:()=>{i("dashboard"),u(null),h&&x?.(c==="zh"?"课堂仍在进行":"Class still in progress",c==="zh"?`可随时从看板顶部的「${h.lessonTitle} · 返回课堂」回到课堂。`:"You can return anytime via the banner at the top of your dashboard.","info")},className:"flex items-center gap-2 text-indigo-600 hover:text-indigo-800 transition-colors font-medium text-sm cursor-pointer",children:[e.jsx(de,{className:"rotate-180",size:16})," Back to Dashboard"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[C&&e.jsxs("button",{type:"button","data-testid":"open-icebreaker-btn",onClick:C,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-amber-200 dark:border-amber-800/60 bg-amber-50/80 hover:bg-amber-100/80 dark:bg-amber-950/30 dark:hover:bg-amber-950/50 text-amber-900 dark:text-amber-200 text-xs font-semibold shadow-3xs transition-colors cursor-pointer",title:c==="zh"?"课前破冰心情打卡":"Pre-class Icebreaker Check-in",children:[e.jsx("span",{children:"✨"}),e.jsx("span",{children:c==="zh"?"心情打卡":"Mood Check-in"})]}),e.jsx("h2",{className:"text-xl font-bold text-gray-800 dark:text-gray-100",children:f.find($=>$.id===y)?.title})]})]})}function Fe(r){const{students:s,activeStudentId:d,isStudentLocked:o=!1,studentFullscreenPanel:p,setStudentFullscreenPanel:i,timelineSegments:u,lang:f,activeSegmentId:y,localProgressPercent:c,setLocalProgressPercent:x,updateStudentProgress:C,selectedLesson:h,lessons:z,isStudentLessonContentCollapsed:m,addToast:k,segmentAccess:N}=r,$=a=>{if(!a?.id||y===a.id)return;k?.(f==="zh"?"请跟随课堂":"Follow the class",f==="zh"?"请跟随课堂当前环节":"Please follow the current class segment","warning")};return e.jsxs("div",{className:`${m?"hidden":p==="left"?"w-full":"w-1/3 md:block hidden"} border-gray-100 pr-4 overflow-y-auto ${p==="right"?"hidden":""} ${p==="left"?"":"border-r"} transition-all duration-300`,children:[e.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 mb-4 flex items-center justify-between pointer-events-auto shrink-0 select-none border-b border-gray-100 pb-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ce,{size:14,className:"text-indigo-500"})," Lesson Content (课程内容)"]}),e.jsx("button",{onClick:()=>i(a=>a==="left"?"none":"left"),className:"p-1 hover:bg-gray-100 text-subtle hover:text-main rounded transition-colors cursor-pointer flex items-center gap-1",title:p==="left"?"退出全屏":"全屏",children:p==="left"?e.jsxs(e.Fragment,{children:[e.jsx(xe,{size:13}),e.jsx("span",{className:"text-xs font-medium",children:"退出全屏"})]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{size:13}),e.jsx("span",{className:"text-xs font-medium",children:"全屏"})]})})]}),e.jsxs("div",{className:"prose prose-sm prose-indigo max-w-none",children:[!o&&!s.find(a=>a.id===d)?.locked_lesson_id&&u.length>0&&e.jsxs("div",{className:"mb-4 flex flex-col gap-2 p-3 bg-slate-50/70 border border-slate-200/50 rounded-xl shadow-3xs text-left",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider flex items-center gap-1.5 mb-1 select-none",children:[e.jsx(se,{size:12,className:"text-indigo-500"}),f==="zh"?"教学环节 (点击切换)":"Timeline Segments"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:u.map((a,S)=>{const L=y===a.id,P=L&&N?.status==="locked";return e.jsxs("button",{onClick:()=>$(a),title:P?N?.reason||"未满足进入条件":void 0,className:`px-2.5 py-1 text-xs font-semibold rounded-lg border transition-all cursor-pointer shadow-3xs flex items-center gap-1.5 ${a.color} ${L?"ring-2 ring-indigo-500 scale-[1.02] shadow-sm border-indigo-400 font-bold":"opacity-85 hover:opacity-100"}`,children:[P&&e.jsx(Q,{size:11,className:"text-amber-600 shrink-0"}),e.jsxs("span",{children:[a.title," (",a.duration,")"]}),e.jsx(B,{slot:"student.segment.badge",slotProps:{segment:a,idx:S,isActive:L,isLocked:!!P,studentId:d,lessonId:h,lang:f}})]},a.id||S)})})]}),e.jsxs("div",{className:"mb-4 bg-slate-50 p-2.5 rounded-xl border border-slate-200/60 shadow-3xs flex flex-col gap-1.5 text-left select-none",children:[e.jsxs("div",{className:"flex justify-between items-center text-xs font-bold text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(se,{size:12,className:"text-indigo-500 animate-pulse"}),f==="zh"?"自主学习进度(教师确认后计入成绩)":"Learning Progress (graded after teacher verification)"]}),e.jsxs("span",{className:"font-mono text-indigo-600 font-extrabold",children:[c,"%"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"range",min:"0",max:"100",value:c,onChange:a=>{const S=parseInt(a.target.value);x(S)},onMouseUp:()=>C(c),onTouchEnd:()=>C(c),className:"flex-grow h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),e.jsx("button",{onClick:()=>{x(100),C(100)},className:`text-xs font-bold rounded-lg px-2 py-1 transition-all ${c===100?"bg-emerald-100 text-emerald-700 border border-emerald-200":"bg-white hover:bg-slate-50 text-slate-650 border border-slate-200 hover:border-indigo-200 shadow-3xs cursor-pointer"}`,children:f==="zh"?"已完成":"Done"})]})]}),e.jsx(Pe,{children:z.find(a=>a.id===h)?.content||""})]})]})}function Re(r){if(!r)return"";const s=r.split("/");return s[s.length-1]||r}function ne(r){const s=Re(r?.file_path);if(s)return s;const d=Array.isArray(r?.files)?r.files:[];return d.length===1?d[0]?.name||"附件":d.length>1?`${d.length} 个附件`:r?.textContent?"文字作答":r?.linkUrl?"链接作答":"已提交(无附件)"}function ae(r,s){return!s?.fileId||!r?.assignment_id?null:`/api/assignments/${r.assignment_id}/files/${s.fileId}`}function Te({lessonId:r,studentId:s,lang:d,addToast:o}){const[p,i]=j.useState(!1),[u,f]=j.useState(!1),[y,c]=j.useState(null),[x,C]=j.useState([]),[h,z]=j.useState(""),[m,k]=j.useState(!1),[N,$]=j.useState({}),[a,S]=j.useState({}),[L,P]=j.useState({}),n=d==="zh",A=async(t=!1)=>{t?f(!0):i(!0);try{const b=await(await fetch(`/api/lessons/${r}/students/${s}/eval-status`)).json();c(b);const _=await(await fetch(`/api/lessons/${r}/eval-submissions`)).json();C(_)}catch(g){console.error("Error fetching eval data:",g),o(n?"数据加载失败":"Failed to Load Data",n?"请检查网络连接或刷新页面。":"Please check your connection and try again.","warning")}finally{i(!1),f(!1)}};j.useEffect(()=>{r&&s&&A()},[r,s]);const D=async t=>{t.preventDefault(),h.trim(),k(!0);try{const b=await(await fetch(`/api/lessons/${r}/eval-submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:s,filePath:h.trim()||void 0})})).json();if(b.success)o(n?"作业提交成功":"Assignment Submitted",n?`成功提交版本 ${b.version}!`:`Successfully submitted version ${b.version}!`,"success"),A(!0);else throw new Error(b.error||"Failed to submit assignment")}catch(g){o(n?"提交失败":"Submission Failed",g.message,"warning")}finally{k(!1)}},R=async(t,g)=>{const b=N[t],l=a[t]||"";if(b===void 0||isNaN(b)||b<0||b>100){o(n?"评分无效":"Invalid Score",n?"分数必须在 0 到 100 之间!":"Score must be between 0 and 100!","warning");return}P(_=>({..._,[t]:!0}));try{const U=await(await fetch(`/api/lessons/${r}/eval-submissions/${t}/reviews`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:Number(b),comment:l})})).json();if(U.success)o(n?"互评提交成功":"Review Submitted",n?"成功对同学的作品完成了评价!":"Successfully completed review for classmate!","success"),S(H=>{const E={...H};return delete E[t],E}),A(!0);else throw new Error(U.error||"Failed to submit review")}catch(_){o(n?"评价提交失败":"Review Failed",_.message,"warning")}finally{P(_=>({..._,[t]:!1}))}};if(p)return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-gray-500",children:[e.jsx(G,{className:"animate-spin text-indigo-500 mb-2",size:32}),e.jsx("p",{children:n?"正在读取作业互评状态...":"Loading assignment status..."})]});const v=y?.submission,I=K(v?.linkUrl),w=y?.grade,T=y?.reviewsWritten||[],M=x.filter(t=>t.student_id!==s);return e.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-6 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"w-full lg:w-5/12 flex flex-col gap-6",children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs text-left",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 select-none",children:[e.jsx(te,{size:16,className:"text-indigo-600"}),n?"我的作业提交":"My Assignment Submission"]}),e.jsx("button",{onClick:()=>A(!0),className:"p-1 hover:bg-slate-200/50 rounded transition-colors text-slate-550",title:n?"刷新数据":"Refresh Data",children:e.jsx(G,{size:14,className:u?"animate-spin":""})})]}),v?e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-xl space-y-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-emerald-50 text-emerald-600 p-2.5 rounded-lg border border-emerald-100",children:e.jsx(be,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-400 font-medium",children:n?"当前已提交版本":"Currently Submitted Version"}),e.jsx("p",{className:"text-sm font-semibold text-slate-700 truncate",children:ne(v)})]}),e.jsxs("span",{className:"bg-indigo-100 text-indigo-700 text-xs font-bold px-2 py-0.5 rounded-full border border-indigo-200",children:["V",v.version]})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-2.5 flex justify-between items-center text-xs text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ge,{size:11}),n?"更新时间:":"Updated At:"," ",new Date(v.updated_at).toLocaleString()]}),e.jsx("span",{className:"font-mono text-slate-350 select-all truncate max-w-[120px]",title:v.file_path||void 0,children:v.file_path||"—"})]}),(v.textContent||v.linkUrl||Array.isArray(v.files)&&v.files.length>0)&&e.jsxs("div",{className:"border-t border-slate-100 pt-2.5 space-y-1 text-xs text-slate-600",children:[v.textContent&&e.jsx("p",{className:"whitespace-pre-wrap break-all max-h-20 overflow-hidden",children:v.textContent}),I&&e.jsx("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-indigo-600 hover:underline",children:v.linkUrl}),Array.isArray(v.files)&&v.files.map((t,g)=>{const b=K(ae(v,t));return b?e.jsx("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-indigo-600 hover:underline",children:t.name},t.fileId??g):e.jsx("span",{className:"block truncate",children:t.name},t.name??g)})]}),e.jsx(B,{slot:"assignment.submission.preview",slotProps:{submission:v,studentId:s,lessonId:r,isSelf:!0,lang:d}})]}):e.jsxs("div",{className:"bg-amber-50/50 border border-amber-100 p-4 rounded-xl flex items-start gap-3 mb-4 text-left",children:[e.jsx(fe,{className:"text-amber-500 shrink-0 mt-0.5",size:16}),e.jsxs("div",{className:"text-xs text-amber-700",children:[e.jsx("p",{className:"font-bold",children:n?"未提交作业":"No Submission Yet"}),e.jsx("p",{className:"mt-1",children:n?"在此上传提交后,其他同学将可以对您的作业进行评分互评。":"Once submitted, other students can view and peer-review your work."})]})]}),e.jsx("form",{onSubmit:D,className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:n?"输入作品文件路径 / 虚拟路径":"Simulated File Path"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:h,onChange:t=>z(t.target.value),placeholder:"/files/homework.pdf",required:!0,className:"flex-1 bg-white border border-slate-200 px-3 py-2 text-xs rounded-lg text-slate-700 focus:outline-none focus:border-indigo-400 font-mono transition-colors"}),e.jsxs("button",{type:"submit",disabled:m,className:"bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs px-4 py-2 rounded-lg transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1.5 shadow-3xs",children:[m?e.jsx(G,{className:"animate-spin",size:13}):e.jsx(te,{size:13}),v?n?"重新提交":"Re-submit":n?"上传作品":"Submit"]})]})]})})]}),v&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs text-left",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-4 select-none",children:[e.jsx(pe,{size:16,className:"text-pink-650"}),n?"我的平时学习得分":"My Score & Feedback"]}),w?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-xl flex items-center justify-between shadow-3xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-slate-400 font-bold uppercase tracking-wider",children:n?"学期对接总分":"Weighted Final Grade"}),e.jsxs("h2",{className:"text-3xl font-extrabold text-indigo-700 font-mono mt-1",children:[w.calculated_final_score," ",e.jsx("span",{className:"text-xs text-slate-455 font-normal",children:"/ 100"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("span",{className:`inline-block px-2.5 py-1 text-xs font-bold rounded-lg border ${w.status==="confirmed"?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-amber-50 text-amber-700 border-amber-100"}`,children:w.status==="confirmed"?n?"已确认同步":"Synced":n?"教师评分草稿":"Draft"}),e.jsx("p",{className:"text-xs text-slate-400 mt-1.5 font-medium",children:n?`教师分 ${w.teacher_score} (占 ${(w.teacher_weight*100).toFixed(0)}%)`:`Teacher ${w.teacher_score} (${(w.teacher_weight*100).toFixed(0)}%)`}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5 font-medium",children:n?`学生互评 (占 ${(w.peer_weight*100).toFixed(0)}%)`:`Peer Review (${(w.peer_weight*100).toFixed(0)}%)`})]})]}),w.teacher_comment&&e.jsxs("div",{className:"bg-slate-100/60 p-3 rounded-lg border border-slate-200 flex gap-2",children:[e.jsx(je,{size:14,className:"text-slate-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500",children:n?"教师寄语":"Teacher Comments"}),e.jsx("p",{className:"text-xs text-slate-650 mt-0.5",children:w.teacher_comment})]})]})]}):e.jsx("div",{className:"bg-white border border-slate-150 p-4 rounded-xl flex items-center justify-center text-slate-400 italic text-xs py-8",children:n?"教师尚未确认最终成绩与权重折算。":"Teacher grading is in progress."})]})]}),e.jsxs("div",{className:"flex-grow bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs flex flex-col min-h-[400px] text-left",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-4 shrink-0 select-none",children:[e.jsx(ve,{size:16,className:"text-teal-700"}),n?"同学作业互评公开板":"Classmate Submissions for Peer Review"]}),M.length===0?e.jsx("div",{className:"flex-grow flex items-center justify-center text-subtle italic text-xs py-12 border border-dashed border-slate-200 rounded-xl bg-white",children:n?"当前暂无同学提交作业作品。":"No classmate submissions available yet."}):e.jsx("div",{className:"flex-grow overflow-y-auto space-y-4 pr-1",children:M.map(t=>{const g=T.find(F=>F.submission_id===t.id),b=N[t.id]!==void 0?N[t.id]:g?g.score:85,l=a[t.id]!==void 0?a[t.id]:g?g.comment:"",_=L[t.id]||!1,U=Array.isArray(t.files)?t.files:[],H=K(t.file_path||ae(t,U[0])||null),E=H||K(t.linkUrl)||null;return e.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl p-4 shadow-3xs flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-start border-b border-slate-100 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-indigo-50 text-indigo-700 flex items-center justify-center font-bold text-xs select-none",children:t.student_name?t.student_name[0]:"?"}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-slate-700",children:t.student_name||t.student_id}),e.jsxs("p",{className:"text-xs text-slate-400 font-mono flex items-center gap-1 mt-0.5 truncate max-w-[200px]",title:t.file_path||void 0,children:[e.jsx(ye,{size:11,className:"text-slate-350"}),ne(t)," (V",t.version,")"]})]})]}),E?e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-bold text-indigo-600 hover:text-indigo-800 transition-colors border border-indigo-100 px-2 py-1 rounded bg-indigo-50/50 hover:bg-indigo-50 shrink-0",children:H?n?"下载查阅":"Download File":n?"打开链接":"Open Link"}):e.jsx("span",{className:"text-xs text-slate-400 px-2 py-1 border border-slate-200 rounded bg-white shrink-0",children:n?"无附件":"No File"})]}),t.textContent&&e.jsx("p",{className:"text-xs text-slate-600 whitespace-pre-wrap break-all max-h-24 overflow-auto bg-slate-50 border border-slate-100 rounded-lg p-2",children:t.textContent}),e.jsx(B,{slot:"assignment.submission.preview",slotProps:{submission:t,studentId:t.student_id,lessonId:r,isSelf:!1,lang:d}}),g&&e.jsxs("div",{className:"bg-emerald-50/50 border border-emerald-100 p-2.5 rounded-lg flex items-start gap-2 text-xs text-emerald-800",children:[e.jsx(ue,{className:"text-emerald-500 shrink-0 mt-0.5",size:14}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-bold flex items-center gap-1",children:n?`我已评分:${g.score} 分`:`My Score: ${g.score} pts`}),g.comment&&e.jsxs("p",{className:"text-xs text-emerald-700/80 mt-0.5 italic",children:['"',g.comment,'"']})]})]}),e.jsxs("div",{className:"bg-slate-50/60 border border-slate-100 rounded-lg p-3 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:n?"滑动或输入互评分数":"Peer Rating"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"number",min:"0",max:"100",value:b,onChange:F=>{const O=Math.min(100,Math.max(0,parseInt(F.target.value)||0));$(V=>({...V,[t.id]:O}))},className:"w-12 text-center text-xs font-bold font-mono border border-slate-200 rounded px-1 py-0.5 bg-white text-indigo-750"}),e.jsx("span",{className:"text-xs text-slate-400 font-bold",children:n?"分":"pts"})]})]}),e.jsx("input",{type:"range",min:"0",max:"100",value:b,onChange:F=>{const O=parseInt(F.target.value);$(V=>({...V,[t.id]:O}))},className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("textarea",{rows:1,value:l,onChange:F=>{S(O=>({...O,[t.id]:F.target.value}))},placeholder:n?"简要评语反馈...":"Brief feedback comment...",className:"flex-1 bg-white border border-slate-200 px-2 py-1 text-xs rounded-lg text-slate-700 focus:outline-none focus:border-indigo-400 resize-none transition-colors"}),e.jsxs("button",{onClick:()=>R(t.id,t.student_id),disabled:_,className:"bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs px-3 rounded-lg transition-colors cursor-pointer disabled:opacity-50 flex items-center justify-center",children:[_?e.jsx(G,{className:"animate-spin",size:13}):e.jsx(we,{size:13}),e.jsx("span",{className:"ml-1 shrink-0",children:g?n?"修改评分":"Update":n?"确认提交":"Submit"})]})]})]})]},t.id)})})]})]})}function Me(r){const{isStudentLocked:s=!1,isNavigationLocked:d,isInteractionLocked:o,lockMode:p,studentLessonTab:i,setStudentLessonTab:u,isStudentLessonContentCollapsed:f,setIsStudentLessonContentCollapsed:y,lang:c,studentFullscreenPanel:x,setStudentFullscreenPanel:C,selectedLesson:h,elements:z,activeRole:m,activeSegmentId:k,contentSegmentId:N,blockSegmentContent:$=!1,setActiveSegmentId:a,fetchElements:S,currentVfsParent:L,setCurrentVfsParent:P,vfsNodes:n,studentSelectedCourseware:A,setStudentSelectedCourseware:D,activeStudentId:R,addToast:v}=r,I=d??s,w=o??(p==="navigation"?!1:s),T=(p||(!w&&I?"navigation":"full"))==="navigation",M=l=>{if(I){l!==i&&v(c==="zh"?T?"🔒 答题锁定":"🔒 全班专注锁定":T?"🔒 Answer Locked":"🔒 Class Focus Locked",c==="zh"?T?"答题锁定中,请在当前页面完成作答并提交。":"锁定期间无法切换标签页,请跟随教师当前授课内容。":T?"Answer lock active. Complete your work on this page.":"Switching tabs is disabled while the class is locked.","warning");return}u(l)},t=N||k,g=$,b=l=>`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${i===l?"bg-primary-theme/10 text-primary-theme shadow-sm font-bold":"text-muted hover:bg-surface-secondary"} ${I&&i!==l?"opacity-50 cursor-not-allowed":"cursor-pointer"}`;return e.jsxs("div",{className:`${f||x==="right"?"w-full flex-grow":"flex-grow flex-1"} relative flex flex-col min-h-0 ${x==="left"?"hidden":""} transition-all duration-300`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>y(!f),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold bg-primary-theme/10 text-primary-theme rounded-lg hover:bg-primary-theme/20 transition-colors border border-primary-theme/20 cursor-pointer shadow-3xs",title:f?"展开课程内容":"折叠课程内容",children:[e.jsx(ce,{size:13,className:"text-primary-theme"}),e.jsx("span",{children:f?c==="zh"?"展开课程内容":"Expand Content":c==="zh"?"折叠课程内容":"Collapse Content"})]}),e.jsxs("button",{onClick:()=>M("whiteboard"),className:b("whiteboard"),title:w&&c==="zh"?"锁定中:白板为只读跟随模式":I&&c==="zh"?"答题锁定中:请在此页面完成作答":void 0,children:["Interactive Whiteboard",w&&i==="whiteboard"&&e.jsxs("span",{className:"ml-1.5 text-xs font-bold text-indigo-500",children:["🔒 ",c==="zh"?"只读":"RO"]}),!w&&I&&i==="whiteboard"&&e.jsxs("span",{className:"ml-1.5 text-xs font-bold text-amber-600",children:["✏️ ",c==="zh"?"答题锁定":"Answering"]})]}),e.jsx("button",{onClick:()=>M("courseware"),className:b("courseware"),children:"Interactive Courseware Viewer"}),e.jsx("button",{onClick:()=>M("assignment"),className:b("assignment"),children:c==="zh"?"作业提交与互评":"Assignments & Peer Reviews"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{slot:"student.lesson.tool",slotProps:{lessonId:h,studentId:R,activeSegmentId:k,lang:c}}),e.jsx("button",{onClick:()=>C(l=>l==="right"?"none":"right"),className:"p-1 hover:bg-gray-100 text-subtle hover:text-main rounded transition-colors cursor-pointer flex items-center gap-1",title:x==="right"?"退出全屏":"全屏",children:x==="right"?e.jsxs(e.Fragment,{children:[e.jsx(xe,{size:13}),e.jsx("span",{className:"text-xs font-medium",children:"退出全屏"})]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{size:13}),e.jsx("span",{className:"text-xs font-medium",children:"全屏"})]})})]})]}),g?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-amber-800 bg-amber-50/60 rounded-xl border border-amber-200 gap-3",children:[e.jsxs("div",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),e.jsx("span",{children:c==="zh"?"本教学环节尚未解锁":"This segment is not unlocked yet"})]}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400 max-w-md text-center",children:c==="zh"?"您尚未满足本教学环节的进入门禁条件,请完成前置任务或等待教师统一推进。":"You have not met the gate conditions for this segment yet. Please complete prerequisites or wait for the teacher."}),e.jsx(B,{slot:"student.segment.gate_fallback",slotProps:{lessonId:h,activeSegmentId:k,studentId:R,contentSegmentId:N,lang:c}})]}):null,!g&&i==="whiteboard"&&e.jsx(_e,{lessonId:h,elements:z,userRole:m,readOnly:w,followRemoteFullscreen:!0,activeSegmentId:t,onSegmentSync:l=>{N!==void 0&&N!==k||a(l)},onElementUpdate:async()=>{},onElementDelete:async l=>{w||h&&(await fetch(`/api/lessons/${h}/whiteboard/${l}`,{method:"DELETE"}),S(h))},onClearBoard:async()=>{w||h&&(await fetch(`/api/lessons/${h}/whiteboard`,{method:"DELETE"}),S(h))},onElementAdd:async()=>{},onRefresh:()=>{h&&S(h)}}),!g&&i==="courseware"&&e.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[e.jsxs("div",{className:"w-48 flex-shrink-0 bg-gray-50 border border-gray-200 rounded-lg p-3 flex flex-col min-h-0",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2 border-b border-gray-200 pb-2",children:"Cloud Apps"}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1",children:[L!==null&&e.jsxs("button",{onClick:()=>P(null),className:"flex items-center gap-2 p-1.5 text-xs text-indigo-600 w-full hover:bg-gray-200 rounded mb-1 font-medium",children:[e.jsx(de,{className:"rotate-180",size:14})," Back to Root"]}),n.filter(l=>l.type==="dir").map(l=>e.jsxs("button",{onClick:()=>P(l.id),className:"w-full text-left p-1.5 rounded text-xs text-gray-700 hover:bg-gray-200 flex items-center gap-2 group truncate",title:l.name,children:[e.jsx(ke,{size:14,className:"text-indigo-400 shrink-0 group-hover:text-indigo-600"}),e.jsx("span",{className:"truncate",children:l.name})]},l.id)),n.filter(l=>l.type==="file"&&(l.name.endsWith(".html")||l.name.endsWith(".htm")||l.content?.includes("<html"))).length===0?e.jsx("div",{className:"text-xs text-center text-gray-400 italic py-4",children:"No interactive HTML apps found."}):n.filter(l=>l.type==="file"&&(l.name.endsWith(".html")||l.name.endsWith(".htm")||l.content?.includes("<html"))).map(l=>e.jsxs("button",{onClick:()=>D(l.id),className:`w-full text-left p-2 rounded text-xs flex items-center gap-2 truncate transition-colors ${A===l.id?"bg-indigo-100 text-indigo-700 font-medium":"text-gray-600 hover:bg-gray-100"}`,title:l.name,children:[e.jsx(Ne,{size:14,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:l.name})]},l.id))]}),e.jsx("div",{className:"mt-2 text-xs text-gray-400 leading-tight",children:"Note: Showing HTML courseware from current OS drive directory. Ask agent to generate courseware."})]}),e.jsx("div",{className:"flex-1 relative bg-white min-h-0",children:e.jsx(Ie,{coursewareId:A,onClose:()=>D(null)})})]}),!g&&i==="assignment"&&h&&R&&e.jsx(Te,{lessonId:h,studentId:R,lang:c,addToast:v})]})}function Oe({access:r,lang:s}){if(!r.segmentId)return null;if(r.status==="loading"||r.status==="idle")return e.jsx("div",{className:"rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-600",role:"status",children:s==="zh"?"正在核对进入条件":"Checking entry conditions"});if(r.status!=="locked")return null;const d=r.gates.filter(o=>!o.allowed);return e.jsx("div",{"data-testid":"segment-gate-lock",role:"status",className:"rounded-xl border border-amber-300 bg-amber-50 px-3 py-2.5 text-xs text-amber-900",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Q,{size:14,className:"mt-0.5 shrink-0 text-amber-700"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-bold",children:s==="zh"?"本环节尚未解锁":"This segment is locked"}),e.jsx("p",{className:"mt-0.5 leading-snug",children:r.reason||(s==="zh"?"未满足进入条件":"Conditions not met")}),d.length>0&&e.jsx("ul",{className:"mt-1.5 space-y-0.5",children:d.map(o=>e.jsxs("li",{children:[o.reason||o.type,o.progress?`(${o.progress.current}/${o.progress.target}${o.progress.unit||""})`:""]},`${o.type}-${o.reason||""}`))})]})]})})}const ie={status:"idle",allowed:!0,gates:[],visibleSegmentId:null,segmentId:null};function oe(r,s){return{status:"locked",allowed:!1,reason:s,gates:[],visibleSegmentId:null,segmentId:r}}function Be(r,s){const[d,o]=j.useState(ie),p=j.useCallback(async()=>{if(!r||!s){o(ie);return}o(i=>i.segmentId===s&&(i.status==="open"||i.status==="locked")?i:{...i,status:"loading",segmentId:s});try{const i=await fetch(`/api/lessons/${encodeURIComponent(r)}/segment-access`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({targetSegmentId:s})}),u=await i.json().catch(()=>null);if(typeof u?.allowed=="boolean"){const f=Array.isArray(u.gates)?u.gates:[];o({status:u.allowed?"open":"locked",allowed:u.allowed,reason:typeof u.reason=="string"?u.reason:void 0,progress:u.progress,gates:f,visibleSegmentId:typeof u.visibleSegmentId=="string"?u.visibleSegmentId:u.allowed?s:null,segmentId:s});return}o(oe(s,i.ok?"进入条件返回了无法识别的结果":`进入条件暂时无法核对(HTTP ${i.status})`))}catch{o(oe(s,"进入条件服务不可达,已暂时锁定"))}},[r,s]);return j.useEffect(()=>{p()},[p]),j.useEffect(()=>{const i=()=>{p()};window.addEventListener("openlearn:segment-gate-changed",i);const u=re.subscribe("QuizSubmitted",i),f=re.subscribe("assignment.submitted",i);return()=>{window.removeEventListener("openlearn:segment-gate-changed",i),u(),f()}},[p]),j.useEffect(()=>{if(d.status!=="locked"||!r||!s)return;const i=window.setInterval(()=>{p()},5e3);return()=>window.clearInterval(i)},[d.status,r,s,p]),d}function De({isOpen:r,onClose:s,classId:d,lessonId:o,studentId:p,lang:i="zh",onCheckinSuccess:u,addToast:f}){const[y,c]=j.useState(null),[x,C]=j.useState(!1),[h,z]=j.useState(null),m=i==="zh";if(j.useEffect(()=>{r&&z(null)},[r]),!r)return null;const k=async a=>{const S=y;if(S){if(!d){z(m?"未检测到当前班级信息,暂时无法打卡":"No class found, unable to check in");return}C(!0),z(null);try{const L=await fetch(`/api/classes/${encodeURIComponent(d)}/checkin/icebreaker`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({mood:S,lessonId:o||void 0})});if(!L.ok){const n=await L.json().catch(()=>({}));throw new Error(n.error||`HTTP ${L.status}`)}const P=await L.json();try{const n=`icebreaker_checked_${p||"cur"}_${d}_${o||"today"}`;sessionStorage.setItem(n,S)}catch{}f&&f(m?"打卡成功!":"Check-in successful!",m?"老师已收到你的课前心态,祝本节课收获满满~":"Your mood has been shared with teacher.","success"),u&&u(P.stats),s()}catch(L){z(L.message||(m?"打卡失败,请重试":"Check-in failed, please retry"))}finally{C(!1)}}},N=()=>{try{const a=`icebreaker_skipped_${p||"cur"}_${d}_${o||"today"}`;sessionStorage.setItem(a,"1")}catch{}s()},$=[{id:"fullPower",label:m?"充满电":"Full Power",sub:m?"精力充沛,准备好迎接挑战!":"Energetic and ready to learn!",icon:e.jsx(ze,{className:"w-6 h-6 text-amber-500 animate-pulse"}),color:"hover:border-amber-400 hover:bg-amber-50/50 dark:hover:bg-amber-950/20",activeBorder:"border-amber-500 ring-2 ring-amber-400/30",activeBg:"bg-amber-50/80 dark:bg-amber-950/40"},{id:"needCoffee",label:m?"需要咖啡":"Need Coffee",sub:m?"稍显疲倦,需要唤醒状态~":"A bit tired, getting warmed up~",icon:e.jsx(Le,{className:"w-6 h-6 text-amber-700 dark:text-amber-300"}),color:"hover:border-amber-600 hover:bg-amber-50/50 dark:hover:bg-amber-950/20",activeBorder:"border-amber-600 ring-2 ring-amber-600/30",activeBg:"bg-amber-50/80 dark:bg-amber-950/40"},{id:"needHelp",label:m?"需要帮助":"Need Help",sub:m?"有点吃力,希望老师重点关照!":"Need support, please guide me!",icon:e.jsx($e,{className:"w-6 h-6 text-rose-500"}),color:"hover:border-rose-400 hover:bg-rose-50/50 dark:hover:bg-rose-950/20",activeBorder:"border-rose-500 ring-2 ring-rose-400/30",activeBg:"bg-rose-50/80 dark:bg-rose-950/40"}];return e.jsx("div",{"data-testid":"student-icebreaker-modal",className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-xs animate-in fade-in duration-200",role:"dialog","aria-modal":"true","aria-labelledby":"icebreaker-title",children:e.jsxs("div",{className:"relative w-full max-w-md rounded-2xl bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 shadow-2xl p-6 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-16 -right-16 w-36 h-36 bg-amber-400/10 rounded-full blur-2xl pointer-events-none"}),e.jsx("div",{className:"absolute -bottom-16 -left-16 w-36 h-36 bg-indigo-500/10 rounded-full blur-2xl pointer-events-none"}),e.jsxs("div",{className:"flex items-start justify-between pb-3 border-b border-gray-100 dark:border-gray-800/80",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl",children:"✨"}),e.jsx("h2",{id:"icebreaker-title",className:"text-lg font-bold text-gray-900 dark:text-gray-100",children:m?"课前破冰心情打卡":"Pre-Class Icebreaker"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:m?"分享你此刻的心态,帮助老师更好地调整上课节奏":"Share your status so the teacher can tailor the lesson"})]}),e.jsx("button",{type:"button",onClick:N,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 p-1 rounded-lg transition-colors cursor-pointer","aria-label":m?"跳过":"Skip",children:e.jsx(Se,{size:18})})]}),h&&e.jsxs("div",{className:"mt-3 p-2.5 rounded-lg bg-rose-50 dark:bg-rose-950/40 border border-rose-200 dark:border-rose-900/50 text-rose-700 dark:text-rose-300 text-xs flex items-center gap-2",children:[e.jsx("span",{className:"shrink-0",children:"⚠️"}),e.jsx("span",{children:h})]}),e.jsx("div",{className:"mt-4 space-y-2.5",children:$.map(a=>{const S=y===a.id;return e.jsxs("button",{type:"button","data-testid":`mood-option-${a.id}`,onClick:()=>c(a.id),className:`w-full text-left p-3.5 rounded-xl border transition-all cursor-pointer flex items-center justify-between gap-3 ${S?`${a.activeBorder} ${a.activeBg}`:`border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/40 ${a.color}`}`,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"shrink-0 p-2 rounded-lg bg-white dark:bg-gray-800 shadow-2xs border border-gray-100 dark:border-gray-700",children:a.icon}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:a.label}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate mt-0.5",children:a.sub})]})]}),S&&e.jsx(ue,{size:18,className:"shrink-0 text-indigo-600 dark:text-indigo-400"})]},a.id)})}),e.jsxs("div",{className:"mt-6 pt-3 border-t border-gray-100 dark:border-gray-800/80 flex items-center justify-between gap-3",children:[e.jsx("button",{type:"button","data-testid":"icebreaker-skip-btn",onClick:N,className:"text-xs text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 px-3 py-2 rounded-lg transition-colors cursor-pointer",children:m?"稍后再说 / 跳过":"Skip for now"}),e.jsx("button",{type:"button","data-testid":"icebreaker-submit-btn",disabled:!y||x,onClick:()=>k(),className:`inline-flex items-center justify-center gap-1.5 px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-xs cursor-pointer ${!y||x?"bg-gray-200 dark:bg-gray-800 text-gray-400 cursor-not-allowed":"bg-indigo-600 hover:bg-indigo-700 text-white shadow-indigo-500/20"}`,children:x?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:14,className:"animate-spin"}),e.jsx("span",{children:m?"提交中...":"Submitting..."})]}):e.jsx("span",{children:m?"确认打卡":"Check In"})})]})]})})}function Xe(r){const{students:s,activeStudentId:d,isStudentLocked:o=!1,isNavigationLocked:p,isInteractionLocked:i,lockMode:u,setStudentViewStatus:f,setSelectedLesson:y,lessons:c,selectedLesson:x,studentFullscreenPanel:C,setStudentFullscreenPanel:h,timelineSegments:z,lang:m,activeSegmentId:k,setActiveSegmentId:N,localProgressPercent:$,setLocalProgressPercent:a,updateStudentProgress:S,isStudentLessonContentCollapsed:L,setIsStudentLessonContentCollapsed:P,studentLessonTab:n,setStudentLessonTab:A,elements:D,activeRole:R,fetchElements:v,currentVfsParent:I,setCurrentVfsParent:w,vfsNodes:T,studentSelectedCourseware:M,setStudentSelectedCourseware:t,addToast:g}=r,b=Be(x,k),_=!!k&&(b.status==="idle"||b.status==="loading")||b.status==="locked"&&!b.visibleSegmentId,U=b.status==="locked"&&b.visibleSegmentId?b.visibleSegmentId:k,[H,E]=j.useState(!1),[F,O]=j.useState(null),V=le(W=>W.activeSession),J=F||(V?.lessonId===x?V.classId:null);return j.useEffect(()=>{if(!(!J||!x))try{const W=`icebreaker_checked_${d||"cur"}_${J}_${x}`,Y=`icebreaker_skipped_${d||"cur"}_${J}_${x}`;!sessionStorage.getItem(W)&&!sessionStorage.getItem(Y)&&E(!0)}catch{}},[J,x,d]),j.useEffect(()=>{if(!x||typeof fetch!="function")return;let W=!1;const Y=async()=>{try{const Z=await fetch(`/api/classroom/sessions/${encodeURIComponent(x)}`,{credentials:"same-origin"});if(!Z.ok||W)return;const ee=await Z.json(),q=ee?.session?.current_segment_id,X=ee?.session?.class_id;X&&typeof X=="string"&&O(X),typeof q=="string"&&q&&q!==k&&N(q)}catch{}};Y();const he=window.setInterval(()=>{Y()},2500);return()=>{W=!0,window.clearInterval(he)}},[x,k,N]),e.jsxs("div",{className:"flex flex-col h-full space-y-4",children:[e.jsx(Ee,{students:s,activeStudentId:d,isStudentLocked:p??o,lockMode:u,setStudentViewStatus:f,setSelectedLesson:y,lessons:c,selectedLesson:x,addToast:g,lang:m,onOpenIcebreaker:()=>E(!0)}),e.jsx(Ae,{lessonId:x,lang:m,addToast:g}),e.jsx(Oe,{access:b,lang:m}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 bg-surface border border-theme rounded-xl p-4 shadow-sm text-main",children:[e.jsx(Fe,{students:s,activeStudentId:d,isStudentLocked:o,studentFullscreenPanel:C,setStudentFullscreenPanel:h,timelineSegments:z,lang:m,activeSegmentId:k,setActiveSegmentId:N,localProgressPercent:$,setLocalProgressPercent:a,updateStudentProgress:S,selectedLesson:x,lessons:c,isStudentLessonContentCollapsed:L,addToast:g,segmentAccess:b}),e.jsx(Me,{isStudentLocked:o,isNavigationLocked:p,isInteractionLocked:i,lockMode:u,studentLessonTab:n,setStudentLessonTab:A,isStudentLessonContentCollapsed:L,setIsStudentLessonContentCollapsed:P,lang:m,studentFullscreenPanel:C,setStudentFullscreenPanel:h,selectedLesson:x,elements:D,activeRole:R,activeSegmentId:k,contentSegmentId:U,blockSegmentContent:_,setActiveSegmentId:N,fetchElements:v,currentVfsParent:I,setCurrentVfsParent:w,vfsNodes:T,studentSelectedCourseware:M,setStudentSelectedCourseware:t,activeStudentId:d,addToast:g})]}),e.jsx(B,{slot:"student.lesson.notes_addon",slotProps:{lessonId:x,studentId:d,activeSegmentId:k,lang:m}}),e.jsx(B,{slot:"student.lesson.toolbox",slotProps:{lessonId:x,studentId:d,lang:m}}),e.jsx(De,{isOpen:H,onClose:()=>E(!1),classId:J,lessonId:x,studentId:d,lang:m,addToast:g})]})}export{Xe as StudentLessonView};
1
+ import{r as j,j as e}from"./vendor-react-Kv_JATwr.js";import{u as le}from"./StudentView-CpJsG7FT.js";import{L as Q,f as de,B as ce,l as xe,m as me,q as se,R as G,a8 as te,b3 as be,$ as ge,C as fe,k as pe,O as je,a as ve,w as ye,a3 as ue,p as we,aY as ke,ao as Ne,X as Se,c as Ce,aA as ze,b4 as Le,e as $e}from"./vendor-icons-CXrZ3R2V.js";import{E as B,M as Pe,s as K,f as re}from"./index-BzXADCXZ.js";import{L as _e}from"./LazyWhiteboard-CcoBIx6V.js";import{L as Ie}from"./LazyCourseware-0iFYlRGj.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-pdf-C1Vh2Aqq.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-SrpBsvM3.js";function Ae({lessonId:r,lang:s,addToast:d}){const[o,p]=j.useState(""),[i,u]=j.useState("idle"),[f,y]=j.useState("");if(j.useEffect(()=>{p(""),u("idle"),y("")},[r]),!r)return null;const c=async()=>{const x=o.trim();if(!x){u("error"),y(s==="zh"?"请先输入签到码":"Enter the check-in code first");return}u("submitting"),y("");try{const C=await fetch(`/api/classroom/sessions/${encodeURIComponent(r)}/checkin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:x})}),h=await C.json().catch(()=>({}));if(!C.ok||!h.success){u("error");const m=h.error==="Invalid checkin code"?s==="zh"?"签到码不正确,请核对大屏后重试":"Wrong code, check the stage display and retry":h.error||(s==="zh"?"签到失败,请稍后重试":"Check-in failed, retry later");y(m);return}u("done");const z=h.attendanceScheduled!==!1;y(z?s==="zh"?"签到成功,出勤已记录":"Checked in, attendance recorded":s==="zh"?"签到成功(本课节未关联排课,未计入正式出勤)":"Checked in (no schedule linked; not counted in official attendance)"),d(s==="zh"?"签到成功":"Checked in",z?s==="zh"?"出勤已记录":"Attendance recorded":s==="zh"?"会话级签到,未计入正式出勤":"Session-level check-in only","success")}catch{u("error"),y(s==="zh"?"网络异常,请稍后重试":"Network error, retry later")}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 bg-surface border border-theme rounded-xl px-3 py-2 shadow-sm text-main",children:[e.jsx("span",{className:"text-xs font-bold",children:s==="zh"?"课堂签到":"Check-in"}),i==="done"?e.jsxs("span",{className:"text-xs font-bold text-emerald-600",children:["✓ ",f]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{value:o,onChange:x=>p(x.target.value.replace(/\s/g,"").slice(0,12)),onKeyDown:x=>{x.key==="Enter"&&c()},placeholder:s==="zh"?"输入大屏 4 位签到码":"4-digit code on stage display",inputMode:"numeric","aria-label":s==="zh"?"课堂签到码":"Class check-in code",className:"w-44 px-2 py-1 text-sm font-mono tracking-widest border border-theme rounded-lg bg-transparent"}),e.jsx("button",{type:"button",onClick:()=>void c(),disabled:i==="submitting",className:"px-3 py-1 text-xs font-bold rounded-lg bg-indigo-600 text-white hover:bg-indigo-700 disabled:opacity-50 cursor-pointer",children:i==="submitting"?s==="zh"?"提交中…":"Submitting…":s==="zh"?"签到":"Check in"})]}),i==="error"&&f&&e.jsx("span",{className:"text-xs text-rose-600",children:f})]})}function Ee(r){const{students:s,activeStudentId:d,isStudentLocked:o=!1,lockMode:p,setStudentViewStatus:i,setSelectedLesson:u,lessons:f,selectedLesson:y,lang:c="zh",addToast:x,onOpenIcebreaker:C}=r,h=le($=>$.activeSession),z=s.find($=>$.id===d),m=o||!!z?.locked_lesson_id,N=(p||z?.lock_mode||"full")==="navigation";return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[m?N?e.jsxs("div",{className:"text-amber-800 font-semibold text-sm flex items-center gap-2 px-3 py-1.5 rounded-lg bg-amber-50 border border-amber-200 shadow-3xs select-none",role:"status",title:c==="zh"?"答题锁定中 · 请完成作答后提交,暂时无法离开本页":"Answer Locked · Complete and submit your work before leaving",children:[e.jsx(Q,{size:15,className:"text-amber-600 shrink-0"}),c==="zh"?"答题锁定中 · 请完成作答后提交,暂时无法离开本页":"Answer Locked · Complete and submit work"]}):e.jsxs("div",{className:"text-indigo-700 font-semibold text-sm flex items-center gap-2 px-3 py-1.5 rounded-lg bg-indigo-50 border border-indigo-200 shadow-3xs select-none",role:"status",title:c==="zh"?"老师已开启全班专注锁定,您暂时无法切换页面":"The teacher locked the class focus. Navigating away is disabled.",children:[e.jsx(Q,{size:15,className:"text-indigo-600 shrink-0"}),c==="zh"?"全班专注锁定 · 跟随教师授课":"Class Focus Locked · Following Teacher"]}):e.jsxs("button",{onClick:()=>{i("dashboard"),u(null),h&&x?.(c==="zh"?"课堂仍在进行":"Class still in progress",c==="zh"?`可随时从看板顶部的「${h.lessonTitle} · 返回课堂」回到课堂。`:"You can return anytime via the banner at the top of your dashboard.","info")},className:"flex items-center gap-2 text-indigo-600 hover:text-indigo-800 transition-colors font-medium text-sm cursor-pointer",children:[e.jsx(de,{className:"rotate-180",size:16})," Back to Dashboard"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[C&&e.jsxs("button",{type:"button","data-testid":"open-icebreaker-btn",onClick:C,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-amber-200 dark:border-amber-800/60 bg-amber-50/80 hover:bg-amber-100/80 dark:bg-amber-950/30 dark:hover:bg-amber-950/50 text-amber-900 dark:text-amber-200 text-xs font-semibold shadow-3xs transition-colors cursor-pointer",title:c==="zh"?"课前破冰心情打卡":"Pre-class Icebreaker Check-in",children:[e.jsx("span",{children:"✨"}),e.jsx("span",{children:c==="zh"?"心情打卡":"Mood Check-in"})]}),e.jsx("h2",{className:"text-xl font-bold text-gray-800 dark:text-gray-100",children:f.find($=>$.id===y)?.title})]})]})}function Fe(r){const{students:s,activeStudentId:d,isStudentLocked:o=!1,studentFullscreenPanel:p,setStudentFullscreenPanel:i,timelineSegments:u,lang:f,activeSegmentId:y,localProgressPercent:c,setLocalProgressPercent:x,updateStudentProgress:C,selectedLesson:h,lessons:z,isStudentLessonContentCollapsed:m,addToast:k,segmentAccess:N}=r,$=a=>{if(!a?.id||y===a.id)return;k?.(f==="zh"?"请跟随课堂":"Follow the class",f==="zh"?"请跟随课堂当前环节":"Please follow the current class segment","warning")};return e.jsxs("div",{className:`${m?"hidden":p==="left"?"w-full":"w-1/3 md:block hidden"} border-gray-100 pr-4 overflow-y-auto ${p==="right"?"hidden":""} ${p==="left"?"":"border-r"} transition-all duration-300`,children:[e.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 mb-4 flex items-center justify-between pointer-events-auto shrink-0 select-none border-b border-gray-100 pb-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ce,{size:14,className:"text-indigo-500"})," Lesson Content (课程内容)"]}),e.jsx("button",{onClick:()=>i(a=>a==="left"?"none":"left"),className:"p-1 hover:bg-gray-100 text-subtle hover:text-main rounded transition-colors cursor-pointer flex items-center gap-1",title:p==="left"?"退出全屏":"全屏",children:p==="left"?e.jsxs(e.Fragment,{children:[e.jsx(xe,{size:13}),e.jsx("span",{className:"text-xs font-medium",children:"退出全屏"})]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{size:13}),e.jsx("span",{className:"text-xs font-medium",children:"全屏"})]})})]}),e.jsxs("div",{className:"prose prose-sm prose-indigo max-w-none",children:[!o&&!s.find(a=>a.id===d)?.locked_lesson_id&&u.length>0&&e.jsxs("div",{className:"mb-4 flex flex-col gap-2 p-3 bg-slate-50/70 border border-slate-200/50 rounded-xl shadow-3xs text-left",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider flex items-center gap-1.5 mb-1 select-none",children:[e.jsx(se,{size:12,className:"text-indigo-500"}),f==="zh"?"教学环节 (点击切换)":"Timeline Segments"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:u.map((a,S)=>{const L=y===a.id,P=L&&N?.status==="locked";return e.jsxs("button",{onClick:()=>$(a),title:P?N?.reason||"未满足进入条件":void 0,className:`px-2.5 py-1 text-xs font-semibold rounded-lg border transition-all cursor-pointer shadow-3xs flex items-center gap-1.5 ${a.color} ${L?"ring-2 ring-indigo-500 scale-[1.02] shadow-sm border-indigo-400 font-bold":"opacity-85 hover:opacity-100"}`,children:[P&&e.jsx(Q,{size:11,className:"text-amber-600 shrink-0"}),e.jsxs("span",{children:[a.title," (",a.duration,")"]}),e.jsx(B,{slot:"student.segment.badge",slotProps:{segment:a,idx:S,isActive:L,isLocked:!!P,studentId:d,lessonId:h,lang:f}})]},a.id||S)})})]}),e.jsxs("div",{className:"mb-4 bg-slate-50 p-2.5 rounded-xl border border-slate-200/60 shadow-3xs flex flex-col gap-1.5 text-left select-none",children:[e.jsxs("div",{className:"flex justify-between items-center text-xs font-bold text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(se,{size:12,className:"text-indigo-500 animate-pulse"}),f==="zh"?"自主学习进度(教师确认后计入成绩)":"Learning Progress (graded after teacher verification)"]}),e.jsxs("span",{className:"font-mono text-indigo-600 font-extrabold",children:[c,"%"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"range",min:"0",max:"100",value:c,onChange:a=>{const S=parseInt(a.target.value);x(S)},onMouseUp:()=>C(c),onTouchEnd:()=>C(c),className:"flex-grow h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),e.jsx("button",{onClick:()=>{x(100),C(100)},className:`text-xs font-bold rounded-lg px-2 py-1 transition-all ${c===100?"bg-emerald-100 text-emerald-700 border border-emerald-200":"bg-white hover:bg-slate-50 text-slate-650 border border-slate-200 hover:border-indigo-200 shadow-3xs cursor-pointer"}`,children:f==="zh"?"已完成":"Done"})]})]}),e.jsx(Pe,{children:z.find(a=>a.id===h)?.content||""})]})]})}function Re(r){if(!r)return"";const s=r.split("/");return s[s.length-1]||r}function ne(r){const s=Re(r?.file_path);if(s)return s;const d=Array.isArray(r?.files)?r.files:[];return d.length===1?d[0]?.name||"附件":d.length>1?`${d.length} 个附件`:r?.textContent?"文字作答":r?.linkUrl?"链接作答":"已提交(无附件)"}function ae(r,s){return!s?.fileId||!r?.assignment_id?null:`/api/assignments/${r.assignment_id}/files/${s.fileId}`}function Te({lessonId:r,studentId:s,lang:d,addToast:o}){const[p,i]=j.useState(!1),[u,f]=j.useState(!1),[y,c]=j.useState(null),[x,C]=j.useState([]),[h,z]=j.useState(""),[m,k]=j.useState(!1),[N,$]=j.useState({}),[a,S]=j.useState({}),[L,P]=j.useState({}),n=d==="zh",A=async(t=!1)=>{t?f(!0):i(!0);try{const b=await(await fetch(`/api/lessons/${r}/students/${s}/eval-status`)).json();c(b);const _=await(await fetch(`/api/lessons/${r}/eval-submissions`)).json();C(_)}catch(g){console.error("Error fetching eval data:",g),o(n?"数据加载失败":"Failed to Load Data",n?"请检查网络连接或刷新页面。":"Please check your connection and try again.","warning")}finally{i(!1),f(!1)}};j.useEffect(()=>{r&&s&&A()},[r,s]);const D=async t=>{t.preventDefault(),h.trim(),k(!0);try{const b=await(await fetch(`/api/lessons/${r}/eval-submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:s,filePath:h.trim()||void 0})})).json();if(b.success)o(n?"作业提交成功":"Assignment Submitted",n?`成功提交版本 ${b.version}!`:`Successfully submitted version ${b.version}!`,"success"),A(!0);else throw new Error(b.error||"Failed to submit assignment")}catch(g){o(n?"提交失败":"Submission Failed",g.message,"warning")}finally{k(!1)}},R=async(t,g)=>{const b=N[t],l=a[t]||"";if(b===void 0||isNaN(b)||b<0||b>100){o(n?"评分无效":"Invalid Score",n?"分数必须在 0 到 100 之间!":"Score must be between 0 and 100!","warning");return}P(_=>({..._,[t]:!0}));try{const U=await(await fetch(`/api/lessons/${r}/eval-submissions/${t}/reviews`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:Number(b),comment:l})})).json();if(U.success)o(n?"互评提交成功":"Review Submitted",n?"成功对同学的作品完成了评价!":"Successfully completed review for classmate!","success"),S(H=>{const E={...H};return delete E[t],E}),A(!0);else throw new Error(U.error||"Failed to submit review")}catch(_){o(n?"评价提交失败":"Review Failed",_.message,"warning")}finally{P(_=>({..._,[t]:!1}))}};if(p)return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-gray-500",children:[e.jsx(G,{className:"animate-spin text-indigo-500 mb-2",size:32}),e.jsx("p",{children:n?"正在读取作业互评状态...":"Loading assignment status..."})]});const v=y?.submission,I=K(v?.linkUrl),w=y?.grade,T=y?.reviewsWritten||[],M=x.filter(t=>t.student_id!==s);return e.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-6 overflow-y-auto pr-2",children:[e.jsxs("div",{className:"w-full lg:w-5/12 flex flex-col gap-6",children:[e.jsxs("div",{className:"bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs text-left",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 select-none",children:[e.jsx(te,{size:16,className:"text-indigo-600"}),n?"我的作业提交":"My Assignment Submission"]}),e.jsx("button",{onClick:()=>A(!0),className:"p-1 hover:bg-slate-200/50 rounded transition-colors text-slate-550",title:n?"刷新数据":"Refresh Data",children:e.jsx(G,{size:14,className:u?"animate-spin":""})})]}),v?e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-xl space-y-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-emerald-50 text-emerald-600 p-2.5 rounded-lg border border-emerald-100",children:e.jsx(be,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-slate-400 font-medium",children:n?"当前已提交版本":"Currently Submitted Version"}),e.jsx("p",{className:"text-sm font-semibold text-slate-700 truncate",children:ne(v)})]}),e.jsxs("span",{className:"bg-indigo-100 text-indigo-700 text-xs font-bold px-2 py-0.5 rounded-full border border-indigo-200",children:["V",v.version]})]}),e.jsxs("div",{className:"border-t border-slate-100 pt-2.5 flex justify-between items-center text-xs text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ge,{size:11}),n?"更新时间:":"Updated At:"," ",new Date(v.updated_at).toLocaleString()]}),e.jsx("span",{className:"font-mono text-slate-350 select-all truncate max-w-[120px]",title:v.file_path||void 0,children:v.file_path||"—"})]}),(v.textContent||v.linkUrl||Array.isArray(v.files)&&v.files.length>0)&&e.jsxs("div",{className:"border-t border-slate-100 pt-2.5 space-y-1 text-xs text-slate-600",children:[v.textContent&&e.jsx("p",{className:"whitespace-pre-wrap break-all max-h-20 overflow-hidden",children:v.textContent}),I&&e.jsx("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-indigo-600 hover:underline",children:v.linkUrl}),Array.isArray(v.files)&&v.files.map((t,g)=>{const b=K(ae(v,t));return b?e.jsx("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:"block truncate text-indigo-600 hover:underline",children:t.name},t.fileId??g):e.jsx("span",{className:"block truncate",children:t.name},t.name??g)})]}),e.jsx(B,{slot:"assignment.submission.preview",slotProps:{submission:v,studentId:s,lessonId:r,isSelf:!0,lang:d}})]}):e.jsxs("div",{className:"bg-amber-50/50 border border-amber-100 p-4 rounded-xl flex items-start gap-3 mb-4 text-left",children:[e.jsx(fe,{className:"text-amber-500 shrink-0 mt-0.5",size:16}),e.jsxs("div",{className:"text-xs text-amber-700",children:[e.jsx("p",{className:"font-bold",children:n?"未提交作业":"No Submission Yet"}),e.jsx("p",{className:"mt-1",children:n?"在此上传提交后,其他同学将可以对您的作业进行评分互评。":"Once submitted, other students can view and peer-review your work."})]})]}),e.jsx("form",{onSubmit:D,className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 uppercase tracking-wider mb-1",children:n?"输入作品文件路径 / 虚拟路径":"Simulated File Path"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:h,onChange:t=>z(t.target.value),placeholder:"/files/homework.pdf",required:!0,className:"flex-1 bg-white border border-slate-200 px-3 py-2 text-xs rounded-lg text-slate-700 focus:outline-none focus:border-indigo-400 font-mono transition-colors"}),e.jsxs("button",{type:"submit",disabled:m,className:"bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs px-4 py-2 rounded-lg transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1.5 shadow-3xs",children:[m?e.jsx(G,{className:"animate-spin",size:13}):e.jsx(te,{size:13}),v?n?"重新提交":"Re-submit":n?"上传作品":"Submit"]})]})]})})]}),v&&e.jsxs("div",{className:"bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs text-left",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-4 select-none",children:[e.jsx(pe,{size:16,className:"text-pink-650"}),n?"我的平时学习得分":"My Score & Feedback"]}),w?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-white border border-slate-200 p-4 rounded-xl flex items-center justify-between shadow-3xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-slate-400 font-bold uppercase tracking-wider",children:n?"学期对接总分":"Weighted Final Grade"}),e.jsxs("h2",{className:"text-3xl font-extrabold text-indigo-700 font-mono mt-1",children:[w.calculated_final_score," ",e.jsx("span",{className:"text-xs text-slate-455 font-normal",children:"/ 100"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("span",{className:`inline-block px-2.5 py-1 text-xs font-bold rounded-lg border ${w.status==="confirmed"?"bg-emerald-50 text-emerald-700 border-emerald-100":"bg-amber-50 text-amber-700 border-amber-100"}`,children:w.status==="confirmed"?n?"已确认同步":"Synced":n?"教师评分草稿":"Draft"}),e.jsx("p",{className:"text-xs text-slate-400 mt-1.5 font-medium",children:n?`教师分 ${w.teacher_score} (占 ${(w.teacher_weight*100).toFixed(0)}%)`:`Teacher ${w.teacher_score} (${(w.teacher_weight*100).toFixed(0)}%)`}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5 font-medium",children:n?`学生互评 (占 ${(w.peer_weight*100).toFixed(0)}%)`:`Peer Review (${(w.peer_weight*100).toFixed(0)}%)`})]})]}),w.teacher_comment&&e.jsxs("div",{className:"bg-slate-100/60 p-3 rounded-lg border border-slate-200 flex gap-2",children:[e.jsx(je,{size:14,className:"text-slate-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500",children:n?"教师寄语":"Teacher Comments"}),e.jsx("p",{className:"text-xs text-slate-650 mt-0.5",children:w.teacher_comment})]})]})]}):e.jsx("div",{className:"bg-white border border-slate-150 p-4 rounded-xl flex items-center justify-center text-slate-400 italic text-xs py-8",children:n?"教师尚未确认最终成绩与权重折算。":"Teacher grading is in progress."})]})]}),e.jsxs("div",{className:"flex-grow bg-slate-50 border border-slate-200/80 rounded-2xl p-5 shadow-3xs flex flex-col min-h-[400px] text-left",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-4 shrink-0 select-none",children:[e.jsx(ve,{size:16,className:"text-teal-700"}),n?"同学作业互评公开板":"Classmate Submissions for Peer Review"]}),M.length===0?e.jsx("div",{className:"flex-grow flex items-center justify-center text-subtle italic text-xs py-12 border border-dashed border-slate-200 rounded-xl bg-white",children:n?"当前暂无同学提交作业作品。":"No classmate submissions available yet."}):e.jsx("div",{className:"flex-grow overflow-y-auto space-y-4 pr-1",children:M.map(t=>{const g=T.find(F=>F.submission_id===t.id),b=N[t.id]!==void 0?N[t.id]:g?g.score:85,l=a[t.id]!==void 0?a[t.id]:g?g.comment:"",_=L[t.id]||!1,U=Array.isArray(t.files)?t.files:[],H=K(t.file_path||ae(t,U[0])||null),E=H||K(t.linkUrl)||null;return e.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl p-4 shadow-3xs flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-start border-b border-slate-100 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-indigo-50 text-indigo-700 flex items-center justify-center font-bold text-xs select-none",children:t.student_name?t.student_name[0]:"?"}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-slate-700",children:t.student_name||t.student_id}),e.jsxs("p",{className:"text-xs text-slate-400 font-mono flex items-center gap-1 mt-0.5 truncate max-w-[200px]",title:t.file_path||void 0,children:[e.jsx(ye,{size:11,className:"text-slate-350"}),ne(t)," (V",t.version,")"]})]})]}),E?e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-bold text-indigo-600 hover:text-indigo-800 transition-colors border border-indigo-100 px-2 py-1 rounded bg-indigo-50/50 hover:bg-indigo-50 shrink-0",children:H?n?"下载查阅":"Download File":n?"打开链接":"Open Link"}):e.jsx("span",{className:"text-xs text-slate-400 px-2 py-1 border border-slate-200 rounded bg-white shrink-0",children:n?"无附件":"No File"})]}),t.textContent&&e.jsx("p",{className:"text-xs text-slate-600 whitespace-pre-wrap break-all max-h-24 overflow-auto bg-slate-50 border border-slate-100 rounded-lg p-2",children:t.textContent}),e.jsx(B,{slot:"assignment.submission.preview",slotProps:{submission:t,studentId:t.student_id,lessonId:r,isSelf:!1,lang:d}}),g&&e.jsxs("div",{className:"bg-emerald-50/50 border border-emerald-100 p-2.5 rounded-lg flex items-start gap-2 text-xs text-emerald-800",children:[e.jsx(ue,{className:"text-emerald-500 shrink-0 mt-0.5",size:14}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-bold flex items-center gap-1",children:n?`我已评分:${g.score} 分`:`My Score: ${g.score} pts`}),g.comment&&e.jsxs("p",{className:"text-xs text-emerald-700/80 mt-0.5 italic",children:['"',g.comment,'"']})]})]}),e.jsxs("div",{className:"bg-slate-50/60 border border-slate-100 rounded-lg p-3 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-bold text-slate-500 uppercase tracking-wider",children:n?"滑动或输入互评分数":"Peer Rating"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"number",min:"0",max:"100",value:b,onChange:F=>{const O=Math.min(100,Math.max(0,parseInt(F.target.value)||0));$(V=>({...V,[t.id]:O}))},className:"w-12 text-center text-xs font-bold font-mono border border-slate-200 rounded px-1 py-0.5 bg-white text-indigo-750"}),e.jsx("span",{className:"text-xs text-slate-400 font-bold",children:n?"分":"pts"})]})]}),e.jsx("input",{type:"range",min:"0",max:"100",value:b,onChange:F=>{const O=parseInt(F.target.value);$(V=>({...V,[t.id]:O}))},className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("textarea",{rows:1,value:l,onChange:F=>{S(O=>({...O,[t.id]:F.target.value}))},placeholder:n?"简要评语反馈...":"Brief feedback comment...",className:"flex-1 bg-white border border-slate-200 px-2 py-1 text-xs rounded-lg text-slate-700 focus:outline-none focus:border-indigo-400 resize-none transition-colors"}),e.jsxs("button",{onClick:()=>R(t.id,t.student_id),disabled:_,className:"bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs px-3 rounded-lg transition-colors cursor-pointer disabled:opacity-50 flex items-center justify-center",children:[_?e.jsx(G,{className:"animate-spin",size:13}):e.jsx(we,{size:13}),e.jsx("span",{className:"ml-1 shrink-0",children:g?n?"修改评分":"Update":n?"确认提交":"Submit"})]})]})]})]},t.id)})})]})]})}function Me(r){const{isStudentLocked:s=!1,isNavigationLocked:d,isInteractionLocked:o,lockMode:p,studentLessonTab:i,setStudentLessonTab:u,isStudentLessonContentCollapsed:f,setIsStudentLessonContentCollapsed:y,lang:c,studentFullscreenPanel:x,setStudentFullscreenPanel:C,selectedLesson:h,elements:z,activeRole:m,activeSegmentId:k,contentSegmentId:N,blockSegmentContent:$=!1,setActiveSegmentId:a,fetchElements:S,currentVfsParent:L,setCurrentVfsParent:P,vfsNodes:n,studentSelectedCourseware:A,setStudentSelectedCourseware:D,activeStudentId:R,addToast:v}=r,I=d??s,w=o??(p==="navigation"?!1:s),T=(p||(!w&&I?"navigation":"full"))==="navigation",M=l=>{if(I){l!==i&&v(c==="zh"?T?"🔒 答题锁定":"🔒 全班专注锁定":T?"🔒 Answer Locked":"🔒 Class Focus Locked",c==="zh"?T?"答题锁定中,请在当前页面完成作答并提交。":"锁定期间无法切换标签页,请跟随教师当前授课内容。":T?"Answer lock active. Complete your work on this page.":"Switching tabs is disabled while the class is locked.","warning");return}u(l)},t=N||k,g=$,b=l=>`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${i===l?"bg-primary-theme/10 text-primary-theme shadow-sm font-bold":"text-muted hover:bg-surface-secondary"} ${I&&i!==l?"opacity-50 cursor-not-allowed":"cursor-pointer"}`;return e.jsxs("div",{className:`${f||x==="right"?"w-full flex-grow":"flex-grow flex-1"} relative flex flex-col min-h-0 ${x==="left"?"hidden":""} transition-all duration-300`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>y(!f),className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold bg-primary-theme/10 text-primary-theme rounded-lg hover:bg-primary-theme/20 transition-colors border border-primary-theme/20 cursor-pointer shadow-3xs",title:f?"展开课程内容":"折叠课程内容",children:[e.jsx(ce,{size:13,className:"text-primary-theme"}),e.jsx("span",{children:f?c==="zh"?"展开课程内容":"Expand Content":c==="zh"?"折叠课程内容":"Collapse Content"})]}),e.jsxs("button",{onClick:()=>M("whiteboard"),className:b("whiteboard"),title:w&&c==="zh"?"锁定中:白板为只读跟随模式":I&&c==="zh"?"答题锁定中:请在此页面完成作答":void 0,children:["Interactive Whiteboard",w&&i==="whiteboard"&&e.jsxs("span",{className:"ml-1.5 text-xs font-bold text-indigo-500",children:["🔒 ",c==="zh"?"只读":"RO"]}),!w&&I&&i==="whiteboard"&&e.jsxs("span",{className:"ml-1.5 text-xs font-bold text-amber-600",children:["✏️ ",c==="zh"?"答题锁定":"Answering"]})]}),e.jsx("button",{onClick:()=>M("courseware"),className:b("courseware"),children:"Interactive Courseware Viewer"}),e.jsx("button",{onClick:()=>M("assignment"),className:b("assignment"),children:c==="zh"?"作业提交与互评":"Assignments & Peer Reviews"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{slot:"student.lesson.tool",slotProps:{lessonId:h,studentId:R,activeSegmentId:k,lang:c}}),e.jsx("button",{onClick:()=>C(l=>l==="right"?"none":"right"),className:"p-1 hover:bg-gray-100 text-subtle hover:text-main rounded transition-colors cursor-pointer flex items-center gap-1",title:x==="right"?"退出全屏":"全屏",children:x==="right"?e.jsxs(e.Fragment,{children:[e.jsx(xe,{size:13}),e.jsx("span",{className:"text-xs font-medium",children:"退出全屏"})]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{size:13}),e.jsx("span",{className:"text-xs font-medium",children:"全屏"})]})})]})]}),g?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-amber-800 bg-amber-50/60 rounded-xl border border-amber-200 gap-3",children:[e.jsxs("div",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),e.jsx("span",{children:c==="zh"?"本教学环节尚未解锁":"This segment is not unlocked yet"})]}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400 max-w-md text-center",children:c==="zh"?"您尚未满足本教学环节的进入门禁条件,请完成前置任务或等待教师统一推进。":"You have not met the gate conditions for this segment yet. Please complete prerequisites or wait for the teacher."}),e.jsx(B,{slot:"student.segment.gate_fallback",slotProps:{lessonId:h,activeSegmentId:k,studentId:R,contentSegmentId:N,lang:c}})]}):null,!g&&i==="whiteboard"&&e.jsx(_e,{lessonId:h,elements:z,userRole:m,readOnly:w,followRemoteFullscreen:!0,activeSegmentId:t,onSegmentSync:l=>{N!==void 0&&N!==k||a(l)},onElementUpdate:async()=>{},onElementDelete:async l=>{w||h&&(await fetch(`/api/lessons/${h}/whiteboard/${l}`,{method:"DELETE"}),S(h))},onClearBoard:async()=>{w||h&&(await fetch(`/api/lessons/${h}/whiteboard`,{method:"DELETE"}),S(h))},onElementAdd:async()=>{},onRefresh:()=>{h&&S(h)}}),!g&&i==="courseware"&&e.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[e.jsxs("div",{className:"w-48 flex-shrink-0 bg-gray-50 border border-gray-200 rounded-lg p-3 flex flex-col min-h-0",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2 border-b border-gray-200 pb-2",children:"Cloud Apps"}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1",children:[L!==null&&e.jsxs("button",{onClick:()=>P(null),className:"flex items-center gap-2 p-1.5 text-xs text-indigo-600 w-full hover:bg-gray-200 rounded mb-1 font-medium",children:[e.jsx(de,{className:"rotate-180",size:14})," Back to Root"]}),n.filter(l=>l.type==="dir").map(l=>e.jsxs("button",{onClick:()=>P(l.id),className:"w-full text-left p-1.5 rounded text-xs text-gray-700 hover:bg-gray-200 flex items-center gap-2 group truncate",title:l.name,children:[e.jsx(ke,{size:14,className:"text-indigo-400 shrink-0 group-hover:text-indigo-600"}),e.jsx("span",{className:"truncate",children:l.name})]},l.id)),n.filter(l=>l.type==="file"&&(l.name.endsWith(".html")||l.name.endsWith(".htm")||l.content?.includes("<html"))).length===0?e.jsx("div",{className:"text-xs text-center text-gray-400 italic py-4",children:"No interactive HTML apps found."}):n.filter(l=>l.type==="file"&&(l.name.endsWith(".html")||l.name.endsWith(".htm")||l.content?.includes("<html"))).map(l=>e.jsxs("button",{onClick:()=>D(l.id),className:`w-full text-left p-2 rounded text-xs flex items-center gap-2 truncate transition-colors ${A===l.id?"bg-indigo-100 text-indigo-700 font-medium":"text-gray-600 hover:bg-gray-100"}`,title:l.name,children:[e.jsx(Ne,{size:14,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:l.name})]},l.id))]}),e.jsx("div",{className:"mt-2 text-xs text-gray-400 leading-tight",children:"Note: Showing HTML courseware from current OS drive directory. Ask agent to generate courseware."})]}),e.jsx("div",{className:"flex-1 relative bg-white min-h-0",children:e.jsx(Ie,{coursewareId:A,onClose:()=>D(null)})})]}),!g&&i==="assignment"&&h&&R&&e.jsx(Te,{lessonId:h,studentId:R,lang:c,addToast:v})]})}function Oe({access:r,lang:s}){if(!r.segmentId)return null;if(r.status==="loading"||r.status==="idle")return e.jsx("div",{className:"rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-600",role:"status",children:s==="zh"?"正在核对进入条件":"Checking entry conditions"});if(r.status!=="locked")return null;const d=r.gates.filter(o=>!o.allowed);return e.jsx("div",{"data-testid":"segment-gate-lock",role:"status",className:"rounded-xl border border-amber-300 bg-amber-50 px-3 py-2.5 text-xs text-amber-900",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Q,{size:14,className:"mt-0.5 shrink-0 text-amber-700"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-bold",children:s==="zh"?"本环节尚未解锁":"This segment is locked"}),e.jsx("p",{className:"mt-0.5 leading-snug",children:r.reason||(s==="zh"?"未满足进入条件":"Conditions not met")}),d.length>0&&e.jsx("ul",{className:"mt-1.5 space-y-0.5",children:d.map(o=>e.jsxs("li",{children:[o.reason||o.type,o.progress?`(${o.progress.current}/${o.progress.target}${o.progress.unit||""})`:""]},`${o.type}-${o.reason||""}`))})]})]})})}const ie={status:"idle",allowed:!0,gates:[],visibleSegmentId:null,segmentId:null};function oe(r,s){return{status:"locked",allowed:!1,reason:s,gates:[],visibleSegmentId:null,segmentId:r}}function Be(r,s){const[d,o]=j.useState(ie),p=j.useCallback(async()=>{if(!r||!s){o(ie);return}o(i=>i.segmentId===s&&(i.status==="open"||i.status==="locked")?i:{...i,status:"loading",segmentId:s});try{const i=await fetch(`/api/lessons/${encodeURIComponent(r)}/segment-access`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({targetSegmentId:s})}),u=await i.json().catch(()=>null);if(typeof u?.allowed=="boolean"){const f=Array.isArray(u.gates)?u.gates:[];o({status:u.allowed?"open":"locked",allowed:u.allowed,reason:typeof u.reason=="string"?u.reason:void 0,progress:u.progress,gates:f,visibleSegmentId:typeof u.visibleSegmentId=="string"?u.visibleSegmentId:u.allowed?s:null,segmentId:s});return}o(oe(s,i.ok?"进入条件返回了无法识别的结果":`进入条件暂时无法核对(HTTP ${i.status})`))}catch{o(oe(s,"进入条件服务不可达,已暂时锁定"))}},[r,s]);return j.useEffect(()=>{p()},[p]),j.useEffect(()=>{const i=()=>{p()};window.addEventListener("openlearn:segment-gate-changed",i);const u=re.subscribe("QuizSubmitted",i),f=re.subscribe("assignment.submitted",i);return()=>{window.removeEventListener("openlearn:segment-gate-changed",i),u(),f()}},[p]),j.useEffect(()=>{if(d.status!=="locked"||!r||!s)return;const i=window.setInterval(()=>{p()},5e3);return()=>window.clearInterval(i)},[d.status,r,s,p]),d}function De({isOpen:r,onClose:s,classId:d,lessonId:o,studentId:p,lang:i="zh",onCheckinSuccess:u,addToast:f}){const[y,c]=j.useState(null),[x,C]=j.useState(!1),[h,z]=j.useState(null),m=i==="zh";if(j.useEffect(()=>{r&&z(null)},[r]),!r)return null;const k=async a=>{const S=y;if(S){if(!d){z(m?"未检测到当前班级信息,暂时无法打卡":"No class found, unable to check in");return}C(!0),z(null);try{const L=await fetch(`/api/classes/${encodeURIComponent(d)}/checkin/icebreaker`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({mood:S,lessonId:o||void 0})});if(!L.ok){const n=await L.json().catch(()=>({}));throw new Error(n.error||`HTTP ${L.status}`)}const P=await L.json();try{const n=`icebreaker_checked_${p||"cur"}_${d}_${o||"today"}`;sessionStorage.setItem(n,S)}catch{}f&&f(m?"打卡成功!":"Check-in successful!",m?"老师已收到你的课前心态,祝本节课收获满满~":"Your mood has been shared with teacher.","success"),u&&u(P.stats),s()}catch(L){z(L.message||(m?"打卡失败,请重试":"Check-in failed, please retry"))}finally{C(!1)}}},N=()=>{try{const a=`icebreaker_skipped_${p||"cur"}_${d}_${o||"today"}`;sessionStorage.setItem(a,"1")}catch{}s()},$=[{id:"fullPower",label:m?"充满电":"Full Power",sub:m?"精力充沛,准备好迎接挑战!":"Energetic and ready to learn!",icon:e.jsx(ze,{className:"w-6 h-6 text-amber-500 animate-pulse"}),color:"hover:border-amber-400 hover:bg-amber-50/50 dark:hover:bg-amber-950/20",activeBorder:"border-amber-500 ring-2 ring-amber-400/30",activeBg:"bg-amber-50/80 dark:bg-amber-950/40"},{id:"needCoffee",label:m?"需要咖啡":"Need Coffee",sub:m?"稍显疲倦,需要唤醒状态~":"A bit tired, getting warmed up~",icon:e.jsx(Le,{className:"w-6 h-6 text-amber-700 dark:text-amber-300"}),color:"hover:border-amber-600 hover:bg-amber-50/50 dark:hover:bg-amber-950/20",activeBorder:"border-amber-600 ring-2 ring-amber-600/30",activeBg:"bg-amber-50/80 dark:bg-amber-950/40"},{id:"needHelp",label:m?"需要帮助":"Need Help",sub:m?"有点吃力,希望老师重点关照!":"Need support, please guide me!",icon:e.jsx($e,{className:"w-6 h-6 text-rose-500"}),color:"hover:border-rose-400 hover:bg-rose-50/50 dark:hover:bg-rose-950/20",activeBorder:"border-rose-500 ring-2 ring-rose-400/30",activeBg:"bg-rose-50/80 dark:bg-rose-950/40"}];return e.jsx("div",{"data-testid":"student-icebreaker-modal",className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-xs animate-in fade-in duration-200",role:"dialog","aria-modal":"true","aria-labelledby":"icebreaker-title",children:e.jsxs("div",{className:"relative w-full max-w-md rounded-2xl bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 shadow-2xl p-6 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-16 -right-16 w-36 h-36 bg-amber-400/10 rounded-full blur-2xl pointer-events-none"}),e.jsx("div",{className:"absolute -bottom-16 -left-16 w-36 h-36 bg-indigo-500/10 rounded-full blur-2xl pointer-events-none"}),e.jsxs("div",{className:"flex items-start justify-between pb-3 border-b border-gray-100 dark:border-gray-800/80",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xl",children:"✨"}),e.jsx("h2",{id:"icebreaker-title",className:"text-lg font-bold text-gray-900 dark:text-gray-100",children:m?"课前破冰心情打卡":"Pre-Class Icebreaker"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:m?"分享你此刻的心态,帮助老师更好地调整上课节奏":"Share your status so the teacher can tailor the lesson"})]}),e.jsx("button",{type:"button",onClick:N,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 p-1 rounded-lg transition-colors cursor-pointer","aria-label":m?"跳过":"Skip",children:e.jsx(Se,{size:18})})]}),h&&e.jsxs("div",{className:"mt-3 p-2.5 rounded-lg bg-rose-50 dark:bg-rose-950/40 border border-rose-200 dark:border-rose-900/50 text-rose-700 dark:text-rose-300 text-xs flex items-center gap-2",children:[e.jsx("span",{className:"shrink-0",children:"⚠️"}),e.jsx("span",{children:h})]}),e.jsx("div",{className:"mt-4 space-y-2.5",children:$.map(a=>{const S=y===a.id;return e.jsxs("button",{type:"button","data-testid":`mood-option-${a.id}`,onClick:()=>c(a.id),className:`w-full text-left p-3.5 rounded-xl border transition-all cursor-pointer flex items-center justify-between gap-3 ${S?`${a.activeBorder} ${a.activeBg}`:`border-gray-200 dark:border-gray-800 bg-gray-50/50 dark:bg-gray-800/40 ${a.color}`}`,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"shrink-0 p-2 rounded-lg bg-white dark:bg-gray-800 shadow-2xs border border-gray-100 dark:border-gray-700",children:a.icon}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:a.label}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate mt-0.5",children:a.sub})]})]}),S&&e.jsx(ue,{size:18,className:"shrink-0 text-indigo-600 dark:text-indigo-400"})]},a.id)})}),e.jsxs("div",{className:"mt-6 pt-3 border-t border-gray-100 dark:border-gray-800/80 flex items-center justify-between gap-3",children:[e.jsx("button",{type:"button","data-testid":"icebreaker-skip-btn",onClick:N,className:"text-xs text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 px-3 py-2 rounded-lg transition-colors cursor-pointer",children:m?"稍后再说 / 跳过":"Skip for now"}),e.jsx("button",{type:"button","data-testid":"icebreaker-submit-btn",disabled:!y||x,onClick:()=>k(),className:`inline-flex items-center justify-center gap-1.5 px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-xs cursor-pointer ${!y||x?"bg-gray-200 dark:bg-gray-800 text-gray-400 cursor-not-allowed":"bg-indigo-600 hover:bg-indigo-700 text-white shadow-indigo-500/20"}`,children:x?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:14,className:"animate-spin"}),e.jsx("span",{children:m?"提交中...":"Submitting..."})]}):e.jsx("span",{children:m?"确认打卡":"Check In"})})]})]})})}function Xe(r){const{students:s,activeStudentId:d,isStudentLocked:o=!1,isNavigationLocked:p,isInteractionLocked:i,lockMode:u,setStudentViewStatus:f,setSelectedLesson:y,lessons:c,selectedLesson:x,studentFullscreenPanel:C,setStudentFullscreenPanel:h,timelineSegments:z,lang:m,activeSegmentId:k,setActiveSegmentId:N,localProgressPercent:$,setLocalProgressPercent:a,updateStudentProgress:S,isStudentLessonContentCollapsed:L,setIsStudentLessonContentCollapsed:P,studentLessonTab:n,setStudentLessonTab:A,elements:D,activeRole:R,fetchElements:v,currentVfsParent:I,setCurrentVfsParent:w,vfsNodes:T,studentSelectedCourseware:M,setStudentSelectedCourseware:t,addToast:g}=r,b=Be(x,k),_=!!k&&(b.status==="idle"||b.status==="loading")||b.status==="locked"&&!b.visibleSegmentId,U=b.status==="locked"&&b.visibleSegmentId?b.visibleSegmentId:k,[H,E]=j.useState(!1),[F,O]=j.useState(null),V=le(W=>W.activeSession),J=F||(V?.lessonId===x?V.classId:null);return j.useEffect(()=>{if(!(!J||!x))try{const W=`icebreaker_checked_${d||"cur"}_${J}_${x}`,Y=`icebreaker_skipped_${d||"cur"}_${J}_${x}`;!sessionStorage.getItem(W)&&!sessionStorage.getItem(Y)&&E(!0)}catch{}},[J,x,d]),j.useEffect(()=>{if(!x||typeof fetch!="function")return;let W=!1;const Y=async()=>{try{const Z=await fetch(`/api/classroom/sessions/${encodeURIComponent(x)}`,{credentials:"same-origin"});if(!Z.ok||W)return;const ee=await Z.json(),q=ee?.session?.current_segment_id,X=ee?.session?.class_id;X&&typeof X=="string"&&O(X),typeof q=="string"&&q&&q!==k&&N(q)}catch{}};Y();const he=window.setInterval(()=>{Y()},2500);return()=>{W=!0,window.clearInterval(he)}},[x,k,N]),e.jsxs("div",{className:"flex flex-col h-full space-y-4",children:[e.jsx(Ee,{students:s,activeStudentId:d,isStudentLocked:p??o,lockMode:u,setStudentViewStatus:f,setSelectedLesson:y,lessons:c,selectedLesson:x,addToast:g,lang:m,onOpenIcebreaker:()=>E(!0)}),e.jsx(Ae,{lessonId:x,lang:m,addToast:g}),e.jsx(Oe,{access:b,lang:m}),e.jsxs("div",{className:"flex-1 flex gap-6 min-h-0 bg-surface border border-theme rounded-xl p-4 shadow-sm text-main",children:[e.jsx(Fe,{students:s,activeStudentId:d,isStudentLocked:o,studentFullscreenPanel:C,setStudentFullscreenPanel:h,timelineSegments:z,lang:m,activeSegmentId:k,setActiveSegmentId:N,localProgressPercent:$,setLocalProgressPercent:a,updateStudentProgress:S,selectedLesson:x,lessons:c,isStudentLessonContentCollapsed:L,addToast:g,segmentAccess:b}),e.jsx(Me,{isStudentLocked:o,isNavigationLocked:p,isInteractionLocked:i,lockMode:u,studentLessonTab:n,setStudentLessonTab:A,isStudentLessonContentCollapsed:L,setIsStudentLessonContentCollapsed:P,lang:m,studentFullscreenPanel:C,setStudentFullscreenPanel:h,selectedLesson:x,elements:D,activeRole:R,activeSegmentId:k,contentSegmentId:U,blockSegmentContent:_,setActiveSegmentId:N,fetchElements:v,currentVfsParent:I,setCurrentVfsParent:w,vfsNodes:T,studentSelectedCourseware:M,setStudentSelectedCourseware:t,activeStudentId:d,addToast:g})]}),e.jsx(B,{slot:"student.lesson.notes_addon",slotProps:{lessonId:x,studentId:d,activeSegmentId:k,lang:m}}),e.jsx(B,{slot:"student.lesson.toolbox",slotProps:{lessonId:x,studentId:d,lang:m}}),e.jsx(De,{isOpen:H,onClose:()=>E(!1),classId:J,lessonId:x,studentId:d,lang:m,addToast:g})]})}export{Xe as StudentLessonView};