openlearn-next 0.4.2 → 0.7.3

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 (149) hide show
  1. package/README.md +26 -21
  2. package/cli-data.mjs +535 -40
  3. package/cli-doctor.mjs +456 -17
  4. package/cli.mjs +214 -12
  5. package/dist/assets/AcademicYearFilter-DUUGpDKt.js +1 -0
  6. package/dist/assets/ActivityWorkspaceWidget-5PzyxF6a.js +1 -0
  7. package/dist/assets/AdminDirectoryView-BCtmQTEK.js +5 -0
  8. package/dist/assets/AssessmentCenter-B43ojHG-.js +1 -0
  9. package/dist/assets/BatchPickerModal-CbmjInp7.js +1 -0
  10. package/dist/assets/ClassesView-DEnMaDOt.js +32 -0
  11. package/dist/assets/ClassroomCountdownWidget-CHq4983w.js +2 -0
  12. package/dist/assets/CloudDriveModal-D2t3Uyzr.js +1 -0
  13. package/dist/assets/ComputerLabView-YtnoT5Rb.js +1 -0
  14. package/dist/assets/CourseManagement-DOXyJ_j-.js +1 -0
  15. package/dist/assets/CourseWizardModal-Dbi6Caw2.js +3 -0
  16. package/dist/assets/CoursewareHubPanel-CyxDIJAF.js +1 -0
  17. package/dist/assets/Dashboard-2rLu_ZBy.js +8 -0
  18. package/dist/assets/ExportWeightModal-BrmAh6VX.js +1 -0
  19. package/dist/assets/GLTFLoader-CZJbo_y1.js +1 -0
  20. package/dist/assets/HelpTour-D_q1z_MI.js +1 -0
  21. package/dist/assets/HelpView-CVBrKDrd.js +204 -0
  22. package/dist/assets/ImportLessonsModal-PhHtX31R.js +1 -0
  23. package/dist/assets/ImportModal-DqjqNeH4.js +2 -0
  24. package/dist/assets/InteractiveCoursewareViewer-Vi6lLz7a.js +1 -0
  25. package/dist/assets/InteractiveWhiteboard-lTzeayX5.js +65 -0
  26. package/dist/assets/LazyCourseware-KIt0rGtW.js +2 -0
  27. package/dist/assets/LazyWhiteboard-CCN3pYcW.js +2 -0
  28. package/dist/assets/LessonEditorView-D_GVhHuM.js +1 -0
  29. package/dist/assets/LiveClassroomView-BRsZ6QEq.js +61 -0
  30. package/dist/assets/NotificationDetailModal-tY5rxYCN.js +1 -0
  31. package/dist/assets/OrbitControls-CQjN_uwS.js +1 -0
  32. package/dist/assets/PluginView-CedpAW6d.js +77 -0
  33. package/dist/assets/ProcessLogsModal-Cfr-T9Gd.js +1 -0
  34. package/dist/assets/QuizGeneratorModal-bUA002kP.js +1 -0
  35. package/dist/assets/StudentAssignmentView-BhAz6Hfk.js +1 -0
  36. package/dist/assets/StudentLessonView-DC1yX4kG.js +1 -0
  37. package/dist/assets/StudentView-PHKxIV9T.js +2 -0
  38. package/dist/assets/SystemResourceLibraryModal-DgXYe6_x.js +1 -0
  39. package/dist/assets/TeacherView-DscJtOJ9.js +2 -0
  40. package/dist/assets/TimetableView-D2ozoj_D.js +6 -0
  41. package/dist/assets/UTIF-FfCsrHhe.js +1 -0
  42. package/dist/assets/__vite-optional-peer-dep_ai_ooxml-ui-BIHI7g3E.js +1 -0
  43. package/dist/assets/browser-DEI0QxZC.js +1 -0
  44. package/dist/assets/html2canvas-pro.esm-Bo50djkB.js +12 -0
  45. package/dist/assets/index-2676X8YB.js +131 -0
  46. package/dist/assets/index-C6hlh8pw.css +1 -0
  47. package/dist/assets/{index.es-C5eWEO4o.js → index.es-DyEF0CZ9.js} +1 -1
  48. package/dist/assets/pluginParsers-e4PSm2Iy.js +1 -0
  49. package/dist/assets/react_pptx-react-viewer-BIHI7g3E.js +1 -0
  50. package/dist/assets/teaching-modes-client-BeVaDdJ-.js +1 -0
  51. package/dist/assets/three.module-iOYB3rD4.js +4228 -0
  52. package/dist/assets/timeline-duration-BgdJCSrW.js +1 -0
  53. package/dist/assets/{vendor-charts-qLbgF1eL.js → vendor-charts-SrpBsvM3.js} +2 -2
  54. package/dist/assets/{vendor-icons-BRmhY6fg.js → vendor-icons-CXrZ3R2V.js} +2 -2
  55. package/dist/assets/{vendor-konva-CEOq4dcl.js → vendor-konva-Dne0Z-WC.js} +1 -1
  56. package/dist/assets/{vendor-pdf-D7rGevI1.js → vendor-pdf-C1Vh2Aqq.js} +56 -56
  57. package/dist/assets/vendor-pptx-Bzn6whfK.js +11311 -0
  58. package/dist/assets/vendor-pptx-DIWdXF1L.css +1 -0
  59. package/dist/assets/{vendor-react-B0t7H3hh.js → vendor-react-Kv_JATwr.js} +1 -1
  60. package/dist/assets/vendor-utils-aM7aYvPP.js +1 -0
  61. package/dist/cli-migrator.cjs +310 -0
  62. package/dist/env-validation.cjs +351 -0
  63. package/dist/index.html +13 -10
  64. package/dist/plugin-net-preload.cjs +263 -0
  65. package/dist/server.cjs +51140 -27229
  66. package/migrations/000_initial_schema.sql +410 -0
  67. package/migrations/001_add_execution_mode.sql +6 -0
  68. package/migrations/002_add_client_session_expiry.sql +6 -0
  69. package/migrations/003_classroom_runtime.sql +33 -0
  70. package/migrations/004_courseware_score_config.sql +26 -0
  71. package/migrations/005_assignment_hub.sql +155 -0
  72. package/migrations/006_classroom_event_bus.sql +28 -0
  73. package/migrations/007_interactive_classroom.sql +119 -0
  74. package/migrations/008_teaching_modes.sql +36 -0
  75. package/migrations/009_classroom_peer_review.sql +159 -0
  76. package/migrations/010_class_groups.sql +33 -0
  77. package/migrations/011_classroom_feed.sql +34 -0
  78. package/migrations/012_auto_record_score.sql +48 -0
  79. package/migrations/013_score_source_strategy.sql +81 -0
  80. package/migrations/014_performance_indexes.sql +21 -0
  81. package/migrations/015_demo_data_registry.sql +26 -0
  82. package/migrations/016_preset_polls_and_passcode_expiry.sql +33 -0
  83. package/migrations/017_pacing_signals_segment.sql +6 -0
  84. package/migrations/018_processes_plugin_owner.sql +26 -0
  85. package/migrations/019_plugins_version.sql +61 -0
  86. package/migrations/020_upload_max_file_mb.sql +14 -0
  87. package/migrations/021_class_owner_and_password_gate.sql +11 -0
  88. package/migrations/022_plugin_public_routes.sql +14 -0
  89. package/migrations/023_encrypt_class_passcodes.sql +18 -0
  90. package/migrations/024_segment_gates.sql +37 -0
  91. package/migrations/025_assignment_lookup_indexes.sql +11 -0
  92. package/migrations/026_plugin_grants.sql +21 -0
  93. package/migrations/027_academic_year.sql +26 -0
  94. package/migrations/028_classroom_indexes.sql +14 -0
  95. package/migrations/029_clean_lesson_think_artifacts.sql +13 -0
  96. package/migrations/030_backfill_academic_year.sql +30 -0
  97. package/migrations/031_assessment_core.sql +158 -0
  98. package/migrations/032_progress_verification.sql +17 -0
  99. package/migrations/033_student_lock_mode.sql +9 -0
  100. package/migrations/034_plugin_orphan_data.sql +27 -0
  101. package/migrations/035_icebreaker_checkins.sql +26 -0
  102. package/migrations/036_student_read_notifications_created_at.sql +19 -0
  103. package/migrations/037_plugin_config_scopes.sql +40 -0
  104. package/migrations/038_assessment_ai_grading_suggestion.sql +10 -0
  105. package/migrations/039_question_bank_sharing_and_papers.sql +14 -0
  106. package/migrations/040_assignment_grade_history.sql +37 -0
  107. package/migrations/041_course_package_idempotency.sql +33 -0
  108. package/migrations/042_assignment_grade_resubmit_audit.sql +12 -0
  109. package/migrations/043_mark_sha256_passwords.sql +31 -0
  110. package/migrations/README.md +61 -0
  111. package/migrations/schema-golden.json +640 -0
  112. package/package.json +54 -28
  113. package/dist/assets/AdminDirectoryView-DY--WM5Z.js +0 -1
  114. package/dist/assets/BatchPickerModal-BpWu0Lil.js +0 -1
  115. package/dist/assets/ClassesView-KbHEqJto.js +0 -22
  116. package/dist/assets/ClassroomCountdownWidget-96WFRO9A.js +0 -2
  117. package/dist/assets/CloudDriveModal-DEQ1nkNk.js +0 -1
  118. package/dist/assets/ComputerLabView-1qWDNRQ2.js +0 -1
  119. package/dist/assets/CourseManagement-D3ZpxY0l.js +0 -1
  120. package/dist/assets/CourseWizardModal-Ck_-M8pk.js +0 -3
  121. package/dist/assets/CoursewareHubPanel-CaEizhxl.js +0 -1
  122. package/dist/assets/Dashboard-CYbpbofV.js +0 -8
  123. package/dist/assets/ExportWeightModal-DW2bu9Zz.js +0 -1
  124. package/dist/assets/HelpTour-CMJbbGne.js +0 -1
  125. package/dist/assets/HelpView-CtzdqhBq.js +0 -204
  126. package/dist/assets/ImportLessonsModal-jBuIK453.js +0 -1
  127. package/dist/assets/ImportModal-D7L-KNhZ.js +0 -1
  128. package/dist/assets/InteractiveCoursewareViewer-Bj7ahXMs.js +0 -1
  129. package/dist/assets/InteractiveWhiteboard-B7JcJvDu.js +0 -77
  130. package/dist/assets/LazyCourseware-CuiPxhDg.js +0 -2
  131. package/dist/assets/LazyWhiteboard-BJwCEZAU.js +0 -2
  132. package/dist/assets/LessonEditorView-DFrOp2qp.js +0 -1
  133. package/dist/assets/LiveClassroomView-BZ5nGee3.js +0 -59
  134. package/dist/assets/NotificationDetailModal-Baqnc5pU.js +0 -1
  135. package/dist/assets/PluginView-CCbIuZ24.js +0 -66
  136. package/dist/assets/ProcessLogsModal-DmFXg9mG.js +0 -1
  137. package/dist/assets/QuizGeneratorModal-BBEDssp7.js +0 -1
  138. package/dist/assets/StudentAssignmentView-DgIjUsXz.js +0 -1
  139. package/dist/assets/StudentLessonView-CBJbI5x6.js +0 -1
  140. package/dist/assets/StudentPreviewModal-Bh8OZs0t.js +0 -1
  141. package/dist/assets/StudentView--uGxc5TJ.js +0 -2
  142. package/dist/assets/SystemResourceLibraryModal-BVCclcqA.js +0 -1
  143. package/dist/assets/TeacherView-D4Zsc0eZ.js +0 -2
  144. package/dist/assets/TimetableView-BQG-rEb5.js +0 -6
  145. package/dist/assets/index-BKBCBKvy.js +0 -217
  146. package/dist/assets/index-CvGu7LSj.css +0 -1
  147. package/dist/assets/purify.es-CYR4BTuT.js +0 -3
  148. package/dist/assets/vendor-pptx-C5-U7ieS.js +0 -39
  149. package/dist/assets/vendor-utils-m0Urvtws.js +0 -1
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InteractiveCoursewareViewer-Vi6lLz7a.js","assets/vendor-react-Kv_JATwr.js","assets/vendor-utils-aM7aYvPP.js","assets/index-2676X8YB.js","assets/vendor-icons-CXrZ3R2V.js","assets/vendor-motion-BFAPOs-b.js","assets/index-C6hlh8pw.css"])))=>i.map(i=>d[i]);
2
+ import{_ as a}from"./vendor-pdf-C1Vh2Aqq.js";import{j as e,r}from"./vendor-react-Kv_JATwr.js";const i=r.lazy(()=>a(()=>import("./InteractiveCoursewareViewer-Vi6lLz7a.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function n(s){return e.jsx(r.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,{...s})})}export{n as L};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InteractiveWhiteboard-lTzeayX5.js","assets/vendor-react-Kv_JATwr.js","assets/vendor-utils-aM7aYvPP.js","assets/index-2676X8YB.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-lTzeayX5.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};
@@ -0,0 +1 @@
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-2676X8YB.js";import{L as Le}from"./LazyWhiteboard-CCN3pYcW.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};