openlearn-next 0.7.4 → 0.7.5

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 (61) hide show
  1. package/README.md +1 -1
  2. package/cli-doctor.mjs +18 -5
  3. package/cli.mjs +49 -0
  4. package/dist/assets/{ActivityWorkspaceWidget-CMN8elwQ.js → ActivityWorkspaceWidget-Dq4kjBS2.js} +1 -1
  5. package/dist/assets/{AdminDirectoryView-Dlz7q-xf.js → AdminDirectoryView-B6OAs5Rj.js} +1 -1
  6. package/dist/assets/AssessmentCenter-B3f1DxSG.js +1 -0
  7. package/dist/assets/AssignmentFilePreview-DQbvbgnd.js +3 -0
  8. package/dist/assets/{BatchPickerModal-CzutdtIz.js → BatchPickerModal-CoOWloSS.js} +1 -1
  9. package/dist/assets/{ClassesView-RkFPpWRu.js → ClassesView-Q56Kf4eL.js} +5 -5
  10. package/dist/assets/{ClassroomCountdownWidget-gs42lIGW.js → ClassroomCountdownWidget-C6luhy8P.js} +1 -1
  11. package/dist/assets/{CloudDriveModal-C6JtK08M.js → CloudDriveModal-DLf4fbKR.js} +1 -1
  12. package/dist/assets/ComputerLabView-D9-Tk7yA.js +1 -0
  13. package/dist/assets/{CourseManagement-DNeaJcT9.js → CourseManagement-DNSfyre-.js} +1 -1
  14. package/dist/assets/{CourseWizardModal-vw876VJr.js → CourseWizardModal-DAueHXcl.js} +1 -1
  15. package/dist/assets/{CoursewareHubPanel-CyxDIJAF.js → CoursewareHubPanel-DLjH-UzF.js} +1 -1
  16. package/dist/assets/{Dashboard-C1iYnfCh.js → Dashboard-qMVadkd2.js} +2 -2
  17. package/dist/assets/{ExportWeightModal-CTZ-O_wi.js → ExportWeightModal-Dkh7OC8U.js} +1 -1
  18. package/dist/assets/{HelpTour-D_q1z_MI.js → HelpTour-BLuiS8rr.js} +1 -1
  19. package/dist/assets/{HelpView-wyKldm_R.js → HelpView-CTF6B9ml.js} +1 -1
  20. package/dist/assets/{ImportLessonsModal-C09Z-qtx.js → ImportLessonsModal-Ra-OF_Vo.js} +1 -1
  21. package/dist/assets/{ImportModal-DqjqNeH4.js → ImportModal-H5s5MyZY.js} +1 -1
  22. package/dist/assets/{InteractiveCoursewareViewer-V97euiJF.js → InteractiveCoursewareViewer-BfHEDrCf.js} +1 -1
  23. package/dist/assets/InteractiveWhiteboard-KBzmiNBG.js +65 -0
  24. package/dist/assets/{LazyCourseware-0iFYlRGj.js → LazyCourseware-BaZS8-i1.js} +2 -2
  25. package/dist/assets/LazyWhiteboard-DGyln3JC.js +2 -0
  26. package/dist/assets/LessonEditorView-B5JXYyup.js +1 -0
  27. package/dist/assets/{LiveClassroomView-CaS1DzSS.js → LiveClassroomView-DezAlve2.js} +7 -7
  28. package/dist/assets/{NotificationDetailModal-4MdNF4tw.js → NotificationDetailModal-DbMMrIHQ.js} +1 -1
  29. package/dist/assets/{PluginView-BqTbAp30.js → PluginView-CvIr-ANj.js} +1 -1
  30. package/dist/assets/{ProcessLogsModal-Cfr-T9Gd.js → ProcessLogsModal-_BwkmJVw.js} +1 -1
  31. package/dist/assets/{QuizGeneratorModal-xTq22vDq.js → QuizGeneratorModal-CTj2moWM.js} +1 -1
  32. package/dist/assets/StudentAssignmentEvalPanel-DrfZT8Lr.js +1 -0
  33. package/dist/assets/{StudentAssignmentView-Cy_JdPYB.js → StudentAssignmentView-D_EhblVQ.js} +1 -1
  34. package/dist/assets/StudentLessonView-BHG50-4M.js +1 -0
  35. package/dist/assets/{StudentView-CpJsG7FT.js → StudentView-DKDhnJQx.js} +2 -2
  36. package/dist/assets/{SystemResourceLibraryModal-YZ85mv_v.js → SystemResourceLibraryModal-C5y8H5Pf.js} +1 -1
  37. package/dist/assets/TeacherView-CWDK3DOe.js +2 -0
  38. package/dist/assets/{TimetableView-D_4XmrRN.js → TimetableView-C8kdJlf7.js} +1 -1
  39. package/dist/assets/{UTIF-FfCsrHhe.js → UTIF-4E-wdh3X.js} +1 -1
  40. package/dist/assets/index-BBznBaN5.js +131 -0
  41. package/dist/assets/index-DPky2leG.css +1 -0
  42. package/dist/assets/{index.es-DyEF0CZ9.js → index.es-WXdI0L-F.js} +1 -1
  43. package/dist/assets/pluginParsers-DkiO-BBu.js +1 -0
  44. package/dist/assets/student-workspace-1yVTbWHC.js +1 -0
  45. package/dist/assets/{vendor-icons-CXrZ3R2V.js → vendor-icons-hc6MjYFv.js} +1 -1
  46. package/dist/assets/{vendor-pdf-C1Vh2Aqq.js → vendor-pdf-By0fofA0.js} +3 -3
  47. package/dist/assets/{vendor-pptx-Bzn6whfK.js → vendor-pptx-EjNUtdws.js} +178 -178
  48. package/dist/index.html +3 -3
  49. package/dist/server.cjs +538 -174
  50. package/package.json +6 -4
  51. package/scripts/assert-node-runtime.mjs +165 -0
  52. package/dist/assets/AssessmentCenter-CaoAI9Ke.js +0 -1
  53. package/dist/assets/ComputerLabView-Dr-g8FrU.js +0 -1
  54. package/dist/assets/InteractiveWhiteboard-COLMh_-w.js +0 -65
  55. package/dist/assets/LazyWhiteboard-CcoBIx6V.js +0 -2
  56. package/dist/assets/LessonEditorView-BWmtKwmP.js +0 -1
  57. package/dist/assets/StudentLessonView-B3fKejCU.js +0 -1
  58. package/dist/assets/TeacherView-B3zhzd5g.js +0 -2
  59. package/dist/assets/index-BzXADCXZ.js +0 -131
  60. package/dist/assets/index-C6hlh8pw.css +0 -1
  61. package/dist/assets/pluginParsers-PzgFzxS9.js +0 -1
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InteractiveWhiteboard-COLMh_-w.js","assets/vendor-react-Kv_JATwr.js","assets/vendor-utils-aM7aYvPP.js","assets/index-BzXADCXZ.js","assets/vendor-icons-CXrZ3R2V.js","assets/vendor-motion-BFAPOs-b.js","assets/index-C6hlh8pw.css","assets/vendor-pptx-DIWdXF1L.css","assets/vendor-reveal-DcQQzuI9.css"])))=>i.map(i=>d[i]);
2
- import{_ as s}from"./vendor-pdf-C1Vh2Aqq.js";import{r as t,j as e}from"./vendor-react-Kv_JATwr.js";const i=t.lazy(()=>s(()=>import("./InteractiveWhiteboard-COLMh_-w.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(r=>({default:r.InteractiveWhiteboard}))),n=t.forwardRef((r,a)=>e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full bg-gray-50",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-500"})}),children:e.jsx(i,{ref:a,...r})}));export{n as L};
@@ -1 +0,0 @@
1
- import{j as e,r as f,R as ae}from"./vendor-react-Kv_JATwr.js";import{j as se,k as ke,l as Ce,n as Se,E as O,p as me,q as Ee,r as Ie,e as ve,v as Te,S as $e,f as ne,w as ie,x as De,b as Pe,y as Ae,z as he}from"./index-BzXADCXZ.js";import{L as Le}from"./LazyWhiteboard-CcoBIx6V.js";import{P as Re,p as je,b9 as _e,aU as pe,ba as xe,bb as Me,a6 as fe,ak as ce,t as Fe,ac as de,a$ as Ze,X as we,$ as ue,z as Ne,f as Be,bc as Ge,aR as Oe,o as ze,aZ as He,L as qe,aa as Ue,w as be,ab as We,a7 as Je,ar as Qe,c as ge,ap as Ve,T as Xe,af as Ye,aQ as Ke}from"./vendor-icons-CXrZ3R2V.js";import{r as et}from"./timeline-duration-BgdJCSrW.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-pdf-C1Vh2Aqq.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-SrpBsvM3.js";function ye({config:s,lang:t,onActivate:o,disabled:m=!1,isFavorite:y=!1,onToggleFavorite:r}){const a=s.icon||Re,N=se[s.color]||se.indigo;return e.jsxs("div",{draggable:!m,onDragStart:x=>{if(m){x.preventDefault();return}const v={type:s.type,...s.defaultData},c=JSON.stringify(v);x.dataTransfer.effectAllowed="copy",x.dataTransfer.setData("application/json",c),x.dataTransfer.setData("text/plain",c)},onClick:()=>!m&&o(s.type),title:m?t==="zh"?"当前为只读模式":"Read-only mode":t==="zh"?"点击编辑并添加到画板,或拖拽到画板":"Click to edit & add, or drag onto the board","aria-disabled":m,className:`group relative bg-surface border border-theme rounded-xl p-2.5 shadow-sm transition-all duration-200 ${m?"opacity-60 cursor-not-allowed":"cursor-grab active:cursor-grabbing hover:shadow-md hover:-translate-y-0.5"} ${N.cardHoverBorder} ${N.cardHoverRing} ${N.cardHoverShadow} flex flex-col justify-between min-h-[92px]`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("div",{className:`p-2 rounded-lg ${N.iconBg} ${N.iconText} transition-transform group-hover:scale-105 shrink-0`,children:e.jsx(a,{size:16})}),r&&e.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),r(s.type,x)},className:`p-1 rounded-md transition-colors ${y?"text-amber-400 opacity-100":"text-slate-300 opacity-0 group-hover:opacity-100 hover:text-amber-400 hover:bg-surface-secondary"}`,title:y?t==="zh"?"取消收藏":"Remove favorite":t==="zh"?"收藏组件":"Add favorite",children:e.jsx(je,{size:13,className:y?"fill-amber-400":""})})]}),e.jsxs("div",{className:"flex flex-col min-w-0 mt-1.5",children:[e.jsx("span",{className:"font-semibold text-xs text-main truncate group-hover:text-primary-theme transition-colors",children:t==="zh"?s.labelZh:s.labelEn}),e.jsx("span",{className:"text-xs text-muted leading-tight mt-0.5 truncate",children:t==="zh"?s.descriptionZh:s.descriptionEn})]}),e.jsx("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none",children:e.jsx("span",{className:"text-xs font-bold text-indigo-500 bg-indigo-50 px-1 py-0.5 rounded border border-indigo-100",children:"+ Drag"})})]})}function tt({lang:s,onActivate:t,readOnly:o=!1,collapsed:m,onToggleCollapse:y,pages:r,currentPage:a=0,onSwitchPage:N,onAddPage:x,onDeletePage:v,onRenamePage:c,dragState:b,onHoverDropTarget:z}){const[C,d]=f.useState(!1),l=m!==void 0?m:C,g=()=>{const n=!l;d(n),y&&y(n)},[S,B]=f.useState(""),[M,H]=f.useState(!1),[K,h]=f.useState(null),[j,E]=f.useState(""),[T,G]=f.useState("all"),[_,q]=f.useState(()=>{try{const n=localStorage.getItem("openlearn_palette_favs");return n?JSON.parse(n):[]}catch{return[]}}),[F,D]=f.useState(()=>{try{const n=localStorage.getItem("openlearn_palette_recent");return n?JSON.parse(n):[]}catch{return[]}}),[ee,U]=f.useState({}),W=n=>{o||(D(u=>{const p=[n,...u.filter(k=>k!==n)].slice(0,6);try{localStorage.setItem("openlearn_palette_recent",JSON.stringify(p))}catch{}return p}),t(n))},P=(n,u)=>{u.stopPropagation(),q(p=>{const $=p.includes(n)?p.filter(I=>I!==n):[...p,n];try{localStorage.setItem("openlearn_palette_favs",JSON.stringify($))}catch{}return $})},oe=n=>{U(u=>({...u,[n]:!u[n]}))},le=ke(),re=[...Ce,...le],J=re.filter(n=>{if(S.trim()){const u=S.toLowerCase(),p=n.labelZh.toLowerCase().includes(u)||n.descriptionZh.toLowerCase().includes(u),k=n.labelEn.toLowerCase().includes(u)||n.descriptionEn.toLowerCase().includes(u);if(!p&&!k)return!1}return T==="favorites"?_.includes(n.type):T==="recent"?F.includes(n.type):!0}),X=ae.useRef(null),Y=ae.useRef(null),A=ae.useRef(null),Z=ae.useRef(null),[Q,V]=f.useState(null);return f.useEffect(()=>{if(!b){Z.current&&(clearTimeout(Z.current),Z.current=null),A.current&&(clearTimeout(A.current),A.current=null),V(null),z?.(null);return}const{clientX:n,clientY:u}=b;if(X.current){const p=X.current.getBoundingClientRect(),k=n>=p.left&&n<=p.right&&u>=p.top&&u<=p.bottom;k&&l?A.current||(A.current=setTimeout(()=>{d(!1),y?.(!1),A.current=null},250)):!k&&A.current&&(clearTimeout(A.current),A.current=null)}if(Y.current){const p=Y.current.getBoundingClientRect(),k=n>=p.left&&n<=p.right&&u>=p.top&&u<=p.bottom;if(k&&M?Z.current||(Z.current=setTimeout(()=>{H(!1),Z.current=null},250)):!k&&Z.current&&(clearTimeout(Z.current),Z.current=null),!M&&r&&r.length>0){let $=null;Y.current.querySelectorAll("[data-page-index]").forEach(i=>{const w=i.getBoundingClientRect();if(n>=w.left&&n<=w.right&&u>=w.top&&u<=w.bottom){const L=i.getAttribute("data-page-index");L!==null&&($=parseInt(L,10))}}),$!==null&&$!==b.initialPage?(V($),z?.({type:"page",pageIndex:$})):(V(null),z?.(null))}}},[b,l,M,r,y,z]),l?e.jsxs("div",{ref:X,className:`w-14 shrink-0 border-r border-theme bg-surface-secondary/40 backdrop-blur-md p-2 flex flex-col items-center gap-3 select-none transition-all duration-300 ${b?"ring-2 ring-primary-theme/50 bg-primary-theme/10":""}`,children:[e.jsx("button",{type:"button",onClick:g,className:"w-10 h-10 rounded-xl bg-surface hover:bg-surface-secondary border border-theme text-muted hover:text-main flex items-center justify-center transition-all cursor-pointer shadow-2xs hover:scale-105",title:s==="zh"?"展开备课组件库 (Ctrl+B)":"Expand Component Palette",children:e.jsx(_e,{size:16})}),e.jsx("div",{className:"w-8 h-px bg-border/60 my-0.5"}),r&&r.length>0&&e.jsxs("button",{type:"button",onClick:g,className:"w-10 h-10 rounded-xl bg-surface hover:bg-primary-theme/10 border border-theme text-primary-theme flex items-center justify-center transition-all cursor-pointer shadow-2xs group relative",title:`${s==="zh"?"页面大纲":"Outline"} (P${a+1}/${r.length}) - ${s==="zh"?"点击展开":"Click to expand"}`,children:[e.jsx(pe,{size:16}),e.jsx("span",{className:"absolute -top-1 -right-1 text-[9px] bg-primary-theme text-white rounded-full w-4 h-4 flex items-center justify-center font-bold",children:a+1})]}),e.jsx("div",{className:"flex flex-col gap-2 overflow-y-auto max-h-[calc(100vh-220px)] p-0.5",children:re.slice(0,8).map(n=>{const u=n.icon||xe;return e.jsx("button",{type:"button",onClick:()=>W(n.type),disabled:o,"aria-disabled":o,className:`w-10 h-10 rounded-xl bg-surface border border-theme text-main flex items-center justify-center transition-all shadow-2xs group relative ${o?"opacity-50 cursor-not-allowed":"hover:bg-primary-theme/10 hover:border-primary-theme cursor-pointer"}`,title:`${s==="zh"?n.labelZh:n.labelEn} - ${s==="zh"?"点击配置":"Configure"}`,children:e.jsx(u,{size:16,className:"text-primary-theme transition-transform group-hover:scale-110"})},n.type)})})]}):e.jsxs("div",{ref:X,className:`w-[260px] shrink-0 border-r border-theme bg-surface-secondary/40 backdrop-blur-md p-3.5 overflow-y-auto flex flex-col gap-3.5 font-sans select-none text-main transition-all duration-300 ${b&&Q!==null?"ring-1 ring-primary-theme/30":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-theme/60 pb-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-primary-theme/10 text-primary-theme flex items-center justify-center",children:e.jsx(xe,{size:15})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-black text-main uppercase tracking-wider",children:s==="zh"?"备课组件画板":"Palette"}),e.jsxs("span",{className:"text-[10px] text-muted",children:[J.length," ",s==="zh"?"个可用组件":"components"]})]})]}),e.jsx("button",{type:"button",onClick:g,className:"p-1.5 rounded-lg text-muted hover:text-main hover:bg-surface border border-theme/50 transition-colors cursor-pointer",title:s==="zh"?"收起组件面板以扩大画布":"Collapse Palette",children:e.jsx(Me,{size:14})})]}),r&&r.length>0&&e.jsxs("div",{ref:Y,className:`bg-surface rounded-xl border border-theme p-2.5 flex flex-col gap-2 shadow-2xs transition-all duration-200 ${Q!==null?"border-primary-theme shadow-md ring-1 ring-primary-theme/30":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("button",{type:"button",onClick:()=>H(n=>!n),className:"flex items-center gap-1.5 text-xs font-bold text-main hover:text-primary-theme transition-colors cursor-pointer",children:[e.jsx(pe,{size:14,className:"text-primary-theme"}),e.jsxs("span",{children:[s==="zh"?"页面大纲":"Outline"," (",r.length,")"]}),e.jsx(fe,{size:13,className:`text-muted transition-transform duration-200 ${M?"-rotate-90":""}`})]}),!o&&x&&e.jsx("button",{type:"button",onClick:()=>x(),className:"p-1 rounded-md text-muted hover:text-primary-theme hover:bg-primary-theme/10 transition-colors cursor-pointer",title:s==="zh"?"新建白板页面":"Add page",children:e.jsx(ce,{size:13})})]}),M?e.jsxs("div",{onClick:()=>H(!1),className:`flex items-center justify-between text-2xs px-2 py-1 bg-surface-secondary/70 rounded-lg text-muted hover:text-main cursor-pointer transition-colors ${b?"border border-dashed border-primary-theme/60 bg-primary-theme/10 text-primary-theme font-medium animate-pulse":""}`,children:[e.jsx("span",{className:"truncate max-w-[170px]",children:b?s==="zh"?"🎯 悬停自动展开页面大纲":"🎯 Hover to expand outline":`${s==="zh"?"当前":"Current"}: ${r[a]?.title||`P${a+1}`}`}),e.jsx("span",{className:"text-[10px] text-primary-theme font-medium",children:s==="zh"?"展开":"Expand"})]}):e.jsx("div",{className:"flex flex-col gap-1 max-h-48 overflow-y-auto pr-0.5 no-scrollbar",children:r.map((n,u)=>{const p=u===a,k=K===u,$=Q===u;return e.jsxs("div",{"data-page-index":u,onClick:()=>{k||N?.(u)},className:`group flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-all cursor-pointer ${$?"ring-2 ring-primary-theme ring-offset-1 border-dashed border-2 border-primary-theme bg-primary-theme/15 animate-pulse":p?"bg-primary-theme text-white font-semibold shadow-xs":"bg-surface hover:bg-surface-secondary text-main border border-theme/40"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 truncate min-w-0 flex-1",children:[e.jsxs("span",{className:`text-[10px] px-1 py-0.2 rounded font-mono shrink-0 ${$?"bg-primary-theme text-white font-bold":p?"bg-white/20 text-white":"bg-surface-secondary text-muted"}`,children:["P",u+1]}),k?e.jsx("input",{type:"text",autoFocus:!0,value:j,onChange:I=>E(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(j.trim()&&c?.(u,j.trim()),h(null)),I.key==="Escape"&&h(null)},onBlur:()=>{j.trim()&&c?.(u,j.trim()),h(null)},className:"px-1.5 py-0.5 text-xs bg-surface border border-primary-theme rounded text-main outline-none w-full",onClick:I=>I.stopPropagation()}):e.jsx("span",{className:"truncate",children:n.title})]}),$&&e.jsxs("span",{className:"text-[10px] font-bold text-primary-theme animate-bounce shrink-0 flex items-center gap-1 pl-1",children:[e.jsx("span",{children:"📥"}),e.jsx("span",{children:s==="zh"?"松开移入":"Drop"})]}),!o&&!k&&e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity ml-1 shrink-0",onClick:I=>I.stopPropagation(),children:[c&&e.jsx("button",{type:"button",onClick:()=>{h(u),E(n.title)},className:`p-0.5 rounded hover:bg-black/10 cursor-pointer ${p?"text-white":"text-muted hover:text-main"}`,title:"重命名",children:e.jsx(Fe,{size:11})}),r.length>1&&v&&e.jsx("button",{type:"button",onClick:()=>{window.confirm(`确定删除页面"${n.title}"吗?页面内的组件也将被清理。`)&&v(u)},className:`p-0.5 rounded hover:bg-rose-500/20 text-rose-500 cursor-pointer ${p?"text-white hover:bg-white/20":""}`,title:"删除此页",children:e.jsx(de,{size:11})})]})]},n.id||u)})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ze,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-muted"}),e.jsx("input",{type:"text",value:S,onChange:n=>B(n.target.value),placeholder:s==="zh"?"搜索画板组件...":"Search components...",className:"w-full pl-8 pr-7 py-1.5 bg-surface border border-theme rounded-xl text-xs text-main placeholder-muted outline-none focus:border-primary-theme focus:ring-1 focus:ring-primary-theme transition-all shadow-2xs"}),S&&e.jsx("button",{onClick:()=>B(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-main cursor-pointer",children:e.jsx(we,{size:12})})]}),e.jsxs("div",{className:"flex items-center gap-1 bg-surface border border-theme p-1 rounded-xl shadow-2xs",children:[e.jsx("button",{type:"button",onClick:()=>G("all"),className:`flex-1 py-1 text-xs rounded-lg transition-all cursor-pointer ${T==="all"?"bg-surface-secondary text-main font-bold shadow-2xs":"text-muted hover:text-main font-medium"}`,children:s==="zh"?"全部":"All"}),e.jsxs("button",{type:"button",onClick:()=>G("favorites"),className:`flex-1 py-1 text-xs rounded-lg transition-all flex items-center justify-center gap-1 cursor-pointer ${T==="favorites"?"bg-amber-500/10 text-amber-600 font-bold border border-amber-500/20 shadow-2xs":"text-muted hover:text-amber-500 font-medium"}`,children:[e.jsx(je,{size:11,className:T==="favorites"?"fill-amber-500":""}),e.jsx("span",{children:s==="zh"?"常用":"Favs"})]}),e.jsxs("button",{type:"button",onClick:()=>G("recent"),className:`flex-1 py-1 text-xs rounded-lg transition-all flex items-center justify-center gap-1 cursor-pointer ${T==="recent"?"bg-primary-theme/10 text-primary-theme font-bold border border-primary-theme/20 shadow-2xs":"text-muted hover:text-primary-theme font-medium"}`,children:[e.jsx(ue,{size:11}),e.jsx("span",{children:s==="zh"?"最近":"Recent"})]})]}),e.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-y-auto pr-0.5",children:[J.length===0?e.jsxs("div",{className:"text-center py-8 text-muted text-xs",children:[e.jsx(Ne,{size:24,className:"mx-auto mb-2 opacity-30 text-primary-theme"}),e.jsx("p",{className:"font-bold text-main",children:s==="zh"?"未找到相关组件":"No components found"}),e.jsx("p",{className:"text-[11px] mt-1 text-muted",children:T!=="all"?s==="zh"?"尝试切换回「全部」标签":"Try switching to All tab":s==="zh"?"请更换关键词重新搜索":"Try a different keyword"})]}):T!=="all"||S.trim()?e.jsx("div",{className:"grid grid-cols-2 gap-2",children:J.map(n=>e.jsx(ye,{config:n,lang:s,onActivate:W,disabled:o,isFavorite:_.includes(n.type),onToggleFavorite:P},n.type))}):(()=>{const n=[...Se];return J.forEach(u=>{n.some(p=>p.id===u.group)||n.push({id:u.group,labelZh:u.group,labelEn:u.group})}),n.map(u=>{const p=J.filter(I=>I.group===u.id);if(p.length===0)return null;const k=se[p[0].color]||se.indigo,$=ee[u.id];return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>oe(u.id),className:"flex items-center justify-between px-1.5 py-1 text-left rounded-lg transition-colors cursor-pointer hover:bg-surface-secondary/60",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${k.groupAccent}`}),e.jsx("span",{className:`text-[11px] font-black uppercase tracking-wider ${k.groupText}`,children:s==="zh"?u.labelZh:u.labelEn})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted",children:[e.jsxs("span",{className:"text-[10px] font-mono opacity-80",children:["(",p.length,")"]}),$?e.jsx(Be,{size:12}):e.jsx(fe,{size:12})]})]}),!$&&e.jsx("div",{className:"grid grid-cols-2 gap-2",children:p.map(I=>e.jsx(ye,{config:I,lang:s,onActivate:W,disabled:o,isFavorite:_.includes(I.type),onToggleFavorite:P},I.type))})]},u.id)})})(),e.jsx(O,{slot:"editor.palette_item",slotProps:{lang:s,onActivate:W,readOnly:o}})]})]})}function st({lang:s,segments:t,activeSegmentId:o,setActiveSegmentId:m,draggedSegmentIdx:y,setDraggedSegmentIdx:r,selectedLesson:a,saveTimeline:N,readOnly:x=!1,editorPanelsExpanded:v,setEditorPanelsExpanded:c,dragState:b,onHoverDropTarget:z}){const C=t.findIndex(h=>h.id===o),d=t.length>1&&C>=0?C/(t.length-1):0,l=C>=0?me(t[C].color):null,g=f.useRef(null),[S,B]=f.useState(null);f.useEffect(()=>{if(!b){B(null),z?.(null);return}const{clientX:h,clientY:j}=b;if(g.current&&t&&t.length>0){let E=null;g.current.querySelectorAll("[data-segment-id]").forEach(G=>{const _=G.getBoundingClientRect();if(h>=_.left&&h<=_.right&&j>=_.top&&j<=_.bottom){const q=G.getAttribute("data-segment-id");q&&(E=q)}}),E!==null&&E!==b.initialSegmentId?(B(E),z?.({type:"segment",segmentId:E})):(B(null),z?.(null))}},[b,t,z]);const M=t.reduce((h,j)=>{const{seconds:E}=et(j,{fallbackSeconds:600});return E==null||!Number.isFinite(E)?h:h+Math.round(E/60)},0),H=h=>{if(x)return;if(y===null||y===h){r(null);return}const j=[...t],[E]=j.splice(y,1);j.splice(h,0,E),r(null),a&&N(a,j)},K=()=>{if(x||!a)return;const h="seg-"+Math.random().toString(36).slice(2,9),j={id:h,title:s==="zh"?`新环节 ${t.length+1}`:`Segment ${t.length+1}`,notes:"",type:"lecture",duration:"10m",color:Ie};N(a,[...t,j]),m(h),c(!0)};return e.jsxs("div",{ref:g,className:`sticky top-0 z-30 flex items-center justify-between gap-3 px-3.5 py-2 border-b border-theme bg-surface/95 backdrop-blur-md shrink-0 select-none overflow-x-auto text-main shadow-2xs transition-all ${b?"ring-1 ring-primary-theme/30":""}`,children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0 border-r border-theme pr-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-lg bg-primary-theme/10 text-primary-theme flex items-center justify-center",children:e.jsx(Ge,{size:14})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-black uppercase tracking-wider text-main whitespace-nowrap",children:s==="zh"?"教学流程":"Lesson Flow"}),e.jsxs("span",{className:"text-[10px] font-mono text-muted flex items-center gap-0.5",children:[e.jsx(ue,{size:9}),e.jsxs("span",{children:[M," min"]})]})]})]}),e.jsxs("div",{className:"relative flex items-center gap-2 py-0.5 min-w-0 flex-1",children:[e.jsx("div",{className:"absolute left-3 right-3 top-1/2 h-0.5 -translate-y-1/2 bg-border/80 rounded-full"}),C>=0&&e.jsx("div",{className:`absolute left-3 top-1/2 h-0.5 -translate-y-1/2 rounded-full transition-all duration-300 ${l?.rail||"bg-primary-theme"}`,style:{width:`calc(${d*100}% - 0.5rem)`}}),t.map((h,j)=>{const E=h.id===o,T=C>=0&&j<C,G=y===j,_=S===h.id,q=Ee(h.type),F=me(h.color),D=q.icon,ee=_?"ring-2 ring-primary-theme ring-offset-2 border-dashed border-2 border-primary-theme bg-primary-theme/20 shadow-md scale-108 animate-pulse text-primary-theme font-bold":E?F.solid+" shadow-md ring-2 ring-primary-theme/30 scale-105":T?"bg-surface-secondary/90 text-main/80 border-primary-theme/30":F.color;return e.jsxs("div",{"data-segment-id":h.id,draggable:!x,onDragStart:U=>{if(x){U.preventDefault();return}r(j),U.dataTransfer.effectAllowed="move"},onDragOver:U=>!x&&U.preventDefault(),onDrop:()=>H(j),onClick:()=>m(h.id),"aria-disabled":x,className:`relative z-10 flex items-center gap-1.5 px-2.5 py-1 rounded-xl text-xs font-semibold ${x?"cursor-pointer":"cursor-grab"} transition-all duration-200 border border-theme/60 shadow-2xs group ${ee} ${G?"opacity-40 scale-95":"hover:scale-102"}`,children:[e.jsx(Oe,{size:11,className:"opacity-0 group-hover:opacity-60 -ml-0.5 text-muted cursor-grab"}),e.jsx("span",{className:"text-[10px] font-mono font-bold opacity-75",children:j+1}),e.jsx(D,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate max-w-[90px]",children:h.title}),e.jsxs("span",{className:"text-[10px] font-mono opacity-60",children:["(",h.duration||"10m",")"]}),T&&e.jsx(ze,{size:11,className:"text-emerald-500 shrink-0 ml-0.5"}),e.jsx(O,{slot:"editor.timeline.node_badge",slotProps:{segment:h,idx:j,isActive:E,isCompleted:T,lang:s}}),_&&e.jsxs("span",{className:"text-[10px] font-bold text-primary-theme animate-bounce flex items-center gap-0.5 ml-1",children:[e.jsx("span",{children:"📥"}),e.jsx("span",{children:s==="zh"?"移入此环节":"Move here"})]})]},h.id)}),a&&!x&&e.jsxs("button",{type:"button",onClick:K,className:"relative z-10 flex items-center gap-1 px-2 py-1 rounded-xl text-xs font-medium text-muted hover:text-primary-theme bg-surface hover:bg-surface-secondary border border-dashed border-theme hover:border-primary-theme transition-all cursor-pointer shadow-2xs",title:s==="zh"?"追加新环节":"Add new segment",children:[e.jsx(ce,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:s==="zh"?"加环节":"Add"})]})]}),e.jsxs("button",{type:"button",onClick:()=>c(h=>!h),"aria-expanded":v,className:`px-3 py-1 text-xs font-bold rounded-xl border transition-all flex items-center gap-1.5 cursor-pointer shrink-0 ${v?"bg-primary-theme text-white border-primary-theme shadow-md shadow-primary-theme/30 ring-2 ring-primary-theme/30 scale-102":"bg-surface hover:bg-surface-secondary text-muted hover:text-main border-theme shadow-2xs"}`,title:s==="zh"?"展开/收起环节设置面板":"Toggle Segment Settings",children:[e.jsx(He,{size:13,className:v?"rotate-90 transition-transform text-white":""}),e.jsx("span",{children:s==="zh"?"环节参数":"Settings"}),v&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white animate-ping ml-0.5"})]})]})}const rt=[{type:"quiz_completed",labelZh:"完成练习",labelEn:"Quiz completed"},{type:"quiz_accuracy",labelZh:"练习正确率",labelEn:"Quiz accuracy"},{type:"assignment_submitted",labelZh:"已提交作业",labelEn:"Assignment submitted"},{type:"dwell_seconds",labelZh:"停留时长",labelEn:"Dwell time"},{type:"checked_in",labelZh:"已签到",labelEn:"Checked in"}];function at(s){const t=[];for(const o of s){if(o.status!=="active")continue;let m={};try{m=JSON.parse(o.manifest)}catch{continue}const y=m.contributes?.["segment.gate_type"];if(Array.isArray(y))for(const r of y){if(!r||typeof r!="object")continue;const a=r.id,N=r.commandType;typeof a!="string"||typeof N!="string"||t.push(r)}}return t}function nt(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&typeof t.type=="string"):[]}function it({lang:s,segment:t,readOnly:o=!1,onPatch:m}){const y=ve(c=>c.plugins),r=at(y),a=nt(t.gates),N=[...rt.map(c=>({type:c.type,label:s==="zh"?c.labelZh:c.labelEn})),...r.map(c=>({type:c.id,label:(s==="zh"?c.labelZh:c.labelEn)||c.id}))],x=c=>m({gates:c}),v=(c,b)=>{const z=a.map((C,d)=>d===c?{...C,...b,params:{...C.params||{},...b.params||{}}}:C);x(z)};return e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl p-2.5 bg-indigo-500/5 border border-indigo-500/20",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-[11px] font-bold text-indigo-700 dark:text-indigo-300 flex items-center gap-1.5",children:[e.jsx(qe,{size:12}),e.jsx("span",{children:s==="zh"?"进入条件":"Entry conditions"})]}),!o&&e.jsxs("button",{type:"button",onClick:()=>x([...a,{type:"quiz_completed",params:{}}]),className:"text-[11px] font-bold text-indigo-700 flex items-center gap-1 cursor-pointer",children:[e.jsx(ce,{size:12}),s==="zh"?"添加条件":"Add condition"]})]}),e.jsx("p",{className:"text-[10px] text-muted leading-snug",children:s==="zh"?"课级 progress_mode 已废弃。条件写在本环节上,全部满足后学生才能看到这一环节。全班仍跟随教师的当前环节。":"Lesson-level progress_mode is deprecated. Students see this segment only after every condition below is met. The class still shares one current segment."}),a.length===0&&e.jsx("p",{className:"text-[11px] text-muted",children:s==="zh"?"未设置条件,跟随课堂即可进入。":"No conditions. Following the class is enough."}),a.map((c,b)=>e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-2 items-end",children:[e.jsxs("label",{className:"flex flex-col gap-1 sm:col-span-2",children:[e.jsx("span",{className:"text-[10px] font-bold text-muted",children:s==="zh"?"条件类型":"Type"}),e.jsxs("select",{"aria-label":s==="zh"?"条件类型":"Condition type",value:c.type,disabled:o,onChange:z=>{const C=a.map((d,l)=>l===b?{type:z.target.value,params:{}}:d);x(C)},className:"border border-theme/80 px-2 py-1.5 rounded-xl bg-surface text-xs",children:[N.map(z=>e.jsx("option",{value:z.type,children:z.label},z.type)),!N.some(z=>z.type===c.type)&&e.jsx("option",{value:c.type,children:c.type})]})]}),e.jsx(lt,{lang:s,gate:c,readOnly:o,onChange:z=>v(b,{params:z})}),!o&&e.jsxs("button",{type:"button",onClick:()=>x(a.filter((z,C)=>C!==b)),className:"px-2 py-1.5 text-xs text-rose-600 border border-rose-200 rounded-xl cursor-pointer flex items-center justify-center gap-1",children:[e.jsx(de,{size:12}),s==="zh"?"移除":"Remove"]})]},`${c.type}-${b}`))]})}function ot(s,t){const o=s?.[t];return typeof o=="string"||typeof o=="number"?String(o):""}function lt({lang:s,gate:t,readOnly:o,onChange:m}){const y=t.params||{},r=(a,N,x,v=!1)=>e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-bold text-muted",children:N}),e.jsx("input",{value:ot(y,a),disabled:o,placeholder:x,onChange:c=>{if(!v){m({[a]:c.target.value});return}const b=Number(c.target.value);m({[a]:c.target.value.trim()===""||!Number.isFinite(b)?c.target.value:b})},className:"border border-theme/80 px-2 py-1.5 rounded-xl bg-surface text-xs"})]});return t.type==="checked_in"?e.jsx("div",{}):t.type==="quiz_accuracy"?e.jsxs(e.Fragment,{children:[r("minScore",s==="zh"?"最低分":"Min score","60",!0),r("elementId",s==="zh"?"题目 ID":"Element ID","")]}):t.type==="dwell_seconds"?r("seconds",s==="zh"?"秒":"Seconds","60",!0):t.type==="assignment_submitted"?r("assignmentId",s==="zh"?"作业 ID":"Assignment ID",""):t.type==="quiz_completed"?r("elementId",s==="zh"?"题目 ID":"Element ID",""):r("segmentId",s==="zh"?"环节 ID":"Segment ID","")}function ct({lang:s,segment:t,readOnly:o=!1,onPatch:m,onDelete:y}){const r=Te();return e.jsxs("div",{className:"relative mx-3 sm:mx-4 my-3 rounded-2xl bg-surface/98 backdrop-blur-xl border-2 border-primary-theme/50 dark:border-primary-theme/60 shadow-2xl shadow-primary-theme/20 ring-4 ring-primary-theme/15 overflow-hidden shrink-0 text-main animate-in fade-in-0 zoom-in-[0.98] slide-in-from-top-3 duration-300 ease-out transition-all",children:[e.jsx("div",{className:"pointer-events-none absolute -top-12 -left-12 w-64 h-32 bg-primary-theme/15 rounded-full blur-2xl opacity-60"}),e.jsx("div",{className:"pointer-events-none absolute -bottom-12 -right-12 w-64 h-32 bg-indigo-500/10 rounded-full blur-2xl opacity-60"}),e.jsx("div",{className:"relative h-1.5 w-full bg-gradient-to-r from-primary-theme via-indigo-500 to-sky-400 shadow-sm shadow-primary-theme/30",children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/40 to-transparent animate-pulse"})}),e.jsxs("div",{className:"p-3.5 sm:p-4 flex flex-col gap-3.5 relative z-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 pb-2.5 border-b border-primary-theme/15",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsxs("div",{className:"relative w-8 h-8 rounded-xl bg-gradient-to-br from-primary-theme/25 to-primary-theme/10 text-primary-theme flex items-center justify-center shrink-0 border border-primary-theme/40 shadow-xs",children:[e.jsx(Ue,{size:15}),e.jsxs("span",{className:"absolute -top-1 -right-1 flex h-3 w-3",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary-theme opacity-80"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-primary-theme ring-2 ring-surface shadow-xs"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 truncate",children:[e.jsxs("span",{className:"text-xs sm:text-sm font-black text-main tracking-tight truncate flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-primary-theme animate-pulse"}),s==="zh"?`环节参数配置:${t.title}`:`Segment Config: ${t.title}`]}),e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[10px] font-black uppercase tracking-wider bg-primary-theme text-white shadow-xs shadow-primary-theme/30 animate-pulse",children:[e.jsx(Ne,{size:10}),s==="zh"?"正在聚焦编辑":"Active Editing"]}),e.jsxs("span",{className:"text-[10px] text-muted font-mono opacity-80 bg-surface-secondary/80 px-1.5 py-0.5 rounded-md border border-theme/50",children:["ID: ",t.id]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(O,{slot:"editor.timeline.node_badge",slotProps:{segment:t,lang:s,isActive:!0,isCompleted:!1}}),e.jsx(O,{slot:"editor.segment.action",slotProps:{segmentId:t.id,segment:t,lang:s,readOnly:o,onPatch:m}}),o?e.jsx("span",{className:"text-2xs font-semibold text-muted px-2 py-1 rounded-lg border border-theme",children:s==="zh"?"只读":"Read-only"}):e.jsxs("button",{type:"button",onClick:y,className:"px-2.5 py-1 text-xs text-rose-600 hover:text-white bg-rose-500/10 hover:bg-rose-600 border border-rose-500/25 rounded-xl flex items-center gap-1.5 transition-all hover:scale-102 cursor-pointer shadow-2xs shrink-0",title:s==="zh"?"删除当前环节":"Delete Segment",children:[e.jsx(de,{size:12}),e.jsx("span",{children:s==="zh"?"删除环节":"Delete"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-2.5",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-[11px] font-bold text-muted flex items-center gap-1",children:[e.jsx(be,{size:11,className:"text-primary-theme"}),e.jsx("span",{children:s==="zh"?"环节名称":"Title"})]}),e.jsx("input",{type:"text",value:t.title||"",onChange:a=>m({title:a.target.value}),disabled:o,className:"border border-theme/80 px-2.5 py-1.5 rounded-xl bg-surface-secondary/80 focus:bg-surface text-xs text-main font-medium outline-none focus:border-primary-theme focus:ring-2 focus:ring-primary-theme/25 transition-all shadow-2xs"})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-[11px] font-bold text-muted flex items-center gap-1",children:[e.jsx(ue,{size:11,className:"text-primary-theme"}),e.jsx("span",{children:s==="zh"?"预计用时":"Duration"})]}),e.jsx("input",{type:"text",value:t.duration||"10m",onChange:a=>m({duration:a.target.value}),disabled:o,placeholder:"例如: 10m",className:"border border-theme/80 px-2.5 py-1.5 rounded-xl bg-surface-secondary/80 focus:bg-surface text-xs text-main font-mono outline-none focus:border-primary-theme focus:ring-2 focus:ring-primary-theme/25 transition-all shadow-2xs"})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-[11px] font-bold text-muted flex items-center gap-1",children:[e.jsx(We,{size:11,className:"text-primary-theme"}),e.jsx("span",{children:s==="zh"?"教学形态":"Instructional Type"})]}),e.jsx("select",{value:t.type||"lecture",onChange:a=>m({type:a.target.value}),disabled:o,className:"border border-theme/80 px-2.5 py-1.5 rounded-xl bg-surface-secondary/80 focus:bg-surface text-xs text-main font-medium outline-none focus:border-primary-theme focus:ring-2 focus:ring-primary-theme/25 transition-all shadow-2xs cursor-pointer",children:r.map(a=>e.jsx("option",{value:a.id,className:"bg-surface text-main",children:s==="zh"?a.labelZh:a.labelEn},a.id))})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-[11px] font-bold text-muted flex items-center gap-1",children:[e.jsx(Je,{size:11,className:"text-primary-theme"}),e.jsx("span",{children:s==="zh"?"环节标识色":"Accent Color"})]}),e.jsx("div",{className:"flex items-center gap-1.5 pt-1",children:$e.map(a=>e.jsx("button",{type:"button",onClick:()=>m({color:a.color}),disabled:o,"aria-label":s==="zh"?`选择颜色 ${a.name}`:`Choose color ${a.name}`,className:`w-5 h-5 rounded-full border border-theme/60 transition-all hover:scale-115 cursor-pointer ${a.color.split(" ")[0]} ${t.color===a.color?"ring-2 ring-primary-theme ring-offset-2 scale-110 shadow-xs":""}`,title:a.name},a.name))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 rounded-xl p-2.5 bg-amber-500/5 dark:bg-amber-500/10 border border-amber-500/20",children:[e.jsxs("span",{className:"text-[11px] font-bold text-amber-700 dark:text-amber-400 flex items-center gap-1.5",children:[e.jsx(be,{size:12,className:"text-amber-500"}),e.jsx("span",{children:s==="zh"?"教师备课备忘 & 教学设计要点":"Instructional Notes"})]}),e.jsx("textarea",{rows:2,value:t.notes||"",onChange:a=>m({notes:a.target.value}),disabled:o,placeholder:s==="zh"?"写给自己的教学小抄:本环节核心提问、白板板书重点、容易卡壳的步骤…":"Teaching points, blackboard highlights, key student friction points…",className:"w-full border border-theme/70 px-3 py-1.5 rounded-xl bg-surface/90 focus:bg-surface text-xs text-main placeholder-muted outline-none focus:border-primary-theme focus:ring-2 focus:ring-primary-theme/20 transition-all resize-y shadow-2xs leading-relaxed"})]}),e.jsx(it,{lang:s,segment:t,readOnly:o,onPatch:m}),e.jsx(O,{slot:"editor.segment.type_config",slotProps:{segmentType:t.type||"lecture",segment:t,lang:s,readOnly:o,onPatch:m}}),e.jsx(O,{slot:"editor.timeline_segment",slotProps:{segment:t,lang:s,readOnly:o,onPatch:m}})]})]})}function dt({config:s,lang:t,initialData:o,onConfirm:m,onCancel:y}){const[r,a]=f.useState(()=>({...o})),[N,x]=f.useState({}),v=s.icon,c=se[s.color];f.useEffect(()=>{let d=!1;const l=s.editFields.filter(g=>g.kind==="select"&&g.loadOptions);if(l.length!==0)return Promise.all(l.map(async g=>{try{const S=await g.loadOptions();return[g.key,S]}catch{return[g.key,[]]}})).then(g=>{d||x(Object.fromEntries(g))}),()=>{d=!0}},[s]);const b=(d,l)=>{a(g=>({...g,[d]:l}))},z=Array.isArray(r.options)?r.options:[],C=(d,l)=>{a(g=>({...g,options:z.map((S,B)=>B===d?l:S)}))};return e.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:e.jsxs("div",{className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-md flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-xl ${c.iconBg} ${c.iconText}`,children:v?e.jsx(v,{size:18}):null}),e.jsx("h2",{className:"font-bold text-gray-800 text-base",children:t==="zh"?`编辑:${s.labelZh}`:`Edit: ${s.labelEn}`})]}),e.jsx("button",{onClick:y,className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors text-lg",children:"×"})]}),e.jsx("div",{className:"p-5 space-y-4",children:s.editFields.length===0?e.jsx("p",{className:"text-sm text-gray-500 leading-relaxed",children:t==="zh"?"该组件无需预编辑内容,确认后即可添加到画板。":"No content to edit for this component. Confirm to add it to the board."}):s.editFields.map(d=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-600",children:t==="zh"?d.labelZh:d.labelEn}),d.kind==="options"?e.jsx("div",{className:"grid grid-cols-2 gap-2",children:z.map((l,g)=>e.jsx("input",{value:l,onChange:S=>C(g,S.target.value),placeholder:`${String.fromCharCode(65+g)}`,className:"border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"},g))}):d.kind==="textarea"?e.jsx("textarea",{value:r[d.key]??"",onChange:l=>b(d.key,l.target.value),placeholder:t==="zh"?d.placeholderZh:d.placeholderEn,rows:5,className:`w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-y ${d.key==="code"||d.key==="markdown"?"font-mono text-[12px]":""}`}):d.kind==="select"?e.jsxs("select",{value:r[d.key]??"",onChange:l=>b(d.key,l.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 bg-white",children:[e.jsx("option",{value:"",children:t==="zh"?"— 不选择 —":"— None —"}),(N[d.key]??d.options??[]).map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))]}):e.jsx("input",{type:"text",value:r[d.key]??"",onChange:l=>b(d.key,l.target.value),placeholder:t==="zh"?d.placeholderZh:d.placeholderEn,className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"})]},d.key))}),e.jsxs("div",{className:"p-4 border-t border-gray-100 flex justify-end gap-2",children:[e.jsx("button",{onClick:y,className:"px-4 py-2 text-sm rounded-lg border border-gray-200 text-gray-600 hover:bg-gray-100 cursor-pointer",children:t==="zh"?"取消":"Cancel"}),e.jsx("button",{onClick:()=>m(r),className:"px-4 py-2 text-sm rounded-lg bg-indigo-600 text-white hover:bg-indigo-700 cursor-pointer",children:t==="zh"?"添加到画板":"Add to Board"})]})]})})}class ut{constructor(t){this.lessonId=null,this.debounceDelay=800,this.status="none",this.lastSavedTime=null,this.pendingMap=new Map,this.timer=null,this.isFlushing=!1,this.lastError=null,this.saveHandler=null,this.interceptors=new Set,this.listeners=new Set,t?.debounceDelay!==void 0&&(this.debounceDelay=t.debounceDelay),t?.saveHandler&&(this.saveHandler=t.saveHandler)}setLessonId(t){this.lessonId!==t&&(this.pendingMap.size>0&&this.lessonId&&this.flush(),this.lessonId=t,this.status=t?"saved":"none",this.notifyListeners())}getLessonId(){return this.lessonId}setSaveHandler(t){this.saveHandler=t}setDebounceDelay(t){this.debounceDelay=Math.max(100,t)}getDebounceDelay(){return this.debounceDelay}getStatus(){return this.status}getLastSavedTime(){return this.lastSavedTime}getPendingCount(){return this.pendingMap.size}getLastError(){return this.lastError}registerInterceptor(t){return this.interceptors.add(t),()=>{this.interceptors.delete(t)}}registerListener(t){return this.listeners.add(t),t(this.status,{lessonId:this.lessonId||void 0,lastSavedTime:this.lastSavedTime,count:this.pendingMap.size}),()=>{this.listeners.delete(t)}}notifyListeners(){this.listeners.forEach(t=>{try{t(this.status,{lessonId:this.lessonId||void 0,lastSavedTime:this.lastSavedTime,error:this.lastError,count:this.pendingMap.size})}catch(o){console.error("[WhiteboardAutoSaveManager] Listener error:",o)}})}queueUpdate(t,o){if(!this.lessonId)return;const m=this.pendingMap.get(t)||{};this.pendingMap.set(t,{...m,...o}),this.status="pending",this.notifyListeners(),ne.publish({id:ie(),type:"whiteboard.autosave.pending",source:"whiteboard.autosave",payload:{lessonId:this.lessonId,elementId:t,pendingCount:this.pendingMap.size},timestamp:Date.now(),correlationId:this.lessonId}),this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},this.debounceDelay)}async flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.pendingMap.size===0||!this.lessonId||!this.saveHandler)return this.status==="pending"&&(this.status="saved",this.notifyListeners()),!0;if(this.isFlushing)return!1;let t=!1;const o={lessonId:this.lessonId,pendingElements:new Map(this.pendingMap),cancel:()=>{t=!0}};for(const a of this.interceptors)try{if(await a(o)===!1||t){t=!0;break}}catch(N){console.error("[WhiteboardAutoSaveManager] Interceptor error:",N)}if(t)return!1;this.isFlushing=!0,this.status="saving",this.notifyListeners(),ne.publish({id:ie(),type:"whiteboard.autosave.saving",source:"whiteboard.autosave",payload:{lessonId:this.lessonId,pendingCount:this.pendingMap.size},timestamp:Date.now(),correlationId:this.lessonId});const m=Array.from(this.pendingMap.entries()),y=[];let r=!1;try{for(const[a,N]of m)await this.saveHandler(this.lessonId,a,N)?(y.push(a),this.pendingMap.get(a)===N&&this.pendingMap.delete(a)):r=!0;if(r)throw new Error("One or more element updates failed to save");return this.lastSavedTime=new Date,this.lastError=null,this.status=this.pendingMap.size>0?"pending":"saved",this.notifyListeners(),ne.publish({id:ie(),type:"whiteboard.autosave.saved",source:"whiteboard.autosave",payload:{lessonId:this.lessonId,savedElementIds:y,lastSavedTime:this.lastSavedTime.toISOString()},timestamp:Date.now(),correlationId:this.lessonId}),!0}catch(a){return this.lastError=a,this.status="error",this.notifyListeners(),ne.publish({id:ie(),type:"whiteboard.autosave.error",source:"whiteboard.autosave",payload:{lessonId:this.lessonId,error:a?.message||String(a)},timestamp:Date.now(),correlationId:this.lessonId}),!1}finally{this.isFlushing=!1,this.pendingMap.size>0&&!this.timer&&(this.timer=setTimeout(()=>{this.flush()},this.debounceDelay))}}cancel(){this.timer&&(clearTimeout(this.timer),this.timer=null),this.pendingMap.clear(),this.status=this.lessonId?"saved":"none",this.lastError=null,this.notifyListeners()}}const R=new ut;function mt({lessonId:s,onSaveToServer:t,debounceDelay:o=800,onStatusChange:m}){const[y,r]=f.useState(()=>R.getStatus()),[a,N]=f.useState(()=>R.getLastSavedTime()),[x,v]=f.useState(()=>R.getPendingCount()),c=f.useRef(t);c.current=t;const b=f.useRef(m);b.current=m,f.useEffect(()=>{R.setLessonId(s),R.setDebounceDelay(o),R.setSaveHandler(async(l,g,S)=>c.current(l,g,S))},[s,o]),f.useEffect(()=>{const l=R.registerListener((g,S)=>{r(g),S?.lastSavedTime!==void 0&&N(S.lastSavedTime),S?.count!==void 0&&v(S.count),b.current?.(g,S?.lastSavedTime??null)});return()=>{l()}},[]),f.useEffect(()=>{const l=()=>{R.getPendingCount()>0&&R.flush()};return window.addEventListener("beforeunload",l),()=>{window.removeEventListener("beforeunload",l),R.flush()}},[]);const z=f.useCallback((l,g)=>{R.queueUpdate(l,g)},[]),C=f.useCallback(async()=>R.flush(),[]),d=f.useCallback(()=>{R.cancel()},[]);return{status:y,lastSavedTime:a,pendingCount:x,queueUpdate:z,flush:C,cancel:d,registry:R}}function wt(){const s=De(),{lang:t,session:o,onCopyCourse:m,lessons:y,selectedLesson:r,activeRole:a,setActiveRole:N,editorSaveStatus:x,setEditorSaveStatus:v,editorLastSavedTime:c,setEditorLastSavedTime:b,setTeacherTab:z,handlePaletteActivate:C,timelineSegments:d,activeSegmentId:l,setActiveSegmentId:g,draggedSegmentIdx:S,setDraggedSegmentIdx:B,saveTimeline:M,editorPanelsExpanded:H,setEditorPanelsExpanded:K,fetchElements:h,whiteboardRef:j,elements:E,paletteEdit:T,handlePaletteConfirm:G,setPaletteEdit:_}=Pe(),q=ve(i=>i.session),F=o||q,D=y.find(i=>i.id===r),ee=F?.username==="admin"||F?.userId==="usr_admin"||F?.role==="administrator"||F?.subRole==="administrator",U=!D?.creator_id||D.creator_id===F?.userId||D.creator_id===F?.username,W=ee||U,P=!W||a!=="teacher",[oe,le]=f.useState(!1),[re,J]=f.useState([]),[X,Y]=f.useState(0),[A,Z]=f.useState(null),Q=f.useRef(null),V=f.useRef(null);f.useEffect(()=>{A||(Q.current=null,V.current=null)},[A]),f.useEffect(()=>{if(!s)return;const i=s.getDispatcher?.();if(!i)return;const w=i.registerHandler("host:refresh",async L=>{const te=L.action.payload.target;if(te==="lessons"||te==="all")return r&&h&&await h(r),{success:!0,refreshed:["lessons"]}});return()=>{w.dispose()}},[s,r,h]);const n=async(i,w,L)=>{try{return(await fetch(`/api/lessons/${i}/whiteboard/${w}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:L})})).ok}catch(te){return console.error("[LessonEditorView] autosave element failed:",te),!1}},{queueUpdate:u,flush:p,pendingCount:k}=mt({lessonId:r,onSaveToServer:n,debounceDelay:800,onStatusChange:(i,w)=>{i!=="pending"&&v(i),w&&b(w)}}),$=f.useCallback((i,w)=>{const L=Q.current||V.current;return L?L.type==="page"?((async()=>(await j.current?.moveElementToPage?.(w,L.pageIndex),r&&(await p(),await h(r))))(),!0):L.type==="segment"?((async()=>(await j.current?.moveElementToSegment?.(w,L.segmentId),r&&(await p(),await h(r))))(),!0):!1:!1},[j,r,p,h]);f.useEffect(()=>{if(!r)return;const i=new Ae;return i.broadcastChangeLesson(r),l&&i.broadcastChangeSegment(l),()=>{i.destroy()}},[r,l]);const I=i=>{if(P){alert(W?t==="zh"?"学生视角预览为只读模式。":"Student preview is read-only.":t==="zh"?"【只读模式】您无法直接修改其他教师创建的课程。请点击上方的「一键克隆为我的备课」生成您的专属教案副本。":"[Read-Only Mode] You cannot modify lessons created by other teachers. Please clone it to your own lessons.");return}C(i)};return e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0 bg-surface rounded-2xl border border-theme overflow-hidden shadow-sm text-main transition-colors",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-theme flex flex-wrap items-center justify-between gap-3 shrink-0 bg-surface/85 backdrop-blur-md",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-primary-theme/10 text-primary-theme border border-primary-theme/20 flex items-center justify-center shrink-0",children:e.jsx(Qe,{size:16})}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-primary-theme",children:t==="zh"?"教案与白板编排":"Lesson Orchestrator"}),P&&e.jsx("span",{className:"text-[9px] px-1.5 py-0.2 rounded-full font-bold bg-amber-500/15 text-amber-600 border border-amber-500/30",children:t==="zh"?"只读预览":"Read-Only Preview"})]}),e.jsx("h2",{className:"text-xs sm:text-sm font-black text-main truncate tracking-tight",children:t==="zh"?`课程编辑器: ${D?.title||"未选择课程"}`:`Lesson Editor: ${D?.title||"No Lesson Selected"}`})]})]}),r&&e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 shrink-0",children:[k>0&&x!=="saving"&&e.jsxs("button",{type:"button",onClick:()=>void p(),title:t==="zh"?"有未保存改动,点击立即写入服务器":"Pending changes, click to sync now",className:"flex items-center gap-1.5 text-xs font-bold text-amber-700 dark:text-amber-300 bg-amber-500/10 hover:bg-amber-500/20 border border-amber-500/30 px-2.5 py-1 rounded-full transition-all cursor-pointer shadow-2xs hover:scale-102",children:[e.jsx(ge,{size:11,className:"animate-spin text-amber-600"}),e.jsx("span",{children:t==="zh"?`${k} 项待写入 (点击立即保存)`:`${k} pending (sync now)`})]}),x==="saving"&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold text-amber-700 dark:text-amber-300 bg-amber-500/10 border border-amber-500/30 px-2.5 py-1 rounded-full animate-pulse shadow-2xs",children:[e.jsx(ge,{size:11,className:"animate-spin text-amber-600"}),e.jsx("span",{children:t==="zh"?"同步 SQLite...":"Saving SQLite..."})]}),x==="saved"&&k===0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold text-emerald-700 dark:text-emerald-300 bg-emerald-500/10 border border-emerald-500/30 px-2.5 py-1 rounded-full shadow-2xs",children:[e.jsx(ze,{size:11,className:"text-emerald-500"}),e.jsx("span",{children:t==="zh"?"已自动保存":"Auto-Saved"}),c&&e.jsx("span",{className:"text-[11px] font-mono opacity-70",children:c.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]}),x==="error"&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold text-rose-600 bg-rose-500/10 border border-rose-500/30 px-2.5 py-1 rounded-full shadow-2xs",children:[e.jsx(we,{size:11,className:"text-rose-600"}),e.jsx("span",{children:t==="zh"?"写入失败":"Failed to save"})]}),x==="none"&&k===0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold text-muted bg-surface-secondary border border-theme px-2.5 py-1 rounded-full shadow-2xs",children:[e.jsx(Ve,{size:11,className:"text-muted"}),e.jsx("span",{children:t==="zh"?"同步就绪":"Ready"})]}),e.jsx(O,{slot:"whiteboard.autosave.status",slotProps:{lessonId:r,status:x,pendingCount:k,lastSavedTime:c}}),e.jsx(O,{slot:"whiteboard.autosave.action",slotProps:{lessonId:r,flush:p,pendingCount:k}})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"bg-surface-secondary border border-theme p-1 rounded-xl flex items-center gap-1 shadow-2xs",children:[e.jsxs("button",{type:"button",onClick:()=>N("teacher"),className:`px-3 py-1 text-xs font-bold rounded-lg transition-all cursor-pointer flex items-center gap-1.5 ${a==="teacher"?"bg-surface text-primary-theme font-black shadow-xs border border-theme/60 scale-102":"text-muted hover:text-main"}`,title:t==="zh"?"在当前窗口切回教师编辑视角":"Switch back to the teacher editor view",children:[e.jsx("span",{children:"👨‍🏫"}),e.jsx("span",{children:t==="zh"?"教师视角":"Teacher"})]}),e.jsxs("button",{type:"button",onClick:()=>{const i=`${window.location.origin}${window.location.pathname}?mode=student_preview&lessonId=${encodeURIComponent(r||"")}#/student_preview`;window.open(i,"_blank")||alert(t==="zh"?"新标签页被浏览器拦截,请允许本站打开弹出窗口后重试。":"The new tab was blocked. Please allow pop-ups for this site and retry.")},className:`px-3 py-1 text-xs font-bold rounded-lg transition-all cursor-pointer flex items-center gap-1.5 ${a==="student"?"bg-primary-theme text-white font-black shadow-xs scale-102":"text-muted hover:text-main"}`,title:t==="zh"?"在新标签页中以学生身份预览本课节(不影响当前备课窗口)":"Open a student-perspective preview of this lesson in a new tab",children:[e.jsx("span",{children:"🎓"}),e.jsx("span",{children:t==="zh"?"学生视角":"Student"})]})]}),e.jsx(O,{slot:"editor.header.action",slotProps:{lessonId:r,currentLesson:D,lang:t,isReadOnly:P,activeRole:a,onSave:n}}),e.jsx("button",{type:"button",onClick:()=>z("courses"),className:"px-3 py-1.5 bg-surface hover:bg-surface-secondary border border-theme text-muted hover:text-main text-xs font-bold rounded-xl transition-all cursor-pointer shadow-2xs hover:scale-102",children:t==="zh"?"返回课程库":"Back to Courses"})]})]}),!W&&D&&e.jsxs("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-4 py-2.5 flex items-center justify-between text-xs text-amber-800 dark:text-amber-300 backdrop-blur-xs shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xe,{size:15,className:"text-amber-500 shrink-0"}),e.jsx("span",{children:t==="zh"?`【他人课程只读模式】当前课程由教师「${D.creator_name||D.creator_id}」创建。您拥有完整查看与备课参考权限。如需编辑调整,请克隆为您的专属教案。`:`[Read-Only Mode] This lesson was created by teacher "${D.creator_name||D.creator_id}". To customize, please clone it.`})]}),m&&e.jsxs("button",{onClick:()=>m(D.id),className:"flex items-center gap-1.5 bg-amber-600 hover:bg-amber-500 text-white font-semibold px-3 py-1.5 rounded-xl shadow-xs transition-all hover:scale-102 cursor-pointer shrink-0",children:[e.jsx(Ye,{size:13}),e.jsx("span",{children:t==="zh"?"一键克隆为我的备课":"Clone as My Lesson"})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(tt,{lang:t,onActivate:I,readOnly:P,collapsed:oe,onToggleCollapse:le,pages:re,currentPage:X,onSwitchPage:i=>j.current?.switchPage?.(i),onAddPage:i=>j.current?.addPage?.(i),onDeletePage:i=>j.current?.deletePage?.(i),onRenamePage:(i,w)=>j.current?.renamePage?.(i,w),dragState:A,onHoverDropTarget:i=>{Q.current=i}}),e.jsxs("div",{className:"flex-1 relative bg-surface flex flex-col min-w-0",children:[e.jsx(st,{lang:t,segments:d,activeSegmentId:l,setActiveSegmentId:g,draggedSegmentIdx:S,setDraggedSegmentIdx:B,selectedLesson:r,saveTimeline:M,readOnly:P,editorPanelsExpanded:H,setEditorPanelsExpanded:K,dragState:A,onHoverDropTarget:i=>{V.current=i}}),e.jsxs("div",{className:"flex-1 relative flex flex-col min-w-0 overflow-y-auto",children:[r&&l&&H&&d.some(i=>i.id===l)&&e.jsx(ct,{lang:t,segment:d.find(i=>i.id===l),readOnly:P,onPatch:i=>M(r,d.map(w=>w.id===l?{...w,...i}:w)),onDelete:()=>{if(d.length<=1){alert("无法删除!课程必须包含至少一个环节。");return}if(window.confirm(`确定要删除环节"${d.find(i=>i.id===l)?.title}"吗?`)){const i=d.filter(w=>w.id!==l);M(r,i),g(i[0]?.id||null)}}},l),e.jsx("div",{className:"flex-1 min-h-[380px] relative flex flex-col min-w-0",children:r?e.jsxs(e.Fragment,{children:[e.jsx(Le,{ref:j,lessonId:r,userRole:a,readOnly:P,elements:E,activeSegmentId:l,hidePageBar:!0,onPagesStateChange:({pages:i,currentPage:w})=>{J(i),Y(w)},onSegmentSync:i=>g(i),onElementDragChange:Z,onElementDropCheck:$,onElementAdd:async(i,w)=>{if(!P){await p(),v("saving");try{(await fetch(`/api/lessons/${r}/whiteboard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:i,data:w})})).ok?(v("saved"),b(new Date),h(r)):v("error")}catch{v("error")}}},onElementUpdate:(i,w)=>{P||u(i,w)},onElementDelete:async i=>{if(!P){await p(),v("saving");try{(await fetch(`/api/lessons/${r}/whiteboard/${i}`,{method:"DELETE"})).ok?(v("saved"),b(new Date),h(r)):v("error")}catch{v("error")}}},onClearBoard:async()=>{if(!P){await p(),v("saving");try{(await fetch(`/api/lessons/${r}/whiteboard`,{method:"DELETE"})).ok?(v("saved"),b(new Date),h(r)):v("error")}catch{v("error")}}},onRefresh:()=>h(r)}),T&&!P&&he(T.type)&&e.jsx(dt,{config:he(T.type),lang:t,initialData:T.data,onConfirm:G,onCancel:()=>_(null)})]}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted p-8 text-center bg-surface-secondary/50",children:e.jsxs("div",{children:[e.jsx(Ke,{size:48,className:"mx-auto mb-4 opacity-30"}),e.jsx("p",{className:"font-medium text-lg text-main mb-2",children:"No active lesson selected"}),e.jsx("p",{className:"text-sm",children:"Please select a lesson from the Dashboard to orchestrate."})]})})})]})]})]})]})}export{wt as LessonEditorView};
@@ -1 +0,0 @@
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};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-C1iYnfCh.js","assets/vendor-react-Kv_JATwr.js","assets/vendor-utils-aM7aYvPP.js","assets/index-BzXADCXZ.js","assets/vendor-icons-CXrZ3R2V.js","assets/vendor-motion-BFAPOs-b.js","assets/ClassroomCountdownWidget-gs42lIGW.js","assets/index-C6hlh8pw.css","assets/LessonEditorView-BWmtKwmP.js","assets/LazyWhiteboard-CcoBIx6V.js","assets/timeline-duration-BgdJCSrW.js","assets/LiveClassroomView-CaS1DzSS.js","assets/teaching-modes-client-BeVaDdJ-.js","assets/PluginView-BqTbAp30.js","assets/pluginParsers-PzgFzxS9.js","assets/vendor-pptx-DIWdXF1L.css","assets/CourseManagement-DNeaJcT9.js","assets/ClassesView-RkFPpWRu.js","assets/AcademicYearFilter-DUUGpDKt.js","assets/TimetableView-D_4XmrRN.js","assets/AdminDirectoryView-Dlz7q-xf.js","assets/ComputerLabView-Dr-g8FrU.js","assets/HelpView-wyKldm_R.js","assets/AssessmentCenter-CaoAI9Ke.js"])))=>i.map(i=>d[i]);
2
- import{_ as m}from"./vendor-pdf-C1Vh2Aqq.js";import{r as u,j as e}from"./vendor-react-Kv_JATwr.js";import{c as T,d as N,e as j,E,t as C,o as P,P as k,D as A}from"./index-BzXADCXZ.js";import{aV as S,aT as V,B as I,a4 as L,U as D,an as O,aG as $,am as R,P as z,S as M,e as H,$ as G,a6 as K,E as U,c as B}from"./vendor-icons-CXrZ3R2V.js";import"./vendor-utils-aM7aYvPP.js";import"./vendor-motion-BFAPOs-b.js";import"./vendor-charts-SrpBsvM3.js";function J(s){return s==="en"?"en":"zh"}const w="openlearn_nav_collapsed_groups",Y=s=>{if(s.status==="cancelled"||s.status==="holiday")return!1;if(!s.time_slot)return!0;try{const a=s.time_slot.split("-");if(a.length<2)return!0;const t=a[1].trim(),[o,r]=t.split(":").map(Number),i=new Date,n=i.getHours(),b=i.getMinutes();return!(n>o||n===o&&b>=r)}catch{return!0}};function F(s={}){const a=T(),t=s.mainNavCollapsed??a?.mainNavCollapsed??!1,o=s.setMainNavCollapsed??a?.setMainNavCollapsed??(()=>{}),r=s.teacherTab??a?.teacherTab??"dashboard",i=s.setTeacherTab??a?.setTeacherTab??(()=>{}),n=s.lang??a?.lang??"zh",b=s.session!==void 0?s.session:a?.session??null,c=s.todaySchedules??a?.todaySchedules??[],l=N(d=>d.extensionPoints).get("teacher.tab")||[];j(d=>d.siteInfo);const[x,y]=u.useState(()=>{try{const d=localStorage.getItem(w);return d?JSON.parse(d):{}}catch{return{}}}),f=d=>{y(v=>{const g={...v,[d]:!v[d]};try{localStorage.setItem(w,JSON.stringify(g))}catch{}return g})};return e.jsxs("div",{id:"navigation_sidebar",className:`${t?"w-16":"w-44 md:w-44"} shrink-0 bg-surface border-r border-theme text-main flex flex-col transition-all duration-300`,children:[e.jsxs("div",{className:`p-2 flex border-b border-theme-subtle ${t?"justify-center":"justify-between items-center px-3"} min-h-[48px] shrink-0`,children:[!t&&e.jsx("span",{className:"inline text-xs font-black tracking-widest text-muted uppercase select-none",children:n==="zh"?"系统导航":"NAVIGATION"}),e.jsx("button",{onClick:()=>o(!t),className:"p-1.5 rounded-lg hover:bg-surface-secondary text-muted hover:text-primary-theme transition-colors cursor-pointer flex items-center justify-center shrink-0",title:t?n==="zh"?"展开导航":"Expand Sidebar":n==="zh"?"折叠导航":"Collapse Sidebar",children:t?e.jsx(S,{size:18}):e.jsx(V,{size:18})})]}),e.jsxs("div",{className:`p-2 ${t?"md:p-2":"md:p-2.5"} flex flex-col gap-2 overflow-y-auto flex-1`,children:[e.jsx(_,{label:n==="zh"?"教学工具":"TEACHING",groupKey:"teaching",mainNavCollapsed:t,isCollapsed:!!x.teaching,onToggle:()=>f("teaching"),lang:n}),(!x.teaching||t)&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(p,{icon:I,label:n==="zh"?"课程管理":"Courses",tab:"courses",teacherTab:r,setTeacherTab:i,mainNavCollapsed:t,lang:n}),e.jsx(p,{icon:L,label:n==="zh"?"互动课堂":"Live Class",tab:"live_class",teacherTab:r,setTeacherTab:i,mainNavCollapsed:t,lang:n,highlight:!0}),e.jsx(p,{icon:D,label:n==="zh"?"班级管理":"Classes & Students",tab:"classes",teacherTab:r,setTeacherTab:i,mainNavCollapsed:t,lang:n}),e.jsx(p,{icon:O,label:n==="zh"?"测评中心":"Assessment Center",tab:"assessments",teacherTab:r,setTeacherTab:i,mainNavCollapsed:t,lang:n})]}),e.jsx(_,{label:n==="zh"?"系统管理":"SYSTEM MANAGEMENT",groupKey:"system",mainNavCollapsed:t,isCollapsed:!!x.system,onToggle:()=>f("system"),lang:n}),(!x.system||t)&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(p,{icon:$,label:n==="zh"?"课表管理":"Timetable Routine",tab:"timetable",teacherTab:r,setTeacherTab:i,mainNavCollapsed:t,lang:n}),e.jsx(p,{icon:R,label:n==="zh"?"机房管理":"Computer Lab Seating",tab:"computer_labs",teacherTab:r,setTeacherTab:i,mainNavCollapsed:t,lang:n}),e.jsx(p,{icon:z,label:n==="zh"?"插件中心":"App Store / Plugins",tab:"plugins",teacherTab:r,setTeacherTab:i,mainNavCollapsed:t,lang:n}),b?.subRole==="administrator"&&e.jsx(p,{icon:M,label:n==="zh"?"管理后台":"⭐ Admin Center",tab:"admin_directory",isAdmin:!0,teacherTab:r,setTeacherTab:i,mainNavCollapsed:t,lang:n})]}),l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(_,{label:n==="zh"?"扩展应用":"EXTENSIONS",groupKey:"extensions",mainNavCollapsed:t,isCollapsed:!!x.extensions,onToggle:()=>f("extensions"),lang:n}),(!x.extensions||t)&&e.jsx("div",{className:"flex flex-col gap-1",children:e.jsx(E,{slot:"teacher.tab",slotProps:{renderType:"button",mainNavCollapsed:t,teacherTab:r,setTeacherTab:i,lang:n}})})]}),e.jsx(_,{label:n==="zh"?"帮助支持":"HELP & SUPPORT",groupKey:"support",mainNavCollapsed:t,isCollapsed:!!x.support,onToggle:()=>f("support"),lang:n}),(!x.support||t)&&e.jsx("div",{className:"flex flex-col gap-1",children:e.jsx(p,{icon:H,label:n==="zh"?"帮助文档":"System Commands / Help",tab:"help",teacherTab:r,setTeacherTab:i,mainNavCollapsed:t,lang:n})})]}),(()=>{const d=c.filter(Y),v=d.length;return t||c.length===0?null:e.jsxs("div",{className:"mt-auto p-2.5 m-2 bg-indigo-50/55 dark:bg-indigo-950/20 rounded-xl border border-indigo-100 dark:border-indigo-900/30 block select-none shadow-3xs",id:"today_schedule_sidebar_panel",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold text-indigo-700 mb-1",children:[e.jsx(G,{size:12,className:"text-indigo-600 animate-pulse shrink-0"}),e.jsx("span",{className:"truncate",children:n==="zh"?"本堂余课":"Classes Remaining"})]}),e.jsx("div",{className:"text-xs text-gray-500 mb-1.5 truncate",children:n==="zh"?`今天还有 ${v} 节课`:`${v} more classes left`}),d.length>0&&e.jsx("div",{className:"max-h-[130px] overflow-y-auto space-y-1 pr-0.5",children:d.map(g=>e.jsxs("div",{className:"text-xs p-1.5 bg-white rounded border border-indigo-100/60 shadow-3xs hover:border-indigo-200 transition-colors",children:[e.jsx("div",{className:"font-bold text-gray-750 truncate",title:g.lesson_title,children:g.lesson_title}),e.jsxs("div",{className:"text-xs text-gray-450 truncate flex justify-between items-center mt-0.5 gap-1",children:[e.jsx("span",{className:"font-medium text-slate-500 truncate max-w-[55px]",children:g.class_name}),e.jsx("span",{className:"font-mono text-indigo-700 font-semibold shrink-0",children:g.time_slot})]})]},g.id))})]})})()]})}function _({label:s,groupKey:a,mainNavCollapsed:t,isCollapsed:o,onToggle:r,lang:i}){return t?e.jsx("div",{className:"h-px bg-border-theme-subtle my-1 w-full opacity-60"}):e.jsxs("button",{type:"button",onClick:r,"aria-expanded":!o,"data-testid":`nav_group_${a}`,className:"w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg bg-surface-secondary/40 hover:bg-surface-secondary/80 border-0 text-xs font-semibold text-muted hover:text-main cursor-pointer transition-all duration-150 select-none group mt-1.5",title:`${s} (${o?i==="zh"?"点击展开":"Click to expand":i==="zh"?"点击折叠":"Click to collapse"})`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"w-1 h-3 rounded-full bg-primary-theme/75 group-hover:bg-primary-theme transition-colors shrink-0"}),e.jsx("span",{className:"truncate tracking-wide text-xs",children:s})]}),e.jsx(K,{size:13,className:`text-muted/60 group-hover:text-main transition-transform duration-200 shrink-0 ${o?"-rotate-90":"rotate-0"}`})]})}function p({icon:s,label:a,tab:t,teacherTab:o,setTeacherTab:r,mainNavCollapsed:i,highlight:n,isAdmin:b,lang:c}){const h=o===t,l=J(c),x=C[l],y=l==="zh"?`在新标签页打开"${a}"`:`Open "${a}" in a new tab`;return e.jsxs("div",{className:`group relative flex items-center rounded-xl transition-all duration-150 ${h?"bg-primary-theme-light text-primary-theme font-bold border border-primary-theme/25 shadow-3xs":"border border-transparent text-muted hover:bg-surface-secondary hover:text-main"} ${i?"justify-center":""}`,title:a,children:[e.jsxs("button",{type:"button",onClick:()=>r(t),id:`nav_btn_${t}`,"aria-label":a,"aria-current":h?"page":void 0,className:`flex items-center gap-2.5 py-2 flex-1 min-w-0 text-sm font-medium focus:outline-none focus-visible:ring-1 focus-visible:ring-primary-theme/50 rounded-lg ${h?"font-bold":""} ${i?"justify-center px-2":"pl-2.5 pr-8"}`,children:[e.jsx(s,{size:18,className:`shrink-0 transition-colors ${h||n?"text-primary-theme":b?"text-indigo-600 dark:text-indigo-400":""}`}),e.jsx("span",{className:i?"hidden":"block truncate",children:a})]}),!i&&e.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),P(t)},id:`nav_btn_${t}_newtab`,"aria-label":y,title:x.openInNewTab,"data-testid":`nav_newtab_${t}`,className:"absolute right-1.5 p-1 rounded-md opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:bg-black/10 dark:hover:bg-white/15 focus:outline-none focus-visible:ring-1 focus-visible:ring-primary-theme/50 transition-opacity text-current",children:e.jsx(U,{size:12,className:"shrink-0"})})]})}function Q({component:s,lessonId:a,classId:t}){const o=s;return e.jsx(o,{renderType:"panel",lessonId:a,classId:t})}function W({activeNavPlugin:s}){const a=N(l=>l.extensionPoints),t=N(l=>l.pluginErrors),o=j(l=>l.lang),r=j(l=>l.selectedLesson),i=j(l=>l.liveClassSelectedClassId),n=a.get("teacher.tab")||[],b=s||(n.length>0?n[0].pluginId:null),c=n.find(l=>l.pluginId===b),h=c?t.get(c.pluginId):void 0;return e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:e.jsx("div",{className:"flex-1 overflow-auto",children:h?e.jsx(k,{pluginId:c.pluginId,message:h,lang:o==="en"?"en":"zh"}):c?.component?e.jsx(Q,{component:c.component,lessonId:r,classId:i}):c&&typeof c.render=="function"?e.jsx(A,{ext:c,slot:"teacher.tab",slotProps:{renderType:"panel",lessonId:r,classId:i}}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(z,{size:48,className:"mx-auto text-gray-300 mb-3"}),e.jsx("p",{className:"text-sm text-subtle font-medium",children:o==="zh"?"此插件未提供页面组件":"This plugin has no page component"}),e.jsx("p",{className:"text-xs text-muted mt-1",children:o==="zh"?"插件已注册导航条目,但未提供对应的界面渲染逻辑。":"The plugin registered a navigation entry but did not provide a render component."})]})})})})}const X=u.lazy(()=>m(()=>import("./Dashboard-C1iYnfCh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(s=>({default:s.Dashboard}))),q=u.lazy(()=>m(()=>import("./LessonEditorView-BWmtKwmP.js"),__vite__mapDeps([8,1,2,3,4,5,9,10,7])).then(s=>({default:s.LessonEditorView}))),Z=u.lazy(()=>m(()=>import("./LiveClassroomView-CaS1DzSS.js"),__vite__mapDeps([11,1,2,3,4,5,9,6,10,12,7])).then(s=>({default:s.LiveClassroomView}))),ee=u.lazy(()=>m(()=>import("./PluginView-BqTbAp30.js"),__vite__mapDeps([13,1,2,4,3,5,14,15,7])).then(s=>({default:s.PluginView}))),te=u.lazy(()=>m(()=>import("./CourseManagement-DNeaJcT9.js"),__vite__mapDeps([16,1,2,3,4,5,7])).then(s=>({default:s.CourseManagement}))),se=u.lazy(()=>m(()=>import("./ClassesView-RkFPpWRu.js"),__vite__mapDeps([17,1,2,3,4,5,14,18,7])).then(s=>({default:s.ClassesView}))),ne=u.lazy(()=>m(()=>import("./TimetableView-D_4XmrRN.js"),__vite__mapDeps([19,1,2,3,4,5,18,12,7])).then(s=>({default:s.TimetableView}))),ae=u.lazy(()=>m(()=>import("./AdminDirectoryView-Dlz7q-xf.js"),__vite__mapDeps([20,1,2,4,3,5,7])).then(s=>({default:s.AdminDirectoryView}))),ie=u.lazy(()=>m(()=>import("./ComputerLabView-Dr-g8FrU.js"),__vite__mapDeps([21,1,2,3,4,5,7])).then(s=>({default:s.ComputerLabView}))),re=u.lazy(()=>m(()=>import("./HelpView-wyKldm_R.js"),__vite__mapDeps([22,1,2,3,4,5,7])).then(s=>({default:s.HelpView}))),oe=u.lazy(()=>m(()=>import("./AssessmentCenter-CaoAI9Ke.js"),__vite__mapDeps([23,1,2,3,4,5,7])).then(s=>({default:s.AssessmentCenter})));function he(s={}){const a=T(),t=s.teacherTab??a?.teacherTab??"dashboard";return e.jsxs("div",{className:"flex-1 overflow-hidden flex bg-gray-50",children:[e.jsx(F,{}),e.jsxs("div",{className:"flex-1 p-6 overflow-hidden flex gap-6 relative",children:[["dashboard","lesson_editor","live_class","plugins","courses","classes","timetable","admin_directory","help","computer_labs","assessments"].includes(t)?null:e.jsx(W,{activeNavPlugin:t.includes("/")?t.split("/")[0]:null}),e.jsx(u.Suspense,{fallback:e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center min-h-[400px] text-slate-400 gap-3",children:[e.jsx(B,{className:"w-8 h-8 animate-spin text-indigo-500"}),e.jsx("span",{className:"text-sm font-medium",children:"加载视图中..."})]}),children:t==="dashboard"?e.jsx(X,{}):t==="lesson_editor"?e.jsx(q,{}):t==="live_class"?e.jsx("div",{className:"flex-grow flex-1 flex flex-col min-h-0 min-w-0",children:e.jsx(Z,{})}):t==="plugins"?e.jsx(ee,{}):t==="courses"?e.jsx(te,{}):t==="classes"?e.jsx(se,{}):t==="timetable"?e.jsx(ne,{}):t==="admin_directory"?e.jsx(ae,{}):t==="computer_labs"?e.jsx(ie,{}):t==="assessments"?e.jsx(oe,{}):t==="help"?e.jsx(re,{}):null})]})]})}export{he as TeacherView};