openlearn-next 0.3.15 → 0.3.18
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.
- package/README.md +21 -22
- package/cli-cleaner.mjs +4 -6
- package/cli-data.mjs +6 -3
- package/cli-doctor.mjs +66 -24
- package/cli.mjs +3 -14
- package/dist/assets/AdminDirectoryView-BtdFA-PR.js +1 -0
- package/dist/assets/{BatchPickerModal-DrQn8KfF.js → BatchPickerModal-BQ_vsb5h.js} +1 -1
- package/dist/assets/ClassesView-D_m_99Wk.js +19 -0
- package/dist/assets/{CloudDriveModal-CkBmfYLe.js → CloudDriveModal-BHWCchwE.js} +1 -1
- package/dist/assets/ComputerLabView-n5hzKtEx.js +1 -0
- package/dist/assets/CourseManagement-DamuhaYN.js +1 -0
- package/dist/assets/CourseWizardModal-1F_Ksxgf.js +3 -0
- package/dist/assets/CoursewareHubPanel-B0JwbcQz.js +1 -0
- package/dist/assets/Dashboard-CgJNFUha.js +8 -0
- package/dist/assets/ExportWeightModal-B2wHglNt.js +1 -0
- package/dist/assets/HelpTour-C3G0EsYT.js +1 -0
- package/dist/assets/HelpView-Bgxlwpn_.js +204 -0
- package/dist/assets/ImportLessonsModal-xjfRYYa0.js +1 -0
- package/dist/assets/ImportModal-ChLAX_xg.js +1 -0
- package/dist/assets/InteractiveCoursewareViewer-pi7sr3lt.js +1 -0
- package/dist/assets/InteractiveWhiteboard-CsKeinZt.js +78 -0
- package/dist/assets/LazyCourseware-Bw86DSzq.js +2 -0
- package/dist/assets/{LazyWhiteboard-Dy3pdZ5v.js → LazyWhiteboard-XI8iSIjM.js} +2 -2
- package/dist/assets/LessonEditorView-3TnocL3v.js +1 -0
- package/dist/assets/LiveClassroomView-CQGaFkzD.js +1 -0
- package/dist/assets/{NotificationDetailModal-Ct6gVcYm.js → NotificationDetailModal-CI4IfD2v.js} +1 -1
- package/dist/assets/PluginView-LokCtvB8.js +65 -0
- package/dist/assets/ProcessLogsModal-uJqQQFyw.js +1 -0
- package/dist/assets/QuizGeneratorModal-Bul00fIH.js +1 -0
- package/dist/assets/StudentAssignmentView-CaOXzBkt.js +1 -0
- package/dist/assets/StudentLessonView-6l-A6scB.js +1 -0
- package/dist/assets/StudentPreviewModal-CnWC2qso.js +1 -0
- package/dist/assets/StudentView-BtGPu4nl.js +2 -0
- package/dist/assets/SystemResourceLibraryModal-CiRD12Rw.js +1 -0
- package/dist/assets/TeacherView-_iKPvpXI.js +2 -0
- package/dist/assets/TimetableView-B0yL3omc.js +6 -0
- package/dist/assets/index-AdOtUso0.js +202 -0
- package/dist/assets/index-CM3Tw-Rg.css +1 -0
- package/dist/assets/{index.es-CfxBkm_z.js → index.es-CkgATcHw.js} +2 -2
- package/dist/assets/{vendor-charts-CRXa4AlU.js → vendor-charts-U9fLlNC_.js} +1 -1
- package/dist/assets/{vendor-icons-Dq6MhgH9.js → vendor-icons-BHXru9a4.js} +2 -2
- package/dist/assets/{vendor-konva-CzxOmTv9.js → vendor-konva-CEOq4dcl.js} +1 -1
- package/dist/assets/{vendor-pdf-Cp-cYteE.js → vendor-pdf-Bw0ZQZtM.js} +1 -1
- package/dist/assets/{vendor-pptx-B_NheIKl.js → vendor-pptx-C5-U7ieS.js} +1 -1
- package/dist/assets/{vendor-react-0Lg0vA-4.js → vendor-react-B0t7H3hh.js} +10 -10
- package/dist/assets/vendor-utils-m0Urvtws.js +1 -0
- package/dist/index.html +9 -10
- package/dist/server.cjs +2223 -1713
- package/package.json +2 -2
- package/dist/assets/AdminDirectoryView-0XV86Ues.js +0 -1
- package/dist/assets/ClassesView-NzXmBc5D.js +0 -19
- package/dist/assets/ComputerLabView-BId0ZarM.js +0 -1
- package/dist/assets/CourseManagement-D0nfQuUO.js +0 -1
- package/dist/assets/CourseWizardModal-Sf71a02x.js +0 -3
- package/dist/assets/CoursewareHubPanel-LpUgjqbH.js +0 -1
- package/dist/assets/Dashboard-BYLfPux5.js +0 -8
- package/dist/assets/ExportWeightModal-uMQTJEn3.js +0 -1
- package/dist/assets/HelpTour-CHPIK2ae.js +0 -1
- package/dist/assets/HelpView-iOEvT7B3.js +0 -204
- package/dist/assets/ImportLessonsModal-DRuFaGKs.js +0 -1
- package/dist/assets/ImportModal-BTfia0Ah.js +0 -1
- package/dist/assets/InteractiveCoursewareViewer-GAUCqBpg.js +0 -1
- package/dist/assets/InteractiveWhiteboard-SnBmwJaO.js +0 -78
- package/dist/assets/LazyCourseware-CICx7ccM.js +0 -1
- package/dist/assets/LessonEditorView-CxAFaXPX.js +0 -1
- package/dist/assets/LiveClassroomView-1xEQD8kc.js +0 -1
- package/dist/assets/PluginView-C_x3cLPF.js +0 -65
- package/dist/assets/ProcessLogsModal-01S7zsw0.js +0 -1
- package/dist/assets/QuizGeneratorModal-wuwCjhBQ.js +0 -1
- package/dist/assets/StudentAssignmentView-COE6Qt_M.js +0 -1
- package/dist/assets/StudentLessonView-Va3OjK-3.js +0 -1
- package/dist/assets/StudentPreviewModal-DWQIUz_y.js +0 -1
- package/dist/assets/StudentView-DDr5t9eP.js +0 -2
- package/dist/assets/SystemResourceLibraryModal-L2ArPBxr.js +0 -1
- package/dist/assets/TeacherView-DHBfbHxr.js +0 -2
- package/dist/assets/TimetableView-DJgOlGSf.js +0 -6
- package/dist/assets/index-AmZ2Y6s6.js +0 -193
- package/dist/assets/index-D7PQWdtD.css +0 -1
- package/dist/assets/index-Du12Kt7k.js +0 -2
- package/dist/assets/vendor-utils-BEhuP0Zq.js +0 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import{R as Je,r as p,j as a,u as Nf,g as Tl,b as Pf,d as ui,h as di,J as Wo,i as Go,k as Tf}from"./vendor-react-B0t7H3hh.js";import{G as Qo,S as If,U as Il,C as hi,a as In,L as fi,A as Jo,b as Ps,c as Oi,P as pi,d as Zo,D as Yo,X as ot,e as yt,f as _n,g as Af,h as zf,T as Al,E as Ts,B as Di,R as zl,i as _f,j as An,k as Lf,M as Rf,l as Mf,m as Of,n as Df,H as _l,o as Ff,p as Bf,q as Ll,r as Ln,s as mi,t as $f,K as Vf,u as Uf,v as ls,w as Hf,x as Fi,y as qf,z as Bi,F as Wf,I as Gf,J as Qf,N as Jf,O as Rl,Q as Zf,V as Yf,W as Kf,Y as Xf,Z as ep,_ as $i,$ as zr,a0 as tp,a1 as np,a2 as sp,a3 as rp,a4 as Ml,a5 as Ol,a6 as ip,a7 as Ko,a8 as op,a9 as Xo}from"./vendor-icons-BHXru9a4.js";import{_ as Ie,E as ap}from"./vendor-pdf-Bw0ZQZtM.js";import{e as Vi,f as bt,h as Is}from"./vendor-utils-m0Urvtws.js";import{i as _r,g as lp,s as Dl,a as Ui,b as Fl,c as ea,d as cp,e as up,f as dp,h as hp,r as fp,j as pp,k as Bl,l as mp,m as gp,n as xp,o as yp,S as bp,H as wp,F as At,p as Sp,q as vp,t as $l,u as Ss,v as ta,w as et,x as Vl,y as Cp,z as na,A as kp,B as vs,C as gi,D as sa,E as Ep,G as jp,I as Pt,J as Np,K as Pp,L as Tp,M as ra,N as Ip,O as Ap,P as ia,Q as zp,R as _p,T as cs,U as Lp,V as Rp,W as Ul,X as Mp,Y as Op}from"./vendor-motion-DjY2czvL.js";import{v as Dp}from"./vendor-pptx-C5-U7ieS.js";import{R as oa}from"./vendor-charts-U9fLlNC_.js";const Fp=e=>{const t=e.split(/\r?\n/);if(t.length<2)return[];const n=t[0],s=[",",";"," "];let r=",",i=0;s.forEach(g=>{const y=n.split(g).length;y>i&&(i=y,r=g)});const o=g=>{const y=[];let C=!1,w="";for(let N=0;N<g.length;N++){const S=g[N];S==='"'?C=!C:S===r&&!C?(y.push(w.trim()),w=""):w+=S}return y.push(w.trim()),y},l=o(n).map(g=>g.toLowerCase().replace(/["'\r]/g,"").trim()),c=l.findIndex(g=>g.includes("student_number")||g.includes("studentnumber")||g.includes("student_id")||g.includes("studentid")||g.includes("学号")||g.includes("编号")||g.includes("id")&&!g.includes("class")&&!g.includes("lesson")),u=l.findIndex(g=>g.includes("name")||g.includes("姓名")||g.includes("student")&&!g.includes("num")&&!g.includes("id")||g.includes("学生")&&!g.includes("号")),d=l.findIndex(g=>g.includes("email")||g.includes("mail")||g.includes("邮箱")),h=u>=0?u:0,m=d>=0?d:1,f=[];for(let g=1;g<t.length;g++){if(!t[g].trim())continue;const y=o(t[g]),C=y[h]?y[h].replace(/["'\r]/g,"").trim():"",w=y[m]?y[m].replace(/["'\r]/g,"").trim():"",N=c>=0&&y[c]?y[c].replace(/["'\r]/g,"").trim():void 0;C&&f.push({name:C,email:w,...N?{student_number:N}:{}})}return f},aa={zh:{migratableBadge:"可迁移",migrateToFormat:"迁移到新格式",migrationPromptHeading:"发现可迁移的旧格式插件",migrationPromptBody:"该插件使用旧格式运行。上传新格式 ZIP 包以完成迁移,迁移后旧版本可安全卸载。",zipParseError:"ZIP 文件解析失败,请确认文件包含有效的 manifest.json",workerActivationError:"插件在 Worker 环境中激活失败,请检查插件代码与浏览器兼容性",extensionLoadError:"扩展组件加载失败",retry:"重新加载",noExtensionPoints:"暂无已注册的扩展组件",dropZipHere:"拖拽 ZIP 文件到此处",zipFileHint:"仅支持 .zip 格式的插件包",analyzing:"分析中...",dragActive:"释放以上传",legacyTooltip:"该插件使用旧执行格式运行。新格式版本可能可用。",ready:"就绪",uploadZipPlugin:"上传并安装 ZIP 插件",agentTitle:"内核助手",agentSubtitle:"自主 Shell 控制器",agentIntro:"你好!我是你的教育系统 OS 内核助手。你可以让我“创建一节物理课并在白板上画一个圆”,我将通过底层总线为你构建。",placeholder:"例如:创建一节历史课并画一张地图...",dashboard:"系统总览",kernelRunning:"系统正常运行",lessons:"课程",noLessons:"暂无课程。请让助手创建一节课!",noContent:"无内容...",whiteboardCanvas:"白板画布",emptyWhiteboard:"白板为空",simulationError:"系统错误:执行 OS 命令失败。",executedCommands:"执行的命令:",switchLang:"Switch to English",plugins:"插件中心",uploadPlugin:"上传并安装插件",pluginSource:"扩展插件源码 (JS)",installPlugin:"验证并安装",installing:"安装中...",installedPlugins:"已运行插件",noPlugins:"未发现第三方插件",lessonContent:"课程教案与笔记",eventStream:"内核审计事件流",selectLesson:"请先在左侧选择一节课程",systemLogs:"系统日志",hideLogs:"隐藏日志",showLogs:"显示日志",approvals:"待审批高危操作",approve:"批准",reject:"拒绝",noApprovals:"暂无待审批命令",fileSystem:"虚拟文件系统",noFiles:"当前目录为空",processes:"进程管理",noProcesses:"没有正在运行的进程",processLogs:"查看日志",classes:"班级管理",students:"学生管理",noClasses:"暂无班级",noStudents:"暂无学生"},en:{migratableBadge:"Migratable",migrateToFormat:"Migrate to New Format",migrationPromptHeading:"Legacy Plugin Detected",migrationPromptBody:"This plugin runs in legacy mode. Upload a new-format ZIP package to migrate. The old version can be safely uninstalled afterwards.",zipParseError:"Failed to parse ZIP file. Ensure the package contains a valid manifest.json.",workerActivationError:"Plugin activation in Worker environment failed. Check plugin code and browser compatibility.",extensionLoadError:"Extension failed to load",retry:"Retry Load",noExtensionPoints:"No extension points registered",dropZipHere:"Drop ZIP file here",zipFileHint:".zip plugin packages only",analyzing:"Analyzing...",dragActive:"Release to upload",legacyTooltip:"This plugin uses the old execution format. A new-format version may be available.",ready:"Ready",uploadZipPlugin:"Upload & Install ZIP Plugin",agentTitle:"Kernel Agent",agentSubtitle:"Autonomous Shell Controller",agentIntro:'Hello! I am your Educational OS Kernel Agent. You can ask me to "create a physics lesson and draw a circle on its whiteboard" and I will use the Command Bus to build it.',placeholder:"e.g. Create a history lesson and draw a map...",dashboard:"OS Dashboard",kernelRunning:"Kernel Running",lessons:"Lessons",noLessons:"No lessons yet. Ask the Agent to create one!",noContent:"No content...",whiteboardCanvas:"Whiteboard Canvas",emptyWhiteboard:"Empty Whiteboard",simulationError:"Simulation Error: Failed to execute OS command.",executedCommands:"Executed Commands: ",switchLang:"切换到中文",plugins:"Plugin Center",uploadPlugin:"Upload & Install Plugin",pluginSource:"Extension Source Code (JS)",installPlugin:"Validate & Install",installing:"Installing...",installedPlugins:"Running Plugins",noPlugins:"No 3rd-party plugins found",lessonContent:"Lesson Content & Notes",eventStream:"Kernel Audit Event Stream",selectLesson:"Please select a lesson from the left",systemLogs:"System Logs",hideLogs:"Hide Logs",showLogs:"Show Logs",approvals:"Pending Approvals",approve:"Approve",reject:"Reject",noApprovals:"No pending commands",fileSystem:"Virtual File System",noFiles:"Directory is empty",processes:"Process Manager",noProcesses:"No active processes",processLogs:"View Logs",classes:"Classes",students:"Students",noClasses:"No classes found",noStudents:"No students found"}},Bp=Je.memo(function({onLoginSuccess:t,lang:n}){const[s,r]=p.useState("teacher"),[i,o]=p.useState(null),[l,c]=p.useState(""),[u,d]=p.useState(""),[h,m]=p.useState(""),[f,g]=p.useState(!1),[y,C]=p.useState([]),[w,N]=p.useState(""),[S,E]=p.useState(""),[I,k]=p.useState(""),[z,D]=p.useState(""),[F,_]=p.useState(!1);p.useEffect(()=>{(async()=>{try{const R=await fetch("/api/students");if(R.ok){const P=await R.json();C(P),P.length>0&&N(P[0].id)}}catch(R){console.warn("Failed to fetch student roster for login selection:",R)}})()},[]),p.useEffect(()=>{(async()=>{try{const R=await fetch("/api/site-settings");if(R.ok){const P=await R.json();o(P)}}catch(R){console.warn("Failed to fetch site settings for login branding:",R)}})()},[]);const A=async O=>{if(O.preventDefault(),!l.trim()||!u){m(n==="zh"?"请输入完整的用户名和密码。":"Please fill in both key fields.");return}try{m(""),g(!0);const R=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"teacher",username:l.trim(),password:u})});if(R.ok){const P=await R.json();t(P.session)}else{const P=await R.json();m(P.error||(n==="zh"?"用户名或密码不正确":"Invalid username or password"))}}catch{m(n==="zh"?"网络连接异常,请重试":"Network communication failure. Please try again.")}finally{g(!1)}},L=async O=>{O.preventDefault();const R=w||S.trim();if(!R){D(n==="zh"?"请选择或输入学号/学生标识。":"Please select or enter your Student ID.");return}if(!I.trim()){D(n==="zh"?"请输入个人密码或临时班级密码。":"Please enter your personal password or temporary class passcode.");return}try{D(""),_(!0);const P=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"student",studentId:R,password:I.trim()})});if(P.ok){const T=await P.json();t(T.session)}else{const T=await P.json();D(T.error||(n==="zh"?"找不到该学生记录":"Student record not found"))}}catch{D(n==="zh"?"网络连接异常,请重试":"Network connection failure. Please try again.")}finally{_(!1)}};return a.jsxs("div",{className:"min-h-screen bg-slate-900 flex flex-col items-center justify-center p-4 relative overflow-hidden font-sans",id:"login_page_container",children:[a.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40rem] h-[40rem] rounded-full bg-indigo-500/10 blur-3xl -z-10"}),a.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[35rem] h-[35rem] rounded-full bg-violet-500/10 blur-3xl -z-10"}),a.jsxs("div",{className:"w-full max-w-md bg-slate-950/85 backdrop-blur-md rounded-2xl border border-slate-800 shadow-2xl p-6 sm:p-8",id:"login_card",children:[a.jsxs("div",{className:"text-center mb-8",children:[i?.logoUrl?a.jsx("img",{src:i.logoUrl,alt:i.siteName||"logo",className:"inline-block h-16 w-16 object-contain mb-4 rounded-xl"}):a.jsx("div",{className:"inline-flex items-center justify-center p-3 bg-gradient-to-tr from-indigo-500 to-indigo-600 rounded-2xl shadow-lg border border-indigo-400/20 mb-4 text-white",children:a.jsx(Qo,{size:32})}),a.jsxs("h1",{className:"text-2xl sm:text-3xl font-black text-white tracking-tight flex items-center justify-center gap-2",children:[i?.siteName||"OpenLearn Next"," ",a.jsx("span",{className:"text-indigo-400 font-medium text-xs bg-indigo-500/20 px-2 py-0.5 rounded-full border border-indigo-400/20",children:"V2.0"})]}),a.jsx("p",{className:"text-slate-400 text-xs sm:text-sm mt-2",children:i?.slogan||(n==="zh"?"下一代智能数字化学习系统":"Next-Generation Intelligent Digital Learning Platform")})]}),a.jsxs("div",{className:"flex bg-slate-900 p-1 rounded-xl border border-slate-800 gap-1 mb-6",children:[a.jsxs("button",{onClick:()=>r("teacher"),className:`flex-1 py-2.5 rounded-lg text-xs font-bold transition-all duration-200 flex items-center justify-center gap-2 focus:outline-none ${s==="teacher"?"bg-indigo-600 text-white shadow-md":"text-slate-400 hover:text-slate-200 hover:bg-slate-800/40"}`,children:[a.jsx(If,{size:14}),n==="zh"?"教师与管理端":"Teacher / Staff Portal"]}),a.jsxs("button",{onClick:()=>r("student"),className:`flex-1 py-2.5 rounded-lg text-xs font-bold transition-all duration-200 flex items-center justify-center gap-2 focus:outline-none ${s==="student"?"bg-indigo-600 text-white shadow-md":"text-slate-400 hover:text-slate-200 hover:bg-slate-800/40"}`,children:[a.jsx(Il,{size:14}),n==="zh"?"学生自助端":"Student Self-Service"]})]}),s==="teacher"?a.jsxs("form",{onSubmit:A,className:"space-y-4",children:[h&&a.jsxs("div",{className:"p-3 bg-red-950/50 border border-red-800 text-red-300 text-xs rounded-xl flex items-center gap-2",children:[a.jsx(hi,{size:15,className:"shrink-0"}),a.jsx("span",{children:h})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(In,{size:13}),n==="zh"?"教工账户名 / username":"Staff Username"]}),a.jsx("input",{type:"text",value:l,onChange:O=>c(O.target.value),placeholder:n==="zh"?"输入教工账户名":"Enter staff username",className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none placeholder-slate-500 transition-colors",required:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(fi,{size:13}),n==="zh"?"输入登录密码 / password":"Access Password"]}),a.jsx("input",{type:"password",value:u,onChange:O=>d(O.target.value),placeholder:n==="zh"?"输入登录密码":"Enter access password",className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none placeholder-slate-500 transition-colors",required:!0})]}),a.jsxs("button",{type:"submit",disabled:f,className:"w-full mt-6 bg-gradient-to-r from-indigo-600 to-violet-600 hover:from-indigo-500 hover:to-violet-500 disabled:opacity-50 text-white font-bold py-3 px-4 rounded-xl text-xs sm:text-sm flex items-center justify-center gap-2 transition-all duration-200 cursor-pointer shadow-lg shadow-indigo-600/20 active:scale-[0.98]",children:[a.jsx("span",{children:f?n==="zh"?"鉴权登录中...":"Authorizing...":n==="zh"?"安全验证登录":"Authorized Sign In"}),a.jsx(Jo,{size:15})]})]}):a.jsxs("form",{onSubmit:L,className:"space-y-4",children:[z&&a.jsxs("div",{className:"p-3 bg-red-950/50 border border-red-800 text-red-300 text-xs rounded-xl flex items-center gap-2",children:[a.jsx(hi,{size:15,className:"shrink-0"}),a.jsx("span",{children:z})]}),y.length>0?a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(Qo,{size:14}),n==="zh"?"从学生花名册中快速选择":"Quick Access Student Select"]}),a.jsx("select",{value:w,onChange:O=>{N(O.target.value),E("")},className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none transition-colors cursor-pointer",children:y.map(O=>a.jsxs("option",{value:O.id,children:[O.name," (",O.student_number||O.id,")"]},O.id))}),a.jsx("p",{className:"text-xs text-slate-500 font-medium",children:n==="zh"?"✨ 在沙盒调试中,你可以直接下拉选择已有的学生账户一键登录为该生。":"✨ Sandbox help: Quick select existing students on file to simulate as student."})]}):null,a.jsxs("div",{className:"relative flex py-2 items-center",children:[a.jsx("div",{className:"flex-grow border-t border-slate-850"}),a.jsx("span",{className:"flex-shrink mx-3 text-xs font-bold text-slate-500 uppercase tracking-wider",children:n==="zh"?"或手动输入学号":"Or input key manually"}),a.jsx("div",{className:"flex-grow border-t border-slate-850"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(In,{size:13}),n==="zh"?"学号 / Student ID":"Student Access Key"]}),a.jsx("input",{type:"text",value:S,onChange:O=>{E(O.target.value),N("")},placeholder:n==="zh"?"手工输入您的特有学号":"Enter specific numeric ID code",className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none placeholder-slate-500 transition-colors"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[a.jsx(fi,{size:13}),n==="zh"?"个人密码 / 临时班级密码":"Personal Password / Class Passcode"]}),a.jsx("input",{type:"password",required:!0,value:I,onChange:O=>k(O.target.value),placeholder:n==="zh"?"输入个人密码或临时班级密码":"Enter personal password or class passcode",className:"w-full bg-slate-900 border border-slate-800 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 rounded-xl text-xs sm:text-sm p-3 text-white outline-none placeholder-slate-500 transition-colors"})]}),a.jsxs("button",{type:"submit",disabled:F,className:"w-full mt-6 bg-gradient-to-r from-indigo-600 to-violet-600 hover:from-indigo-500 hover:to-violet-500 disabled:opacity-50 text-white font-bold py-3 px-4 rounded-xl text-xs sm:text-sm flex items-center justify-center gap-2 transition-all duration-200 cursor-pointer shadow-lg shadow-indigo-600/20 active:scale-[0.98]",children:[a.jsx("span",{children:F?n==="zh"?"正在连接学生终端...":"Entering Desk...":n==="zh"?"登录学生智慧桌面":"Login Interactive Desk"}),a.jsx(Jo,{size:15})]})]})]})]})});function $p({session:e,lang:t,onLogout:n,onProfile:s}){const[r,i]=p.useState(!1),o=p.useRef(null);p.useEffect(()=>{if(!r)return;const c=u=>{o.current&&!o.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]);const l=(c,u)=>t==="zh"?c:u;return a.jsxs("div",{className:"relative",ref:o,children:[a.jsxs("button",{type:"button",onClick:()=>i(c=>!c),"aria-haspopup":"menu","aria-expanded":r,title:e.name,className:"flex items-center gap-1 rounded-full p-1 hover:bg-gray-100 transition-colors cursor-pointer",children:[a.jsx("span",{className:"w-9 h-9 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center shrink-0 overflow-hidden",children:e.avatar?a.jsx("img",{src:e.avatar,alt:e.name,className:"w-full h-full object-cover"}):a.jsx(In,{size:20})}),a.jsx(Ps,{size:14,className:`text-gray-400 transition-transform duration-200 ${r?"rotate-180":""}`})]}),r&&a.jsxs("div",{role:"menu",className:"absolute right-0 mt-2 w-52 bg-white border border-gray-200 shadow-lg rounded-xl z-50 overflow-hidden py-1",children:[a.jsxs("div",{className:"px-4 py-2 border-b border-gray-100",children:[a.jsx("p",{className:"text-sm font-semibold text-gray-800 truncate",title:e.name,children:e.name}),a.jsx("p",{className:"text-xs text-gray-400 truncate",children:e.username})]}),a.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{i(!1),s()},className:"w-full flex items-center gap-2 px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 transition-colors cursor-pointer",children:[a.jsx(In,{size:16,className:"text-gray-400"}),l("个人资料","Profile")]}),a.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{i(!1),n()},className:"w-full flex items-center gap-2 px-4 py-2 text-sm text-rose-600 hover:bg-rose-50 transition-colors cursor-pointer",children:[a.jsx(Oi,{size:16}),l("注销登录","Sign Out")]})]})]})}const Vp=[{id:"light",label:"浅色日间",description:"明亮通透,适合自然采光良好的日间课堂",previewBg:"#f8fafc",previewPrimary:"#4f46e5",category:"builtin"},{id:"dark",label:"暗夜极客",description:"深邃内敛,适合计算机房与夜间专注备课",previewBg:"#0b0f19",previewPrimary:"#6366f1",category:"builtin"},{id:"eyecare",label:"教学护眼",description:"柔和舒缓,防教室大屏眩光,减轻视觉疲劳",previewBg:"#f2f7f4",previewPrimary:"#2d6a4f",category:"builtin"},{id:"chalkboard",label:"经典黑板",description:"经典墨绿板书质感,沉浸式板书演练",previewBg:"#0e1713",previewPrimary:"#4caf50",category:"builtin"}],us={light:{"--bg-app":"#f8fafc","--bg-surface":"#ffffff","--bg-surface-secondary":"#f1f5f9","--bg-surface-elevated":"#ffffff","--border-theme":"#e2e8f0","--border-theme-subtle":"#f1f5f9","--text-main":"#0f172a","--text-muted":"#64748b","--color-primary":"#4f46e5","--color-primary-hover":"#4338ca"},dark:{"--bg-app":"#0b0f19","--bg-surface":"#111827","--bg-surface-secondary":"#1f2937","--bg-surface-elevated":"#1f2937","--border-theme":"#374151","--border-theme-subtle":"#1f2937","--text-main":"#f9fafb","--text-muted":"#9ca3af","--color-primary":"#6366f1","--color-primary-hover":"#4f46e5"},eyecare:{"--bg-app":"#f2f7f4","--bg-surface":"#ffffff","--bg-surface-secondary":"#e4eee8","--bg-surface-elevated":"#ffffff","--border-theme":"#cbe0d5","--border-theme-subtle":"#dbeef2","--text-main":"#143526","--text-muted":"#3d6350","--color-primary":"#2d6a4f","--color-primary-hover":"#1b4332"},chalkboard:{"--bg-app":"#0e1713","--bg-surface":"#15241e","--bg-surface-secondary":"#1b2f27","--bg-surface-elevated":"#1f382e","--border-theme":"#28473a","--border-theme-subtle":"#1b2f27","--text-main":"#e8f5e9","--text-muted":"#81c784","--color-primary":"#4caf50","--color-primary-hover":"#388e3c"}},Lr="openlearn_theme",xn="openlearn_custom_themes",Cs={};function Hi(e){return Cs[e]?Cs[e]:e in us?us[e]:us.light}function Rr(e){typeof document>"u"||document.documentElement.setAttribute("data-theme",e)}function Up(e,t){if(typeof document>"u")return;Cs[e]=t;const n=`openlearn-custom-theme-${e}`;let s=document.getElementById(n);s||(s=document.createElement("style"),s.id=n,document.head.appendChild(s));const r=Object.entries(t).map(([i,o])=>` ${i}: ${o};`).join(`
|
|
2
|
+
`);s.textContent=`[data-theme="${e}"] {
|
|
3
|
+
${r}
|
|
4
|
+
}`}function Hp(e){if(typeof document>"u")return;delete Cs[e];const t=document.getElementById(`openlearn-custom-theme-${e}`);t&&t.parentNode&&t.parentNode.removeChild(t)}function Mr(e){if(!(typeof window>"u"))try{setTimeout(async()=>{try{const{broadcastThemeToIframes:t}=await Ie(async()=>{const{broadcastThemeToIframes:n}=await Promise.resolve().then(()=>Jc);return{broadcastThemeToIframes:n}},void 0);t(e,Hi(e))}catch{}},0)}catch{}}const As=Vi((e,t)=>({theme:"light",availableThemes:[...Vp],initTheme:()=>{if(typeof window>"u")return;try{const r=localStorage.getItem(xn);if(r){const i=JSON.parse(r);Array.isArray(i)&&i.forEach(o=>{o&&o.spec&&o.spec.id&&t().registerTheme(o.spec,o.cssVariables)})}}catch{}const s=localStorage.getItem(Lr)||"light";Rr(s),e({theme:s}),Mr(s)},setTheme:n=>{Rr(n),typeof window<"u"&&localStorage.setItem(Lr,n),e({theme:n}),Mr(n)},registerTheme:(n,s)=>{s&&Up(n.id,s),e(r=>({availableThemes:[...r.availableThemes.filter(o=>o.id!==n.id),n]}))},unregisterTheme:n=>{Hp(n),e(s=>{const r=s.availableThemes.filter(o=>o.id!==n),i=s.theme===n?"light":s.theme;return s.theme===n&&(Rr("light"),typeof window<"u"&&localStorage.setItem(Lr,"light"),Mr("light")),{availableThemes:r,theme:i}})},saveCustomTheme:(n,s)=>{if(t().registerTheme(n,s),typeof window<"u")try{const r=localStorage.getItem(xn);let i=r?JSON.parse(r):[];Array.isArray(i)||(i=[]),i=i.filter(o=>o.spec.id!==n.id),i.push({spec:n,cssVariables:s}),localStorage.setItem(xn,JSON.stringify(i))}catch{}t().setTheme(n.id)},deleteCustomTheme:n=>{if(typeof window<"u")try{const s=localStorage.getItem(xn);if(s){let r=JSON.parse(s);Array.isArray(r)&&(r=r.filter(i=>i.spec.id!==n),localStorage.setItem(xn,JSON.stringify(r)))}}catch{}t().unregisterTheme(n)}})),qp=[{id:"sapphire-classic",label:"高雅墨蓝",description:"深海午夜蓝灰与经典宝石蓝,适合沉浸式研究与高对比度投影",tokens:{"--bg-app":"#0d131f","--bg-surface":"#161f30","--bg-surface-secondary":"#1f2c42","--bg-surface-elevated":"#24334d","--border-theme":"#2e3f5b","--border-theme-subtle":"#1f2c42","--text-main":"#f1f5f9","--text-muted":"#94a3b8","--color-primary":"#3b82f6","--color-primary-hover":"#2563eb"}},{id:"sakura-dusk",label:"暮樱柔粉",description:"柔和日系樱花与温暖象牙白,适合美育、艺术与温馨研讨课堂",tokens:{"--bg-app":"#fff9fa","--bg-surface":"#ffffff","--bg-surface-secondary":"#fceef1","--bg-surface-elevated":"#ffffff","--border-theme":"#f5d5db","--border-theme-subtle":"#fae8eb","--text-main":"#3f2d33","--text-muted":"#8a6d76","--color-primary":"#f43f5e","--color-primary-hover":"#e11d48"}},{id:"autumn-amber",label:"复古秋叶",description:"温暖金秋落叶色调与复古羊皮纸质感,适合文科通识与阅读研讨",tokens:{"--bg-app":"#fdfaf6","--bg-surface":"#ffffff","--bg-surface-secondary":"#f5eee6","--bg-surface-elevated":"#ffffff","--border-theme":"#e6d7c3","--border-theme-subtle":"#ede3d5","--text-main":"#2d241e","--text-muted":"#7c6a59","--color-primary":"#d97706","--color-primary-hover":"#b45309"}},{id:"deep-sea-cyber",label:"深海极客",description:"赛博暗黑青绿冷光,极高现代感与未来科技探索质感",tokens:{"--bg-app":"#091014","--bg-surface":"#0f1a20","--bg-surface-secondary":"#16262e","--bg-surface-elevated":"#1d333e","--border-theme":"#25414e","--border-theme-subtle":"#16262e","--text-main":"#e0f2fe","--text-muted":"#7dd3fc","--color-primary":"#06b6d4","--color-primary-hover":"#0891b2"}}],la={...us.light};function Wp({isOpen:e,onClose:t,lang:n="zh"}){const{availableThemes:s,saveCustomTheme:r,deleteCustomTheme:i}=As(),o=p.useId(),[l,c]=p.useState("custom-mytheme"),[u,d]=p.useState("我的专属主题"),[h,m]=p.useState("自定义教学调色板配置"),[f,g]=p.useState({...la}),[y,C]=p.useState("none"),[w,N]=p.useState(""),[S,E]=p.useState(!1),[I,k]=p.useState(null);if(!e)return null;const z=s.filter(j=>j.category==="custom"),D=j=>{k(j),setTimeout(()=>k(null),3e3)},F=j=>{c(j.id),d(j.label),m(j.description),g({...j.tokens}),D(`已载入预设: ${j.label}`)},_=j=>{c(j.id),d(j.label),m(j.description);const $=Hi(j.id);$&&Object.keys($).length>0&&g({...$}),D(`已载入自定义主题: ${j.label}`)},A=(j,$)=>{g(x=>({...x,[j]:$}))},L=()=>{const j=l.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-");if(!j){alert("请输入有效的主题标识 (ID)");return}const $={id:j,label:u.trim()||"未命名主题",description:h.trim()||"自定义主题",previewBg:f["--bg-app"]||"#ffffff",previewPrimary:f["--color-primary"]||"#4f46e5",category:"custom"};r($,f),D(`主题「${$.label}」已保存并成功激活!`)},O=()=>{N(JSON.stringify({version:"1.0",id:l,label:u,description:h,tokens:f},null,2)),C("export")},R=()=>{N(""),C("import")},P=()=>{try{const j=JSON.parse(w);if(!j.tokens||typeof j.tokens!="object")throw new Error("缺少合法的 tokens 字段");j.id&&c(j.id),j.label&&d(j.label),j.description&&m(j.description),g($=>({...$,...j.tokens})),C("none"),D("主题配置导入成功!")}catch(j){alert(`导入失败: ${j.message||"JSON 格式解析错误"}`)}},T=()=>{navigator.clipboard.writeText(w),E(!0),setTimeout(()=>E(!1),2e3)},W=[{key:"--color-primary",labelZh:"核心主色",labelEn:"Primary Brand Color",desc:"按钮高亮、焦点描边与重点图标"},{key:"--color-primary-hover",labelZh:"主色悬浮",labelEn:"Primary Hover",desc:"按钮悬停交互色"},{key:"--bg-app",labelZh:"全局底色",labelEn:"App Background",desc:"页面整体底衬颜色"},{key:"--bg-surface",labelZh:"卡片底色",labelEn:"Surface Background",desc:"白板卡片、浮层与侧边栏底色"},{key:"--bg-surface-secondary",labelZh:"次级底色",labelEn:"Secondary Surface",desc:"表格斑马纹、标签与次级面板"},{key:"--bg-surface-elevated",labelZh:"浮层底色",labelEn:"Elevated Surface",desc:"弹窗与下拉菜单浮动卡片"},{key:"--border-theme",labelZh:"主边框色",labelEn:"Border Color",desc:"卡片外边框、网格分割线"},{key:"--border-theme-subtle",labelZh:"弱化边框",labelEn:"Subtle Border",desc:"细微内部分割线"},{key:"--text-main",labelZh:"主文本色",labelEn:"Main Text",desc:"正文文字、标题"},{key:"--text-muted",labelZh:"弱化文本",labelEn:"Muted Text",desc:"副标题、辅助信息与提示说明"}];return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 bg-black/60 backdrop-blur-xs animate-in fade-in duration-150",children:a.jsxs("div",{className:"bg-surface text-main border border-theme rounded-2xl shadow-2xl w-full max-w-6xl h-[92vh] max-h-[900px] flex flex-col overflow-hidden relative",children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-theme shrink-0 bg-surface",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-primary-theme/10 rounded-xl text-primary-theme",children:a.jsx(pi,{size:22})}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-bold flex items-center gap-2 text-main",children:[n==="zh"?"主题可视化设计器":"Theme Visual Designer",a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-primary-theme/10 text-primary-theme font-medium",children:"v0.3.0"})]}),a.jsx("p",{className:"text-xs text-muted mt-0.5",children:n==="zh"?"自定义课堂交互色盘,支持一键载入创意预设、实时拟真沙箱预览与微前端自动同步":"Customize learning palettes with live previews, creative presets, and micro-frontend sync"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:R,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导入 JSON",children:[a.jsx(Zo,{size:14}),n==="zh"?"导入配置":"Import"]}),a.jsxs("button",{onClick:O,className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",title:"导出 JSON",children:[a.jsx(Yo,{size:14}),n==="zh"?"导出配置":"Export"]}),a.jsx("button",{onClick:t,className:"p-2 rounded-lg text-muted hover:text-main hover:bg-surface-secondary transition-colors cursor-pointer ml-1","aria-label":"Close",children:a.jsx(ot,{size:18})})]})]}),I&&a.jsxs("div",{className:"absolute top-18 left-1/2 -translate-x-1/2 z-50 bg-primary-theme text-white px-4 py-2 rounded-xl shadow-lg text-xs font-medium flex items-center gap-2 animate-in fade-in slide-in-from-top-2",children:[a.jsx(yt,{size:14}),I]}),a.jsxs("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[a.jsxs("div",{className:"w-full md:w-1/2 border-r border-theme overflow-y-auto p-6 space-y-6",children:[a.jsxs("section",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(_n,{size:14,className:"text-amber-500"}),n==="zh"?"创意预设配色":"Creative Presets"]}),a.jsx("span",{className:"text-xs text-muted",children:"一键填入调色板"})]}),a.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:qp.map(j=>a.jsxs("button",{onClick:()=>F(j),className:"flex flex-col p-3 rounded-xl border border-theme hover:border-primary-theme/50 hover:bg-surface-secondary text-left transition-all cursor-pointer group relative overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between w-full",children:[a.jsxs("div",{className:"font-semibold text-xs text-main flex items-center gap-2",children:[a.jsx("span",{className:"w-3 h-3 rounded-full border border-black/10 shrink-0",style:{backgroundColor:j.tokens["--color-primary"]}}),j.label]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:j.tokens["--bg-app"]}}),a.jsx("span",{className:"w-2.5 h-2.5 rounded-xs",style:{backgroundColor:j.tokens["--bg-surface"]}})]})]}),a.jsx("p",{className:"text-xs text-muted mt-1.5 line-clamp-2 leading-relaxed opacity-85",children:j.description})]},j.id))})]}),a.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(Af,{size:14,className:"text-primary-theme"}),n==="zh"?"主题基础信息":"Theme Metadata"]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:`${o}-themeId`,className:"block text-xs font-medium text-muted mb-1",children:"主题标识 (ID)"}),a.jsx("input",{id:`${o}-themeId`,type:"text",value:l,onChange:j=>c(j.target.value),placeholder:"custom-mytheme",className:"w-full px-3 py-1.5 text-xs rounded-lg border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:`${o}-label`,className:"block text-xs font-medium text-muted mb-1",children:"主题名称"}),a.jsx("input",{id:`${o}-label`,type:"text",value:u,onChange:j=>d(j.target.value),placeholder:"我的专属主题",className:"w-full px-3 py-1.5 text-xs rounded-lg border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme"})]})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:`${o}-description`,className:"block text-xs font-medium text-muted mb-1",children:"主题描述"}),a.jsx("input",{id:`${o}-description`,type:"text",value:h,onChange:j=>m(j.target.value),placeholder:"针对特定课堂采光与演示场景优化",className:"w-full px-3 py-1.5 text-xs rounded-lg border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme"})]})]}),a.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(pi,{size:14,className:"text-primary-theme"}),n==="zh"?"色彩变量调节 (Design Tokens)":"CSS Variables Token Tuning"]}),a.jsx("div",{className:"space-y-2.5",children:W.map(j=>{const $=f[j.key]||"#000000";return a.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme hover:bg-surface-secondary/40 transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0 pr-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs font-medium text-main",children:j.labelZh}),a.jsx("span",{className:"text-xs font-mono text-muted bg-surface-secondary px-1.5 py-0.5 rounded",children:j.key})]}),a.jsx("p",{className:"text-xs text-muted mt-0.5",children:j.desc})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("div",{className:"relative flex items-center",children:a.jsx("input",{type:"color",value:$.startsWith("#")&&$.length===7?$:"#4f46e5",onChange:x=>A(j.key,x.target.value),className:"w-8 h-8 rounded-lg cursor-pointer border border-theme p-0.5 bg-surface",title:"打开系统拾色器"})}),a.jsx("input",{type:"text",value:$,onChange:x=>A(j.key,x.target.value),className:"w-20 px-2 py-1 text-xs font-mono rounded-lg border border-theme bg-surface text-main text-center focus:outline-none focus:ring-1 focus:ring-primary-theme"})]})]},j.key)})})]}),z.length>0&&a.jsxs("section",{className:"space-y-3 pt-2 border-t border-theme-subtle",children:[a.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-muted flex items-center gap-1.5",children:[a.jsx(zf,{size:14,className:"text-primary-theme"}),n==="zh"?"已创建的自定义主题":"Saved Custom Themes"]}),a.jsx("div",{className:"space-y-2",children:z.map(j=>a.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-xl border border-theme bg-surface-secondary/30",children:[a.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[a.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 shrink-0",style:{backgroundColor:j.previewPrimary}}),a.jsxs("div",{className:"truncate",children:[a.jsx("div",{className:"text-xs font-semibold text-main truncate",children:j.label}),a.jsx("div",{className:"text-xs text-muted truncate",children:j.description})]})]}),a.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[a.jsx("button",{onClick:()=>_(j),className:"px-2 py-1 text-xs rounded-md bg-surface border border-theme hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:"编辑"}),a.jsx("button",{onClick:()=>{confirm(`确定删除自定义主题「${j.label}」吗?`)&&(i(j.id),D(`已删除主题「${j.label}」`))},className:"p-1 text-muted hover:text-red-500 rounded-md transition-colors cursor-pointer",title:"删除",children:a.jsx(Al,{size:13})})]})]},j.id))})]})]}),a.jsxs("div",{className:"w-full md:w-1/2 flex flex-col p-6 bg-surface-secondary/30 overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider text-muted",children:[a.jsx(Ts,{size:14,className:"text-primary-theme"}),n==="zh"?"拟真沙盒视口 (Live Sandbox)":"Live Sandbox Preview"]}),a.jsxs("span",{className:"text-xs text-muted font-mono",children:["当前预览: ",u," (",l,")"]})]}),a.jsxs("div",{className:"flex-1 rounded-2xl border shadow-inner overflow-hidden flex flex-col transition-colors duration-200",style:{backgroundColor:f["--bg-app"]||"#f8fafc",borderColor:f["--border-theme"]||"#e2e8f0",color:f["--text-main"]||"#0f172a"},children:[a.jsxs("div",{className:"h-12 border-b px-4 flex items-center justify-between shrink-0",style:{backgroundColor:f["--bg-surface"]||"#ffffff",borderColor:f["--border-theme"]||"#e2e8f0"},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"w-6 h-6 rounded-lg flex items-center justify-center font-bold text-white text-xs",style:{backgroundColor:f["--color-primary"]||"#4f46e5"},children:"OL"}),a.jsx("span",{className:"font-bold text-xs",style:{color:f["--text-main"]},children:"OpenLearn V2"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"text-xs px-2 py-0.5 rounded-md font-mono",style:{backgroundColor:f["--bg-surface-secondary"]||"#f1f5f9",color:f["--text-muted"]||"#64748b"},children:"10:30:00"}),a.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white",style:{backgroundColor:f["--color-primary"]||"#4f46e5"},children:"T"})]})]}),a.jsxs("div",{className:"p-4 space-y-4 flex-1 overflow-y-auto",children:[a.jsxs("div",{className:"p-4 rounded-xl border shadow-xs space-y-3",style:{backgroundColor:f["--bg-surface"]||"#ffffff",borderColor:f["--border-theme"]||"#e2e8f0"},children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"font-bold text-sm",style:{color:f["--text-main"]},children:"高中物理实验探究:机械能守恒定律"}),a.jsx("p",{className:"text-xs mt-1",style:{color:f["--text-muted"]},children:"DIS 光电门传感器毫秒级数据回传与曲线拟合分析"})]}),a.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:f["--bg-surface-secondary"],color:f["--color-primary"],border:`1px solid ${f["--border-theme"]}`},children:"进行中"})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-1",children:[a.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:f["--bg-surface-secondary"]},children:[a.jsx("div",{className:"text-xs",style:{color:f["--text-muted"]},children:"光电门测速 (v)"}),a.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:f["--text-main"]},children:"2.43 m/s"})]}),a.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:f["--bg-surface-secondary"]},children:[a.jsx("div",{className:"text-xs",style:{color:f["--text-muted"]},children:"动能增量 (ΔEk)"}),a.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:f["--color-primary"]},children:"0.589 J"})]}),a.jsxs("div",{className:"p-2 rounded-lg",style:{backgroundColor:f["--bg-surface-secondary"]},children:[a.jsx("div",{className:"text-xs",style:{color:f["--text-muted"]},children:"误差率 (Err)"}),a.jsx("div",{className:"text-sm font-bold font-mono mt-0.5",style:{color:f["--text-main"]},children:"0.84 %"})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsx("button",{className:"px-3 py-1.5 rounded-lg text-xs font-medium text-white shadow-xs transition-opacity hover:opacity-90 cursor-pointer",style:{backgroundColor:f["--color-primary"]||"#4f46e5"},children:"开始数据采集"}),a.jsx("button",{className:"px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors cursor-pointer",style:{backgroundColor:f["--bg-surface-elevated"]||"#ffffff",borderColor:f["--border-theme"]||"#e2e8f0",color:f["--text-main"]||"#0f172a"},children:"重置实验"}),a.jsx("button",{className:"px-2 py-1.5 rounded-lg text-xs transition-colors cursor-pointer",style:{color:f["--text-muted"]},children:"查看教案"})]})]}),a.jsxs("div",{className:"p-3 rounded-xl border space-y-2",style:{backgroundColor:f["--bg-surface-elevated"]||"#ffffff",borderColor:f["--border-theme-subtle"]||"#f1f5f9"},children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-xs font-semibold",style:{color:f["--text-main"]},children:"互动白板区域 (Whiteboard Canvas)"}),a.jsx("span",{className:"text-xs font-mono",style:{color:f["--text-muted"]},children:"60 FPS"})]}),a.jsxs("div",{className:"h-28 rounded-lg border border-dashed flex items-center justify-center p-3 relative overflow-hidden",style:{backgroundColor:f["--bg-app"],borderColor:f["--border-theme"]},children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white font-bold shadow-md transform -rotate-6",style:{backgroundColor:f["--color-primary"]},children:a.jsx(Di,{size:20})}),a.jsx("div",{className:"absolute bottom-2 right-2 text-xs font-mono px-1.5 py-0.5 rounded border",style:{backgroundColor:f["--bg-surface"],borderColor:f["--border-theme"],color:f["--text-muted"]},children:"iframe Bridge Sync Ready"})]})]})]})]})]})]}),a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-theme shrink-0 bg-surface",children:[a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("button",{onClick:()=>{g({...la}),D("已重置为系统默认调色板")},className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors flex items-center gap-1.5 cursor-pointer",children:[a.jsx(zl,{size:14}),n==="zh"?"重置默认":"Reset Defaults"]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:t,className:"px-4 py-2 rounded-xl border border-theme text-xs font-medium hover:bg-surface-secondary text-main transition-colors cursor-pointer",children:n==="zh"?"关闭":"Close"}),a.jsxs("button",{onClick:L,className:"px-5 py-2 rounded-xl bg-primary-theme text-white text-xs font-semibold shadow-sm hover:opacity-95 transition-opacity flex items-center gap-1.5 cursor-pointer",children:[a.jsx(_f,{size:15}),n==="zh"?"保存并激活主题":"Save & Activate Theme"]})]})]}),y!=="none"&&a.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-xs flex items-center justify-center p-6 z-50 animate-in fade-in duration-100",children:a.jsxs("div",{className:"bg-surface border border-theme rounded-2xl p-5 w-full max-w-lg shadow-2xl space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"font-bold text-sm text-main flex items-center gap-2",children:y==="export"?a.jsxs(a.Fragment,{children:[a.jsx(Yo,{size:16,className:"text-primary-theme"}),n==="zh"?"导出主题配置 JSON":"Export Theme JSON"]}):a.jsxs(a.Fragment,{children:[a.jsx(Zo,{size:16,className:"text-primary-theme"}),n==="zh"?"导入主题配置 JSON":"Import Theme JSON"]})}),a.jsx("button",{onClick:()=>C("none"),className:"p-1 rounded-md text-muted hover:text-main cursor-pointer",children:a.jsx(ot,{size:16})})]}),a.jsx("div",{children:a.jsx("textarea",{value:w,readOnly:y==="export",onChange:j=>N(j.target.value),placeholder:y==="import"?"请在此粘贴主题导出的 JSON 字符串...":"",rows:10,className:"w-full p-3 font-mono text-xs rounded-xl border border-theme bg-surface-secondary text-main focus:outline-none focus:ring-1 focus:ring-primary-theme resize-none"})}),a.jsx("div",{className:"flex items-center justify-end gap-2",children:y==="export"?a.jsx(a.Fragment,{children:a.jsxs("button",{onClick:T,className:"px-4 py-1.5 rounded-lg bg-primary-theme text-white text-xs font-medium flex items-center gap-1.5 cursor-pointer",children:[S?a.jsx(yt,{size:14}):a.jsx(An,{size:14}),S?n==="zh"?"已复制":"Copied":n==="zh"?"复制到剪贴板":"Copy"]})}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>C("none"),className:"px-3 py-1.5 rounded-lg border border-theme text-xs font-medium hover:bg-surface-secondary text-main cursor-pointer",children:n==="zh"?"取消":"Cancel"}),a.jsx("button",{onClick:P,className:"px-4 py-1.5 rounded-lg bg-primary-theme text-white text-xs font-medium cursor-pointer",children:n==="zh"?"解析并导入":"Parse & Import"})]})})]})})]})})}function Gp({lang:e="zh"}){const[t,n]=p.useState(!1),[s,r]=p.useState(!1),i=p.useRef(null),{theme:o,availableThemes:l,setTheme:c}=As();p.useEffect(()=>{function d(h){i.current&&!i.current.contains(h.target)&&n(!1)}return t&&document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[t]);const u=d=>{switch(d){case"dark":return a.jsx(Rf,{size:16,className:"text-indigo-400"});case"eyecare":return a.jsx(Ts,{size:16,className:"text-emerald-500"});case"chalkboard":return a.jsx(pi,{size:16,className:"text-green-400"});case"light":default:return a.jsx(Lf,{size:16,className:"text-amber-500"})}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"relative",ref:i,children:[a.jsx("button",{onClick:()=>n(!t),title:e==="zh"?"切换教学界面主题":"Switch Theme",className:"p-2 hover:bg-surface-secondary text-main transition-colors bg-surface rounded-lg border border-theme shadow-3xs flex items-center justify-center shrink-0 cursor-pointer","aria-label":"Theme selector",children:u(o)}),t&&a.jsxs("div",{className:"absolute right-0 mt-2 w-64 rounded-xl border border-theme bg-surface shadow-xl z-50 p-2 overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[a.jsxs("div",{className:"px-3 py-2 border-b border-theme-subtle mb-1",children:[a.jsx("div",{className:"text-xs font-semibold text-main uppercase tracking-wider",children:e==="zh"?"界面主题模式":"Interface Theme"}),a.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"针对不同教学采光与场景优化":"Optimized for diverse lighting"})]}),a.jsx("div",{className:"space-y-1",children:l.map(d=>{const h=o===d.id;return a.jsxs("button",{onClick:()=>{c(d.id),n(!1)},className:`w-full flex items-center justify-between px-3 py-2 rounded-lg text-left text-xs transition-all cursor-pointer ${h?"bg-surface-secondary text-main font-semibold shadow-xs":"text-muted hover:bg-surface-secondary hover:text-main"}`,children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("span",{className:"w-3.5 h-3.5 rounded-full border border-black/10 dark:border-white/20 shrink-0 shadow-inner",style:{backgroundColor:d.previewPrimary}}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-main leading-none",children:d.label}),a.jsx("div",{className:"text-xs text-muted mt-1 leading-tight opacity-80",children:d.description})]})]}),h&&a.jsx(yt,{size:14,className:"text-primary-theme shrink-0"})]},d.id)})}),a.jsx("div",{className:"pt-2 mt-1 border-t border-theme-subtle",children:a.jsxs("button",{onClick:()=>{n(!1),r(!0)},className:"w-full flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-primary-theme hover:bg-primary-theme/10 transition-colors cursor-pointer",children:[a.jsx(_n,{size:14}),a.jsx("span",{children:e==="zh"?"🎨 自定义主题设计器...":"🎨 Theme Designer..."})]})})]})]}),a.jsx(Wp,{isOpen:s,onClose:()=>r(!1),lang:e})]})}const Or="openlearn_font_scale",Zt=85,Yt=140,Dr=5,ds=100,ca=[{scale:90,labelZh:"紧凑 (90%)",labelEn:"Compact (90%)"},{scale:100,labelZh:"标准 (100%)",labelEn:"Standard (100%)"},{scale:110,labelZh:"中大 (110%)",labelEn:"Medium (110%)"},{scale:120,labelZh:"大号 (120%)",labelEn:"Large (120%)"},{scale:130,labelZh:"特大 (130%)",labelEn:"Extra Large (130%)"}];function Fr(e){if(typeof document>"u")return;const t=Math.min(Yt,Math.max(Zt,Math.round(e)));document.documentElement.style.fontSize=`${t}%`,document.documentElement.style.setProperty("--app-font-scale",(t/100).toFixed(2)),document.documentElement.setAttribute("data-font-scale",String(t))}function Br(e){if(!(typeof window>"u"))try{setTimeout(async()=>{try{const{broadcastFontScaleToIframes:t}=await Ie(async()=>{const{broadcastFontScaleToIframes:n}=await Promise.resolve().then(()=>Jc);return{broadcastFontScaleToIframes:n}},void 0);t(e)}catch{}},0)}catch{}}const Xt=Vi((e,t)=>({scale:ds,minScale:Zt,maxScale:Yt,step:Dr,initFontSize:()=>{if(typeof window>"u")return;let n=ds;try{const s=localStorage.getItem(Or);if(s){const r=Number(s);!isNaN(r)&&r>=Zt&&r<=Yt&&(n=r)}}catch{}Fr(n),e({scale:n}),Br(n);try{window.addEventListener("storage",s=>{if(s.key===Or&&s.newValue){const r=Number(s.newValue);!isNaN(r)&&r>=Zt&&r<=Yt&&(Fr(r),e({scale:r}),Br(r))}})}catch{}},setScale:n=>{const s=Math.min(Yt,Math.max(Zt,Math.round(n)));if(Fr(s),typeof window<"u")try{localStorage.setItem(Or,String(s))}catch{}e({scale:s}),Br(s)},increaseScale:()=>{const n=t().scale,s=Math.min(Yt,n+Dr);t().setScale(s)},decreaseScale:()=>{const n=t().scale,s=Math.max(Zt,n-Dr);t().setScale(s)},resetScale:()=>{t().setScale(ds)}}));function Hl({lang:e="zh"}){const[t,n]=p.useState(!1),s=p.useRef(null),{scale:r,minScale:i,maxScale:o,setScale:l,increaseScale:c,decreaseScale:u,resetScale:d}=Xt();p.useEffect(()=>{function f(g){s.current&&!s.current.contains(g.target)&&n(!1)}return t&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[t]);const h=ca.find(f=>f.scale===r),m=r===ds;return a.jsxs("div",{className:"relative",ref:s,children:[a.jsxs("button",{type:"button",onClick:()=>n(!t),title:e==="zh"?`界面字体缩放: ${r}%(点击调节)`:`Interface Font Scaling: ${r}% (Click to adjust)`,className:`p-2 hover:bg-surface-secondary transition-colors rounded-lg border shadow-3xs flex items-center justify-center shrink-0 cursor-pointer relative ${m?"bg-surface border-theme text-main":"bg-primary-theme-light border-primary-theme text-primary-theme font-bold"}`,"aria-label":"Font size selector","aria-expanded":t,children:[a.jsx(Mf,{size:16}),!m&&a.jsxs("span",{className:"absolute -bottom-1 -right-1 text-xs px-1 py-0.2 rounded-full bg-primary-theme text-white font-extrabold leading-none shadow-xs",children:[r,"%"]})]}),t&&a.jsxs("div",{className:"absolute right-0 mt-2 w-72 rounded-xl border border-theme bg-surface shadow-xl z-50 p-3 overflow-hidden animate-in fade-in zoom-in-95 duration-100 select-none",children:[a.jsxs("div",{className:"px-1 pb-2 border-b border-theme-subtle mb-2.5 flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-semibold text-main",children:e==="zh"?"界面字号大小":"Interface Font Size"}),a.jsx("div",{className:"text-xs text-muted mt-0.5",children:e==="zh"?"全局等比缩放排版与文字":"Proportionally scale typography"})]}),!m&&a.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1 text-xs text-muted hover:text-primary-theme transition-colors cursor-pointer px-1.5 py-0.5 rounded hover:bg-surface-secondary",title:e==="zh"?"恢复默认 100%":"Reset to 100%",children:[a.jsx(zl,{size:11}),a.jsx("span",{children:e==="zh"?"重置":"Reset"})]})]}),a.jsxs("div",{className:"bg-surface-secondary/70 rounded-lg p-2 flex items-center justify-between mb-3 border border-theme-subtle",children:[a.jsx("button",{type:"button",onClick:u,disabled:r<=i,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"减小字体 (A-)":"Decrease (A-)",children:a.jsx(Of,{size:14})}),a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-sm font-black text-main leading-tight",children:[r,"%"]}),a.jsx("div",{className:"text-xs text-muted",children:h?e==="zh"?h.labelZh.split(" ")[0]:h.labelEn.split(" ")[0]:e==="zh"?"自定义比例":"Custom"})]}),a.jsx("button",{type:"button",onClick:c,disabled:r>=o,className:"w-8 h-8 rounded-md bg-surface border border-theme flex items-center justify-center text-main hover:bg-surface-elevated disabled:opacity-40 disabled:cursor-not-allowed transition-colors cursor-pointer shadow-3xs",title:e==="zh"?"增大字体 (A+)":"Increase (A+)",children:a.jsx(Df,{size:14})})]}),a.jsxs("div",{className:"space-y-1 mb-3",children:[a.jsx("div",{className:"text-xs font-bold text-muted uppercase tracking-wider px-1",children:e==="zh"?"常用档位":"Presets"}),a.jsx("div",{className:"grid grid-cols-1 gap-1",children:ca.map(f=>{const g=r===f.scale;return a.jsxs("button",{type:"button",onClick:()=>l(f.scale),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-left text-xs transition-all cursor-pointer ${g?"bg-primary-theme-light text-primary-theme font-bold border border-primary-theme/30":"text-main hover:bg-surface-secondary border border-transparent"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-60"}),a.jsx("span",{children:e==="zh"?f.labelZh:f.labelEn})]}),g&&a.jsx(yt,{size:13,className:"text-primary-theme shrink-0"})]},f.scale)})})]}),a.jsxs("div",{className:"p-2.5 rounded-lg border border-theme-subtle bg-surface-secondary/40 mb-2",children:[a.jsxs("div",{className:"text-xs text-muted mb-1 flex items-center justify-between",children:[a.jsx("span",{children:e==="zh"?"实时效果预览":"Live Preview"}),a.jsxs("span",{children:[r,"%"]})]}),a.jsx("p",{className:"text-xs text-main font-medium leading-relaxed",children:e==="zh"?"让每一个文字都清晰舒适,智能赋能教学。":"Clear and comfortable typography empowers modern teaching."})]}),a.jsx("div",{className:"text-xs text-muted/80 text-center px-1",children:e==="zh"?"快捷键:Ctrl + Alt + 加号/减号":"Shortcut: Ctrl + Alt + +/-"})]})]})}function Qp(e){const{activeRole:t,lang:n,teacherTab:s,studentViewStatus:r,session:i,activeStudentId:o,students:l,studentDashboardData:c,isNotificationsOpen:u,studentNotifications:d,unreadNotifications:h,readNotifications:m,dbConnected:f,dbStatus:g,siteInfo:y,setActiveStudentId:C,setReadNotifications:w,setIsSystemResourceLibraryOpen:N,setProfileOpen:S,setTeacherTab:E,setStudentViewStatus:I,setIsNotificationsOpen:k,setSelectedNotificationForModal:z,handleLogout:D,toggleLanguage:F,setActiveRole:_,isStudentLocked:A=!1,onBlockedNavigate:L}=e,O=t==="student"&&A,R=()=>{if(O){L?.();return}t==="teacher"?E("dashboard"):t==="student"&&I("dashboard")};return a.jsxs("header",{className:"h-16 border-b border-theme bg-surface text-main flex items-center px-6 justify-between shrink-0 shadow-sm relative z-20 transition-colors duration-200",children:[a.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[a.jsxs("button",{onClick:R,className:"flex items-center gap-2.5 shrink-0 hover:opacity-80 transition-opacity cursor-pointer",title:O?n==="zh"?"全班专注锁定中,无法返回系统总览":"Class focus locked — cannot return to dashboard":n==="zh"?"返回系统总览":"Back to Dashboard",children:[y.logoUrl?a.jsx("img",{src:y.logoUrl,alt:"site logo",className:"h-8 w-8 object-contain rounded-lg shrink-0"}):a.jsx("div",{className:"h-8 w-8 rounded-lg bg-gradient-to-tr from-indigo-600 to-indigo-700 flex items-center justify-center text-white font-black text-sm shadow-xs shrink-0",children:"OL"}),a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"text-base font-black text-slate-900 tracking-tight",children:y.siteName||"OpenLearn Next"}),a.jsxs("span",{className:"text-xs font-medium text-slate-400 tracking-tight",children:["v","0.3.18"]}),y.slogan&&a.jsx("span",{className:"hidden md:inline text-xs text-slate-400 font-normal truncate max-w-[200px]",children:y.slogan})]})]}),a.jsxs("button",{onClick:R,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors cursor-pointer ${t==="teacher"&&s==="dashboard"||t==="student"&&r==="dashboard"?"bg-indigo-50 text-indigo-700":"text-slate-600 hover:text-indigo-600 hover:bg-slate-100"} ${O?"opacity-50":""}`,children:[O?a.jsx(fi,{size:16}):a.jsx(_l,{size:16}),n==="zh"?"系统总览":"Dashboard"]}),t==="student"&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-slate-300 font-light text-lg select-none",children:"/"}),a.jsxs("h2",{className:"font-semibold text-gray-800 tracking-tight flex items-center gap-2",children:[a.jsx(Ff,{size:20,className:"text-gray-400"}),"Student Dashboard"]})]}),t==="student"&&i?.role==="teacher"&&a.jsxs("div",{className:"flex items-center gap-2 bg-amber-50/90 border border-amber-200/80 px-2.5 py-1 rounded-lg shadow-2xs",children:[a.jsxs("span",{className:"text-xs font-semibold text-amber-800 flex items-center gap-1",children:[a.jsx(Ts,{size:13,className:"text-amber-600"}),n==="zh"?"模拟学生:":"View as:"]}),a.jsxs("select",{className:"border border-amber-300 rounded px-1.5 py-0.5 text-xs bg-white text-gray-800 font-medium focus:ring-1 focus:ring-amber-400 focus:outline-hidden",value:o||"",onChange:P=>C(P.target.value),children:[a.jsxs("option",{value:"",children:["-- ",n==="zh"?"选择学生":"Select Student"," --"]}),l.map(P=>a.jsx("option",{value:P.id,children:P.name},P.id))]}),_&&a.jsxs("button",{type:"button",onClick:()=>_("teacher"),className:"ml-1 px-2.5 py-1 bg-amber-600 hover:bg-amber-700 active:bg-amber-800 text-white text-xs font-bold rounded-md flex items-center gap-1 transition-all cursor-pointer shadow-2xs",title:n==="zh"?"退出模拟学生并返回教师端工作台":"Exit student view and return to teacher workspace",children:[a.jsx(Oi,{size:12}),n==="zh"?"返回教师端":"Exit Student View"]})]})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[t==="student"&&o&&c&&a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>k(!u),className:"relative p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:[a.jsx(Bf,{size:20}),h.length>0&&a.jsx("span",{className:"absolute top-1 right-1 bg-red-500 text-white text-xs font-bold px-1.5 py-0.5 rounded-full flex items-center justify-center min-w-[18px]",children:h.length})]}),u&&a.jsxs("div",{className:"absolute right-0 mt-2 w-80 bg-white border border-gray-200 shadow-lg rounded-xl z-50 overflow-hidden",children:[a.jsxs("div",{className:"p-3 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[a.jsx("h3",{className:"font-semibold text-gray-800",children:"Notifications"}),h.length>0&&a.jsx("button",{onClick:async()=>{if(!o)return;try{const T=d.filter(W=>!m.has(W.id)).map(W=>fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:W.id})}));await Promise.all(T)}catch(T){console.error(T)}const P=new Set(m);d.forEach(T=>P.add(T.id)),w(P)},className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium",children:"Mark all as read"})]}),a.jsx("div",{className:"max-h-96 overflow-y-auto",children:d.length===0?a.jsx("div",{className:"p-4 text-center text-sm text-gray-500 italic",children:"No notifications."}):a.jsx("div",{className:"divide-y divide-gray-100",children:d.map(P=>{const T=!m.has(P.id);return a.jsx("div",{className:`p-3 hover:bg-gray-50 cursor-pointer ${T?"bg-indigo-50/30":""}`,onClick:()=>{if(T){o&&fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:P.id})}).catch(console.error);const j=new Set(m);j.add(P.id),w(j)}const W=c?.assignments?.find(j=>j.id===P.relatedId);z({...P,assignment:W}),k(!1)},children:a.jsxs("div",{className:"flex gap-3",children:[a.jsx("div",{className:"mt-0.5",children:P.type==="new_assignment"?a.jsx(Ll,{size:16,className:"text-indigo-500"}):P.type==="rollcall_picked"?a.jsx(_n,{size:16,className:"text-amber-500 animate-pulse"}):a.jsx(Ln,{size:16,className:"text-green-500"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:`text-sm ${T?"font-semibold text-gray-900":"font-medium text-gray-700"}`,children:P.title}),a.jsx("div",{className:`text-xs mt-0.5 ${T?"text-gray-600":"text-gray-500"}`,children:P.message})]}),T&&a.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500 mt-1"})]})},P.id)})})})]})]}),a.jsxs("button",{onClick:()=>N(!0),className:"flex items-center gap-1.5 hover:text-primary-theme transition-colors bg-surface text-main px-3 py-1.5 rounded-md border border-theme shadow-sm font-medium cursor-pointer",children:[a.jsx(mi,{size:14,className:"text-emerald-500 animate-pulse"}),n==="zh"?"系统资源库":"System Resource Library"]}),a.jsx("button",{onClick:F,title:n==="zh"?"Switch to English":"切换为中文",className:"p-2 hover:bg-surface-secondary text-main transition-colors bg-surface rounded-lg border border-theme shadow-3xs flex items-center justify-center shrink-0 cursor-pointer",children:a.jsx(mi,{size:16})}),a.jsx(Hl,{lang:n}),a.jsx(Gp,{lang:n}),(()=>{const P=g==="error"||!f?{bg:"bg-rose-50 border-rose-200 text-rose-600 hover:bg-rose-100 animate-pulse",dot:"bg-rose-500",ping:"bg-rose-400",label:n==="zh"?"SQLite 数据库连接出错或已断开":"SQLite DB Error / Disconnected"}:g==="warning"?{bg:"bg-amber-50 border-amber-200 text-amber-600 hover:bg-amber-100",dot:"bg-amber-500",ping:"bg-amber-400",label:n==="zh"?"SQLite 数据库存在状态警告":"SQLite DB Warning"}:{bg:"bg-emerald-50 border-emerald-200 text-emerald-600 hover:bg-emerald-100",dot:"bg-emerald-500",ping:"bg-emerald-400",label:n==="zh"?"SQLite 数据库连接正常":"SQLite DB Connected & Normal"};return a.jsxs("div",{id:"db-connection-status-badge",className:`w-8 h-8 rounded-lg border flex items-center justify-center relative select-none shrink-0 cursor-pointer transition-colors shadow-3xs ${P.bg}`,title:P.label,children:[a.jsx($f,{size:15}),a.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2.5 w-2.5",children:[a.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${P.ping}`}),a.jsx("span",{className:`relative inline-flex rounded-full h-2.5 w-2.5 ${P.dot}`})]})]})})(),a.jsx($p,{session:i,lang:n,onLogout:D,onProfile:()=>S(!0)})]})]})}const Jp="openlearn_live_classroom_sync";class ua{constructor(t=Jp){this.channel=null,this.isDestroyed=!1,this.messageListeners=[],typeof window<"u"&&typeof window.BroadcastChannel<"u"&&(this.channel=new BroadcastChannel(t),this.channel.onmessage=n=>{this.isDestroyed||!n.data||this.messageListeners.forEach(s=>{try{s(n.data)}catch(r){console.error("[ClassroomSyncChannel] Listener error:",r)}})})}onMessage(t){return this.messageListeners.push(t),()=>{this.messageListeners=this.messageListeners.filter(n=>n!==t)}}postMessage(t){if(!(this.isDestroyed||!this.channel))try{this.channel.postMessage(t)}catch(n){console.warn("[ClassroomSyncChannel] Failed to post message:",n)}}broadcastInitState(t){this.postMessage({type:"TEACHER_INIT_STATE",payload:t})}broadcastChangeLesson(t){this.postMessage({type:"TEACHER_CHANGE_LESSON",payload:{lessonId:t}})}broadcastChangeSegment(t){this.postMessage({type:"TEACHER_CHANGE_SEGMENT",payload:{segmentId:t}})}broadcastChangeTab(t){this.postMessage({type:"TEACHER_CHANGE_TAB",payload:{tab:t}})}broadcastLockClass(t){this.postMessage({type:"TEACHER_LOCK_CLASS",payload:{locked:t}})}broadcastPickStudent(t,n){this.postMessage({type:"TEACHER_PICK_STUDENT",payload:{studentId:t,studentName:n}})}broadcastSyncTimer(t,n){this.postMessage({type:"TEACHER_SYNC_TIMER",payload:{timeRemaining:t,isRunning:n}})}broadcastPingStudent(t,n){this.postMessage({type:"TEACHER_PING_STUDENT",payload:{studentId:t,message:n}})}broadcastFullscreen(t,n){this.postMessage({type:"TEACHER_BROADCAST_FULLSCREEN",payload:{elementId:t,lessonId:n}})}requestHandshake(){this.postMessage({type:"STUDENT_HANDSHAKE_REQUEST"})}acknowledgePick(t){this.postMessage({type:"STUDENT_ACKNOWLEDGE_PICK",payload:{studentId:t}})}sendHeartbeat(t){this.postMessage({type:"STUDENT_HEARTBEAT",payload:{studentId:t,timestamp:Date.now()}})}destroy(){this.isDestroyed=!0,this.messageListeners=[],this.channel&&(this.channel.close(),this.channel=null)}}const tn=bt(e=>({remoteFullscreenElementId:null,setRemoteFullscreenElementId:t=>e({remoteFullscreenElementId:t}),clearRemoteFullscreen:()=>e({remoteFullscreenElementId:null})})),pC=e=>Is(tn,e);function Zp({open:e,session:t,lang:n,onClose:s,onSaved:r,onAvatar:i}){const[o,l]=p.useState(t.name),[c,u]=p.useState(!1),[d,h]=p.useState(null),m=p.useRef(null),[f,g]=p.useState(!1),[y,C]=p.useState(null),[w,N]=p.useState(!1),[S,E]=p.useState(""),[I,k]=p.useState(""),[z,D]=p.useState(""),[F,_]=p.useState(!1),[A,L]=p.useState(null),[O,R]=p.useState(!1);if(!e)return null;const P=(J,U)=>n==="zh"?J:U,T=t.role==="teacher"?t.subRole==="administrator"?P("管理员","Administrator"):P("教师","Teacher"):P("学生","Student"),W=o.trim(),j=W.length>0&&W!==t.name,$=async()=>{if(!(!j||c)){u(!0),h(null);try{const J=await fetch("/api/auth/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W})}),U=await J.json();if(!J.ok){h(U.error||(n==="zh"?"保存失败":"Save failed"));return}r(U.name??W)}catch{h(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{u(!1)}}},x=S.length>0&&I.length>=8&&/[a-zA-Z]/.test(I)&&/[0-9]/.test(I)&&I===z,oe=async()=>{if(!(!x||F)){_(!0),L(null);try{const J=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:S,newPassword:I})}),U=await J.json();if(!J.ok){L(U.error||(n==="zh"?"修改失败":"Change failed"));return}R(!0),E(""),k(""),D(""),N(!1)}catch{L(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{_(!1)}}},pe=async J=>{const U=J.target.files?.[0];if(J.target.value="",!!U){g(!0),C(null);try{const Q=await new Promise((we,me)=>{const le=new FileReader;le.onload=()=>we(le.result),le.onerror=()=>me(le.error),le.readAsDataURL(U)}),re=await fetch("/api/auth/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:U.name,base64Data:Q})}),se=await re.json();if(!re.ok){C(se.error||(n==="zh"?"上传失败":"Upload failed"));return}i?.(se.avatar)}catch{C(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}}},b=async()=>{g(!0),C(null);try{const J=await fetch("/api/auth/avatar",{method:"DELETE"}),U=await J.json().catch(()=>({}));if(!J.ok){C(U.error||(n==="zh"?"移除失败":"Remove failed"));return}i?.(null)}catch{C(n==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}};return a.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4",onClick:s,children:a.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden",onClick:J=>J.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[a.jsx("h3",{className:"font-semibold text-gray-800",children:P("个人资料","Profile")}),a.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:a.jsx(ot,{size:18})})]}),a.jsxs("div",{className:"p-5 space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"w-14 h-14 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center shrink-0 overflow-hidden",children:t.avatar?a.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full object-cover"}):a.jsx(In,{size:28})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-base font-semibold text-gray-800 truncate",children:t.name}),a.jsx("p",{className:"text-xs text-gray-400",children:T}),a.jsxs("div",{className:"mt-1.5 flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:()=>m.current?.click(),disabled:f,className:"text-xs text-indigo-600 hover:text-indigo-800 disabled:opacity-50 cursor-pointer",children:f?P("上传中…","Uploading…"):t.avatar?P("更换头像","Change avatar"):P("上传头像","Upload avatar")}),t.avatar&&a.jsx("button",{type:"button",onClick:b,disabled:f,className:"text-xs text-rose-500 hover:text-rose-700 disabled:opacity-50 cursor-pointer",children:P("移除","Remove")})]}),a.jsx("input",{ref:m,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:pe})]})]}),y&&a.jsx("p",{className:"text-xs text-rose-500",children:y}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:P("显示名称","Display Name")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{value:o,onChange:J=>l(J.target.value),maxLength:50,className:"flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),a.jsx("button",{onClick:$,disabled:!j||c,className:"px-4 py-2 rounded-lg bg-indigo-600 text-white text-sm font-medium disabled:opacity-40 enabled:hover:bg-indigo-700 transition-colors cursor-pointer shrink-0",children:c?P("保存中…","Saving…"):P("保存","Save")})]}),d&&a.jsx("p",{className:"text-xs text-rose-500 mt-1",children:d})]}),a.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:[a.jsx(Vf,{size:16,className:"text-gray-400"}),P("修改密码","Change Password")]}),!w&&!O&&a.jsx("button",{onClick:()=>{N(!0),L(null)},className:"text-sm text-indigo-600 hover:text-indigo-800 cursor-pointer",children:P("修改","Edit")})]}),O&&a.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-sm text-emerald-600",children:[a.jsx(Ln,{size:16}),P("密码已修改,其他设备的登录已失效","Password changed. Other devices were logged out.")]}),w&&a.jsxs("div",{className:"mt-3 space-y-3",children:[a.jsx("input",{type:"password",value:S,onChange:J=>E(J.target.value),placeholder:P("当前密码","Current password"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),a.jsx("input",{type:"password",value:I,onChange:J=>k(J.target.value),placeholder:P("新密码(≥8 位,含字母和数字)","New password (≥8 chars, letters + numbers)"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),a.jsx("input",{type:"password",value:z,onChange:J=>D(J.target.value),placeholder:P("确认新密码","Confirm new password"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-indigo-200"}),A&&a.jsx("p",{className:"text-xs text-rose-500",children:A}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx("button",{onClick:()=>{N(!1),E(""),k(""),D(""),L(null)},className:"px-4 py-2 rounded-lg border border-gray-300 text-sm text-gray-600 hover:bg-gray-50 cursor-pointer",children:P("取消","Cancel")}),a.jsx("button",{onClick:oe,disabled:!x||F,className:"px-4 py-2 rounded-lg bg-indigo-600 text-white text-sm font-medium disabled:opacity-40 enabled:hover:bg-indigo-700 transition-colors cursor-pointer",children:F?P("提交中…","Submitting…"):P("提交","Submit")})]})]})]}),a.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-400",children:P("用户名(登录账号)","Username (login)")}),a.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-[60%]",title:t.username,children:t.username||"-"})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-gray-400",children:P("角色","Role")}),a.jsx("span",{className:"text-sm font-medium text-gray-700",children:T})]})]})]})]})})}class Yp{constructor(){this.store=bt(()=>({items:new Map}))}register(t,n){const s=n||t.pluginId;this.store.setState(r=>{const i=new Map(r.items);return i.set(t.type,{config:{...t,pluginId:s},pluginId:s}),{items:i}})}unregister(t,n){this.store.setState(s=>{const r=s.items.get(t);if(!r||n&&r.pluginId!==n)return s;const i=new Map(s.items);return i.delete(t),{items:i}})}unregisterPlugin(t){this.store.setState(n=>{let s=!1;const r=new Map(n.items);for(const[i,o]of n.items)o.pluginId===t&&(r.delete(i),s=!0);return s?{items:r}:n})}get(t){return this.store.getState().items.get(t)?.config}getAll(){return Array.from(this.store.getState().items.values()).map(t=>t.config)}has(t){return this.store.getState().items.has(t)}getStore(){return this.store}}const En=new Yp;function mC(){return Is(En.getStore(),Nf(e=>Array.from(e.items.values()).map(t=>t.config)))}const gC={slate:{iconBg:"bg-slate-100",iconText:"text-slate-600",cardHoverBorder:"hover:border-slate-400",cardHoverRing:"group-hover:ring-slate-300",cardHoverShadow:"group-hover:shadow-slate-200/70",groupAccent:"bg-slate-400",groupText:"text-slate-500"},blue:{iconBg:"bg-blue-100",iconText:"text-blue-600",cardHoverBorder:"hover:border-blue-400",cardHoverRing:"group-hover:ring-blue-300",cardHoverShadow:"group-hover:shadow-blue-200/70",groupAccent:"bg-blue-400",groupText:"text-blue-500"},violet:{iconBg:"bg-violet-100",iconText:"text-violet-600",cardHoverBorder:"hover:border-violet-400",cardHoverRing:"group-hover:ring-violet-300",cardHoverShadow:"group-hover:shadow-violet-200/70",groupAccent:"bg-violet-400",groupText:"text-violet-500"},amber:{iconBg:"bg-amber-100",iconText:"text-amber-600",cardHoverBorder:"hover:border-amber-400",cardHoverRing:"group-hover:ring-amber-300",cardHoverShadow:"group-hover:shadow-amber-200/70",groupAccent:"bg-amber-400",groupText:"text-amber-500"},rose:{iconBg:"bg-rose-100",iconText:"text-rose-600",cardHoverBorder:"hover:border-rose-400",cardHoverRing:"group-hover:ring-rose-300",cardHoverShadow:"group-hover:shadow-rose-200/70",groupAccent:"bg-rose-400",groupText:"text-rose-500"},emerald:{iconBg:"bg-emerald-100",iconText:"text-emerald-600",cardHoverBorder:"hover:border-emerald-400",cardHoverRing:"group-hover:ring-emerald-300",cardHoverShadow:"group-hover:shadow-emerald-200/70",groupAccent:"bg-emerald-400",groupText:"text-emerald-500"},cyan:{iconBg:"bg-cyan-100",iconText:"text-cyan-600",cardHoverBorder:"hover:border-cyan-400",cardHoverRing:"group-hover:ring-cyan-300",cardHoverShadow:"group-hover:shadow-cyan-200/70",groupAccent:"bg-cyan-400",groupText:"text-cyan-500"},pink:{iconBg:"bg-pink-100",iconText:"text-pink-600",cardHoverBorder:"hover:border-pink-400",cardHoverRing:"group-hover:ring-pink-300",cardHoverShadow:"group-hover:shadow-pink-200/70",groupAccent:"bg-pink-400",groupText:"text-pink-500"},indigo:{iconBg:"bg-indigo-100",iconText:"text-indigo-600",cardHoverBorder:"hover:border-indigo-400",cardHoverRing:"group-hover:ring-indigo-300",cardHoverShadow:"group-hover:shadow-indigo-200/70",groupAccent:"bg-indigo-400",groupText:"text-indigo-500"}},xC=[{id:"present",labelZh:"内容呈现",labelEn:"Content"},{id:"assess",labelZh:"评估互动",labelEn:"Assessment"},{id:"manage",labelZh:"课堂管理",labelEn:"Classroom"},{id:"extension",labelZh:"插件扩展",labelEn:"Extensions"}],Kp=[{type:"presentation",labelZh:"课件演示",labelEn:"Slides Deck",descriptionZh:"Markdown 幻灯片",descriptionEn:"Markdown slides",icon:Uf,color:"violet",group:"present",defaultData:{markdown:`# Title Slide
|
|
5
|
+
---
|
|
6
|
+
## Slide 2`},editFields:[{key:"markdown",labelZh:"幻灯片内容 (Markdown)",labelEn:"Slides Content (Markdown)",kind:"textarea",placeholderZh:`# 标题
|
|
7
|
+
---
|
|
8
|
+
## 第二页`}]},{type:"code-sandbox",labelZh:"代码沙箱",labelEn:"Code Editor",descriptionZh:"可运行代码",descriptionEn:"Runnable code",icon:ls,color:"slate",group:"present",defaultData:{code:"console.log('Hello Sandbox!');"},editFields:[{key:"code",labelZh:"代码",labelEn:"Code",kind:"textarea",placeholderZh:"console.log('Hello');"}]},{type:"math-graph",labelZh:"数学函数",labelEn:"Math Grapher",descriptionZh:"函数图像",descriptionEn:"Function graph",icon:Hf,color:"blue",group:"present",defaultData:{equation:"Math.sin(x)"},editFields:[{key:"equation",labelZh:"函数表达式",labelEn:"Equation",kind:"input",placeholderZh:"如 Math.sin(x)"}]},{type:"html-applet",labelZh:"交互网页课件",labelEn:"Interactive Courseware",descriptionZh:"可交互 HTML/ZIP 网页",descriptionEn:"Interactive web/ZIP applet",icon:mi,color:"emerald",group:"present",defaultData:{title:"Interactive Web Courseware",code:`<!-- Interactive Web Courseware -->
|
|
9
|
+
<div style='padding:20px; text-align:center;'>
|
|
10
|
+
<h2>Interactive Web Courseware</h2>
|
|
11
|
+
<p>在属性栏中配置本地 ZIP/HTML 部署包。</p>
|
|
12
|
+
</div>`},editFields:[{key:"title",labelZh:"标题",labelEn:"Title",kind:"input",placeholderZh:"课件标题",placeholderEn:"Courseware title"},{key:"coursewareUuid",labelZh:"互动课件 (Courseware)",labelEn:"Courseware",kind:"select",loadOptions:async()=>{try{return(await(await fetch("/api/courseware")).json()).map(n=>({value:n.uuid,label:n.name}))}catch{return[]}}},{key:"code",labelZh:"HTML 代码",labelEn:"HTML Code",kind:"textarea",placeholderZh:"<div>…</div>"}]},{type:"quiz",labelZh:"随堂测试",labelEn:"Interactive Quiz",descriptionZh:"选择题互动",descriptionEn:"Multiple choice",icon:Fi,color:"amber",group:"assess",defaultData:{question:"New Quiz",options:["A","B","C","D"]},editFields:[{key:"question",labelZh:"题目",labelEn:"Question",kind:"input",placeholderZh:"请输入题目"},{key:"options",labelZh:"选项 (A/B/C/D)",labelEn:"Options (A/B/C/D)",kind:"options"}]},{type:"assignment",labelZh:"作业提交",labelEn:"Assignment",descriptionZh:"布置与提交",descriptionEn:"Submit work",icon:Ll,color:"rose",group:"assess",defaultData:{title:"New Assignment",description:"Upload your work here"},editFields:[{key:"title",labelZh:"作业标题",labelEn:"Title",kind:"input",placeholderZh:"如:第一章练习"},{key:"description",labelZh:"说明",labelEn:"Description",kind:"textarea",placeholderZh:"作业要求说明…"}]},{type:"rollcall",labelZh:"随机点名",labelEn:"Random Picker",descriptionZh:"课堂点名",descriptionEn:"Pick a student",icon:qf,color:"cyan",group:"manage",defaultData:{allStudents:[]},editFields:[]},{type:"hello-world",labelZh:"问候插件",labelEn:"Hello World",descriptionZh:"欢迎问候",descriptionEn:"Welcome greeting",icon:_n,color:"pink",group:"manage",defaultData:{},editFields:[]}],Xp=Kp.reduce((e,t)=>(e[t.type]=t,e),{});function em(e){return Xp[e]||En.get(e)}const st=bt(e=>({lang:"zh",activeRole:"teacher",teacherTab:"courses",profileOpen:!1,isCourseWizardOpen:!1,isImportLessonsOpen:!1,isQuizGeneratorOpen:!1,isLessonPreviewVisible:!1,isSystemResourceLibraryOpen:!1,batchPicker:null,isExportWeightModalOpen:!1,toasts:[],siteInfo:{siteName:"",slogan:"",logoUrl:null},setLang:t=>e({lang:t}),setActiveRole:t=>e({activeRole:t}),setTeacherTab:t=>e({teacherTab:t}),setProfileOpen:t=>e({profileOpen:t}),setIsCourseWizardOpen:t=>e({isCourseWizardOpen:t}),setIsImportLessonsOpen:t=>e({isImportLessonsOpen:t}),setIsQuizGeneratorOpen:t=>e({isQuizGeneratorOpen:t}),setIsLessonPreviewVisible:t=>e({isLessonPreviewVisible:t}),setIsSystemResourceLibraryOpen:t=>e({isSystemResourceLibraryOpen:t}),setBatchPicker:t=>e({batchPicker:t}),setIsExportWeightModalOpen:t=>e({isExportWeightModalOpen:t}),addToast:t=>e(n=>({toasts:[...n.toasts,t]})),removeToast:t=>e(n=>({toasts:n.toasts.filter(s=>s.id!==t)})),setSiteInfo:t=>e({siteInfo:t})})),tm=bt(e=>({classes:[],students:[],classStudentsMap:{},classDashboardMap:{},studentProgressMap:{},classSchedulesMap:{},scheduleAttendanceMap:{},assignmentSubmissionsMap:{},classAssignmentsMap:{},classProgressMap:{},classSeats:{lab_id:null,seats:[]},setClasses:t=>e({classes:t}),setStudents:t=>e({students:t}),setClassStudents:(t,n)=>e(s=>({classStudentsMap:{...s.classStudentsMap,[t]:n}})),setClassDashboard:(t,n)=>e(s=>({classDashboardMap:{...s.classDashboardMap,[t]:n}})),setStudentProgress:(t,n)=>e(s=>({studentProgressMap:{...s.studentProgressMap,[t]:n}})),setClassSchedules:(t,n)=>e(s=>({classSchedulesMap:{...s.classSchedulesMap,[t]:n}})),setScheduleAttendance:(t,n)=>e(s=>({scheduleAttendanceMap:{...s.scheduleAttendanceMap,[t]:n}})),setAssignmentSubmissions:(t,n)=>e(s=>({assignmentSubmissionsMap:{...s.assignmentSubmissionsMap,[t]:n}})),setClassAssignments:(t,n)=>e(s=>({classAssignmentsMap:{...s.classAssignmentsMap,[t]:n}})),setClassProgress:(t,n)=>e(s=>({classProgressMap:{...s.classProgressMap,[t]:n}})),setClassSeats:t=>e({classSeats:t})})),nm=bt(e=>({lessons:[],selectedLesson:null,elements:[],vfsNodes:[],setLessons:t=>e(n=>({lessons:typeof t=="function"?t(n.lessons):t})),setSelectedLesson:t=>e({selectedLesson:t}),setElements:t=>e({elements:t}),setVfsNodes:t=>e({vfsNodes:t})})),sm=bt(e=>({liveClassSelectedClassId:null,liveClassIsActive:!1,liveClassFeed:[],liveClassTimeRemaining:0,liveClassAcknowledgedMap:new Map,liveClassStudentProgress:[],onlineStudentIds:[],activeStudentLessons:{},setLiveClassSelectedClassId:t=>e({liveClassSelectedClassId:t}),setLiveClassIsActive:t=>e({liveClassIsActive:t}),setLiveClassFeed:t=>e({liveClassFeed:t}),appendLiveClassFeed:t=>e(n=>({liveClassFeed:[...n.liveClassFeed.slice(-49),t]})),setLiveClassTimeRemaining:t=>e({liveClassTimeRemaining:t}),setLiveClassAcknowledgedMap:t=>e({liveClassAcknowledgedMap:t}),setLiveClassStudentProgress:t=>e({liveClassStudentProgress:t}),setOnlineStudentIds:t=>e({onlineStudentIds:t}),setActiveStudentLessons:t=>e({activeStudentLessons:t})})),rm=bt(e=>({studentDashboardData:null,notifications:[],setStudentDashboardData:t=>e({studentDashboardData:t}),setNotifications:t=>e({notifications:t})})),Ee=bt(e=>({lang:st.getState().lang,session:null,lessons:[],selectedLesson:null,elements:[],classes:[],students:[],liveClassSelectedClassId:null,liveClassIsActive:!1,teacherTab:st.getState().teacherTab,aiProviders:[],plugins:[],registeredCommands:[],events:[],approvals:[],processes:[],vfsNodes:[],todaySchedules:[],computerLabs:[],dbConnected:!1,sessionLoading:!0,classStudentsMap:{},classDashboardMap:{},studentProgressMap:{},classSchedulesMap:{},scheduleAttendanceMap:{},assignmentSubmissionsMap:{},classAssignmentsMap:{},classProgressMap:{},classSeats:{lab_id:null,seats:[]},onlineStudentIds:[],activeStudentLessons:{},liveClassFeed:[],liveClassTimeRemaining:0,liveClassAcknowledgedMap:new Map,liveClassStudentProgress:[],studentDashboardData:null,notifications:[],toasts:st.getState().toasts,siteInfo:st.getState().siteInfo,setLang:t=>{st.getState().setLang(t)},setSession:t=>e({session:t}),setLessons:t=>e(n=>({lessons:typeof t=="function"?t(n.lessons):t})),setSelectedLesson:t=>e({selectedLesson:t}),setElements:t=>e({elements:t}),setClasses:t=>e({classes:t}),setStudents:t=>e({students:t}),setLiveClassSelectedClassId:t=>e({liveClassSelectedClassId:t}),setLiveClassIsActive:t=>e({liveClassIsActive:t}),setTeacherTab:t=>{st.getState().setTeacherTab(t)},setAiProviders:t=>e({aiProviders:t}),setPlugins:t=>e({plugins:t}),setRegisteredCommands:t=>e({registeredCommands:t}),setEvents:t=>e({events:t}),setApprovals:t=>e({approvals:t}),setProcesses:t=>e({processes:t}),setVfsNodes:t=>e({vfsNodes:t}),setTodaySchedules:t=>e({todaySchedules:t}),setComputerLabs:t=>e({computerLabs:t}),setDbConnected:t=>e({dbConnected:t}),setSessionLoading:t=>e({sessionLoading:t}),setClassStudents:(t,n)=>e(s=>({classStudentsMap:{...s.classStudentsMap,[t]:n}})),setClassDashboard:(t,n)=>e(s=>({classDashboardMap:{...s.classDashboardMap,[t]:n}})),setStudentProgress:(t,n)=>e(s=>({studentProgressMap:{...s.studentProgressMap,[t]:n}})),setClassSchedules:(t,n)=>e(s=>({classSchedulesMap:{...s.classSchedulesMap,[t]:n}})),setScheduleAttendance:(t,n)=>e(s=>({scheduleAttendanceMap:{...s.scheduleAttendanceMap,[t]:n}})),setAssignmentSubmissions:(t,n)=>e(s=>({assignmentSubmissionsMap:{...s.assignmentSubmissionsMap,[t]:n}})),setClassAssignments:(t,n)=>e(s=>({classAssignmentsMap:{...s.classAssignmentsMap,[t]:n}})),setClassProgress:(t,n)=>e(s=>({classProgressMap:{...s.classProgressMap,[t]:n}})),setClassSeats:t=>e({classSeats:t}),setOnlineStudentIds:t=>e({onlineStudentIds:t}),setActiveStudentLessons:t=>e({activeStudentLessons:t}),setLiveClassFeed:t=>e({liveClassFeed:t}),appendLiveClassFeed:t=>e(n=>({liveClassFeed:[...n.liveClassFeed.slice(-49),t]})),setLiveClassTimeRemaining:t=>e({liveClassTimeRemaining:t}),setLiveClassAcknowledgedMap:t=>e({liveClassAcknowledgedMap:t}),setLiveClassStudentProgress:t=>e({liveClassStudentProgress:t}),setStudentDashboardData:t=>e({studentDashboardData:t}),setNotifications:t=>e({notifications:t}),addToast:t=>{st.getState().addToast(t)},removeToast:t=>{st.getState().removeToast(t)},setSiteInfo:t=>{st.getState().setSiteInfo(t)}}));st.subscribe(e=>{Ee.setState({lang:e.lang,teacherTab:e.teacherTab,toasts:e.toasts,siteInfo:e.siteInfo})});tm.subscribe(e=>{Ee.setState({classes:e.classes,students:e.students,classStudentsMap:e.classStudentsMap,classDashboardMap:e.classDashboardMap,studentProgressMap:e.studentProgressMap,classSchedulesMap:e.classSchedulesMap,scheduleAttendanceMap:e.scheduleAttendanceMap,assignmentSubmissionsMap:e.assignmentSubmissionsMap,classAssignmentsMap:e.classAssignmentsMap,classProgressMap:e.classProgressMap,classSeats:e.classSeats})});nm.subscribe(e=>{Ee.setState({lessons:e.lessons,selectedLesson:e.selectedLesson,elements:e.elements,vfsNodes:e.vfsNodes})});sm.subscribe(e=>{Ee.setState({liveClassSelectedClassId:e.liveClassSelectedClassId,liveClassIsActive:e.liveClassIsActive,liveClassFeed:e.liveClassFeed,liveClassTimeRemaining:e.liveClassTimeRemaining,liveClassAcknowledgedMap:e.liveClassAcknowledgedMap,liveClassStudentProgress:e.liveClassStudentProgress,onlineStudentIds:e.onlineStudentIds,activeStudentLessons:e.activeStudentLessons})});rm.subscribe(e=>{Ee.setState({studentDashboardData:e.studentDashboardData,notifications:e.notifications})});const he=e=>Is(Ee,e);function im(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const om=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,am=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lm={};function da(e,t){return(lm.jsx?am:om).test(e)}const cm=/[ \t\n\f\r]/g;function um(e){return typeof e=="object"?e.type==="text"?ha(e.value):!1:ha(e)}function ha(e){return e.replace(cm,"")===""}class Rn{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Rn.prototype.normal={};Rn.prototype.property={};Rn.prototype.space=void 0;function ql(e,t){const n={},s={};for(const r of e)Object.assign(n,r.property),Object.assign(s,r.normal);return new Rn(n,s,t)}function xi(e){return e.toLowerCase()}class De{constructor(t,n){this.attribute=n,this.property=t}}De.prototype.attribute="";De.prototype.booleanish=!1;De.prototype.boolean=!1;De.prototype.commaOrSpaceSeparated=!1;De.prototype.commaSeparated=!1;De.prototype.defined=!1;De.prototype.mustUseProperty=!1;De.prototype.number=!1;De.prototype.overloadedBoolean=!1;De.prototype.property="";De.prototype.spaceSeparated=!1;De.prototype.space=void 0;let dm=0;const ne=Dt(),Se=Dt(),yi=Dt(),V=Dt(),de=Dt(),Ot=Dt(),Be=Dt();function Dt(){return 2**++dm}const bi=Object.freeze(Object.defineProperty({__proto__:null,boolean:ne,booleanish:Se,commaOrSpaceSeparated:Be,commaSeparated:Ot,number:V,overloadedBoolean:yi,spaceSeparated:de},Symbol.toStringTag,{value:"Module"})),$r=Object.keys(bi);class qi extends De{constructor(t,n,s,r){let i=-1;if(super(t,n),fa(this,"space",r),typeof s=="number")for(;++i<$r.length;){const o=$r[i];fa(this,$r[i],(s&bi[o])===bi[o])}}}qi.prototype.defined=!0;function fa(e,t,n){n&&(e[t]=n)}function rn(e){const t={},n={};for(const[s,r]of Object.entries(e.properties)){const i=new qi(s,e.transform(e.attributes||{},s),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(i.mustUseProperty=!0),t[s]=i,n[xi(s)]=s,n[xi(i.attribute)]=s}return new Rn(t,n,e.space)}const Wl=rn({properties:{ariaActiveDescendant:null,ariaAtomic:Se,ariaAutoComplete:null,ariaBusy:Se,ariaChecked:Se,ariaColCount:V,ariaColIndex:V,ariaColSpan:V,ariaControls:de,ariaCurrent:null,ariaDescribedBy:de,ariaDetails:null,ariaDisabled:Se,ariaDropEffect:de,ariaErrorMessage:null,ariaExpanded:Se,ariaFlowTo:de,ariaGrabbed:Se,ariaHasPopup:null,ariaHidden:Se,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:de,ariaLevel:V,ariaLive:null,ariaModal:Se,ariaMultiLine:Se,ariaMultiSelectable:Se,ariaOrientation:null,ariaOwns:de,ariaPlaceholder:null,ariaPosInSet:V,ariaPressed:Se,ariaReadOnly:Se,ariaRelevant:null,ariaRequired:Se,ariaRoleDescription:de,ariaRowCount:V,ariaRowIndex:V,ariaRowSpan:V,ariaSelected:Se,ariaSetSize:V,ariaSort:null,ariaValueMax:V,ariaValueMin:V,ariaValueNow:V,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Gl(e,t){return t in e?e[t]:t}function Ql(e,t){return Gl(e,t.toLowerCase())}const hm=rn({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ot,acceptCharset:de,accessKey:de,action:null,allow:null,allowFullScreen:ne,allowPaymentRequest:ne,allowUserMedia:ne,alpha:ne,alt:null,as:null,async:ne,autoCapitalize:null,autoComplete:de,autoFocus:ne,autoPlay:ne,blocking:de,capture:null,charSet:null,checked:ne,cite:null,className:de,closedBy:null,colorSpace:null,cols:V,colSpan:V,command:null,commandFor:null,content:null,contentEditable:Se,controls:ne,controlsList:de,coords:V|Ot,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ne,defer:ne,dir:null,dirName:null,disabled:ne,download:yi,draggable:Se,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ne,formTarget:null,headers:de,height:V,hidden:yi,high:V,href:null,hrefLang:null,htmlFor:de,httpEquiv:de,id:null,imageSizes:null,imageSrcSet:null,inert:ne,inputMode:null,integrity:null,is:null,isMap:ne,itemId:null,itemProp:de,itemRef:de,itemScope:ne,itemType:de,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ne,low:V,manifest:null,max:null,maxLength:V,media:null,method:null,min:null,minLength:V,multiple:ne,muted:ne,name:null,nonce:null,noModule:ne,noValidate:ne,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ne,optimum:V,pattern:null,ping:de,placeholder:null,playsInline:ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ne,referrerPolicy:null,rel:de,required:ne,reversed:ne,rows:V,rowSpan:V,sandbox:de,scope:null,scoped:ne,seamless:ne,selected:ne,shadowRootClonable:ne,shadowRootCustomElementRegistry:ne,shadowRootDelegatesFocus:ne,shadowRootMode:null,shadowRootSerializable:ne,shape:null,size:V,sizes:null,slot:null,span:V,spellCheck:Se,src:null,srcDoc:null,srcLang:null,srcSet:null,start:V,step:null,style:null,tabIndex:V,target:null,title:null,translate:null,type:null,typeMustMatch:ne,useMap:null,value:Se,width:V,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:de,axis:null,background:null,bgColor:null,border:V,borderColor:null,bottomMargin:V,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ne,declare:ne,event:null,face:null,frame:null,frameBorder:null,hSpace:V,leftMargin:V,link:null,longDesc:null,lowSrc:null,marginHeight:V,marginWidth:V,noResize:ne,noHref:ne,noShade:ne,noWrap:ne,object:null,profile:null,prompt:null,rev:null,rightMargin:V,rules:null,scheme:null,scrolling:Se,standby:null,summary:null,text:null,topMargin:V,valueType:null,version:null,vAlign:null,vLink:null,vSpace:V,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ne,disablePictureInPicture:ne,disableRemotePlayback:ne,exportParts:Ot,part:de,prefix:null,property:null,results:V,security:null,unselectable:null},space:"html",transform:Ql}),fm=rn({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Be,accentHeight:V,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:V,amplitude:V,arabicForm:null,ascent:V,attributeName:null,attributeType:null,azimuth:V,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:V,by:null,calcMode:null,capHeight:V,className:de,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:V,diffuseConstant:V,direction:null,display:null,dur:null,divisor:V,dominantBaseline:null,download:ne,dx:null,dy:null,edgeMode:null,editable:null,elevation:V,enableBackground:null,end:null,event:null,exponent:V,externalResourcesRequired:null,fill:null,fillOpacity:V,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ot,g2:Ot,glyphName:Ot,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:V,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:V,horizOriginX:V,horizOriginY:V,id:null,ideographic:V,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:V,k:V,k1:V,k2:V,k3:V,k4:V,kernelMatrix:Be,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:V,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:V,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:V,overlineThickness:V,paintOrder:null,panose1:null,path:null,pathLength:V,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:de,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:V,pointsAtY:V,pointsAtZ:V,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Be,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Be,rev:Be,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Be,requiredFeatures:Be,requiredFonts:Be,requiredFormats:Be,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:V,specularExponent:V,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:V,strikethroughThickness:V,string:null,stroke:null,strokeDashArray:Be,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:V,strokeOpacity:V,strokeWidth:null,style:null,surfaceScale:V,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Be,tabIndex:V,tableValues:null,target:null,targetX:V,targetY:V,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Be,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:V,underlineThickness:V,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:V,values:null,vAlphabetic:V,vMathematical:V,vectorEffect:null,vHanging:V,vIdeographic:V,version:null,vertAdvY:V,vertOriginX:V,vertOriginY:V,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:V,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Gl}),Jl=rn({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Zl=rn({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ql}),Yl=rn({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),pm={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},mm=/[A-Z]/g,pa=/-[a-z]/g,gm=/^data[-\w.:]+$/i;function xm(e,t){const n=xi(t);let s=t,r=De;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&gm.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(pa,bm);s="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!pa.test(i)){let o=i.replace(mm,ym);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}r=qi}return new r(s,t)}function ym(e){return"-"+e.toLowerCase()}function bm(e){return e.charAt(1).toUpperCase()}const wm=ql([Wl,hm,Jl,Zl,Yl],"html"),Wi=ql([Wl,fm,Jl,Zl,Yl],"svg");function Sm(e){return e.join(" ").trim()}var Qt={},Vr,ma;function vm(){if(ma)return Vr;ma=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,r=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,l=/^\s+|\s+$/g,c=`
|
|
13
|
+
`,u="/",d="*",h="",m="comment",f="declaration";function g(C,w){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];w=w||{};var N=1,S=1;function E(R){var P=R.match(t);P&&(N+=P.length);var T=R.lastIndexOf(c);S=~T?R.length-T:S+R.length}function I(){var R={line:N,column:S};return function(P){return P.position=new k(R),F(),P}}function k(R){this.start=R,this.end={line:N,column:S},this.source=w.source}k.prototype.content=C;function z(R){var P=new Error(w.source+":"+N+":"+S+": "+R);if(P.reason=R,P.filename=w.source,P.line=N,P.column=S,P.source=C,!w.silent)throw P}function D(R){var P=R.exec(C);if(P){var T=P[0];return E(T),C=C.slice(T.length),P}}function F(){D(n)}function _(R){var P;for(R=R||[];P=A();)P!==!1&&R.push(P);return R}function A(){var R=I();if(!(u!=C.charAt(0)||d!=C.charAt(1))){for(var P=2;h!=C.charAt(P)&&(d!=C.charAt(P)||u!=C.charAt(P+1));)++P;if(P+=2,h===C.charAt(P-1))return z("End of comment missing");var T=C.slice(2,P-2);return S+=2,E(T),C=C.slice(P),S+=2,R({type:m,comment:T})}}function L(){var R=I(),P=D(s);if(P){if(A(),!D(r))return z("property missing ':'");var T=D(i),W=R({type:f,property:y(P[0].replace(e,h)),value:T?y(T[0].replace(e,h)):h});return D(o),W}}function O(){var R=[];_(R);for(var P;P=L();)P!==!1&&(R.push(P),_(R));return R}return F(),O()}function y(C){return C?C.replace(l,h):h}return Vr=g,Vr}var ga;function Cm(){if(ga)return Qt;ga=1;var e=Qt&&Qt.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.default=n;const t=e(vm());function n(s,r){let i=null;if(!s||typeof s!="string")return i;const o=(0,t.default)(s),l=typeof r=="function";return o.forEach(c=>{if(c.type!=="declaration")return;const{property:u,value:d}=c;l?r(u,d,c):d&&(i=i||{},i[u]=d)}),i}return Qt}var yn={},xa;function km(){if(xa)return yn;xa=1,Object.defineProperty(yn,"__esModule",{value:!0}),yn.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,r=/^-(ms)-/,i=function(u){return!u||n.test(u)||e.test(u)},o=function(u,d){return d.toUpperCase()},l=function(u,d){return"".concat(d,"-")},c=function(u,d){return d===void 0&&(d={}),i(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(r,l):u=u.replace(s,l),u.replace(t,o))};return yn.camelCase=c,yn}var bn,ya;function Em(){if(ya)return bn;ya=1;var e=bn&&bn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}},t=e(Cm()),n=km();function s(r,i){var o={};return!r||typeof r!="string"||(0,t.default)(r,function(l,c){l&&c&&(o[(0,n.camelCase)(l,i)]=c)}),o}return s.default=s,bn=s,bn}var jm=Em();const Nm=Tl(jm),Kl=Xl("end"),Gi=Xl("start");function Xl(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function Pm(e){const t=Gi(e),n=Kl(e);if(t&&n)return{start:t,end:n}}function jn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ba(e.position):"start"in e||"end"in e?ba(e):"line"in e||"column"in e?wi(e):""}function wi(e){return wa(e&&e.line)+":"+wa(e&&e.column)}function ba(e){return wi(e&&e.start)+"-"+wi(e&&e.end)}function wa(e){return e&&typeof e=="number"?e:1}class ze extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let r="",i={},o=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?r=t:!i.cause&&t&&(o=!0,r=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof s=="string"){const c=s.indexOf(":");c===-1?i.ruleId=s:(i.source=s.slice(0,c),i.ruleId=s.slice(c+1))}if(!i.place&&i.ancestors&&i.ancestors){const c=i.ancestors[i.ancestors.length-1];c&&(i.place=c.position)}const l=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=l?l.line:void 0,this.name=jn(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ze.prototype.file="";ze.prototype.name="";ze.prototype.reason="";ze.prototype.message="";ze.prototype.stack="";ze.prototype.column=void 0;ze.prototype.line=void 0;ze.prototype.ancestors=void 0;ze.prototype.cause=void 0;ze.prototype.fatal=void 0;ze.prototype.place=void 0;ze.prototype.ruleId=void 0;ze.prototype.source=void 0;const Qi={}.hasOwnProperty,Tm=new Map,Im=/[A-Z]/g,Am=new Set(["table","tbody","thead","tfoot","tr"]),zm=new Set(["td","th"]),ec="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function _m(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=$m(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=Bm(n,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Wi:wm,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=tc(r,e,void 0);return i&&typeof i!="string"?i:r.create(e,r.Fragment,{children:i||void 0},void 0)}function tc(e,t,n){if(t.type==="element")return Lm(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Rm(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Om(e,t,n);if(t.type==="mdxjsEsm")return Mm(e,t);if(t.type==="root")return Dm(e,t,n);if(t.type==="text")return Fm(e,t)}function Lm(e,t,n){const s=e.schema;let r=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(r=Wi,e.schema=r),e.ancestors.push(t);const i=sc(e,t.tagName,!1),o=Vm(e,t);let l=Zi(e,t);return Am.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!um(c):!0})),nc(e,o,i,t),Ji(o,l),e.ancestors.pop(),e.schema=s,e.create(t,i,o,n)}function Rm(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}zn(e,t.position)}function Mm(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);zn(e,t.position)}function Om(e,t,n){const s=e.schema;let r=s;t.name==="svg"&&s.space==="html"&&(r=Wi,e.schema=r),e.ancestors.push(t);const i=t.name===null?e.Fragment:sc(e,t.name,!0),o=Um(e,t),l=Zi(e,t);return nc(e,o,i,t),Ji(o,l),e.ancestors.pop(),e.schema=s,e.create(t,i,o,n)}function Dm(e,t,n){const s={};return Ji(s,Zi(e,t)),e.create(t,e.Fragment,s,n)}function Fm(e,t){return t.value}function nc(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Ji(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Bm(e,t,n){return s;function s(r,i,o,l){const u=Array.isArray(o.children)?n:t;return l?u(i,o,l):u(i,o)}}function $m(e,t){return n;function n(s,r,i,o){const l=Array.isArray(i.children),c=Gi(s);return t(r,i,o,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Vm(e,t){const n={};let s,r;for(r in t.properties)if(r!=="children"&&Qi.call(t.properties,r)){const i=Hm(e,r,t.properties[r]);if(i){const[o,l]=i;e.tableCellAlignToStyle&&o==="align"&&typeof l=="string"&&zm.has(t.tagName)?s=l:n[o]=l}}if(s){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function Um(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const i=s.data.estree.body[0];i.type;const o=i.expression;o.type;const l=o.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else zn(e,t.position);else{const r=s.name;let i;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const l=s.value.data.estree.body[0];l.type,i=e.evaluater.evaluateExpression(l.expression)}else zn(e,t.position);else i=s.value===null?!0:s.value;n[r]=i}return n}function Zi(e,t){const n=[];let s=-1;const r=e.passKeys?new Map:Tm;for(;++s<t.children.length;){const i=t.children[s];let o;if(e.passKeys){const c=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(c){const u=r.get(c)||0;o=c+"-"+u,r.set(c,u+1)}}const l=tc(e,i,o);l!==void 0&&n.push(l)}return n}function Hm(e,t,n){const s=xm(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?im(n):Sm(n)),s.property==="style"){let r=typeof n=="object"?n:qm(e,String(n));return e.stylePropertyNameCase==="css"&&(r=Wm(r)),["style",r]}return[e.elementAttributeNameCase==="react"&&s.space?pm[s.property]||s.property:s.attribute,n]}}function qm(e,t){try{return Nm(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const s=n,r=new ze("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=ec+"#cannot-parse-style-attribute",r}}function sc(e,t,n){let s;if(!n)s={type:"Literal",value:t};else if(t.includes(".")){const r=t.split(".");let i=-1,o;for(;++i<r.length;){const l=da(r[i])?{type:"Identifier",name:r[i]}:{type:"Literal",value:r[i]};o=o?{type:"MemberExpression",object:o,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}s=o}else s=da(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const r=s.value;return Qi.call(e.components,r)?e.components[r]:r}if(e.evaluater)return e.evaluater.evaluateExpression(s);zn(e)}function zn(e,t){const n=new ze("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=ec+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Wm(e){const t={};let n;for(n in e)Qi.call(e,n)&&(t[Gm(n)]=e[n]);return t}function Gm(e){let t=e.replace(Im,Qm);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Qm(e){return"-"+e.toLowerCase()}const Ur={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Jm={};function Zm(e,t){const n=Jm,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,r=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return rc(e,s,r)}function rc(e,t,n){if(Ym(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Sa(e.children,t,n)}return Array.isArray(e)?Sa(e,t,n):""}function Sa(e,t,n){const s=[];let r=-1;for(;++r<e.length;)s[r]=rc(e[r],t,n);return s.join("")}function Ym(e){return!!(e&&typeof e=="object")}const va=document.createElement("i");function Yi(e){const t="&"+e+";";va.innerHTML=t;const n=va.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function at(e,t,n,s){const r=e.length;let i=0,o;if(t<0?t=-t>r?0:r+t:t=t>r?r:t,n=n>0?n:0,s.length<1e4)o=Array.from(s),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);i<s.length;)o=s.slice(i,i+1e4),o.unshift(t,0),e.splice(...o),i+=1e4,t+=1e4}function Ge(e,t){return e.length>0?(at(e,e.length,0,t),e):t}const Ca={}.hasOwnProperty;function Km(e){const t={};let n=-1;for(;++n<e.length;)Xm(t,e[n]);return t}function Xm(e,t){let n;for(n in t){const r=(Ca.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let o;if(i)for(o in i){Ca.call(r,o)||(r[o]=[]);const l=i[o];eg(r[o],Array.isArray(l)?l:l?[l]:[])}}}function eg(e,t){let n=-1;const s=[];for(;++n<t.length;)(t[n].add==="after"?e:s).push(t[n]);at(e,0,0,s)}function ic(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function nn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const it=zt(/[A-Za-z]/),$e=zt(/[\dA-Za-z]/),tg=zt(/[#-'*+\--9=?A-Z^-~]/);function Si(e){return e!==null&&(e<32||e===127)}const vi=zt(/\d/),ng=zt(/[\dA-Fa-f]/),sg=zt(/[!-/:-@[-`{-~]/);function ee(e){return e!==null&&e<-2}function Oe(e){return e!==null&&(e<0||e===32)}function ce(e){return e===-2||e===-1||e===32}const rg=zt(/\p{P}|\p{S}/u),ig=zt(/\s/);function zt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function on(e){const t=[];let n=-1,s=0,r=0;for(;++n<e.length;){const i=e.charCodeAt(n);let o="";if(i===37&&$e(e.charCodeAt(n+1))&&$e(e.charCodeAt(n+2)))r=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(o=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(o=String.fromCharCode(i,l),r=1):o="�"}else o=String.fromCharCode(i);o&&(t.push(e.slice(s,n),encodeURIComponent(o)),s=n+r+1,o=""),r&&(n+=r,r=0)}return t.join("")+e.slice(s)}function fe(e,t,n,s){const r=s?s-1:Number.POSITIVE_INFINITY;let i=0;return o;function o(c){return ce(c)?(e.enter(n),l(c)):t(c)}function l(c){return ce(c)&&i++<r?(e.consume(c),l):(e.exit(n),t(c))}}const og={tokenize:ag};function ag(e){const t=e.attempt(this.parser.constructs.contentInitial,s,r);let n;return t;function s(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),fe(e,t,"linePrefix")}function r(l){return e.enter("paragraph"),i(l)}function i(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,o(l)}function o(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return ee(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),o)}}const lg={tokenize:cg},ka={tokenize:ug};function cg(e){const t=this,n=[];let s=0,r,i,o;return l;function l(S){if(s<n.length){const E=n[s];return t.containerState=E[1],e.attempt(E[0].continuation,c,u)(S)}return u(S)}function c(S){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&N();const E=t.events.length;let I=E,k;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){k=t.events[I][1].end;break}w(s);let z=E;for(;z<t.events.length;)t.events[z][1].end={...k},z++;return at(t.events,I+1,0,t.events.slice(E)),t.events.length=z,u(S)}return l(S)}function u(S){if(s===n.length){if(!r)return m(S);if(r.currentConstruct&&r.currentConstruct.concrete)return g(S);t.interrupt=!!(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ka,d,h)(S)}function d(S){return r&&N(),w(s),m(S)}function h(S){return t.parser.lazy[t.now().line]=s!==n.length,o=t.now().offset,g(S)}function m(S){return t.containerState={},e.attempt(ka,f,g)(S)}function f(S){return s++,n.push([t.currentConstruct,t.containerState]),m(S)}function g(S){if(S===null){r&&N(),w(0),e.consume(S);return}return r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:i}),y(S)}function y(S){if(S===null){C(e.exit("chunkFlow"),!0),w(0),e.consume(S);return}return ee(S)?(e.consume(S),C(e.exit("chunkFlow")),s=0,t.interrupt=void 0,l):(e.consume(S),y)}function C(S,E){const I=t.sliceStream(S);if(E&&I.push(null),S.previous=i,i&&(i.next=S),i=S,r.defineSkip(S.start),r.write(I),t.parser.lazy[S.start.line]){let k=r.events.length;for(;k--;)if(r.events[k][1].start.offset<o&&(!r.events[k][1].end||r.events[k][1].end.offset>o))return;const z=t.events.length;let D=z,F,_;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){if(F){_=t.events[D][1].end;break}F=!0}for(w(s),k=z;k<t.events.length;)t.events[k][1].end={..._},k++;at(t.events,D+1,0,t.events.slice(z)),t.events.length=k}}function w(S){let E=n.length;for(;E-- >S;){const I=n[E];t.containerState=I[1],I[0].exit.call(t,e)}n.length=S}function N(){r.write([null]),i=void 0,r=void 0,t.containerState._closeFlow=void 0}}function ug(e,t,n){return fe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ea(e){if(e===null||Oe(e)||ig(e))return 1;if(rg(e))return 2}function Ki(e,t,n){const s=[];let r=-1;for(;++r<e.length;){const i=e[r].resolveAll;i&&!s.includes(i)&&(t=i(t,n),s.push(i))}return t}const Ci={name:"attention",resolveAll:dg,tokenize:hg};function dg(e,t){let n=-1,s,r,i,o,l,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(s=n;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[s][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[s][1].end.offset-e[s][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[s][1].end},m={...e[n][1].start};ja(h,-c),ja(m,c),o={type:c>1?"strongSequence":"emphasisSequence",start:h,end:{...e[s][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},i={type:c>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},r={type:c>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[s][1].end={...o.start},e[n][1].start={...l.end},u=[],e[s][1].end.offset-e[s][1].start.offset&&(u=Ge(u,[["enter",e[s][1],t],["exit",e[s][1],t]])),u=Ge(u,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",i,t]]),u=Ge(u,Ki(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),u=Ge(u,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",r,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Ge(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,at(e,s-1,n-s+3,u),n=s+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function hg(e,t){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,r=Ea(s);let i;return o;function o(c){return i=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===i)return e.consume(c),l;const u=e.exit("attentionSequence"),d=Ea(c),h=!d||d===2&&r||n.includes(c),m=!r||r===2&&d||n.includes(s);return u._open=!!(i===42?h:h&&(r||!m)),u._close=!!(i===42?m:m&&(d||!h)),t(c)}}function ja(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const fg={name:"autolink",tokenize:pg};function pg(e,t,n){let s=0;return r;function r(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(f){return it(f)?(e.consume(f),o):f===64?n(f):u(f)}function o(f){return f===43||f===45||f===46||$e(f)?(s=1,l(f)):u(f)}function l(f){return f===58?(e.consume(f),s=0,c):(f===43||f===45||f===46||$e(f))&&s++<32?(e.consume(f),l):(s=0,u(f))}function c(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||Si(f)?n(f):(e.consume(f),c)}function u(f){return f===64?(e.consume(f),d):tg(f)?(e.consume(f),u):n(f)}function d(f){return $e(f)?h(f):n(f)}function h(f){return f===46?(e.consume(f),s=0,d):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):m(f)}function m(f){if((f===45||$e(f))&&s++<63){const g=f===45?m:h;return e.consume(f),g}return n(f)}}const zs={partial:!0,tokenize:mg};function mg(e,t,n){return s;function s(i){return ce(i)?fe(e,r,"linePrefix")(i):r(i)}function r(i){return i===null||ee(i)?t(i):n(i)}}const oc={continuation:{tokenize:xg},exit:yg,name:"blockQuote",tokenize:gg};function gg(e,t,n){const s=this;return r;function r(o){if(o===62){const l=s.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),i}return n(o)}function i(o){return ce(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function xg(e,t,n){const s=this;return r;function r(o){return ce(o)?fe(e,i,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):i(o)}function i(o){return e.attempt(oc,t,n)(o)}}function yg(e){e.exit("blockQuote")}const ac={name:"characterEscape",tokenize:bg};function bg(e,t,n){return s;function s(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),r}function r(i){return sg(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const lc={name:"characterReference",tokenize:wg};function wg(e,t,n){const s=this;let r=0,i,o;return l;function l(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),c}function c(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),i=31,o=$e,d(h))}function u(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,o=ng,d):(e.enter("characterReferenceValue"),i=7,o=vi,d(h))}function d(h){if(h===59&&r){const m=e.exit("characterReferenceValue");return o===$e&&!Yi(s.sliceSerialize(m))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(h)&&r++<i?(e.consume(h),d):n(h)}}const Na={partial:!0,tokenize:vg},Pa={concrete:!0,name:"codeFenced",tokenize:Sg};function Sg(e,t,n){const s=this,r={partial:!0,tokenize:I};let i=0,o=0,l;return c;function c(k){return u(k)}function u(k){const z=s.events[s.events.length-1];return i=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[1],!0).length:0,l=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(k)}function d(k){return k===l?(o++,e.consume(k),d):o<3?n(k):(e.exit("codeFencedFenceSequence"),ce(k)?fe(e,h,"whitespace")(k):h(k))}function h(k){return k===null||ee(k)?(e.exit("codeFencedFence"),s.interrupt?t(k):e.check(Na,y,E)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||ee(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(k)):ce(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),fe(e,f,"whitespace")(k)):k===96&&k===l?n(k):(e.consume(k),m)}function f(k){return k===null||ee(k)?h(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(k))}function g(k){return k===null||ee(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(k)):k===96&&k===l?n(k):(e.consume(k),g)}function y(k){return e.attempt(r,E,C)(k)}function C(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),w}function w(k){return i>0&&ce(k)?fe(e,N,"linePrefix",i+1)(k):N(k)}function N(k){return k===null||ee(k)?e.check(Na,y,E)(k):(e.enter("codeFlowValue"),S(k))}function S(k){return k===null||ee(k)?(e.exit("codeFlowValue"),N(k)):(e.consume(k),S)}function E(k){return e.exit("codeFenced"),t(k)}function I(k,z,D){let F=0;return _;function _(P){return k.enter("lineEnding"),k.consume(P),k.exit("lineEnding"),A}function A(P){return k.enter("codeFencedFence"),ce(P)?fe(k,L,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):L(P)}function L(P){return P===l?(k.enter("codeFencedFenceSequence"),O(P)):D(P)}function O(P){return P===l?(F++,k.consume(P),O):F>=o?(k.exit("codeFencedFenceSequence"),ce(P)?fe(k,R,"whitespace")(P):R(P)):D(P)}function R(P){return P===null||ee(P)?(k.exit("codeFencedFence"),z(P)):D(P)}}}function vg(e,t,n){const s=this;return r;function r(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i)}function i(o){return s.parser.lazy[s.now().line]?n(o):t(o)}}const Hr={name:"codeIndented",tokenize:kg},Cg={partial:!0,tokenize:Eg};function kg(e,t,n){const s=this;return r;function r(u){return e.enter("codeIndented"),fe(e,i,"linePrefix",5)(u)}function i(u){const d=s.events[s.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?c(u):ee(u)?e.attempt(Cg,o,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||ee(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function Eg(e,t,n){const s=this;return r;function r(o){return s.parser.lazy[s.now().line]?n(o):ee(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),r):fe(e,i,"linePrefix",5)(o)}function i(o){const l=s.events[s.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):ee(o)?r(o):n(o)}}const jg={name:"codeText",previous:Pg,resolve:Ng,tokenize:Tg};function Ng(e){let t=e.length-4,n=3,s,r;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s<t;)if(e[s][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(s=n-1,t++;++s<=t;)r===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(r=s):(s===t||e[s][1].type==="lineEnding")&&(e[r][1].type="codeTextData",s!==r+2&&(e[r][1].end=e[s-1][1].end,e.splice(r+2,s-r-2),t-=s-r-2,s=r+2),r=void 0);return e}function Pg(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Tg(e,t,n){let s=0,r,i;return o;function o(h){return e.enter("codeText"),e.enter("codeTextSequence"),l(h)}function l(h){return h===96?(e.consume(h),s++,l):(e.exit("codeTextSequence"),c(h))}function c(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),c):h===96?(i=e.enter("codeTextSequence"),r=0,d(h)):ee(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(h))}function u(h){return h===null||h===32||h===96||ee(h)?(e.exit("codeTextData"),c(h)):(e.consume(h),u)}function d(h){return h===96?(e.consume(h),r++,d):r===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(i.type="codeTextData",u(h))}}class Ig{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const s=n??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const r=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return s&&wn(this.left,s),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),wn(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),wn(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);wn(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);wn(this.left,n.reverse())}}}function wn(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function cc(e){const t={};let n=-1,s,r,i,o,l,c,u;const d=new Ig(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(s=d.get(n),n&&s[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=s[1]._tokenizer.events,i=0,i<c.length&&c[i][1].type==="lineEndingBlank"&&(i+=2),i<c.length&&c[i][1].type==="content"))for(;++i<c.length&&c[i][1].type!=="content";)c[i][1].type==="chunkText"&&(c[i][1]._isInFirstContentOfListItem=!0,i++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,Ag(d,n)),n=t[n],u=!0);else if(s[1]._container){for(i=n,r=void 0;i--;)if(o=d.get(i),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(r&&(d.get(r)[1].type="lineEndingBlank"),o[1].type="lineEnding",r=i);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;r&&(s[1].end={...d.get(r)[1].start},l=d.slice(r,n),l.unshift(s),d.splice(r,n-r+1,l))}}return at(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function Ag(e,t){const n=e.get(t)[1],s=e.get(t)[2];let r=t-1;const i=[];let o=n._tokenizer;o||(o=s.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const l=o.events,c=[],u={};let d,h,m=-1,f=n,g=0,y=0;const C=[y];for(;f;){for(;e.get(++r)[1]!==f;);i.push(r),f._tokenizer||(d=s.sliceStream(f),f.next||d.push(null),h&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),h=f,f=f.next}for(f=n;++m<l.length;)l[m][0]==="exit"&&l[m-1][0]==="enter"&&l[m][1].type===l[m-1][1].type&&l[m][1].start.line!==l[m][1].end.line&&(y=m+1,C.push(y),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):C.pop(),m=C.length;m--;){const w=l.slice(C[m],C[m+1]),N=i.pop();c.push([N,N+w.length-1]),e.splice(N,2,w)}for(c.reverse(),m=-1;++m<c.length;)u[g+c[m][0]]=g+c[m][1],g+=c[m][1]-c[m][0]-1;return u}const zg={resolve:Lg,tokenize:Rg},_g={partial:!0,tokenize:Mg};function Lg(e){return cc(e),e}function Rg(e,t){let n;return s;function s(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(l)}function r(l){return l===null?i(l):ee(l)?e.check(_g,o,i)(l):(e.consume(l),r)}function i(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function o(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}function Mg(e,t,n){const s=this;return r;function r(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),fe(e,i,"linePrefix")}function i(o){if(o===null||ee(o))return n(o);const l=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):e.interrupt(s.parser.constructs.flow,n,t)(o)}}function uc(e,t,n,s,r,i,o,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return h;function h(w){return w===60?(e.enter(s),e.enter(r),e.enter(i),e.consume(w),e.exit(i),m):w===null||w===32||w===41||Si(w)?n(w):(e.enter(s),e.enter(o),e.enter(l),e.enter("chunkString",{contentType:"string"}),y(w))}function m(w){return w===62?(e.enter(i),e.consume(w),e.exit(i),e.exit(r),e.exit(s),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),f(w))}function f(w){return w===62?(e.exit("chunkString"),e.exit(l),m(w)):w===null||w===60||ee(w)?n(w):(e.consume(w),w===92?g:f)}function g(w){return w===60||w===62||w===92?(e.consume(w),f):f(w)}function y(w){return!d&&(w===null||w===41||Oe(w))?(e.exit("chunkString"),e.exit(l),e.exit(o),e.exit(s),t(w)):d<u&&w===40?(e.consume(w),d++,y):w===41?(e.consume(w),d--,y):w===null||w===32||w===40||Si(w)?n(w):(e.consume(w),w===92?C:y)}function C(w){return w===40||w===41||w===92?(e.consume(w),y):y(w)}}function dc(e,t,n,s,r,i){const o=this;let l=0,c;return u;function u(f){return e.enter(s),e.enter(r),e.consume(f),e.exit(r),e.enter(i),d}function d(f){return l>999||f===null||f===91||f===93&&!c||f===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?n(f):f===93?(e.exit(i),e.enter(r),e.consume(f),e.exit(r),e.exit(s),t):ee(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),h(f))}function h(f){return f===null||f===91||f===93||ee(f)||l++>999?(e.exit("chunkString"),d(f)):(e.consume(f),c||(c=!ce(f)),f===92?m:h)}function m(f){return f===91||f===92||f===93?(e.consume(f),l++,h):h(f)}}function hc(e,t,n,s,r,i){let o;return l;function l(m){return m===34||m===39||m===40?(e.enter(s),e.enter(r),e.consume(m),e.exit(r),o=m===40?41:m,c):n(m)}function c(m){return m===o?(e.enter(r),e.consume(m),e.exit(r),e.exit(s),t):(e.enter(i),u(m))}function u(m){return m===o?(e.exit(i),c(o)):m===null?n(m):ee(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),fe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(m))}function d(m){return m===o||m===null||ee(m)?(e.exit("chunkString"),u(m)):(e.consume(m),m===92?h:d)}function h(m){return m===o||m===92?(e.consume(m),d):d(m)}}function Nn(e,t){let n;return s;function s(r){return ee(r)?(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,s):ce(r)?fe(e,s,n?"linePrefix":"lineSuffix")(r):t(r)}}const Og={name:"definition",tokenize:Fg},Dg={partial:!0,tokenize:Bg};function Fg(e,t,n){const s=this;let r;return i;function i(f){return e.enter("definition"),o(f)}function o(f){return dc.call(s,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function l(f){return r=nn(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),c):n(f)}function c(f){return Oe(f)?Nn(e,u)(f):u(f)}function u(f){return uc(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function d(f){return e.attempt(Dg,h,h)(f)}function h(f){return ce(f)?fe(e,m,"whitespace")(f):m(f)}function m(f){return f===null||ee(f)?(e.exit("definition"),s.parser.defined.push(r),t(f)):n(f)}}function Bg(e,t,n){return s;function s(l){return Oe(l)?Nn(e,r)(l):n(l)}function r(l){return hc(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return ce(l)?fe(e,o,"whitespace")(l):o(l)}function o(l){return l===null||ee(l)?t(l):n(l)}}const $g={name:"hardBreakEscape",tokenize:Vg};function Vg(e,t,n){return s;function s(i){return e.enter("hardBreakEscape"),e.consume(i),r}function r(i){return ee(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const Ug={name:"headingAtx",resolve:Hg,tokenize:qg};function Hg(e,t){let n=e.length-2,s=3,r,i;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(r={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},i={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},at(e,s,n-s+1,[["enter",r,t],["enter",i,t],["exit",i,t],["exit",r,t]])),e}function qg(e,t,n){let s=0;return r;function r(d){return e.enter("atxHeading"),i(d)}function i(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&s++<6?(e.consume(d),o):d===null||Oe(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||ee(d)?(e.exit("atxHeading"),t(d)):ce(d)?fe(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||Oe(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const Wg=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Ta=["pre","script","style","textarea"],Gg={concrete:!0,name:"htmlFlow",resolveTo:Zg,tokenize:Yg},Qg={partial:!0,tokenize:Xg},Jg={partial:!0,tokenize:Kg};function Zg(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Yg(e,t,n){const s=this;let r,i,o,l,c;return u;function u(b){return d(b)}function d(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),h}function h(b){return b===33?(e.consume(b),m):b===47?(e.consume(b),i=!0,y):b===63?(e.consume(b),r=3,s.interrupt?t:x):it(b)?(e.consume(b),o=String.fromCharCode(b),C):n(b)}function m(b){return b===45?(e.consume(b),r=2,f):b===91?(e.consume(b),r=5,l=0,g):it(b)?(e.consume(b),r=4,s.interrupt?t:x):n(b)}function f(b){return b===45?(e.consume(b),s.interrupt?t:x):n(b)}function g(b){const J="CDATA[";return b===J.charCodeAt(l++)?(e.consume(b),l===J.length?s.interrupt?t:L:g):n(b)}function y(b){return it(b)?(e.consume(b),o=String.fromCharCode(b),C):n(b)}function C(b){if(b===null||b===47||b===62||Oe(b)){const J=b===47,U=o.toLowerCase();return!J&&!i&&Ta.includes(U)?(r=1,s.interrupt?t(b):L(b)):Wg.includes(o.toLowerCase())?(r=6,J?(e.consume(b),w):s.interrupt?t(b):L(b)):(r=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(b):i?N(b):S(b))}return b===45||$e(b)?(e.consume(b),o+=String.fromCharCode(b),C):n(b)}function w(b){return b===62?(e.consume(b),s.interrupt?t:L):n(b)}function N(b){return ce(b)?(e.consume(b),N):_(b)}function S(b){return b===47?(e.consume(b),_):b===58||b===95||it(b)?(e.consume(b),E):ce(b)?(e.consume(b),S):_(b)}function E(b){return b===45||b===46||b===58||b===95||$e(b)?(e.consume(b),E):I(b)}function I(b){return b===61?(e.consume(b),k):ce(b)?(e.consume(b),I):S(b)}function k(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),c=b,z):ce(b)?(e.consume(b),k):D(b)}function z(b){return b===c?(e.consume(b),c=null,F):b===null||ee(b)?n(b):(e.consume(b),z)}function D(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||Oe(b)?I(b):(e.consume(b),D)}function F(b){return b===47||b===62||ce(b)?S(b):n(b)}function _(b){return b===62?(e.consume(b),A):n(b)}function A(b){return b===null||ee(b)?L(b):ce(b)?(e.consume(b),A):n(b)}function L(b){return b===45&&r===2?(e.consume(b),T):b===60&&r===1?(e.consume(b),W):b===62&&r===4?(e.consume(b),oe):b===63&&r===3?(e.consume(b),x):b===93&&r===5?(e.consume(b),$):ee(b)&&(r===6||r===7)?(e.exit("htmlFlowData"),e.check(Qg,pe,O)(b)):b===null||ee(b)?(e.exit("htmlFlowData"),O(b)):(e.consume(b),L)}function O(b){return e.check(Jg,R,pe)(b)}function R(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),P}function P(b){return b===null||ee(b)?O(b):(e.enter("htmlFlowData"),L(b))}function T(b){return b===45?(e.consume(b),x):L(b)}function W(b){return b===47?(e.consume(b),o="",j):L(b)}function j(b){if(b===62){const J=o.toLowerCase();return Ta.includes(J)?(e.consume(b),oe):L(b)}return it(b)&&o.length<8?(e.consume(b),o+=String.fromCharCode(b),j):L(b)}function $(b){return b===93?(e.consume(b),x):L(b)}function x(b){return b===62?(e.consume(b),oe):b===45&&r===2?(e.consume(b),x):L(b)}function oe(b){return b===null||ee(b)?(e.exit("htmlFlowData"),pe(b)):(e.consume(b),oe)}function pe(b){return e.exit("htmlFlow"),t(b)}}function Kg(e,t,n){const s=this;return r;function r(o){return ee(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):n(o)}function i(o){return s.parser.lazy[s.now().line]?n(o):t(o)}}function Xg(e,t,n){return s;function s(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(zs,t,n)}}const ex={name:"htmlText",tokenize:tx};function tx(e,t,n){const s=this;let r,i,o;return l;function l(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),c}function c(x){return x===33?(e.consume(x),u):x===47?(e.consume(x),I):x===63?(e.consume(x),S):it(x)?(e.consume(x),D):n(x)}function u(x){return x===45?(e.consume(x),d):x===91?(e.consume(x),i=0,g):it(x)?(e.consume(x),N):n(x)}function d(x){return x===45?(e.consume(x),f):n(x)}function h(x){return x===null?n(x):x===45?(e.consume(x),m):ee(x)?(o=h,W(x)):(e.consume(x),h)}function m(x){return x===45?(e.consume(x),f):h(x)}function f(x){return x===62?T(x):x===45?m(x):h(x)}function g(x){const oe="CDATA[";return x===oe.charCodeAt(i++)?(e.consume(x),i===oe.length?y:g):n(x)}function y(x){return x===null?n(x):x===93?(e.consume(x),C):ee(x)?(o=y,W(x)):(e.consume(x),y)}function C(x){return x===93?(e.consume(x),w):y(x)}function w(x){return x===62?T(x):x===93?(e.consume(x),w):y(x)}function N(x){return x===null||x===62?T(x):ee(x)?(o=N,W(x)):(e.consume(x),N)}function S(x){return x===null?n(x):x===63?(e.consume(x),E):ee(x)?(o=S,W(x)):(e.consume(x),S)}function E(x){return x===62?T(x):S(x)}function I(x){return it(x)?(e.consume(x),k):n(x)}function k(x){return x===45||$e(x)?(e.consume(x),k):z(x)}function z(x){return ee(x)?(o=z,W(x)):ce(x)?(e.consume(x),z):T(x)}function D(x){return x===45||$e(x)?(e.consume(x),D):x===47||x===62||Oe(x)?F(x):n(x)}function F(x){return x===47?(e.consume(x),T):x===58||x===95||it(x)?(e.consume(x),_):ee(x)?(o=F,W(x)):ce(x)?(e.consume(x),F):T(x)}function _(x){return x===45||x===46||x===58||x===95||$e(x)?(e.consume(x),_):A(x)}function A(x){return x===61?(e.consume(x),L):ee(x)?(o=A,W(x)):ce(x)?(e.consume(x),A):F(x)}function L(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),r=x,O):ee(x)?(o=L,W(x)):ce(x)?(e.consume(x),L):(e.consume(x),R)}function O(x){return x===r?(e.consume(x),r=void 0,P):x===null?n(x):ee(x)?(o=O,W(x)):(e.consume(x),O)}function R(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||Oe(x)?F(x):(e.consume(x),R)}function P(x){return x===47||x===62||Oe(x)?F(x):n(x)}function T(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function W(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),j}function j(x){return ce(x)?fe(e,$,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):$(x)}function $(x){return e.enter("htmlTextData"),o(x)}}const Xi={name:"labelEnd",resolveAll:ix,resolveTo:ox,tokenize:ax},nx={tokenize:lx},sx={tokenize:cx},rx={tokenize:ux};function ix(e){let t=-1;const n=[];for(;++t<e.length;){const s=e[t][1];if(n.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const r=s.type==="labelImage"?4:2;s.type="data",t+=r}}return e.length!==n.length&&at(e,0,e.length,n),e}function ox(e,t){let n=e.length,s=0,r,i,o,l;for(;n--;)if(r=e[n][1],i){if(r.type==="link"||r.type==="labelLink"&&r._inactive)break;e[n][0]==="enter"&&r.type==="labelLink"&&(r._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(r.type==="labelImage"||r.type==="labelLink")&&!r._balanced&&(i=n,r.type!=="labelLink")){s=2;break}}else r.type==="labelEnd"&&(o=n);const c={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[i][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[i+s+2][1].end},end:{...e[o-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=Ge(l,e.slice(i+1,i+s+3)),l=Ge(l,[["enter",d,t]]),l=Ge(l,Ki(t.parser.constructs.insideSpan.null,e.slice(i+s+4,o-3),t)),l=Ge(l,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),l=Ge(l,e.slice(o+1)),l=Ge(l,[["exit",c,t]]),at(e,i,e.length,l),e}function ax(e,t,n){const s=this;let r=s.events.length,i,o;for(;r--;)if((s.events[r][1].type==="labelImage"||s.events[r][1].type==="labelLink")&&!s.events[r][1]._balanced){i=s.events[r][1];break}return l;function l(m){return i?i._inactive?h(m):(o=s.parser.defined.includes(nn(s.sliceSerialize({start:i.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),c):n(m)}function c(m){return m===40?e.attempt(nx,d,o?d:h)(m):m===91?e.attempt(sx,d,o?u:h)(m):o?d(m):h(m)}function u(m){return e.attempt(rx,d,h)(m)}function d(m){return t(m)}function h(m){return i._balanced=!0,n(m)}}function lx(e,t,n){return s;function s(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),r}function r(h){return Oe(h)?Nn(e,i)(h):i(h)}function i(h){return h===41?d(h):uc(e,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function o(h){return Oe(h)?Nn(e,c)(h):d(h)}function l(h){return n(h)}function c(h){return h===34||h===39||h===40?hc(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):d(h)}function u(h){return Oe(h)?Nn(e,d)(h):d(h)}function d(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function cx(e,t,n){const s=this;return r;function r(l){return dc.call(s,e,i,o,"reference","referenceMarker","referenceString")(l)}function i(l){return s.parser.defined.includes(nn(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function o(l){return n(l)}}function ux(e,t,n){return s;function s(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),r}function r(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const dx={name:"labelStartImage",resolveAll:Xi.resolveAll,tokenize:hx};function hx(e,t,n){const s=this;return r;function r(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),o):n(l)}function o(l){return l===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(l):t(l)}}const fx={name:"labelStartLink",resolveAll:Xi.resolveAll,tokenize:px};function px(e,t,n){const s=this;return r;function r(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),i}function i(o){return o===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(o):t(o)}}const qr={name:"lineEnding",tokenize:mx};function mx(e,t){return n;function n(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),fe(e,t,"linePrefix")}}const hs={name:"thematicBreak",tokenize:gx};function gx(e,t,n){let s=0,r;return i;function i(u){return e.enter("thematicBreak"),o(u)}function o(u){return r=u,l(u)}function l(u){return u===r?(e.enter("thematicBreakSequence"),c(u)):s>=3&&(u===null||ee(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===r?(e.consume(u),s++,c):(e.exit("thematicBreakSequence"),ce(u)?fe(e,l,"whitespace")(u):l(u))}}const Me={continuation:{tokenize:wx},exit:vx,name:"list",tokenize:bx},xx={partial:!0,tokenize:Cx},yx={partial:!0,tokenize:Sx};function bx(e,t,n){const s=this,r=s.events[s.events.length-1];let i=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,o=0;return l;function l(f){const g=s.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!s.containerState.marker||f===s.containerState.marker:vi(f)){if(s.containerState.type||(s.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(hs,n,u)(f):u(f);if(!s.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(f)}return n(f)}function c(f){return vi(f)&&++o<10?(e.consume(f),c):(!s.interrupt||o<2)&&(s.containerState.marker?f===s.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),u(f)):n(f)}function u(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||f,e.check(zs,s.interrupt?n:d,e.attempt(xx,m,h))}function d(f){return s.containerState.initialBlankLine=!0,i++,m(f)}function h(f){return ce(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),m):n(f)}function m(f){return s.containerState.size=i+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function wx(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(zs,r,i);function r(l){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,fe(e,t,"listItemIndent",s.containerState.size+1)(l)}function i(l){return s.containerState.furtherBlankLines||!ce(l)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,o(l)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(yx,t,o)(l))}function o(l){return s.containerState._closeFlow=!0,s.interrupt=void 0,fe(e,e.attempt(Me,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Sx(e,t,n){const s=this;return fe(e,r,"listItemIndent",s.containerState.size+1);function r(i){const o=s.events[s.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===s.containerState.size?t(i):n(i)}}function vx(e){e.exit(this.containerState.type)}function Cx(e,t,n){const s=this;return fe(e,r,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function r(i){const o=s.events[s.events.length-1];return!ce(i)&&o&&o[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const Ia={name:"setextUnderline",resolveTo:kx,tokenize:Ex};function kx(e,t){let n=e.length,s,r,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(r=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const o={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",o,t]),e.splice(i+1,0,["exit",e[s][1],t]),e[s][1].end={...e[i][1].end}):e[s][1]=o,e.push(["exit",o,t]),e}function Ex(e,t,n){const s=this;let r;return i;function i(u){let d=s.events.length,h;for(;d--;)if(s.events[d][1].type!=="lineEnding"&&s.events[d][1].type!=="linePrefix"&&s.events[d][1].type!=="content"){h=s.events[d][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||h)?(e.enter("setextHeadingLine"),r=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===r?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),ce(u)?fe(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||ee(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const jx={tokenize:Nx};function Nx(e){const t=this,n=e.attempt(zs,s,e.attempt(this.parser.constructs.flowInitial,r,fe(e,e.attempt(this.parser.constructs.flow,r,e.attempt(zg,r)),"linePrefix")));return n;function s(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function r(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Px={resolveAll:pc()},Tx=fc("string"),Ix=fc("text");function fc(e){return{resolveAll:pc(e==="text"?Ax:void 0),tokenize:t};function t(n){const s=this,r=this.parser.constructs[e],i=n.attempt(r,o,l);return o;function o(d){return u(d)?i(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),i(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const h=r[d];let m=-1;if(h)for(;++m<h.length;){const f=h[m];if(!f.previous||f.previous.call(s,s.previous))return!0}return!1}}}function pc(e){return t;function t(n,s){let r=-1,i;for(;++r<=n.length;)i===void 0?n[r]&&n[r][1].type==="data"&&(i=r,r++):(!n[r]||n[r][1].type!=="data")&&(r!==i+2&&(n[i][1].end=n[r-1][1].end,n.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(n,s):n}}function Ax(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],r=t.sliceStream(s);let i=r.length,o=-1,l=0,c;for(;i--;){const u=r[i];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)l++,o--;if(o)break;o=-1}else if(u===-2)c=!0,l++;else if(u!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:s.start._bufferIndex+o,_index:s.start._index+i,line:s.end.line,column:s.end.column-l,offset:s.end.offset-l},end:{...s.end}};s.end={...u.start},s.start.offset===s.end.offset?Object.assign(s,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const zx={42:Me,43:Me,45:Me,48:Me,49:Me,50:Me,51:Me,52:Me,53:Me,54:Me,55:Me,56:Me,57:Me,62:oc},_x={91:Og},Lx={[-2]:Hr,[-1]:Hr,32:Hr},Rx={35:Ug,42:hs,45:[Ia,hs],60:Gg,61:Ia,95:hs,96:Pa,126:Pa},Mx={38:lc,92:ac},Ox={[-5]:qr,[-4]:qr,[-3]:qr,33:dx,38:lc,42:Ci,60:[fg,ex],91:fx,92:[$g,ac],93:Xi,95:Ci,96:jg},Dx={null:[Ci,Px]},Fx={null:[42,95]},Bx={null:[]},$x=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Fx,contentInitial:_x,disable:Bx,document:zx,flow:Rx,flowInitial:Lx,insideSpan:Dx,string:Mx,text:Ox},Symbol.toStringTag,{value:"Module"}));function Vx(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},i=[];let o=[],l=[];const c={attempt:z(I),check:z(k),consume:N,enter:S,exit:E,interrupt:z(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:g,parser:e,previous:null,sliceSerialize:m,sliceStream:f,write:h};let d=t.tokenize.call(u,c);return t.resolveAll&&i.push(t),u;function h(A){return o=Ge(o,A),C(),o[o.length-1]!==null?[]:(D(t,0),u.events=Ki(i,u.events,u),u.events)}function m(A,L){return Hx(f(A),L)}function f(A){return Ux(o,A)}function g(){const{_bufferIndex:A,_index:L,line:O,column:R,offset:P}=s;return{_bufferIndex:A,_index:L,line:O,column:R,offset:P}}function y(A){r[A.line]=A.column,_()}function C(){let A;for(;s._index<o.length;){const L=o[s._index];if(typeof L=="string")for(A=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===A&&s._bufferIndex<L.length;)w(L.charCodeAt(s._bufferIndex));else w(L)}}function w(A){d=d(A)}function N(A){ee(A)?(s.line++,s.column=1,s.offset+=A===-3?2:1,_()):A!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===o[s._index].length&&(s._bufferIndex=-1,s._index++)),u.previous=A}function S(A,L){const O=L||{};return O.type=A,O.start=g(),u.events.push(["enter",O,u]),l.push(O),O}function E(A){const L=l.pop();return L.end=g(),u.events.push(["exit",L,u]),L}function I(A,L){D(A,L.from)}function k(A,L){L.restore()}function z(A,L){return O;function O(R,P,T){let W,j,$,x;return Array.isArray(R)?pe(R):"tokenize"in R?pe([R]):oe(R);function oe(Q){return re;function re(se){const we=se!==null&&Q[se],me=se!==null&&Q.null,le=[...Array.isArray(we)?we:we?[we]:[],...Array.isArray(me)?me:me?[me]:[]];return pe(le)(se)}}function pe(Q){return W=Q,j=0,Q.length===0?T:b(Q[j])}function b(Q){return re;function re(se){return x=F(),$=Q,Q.partial||(u.currentConstruct=Q),Q.name&&u.parser.constructs.disable.null.includes(Q.name)?U():Q.tokenize.call(L?Object.assign(Object.create(u),L):u,c,J,U)(se)}}function J(Q){return A($,x),P}function U(Q){return x.restore(),++j<W.length?b(W[j]):T}}}function D(A,L){A.resolveAll&&!i.includes(A)&&i.push(A),A.resolve&&at(u.events,L,u.events.length-L,A.resolve(u.events.slice(L),u)),A.resolveTo&&(u.events=A.resolveTo(u.events,u))}function F(){const A=g(),L=u.previous,O=u.currentConstruct,R=u.events.length,P=Array.from(l);return{from:R,restore:T};function T(){s=A,u.previous=L,u.currentConstruct=O,u.events.length=R,l=P,_()}}function _(){s.line in r&&s.column<2&&(s.column=r[s.line],s.offset+=r[s.line]-1)}}function Ux(e,t){const n=t.start._index,s=t.start._bufferIndex,r=t.end._index,i=t.end._bufferIndex;let o;if(n===r)o=[e[n].slice(s,i)];else{if(o=e.slice(n,r),s>-1){const l=o[0];typeof l=="string"?o[0]=l.slice(s):o.shift()}i>0&&o.push(e[r].slice(0,i))}return o}function Hx(e,t){let n=-1;const s=[];let r;for(;++n<e.length;){const i=e[n];let o;if(typeof i=="string")o=i;else switch(i){case-5:{o="\r";break}case-4:{o=`
|
|
14
|
+
`;break}case-3:{o=`\r
|
|
15
|
+
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&r)continue;o=" ";break}default:o=String.fromCharCode(i)}r=i===-2,s.push(o)}return s.join("")}function qx(e){const s={constructs:Km([$x,...(e||{}).extensions||[]]),content:r(og),defined:[],document:r(lg),flow:r(jx),lazy:{},string:r(Tx),text:r(Ix)};return s;function r(i){return o;function o(l){return Vx(s,i,l)}}}function Wx(e){for(;!cc(e););return e}const Aa=/[\0\t\n\r]/g;function Gx(){let e=1,t="",n=!0,s;return r;function r(i,o,l){const c=[];let u,d,h,m,f;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(o||void 0).decode(i)),h=0,t="",n&&(i.charCodeAt(0)===65279&&h++,n=void 0);h<i.length;){if(Aa.lastIndex=h,u=Aa.exec(i),m=u&&u.index!==void 0?u.index:i.length,f=i.charCodeAt(m),!u){t=i.slice(h);break}if(f===10&&h===m&&s)c.push(-3),s=void 0;else switch(s&&(c.push(-5),s=void 0),h<m&&(c.push(i.slice(h,m)),e+=m-h),f){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:s=!0,e=1}h=m+1}return l&&(s&&c.push(-5),t&&c.push(t),c.push(null)),c}}const Qx=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Jx(e){return e.replace(Qx,Zx)}function Zx(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const r=n.charCodeAt(1),i=r===120||r===88;return ic(n.slice(i?2:1),i?16:10)}return Yi(n)||e}const mc={}.hasOwnProperty;function Yx(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Kx(n)(Wx(qx(n).document().write(Gx()(e,t,!0))))}function Kx(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(te),autolinkProtocol:F,autolinkEmail:F,atxHeading:i(St),blockQuote:i(me),characterEscape:F,characterReference:F,codeFenced:i(le),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:i(le,o),codeText:i(Ve,o),codeTextData:F,data:F,codeFlowValue:F,definition:i(wt),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:i(Ft),hardBreakEscape:i(vt),hardBreakTrailing:i(vt),htmlFlow:i(_t,o),htmlFlowData:F,htmlText:i(_t,o),htmlTextData:F,image:i(Y),label:o,link:i(te),listItem:i(je),listItemValue:m,listOrdered:i(ae,h),listUnordered:i(ae),paragraph:i(Ue),reference:b,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:i(St),strong:i(He),thematicBreak:i(Ne)},exit:{atxHeading:c(),atxHeadingSequence:I,autolink:c(),autolinkEmail:we,autolinkProtocol:se,blockQuote:c(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:Q,characterReference:re,codeFenced:c(C),codeFencedFence:y,codeFencedFenceInfo:f,codeFencedFenceMeta:g,codeFlowValue:_,codeIndented:c(w),codeText:c(P),codeTextData:_,data:_,definition:c(),definitionDestinationString:E,definitionLabelString:N,definitionTitleString:S,emphasis:c(),hardBreakEscape:c(L),hardBreakTrailing:c(L),htmlFlow:c(O),htmlFlowData:_,htmlText:c(R),htmlTextData:_,image:c(W),label:$,labelText:j,lineEnding:A,link:c(T),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:J,resourceDestinationString:x,resourceTitleString:oe,resource:pe,setextHeading:c(D),setextHeadingLineSequence:z,setextHeadingText:k,strong:c(),thematicBreak:c()}};gc(t,(e||{}).mdastExtensions||[]);const n={};return s;function s(M){let H={type:"root",children:[]};const K={stack:[H],tokenStack:[],config:t,enter:l,exit:u,buffer:o,resume:d,data:n},Z=[];let X=-1;for(;++X<M.length;)if(M[X][1].type==="listOrdered"||M[X][1].type==="listUnordered")if(M[X][0]==="enter")Z.push(X);else{const Pe=Z.pop();X=r(M,Pe,X)}for(X=-1;++X<M.length;){const Pe=t[M[X][0]];mc.call(Pe,M[X][1].type)&&Pe[M[X][1].type].call(Object.assign({sliceSerialize:M[X][2].sliceSerialize},K),M[X][1])}if(K.tokenStack.length>0){const Pe=K.tokenStack[K.tokenStack.length-1];(Pe[1]||za).call(K,void 0,Pe[0])}for(H.position={start:Tt(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:Tt(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},X=-1;++X<t.transforms.length;)H=t.transforms[X](H)||H;return H}function r(M,H,K){let Z=H-1,X=-1,Pe=!1,Ze,Fe,tt,ut;for(;++Z<=K;){const ge=M[Z];switch(ge[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ge[0]==="enter"?X++:X--,ut=void 0;break}case"lineEndingBlank":{ge[0]==="enter"&&(Ze&&!ut&&!X&&!tt&&(tt=Z),ut=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ut=void 0}if(!X&&ge[0]==="enter"&&ge[1].type==="listItemPrefix"||X===-1&&ge[0]==="exit"&&(ge[1].type==="listUnordered"||ge[1].type==="listOrdered")){if(Ze){let nt=Z;for(Fe=void 0;nt--;){const _e=M[nt];if(_e[1].type==="lineEnding"||_e[1].type==="lineEndingBlank"){if(_e[0]==="exit")continue;Fe&&(M[Fe][1].type="lineEndingBlank",Pe=!0),_e[1].type="lineEnding",Fe=nt}else if(!(_e[1].type==="linePrefix"||_e[1].type==="blockQuotePrefix"||_e[1].type==="blockQuotePrefixWhitespace"||_e[1].type==="blockQuoteMarker"||_e[1].type==="listItemIndent"))break}tt&&(!Fe||tt<Fe)&&(Ze._spread=!0),Ze.end=Object.assign({},Fe?M[Fe][1].start:ge[1].end),M.splice(Fe||Z,0,["exit",Ze,ge[2]]),Z++,K++}if(ge[1].type==="listItemPrefix"){const nt={type:"listItem",_spread:!1,start:Object.assign({},ge[1].start),end:void 0};Ze=nt,M.splice(Z,0,["enter",nt,ge[2]]),Z++,K++,tt=void 0,ut=!0}}}return M[H][1]._spread=Pe,K}function i(M,H){return K;function K(Z){l.call(this,M(Z),Z),H&&H.call(this,Z)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(M,H,K){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([H,K||void 0]),M.position={start:Tt(H.start),end:void 0}}function c(M){return H;function H(K){M&&M.call(this,K),u.call(this,K)}}function u(M,H){const K=this.stack.pop(),Z=this.tokenStack.pop();if(Z)Z[0].type!==M.type&&(H?H.call(this,M,Z[0]):(Z[1]||za).call(this,M,Z[0]));else throw new Error("Cannot close `"+M.type+"` ("+jn({start:M.start,end:M.end})+"): it’s not open");K.position.end=Tt(M.end)}function d(){return Zm(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function m(M){if(this.data.expectingFirstListItemValue){const H=this.stack[this.stack.length-2];H.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function f(){const M=this.resume(),H=this.stack[this.stack.length-1];H.lang=M}function g(){const M=this.resume(),H=this.stack[this.stack.length-1];H.meta=M}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const M=this.resume(),H=this.stack[this.stack.length-1];H.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function w(){const M=this.resume(),H=this.stack[this.stack.length-1];H.value=M.replace(/(\r?\n|\r)$/g,"")}function N(M){const H=this.resume(),K=this.stack[this.stack.length-1];K.label=H,K.identifier=nn(this.sliceSerialize(M)).toLowerCase()}function S(){const M=this.resume(),H=this.stack[this.stack.length-1];H.title=M}function E(){const M=this.resume(),H=this.stack[this.stack.length-1];H.url=M}function I(M){const H=this.stack[this.stack.length-1];if(!H.depth){const K=this.sliceSerialize(M).length;H.depth=K}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function z(M){const H=this.stack[this.stack.length-1];H.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function D(){this.data.setextHeadingSlurpLineEnding=void 0}function F(M){const K=this.stack[this.stack.length-1].children;let Z=K[K.length-1];(!Z||Z.type!=="text")&&(Z=ct(),Z.position={start:Tt(M.start),end:void 0},K.push(Z)),this.stack.push(Z)}function _(M){const H=this.stack.pop();H.value+=this.sliceSerialize(M),H.position.end=Tt(M.end)}function A(M){const H=this.stack[this.stack.length-1];if(this.data.atHardBreak){const K=H.children[H.children.length-1];K.position.end=Tt(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(H.type)&&(F.call(this,M),_.call(this,M))}function L(){this.data.atHardBreak=!0}function O(){const M=this.resume(),H=this.stack[this.stack.length-1];H.value=M}function R(){const M=this.resume(),H=this.stack[this.stack.length-1];H.value=M}function P(){const M=this.resume(),H=this.stack[this.stack.length-1];H.value=M}function T(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const H=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=H,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function W(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const H=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=H,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function j(M){const H=this.sliceSerialize(M),K=this.stack[this.stack.length-2];K.label=Jx(H),K.identifier=nn(H).toLowerCase()}function $(){const M=this.stack[this.stack.length-1],H=this.resume(),K=this.stack[this.stack.length-1];if(this.data.inReference=!0,K.type==="link"){const Z=M.children;K.children=Z}else K.alt=H}function x(){const M=this.resume(),H=this.stack[this.stack.length-1];H.url=M}function oe(){const M=this.resume(),H=this.stack[this.stack.length-1];H.title=M}function pe(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function J(M){const H=this.resume(),K=this.stack[this.stack.length-1];K.label=H,K.identifier=nn(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function U(M){this.data.characterReferenceType=M.type}function Q(M){const H=this.sliceSerialize(M),K=this.data.characterReferenceType;let Z;K?(Z=ic(H,K==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Z=Yi(H);const X=this.stack[this.stack.length-1];X.value+=Z}function re(M){const H=this.stack.pop();H.position.end=Tt(M.end)}function se(M){_.call(this,M);const H=this.stack[this.stack.length-1];H.url=this.sliceSerialize(M)}function we(M){_.call(this,M);const H=this.stack[this.stack.length-1];H.url="mailto:"+this.sliceSerialize(M)}function me(){return{type:"blockquote",children:[]}}function le(){return{type:"code",lang:null,meta:null,value:""}}function Ve(){return{type:"inlineCode",value:""}}function wt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ft(){return{type:"emphasis",children:[]}}function St(){return{type:"heading",depth:0,children:[]}}function vt(){return{type:"break"}}function _t(){return{type:"html",value:""}}function Y(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ae(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function je(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function Ue(){return{type:"paragraph",children:[]}}function He(){return{type:"strong",children:[]}}function ct(){return{type:"text",value:""}}function Ne(){return{type:"thematicBreak"}}}function Tt(e){return{line:e.line,column:e.column,offset:e.offset}}function gc(e,t){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?gc(e,s):Xx(e,s)}}function Xx(e,t){let n;for(n in t)if(mc.call(t,n))switch(n){case"canContainEols":{const s=t[n];s&&e[n].push(...s);break}case"transforms":{const s=t[n];s&&e[n].push(...s);break}case"enter":case"exit":{const s=t[n];s&&Object.assign(e[n],s);break}}}function za(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+jn({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+jn({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+jn({start:t.start,end:t.end})+") is still open")}function ey(e){const t=this;t.parser=n;function n(s){return Yx(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function ty(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function ny(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
16
|
+
`}]}function sy(e,t){const n=t.value?t.value+`
|
|
17
|
+
`:"",s={},r=t.lang?t.lang.split(/\s+/):[];r.length>0&&(s.className=["language-"+r[0]]);let i={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function ry(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iy(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function oy(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),r=on(s.toLowerCase()),i=e.footnoteOrder.indexOf(s);let o,l=e.footnoteCounts.get(s);l===void 0?(l=0,e.footnoteOrder.push(s),o=e.footnoteOrder.length):o=i+1,l+=1,e.footnoteCounts.set(s,l);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function ay(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ly(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xc(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const r=e.all(t),i=r[0];i&&i.type==="text"?i.value="["+i.value:r.unshift({type:"text",value:"["});const o=r[r.length-1];return o&&o.type==="text"?o.value+=s:r.push({type:"text",value:s}),r}function cy(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xc(e,t);const r={src:on(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(r.title=s.title);const i={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,i),e.applyData(t,i)}function uy(e,t){const n={src:on(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function dy(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function hy(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return xc(e,t);const r={href:on(s.url||"")};s.title!==null&&s.title!==void 0&&(r.title=s.title);const i={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function fy(e,t){const n={href:on(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function py(e,t,n){const s=e.all(t),r=n?my(n):yc(t),i={},o=[];if(typeof t.checked=="boolean"){const d=s[0];let h;d&&d.type==="element"&&d.tagName==="p"?h=d:(h={type:"element",tagName:"p",properties:{},children:[]},s.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<s.length;){const d=s[l];(r||l!==0||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:`
|
|
18
|
+
`}),d.type==="element"&&d.tagName==="p"&&!r?o.push(...d.children):o.push(d)}const c=s[s.length-1];c&&(r||c.type!=="element"||c.tagName!=="p")&&o.push({type:"text",value:`
|
|
19
|
+
`});const u={type:"element",tagName:"li",properties:i,children:o};return e.patch(t,u),e.applyData(t,u)}function my(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let s=-1;for(;!t&&++s<n.length;)t=yc(n[s])}return t}function yc(e){const t=e.spread;return t??e.children.length>1}function gy(e,t){const n={},s=e.all(t);let r=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++r<s.length;){const o=s[r];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)}function xy(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yy(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function by(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wy(e,t){const n=e.all(t),s=n.shift(),r=[];if(s){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(t.children[0],o),r.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=Gi(t.children[1]),c=Kl(t.children[t.children.length-1]);l&&c&&(o.position={start:l,end:c}),r.push(o)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function Sy(e,t,n){const s=n?n.children:void 0,i=(s?s.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,l=o?o.length:t.children.length;let c=-1;const u=[];for(;++c<l;){const h=t.children[c],m={},f=o?o[c]:void 0;f&&(m.align=f);let g={type:"element",tagName:i,properties:m,children:[]};h&&(g.children=e.all(h),e.patch(h,g),g=e.applyData(h,g)),u.push(g)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function vy(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const _a=9,La=32;function Cy(e){const t=String(e),n=/\r?\n|\r/g;let s=n.exec(t),r=0;const i=[];for(;s;)i.push(Ra(t.slice(r,s.index),r>0,!0),s[0]),r=s.index+s[0].length,s=n.exec(t);return i.push(Ra(t.slice(r),r>0,!1)),i.join("")}function Ra(e,t,n){let s=0,r=e.length;if(t){let i=e.codePointAt(s);for(;i===_a||i===La;)s++,i=e.codePointAt(s)}if(n){let i=e.codePointAt(r-1);for(;i===_a||i===La;)r--,i=e.codePointAt(r-1)}return r>s?e.slice(s,r):""}function ky(e,t){const n={type:"text",value:Cy(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Ey(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const jy={blockquote:ty,break:ny,code:sy,delete:ry,emphasis:iy,footnoteReference:oy,heading:ay,html:ly,imageReference:cy,image:uy,inlineCode:dy,linkReference:hy,link:fy,listItem:py,list:gy,paragraph:xy,root:yy,strong:by,table:wy,tableCell:vy,tableRow:Sy,text:ky,thematicBreak:Ey,toml:Yn,yaml:Yn,definition:Yn,footnoteDefinition:Yn};function Yn(){}const bc=-1,_s=0,Pn=1,ks=2,eo=3,to=4,no=5,so=6,wc=7,Sc=8,Ny=typeof self=="object"?self:globalThis,Ma=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new Ny[e](t)},Py=(e,t)=>{const n=(r,i)=>(e.set(i,r),r),s=r=>{if(e.has(r))return e.get(r);const[i,o]=t[r];switch(i){case _s:case bc:return n(o,r);case Pn:{const l=n([],r);for(const c of o)l.push(s(c));return l}case ks:{const l=n({},r);for(const[c,u]of o)l[s(c)]=s(u);return l}case eo:return n(new Date(o),r);case to:{const{source:l,flags:c}=o;return n(new RegExp(l,c),r)}case no:{const l=n(new Map,r);for(const[c,u]of o)l.set(s(c),s(u));return l}case so:{const l=n(new Set,r);for(const c of o)l.add(s(c));return l}case wc:{const{name:l,message:c}=o;return n(Ma(l,c),r)}case Sc:return n(BigInt(o),r);case"BigInt":return n(Object(BigInt(o)),r);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:l}=new Uint8Array(o);return n(new DataView(l),o)}}return n(Ma(i,o),r)};return s},Oa=e=>Py(new Map,e)(0),Jt="",{toString:Ty}={},{keys:Iy}=Object,Sn=e=>{const t=typeof e;if(t!=="object"||!e)return[_s,t];const n=Ty.call(e).slice(8,-1);switch(n){case"Array":return[Pn,Jt];case"Object":return[ks,Jt];case"Date":return[eo,Jt];case"RegExp":return[to,Jt];case"Map":return[no,Jt];case"Set":return[so,Jt];case"DataView":return[Pn,n]}return n.includes("Array")?[Pn,n]:n.includes("Error")?[wc,n]:[ks,n]},Kn=([e,t])=>e===_s&&(t==="function"||t==="symbol"),Ay=(e,t,n,s)=>{const r=(o,l)=>{const c=s.push(o)-1;return n.set(l,c),c},i=o=>{if(n.has(o))return n.get(o);let[l,c]=Sn(o);switch(l){case _s:{let d=o;switch(c){case"bigint":l=Sc,d=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return r([bc],o)}return r([l,d],o)}case Pn:{if(c){let m=o;return c==="DataView"?m=new Uint8Array(o.buffer):c==="ArrayBuffer"&&(m=new Uint8Array(o)),r([c,[...m]],o)}const d=[],h=r([l,d],o);for(const m of o)d.push(i(m));return h}case ks:{if(c)switch(c){case"BigInt":return r([c,o.toString()],o);case"Boolean":case"Number":case"String":return r([c,o.valueOf()],o)}if(t&&"toJSON"in o)return i(o.toJSON());const d=[],h=r([l,d],o);for(const m of Iy(o))(e||!Kn(Sn(o[m])))&&d.push([i(m),i(o[m])]);return h}case eo:return r([l,o.toISOString()],o);case to:{const{source:d,flags:h}=o;return r([l,{source:d,flags:h}],o)}case no:{const d=[],h=r([l,d],o);for(const[m,f]of o)(e||!(Kn(Sn(m))||Kn(Sn(f))))&&d.push([i(m),i(f)]);return h}case so:{const d=[],h=r([l,d],o);for(const m of o)(e||!Kn(Sn(m)))&&d.push(i(m));return h}}const{message:u}=o;return r([l,{name:c,message:u}],o)};return i},Da=(e,{json:t,lossy:n}={})=>{const s=[];return Ay(!(t||n),!!t,new Map,s)(e),s},Es=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Oa(Da(e,t)):structuredClone(e):(e,t)=>Oa(Da(e,t));function zy(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function _y(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Ly(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||zy,s=e.options.footnoteBackLabel||_y,r=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const d=e.all(u),h=String(u.identifier).toUpperCase(),m=on(h.toLowerCase());let f=0;const g=[],y=e.footnoteCounts.get(h);for(;y!==void 0&&++f<=y;){g.length>0&&g.push({type:"text",value:" "});let N=typeof n=="string"?n:n(c,f);typeof N=="string"&&(N={type:"text",value:N}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+m+(f>1?"-"+f:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(c,f),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const C=d[d.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const N=C.children[C.children.length-1];N&&N.type==="text"?N.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...g)}else d.push(...g);const w={type:"element",tagName:"li",properties:{id:t+"fn-"+m},children:e.wrap(d,!0)};e.patch(u,w),l.push(w)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...Es(o),id:"footnote-label"},children:[{type:"text",value:r}]},{type:"text",value:`
|
|
20
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
|
|
21
|
+
`}]}}const vc=(function(e){if(e==null)return Dy;if(typeof e=="function")return Ls(e);if(typeof e=="object")return Array.isArray(e)?Ry(e):My(e);if(typeof e=="string")return Oy(e);throw new Error("Expected function, string, or object as test")});function Ry(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=vc(e[n]);return Ls(s);function s(...r){let i=-1;for(;++i<t.length;)if(t[i].apply(this,r))return!0;return!1}}function My(e){const t=e;return Ls(n);function n(s){const r=s;let i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Oy(e){return Ls(t);function t(n){return n&&n.type===e}}function Ls(e){return t;function t(n,s,r){return!!(Fy(n)&&e.call(this,n,typeof s=="number"?s:void 0,r||void 0))}}function Dy(){return!0}function Fy(e){return e!==null&&typeof e=="object"&&"type"in e}const Cc=[],By=!0,Fa=!1,$y="skip";function Vy(e,t,n,s){let r;typeof t=="function"&&typeof n!="function"?(s=n,n=t):r=t;const i=vc(r),o=s?-1:1;l(e,void 0,[])();function l(c,u,d){const h=c&&typeof c=="object"?c:{};if(typeof h.type=="string"){const f=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(m,"name",{value:"node ("+(c.type+(f?"<"+f+">":""))+")"})}return m;function m(){let f=Cc,g,y,C;if((!t||i(c,u,d[d.length-1]||void 0))&&(f=Uy(n(c,d)),f[0]===Fa))return f;if("children"in c&&c.children){const w=c;if(w.children&&f[0]!==$y)for(y=(s?w.children.length:-1)+o,C=d.concat(w);y>-1&&y<w.children.length;){const N=w.children[y];if(g=l(N,y,C)(),g[0]===Fa)return g;y=typeof g[1]=="number"?g[1]:y+o}}return f}}}function Uy(e){return Array.isArray(e)?e:typeof e=="number"?[By,e]:e==null?Cc:[e]}function kc(e,t,n,s){let r,i,o;typeof t=="function"&&typeof n!="function"?(i=void 0,o=t,r=n):(i=t,o=n,r=s),Vy(e,i,l,r);function l(c,u){const d=u[u.length-1],h=d?d.children.indexOf(c):void 0;return o(c,h,d)}}const ki={}.hasOwnProperty,Hy={};function qy(e,t){const n=t||Hy,s=new Map,r=new Map,i=new Map,o={...jy,...n.handlers},l={all:u,applyData:Gy,definitionById:s,footnoteById:r,footnoteCounts:i,footnoteOrder:[],handlers:o,one:c,options:n,patch:Wy,wrap:Jy};return kc(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const h=d.type==="definition"?s:r,m=String(d.identifier).toUpperCase();h.has(m)||h.set(m,d)}}),l;function c(d,h){const m=d.type,f=l.handlers[m];if(ki.call(l.handlers,m)&&f)return f(l,d,h);if(l.options.passThrough&&l.options.passThrough.includes(m)){if("children"in d){const{children:y,...C}=d,w=Es(C);return w.children=l.all(d),w}return Es(d)}return(l.options.unknownHandler||Qy)(l,d,h)}function u(d){const h=[];if("children"in d){const m=d.children;let f=-1;for(;++f<m.length;){const g=l.one(m[f],d);if(g){if(f&&m[f-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=Ba(g.value)),!Array.isArray(g)&&g.type==="element")){const y=g.children[0];y&&y.type==="text"&&(y.value=Ba(y.value))}Array.isArray(g)?h.push(...g):h.push(g)}}}return h}}function Wy(e,t){e.position&&(t.position=Pm(e))}function Gy(e,t){let n=t;if(e&&e.data){const s=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;if(typeof s=="string")if(n.type==="element")n.tagName=s;else{const o="children"in n?n.children:[n];n={type:"element",tagName:s,properties:{},children:o}}n.type==="element"&&i&&Object.assign(n.properties,Es(i)),"children"in n&&n.children&&r!==null&&r!==void 0&&(n.children=r)}return n}function Qy(e,t){const n=t.data||{},s="value"in t&&!(ki.call(n,"hProperties")||ki.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function Jy(e,t){const n=[];let s=-1;for(t&&n.push({type:"text",value:`
|
|
22
|
+
`});++s<e.length;)s&&n.push({type:"text",value:`
|
|
23
|
+
`}),n.push(e[s]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
24
|
+
`}),n}function Ba(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function $a(e,t){const n=qy(e,t),s=n.one(e,void 0),r=Ly(n),i=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return r&&i.children.push({type:"text",value:`
|
|
25
|
+
`},r),i}function Zy(e,t){return e&&"run"in e?async function(n,s){const r=$a(n,{file:s,...t});await e.run(r,s)}:function(n,s){return $a(n,{file:s,...e||t})}}function Va(e){if(e)throw e}var Wr,Ua;function Yy(){if(Ua)return Wr;Ua=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,r=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},i=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),h=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!h)return!1;var m;for(m in u);return typeof m>"u"||e.call(u,m)},o=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},l=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(s)return s(u,d).value}else return;return u[d]};return Wr=function c(){var u,d,h,m,f,g,y=arguments[0],C=1,w=arguments.length,N=!1;for(typeof y=="boolean"&&(N=y,y=arguments[1]||{},C=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});C<w;++C)if(u=arguments[C],u!=null)for(d in u)h=l(y,d),m=l(u,d),y!==m&&(N&&m&&(i(m)||(f=r(m)))?(f?(f=!1,g=h&&r(h)?h:[]):g=h&&i(h)?h:{},o(y,{name:d,newValue:c(N,g,m)})):typeof m<"u"&&o(y,{name:d,newValue:m}));return y},Wr}var Ky=Yy();const Gr=Tl(Ky);function Ei(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Xy(){const e=[],t={run:n,use:s};return t;function n(...r){let i=-1;const o=r.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);l(null,...r);function l(c,...u){const d=e[++i];let h=-1;if(c){o(c);return}for(;++h<r.length;)(u[h]===null||u[h]===void 0)&&(u[h]=r[h]);r=u,d?eb(d,l)(...u):o(null,...u)}}function s(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),t}}function eb(e,t){let n;return s;function s(...o){const l=e.length>o.length;let c;l&&o.push(r);try{c=e.apply(this,o)}catch(u){const d=u;if(l&&n)throw d;return r(d)}l||(c&&c.then&&typeof c.then=="function"?c.then(i,r):c instanceof Error?r(c):i(c))}function r(o,...l){n||(n=!0,t(o,...l))}function i(o){r(null,o)}}const rt={basename:tb,dirname:nb,extname:sb,join:rb,sep:"/"};function tb(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Mn(e);let n=0,s=-1,r=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;r--;)if(e.codePointAt(r)===47){if(i){n=r+1;break}}else s<0&&(i=!0,s=r+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let o=-1,l=t.length-1;for(;r--;)if(e.codePointAt(r)===47){if(i){n=r+1;break}}else o<0&&(i=!0,o=r+1),l>-1&&(e.codePointAt(r)===t.codePointAt(l--)?l<0&&(s=r):(l=-1,s=o));return n===s?s=o:s<0&&(s=e.length),e.slice(n,s)}function nb(e){if(Mn(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function sb(e){Mn(e);let t=e.length,n=-1,s=0,r=-1,i=0,o;for(;t--;){const l=e.codePointAt(t);if(l===47){if(o){s=t+1;break}continue}n<0&&(o=!0,n=t+1),l===46?r<0?r=t:i!==1&&(i=1):r>-1&&(i=-1)}return r<0||n<0||i===0||i===1&&r===n-1&&r===s+1?"":e.slice(r,n)}function rb(...e){let t=-1,n;for(;++t<e.length;)Mn(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":ib(n)}function ib(e){Mn(e);const t=e.codePointAt(0)===47;let n=ob(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function ob(e,t){let n="",s=0,r=-1,i=0,o=-1,l,c;for(;++o<=e.length;){if(o<e.length)l=e.codePointAt(o);else{if(l===47)break;l=47}if(l===47){if(!(r===o-1||i===1))if(r!==o-1&&i===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",s=0):(n=n.slice(0,c),s=n.length-1-n.lastIndexOf("/")),r=o,i=0;continue}}else if(n.length>0){n="",s=0,r=o,i=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(r+1,o):n=e.slice(r+1,o),s=o-r-1;r=o,i=0}else l===46&&i>-1?i++:i=-1}return n}function Mn(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const ab={cwd:lb};function lb(){return"/"}function ji(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function cb(e){if(typeof e=="string")e=new URL(e);else if(!ji(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return ub(e)}function ub(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const s=t.codePointAt(n+2);if(s===70||s===102){const r=new TypeError("File URL path must not include encoded / characters");throw r.code="ERR_INVALID_FILE_URL_PATH",r}}return decodeURIComponent(t)}const Qr=["history","path","basename","stem","extname","dirname"];class Ec{constructor(t){let n;t?ji(t)?n={path:t}:typeof t=="string"||db(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":ab.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<Qr.length;){const i=Qr[s];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let r;for(r in n)Qr.includes(r)||(this[r]=n[r])}get basename(){return typeof this.path=="string"?rt.basename(this.path):void 0}set basename(t){Zr(t,"basename"),Jr(t,"basename"),this.path=rt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?rt.dirname(this.path):void 0}set dirname(t){Ha(this.basename,"dirname"),this.path=rt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?rt.extname(this.path):void 0}set extname(t){if(Jr(t,"extname"),Ha(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=rt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ji(t)&&(t=cb(t)),Zr(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?rt.basename(this.path,this.extname):void 0}set stem(t){Zr(t,"stem"),Jr(t,"stem"),this.path=rt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,s){const r=this.message(t,n,s);throw r.fatal=!0,r}info(t,n,s){const r=this.message(t,n,s);return r.fatal=void 0,r}message(t,n,s){const r=new ze(t,n,s);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Jr(e,t){if(e&&e.includes(rt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+rt.sep+"`")}function Zr(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Ha(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function db(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const hb=(function(e){const s=this.constructor.prototype,r=s[e],i=function(){return r.apply(i,arguments)};return Object.setPrototypeOf(i,s),i}),fb={}.hasOwnProperty;class ro extends hb{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Xy()}copy(){const t=new ro;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];t.use(...s)}return t.data(Gr(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Xr("data",this.frozen),this.namespace[t]=n,this):fb.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Xr("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const r=n.call(t,...s);typeof r=="function"&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Xn(t),s=this.parser||this.Parser;return Yr("parse",s),s(String(n),n)}process(t,n){const s=this;return this.freeze(),Yr("process",this.parser||this.Parser),Kr("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(i,o){const l=Xn(t),c=s.parse(l);s.run(c,l,function(d,h,m){if(d||!h||!m)return u(d);const f=h,g=s.stringify(f,m);gb(g)?m.value=g:m.result=g,u(d,m)});function u(d,h){d||!h?o(d):i?i(h):n(void 0,h)}}}processSync(t){let n=!1,s;return this.freeze(),Yr("processSync",this.parser||this.Parser),Kr("processSync",this.compiler||this.Compiler),this.process(t,r),Wa("processSync","process",n),s;function r(i,o){n=!0,Va(i),s=o}}run(t,n,s){qa(t),this.freeze();const r=this.transformers;return!s&&typeof n=="function"&&(s=n,n=void 0),s?i(void 0,s):new Promise(i);function i(o,l){const c=Xn(n);r.run(t,c,u);function u(d,h,m){const f=h||t;d?l(d):o?o(f):s(void 0,f,m)}}}runSync(t,n){let s=!1,r;return this.run(t,n,i),Wa("runSync","run",s),r;function i(o,l){Va(o),r=l,s=!0}}stringify(t,n){this.freeze();const s=Xn(n),r=this.compiler||this.Compiler;return Kr("stringify",r),qa(t),r(t,s)}use(t,...n){const s=this.attachers,r=this.namespace;if(Xr("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function i(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...h]=u;c(d,h)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(r.settings=Gr(!0,r.settings,u.settings))}function l(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const h=u[d];i(h)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let h=-1,m=-1;for(;++h<s.length;)if(s[h][0]===u){m=h;break}if(m===-1)s.push([u,...d]);else if(d.length>0){let[f,...g]=d;const y=s[m][1];Ei(y)&&Ei(f)&&(f=Gr(!0,y,f)),s[m]=[u,f,...g]}}}}const pb=new ro().freeze();function Yr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Kr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Xr(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function qa(e){if(!Ei(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Wa(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Xn(e){return mb(e)?e:new Ec(e)}function mb(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function gb(e){return typeof e=="string"||xb(e)}function xb(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const yb="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Ga=[],Qa={allowDangerousHtml:!0},bb=/^(https?|ircs?|mailto|xmpp)$/i,wb=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Sb(e){const t=vb(e),n=Cb(e);return kb(t.runSync(t.parse(n),n),e)}function vb(e){const t=e.rehypePlugins||Ga,n=e.remarkPlugins||Ga,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Qa}:Qa;return pb().use(ey).use(n).use(Zy,s).use(t)}function Cb(e){const t=e.children||"",n=new Ec;return typeof t=="string"&&(n.value=t),n}function kb(e,t){const n=t.allowedElements,s=t.allowElement,r=t.components,i=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||Eb;for(const d of wb)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+yb+d.id,void 0);return kc(e,u),_m(e,{Fragment:a.Fragment,components:r,ignoreInvalidStyle:!0,jsx:a.jsx,jsxs:a.jsxs,passKeys:!0,passNode:!0});function u(d,h,m){if(d.type==="raw"&&m&&typeof h=="number")return o?m.children.splice(h,1):m.children[h]={type:"text",value:d.value},h;if(d.type==="element"){let f;for(f in Ur)if(Object.hasOwn(Ur,f)&&Object.hasOwn(d.properties,f)){const g=d.properties[f],y=Ur[f];(y===null||y.includes(d.tagName))&&(d.properties[f]=c(String(g||""),f,d))}}if(d.type==="element"){let f=n?!n.includes(d.tagName):i?i.includes(d.tagName):!1;if(!f&&s&&typeof h=="number"&&(f=!s(d,h,m)),f&&m&&typeof h=="number")return l&&d.children?m.children.splice(h,1,...d.children):m.children.splice(h,1),h}}}function Eb(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),r=e.indexOf("/");return t===-1||r!==-1&&t>r||n!==-1&&t>n||s!==-1&&t>s||bb.test(e.slice(0,t))?e:""}const jc=p.createContext(null);function jb({children:e,host:t}){return a.jsx(jc.Provider,{value:t,children:e})}function Nc(){const e=p.useContext(jc);if(!e)throw new Error("usePluginHost must be used within PluginHostProvider");return e}const Pc="openlearn:dashboardVisibility";function Nb(){try{const e=localStorage.getItem(Pc);if(e)return new Map(JSON.parse(e))}catch{}return new Map}function Ja(e){try{localStorage.setItem(Pc,JSON.stringify([...e.entries()]))}catch{}}const ke=Vi()((e,t)=>({activePlugins:[],extensionPoints:new Map,services:null,dashboardVisibility:Nb(),initialized:!1,initialize:n=>e({services:n,initialized:!0}),addPlugin:n=>e(s=>({activePlugins:[...s.activePlugins,n]})),removePlugin:n=>e(s=>({activePlugins:s.activePlugins.filter(r=>r.id!==n)})),updatePluginState:(n,s)=>e(r=>({activePlugins:r.activePlugins.map(i=>i.id===n?{...i,state:s}:i)})),registerExtensionPoint:(n,s)=>e(r=>{const i=r.extensionPoints.get(n)??[];if(i.find(c=>c.id===s.id)){const c=new Map(r.extensionPoints);return c.set(n,i.map(u=>u.id===s.id?s:u)),{extensionPoints:c}}const l=new Map(r.extensionPoints);return l.set(n,[...i,s]),{extensionPoints:l}}),unregisterExtensionPoint:(n,s)=>e(r=>{const i=r.extensionPoints.get(n);if(!i)return r;const o=i.filter(c=>c.id!==s),l=new Map(r.extensionPoints);return o.length===0?l.delete(n):l.set(n,o),{extensionPoints:l}}),unregisterPluginExtensionPoints:n=>e(s=>{const r=new Map(s.extensionPoints);for(const[i,o]of r){const l=o.filter(c=>c.pluginId!==n);l.length===0?r.delete(i):r.set(i,l)}return{extensionPoints:r}}),getExtensions:n=>[...t().extensionPoints.get(n)??[]].sort((r,i)=>(r.position??100)-(i.position??100)),setDashboardVisibility:(n,s)=>e(r=>{const i=new Map(r.dashboardVisibility);return i.set(n,s),Ja(i),{dashboardVisibility:i}}),setDashboardVisibilityBatch:n=>e(s=>{const r=new Map(s.dashboardVisibility);for(const[i,o]of n)r.set(i,o);return Ja(r),{dashboardVisibility:r}})}));function Pb(){return a.jsx("div",{className:"w-full h-32 bg-gray-100 rounded-xl animate-pulse flex items-center justify-center",children:a.jsxs("div",{className:"flex flex-col items-center gap-2",children:[a.jsx(Bi,{size:24,className:"text-gray-400 animate-spin"}),a.jsx("span",{className:"text-xs text-gray-400",children:"Loading..."})]})})}class Tb extends Je.Component{constructor(t){super(t),this.state={hasError:!1},this.props=t}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??null:this.props.children}}function Ib({ext:e,route:t,slotProps:n,slot:s}){const r=Je.useRef(null),i=JSON.stringify(n||{});Je.useEffect(()=>{r.current&&typeof e.render=="function"&&(r.current.innerHTML="",Promise.resolve(e.render(r.current,{route:t,...n})).catch(console.error))},[e,t,i]);const l=s==="teacher.dashboard.widget"?"h-auto":"h-full min-h-0";return a.jsx("div",{ref:r,className:`w-full ${l}`})}const ei=new WeakMap;function Ab(e){const t=e.component,n=ei.get(t);if(n)return n;if(t.__isLazyFactory===!0){const s=Je.lazy(t);return ei.set(t,s),s}return ei.set(t,t),t}function yC({slot:e,fallback:t,lang:n,route:s,slotProps:r,placement:i}){let l=Nc().getExtensions(e);const c=ke(h=>h.dashboardVisibility),u=he(h=>h.selectedLesson),d=he(h=>h.liveClassSelectedClassId);return i&&(l=l.filter(h=>(h.placement??"after")===i)),l.length===0?null:e==="teacher.tab"&&r?.renderType==="button"?a.jsx(a.Fragment,{children:l.map(h=>{const m=`${h.pluginId}/${h.id}`,f=r?.teacherTab===m,g=h.title||h.label||h.id;return a.jsxs("button",{onClick:()=>r?.setTeacherTab?.(m),className:`flex items-center gap-3 p-3 transition-colors text-sm font-medium rounded-xl ${f?"bg-indigo-50 text-indigo-700 font-bold":"text-gray-600 hover:bg-gray-50"} ${r?.mainNavCollapsed?"justify-center px-2":""}`,title:g,children:[a.jsx(Fi,{size:20,className:"shrink-0"}),a.jsx("span",{className:r?.mainNavCollapsed?"hidden":"hidden md:block",children:g})]},`${h.pluginId}/${h.id}`)})}):a.jsx(a.Fragment,{children:l.map(h=>{const m=typeof h.component=="function",f=typeof h.render=="function";return e==="teacher.dashboard.widget"&&c.get(h.pluginId)===!1||!m&&!f?null:a.jsx(Tb,{fallback:a.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-sm text-red-700",children:a.jsx("p",{children:n==="zh"?"扩展组件加载失败":"Extension failed to load"})}),children:a.jsx(p.Suspense,{fallback:t??a.jsx(Pb,{}),children:m?Je.createElement(Ab(h),{route:h.route||s,lessonId:u,classId:d,...h.slotProps,...r}):a.jsx(Ib,{ext:h,route:h.route||s,slotProps:{lessonId:u,classId:d,...h.slotProps,...r},slot:e})})},`${h.pluginId}/${h.id}`)})})}const zb=(e,t)=>{const n=e?e.trim():"New Course";switch(t){case"Mathematics":return`# ${n}
|
|
26
|
+
|
|
27
|
+
## 101 Course Core Foundations
|
|
28
|
+
Welcome to our mathematics laboratory. This course is designed to break down abstract calculations into visual whiteboard proofs and real-world application models.
|
|
29
|
+
|
|
30
|
+
### 📐 Key Theorems & Proof Matrix
|
|
31
|
+
- **Formula A**: $E = mc^2$ or equivalent derivative parameters
|
|
32
|
+
- **Core Axiom**: For every linear projection, a finite dimension defines its trace.
|
|
33
|
+
|
|
34
|
+
### 实践演练随堂真题 Practice Problems
|
|
35
|
+
1. Calculate the local optima for the function on the interactive workspace.
|
|
36
|
+
2. Prove the uniqueness of the residual limit under Gaussian conditions.
|
|
37
|
+
|
|
38
|
+
### 📥 Homework Assignment Task
|
|
39
|
+
Identify three real-world physical structures implementing these spatial principles and coordinate maps.`;case"ComputerScience":return`# ${n}
|
|
40
|
+
|
|
41
|
+
## 💻 Technical Exploration & Engineering Lab
|
|
42
|
+
This session acts as an immersive sandbox exploring core algorithmic structures, optimization mechanics, and data abstractions.
|
|
43
|
+
|
|
44
|
+
### ⚙️ Core Lecture Blueprint & Pseudocode
|
|
45
|
+
\`\`\`python
|
|
46
|
+
def optimize_weights(data, factor=0.01):
|
|
47
|
+
# Initialize local metrics
|
|
48
|
+
scores = [x * factor for x in data]
|
|
49
|
+
return sum(scores) / len(scores)
|
|
50
|
+
\`\`\`
|
|
51
|
+
|
|
52
|
+
### ⚡ Laboratory Workspace Drill
|
|
53
|
+
- **Objective**: Develop a linear hash-map with zero-collision distribution.
|
|
54
|
+
- **Action**: Use the interactive canvas to sketch data pipelines.
|
|
55
|
+
|
|
56
|
+
### 📝 Post-Class Evaluation
|
|
57
|
+
Write a 200-word critique analyzing memory-locality vs execution-speed trade-offs in low-level registers.`;case"Literature":return`# ${n}
|
|
58
|
+
|
|
59
|
+
## ✍️ Literary Critical Analysis Seminar
|
|
60
|
+
This curriculum evaluates textual aesthetics, semantic patterns, subtextual symbols, and historical contexts across classic paradigms.
|
|
61
|
+
|
|
62
|
+
### 🏛️ Classic Textual Excerpts
|
|
63
|
+
> "Reality represents a state of constant translation between what is experienced and what is chronicled."
|
|
64
|
+
|
|
65
|
+
### 💭 Critique Evaluation Metrics
|
|
66
|
+
- **Theme Assessment**: Analyze structural ironies within contemporary essays.
|
|
67
|
+
- **Author Intention**: Focus on pacing triggers and character foils.
|
|
68
|
+
|
|
69
|
+
### 💬 Classroom Collaborative Debate Topics
|
|
70
|
+
Does digital notation diminish the biological connection to textual journaling? Discuss under 15 minutes framework.`;case"Physics":return`# ${n}
|
|
71
|
+
|
|
72
|
+
## ⚡ Experimental Physics & Natural Science Sandbox
|
|
73
|
+
In this session, theoretical models undergo practical validation through interactive virtual whiteboard modeling and numerical measurements.
|
|
74
|
+
|
|
75
|
+
### 🔬 Key Mechanical Principles & Constraints
|
|
76
|
+
- **Axiom 1**: Momentum is conserved in closed coordinate vectors.
|
|
77
|
+
- **Axiom 2**: Resistance is directly proportional to temperature factors.
|
|
78
|
+
|
|
79
|
+
### 🛠️ Lab Step-by-Step Procedure
|
|
80
|
+
1. Plot the force vectors acting on the balance coordinate vertices.
|
|
81
|
+
2. Measure the velocity coefficients across three alternate trial loops.
|
|
82
|
+
|
|
83
|
+
### 📝 Homework Assignment Evaluation
|
|
84
|
+
Calculate energy loss ratios using standard mathematical integrals in your journal.`;case"History":return`# ${n}
|
|
85
|
+
|
|
86
|
+
## 🏛️ Geopolitical Context Mapping & Historical Context
|
|
87
|
+
This course explores historical trends, decision frameworks, resource patterns, and socio-economic influences that shaped modern civilization.
|
|
88
|
+
|
|
89
|
+
### 🗺️ Context Timeline Focus
|
|
90
|
+
- **Phase A**: Resource migration patterns along major trade waterways.
|
|
91
|
+
- **Phase B**: Strategic institutional reforms and cultural integration cycles.
|
|
92
|
+
|
|
93
|
+
### 🔍 Primary Source Critique Work
|
|
94
|
+
Analyze the 18th-century legislative documents for bias, context gaps, and underlying socio-economic drivers.
|
|
95
|
+
|
|
96
|
+
### 💬 Group Discussion Prompts
|
|
97
|
+
How did geography influence the longevity of ancient administrative models?`;case"Art":return`# ${n}
|
|
98
|
+
|
|
99
|
+
## 🎨 Visual Composition & Creative Sketching Studio
|
|
100
|
+
A workshop focusing on aesthetic principles, negative space ratios, visual balance, and dynamic typography models.
|
|
101
|
+
|
|
102
|
+
### 🖌️ Design Principles
|
|
103
|
+
- **Golden Spiral**: Align critical focal points with recursive visual arcs.
|
|
104
|
+
- **Chiaroscuro**: Leverage deep high-contrast shading to establish three-dimensional form.
|
|
105
|
+
|
|
106
|
+
### 🛠️ Whiteboard Practical Sandbox Project
|
|
107
|
+
Collaborate on the dynamic canvas to draft a raw responsive layout using minimal monochromatic blocks.
|
|
108
|
+
|
|
109
|
+
### 🎨 Portfolio Task
|
|
110
|
+
Submit three divergent conceptual drafts representing active space constraints.`;default:return`# ${n}
|
|
111
|
+
|
|
112
|
+
## 🔮 Multidisciplinary Advanced Exploration & Research
|
|
113
|
+
This course integrates cross-subject paradigms, cognitive practices, and critical reasoning methods.
|
|
114
|
+
|
|
115
|
+
### 📚 Course Syllabus Modules
|
|
116
|
+
- **Module 1**: Core theoretical grounding and conceptual models.
|
|
117
|
+
- **Module 2**: Practical exercises combining research and action.
|
|
118
|
+
|
|
119
|
+
### 📝 Interactive Classroom Tasks
|
|
120
|
+
1. Formulate 2 key research queries aligning with this lecture.
|
|
121
|
+
2. Sketch the systemic flow diagram depicting interaction factors.
|
|
122
|
+
|
|
123
|
+
### 📥 Assignment Brief
|
|
124
|
+
Draft a 300-word integration proposal based on today's whiteboard exercises.`}};async function _b(e="all"){const t=await fetch(`/api/activities?role=${encodeURIComponent(e)}`,{headers:{Accept:"application/json"}});if(!t.ok)throw new Error(`Failed to load activities (${t.status})`);return(await t.json()).activities??[]}async function Za(){const e=await fetch("/api/activities/running",{headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to load running activities (${e.status})`);return(await e.json()).activities??[]}async function Lb(e){const t=await fetch(`/api/activities/${encodeURIComponent(e)}/finish`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`Failed to finish activity (${t.status})`)}}async function Rb(e){const t=await fetch(`/api/activities/${encodeURIComponent(e)}/pause`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`Failed to pause activity (${t.status})`)}}async function Mb(e){const t=await fetch(`/api/activities/${encodeURIComponent(e)}/resume`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok){const n=await t.json().catch(()=>({}));throw new Error(n.error||`Failed to resume activity (${t.status})`)}}async function Ob(e,t,n){const s=await fetch(`/api/activities/${encodeURIComponent(e)}/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t??{},actorId:n})}),r=await s.json();if(!s.ok||r.ok===!1)throw new Error(r.error||`Failed to start activity (${s.status})`);return r}const es={padding:"12px",color:"#e2e8f0",fontSize:"13px"},Db={HelpCircle:Xf,Vote:Kf,BarChart3:Yf,MessagesSquare:Zf,Users:Il,FileText:Rl,Trophy:Jf,CheckCircle2:Ln,BookOpen:Di};function Fb({name:e,className:t}){const n=e&&Db[e]||Fi;return a.jsx(n,{size:18,className:t})}function Bb(e,t){if(!e)return t==="zh"?"进行中":"In progress";const n=Math.max(0,Math.floor((Date.now()-e)/1e3)),s=Math.floor(n/60),r=n%60;return t==="zh"?`${s} 分 ${r} 秒`:`${s}m ${r}s`}const Tc=({role:e,actorId:t,lang:n="en",classroomId:s,mode:r="launcher"})=>{const[i,o]=p.useState([]),[l,c]=p.useState(!0),[u,d]=p.useState(null),[h,m]=p.useState({}),[f,g]=p.useState([]),[y,C]=p.useState(!0),[w,N]=p.useState(null),[S,E]=p.useState(null),[I,k]=p.useState(!1),[z,D]=p.useState(null),F=he(j=>j.setTeacherTab),_=p.useMemo(()=>{const j=new Map;for(const $ of i){const x=$.category;j.has(x)||j.set(x,[]),j.get(x).push($)}return Array.from(j.entries())},[i]);p.useEffect(()=>{if(r!=="launcher")return;let j=!1;return c(!0),_b(e).then($=>{j||o($)}).catch($=>{j||d($ instanceof Error?$.message:String($))}).finally(()=>{j||c(!1)}),()=>{j=!0}},[e,r]),p.useEffect(()=>{if(r!=="status")return;let j=!1;const $=async()=>{try{const oe=await Za();j||g(oe)}catch(oe){j||N(oe instanceof Error?oe.message:String(oe))}finally{j||C(!1)}};$();const x=setInterval($,5e3);return()=>{j=!0,clearInterval(x)}},[r]);const A=async j=>{if(S){k(!0),D(null);try{await j(S),g(await Za())}catch($){D($ instanceof Error?$.message:String($))}finally{k(!1)}}},L=()=>A(Lb),O=()=>A(Rb),R=()=>A(Mb),P=()=>{E(null),F("live_class")};if(r==="status"){if(y)return a.jsx("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm h-24 animate-pulse"});if(w||f.length===0)return null;const j=f.find($=>$.id===S)||null;return a.jsxs("div",{className:"bg-white border border-slate-200/80 rounded-2xl p-5 shadow-sm",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-slate-800 font-extrabold",children:[a.jsx("span",{children:"🧩"}),a.jsx("span",{children:n==="zh"?"进行中的活动":"Activities in Progress"})]}),a.jsx("span",{className:"text-xs font-bold bg-indigo-50 text-indigo-700 px-2 py-0.5 rounded-full",children:f.length})]}),a.jsx("div",{className:"flex flex-col gap-2",children:f.map($=>{const x=$.state==="running";return a.jsxs("button",{onClick:()=>E($.id),className:"w-full flex items-center gap-3 text-left bg-slate-50 hover:bg-slate-100 border border-slate-200/70 rounded-xl p-3 transition-colors",children:[a.jsx(Fb,{name:$.icon,className:"text-indigo-600 shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"font-bold text-slate-800 truncate",children:$.name}),$.category&&a.jsx("div",{className:"text-xs text-slate-500 truncate",children:$.category})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[a.jsx("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${x?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"}`,children:x?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"}),a.jsxs("span",{className:"text-xs text-slate-400 flex items-center gap-1",children:[a.jsx(Wf,{size:10})," ",Bb($.startedAt,n)]})]})]},$.id)})}),j&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4",onClick:()=>E(null),children:a.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-sm p-5",onClick:$=>$.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-bold text-slate-800",children:j.name}),a.jsx("button",{onClick:()=>E(null),className:"text-slate-400 hover:text-slate-600","aria-label":"close",children:a.jsx(ot,{size:18})})]}),a.jsxs("div",{className:"text-sm text-slate-500 mb-1",children:[n==="zh"?"状态":"Status",":"," ",j.state==="running"?n==="zh"?"进行中":"Running":n==="zh"?"已暂停":"Paused"]}),a.jsxs("div",{className:"text-sm text-slate-500 mb-4",children:[n==="zh"?"开始时间":"Started",":"," ",j.startedAt?new Date(j.startedAt).toLocaleString():"-"]}),z&&a.jsx("div",{className:"text-xs text-rose-600 mb-2",children:z}),a.jsxs("div",{className:"flex gap-2",children:[j.state==="running"?a.jsxs("button",{disabled:I,onClick:O,className:"flex-1 flex items-center justify-center gap-1 bg-amber-500 hover:bg-amber-600 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:[a.jsx(Gf,{size:14})," ",n==="zh"?"暂停":"Pause"]}):a.jsxs("button",{disabled:I,onClick:R,className:"flex-1 flex items-center justify-center gap-1 bg-indigo-500 hover:bg-indigo-600 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:[a.jsx(Qf,{size:14})," ",n==="zh"?"恢复":"Resume"]}),a.jsx("button",{disabled:I,onClick:L,className:"flex-1 flex items-center justify-center gap-1 bg-rose-600 hover:bg-rose-700 disabled:opacity-60 text-white rounded-lg py-2 text-sm font-bold",children:I?n==="zh"?"处理中…":"Working…":n==="zh"?"结束":"End"})]}),a.jsx("button",{onClick:P,className:"w-full mt-2 bg-slate-100 hover:bg-slate-200 text-slate-700 rounded-lg py-2 text-sm font-bold",children:n==="zh"?"进入课堂":"Enter Classroom"})]})})]})}const T=async j=>{m($=>({...$,[j.id]:n==="zh"?"启动中…":"Starting…"}));try{const $=await Ob(j.id,{classroomId:s,role:e},t);m(x=>({...x,[j.id]:$.dispatched?n==="zh"?"已启动 ✓":"Started ✓":n==="zh"?"已通知 ✓":"Notified ✓"}))}catch($){m(x=>({...x,[j.id]:$ instanceof Error?$.message:String($)}))}};if(l)return a.jsx("div",{style:es,children:n==="zh"?"加载活动中…":"Loading activities…"});if(u)return a.jsxs("div",{style:es,children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",n==="zh"?"活动中心":"Activity Center"]}),a.jsx("div",{style:{opacity:.7},children:u})]});const W=e==="teacher"?n==="zh"?"活动中心(教师)":"Activity Center":n==="zh"?"活动(学生)":"Activities";return i.length===0?a.jsxs("div",{style:es,children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:6},children:["🧩 ",W]}),a.jsx("div",{style:{opacity:.7},children:n==="zh"?"暂无可用活动。":"No activities available."})]}):a.jsxs("div",{style:es,children:[a.jsxs("div",{style:{fontWeight:600,marginBottom:8},children:["🧩 ",W]}),_.map(([j,$])=>a.jsxs("div",{style:{marginBottom:10},children:[a.jsx("div",{style:{opacity:.6,fontSize:12,textTransform:"uppercase",marginBottom:4},children:j}),a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:$.map(x=>a.jsxs("div",{style:{border:"1px solid #334155",borderRadius:8,padding:"8px 10px",minWidth:150,background:"#0f172a"},children:[a.jsxs("div",{style:{fontWeight:600},children:[x.icon?`${x.icon} `:"▫️ ",x.name]}),x.description&&a.jsx("div",{style:{opacity:.7,fontSize:12,margin:"2px 0 6px"},children:x.description}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[a.jsx("button",{onClick:()=>T(x),style:{cursor:"pointer",background:e==="teacher"?"#2563eb":"#0ea5e9",color:"#fff",border:"none",borderRadius:6,padding:"4px 10px",fontSize:12},children:e==="teacher"?n==="zh"?"启动":"Start":n==="zh"?"参与":"Open"}),h[x.id]&&a.jsx("span",{style:{fontSize:12,opacity:.85},children:h[x.id]})]}),a.jsx("div",{style:{opacity:.5,fontSize:12,marginTop:4},children:x.provider==="official"?"official":x.provider})]},x.id))})]},j))]})},$b=Object.freeze(Object.defineProperty({__proto__:null,ActivityWorkspaceWidget:Tc},Symbol.toStringTag,{value:"Module"}));let Ya=!1;function Vb(){if(Ya)return;Ya=!0;const e=()=>Ie(()=>Promise.resolve().then(()=>$b),void 0).then(t=>({default:()=>a.jsx(Tc,{role:"teacher",mode:"status"})}));e.__isLazyFactory=!0,ke.getState().registerExtensionPoint("teacher.dashboard.widget",{id:"official_activity_center",label:"Activity Center",icon:"Puzzle",pluginId:"openlearn-official",component:e})}const Ka="@openlearn/frontend:IFrontendAPI",Xa="@openlearn/frontend:ISocketService",el="@openlearn/frontend:IUIService",tl="@openlearn/frontend:IStorageService",Ub="@openlearn/frontend:ISemesterGradeService";var be=(e=>(e.INSTALLED="installed",e.ACTIVATING="activating",e.ACTIVE="active",e.DEACTIVATING="deactivating",e.INACTIVE="inactive",e.ERROR="error",e.UNINSTALLED="uninstalled",e))(be||{});const Hb=p.lazy(()=>Ie(()=>import("./StudentView-BtGPu4nl.js"),[]).then(e=>({default:e.StudentView}))),qb=p.lazy(()=>Ie(()=>import("./TeacherView-_iKPvpXI.js"),[]).then(e=>({default:e.TeacherView})));function Wb(e){const{activeRole:t}=e;return a.jsx(p.Suspense,{fallback:a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center min-h-[50vh] text-slate-400 gap-3",children:[a.jsx(Bi,{className:"w-8 h-8 animate-spin text-indigo-500"}),a.jsx("span",{className:"text-sm font-medium tracking-wide",children:"正在加载工作台..."})]}),children:t==="student"?a.jsx(Hb,{...e}):a.jsx(qb,{...e})})}const io=p.createContext({});function oo(e){const t=p.useRef(null);return t.current===null&&(t.current=e()),t.current}const Gb=typeof window<"u",Ic=Gb?p.useLayoutEffect:p.useEffect,Rs=p.createContext(null),ao=p.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function nl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Qb(...e){return t=>{let n=!1;const s=e.map(r=>{const i=nl(r,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let r=0;r<s.length;r++){const i=s[r];typeof i=="function"?i():nl(e[r],null)}}}}function Jb(...e){return p.useCallback(Qb(...e),e)}class Zb extends p.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(_r(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,r=_r(s)&&s.offsetWidth||0,i=_r(s)&&s.offsetHeight||0,o=getComputedStyle(n),l=this.props.sizeRef.current;l.height=parseFloat(o.height),l.width=parseFloat(o.width),l.top=n.offsetTop,l.left=n.offsetLeft,l.right=r-l.width-l.left,l.bottom=i-l.height-l.top,l.direction=o.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Yb({children:e,isPresent:t,anchorX:n,anchorY:s,root:r,pop:i}){const o=p.useId(),l=p.useRef(null),c=p.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:u}=p.useContext(ao),d=e.props?.ref??e?.ref,h=Jb(l,d);return p.useInsertionEffect(()=>{const{width:m,height:f,top:g,left:y,right:C,bottom:w,direction:N}=c.current;if(t||i===!1||!l.current||!m||!f)return;const S=N==="rtl",E=n==="left"?S?`right: ${C}`:`left: ${y}`:S?`left: ${y}`:`right: ${C}`,I=s==="bottom"?`bottom: ${w}`:`top: ${g}`;l.current.dataset.motionPopId=o;const k=document.createElement("style");u&&(k.nonce=u);const z=r??document.head;return z.appendChild(k),k.sheet&&k.sheet.insertRule(`
|
|
125
|
+
[data-motion-pop-id="${o}"] {
|
|
126
|
+
position: absolute !important;
|
|
127
|
+
width: ${m}px !important;
|
|
128
|
+
height: ${f}px !important;
|
|
129
|
+
${E}px !important;
|
|
130
|
+
${I}px !important;
|
|
131
|
+
}
|
|
132
|
+
`),()=>{l.current?.removeAttribute("data-motion-pop-id"),z.contains(k)&&z.removeChild(k)}},[t]),a.jsx(Zb,{isPresent:t,childRef:l,sizeRef:c,pop:i,children:i===!1?e:p.cloneElement(e,{ref:h})})}const Kb=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:i,mode:o,anchorX:l,anchorY:c,root:u})=>{const d=oo(Xb),h=p.useId();let m=!0,f=p.useMemo(()=>(m=!1,{id:h,initial:t,isPresent:n,custom:r,onExitComplete:g=>{d.set(g,!0);for(const y of d.values())if(!y)return;s&&s()},register:g=>(d.set(g,!1),()=>d.delete(g))}),[n,d,s]);return i&&m&&(f={...f}),p.useMemo(()=>{d.forEach((g,y)=>d.set(y,!1))},[n]),p.useEffect(()=>{!n&&!d.size&&s&&s()},[n]),e=a.jsx(Yb,{pop:o==="popLayout",isPresent:n,anchorX:l,anchorY:c,root:u,children:e}),a.jsx(Rs.Provider,{value:f,children:e})};function Xb(){return new Map}function Ac(e=!0){const t=p.useContext(Rs);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:r}=t,i=p.useId();p.useEffect(()=>{if(e)return r(i)},[e]);const o=p.useCallback(()=>e&&s&&s(i),[i,s,e]);return!n&&s?[!1,o]:[!0]}const ts=e=>e.key||"";function sl(e){const t=[];return p.Children.forEach(e,n=>{p.isValidElement(n)&&t.push(n)}),t}const zc=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:i="sync",propagate:o=!1,anchorX:l="left",anchorY:c="top",root:u})=>{const[d,h]=Ac(o),m=p.useMemo(()=>sl(e),[e]),f=o&&!d?[]:m.map(ts),g=p.useRef(!0),y=p.useRef(m),C=oo(()=>new Map),w=p.useRef(new Set),[N,S]=p.useState(m),[E,I]=p.useState(m);Ic(()=>{g.current=!1,y.current=m;for(let D=0;D<E.length;D++){const F=ts(E[D]);f.includes(F)?(C.delete(F),w.current.delete(F)):C.get(F)!==!0&&C.set(F,!1)}},[E,f.length,f.join("-")]);const k=[];if(m!==N){let D=[...m];for(let F=0;F<E.length;F++){const _=E[F],A=ts(_);f.includes(A)||(D.splice(F,0,_),k.push(_))}return i==="wait"&&k.length&&(D=k),I(sl(D)),S(m),null}const{forceRender:z}=p.useContext(io);return a.jsx(a.Fragment,{children:E.map(D=>{const F=ts(D),_=o&&!d?!1:m===E||f.includes(F),A=()=>{if(w.current.has(F))return;if(C.has(F))w.current.add(F),C.set(F,!0);else return;let L=!0;C.forEach(O=>{O||(L=!1)}),L&&(z?.(),I(y.current),o&&h?.(),s&&s())};return a.jsx(Kb,{isPresent:_,initial:!g.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:i,root:u,onExitComplete:_?void 0:A,anchorX:l,anchorY:c,children:D},F)})})},_c=p.createContext({strict:!1}),rl={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let il=!1;function e0(){if(il)return;const e={};for(const t in rl)e[t]={isEnabled:n=>rl[t].some(s=>!!n[s])};Dl(e),il=!0}function Lc(){return e0(),lp()}function t0(e){const t=Lc();for(const n in e)t[n]={...t[n],...e[n]};Dl(t)}const n0=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function js(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||n0.has(e)}let Rc=e=>!js(e);function s0(e){typeof e=="function"&&(Rc=t=>t.startsWith("on")?!js(t):e(t))}try{s0(require("@emotion/is-prop-valid").default)}catch{}function r0(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||Ui(e[r])||(Rc(r)||n===!0&&js(r)||!t&&!js(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const Ms=p.createContext({});function i0(e,t){if(Fl(e)){const{initial:n,animate:s}=e;return{initial:n===!1||ea(n)?n:void 0,animate:ea(s)?s:void 0}}return e.inherit!==!1?t:{}}function o0(e){const{initial:t,animate:n}=i0(e,p.useContext(Ms));return p.useMemo(()=>({initial:t,animate:n}),[ol(t),ol(n)])}function ol(e){return Array.isArray(e)?e.join(" "):e}const lo=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Mc(e,t,n){for(const s in t)!Ui(t[s])&&!cp(s,n)&&(e[s]=t[s])}function a0({transformTemplate:e},t){return p.useMemo(()=>{const n=lo();return up(n,t,e),Object.assign({},n.vars,n.style)},[t])}function l0(e,t){const n=e.style||{},s={};return Mc(s,n,e),Object.assign(s,a0(e,t)),s}function c0(e,t){const n={},s=l0(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const Oc=()=>({...lo(),attrs:{}});function u0(e,t,n,s){const r=p.useMemo(()=>{const i=Oc();return dp(i,t,hp(s),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Mc(i,e.style,e),r.style={...i,...r.style}}return r}const d0=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function co(e){return typeof e!="string"||e.includes("-")?!1:!!(d0.indexOf(e)>-1||/[A-Z]/u.test(e))}function h0(e,t,n,{latestValues:s},r,i=!1,o){const c=(o??co(e)?u0:c0)(t,s,r,e),u=r0(t,typeof e=="string",i),d=e!==p.Fragment?{...u,...c,ref:n}:{},{children:h}=t,m=p.useMemo(()=>Ui(h)?h.get():h,[h]);return p.createElement(e,{...d,children:m})}function f0({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:p0(n,s,r,e),renderState:t()}}function p0(e,t,n,s){const r={},i=s(e,{});for(const m in i)r[m]=fp(i[m]);let{initial:o,animate:l}=e;const c=Fl(e),u=pp(e);t&&u&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const h=d?l:o;if(h&&typeof h!="boolean"&&!Bl(h)){const m=Array.isArray(h)?h:[h];for(let f=0;f<m.length;f++){const g=mp(e,m[f]);if(g){const{transitionEnd:y,transition:C,...w}=g;for(const N in w){let S=w[N];if(Array.isArray(S)){const E=d?S.length-1:0;S=S[E]}S!==null&&(r[N]=S)}for(const N in y)r[N]=y[N]}}}return r}const Dc=e=>(t,n)=>{const s=p.useContext(Ms),r=p.useContext(Rs),i=()=>f0(e,t,s,r);return n?i():oo(i)},m0=Dc({scrapeMotionValuesFromProps:gp,createRenderState:lo}),g0=Dc({scrapeMotionValuesFromProps:xp,createRenderState:Oc}),x0=Symbol.for("motionComponentSymbol");function y0(e,t,n){const s=p.useRef(n);p.useInsertionEffect(()=>{s.current=n});const r=p.useRef(null);return p.useCallback(i=>{i&&e.onMount?.(i),t&&(i?t.mount(i):t.unmount());const o=s.current;if(typeof o=="function")if(i){const l=o(i);typeof l=="function"&&(r.current=l)}else r.current?(r.current(),r.current=null):o(i);else o&&(o.current=i)},[t])}const Fc=p.createContext({});function Kt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function b0(e,t,n,s,r,i){const{visualElement:o}=p.useContext(Ms),l=p.useContext(_c),c=p.useContext(Rs),u=p.useContext(ao),d=u.reducedMotion,h=u.skipAnimations,m=p.useRef(null),f=p.useRef(!1);s=s||l.renderer,!m.current&&s&&(m.current=s(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:d,skipAnimations:h,isSVG:i}),f.current&&m.current&&(m.current.manuallyAnimateOnMount=!0));const g=m.current,y=p.useContext(Fc);g&&!g.projection&&r&&(g.type==="html"||g.type==="svg")&&w0(m.current,n,r,y);const C=p.useRef(!1);p.useInsertionEffect(()=>{g&&C.current&&g.update(n,c)});const w=n[yp],N=p.useRef(!!w&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(w)&&window.MotionHasOptimisedAnimation?.(w));return Ic(()=>{f.current=!0,g&&(C.current=!0,window.MotionIsMounted=!0,g.updateFeatures(),g.scheduleRenderMicrotask(),N.current&&g.animationState&&g.animationState.animateChanges())}),p.useEffect(()=>{g&&(!N.current&&g.animationState&&g.animationState.animateChanges(),N.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(w)}),N.current=!1),g.enteringChildren=void 0)}),g}function w0(e,t,n,s){const{layoutId:r,layout:i,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:u,layoutAnchor:d,layoutCrossfade:h}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Bc(e.parent)),e.projection.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!o||l&&Kt(l),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:h,layoutScroll:c,layoutRoot:u,layoutAnchor:d})}function Bc(e){if(e)return e.options.allowProjection!==!1?e.projection:Bc(e.parent)}function ti(e,{forwardMotionProps:t=!1,type:n}={},s,r){s&&t0(s);const i=n?n==="svg":co(e),o=i?g0:m0;function l(u,d){let h;const m={...p.useContext(ao),...u,layoutId:S0(u)},{isStatic:f}=m,g=o0(u),y=o(u,f);if(!f&&typeof window<"u"){v0();const C=C0(m);h=C.MeasureLayout,g.visualElement=b0(e,y,m,r,C.ProjectionNode,i)}return a.jsxs(Ms.Provider,{value:g,children:[h&&g.visualElement?a.jsx(h,{visualElement:g.visualElement,...m}):null,h0(e,u,y0(y,g.visualElement,d),y,f,t,i)]})}l.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=p.forwardRef(l);return c[x0]=e,c}function S0({layoutId:e}){const t=p.useContext(io).id;return t&&e!==void 0?t+"-"+e:e}function v0(e,t){p.useContext(_c).strict}function C0(e){const t=Lc(),{drag:n,layout:s}=t;if(!n&&!s)return{};const r={...n,...s};return{MeasureLayout:n?.isEnabled(e)||s?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function k0(e,t){if(typeof Proxy>"u")return ti;const n=new Map,s=(i,o)=>ti(i,o,e,t),r=(i,o)=>s(i,o);return new Proxy(r,{get:(i,o)=>o==="create"?s:(n.has(o)||n.set(o,ti(o,void 0,e,t)),n.get(o))})}const E0=(e,t)=>t.isSVG??co(e)?new bp(t):new wp(t,{allowProjection:e!==p.Fragment});class j0 extends At{constructor(t){super(t),t.animationState||(t.animationState=Sp(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Bl(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let N0=0;class P0 extends At{constructor(){super(...arguments),this.id=N0++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;if(t&&s===!1){if(this.isExitComplete){const{initial:i,custom:o}=this.node.getProps();if(typeof i=="string"||typeof i=="object"&&i!==null&&!Array.isArray(i)){const l=vp(this.node,i,o);if(l){const{transition:c,transitionEnd:u,...d}=l;for(const h in d)this.node.getValue(h)?.jump(d[h])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const T0={animation:{Feature:j0},exit:{Feature:P0}};function On(e){return{point:{x:e.pageX,y:e.pageY}}}const I0=e=>t=>$l(t)&&e(t,On(t));function Tn(e,t,n,s){return Ss(e,t,I0(n),s)}const $c=({current:e})=>e?e.ownerDocument.defaultView:null,al=(e,t)=>Math.abs(e-t);function A0(e,t){const n=al(e.x,t.x),s=al(e.y,t.y);return Math.sqrt(n**2+s**2)}const ll=new Set(["auto","scroll"]);class Vc{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:o=3,element:l}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=f=>{this.handleScroll(f.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=ns(this.lastRawMoveEventInfo,this.transformPagePoint));const f=ni(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=A0(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:C}=f,{timestamp:w}=ta;this.history.push({...C,timestamp:w});const{onStart:N,onMove:S}=this.handlers;g||(N&&N(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastRawMoveEventInfo=g,this.lastMoveEventInfo=ns(g,this.transformPagePoint),et.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:C,resumeAnimation:w}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const N=ni(f.type==="pointercancel"?this.lastMoveEventInfo:ns(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,N),C&&C(f,N)},!$l(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=r||window;const c=On(t),u=ns(c,this.transformPagePoint),{point:d}=u,{timestamp:h}=ta;this.history=[{...d,timestamp:h}];const{onSessionStart:m}=n;m&&m(t,ni(u,this.history)),this.removeListeners=Vl(Tn(this.contextWindow,"pointermove",this.handlePointerMove),Tn(this.contextWindow,"pointerup",this.handlePointerUp),Tn(this.contextWindow,"pointercancel",this.handlePointerUp)),l&&this.startScrollTracking(l)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(ll.has(s.overflowX)||ll.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const s=t===window,r=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},i={x:r.x-n.x,y:r.y-n.y};i.x===0&&i.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(t,r),et.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Cp(this.updatePoint)}}function ns(e,t){return t?{point:t(e.point)}:e}function cl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ni({point:e},t){return{point:e,delta:cl(e,Uc(t)),offset:cl(e,z0(t)),velocity:_0(t,.1)}}function z0(e){return e[0]}function Uc(e){return e[e.length-1]}function _0(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Uc(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>na(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&r.timestamp-s.timestamp>na(t)*2&&(s=e[1]);const i=kp(r.timestamp-s.timestamp);if(i===0)return{x:0,y:0};const o={x:(r.x-s.x)/i,y:(r.y-s.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function L0(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?vs(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?vs(n,e,s.max):Math.min(e,n)),e}function ul(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function R0(e,{top:t,left:n,bottom:s,right:r}){return{x:ul(e.x,n,r),y:ul(e.y,t,s)}}function dl(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function M0(e,t){return{x:dl(e.x,t.x),y:dl(e.y,t.y)}}function O0(e,t){let n=.5;const s=gi(e),r=gi(t);return r>s?n=sa(t.min,t.max-s,e.min):s>r&&(n=sa(e.min,e.max-r,t.min)),Ep(0,1,n)}function D0(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const Ni=.35;function F0(e=Ni){return e===!1?e=0:e===!0&&(e=Ni),{x:hl(e,"left","right"),y:hl(e,"top","bottom")}}function hl(e,t,n){return{min:fl(e,t),max:fl(e,n)}}function fl(e,t){return typeof e=="number"?e:e[t]||0}const B0=new WeakMap;class $0{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=jp(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=h=>{n&&this.snapToCursor(On(h).point),this.stopAnimation()},o=(h,m)=>{const{drag:f,dragPropagation:g,onDragStart:y}=this.getProps();if(f&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ap(f),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Pt(w=>{let N=this.getAxisMotionValue(w).get()||0;if(zp.test(N)){const{projection:S}=this.visualElement;if(S&&S.layout){const E=S.layout.layoutBox[w];E&&(N=gi(E)*(parseFloat(N)/100))}}this.originPoint[w]=N}),y&&et.update(()=>y(h,m),!1,!0),ra(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},l=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m;const{dragPropagation:f,dragDirectionLock:g,onDirectionLock:y,onDrag:C}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:w}=m;if(g&&this.currentDirection===null){this.currentDirection=U0(w),this.currentDirection!==null&&y&&y(this.currentDirection);return}this.updateAxis("x",m.point,w),this.updateAxis("y",m.point,w),this.visualElement.render(),C&&et.update(()=>C(h,m),!1,!0)},c=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m,this.stop(h,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>{const{dragSnapToOrigin:h}=this.getProps();(h||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:d}=this.getProps();this.panSession=new Vc(t,{onSessionStart:i,onStart:o,onMove:l,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:$c(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!s)return;const{velocity:o}=r;this.startAnimation(o);const{onDragEnd:l}=this.getProps();l&&et.postRender(()=>l(s,r))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,s){const{drag:r}=this.getProps();if(!s||!ss(t,r,this.currentDirection))return;const i=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=L0(o,this.constraints[t],this.elastic[t])),i.set(o)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;t&&Kt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=R0(s.layoutBox,t):this.constraints=!1,this.elastic=F0(n),r!==this.constraints&&!Kt(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&Pt(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=D0(s.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Kt(t))return!1;const s=t.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());const i=Np(s,r.root,this.visualElement.getTransformPagePoint());let o=M0(r.layout.layoutBox,i);if(n){const l=n(Pp(o));this.hasMutatedConstraints=!!l,l&&(o=Tp(l))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},u=Pt(d=>{if(!ss(d,n,this.currentDirection))return;let h=c&&c[d]||{};(o===!0||o===d)&&(h={min:0,max:0});const m=r?200:1e6,f=r?40:1e7,g={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10,...i,...h};return this.startAxisValueAnimation(d,g)});return Promise.all(u).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ra(this.visualElement,t),s.start(Ip(t,s,0,n,this.visualElement,!1))}stopAnimation(){Pt(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps()[n];return r||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){Pt(n=>{const{drag:s}=this.getProps();if(!ss(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,i=this.getAxisMotionValue(n);if(r&&r.layout){const{min:o,max:l}=r.layout.layoutBox[n],c=i.get()||0;i.set(t[n]-vs(o,l,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Kt(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Pt(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();r[o]=O0({min:c,max:c},this.constraints[o])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),Pt(o=>{if(!ss(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:u}=this.constraints[o];l.set(vs(c,u,r[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;B0.set(this.visualElement,this);const t=this.visualElement.current,n=Tn(t,"pointerdown",u=>{const{drag:d,dragListener:h=!0}=this.getProps(),m=u.target,f=m!==t&&_p(m);d&&h&&!f&&this.start(u)});let s;const r=()=>{const{dragConstraints:u}=this.getProps();Kt(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),s||(s=V0(t,u.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,o=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),et.read(r);const l=Ss(window,"resize",()=>this.scalePositionWithinConstraints()),c=i.addEventListener("didUpdate",(({delta:u,hasLayoutChanged:d})=>{this.isDragging&&d&&(Pt(h=>{const m=this.getAxisMotionValue(h);m&&(this.originPoint[h]+=u[h].translate,m.set(m.get()+u[h].translate))}),this.visualElement.render())}));return()=>{l(),n(),o(),c&&c(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:o=Ni,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:i,dragElastic:o,dragMomentum:l}}}function pl(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function V0(e,t,n){const s=ia(e,pl(n)),r=ia(t,pl(n));return()=>{s(),r()}}function ss(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function U0(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class H0 extends At{constructor(t){super(t),this.removeGroupControls=cs,this.removeListeners=cs,this.controls=new $0(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||cs}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const si=e=>(t,n)=>{e&&et.update(()=>e(t,n),!1,!0)};class q0 extends At{constructor(){super(...arguments),this.removePointerDownListener=cs}onPointerDown(t){this.session=new Vc(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:$c(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:si(t),onStart:si(n),onMove:si(s),onEnd:(i,o)=>{delete this.session,r&&et.postRender(()=>r(i,o))}}}mount(){this.removePointerDownListener=Tn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let ri=!1;class W0 extends p.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:i}=t;i&&(n.group&&n.group.add(i),s&&s.register&&r&&s.register(i),ri&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Rp.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:i}=this.props,{projection:o}=s;return o&&(o.isPresent=i,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),ri=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==i?o.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?o.promote():o.relegate()||et.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:s}=t;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),Lp.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;ri=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Hc(e){const[t,n]=Ac(),s=p.useContext(io);return a.jsx(W0,{...e,layoutGroup:s,switchLayoutGroup:p.useContext(Fc),isPresent:t,safeToRemove:n})}const G0={pan:{Feature:q0},drag:{Feature:H0,ProjectionNode:Ul,MeasureLayout:Hc}};function ml(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,i=s[r];i&&et.postRender(()=>i(t,On(t)))}class Q0 extends At{mount(){const{current:t}=this.node;t&&(this.unmount=Mp(t,(n,s)=>(ml(this.node,s,"Start"),r=>ml(this.node,r,"End"))))}unmount(){}}class J0 extends At{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Vl(Ss(this.node.current,"focus",()=>this.onFocus()),Ss(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function gl(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),i=s[r];i&&et.postRender(()=>i(t,On(t)))}class Z0 extends At{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=Op(t,(r,i)=>(gl(this.node,i,"Start"),(o,{success:l})=>gl(this.node,o,l?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:s?.tap===!1})}unmount(){}}const Pi=new WeakMap,ii=new WeakMap,Y0=e=>{const t=Pi.get(e.target);t&&t(e)},K0=e=>{e.forEach(Y0)};function X0({root:e,...t}){const n=e||document;ii.has(n)||ii.set(n,{});const s=ii.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(K0,{root:e,...t})),s[r]}function ew(e,t,n){const s=X0(t);return Pi.set(e,n),s.observe(e),()=>{Pi.delete(e),s.unobserve(e)}}const tw={some:0,all:1};class nw extends At{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:i}=t,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:tw[r]},l=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:h}=this.node.getProps(),m=u?d:h;m&&m(c)};this.stopObserver=ew(this.node.current,o,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(sw(t,n))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}}function sw({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const rw={inView:{Feature:nw},tap:{Feature:Z0},focus:{Feature:J0},hover:{Feature:Q0}},iw={layout:{ProjectionNode:Ul,MeasureLayout:Hc}},ow={...T0,...rw,...G0,...iw},Ti=k0(ow,E0);async function Ns(e){if(typeof window>"u")return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return console.error("[OpenLearn Clipboard] Failed to copy text to clipboard:",t),!1}}function aw(){const e=he(i=>i.toasts),[t,n]=p.useState(null),s=async(i,o)=>{i.stopPropagation();const l=`[${o.title}] ${o.message}`;await Ns(l)&&(n(o.id),setTimeout(()=>n(null),2e3))},r=i=>{switch(i){case"error":return{border:"border-l-4 border-rose-500",iconBg:"bg-rose-50 text-rose-600 dark:bg-rose-950/60 dark:text-rose-400",icon:a.jsx(hi,{size:16})};case"warning":return{border:"border-l-4 border-amber-500",iconBg:"bg-amber-50 text-amber-600 dark:bg-amber-950/60 dark:text-amber-400",icon:a.jsx($i,{size:16})};case"info":return{border:"border-l-4 border-blue-500",iconBg:"bg-blue-50 text-blue-600 dark:bg-blue-950/60 dark:text-blue-400",icon:a.jsx(ep,{size:16})};case"success":default:return{border:"border-l-4 border-emerald-500",iconBg:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950/60 dark:text-emerald-400",icon:a.jsx(Ln,{size:16})}}};return a.jsx("div",{className:"fixed bottom-6 right-6 z-50 flex flex-col gap-3 min-w-[320px] max-w-sm pointer-events-none",children:a.jsx(zc,{children:e.map(i=>{const o=r(i.type),l=t===i.id;return a.jsxs(Ti.div,{initial:{opacity:0,y:50,x:50,scale:.9},animate:{opacity:1,y:0,x:0,scale:1},exit:{opacity:0,scale:.85,transition:{duration:.2}},transition:{type:"spring",stiffness:300,damping:24},className:`pointer-events-auto w-full bg-white dark:bg-slate-900 ring-1 ring-black/5 shadow-2xl rounded-xl p-4 flex gap-3 ${o.border} overflow-hidden text-gray-900 dark:text-gray-100`,id:`toast-${i.id}`,children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:`p-1 rounded-full shrink-0 ${o.iconBg}`,children:o.icon}),a.jsx("p",{className:"font-semibold text-sm font-sans truncate",children:i.title})]}),(i.type==="error"||i.type==="warning")&&a.jsxs("button",{type:"button",onClick:c=>s(c,i),className:`text-xs font-bold px-1.5 py-0.5 rounded transition-all flex items-center gap-1 cursor-pointer shrink-0 ${l?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 dark:bg-slate-800 dark:hover:bg-slate-700 text-gray-600 dark:text-gray-300"}`,title:"复制错误内容",children:[l?a.jsx(yt,{size:11}):a.jsx(An,{size:11}),a.jsx("span",{children:l?"已复制":"复制"})]})]}),a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2 leading-relaxed font-sans break-words",children:i.message})]}),a.jsx("button",{type:"button",onClick:()=>Ee.getState().removeToast(i.id),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-slate-800 rounded p-1 h-fit transition-colors shrink-0 cursor-pointer",children:a.jsx(ot,{size:14})})]},i.id)})})})}function lw({showRightSidebar:e,setShowRightSidebar:t,rightSidebarTab:n,setRightSidebarTab:s,effectiveAgentProviderId:r,agentProviderId:i,setAgentProviderId:o,aiProviders:l,selectedAgentProvider:c,chatLog:u,loading:d,input:h,setInput:m,handleSend:f,chatAttachments:g,setChatAttachments:y,handleChatFileChange:C,handleChatDrop:w,onClearAgentMemory:N,events:S,lang:E,t:I}){const k=p.useRef(null);return p.useEffect(()=>{k.current?.scrollIntoView({behavior:"smooth"})},[u]),a.jsx("div",{className:`transition-all duration-300 bg-white border-l border-gray-200 flex flex-col shadow-xl relative z-30 shrink-0 ${e?"w-96":"w-12 items-center cursor-pointer hover:bg-gray-50"}`,children:e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex bg-gray-100 p-1 m-4 rounded-lg shrink-0",children:[a.jsxs("button",{onClick:()=>s("agent"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${n==="agent"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[a.jsx(zr,{size:14})," Agent"]}),a.jsxs("button",{onClick:()=>s("shell"),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center justify-center gap-1 ${n==="shell"?"bg-white shadow text-indigo-600":"text-gray-500 hover:text-gray-700"}`,children:[a.jsx(ls,{size:14})," Shell"]}),a.jsx("button",{onClick:()=>t(!1),className:"ml-1 p-1.5 text-gray-400 hover:text-gray-600 rounded-md",children:a.jsx(tp,{size:14})})]}),n==="agent"?a.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[a.jsx("div",{className:"p-4 border-b border-gray-100 shrink-0",children:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("div",{className:"p-1.5 bg-indigo-50 text-indigo-600 rounded-lg",children:a.jsx(zr,{size:16})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"font-semibold text-gray-900 text-sm",children:I.agentTitle}),a.jsx("p",{className:"text-xs text-gray-500",children:I.agentSubtitle}),a.jsxs("button",{onClick:N,title:E==="zh"?"清除内核助手的对话记忆":"Clear the kernel assistant's conversation memory",className:"mt-1 inline-flex items-center gap-1 text-xs text-gray-400 hover:text-red-500 transition-colors",children:["🧹 ",E==="zh"?"清除记忆":"Clear memory"]})]})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1.5 min-w-[150px] max-w-[50%]",children:[a.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-gray-400",children:E==="zh"?"AI 提供商":"AI Provider"}),a.jsxs("div",{className:"relative w-full",children:[l.length===0?a.jsx("select",{disabled:!0,value:"",className:"w-full appearance-none rounded-xl border border-amber-200 bg-amber-50/50 px-3 py-2 pr-9 text-xs font-medium text-amber-700 shadow-xs outline-none cursor-not-allowed",children:a.jsx("option",{value:"",children:E==="zh"?"未配置 AI 提供商":"No AI Provider"})}):a.jsx("select",{value:r,onChange:z=>o(z.target.value),className:"w-full appearance-none rounded-xl border border-gray-200 bg-gradient-to-b from-white to-gray-50 px-3 py-2 pr-9 text-xs font-medium text-gray-700 shadow-xs outline-none transition-colors focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100",children:l.map(z=>a.jsx("option",{value:z.id,children:z.name},z.id))}),a.jsx(Ps,{size:12,className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"})]}),a.jsx("div",{className:"text-xs text-gray-400 truncate w-full text-right",title:c?.model_name||"",children:c?`${c.model_name}`:E==="zh"?"未配置提供商":"No Provider"})]})]})}),l.length===0&&a.jsxs("div",{className:"mx-4 mt-3 p-3 bg-amber-50 border border-amber-200/80 rounded-xl text-xs text-amber-900 flex items-start gap-2 shadow-xs shrink-0",children:[a.jsx($i,{size:15,className:"shrink-0 text-amber-600 mt-0.5"}),a.jsxs("div",{className:"flex-1 leading-relaxed",children:[a.jsx("span",{className:"font-semibold",children:E==="zh"?"未配置 AI 提供商":"No AI Provider Configured"}),a.jsx("p",{className:"mt-0.5 text-amber-700",children:E==="zh"?"请前往「系统管理 -> AI 提供商管理」添加大模型服务(如 DeepSeek、Qwen、OpenAI 等)。":'Please configure an AI provider in "System Management -> AI Provider Management" to use the AI assistant.'})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[u.map((z,D)=>a.jsx("div",{className:`flex flex-col ${z.role==="user"?"items-end":"items-start"}`,children:a.jsx("div",{className:`px-4 py-2.5 rounded-2xl max-w-[85%] text-xs whitespace-pre-wrap ${z.role==="user"?"bg-indigo-600 text-white rounded-br-none":"bg-gray-100 text-gray-800 rounded-bl-none"}`,children:z.content})},D)),d&&a.jsx("div",{className:"flex items-start",children:a.jsxs("div",{className:"px-4 py-2.5 rounded-2xl max-w-[85%] text-xs bg-gray-100 text-gray-500 rounded-bl-none flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce"}),a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.1s"}}),a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce",style:{animationDelay:"0.2s"}})]})}),a.jsx("div",{ref:k})]}),a.jsxs("form",{onSubmit:f,className:"p-3 border-t border-gray-100 bg-white shrink-0 font-sans",onDragOver:z=>z.preventDefault(),onDrop:w,children:[g.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1 mb-2 px-1",children:g.map((z,D)=>a.jsxs("div",{className:"flex items-center gap-1 bg-indigo-50 border border-indigo-100 text-indigo-700 px-2 py-0.5 rounded-full text-xs",children:[a.jsx(Rl,{size:10,className:"shrink-0"}),a.jsx("span",{className:"truncate max-w-[100px]",title:z.name,children:z.name}),a.jsx("button",{type:"button",onClick:()=>y(F=>F.filter((_,A)=>A!==D)),className:"hover:bg-indigo-200 rounded-full p-0.5 cursor-pointer ml-0.5 transition-colors text-indigo-400 hover:text-indigo-600",children:a.jsx(ot,{size:10})})]},D))}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsxs("label",{className:"p-1 px-1.5 text-gray-500 hover:text-indigo-600 rounded-full hover:bg-gray-100 cursor-pointer transition-colors shrink-0",children:[a.jsx(np,{size:14}),a.jsx("input",{type:"file",multiple:!0,className:"hidden",onChange:C,accept:".csv,.txt,.json,.md"})]}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:"text",value:h,disabled:l.length===0,onChange:z=>m(z.target.value),placeholder:l.length===0?E==="zh"?"请先配置 AI 提供商":"Please configure AI provider first":I.placeholder,className:"w-full bg-gray-50 border border-gray-200 rounded-full pl-4 pr-10 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all disabled:opacity-60 disabled:cursor-not-allowed"}),a.jsx("button",{type:"submit",disabled:d||!h.trim()||l.length===0,className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 bg-indigo-600 text-white rounded-full hover:bg-indigo-700 disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed",children:a.jsx(sp,{size:10})})]})]})]})]}):a.jsxs("div",{className:"flex-1 flex flex-col bg-black text-green-400 font-mono text-xs min-h-0 mx-4 mb-4 rounded-xl shadow-inner border border-gray-800 overflow-hidden",children:[a.jsx("div",{className:"p-3 border-b border-gray-800 flex items-center justify-between shrink-0 bg-gray-900",children:a.jsxs("div",{className:"flex items-center gap-2 text-gray-300 font-sans tracking-wide",children:[a.jsx(ls,{size:14}),a.jsx("span",{className:"text-xs",children:I.eventStream})]})}),a.jsx("div",{className:"p-3 overflow-y-auto flex-1 flex flex-col gap-1 select-text",children:S.length===0?a.jsx("div",{className:"text-gray-600 italic",children:"Waiting for events..."}):S.map((z,D)=>a.jsxs("div",{className:"flex flex-col gap-1 hover:bg-gray-800/50 p-2 rounded mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[a.jsxs("span",{className:"text-gray-500 shrink-0 text-xs",children:["[",new Date(z.timestamp).toLocaleTimeString(),"]"]}),a.jsx("span",{className:"text-blue-400 shrink-0 truncate text-xs",title:z.source,children:z.source})]}),a.jsx("div",{className:"text-green-300 font-bold",children:z.type}),a.jsx("div",{className:"text-gray-400 break-words mt-1 leading-tight",children:z.payload})]},D))})]})]}):a.jsxs("div",{className:"flex flex-col items-center py-6 h-full text-gray-400 w-full",onClick:()=>t(!0),children:[a.jsx(zr,{size:18,className:"mb-6 hover:text-indigo-500"}),a.jsx(ls,{size:18,className:"hover:text-indigo-500"}),a.jsx("div",{className:"mt-8 flex-1 flex flex-col justify-end pb-8",children:a.jsx("div",{className:"uppercase tracking-widest text-xs rotate-180",style:{writingMode:"vertical-rl"},children:"OS Core Options"})})]})})}const cw=p.lazy(()=>Ie(()=>import("./ImportModal-ChLAX_xg.js"),[]).then(e=>({default:e.ImportModal}))),uw=p.lazy(()=>Ie(()=>import("./CourseWizardModal-1F_Ksxgf.js"),[]).then(e=>({default:e.CourseWizardModal}))),dw=p.lazy(()=>Ie(()=>import("./ImportLessonsModal-xjfRYYa0.js"),[]).then(e=>({default:e.ImportLessonsModal}))),hw=p.lazy(()=>Ie(()=>import("./QuizGeneratorModal-Bul00fIH.js"),[]).then(e=>({default:e.QuizGeneratorModal}))),fw=p.lazy(()=>Ie(()=>import("./StudentPreviewModal-CnWC2qso.js"),[]).then(e=>({default:e.StudentPreviewModal}))),pw=p.lazy(()=>Ie(()=>import("./ProcessLogsModal-uJqQQFyw.js"),[]).then(e=>({default:e.ProcessLogsModal}))),mw=p.lazy(()=>Ie(()=>import("./CloudDriveModal-BHWCchwE.js"),[]).then(e=>({default:e.CloudDriveModal}))),gw=p.lazy(()=>Ie(()=>import("./SystemResourceLibraryModal-CiRD12Rw.js"),[]).then(e=>({default:e.SystemResourceLibraryModal}))),xw=p.lazy(()=>Ie(()=>import("./BatchPickerModal-BQ_vsb5h.js"),[]).then(e=>({default:e.BatchPickerModal}))),yw=p.lazy(()=>Ie(()=>import("./ExportWeightModal-B2wHglNt.js"),[]).then(e=>({default:e.ExportWeightModal}))),bw=p.lazy(()=>Ie(()=>import("./NotificationDetailModal-CI4IfD2v.js"),[]).then(e=>({default:e.NotificationDetailModal}))),ww=p.lazy(()=>Ie(()=>import("./HelpTour-C3G0EsYT.js"),[]).then(e=>({default:e.HelpTour}))),Sw=p.lazy(()=>Ie(()=>import("./CoursewareHubPanel-B0JwbcQz.js"),[]).then(e=>({default:e.CoursewareHubPanel})));function vw(e){const{lang:t,t:n,showImportModal:s=!1,setShowImportModal:r=()=>{},handleImportFile:i=()=>{},importError:o=null,importSuccess:l=null,isImporting:c=!1,downloadCSVTemplate:u=()=>{},addToast:d=()=>{},generateTemplateContent:h=()=>"",isImportLessonsOpen:m=!1,setIsImportLessonsOpen:f=()=>{},importStatus:g="idle",setIsDraggingImport:y=()=>{},handleCSVFileChange:C=()=>{},downloadCsvTemplate:w=()=>{},isDraggingImport:N=!1,previewImportData:S=[],setPreviewImportData:E=()=>{},setImportStatus:I=()=>{},importProgress:k=0,importProgressTotal:z=0,importErrorMsg:D="",setImportErrorMsg:F=()=>{},handleCSVImportSubmit:_=()=>{},lessons:A=[],fetchClassDashboard:L=()=>{},isLessonPreviewVisible:O=!1,setIsLessonPreviewVisible:R=()=>{},selectedLesson:P=null,previewFullscreenPanel:T="none",setPreviewFullscreenPanel:W=()=>{},previewLessonTab:j="whiteboard",setPreviewLessonTab:$=()=>{},activeRole:x="teacher",elements:oe=[],activeSegmentId:pe=null,setActiveSegmentId:b=()=>{},fetchElements:J=()=>{},currentVfsParent:U=null,setCurrentVfsParent:Q=()=>{},vfsNodes:re=[],previewSelectedCourseware:se=null,setPreviewSelectedCourseware:we=()=>{},showProcessLogs:me=null,setShowProcessLogs:le=()=>{},processLogsContent:Ve="",isCloudDriveOpen:wt=!1,setIsCloudDriveOpen:Ft=()=>{},cloudDrivePreviewNode:St=null,setCloudDrivePreviewNode:vt=()=>{},isSystemResourceLibraryOpen:_t=!1,setIsSystemResourceLibraryOpen:Y=()=>{},systemResourceTab:te="system",setSystemResourceTab:ae=()=>{},selectedLibraryResourceId:je=null,setSelectedLibraryResourceId:Ue=()=>{},loadingLibraryResources:He=!1,libraryResources:ct=[],fetchLibraryResources:Ne=()=>{},classes:M=[],expandedClassId:H=null,isExportWeightModalOpen:K=!1,setIsExportWeightModalOpen:Z=()=>{},quizzesWeight:X=40,setQuizzesWeight:Pe=()=>{},assignmentsWeight:Ze=60,setAssignmentsWeight:Fe=()=>{},handleQuizzesWeightChange:tt=()=>{},handleAssignmentsWeightChange:ut=()=>{},customCategoryOverrides:ge={},setCustomCategoryOverrides:nt=()=>{},classDashboardMap:_e={},exportClassId:Fs="",exportClassName:Dn="",csvPreviewData:Bs=null,handleExportGrades:Ct=()=>{},setSelectedAssignment:Bt=()=>{},setStudentViewStatus:ln=()=>{},setQuizStudentAnswers:$s=()=>{},setSubAssignmentTab:Vs=()=>{},isTourOpen:Us=!1,setIsTourOpen:Hs=()=>{},handleSeedSuccess:qs=()=>{},setTeacherTab:Ws=()=>{},showCoursewareHub:Gs=!1,setShowCoursewareHub:Qs=()=>{}}=e,Ce=e.courseWizard,Js=Ce?.isCourseWizardOpen??e.isCourseWizardOpen??!1,Zs=Ce?.setIsCourseWizardOpen??e.setIsCourseWizardOpen??(()=>{}),Ys=Ce?.wizardStep??e.wizardStep??1,cn=Ce?.setWizardStep??e.setWizardStep??(()=>{}),un=Ce?.wizardIsSubmitting??e.wizardIsSubmitting??!1,Fn=Ce?.wizardCourseTitle??e.wizardCourseTitle??"",Ks=Ce?.setWizardCourseTitle??e.setWizardCourseTitle??(()=>{}),$t=Ce?.wizardCourseDescription??e.wizardCourseDescription??"",Xs=Ce?.setWizardCourseDescription??e.setWizardCourseDescription??(()=>{}),Re=Ce?.wizardCourseCategory??e.wizardCourseCategory??"",Bn=Ce?.setWizardCourseCategory??e.setWizardCourseCategory??(()=>{}),er=Ce?.wizardCourseTimeline??e.wizardCourseTimeline??[],$n=Ce?.setWizardCourseTimeline??e.setWizardCourseTimeline??(()=>{}),tr=Ce?.wizardCourseContent??e.wizardCourseContent??"",Vt=Ce?.setWizardCourseContent??e.setWizardCourseContent??(()=>{}),nr=Ce?.handleDeployWizardCourse??e.handleDeployWizardCourse??(()=>{}),xe=e.quizGenerator,sr=xe?.isQuizGeneratorOpen??e.isQuizGeneratorOpen??!1,rr=xe?.setIsQuizGeneratorOpen??e.setIsQuizGeneratorOpen??(()=>{}),ir=xe?.quizGenMode??e.quizGenMode??"scan_lesson",or=xe?.setQuizGenMode??e.setQuizGenMode??(()=>{}),ar=xe?.quizGenSelectedLessonId??e.quizGenSelectedLessonId??"",lr=xe?.setQuizGenSelectedLessonId??e.setQuizGenSelectedLessonId??(()=>{}),cr=xe?.quizGenTopic??e.quizGenTopic??"",ur=xe?.setQuizGenTopic??e.setQuizGenTopic??(()=>{}),Lt=xe?.isGeneratingSuggestions??e.isGeneratingSuggestions??!1,dr=xe?.setIsGeneratingSuggestions??e.setIsGeneratingSuggestions??(()=>{}),hr=xe?.suggestedObjectives??e.suggestedObjectives??[],fr=xe?.setSuggestedObjectives??e.setSuggestedObjectives??(()=>{}),Vn=xe?.suggestedQuestions??e.suggestedQuestions??[],Un=xe?.setSuggestedQuestions??e.setSuggestedQuestions??(()=>{}),pr=xe?.quizGenTimeLimit??e.quizGenTimeLimit??0,mr=xe?.setQuizGenTimeLimit??e.setQuizGenTimeLimit??(()=>{}),Hn=xe?.savingQuiz??e.savingQuiz??!1,dn=xe?.setSavingQuiz??e.setSavingQuiz??(()=>{}),hn=xe?.quizGeneratorClassId??e.quizGeneratorClassId??null,Ye=e.classBatch,gr=Ye?.batchPicker??e.batchPicker??null,ye=Ye?.setBatchPicker??e.setBatchPicker??(()=>{}),Rt=Ye?.batchPickerLesson??e.batchPickerLesson??"",qn=Ye?.setBatchPickerLesson??e.setBatchPickerLesson??(()=>{}),Wn=Ye?.batchPickerDate??e.batchPickerDate??"",Le=Ye?.setBatchPickerDate??e.setBatchPickerDate??(()=>{}),dt=Ye?.batchPickerTargetClass??e.batchPickerTargetClass??"",xr=Ye?.setBatchPickerTargetClass??e.setBatchPickerTargetClass??(()=>{}),yr=Ye?.confirmBatchPicker??e.confirmBatchPicker??(()=>{}),Gn=e.studentNotificationsHook,Ut=Gn?.selectedNotificationForModal??e.selectedNotificationForModal??null,br=Gn?.setSelectedNotificationForModal??e.setSelectedNotificationForModal??(()=>{});return a.jsxs(p.Suspense,{fallback:null,children:[a.jsx(cw,{show:s,onClose:()=>r(!1),lang:t,handleImportFile:i,importError:o,importSuccess:l,isImporting:c,downloadCSVTemplate:u}),a.jsx(uw,{isCourseWizardOpen:Js,setIsCourseWizardOpen:Zs,lang:t,wizardStep:Ys,setWizardStep:cn,wizardIsSubmitting:un,wizardCourseTitle:Fn,setWizardCourseTitle:Ks,wizardCourseDescription:$t,setWizardCourseDescription:Xs,wizardCourseCategory:Re,setWizardCourseCategory:Bn,wizardCourseTimeline:er,setWizardCourseTimeline:$n,wizardCourseContent:tr,setWizardCourseContent:Vt,addToast:d,generateTemplateContent:h,handleDeployWizardCourse:nr}),a.jsx(dw,{isImportLessonsOpen:m,setIsImportLessonsOpen:f,lang:t,importStatus:g,setIsDraggingImport:y,handleCSVFileChange:C,downloadCsvTemplate:w,isDraggingImport:N,previewImportData:S,setPreviewImportData:E,setImportStatus:I,importProgress:k,importProgressTotal:z,importErrorMsg:D,setImportErrorMsg:F,handleCSVImportSubmit:_}),a.jsx(hw,{isQuizGeneratorOpen:sr,setIsQuizGeneratorOpen:rr,lessons:A,quizGenMode:ir,setQuizGenMode:or,quizGenSelectedLessonId:ar,setQuizGenSelectedLessonId:lr,quizGenTopic:cr,setQuizGenTopic:ur,isGeneratingSuggestions:Lt,setIsGeneratingSuggestions:dr,suggestedObjectives:hr,setSuggestedObjectives:fr,suggestedQuestions:Vn,setSuggestedQuestions:Un,quizGenTimeLimit:pr,setQuizGenTimeLimit:mr,savingQuiz:Hn,setSavingQuiz:dn,quizGeneratorClassId:hn,fetchClassDashboard:L}),a.jsx(fw,{isLessonPreviewVisible:O,setIsLessonPreviewVisible:R,lessons:A,selectedLesson:P,previewFullscreenPanel:T,setPreviewFullscreenPanel:W,previewLessonTab:j,setPreviewLessonTab:$,activeRole:x,elements:oe,activeSegmentId:pe,setActiveSegmentId:b,fetchElements:J,currentVfsParent:U,setCurrentVfsParent:Q,vfsNodes:re,previewSelectedCourseware:se,setPreviewSelectedCourseware:we}),a.jsx(pw,{showProcessLogs:me,setShowProcessLogs:le,processLogsContent:Ve,t:n}),a.jsx(mw,{isOpen:wt,onClose:()=>Ft(!1),vfsNodes:re,currentVfsParent:U,setCurrentVfsParent:Q,cloudDrivePreviewNode:St,setCloudDrivePreviewNode:vt}),a.jsx(gw,{isSystemResourceLibraryOpen:_t,setIsSystemResourceLibraryOpen:Y,lang:t,systemResourceTab:te,setSystemResourceTab:ae,selectedLibraryResourceId:je,setSelectedLibraryResourceId:Ue,vfsNodes:re,currentVfsParent:U,setCurrentVfsParent:Q,cloudDrivePreviewNode:St,setCloudDrivePreviewNode:vt,loadingLibraryResources:He,libraryResources:ct,fetchLibraryResources:Ne}),a.jsx(xw,{batchPicker:gr,setBatchPicker:ye,batchPickerLesson:Rt,setBatchPickerLesson:qn,batchPickerDate:Wn,setBatchPickerDate:Le,batchPickerTargetClass:dt,setBatchPickerTargetClass:xr,lessons:A,classes:M,expandedClassId:H,confirmBatchPicker:yr,lang:t}),a.jsx(yw,{isExportWeightModalOpen:K,setIsExportWeightModalOpen:Z,lang:t,quizzesWeight:X,setQuizzesWeight:Pe,assignmentsWeight:Ze,setAssignmentsWeight:Fe,handleQuizzesWeightChange:tt,handleAssignmentsWeightChange:ut,customCategoryOverrides:ge,setCustomCategoryOverrides:nt,classDashboardMap:_e,exportClassId:Fs,exportClassName:Dn,csvPreviewData:Bs,handleExportGrades:Ct}),a.jsx(bw,{notification:Ut,onClose:()=>br(null),lang:t,onOpenWorkspace:ht=>{Bt(ht),ln("assignment"),$s({}),Vs("quiz")}}),a.jsx(ww,{isOpen:Us,onClose:()=>Hs(!1),lang:t,onSeedSuccess:qs,onJumpTab:ht=>Ws(ht)}),Gs&&a.jsx(Sw,{onClose:()=>Qs(!1),lang:t})]})}const Cw=["whiteboard.","courseware.","quiz.","rollcall."];class kw{constructor(){this.handlers=new Map}setSocketBridge(t){this.socketBridge=t}hasSocketBridge(){return!!this.socketBridge}subscribe(t,n){return this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(n),()=>{this.handlers.get(t)?.delete(n)}}async publish(t){const n=this.handlers.get(t.type);if(n)for(const s of n)try{s(t)}catch(r){console.error("[FrontendEventBus] handler error:",r)}this.socketBridge&&Cw.some(s=>t.type.startsWith(s))&&this.socketBridge(t)}}const Ew=new kw;async function qc(e){const t=e.data;if(!t||typeof t!="object")return;if(typeof window<"u"&&typeof document<"u"&&e.source)try{if(!Array.from(document.querySelectorAll("iframe")).some(u=>u.contentWindow===e.source)&&e.source!==window)return}catch{}let n=t.attempt_id;const s=t.type||"",r=t.payload||t;if(!n&&e.source)try{const l=Array.from(document.querySelectorAll("iframe")).find(c=>c.contentWindow===e.source);if(l&&l.contentWindow){const c=l.contentWindow;c.__LMS_STUDENT__?.attempt_id&&(n=c.__LMS_STUDENT__.attempt_id)}}catch{}if(!n||typeof n!="string")return;if(s==="LMS_CONFIG"){rs("courseware.config_reported",n,t.config??r);return}if(s==="LMS_GET_PROGRESS"){const l=t.requestId,c=e.source;if(l&&c&&typeof c.postMessage=="function"){if(typeof document<"u"&&!Array.from(document.querySelectorAll("iframe")).some(f=>f.contentWindow===c)&&c!==window){console.warn("[LMS Bridge Security] Dropping response to untrusted window");return}let u;try{u=(await(await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/progress`)).json()).progress??null}catch{u=null}const d=e.origin&&e.origin!=="null"?e.origin:"*";c.postMessage({type:"LMS_PROGRESS_RESPONSE",requestId:l,progress:u},d)}return}const i=s==="LMS_SUBMIT"||s==="LMS_FINISH"||s==="submit"||s==="finish"||s==="completed"||r&&typeof r=="object"&&(r.score!==void 0||r.grade!==void 0||r.result!==void 0||r.points!==void 0),o=s==="LMS_SAVE_PROGRESS"||s==="saveProgress";if(i){rs("courseware.submitted",n,r);try{await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:r?.score??r?.grade??r?.result??r?.points??void 0,comment:r?.comment??r?.feedback??r?.note??void 0,completion:r?.completion??1,status:"submitted",extra:r})})}catch(l){console.error("[LMS Bridge] Failed to submit attempt data to backend:",l)}}else if(o){rs("courseware.progress_saved",n,r);try{await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:r?.score??r?.grade??r?.result??r?.points??void 0,comment:r?.comment??r?.feedback??void 0,completion:r?.completion??void 0,status:"inprogress",extra:r})})}catch(l){console.error("[LMS Bridge] Failed to save progress to backend:",l)}}else{rs("courseware.event_logged",n,r);try{await fetch(`/api/courseware/attempts/${encodeURIComponent(n)}/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventType:s||"log",payload:r})})}catch(l){console.error("[LMS Bridge] Failed to log event to backend:",l)}}}function rs(e,t,n){Ew.publish({id:Dp(),type:e,source:"courseware-bridge",payload:{attemptId:t,data:n},timestamp:Date.now(),correlationId:t})}function jw(e,t,n,s){try{let r=s;if(!r&&e.src&&typeof window<"u")try{const i=new URL(e.src,window.location.href);i.origin&&i.origin!=="null"&&!e.src.startsWith("blob:")&&!e.src.startsWith("data:")&&(r=i.origin)}catch{}e.contentWindow?.postMessage({type:"LMS_HOST_COMMAND",event:t,payload:n},r||"*")}catch{}}function Wc(e){p.useEffect(()=>{if(!e)return;const t=n=>{qc(n)};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}},[e])}function Gc(e,t={}){if(!(typeof document>"u"))try{document.querySelectorAll("iframe").forEach(s=>{try{s.contentWindow?.postMessage({type:"LMS_HOST_COMMAND",event:"theme:changed",payload:{theme:e,tokens:t}},"*"),s.contentWindow?.postMessage({type:"LMS_THEME_CHANGED",theme:e,tokens:t},"*")}catch{}})}catch{}}function Qc(e){if(!(typeof document>"u"))try{const t=Math.min(140,Math.max(85,Math.round(e)));document.querySelectorAll("iframe").forEach(s=>{try{s.contentWindow?.postMessage({type:"LMS_HOST_COMMAND",event:"font-scale:changed",payload:{scale:t,fontScale:(t/100).toFixed(2)}},"*"),s.contentWindow?.postMessage({type:"LMS_FONT_SCALE_CHANGED",scale:t,fontScale:(t/100).toFixed(2)},"*")}catch{}})}catch{}}const Jc=Object.freeze(Object.defineProperty({__proto__:null,broadcastFontScaleToIframes:Qc,broadcastThemeToIframes:Gc,processLmsMessage:qc,sendCommandToCourseware:jw,useLmsBridge:Wc},Symbol.toStringTag,{value:"Module"}));function Nw(e){const{session:t,showProcessLogs:n,activeStudentId:s,currentVfsParent:r,selectedLesson:i,selectedAssignment:o,expandedClassId:l,fetchLessons:c,fetchPlugins:u,fetchRegisteredCommands:d,fetchEvents:h,fetchApprovals:m,fetchProcesses:f,fetchClasses:g,fetchTodaySchedules:y,fetchStudents:C,fetchLabs:w,fetchVfs:N,fetchProcessLogs:S,fetchClassStudents:E,fetchElements:I}=e,k=p.useRef(r),z=p.useRef(i),D=p.useRef(o),F=p.useRef(l);p.useEffect(()=>{k.current=r},[r]),p.useEffect(()=>{z.current=i},[i]),p.useEffect(()=>{D.current=o},[o]),p.useEffect(()=>{F.current=l},[l]),p.useEffect(()=>{if(!t)return;const _=t.role==="student",A=t.role==="teacher",L=A&&(t.subRole==="administrator"||t.username==="admin"||t.userId==="usr_admin");c(),u(),d(),y().catch(()=>{}),L&&(h(),m(),f()),A?(g(),C(),w(),N(k.current)):_&&k.current&&N(k.current);let O=!1;const R=setInterval(async()=>{if(!O){O=!0;try{if(L&&(await h(),await m(),await f(),n&&await S(n)),await c(),await d(),await y().catch(()=>{}),A&&(await g(),await C(),await w(),await N(k.current),F.current&&await E(F.current)),z.current&&await I(z.current),D.current){const P=s||D.current.student_id;await I(`assignment-${D.current.id}-student-${P}`)}}finally{O=!1}}},2e3);return()=>clearInterval(R)},[t,n,s]),p.useEffect(()=>{t&&(t.role==="teacher"||r)&&N(r)},[r,t]),p.useEffect(()=>{i&&I(i)},[i])}function Pw(e){const{lang:t,t:n,selectedLesson:s,effectiveAgentProviderId:r,expandedClassId:i,fetchLessons:o,fetchClasses:l,fetchStudents:c,fetchClassStudents:u,fetchClassProgress:d,fetchClassDashboard:h,fetchElements:m}=e,[f,g]=p.useState([{role:"agent",content:n.agentIntro||""}]),[y,C]=p.useState(""),[w,N]=p.useState(!1),[S,E]=p.useState([]);p.useEffect(()=>{f.length===1&&f[0].role==="agent"&&g([{role:"agent",content:n.agentIntro}])},[t,n.agentIntro]);const I=p.useCallback(async _=>{try{const A=await fetch(`/api/agent/conversations?lessonId=${encodeURIComponent(_||"")}`);if(!A.ok)return;const L=await A.json(),O=Array.isArray(L.messages)?L.messages:[];O.length>0?g(O.map(R=>({role:R.role==="assistant"?"agent":"user",content:R.content}))):g([{role:"agent",content:n.agentIntro}])}catch{}},[n.agentIntro]),k=p.useCallback(async()=>{try{await fetch(`/api/agent/conversations?lessonId=${encodeURIComponent(s||"")}`,{method:"DELETE"})}catch{}g([{role:"agent",content:n.agentIntro}])},[s,n.agentIntro]);return p.useEffect(()=>{I(s)},[s,I]),{chatLog:f,setChatLog:g,input:y,setInput:C,loading:w,setLoading:N,chatAttachments:S,setChatAttachments:E,handleChatFileChange:_=>{_.target.files&&Array.from(_.target.files).forEach(A=>{const L=new FileReader;L.onload=O=>{O.target?.result&&E(R=>[...R,{name:A.name,content:O.target.result}])},A.name.endsWith(".zip")?L.readAsDataURL(A):L.readAsText(A)})},handleChatDrop:_=>{_.preventDefault(),_.dataTransfer.files&&Array.from(_.dataTransfer.files).forEach(A=>{const L=new FileReader;L.onload=O=>{O.target?.result&&E(R=>[...R,{name:A.name,content:O.target.result}])},A.name.endsWith(".zip")?L.readAsDataURL(A):L.readAsText(A)})},handleSend:async _=>{if(_.preventDefault(),!y.trim()||w)return;const A=[...S];let L=y;A.length>0&&(L+=`
|
|
133
|
+
(📁 ${t==="zh"?"附件":"Attachments"}: ${A.map(O=>O.name).join(", ")})`),g(O=>[...O,{role:"user",content:L}]),C(""),E([]),N(!0);try{const O=await fetch("/api/agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:y,lang:t,currentLessonId:s,attachments:A,providerId:r||null})}),R=await O.json();let P="";!O.ok||R.success===!1?P=`⚠️ ${R.message||R.error||(t==="zh"?"未知系统错误":"Unknown System Error")}`:(P=R.agentText||"",R.toolResults&&R.toolResults.length>0&&(P+=`
|
|
134
|
+
|
|
135
|
+
${n.executedCommands}`+R.toolResults.map(T=>T.callName).join(", "))),g(T=>[...T,{role:"agent",content:P}]),await o(),await l(),await c(),i&&(await u(i),await d(i),await h(i)),s&&await m(s)}catch{g(O=>[...O,{role:"agent",content:n.simulationError}])}finally{N(!1)}},handleClearAgentMemory:k,restoreAgentMemory:I}}const lt=Object.create(null);lt.open="0";lt.close="1";lt.ping="2";lt.pong="3";lt.message="4";lt.upgrade="5";lt.noop="6";const fs=Object.create(null);Object.keys(lt).forEach(e=>{fs[lt[e]]=e});const Ii={type:"error",data:"parser error"},Zc=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Yc=typeof ArrayBuffer=="function",Kc=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,uo=({type:e,data:t},n,s)=>Zc&&t instanceof Blob?n?s(t):xl(t,s):Yc&&(t instanceof ArrayBuffer||Kc(t))?n?s(t):xl(new Blob([t]),s):s(lt[e]+(t||"")),xl=(e,t)=>{const n=new FileReader;return n.onload=function(){const s=n.result.split(",")[1];t("b"+(s||""))},n.readAsDataURL(e)};function yl(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let oi;function Tw(e,t){if(Zc&&e.data instanceof Blob)return e.data.arrayBuffer().then(yl).then(t);if(Yc&&(e.data instanceof ArrayBuffer||Kc(e.data)))return t(yl(e.data));uo(e,!1,n=>{oi||(oi=new TextEncoder),t(oi.encode(n))})}const bl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",kn=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<bl.length;e++)kn[bl.charCodeAt(e)]=e;const Iw=e=>{let t=e.length*.75,n=e.length,s,r=0,i,o,l,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),d=new Uint8Array(u);for(s=0;s<n;s+=4)i=kn[e.charCodeAt(s)],o=kn[e.charCodeAt(s+1)],l=kn[e.charCodeAt(s+2)],c=kn[e.charCodeAt(s+3)],d[r++]=i<<2|o>>4,d[r++]=(o&15)<<4|l>>2,d[r++]=(l&3)<<6|c&63;return u},Aw=typeof ArrayBuffer=="function",ho=(e,t)=>{if(typeof e!="string")return{type:"message",data:Xc(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:zw(e.substring(1),t)}:fs[n]?e.length>1?{type:fs[n],data:e.substring(1)}:{type:fs[n]}:Ii},zw=(e,t)=>{if(Aw){const n=Iw(e);return Xc(n,t)}else return{base64:!0,data:e}},Xc=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},eu="",_w=(e,t)=>{const n=e.length,s=new Array(n);let r=0;e.forEach((i,o)=>{uo(i,!1,l=>{s[o]=l,++r===n&&t(s.join(eu))})})},Lw=(e,t)=>{const n=e.split(eu),s=[];for(let r=0;r<n.length;r++){const i=ho(n[r],t);if(s.push(i),i.type==="error")break}return s};function Rw(){return new TransformStream({transform(e,t){Tw(e,n=>{const s=n.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const i=new DataView(r.buffer);i.setUint8(0,126),i.setUint16(1,s)}else{r=new Uint8Array(9);const i=new DataView(r.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(s))}e.data&&typeof e.data!="string"&&(r[0]|=128),t.enqueue(r),t.enqueue(n)})}})}let ai;function is(e){return e.reduce((t,n)=>t+n.length,0)}function os(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let s=0;for(let r=0;r<t;r++)n[r]=e[0][s++],s===e[0].length&&(e.shift(),s=0);return e.length&&s<e[0].length&&(e[0]=e[0].slice(s)),n}function Mw(e,t){ai||(ai=new TextDecoder);const n=[];let s=0,r=-1,i=!1;return new TransformStream({transform(o,l){for(n.push(o);;){if(s===0){if(is(n)<1)break;const c=os(n,1);i=(c[0]&128)===128,r=c[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(is(n)<2)break;const c=os(n,2);r=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),s=3}else if(s===2){if(is(n)<8)break;const c=os(n,8),u=new DataView(c.buffer,c.byteOffset,c.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){l.enqueue(Ii);break}r=d*Math.pow(2,32)+u.getUint32(4),s=3}else{if(is(n)<r)break;const c=os(n,r);l.enqueue(ho(i?c:ai.decode(c),t)),s=0}if(r===0||r>e){l.enqueue(Ii);break}}}})}const tu=4;function ve(e){if(e)return Ow(e)}function Ow(e){for(var t in ve.prototype)e[t]=ve.prototype[t];return e}ve.prototype.on=ve.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};ve.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};ve.prototype.off=ve.prototype.removeListener=ve.prototype.removeAllListeners=ve.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var s,r=0;r<n.length;r++)if(s=n[r],s===t||s.fn===t){n.splice(r,1);break}return n.length===0&&delete this._callbacks["$"+e],this};ve.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(n){n=n.slice(0);for(var s=0,r=n.length;s<r;++s)n[s].apply(this,t)}return this};ve.prototype.emitReserved=ve.prototype.emit;ve.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};ve.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Os=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Qe=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Dw="arraybuffer";function nu(e,...t){return t.reduce((n,s)=>(e.hasOwnProperty(s)&&(n[s]=e[s]),n),{})}const Fw=Qe.setTimeout,Bw=Qe.clearTimeout;function Ds(e,t){t.useNativeTimers?(e.setTimeoutFn=Fw.bind(Qe),e.clearTimeoutFn=Bw.bind(Qe)):(e.setTimeoutFn=Qe.setTimeout.bind(Qe),e.clearTimeoutFn=Qe.clearTimeout.bind(Qe))}const $w=1.33;function Vw(e){return typeof e=="string"?Uw(e):Math.ceil((e.byteLength||e.size)*$w)}function Uw(e){let t=0,n=0;for(let s=0,r=e.length;s<r;s++)t=e.charCodeAt(s),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(s++,n+=4);return n}function su(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Hw(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function qw(e){let t={},n=e.split("&");for(let s=0,r=n.length;s<r;s++){let i=n[s].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class Ww extends Error{constructor(t,n,s){super(t),this.description=n,this.context=s,this.type="TransportError"}}class fo extends ve{constructor(t){super(),this.writable=!1,Ds(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,s){return super.emitReserved("error",new Ww(t,n,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=ho(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=Hw(t);return n.length?"?"+n:""}}class Gw extends fo{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||n()})),this.writable||(s++,this.once("drain",function(){--s||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};Lw(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,_w(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=su()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let ru=!1;try{ru=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Qw=ru;function Jw(){}class Zw extends Gw{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let s=location.port;s||(s=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||s!==t.port}}doWrite(t,n){const s=this.request({method:"POST",data:t});s.on("success",n),s.on("error",(r,i)=>{this.onError("xhr post error",r,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,s)=>{this.onError("xhr poll error",n,s)}),this.pollXhr=t}}let sn=class ps extends ve{constructor(t,n,s){super(),this.createRequest=t,Ds(this,s),this._opts=s,this._method=s.method||"GET",this._uri=n,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var t;const n=nu(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(n);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&s.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var r;s.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=ps.requestsCount++,ps.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Jw,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete ps.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};sn.requestsCount=0;sn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",wl);else if(typeof addEventListener=="function"){const e="onpagehide"in Qe?"pagehide":"unload";addEventListener(e,wl,!1)}}function wl(){for(let e in sn.requests)sn.requests.hasOwnProperty(e)&&sn.requests[e].abort()}const Yw=(function(){const e=iu({xdomain:!1});return e&&e.responseType!==null})();class Kw extends Zw{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Yw&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new sn(iu,this.uri(),t)}}function iu(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Qw))return new XMLHttpRequest}catch{}if(!t)try{return new Qe[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ou=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Xw extends fo{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,s=ou?{}:nu(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const s=t[n],r=n===t.length-1;uo(s,this.supportsBinary,i=>{try{this.doWrite(s,i)}catch{}r&&Os(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=su()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const li=Qe.WebSocket||Qe.MozWebSocket;class eS extends Xw{createSocket(t,n,s){return ou?new li(t,n,s):n?new li(t,n):new li(t)}doWrite(t,n){this.ws.send(n)}}class tS extends fo{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=Mw(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(n).getReader(),r=Rw();r.readable.pipeTo(t.writable),this._writer=r.writable.getWriter();const i=()=>{s.read().then(({done:l,value:c})=>{l||(this.onPacket(c),i())}).catch(l=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const s=t[n],r=n===t.length-1;this._writer.write(s).then(()=>{r&&Os(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const nS={websocket:eS,webtransport:tS,polling:Kw},sS=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,rS=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Ai(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),s=e.indexOf("]");n!=-1&&s!=-1&&(e=e.substring(0,n)+e.substring(n,s).replace(/:/g,";")+e.substring(s,e.length));let r=sS.exec(e||""),i={},o=14;for(;o--;)i[rS[o]]=r[o]||"";return n!=-1&&s!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=iS(i,i.path),i.queryKey=oS(i,i.query),i}function iS(e,t){const n=/\/{2,9}/g,s=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&s.splice(0,1),t.slice(-1)=="/"&&s.splice(s.length-1,1),s}function oS(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,i){r&&(n[r]=i)}),n}const zi=typeof addEventListener=="function"&&typeof removeEventListener=="function",ms=[];zi&&addEventListener("offline",()=>{ms.forEach(e=>e())},!1);class It extends ve{constructor(t,n){if(super(),this.binaryType=Dw,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const s=Ai(t);n.hostname=s.host,n.secure=s.protocol==="https"||s.protocol==="wss",n.port=s.port,s.query&&(n.query=s.query)}else n.host&&(n.hostname=Ai(n.host).host);Ds(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(s=>{const r=s.prototype.name;this.transports.push(r),this._transportsByName[r]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=qw(this.opts.query)),zi&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ms.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=tu,n.transport=t,this.id&&(n.sid=this.id);const s=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&It.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",It.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(n+=Vw(r)),s>0&&n>this._maxPayload)return this.writeBuffer.slice(0,s);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Os(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,s){return this._sendPacket("message",t,n,s),this}send(t,n,s){return this._sendPacket("message",t,n,s),this}_sendPacket(t,n,s,r){if(typeof n=="function"&&(r=n,n=void 0),typeof s=="function"&&(r=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const i={type:t,data:n,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},s=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():t()}):this.upgrading?s():t()),this}_onError(t){if(It.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),zi&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=ms.indexOf(this._offlineEventListener);s!==-1&&ms.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}It.protocol=tu;class aS extends It{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),s=!1;It.priorWebsocketSuccess=!1;const r=()=>{s||(n.send([{type:"ping",data:"probe"}]),n.once("packet",h=>{if(!s)if(h.type==="pong"&&h.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;It.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(d(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const m=new Error("probe error");m.transport=n.name,this.emitReserved("upgradeError",m)}}))};function i(){s||(s=!0,d(),n.close(),n=null)}const o=h=>{const m=new Error("probe error: "+h);m.transport=n.name,i(),this.emitReserved("upgradeError",m)};function l(){o("transport closed")}function c(){o("socket closed")}function u(h){n&&h.name!==n.name&&i()}const d=()=>{n.removeListener("open",r),n.removeListener("error",o),n.removeListener("close",l),this.off("close",c),this.off("upgrading",u)};n.once("open",r),n.once("error",o),n.once("close",l),this.once("close",c),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{s||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let s=0;s<t.length;s++)~this.transports.indexOf(t[s])&&n.push(t[s]);return n}}let lS=class extends aS{constructor(t,n={}){const s=typeof t=="object"?t:n;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>nS[r]).filter(r=>!!r)),super(t,s)}};function cS(e,t="",n){let s=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),s=Ai(e)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const i=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+i+":"+s.port+t,s.href=s.protocol+"://"+i+(n&&n.port===s.port?"":":"+s.port),s}const uS=typeof ArrayBuffer=="function",dS=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,au=Object.prototype.toString,hS=typeof Blob=="function"||typeof Blob<"u"&&au.call(Blob)==="[object BlobConstructor]",fS=typeof File=="function"||typeof File<"u"&&au.call(File)==="[object FileConstructor]";function po(e){return uS&&(e instanceof ArrayBuffer||dS(e))||hS&&e instanceof Blob||fS&&e instanceof File}function gs(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,s=e.length;n<s;n++)if(gs(e[n]))return!0;return!1}if(po(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return gs(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&gs(e[n]))return!0;return!1}function pS(e){const t=[],n=e.data,s=e;return s.data=xs(n,t),s.attachments=t.length,{packet:s,buffers:t}}function xs(e,t,n){if(!e)return e;if(po(e)){const s={_placeholder:!0,num:t.length};return t.push(e),s}else if(Array.isArray(e)){const s=new Array(e.length);for(let r=0;r<e.length;r++)s[r]=xs(e[r],t);return s}else if(typeof e=="object"&&!(e instanceof Date)){if(e.toJSON&&typeof e.toJSON=="function"&&!n)return xs(e.toJSON(),t,!0);const s={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(s[r]=xs(e[r],t));return s}return e}function mS(e,t){return e.data=_i(e.data,t),delete e.attachments,e}function _i(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=_i(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=_i(e[n],t));return e}const gS=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var ie;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(ie||(ie={}));class xS{constructor(t){this.replacer=t}encode(t){return(t.type===ie.EVENT||t.type===ie.ACK)&&gs(t)?this.encodeAsBinary({type:t.type===ie.EVENT?ie.BINARY_EVENT:ie.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===ie.BINARY_EVENT||t.type===ie.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=pS(t),s=this.encodeAsString(n.packet),r=n.buffers;return r.unshift(s),r}}class mo extends ve{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const s=n.type===ie.BINARY_EVENT;s||n.type===ie.BINARY_ACK?(n.type=s?ie.EVENT:ie.ACK,this.reconstructor=new yS(n)):super.emitReserved("decoded",n)}else if(po(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const s={type:Number(t.charAt(0))};if(ie[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===ie.BINARY_EVENT||s.type===ie.BINARY_ACK){const i=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const o=t.substring(i,n);if(o!=Number(o)||t.charAt(n)!=="-")throw new Error("Illegal attachments");const l=Number(o);if(!bS(l)||l<1)throw new Error("Illegal attachments");if(l>this.opts.maxAttachments)throw new Error("too many attachments");s.attachments=l}if(t.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););s.nsp=t.substring(i,n)}else s.nsp="/";const r=t.charAt(n+1);if(r!==""&&Number(r)==r){const i=n+1;for(;++n;){const o=t.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===t.length)break}s.id=Number(t.substring(i,n+1))}if(t.charAt(++n)){const i=this.tryParse(t.substr(n));if(mo.isPayloadValid(s.type,i))s.data=i;else throw new Error("invalid payload")}return s}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case ie.CONNECT:return Sl(n);case ie.DISCONNECT:return n===void 0;case ie.CONNECT_ERROR:return typeof n=="string"||Sl(n);case ie.EVENT:case ie.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&gS.indexOf(n[0])===-1);case ie.ACK:case ie.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class yS{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=mS(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const bS=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function Sl(e){return Object.prototype.toString.call(e)==="[object Object]"}const wS=Object.freeze(Object.defineProperty({__proto__:null,Decoder:mo,Encoder:xS,get PacketType(){return ie}},Symbol.toStringTag,{value:"Module"}));function Xe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const SS=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class lu extends ve{constructor(t,n,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Xe(t,"open",this.onopen.bind(this)),Xe(t,"packet",this.onpacket.bind(this)),Xe(t,"error",this.onerror.bind(this)),Xe(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var s,r,i;if(SS.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:ie.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const d=this.ids++,h=n.pop();this._registerAckCallback(d,h),o.id=d}const l=(r=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||r===void 0?void 0:r.writable,c=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!l||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,n){var s;const r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[t]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===t&&this.sendBuffer.splice(l,1);n.call(this,new Error("operation has timed out"))},r),o=(...l)=>{this.io.clearTimeoutFn(i),n.apply(this,l)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...n){return new Promise((s,r)=>{const i=(o,l)=>o?r(o):s(l);i.withError=!0,n.push(i),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((r,...i)=>(this._queue[0],r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(r)):(this._queue.shift(),n&&n(null,...i)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:ie.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(s=>String(s.id)===t)){const s=this.acks[t];delete this.acks[t],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case ie.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ie.EVENT:case ie.BINARY_EVENT:this.onevent(t);break;case ie.ACK:case ie.BINARY_ACK:this.onack(t);break;case ie.DISCONNECT:this.ondisconnect();break;case ie.CONNECT_ERROR:this.destroy();const s=new Error(t.data.message);s.data=t.data.data,this.emitReserved("connect_error",s);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const s of n)s.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let s=!1;return function(...r){s||(s=!0,n.packet({type:ie.ACK,id:t,data:r}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ie.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let s=0;s<n.length;s++)if(t===n[s])return n.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let s=0;s<n.length;s++)if(t===n[s])return n.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const s of n)s.apply(this,t.data)}}}function an(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}an.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-n:e+n}return Math.min(e,this.max)|0};an.prototype.reset=function(){this.attempts=0};an.prototype.setMin=function(e){this.ms=e};an.prototype.setMax=function(e){this.max=e};an.prototype.setJitter=function(e){this.jitter=e};class Li extends ve{constructor(t,n){var s;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Ds(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((s=n.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new an({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const r=n.parser||wS;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new lS(this.uri,this.opts);const n=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=Xe(n,"open",function(){s.onopen(),t&&t()}),i=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=Xe(n,"error",i);if(this._timeout!==!1){const l=this._timeout,c=this.setTimeoutFn(()=>{r(),i(new Error("timeout")),n.close()},l);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(r),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Xe(t,"ping",this.onping.bind(this)),Xe(t,"data",this.ondata.bind(this)),Xe(t,"error",this.onerror.bind(this)),Xe(t,"close",this.onclose.bind(this)),Xe(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){Os(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let s=this.nsps[t];return s?this._autoConnect&&!s.active&&s.connect():(s=new lu(this,t,n),this.nsps[t]=s),s}_destroy(t){const n=Object.keys(this.nsps);for(const s of n)if(this.nsps[s].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let s=0;s<n.length;s++)this.engine.write(n[s],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(r=>{r?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",r)):t.onreconnect()}))},n);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const vn={};function ys(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=cS(e,t.path||"/socket.io"),s=n.source,r=n.id,i=n.path,o=vn[r]&&i in vn[r].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let c;return l?c=new Li(s,t):(vn[r]||(vn[r]=new Li(s,t)),c=vn[r]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(ys,{Manager:Li,Socket:lu,io:ys,connect:ys});class vS{constructor(t=""){this.baseUrl=t}async get(t){return this.request("GET",t)}async post(t,n){return this.request("POST",t,n)}async del(t){return this.request("DELETE",t)}async request(t,n,s){try{const r=`${this.baseUrl}${n}`,i={method:t,credentials:"same-origin",headers:{"Content-Type":"application/json"}};return s!==void 0&&t!=="GET"&&t!=="DELETE"&&(i.body=JSON.stringify(s)),await(await fetch(r,i)).json()}catch(r){return{success:!1,error:r.message??"Network error"}}}}let Ri=null;function cu(e){Ri=e}function wC(){if(!Ri)throw new Error("Socket instance not initialized. Call setSocketInstance() first.");return Ri}class CS{constructor(t){this.socket=t,cu(t)}emit(t,...n){this.socket.emit(t,...n)}on(t,n){this.socket.on(t,n)}off(t,n){this.socket.off(t,n)}disconnect(){this.socket.disconnect()}}class kS{constructor(t){this.modalState=null,this.addToastFn=t??null}showToast(t,n,s="info"){this.addToastFn?this.addToastFn(t,n,s):console.warn("[UIService] No addToast callback registered — toast not shown:",t,n)}showModal(t,n){this.modalState={visible:!0,title:t,content:n}}closeModal(){this.modalState=null}getModalState(){return this.modalState}downloadFile(t,n,s="application/octet-stream"){const r=typeof t=="string"?new Blob([t],{type:s}):t,i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=n,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}}class ES{constructor(t){this.prefix=`edu_os_plugin:${t}:`}get(t){return localStorage.getItem(this.prefix+t)}set(t,n){localStorage.setItem(this.prefix+t,n)}delete(t){localStorage.removeItem(this.prefix+t)}clear(){this.prefix.length;const t=[];for(let n=0;n<localStorage.length;n++){const s=localStorage.key(n);s&&s.startsWith(this.prefix)&&t.push(s)}for(const n of t)localStorage.removeItem(n)}}function jS(e){const{session:t,host:n,activeRole:s,activeStudentId:r,selectedLesson:i,activeSegmentId:o,studentViewStatus:l,lang:c,students:u,addToast:d,setOnlineStudentIds:h,setActiveStudentLessons:m,setLessons:f,setActiveSegmentId:g,setLiveClassStudentProgress:y,setLiveClassAcknowledgedMap:C,setLiveClassFeed:w,setSelectedLesson:N,setStudentViewStatus:S,studentLessonTab:E,setStudentLessonTab:I,selectedAssignment:k,setSelectedAssignment:z,setLocalProgressPercent:D,fetchStudentDashboard:F,fetchStudents:_,fetchElements:A}=e,L=p.useRef(null),O=p.useRef(s),R=p.useRef(r),P=p.useRef(c),T=p.useRef(u),W=p.useRef(d),j=p.useRef(i),$=p.useRef(null),x=p.useRef(l),oe=p.useRef(E),pe=p.useRef(null);return p.useEffect(()=>{O.current=s},[s]),p.useEffect(()=>{R.current=r},[r]),p.useEffect(()=>{P.current=c},[c]),p.useEffect(()=>{T.current=u},[u]),p.useEffect(()=>{W.current=d},[d]),p.useEffect(()=>{j.current=i},[i]),p.useEffect(()=>{x.current=l},[l]),p.useEffect(()=>{oe.current=E},[E]),p.useEffect(()=>{$.current=k},[k]),p.useEffect(()=>{if(!t)return;const b=ys();L.current=b,cu(b),n.isInitialized()||n.initialize(new vS,new CS(b),new kS(W.current),new ES("__app__")),O.current==="student"&&R.current&&b.emit("register-student",{studentId:R.current,name:T.current.find(U=>U.id===R.current)?.name||R.current}),b.emit("join-room","whiteboard-broadcast"),b.on("presence-update",U=>{h(U.onlineStudentIds),m(U.activeStudentLessons)}),b.on("lesson-progress-mode-changed",U=>{const{lessonId:Q,progressMode:re,progressConditions:se}=U;f(we=>we.map(me=>me.id===Q?{...me,progress_mode:re,progress_conditions:se}:me))}),b.on("student-active-segment-changed",U=>{const{activeSegmentId:Q}=U;g(Q)}),b.on("student-pinged",U=>{const Q=U.message||(P.current==="zh"?"⚠️ 学习进度预警:老师注意到您的进度有些落后,请抓紧时间跟上!":"⚠️ Progress Alert: The teacher noticed you are falling behind. Please keep up!");d(P.current==="zh"?"⚠️ 学习进度预警":"⚠️ Progress Warning",Q,"warning")}),b.on("student-progress-updated",U=>{const{studentId:Q,progressPercent:re,completed:se}=U;y(we=>{const me=we.findIndex(le=>le.student_id===Q);if(me!==-1){const le=[...we];return le[me]={...le[me],progress_percent:re,completed:se?1:0},le}else return[...we,{student_id:Q,progress_percent:re,completed:se?1:0}]})}),b.on("assignment-graded-toast",U=>{if(O.current==="student"&&R.current&&U.studentId===R.current){const Q=U.assignmentTitle||U.assignmentId,re=P.current==="zh"?`您的作业"${Q}"已完成评分!得分:${U.score}%。建议反馈已收到,快去查看。`:`Your assignment "${Q}" was graded. Score: ${U.score}%. Tutoring feedback has been posted.`;d(P.current==="zh"?"🎓 作业已评分":"🎓 Assignment Graded",re,"success"),F(R.current)}}),b.on("student-picked",U=>{if(O.current==="student"&&R.current&&U.studentId===R.current){const Q=P.current==="zh"?"闪电警报!您已被老师在课程随机提问点名中抽中!请立即集中注意力参与课堂。":"Attention alert! You have been randomly picked by the teacher! Please pay immediate attention.";d(P.current==="zh"?"⚡️ 随机点名提问":"⚡️ Classroom Pick Alert",Q,"warning"),F(R.current)}w(Q=>[{id:`feed-pick-${U.studentId}-${U.pickedTime||Date.now()}`,time:new Date(U.pickedTime||Date.now()).toLocaleTimeString(),type:"picked",message:P.current==="zh"?`点名互动:随机抽中学生【${U.studentName}】。`:`Classroom Pick: Randomly selected student "${U.studentName}".`},...Q])}),b.on("student-acknowledged",U=>{const{studentId:Q}=U;C(re=>{const se=new Map(re);return se.set(Q,!0),se}),w(re=>[{id:`feed-ack-${Q}-${Date.now()}`,time:new Date().toLocaleTimeString(),type:"checkin",message:P.current==="zh"?`学生已确认收到提问点名(学生 ID: ${Q})。`:`Student acknowledged the classroom call (Student ID: ${Q}).`},...re]),_()}),b.on("class-lock-status-changed",U=>{const{lessonId:Q,locked:re}=U;O.current==="student"&&R.current?(Promise.resolve(_()).then(()=>{re&&Q&&(N(Q),S("lesson"),d(P.current==="zh"?"🔒 课程已被锁定":"🔒 Lesson Locked",P.current==="zh"?"老师已锁定当前授课,您将无法切换到其他页面。":"The teacher has locked the active lesson. You cannot leave this page.","info"))}),F(R.current)):_()}),b.on("whiteboard-sync",U=>{const{roomId:Q,type:re}=U||{};re==="refresh"&&Q&&(A(Q),!j.current&&O.current==="student"&&(N(Q),S("lesson")),b.emit("join-room",Q))});const J=()=>{tn.getState().clearRemoteFullscreen();const U=pe.current;pe.current=null,U&&(I(U.lessonTab),U.viewStatus==="assignment"&&(z(U.assignment??null),U.lessonId&&N(U.lessonId),S("assignment")))};return b.on("whiteboard-fullscreen-changed",U=>{if(O.current!=="student")return;const Q=U?.lessonId,re=U?.elementId??null;if(!re){J();return}if(!Q)return;const se=x.current;(se==="lesson"?j.current===Q:se==="assignment")&&(tn.getState().remoteFullscreenElementId||(pe.current={viewStatus:se,lessonTab:oe.current,lessonId:j.current,assignment:se==="assignment"?$.current:null}),tn.getState().setRemoteFullscreenElementId(re),se==="assignment"&&z(null),N(Q),A(Q),S("lesson"),I("whiteboard"))}),b.on("connect",()=>{J()}),()=>{b.disconnect(),L.current=null}},[t,s,r]),p.useEffect(()=>{L.current&&s==="student"&&r&&(l==="lesson"&&i?(L.current.emit("enter-lesson",{studentId:r,lessonId:i}),fetch(`/api/students/${r}/progress`).then(b=>b.json()).then(b=>{if(Array.isArray(b)){const J=b.find(U=>U.lesson_id===i);D(J?J.progress_percent:0)}}).catch(console.error)):L.current.emit("leave-lesson",{studentId:r}))},[l,i,s,r]),p.useEffect(()=>{s==="teacher"&&i&&o&&L.current&&L.current.emit("teacher-broadcast-segment",{lessonId:i,activeSegmentId:o})},[o,i,s]),{socketRef:L}}const NS=`exports.default = {
|
|
136
|
+
manifest: {
|
|
137
|
+
id: "@my-scope/hello-world",
|
|
138
|
+
name: "Hello World Plugin",
|
|
139
|
+
version: "1.0.0",
|
|
140
|
+
capabilitiesProposed: ["lesson:read"]
|
|
141
|
+
},
|
|
142
|
+
activate: async (ctx) => {
|
|
143
|
+
ctx.log.info('Hello World plugin activated');
|
|
144
|
+
}
|
|
145
|
+
};`;function PS(e){const{session:t,host:n,lang:s,addToast:r,setChatLog:i,setTeacherTab:o,fetchLessons:l}=e,[c,u]=p.useState([]),[d,h]=p.useState([]),[m,f]=p.useState(!1),[g,y]=p.useState(null),[C,w]=p.useState(""),[N,S]=p.useState(""),[E,I]=p.useState(""),[k,z]=p.useState(""),[D,F]=p.useState(null),[_,A]=p.useState(!1),[L,O]=p.useState("store"),[R,P]=p.useState(NS),[T,W]=p.useState(!1),[j,$]=p.useState([]),[x,oe]=p.useState([]),[pe,b]=p.useState({}),J=p.useRef(new Set),U=p.useCallback(async()=>{try{const Y=await fetch("/api/plugins");if(Y.ok){const te=await Y.json();u(te)}}catch(Y){console.warn("Failed to fetch plugins",Y)}},[]),Q=p.useCallback(async()=>{try{const Y=await fetch("/api/ai-providers");if(Y.ok){const te=await Y.json();h(te)}}catch(Y){console.warn("Failed to fetch AI Providers",Y)}},[]);p.useEffect(()=>{U(),t&&t.role!=="student"&&Q()},[U,Q,t?.role]);const re=p.useCallback(async()=>{try{const Y=await fetch("/api/events");Y.ok&&$(await Y.json())}catch{}},[]),se=p.useCallback(async()=>{try{const Y=await fetch("/api/approvals");Y.ok&&oe(await Y.json())}catch{}},[]);return{plugins:c,setPlugins:u,fetchPlugins:U,aiProviders:d,setAiProviders:h,fetchAIProviders:Q,isAIProviderModalOpen:m,setIsAIProviderModalOpen:f,editingAIProvider:g,setEditingAIProvider:y,providerName:C,setProviderName:w,providerApiUrl:N,setProviderApiUrl:S,providerApiKey:E,setProviderApiKey:I,providerModelName:k,setProviderModelName:z,testingProviderId:D,setTestingProviderId:F,showPluginModal:_,setShowPluginModal:A,storeTab:L,setStoreTab:O,pluginCode:R,setPluginCode:P,installingPlugin:T,setInstallingPlugin:W,events:j,setEvents:$,fetchEvents:re,approvals:x,setApprovals:oe,fetchApprovals:se,scoreOverrides:pe,setScoreOverrides:b,handleSaveAIProvider:async()=>{if(!C.trim()||!N.trim()||!k.trim()){r(s==="zh"?"表单不完整":"Incomplete Form",s==="zh"?"请填写提供商名称、API 基础地址与模型标识。":"Please fill in Name, API URL, and Model Name.","warning");return}try{let Y;if(g?Y=await fetch(`/api/ai-providers/${g.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:C,api_url:N,api_key:E,model_name:k})}):Y=await fetch("/api/ai-providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:C,api_url:N,api_key:E,model_name:k})}),Y.ok)r(s==="zh"?"保存成功":"Saved Successfully",s==="zh"?`AI 提供商 [${C}] 已保存。`:`AI Provider [${C}] has been updated.`,"success"),f(!1),y(null),w(""),S(""),I(""),z(""),Q();else{const te=await Y.json().catch(()=>({}));r(s==="zh"?"保存失败":"Failed to Save",te.error||(s==="zh"?"无法写入数据库":"Failed to write to database"),"warning")}}catch(Y){console.error(Y),r(s==="zh"?"保存异常":"Execution Error",Y.message||"Error occurred","warning")}},handleDeleteAIProvider:async(Y,te)=>{if(confirm(s==="zh"?`确定要删除 AI 提供商 [${te}] 吗?此操作无法撤销。`:`Are you sure you want to delete AI Provider [${te}]?`))try{(await fetch(`/api/ai-providers/${Y}`,{method:"DELETE"})).ok?(r(s==="zh"?"删除成功":"Deleted Successfully",s==="zh"?`AI 提供商 [${te}] 已经被清除。`:`AI Provider [${te}] has been removed.`,"success"),Q()):r(s==="zh"?"删除失败":"Failed to Delete","Database error","warning")}catch(ae){console.error(ae),r(s==="zh"?"操作异常":"Execution Error",ae.message||"Error occurred","warning")}},handleTestAIProvider:async Y=>{F(Y.id);try{const te=await fetch("/api/ai-providers/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_url:Y.api_url,api_key:Y.api_key,model_name:Y.model_name})}),ae=await te.json();te.ok&&ae.success?r(s==="zh"?"测试通过":"Test Succeeded",s==="zh"?`成功连接至 [${Y.name}]。${ae.message}`:`Successfully connected to [${Y.name}]. ${ae.message}`,"success"):r(s==="zh"?"测试失败":"Test Failed",ae.error||"Connection error","warning")}catch(te){console.error(te),r(s==="zh"?"连接异常":"Connection Exception",te.message||"Error occurred","warning")}finally{F(null)}},handleInstallPlugin:async()=>{if(R.trim()){W(!0);try{const te=await(await fetch("/api/plugins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceCode:R})})).json();te.success?(await U(),A(!1),i(ae=>[...ae,{role:"agent",content:`[System] Plugin "${te.manifest.name}" installed successfully. You can now prompt me to use it.`}])):alert("Plugin installation failed: "+te.error)}catch(Y){alert("Error: "+Y.message)}finally{W(!1)}}},handleZipPluginUpload:async(Y,te,ae)=>{W(!0);const je=ae?.mode==="update";try{const Ue={"Content-Type":"application/octet-stream","X-Filename":encodeURIComponent(Y.name),"X-Execution-Mode":te,"X-Install-Mode":je?"update":"install","X-Allow-Downgrade":ae?.allowDowngrade?"true":"false"};ae?.targetPluginId&&(Ue["X-Target-Plugin-Id"]=encodeURIComponent(ae.targetPluginId));const He=je&&ae?.targetPluginId?`/api/plugins/${encodeURIComponent(ae.targetPluginId)}/update-zip-raw`:"/api/plugins/upload-zip-raw",ct=await fetch(He,{method:"POST",headers:Ue,body:Y}),Ne=await ct.json().catch(()=>({}));if(!ct.ok||!Ne.success){const Z=Ne.error||"Unknown error";throw r(s==="zh"?je?"更新失败":"安装失败":je?"Update Failed":"Installation Failed",Z,"error"),new Error(Z)}const M=Ne.pluginId||Ne.manifest?.pluginId||Ne.manifest?.id,H=!!(Ne.updated||je);if(!H&&M)await fetch(`/api/plugins/${encodeURIComponent(M)}/toggle`,{method:"POST"}).catch(()=>{});else if(H&&Ne.wasActive&&M)try{await n.deactivatePlugin(M)}catch{}o("plugins"),O("store"),await U(),setTimeout(()=>{U()},1e3);const K=Ne.manifest?.name||M||Y.name;if(H){const Z=Ne.oldVersion||"?",X=Ne.newVersion||Ne.manifest?.version||"?";r(s==="zh"?"插件更新成功":"Plugin Updated",s==="zh"?`"${K}" 已从 v${Z} 更新到 v${X}(配置与数据已保留)`:`"${K}" updated v${Z} → v${X} (config & data preserved)`,"success"),i(Pe=>[...Pe,{role:"agent",content:`[System] Plugin "${K}" updated ${Z} → ${X}.`}])}else r(s==="zh"?"插件安装成功":"Plugin Installed",s==="zh"?`三方插件 "${K}" 已成功上传并以 [${te==="worker"?"Worker 隔离":"VM 嵌入"}] 模式激活运行!`:`Plugin "${K}" installed and activated in [${te}] mode!`,"success"),i(Z=>[...Z,{role:"agent",content:`[System] Plugin "${K}" installed successfully from ZIP file.`}])}catch(Ue){const He=Ue?.message?String(Ue.message):"";throw He&&He!=="Failed to fetch"&&He!=="Network error"||r(s==="zh"?"网络错误":"Network Error",He||"Network error","error"),Ue}finally{W(!1)}},handleTogglePlugin:async Y=>{if(!J.current.has(Y)){J.current.add(Y);try{const te=await fetch(`/api/plugins/${encodeURIComponent(Y)}/toggle`,{method:"POST"}),ae=await te.json().catch(()=>({}));if(te.ok)await U();else{const je=ae.error||"Unknown error";je.includes("requires human approval")||je.includes("queued")?(alert(s==="zh"?'该操作已加入"待审批高危操作"列表,请在右侧侧边栏中通过审批以生效。':"This action has been queued. Please approve it in the Pending Approvals list on the right side."),await se()):alert((s==="zh"?"切换插件状态失败: ":"Failed to toggle plugin: ")+je)}}catch(te){console.error("Failed to toggle plugin:",te),alert(s==="zh"?"网络错误,切换插件失败":"Network error, failed to toggle plugin")}finally{J.current.delete(Y)}}},handleDeletePlugin:async Y=>{if(window.confirm(s==="zh"?"确定要彻底删除该插件吗?删除后此插件相关的功能将无法使用。":"Are you sure you want to completely delete this plugin? This cannot be undone."))try{const te=await fetch(`/api/plugins/${encodeURIComponent(Y)}`,{method:"DELETE"});if(te.ok)o("plugins"),O("store"),await U(),i(ae=>[...ae,{role:"agent",content:"[System] Plugin uninstalled and deleted."}]);else{const ae=await te.json().catch(()=>({}));alert(ae.error||(s==="zh"?"删除插件失败":"Failed to delete plugin"))}}catch(te){console.error("Failed to delete plugin:",te),alert(s==="zh"?"删除插件失败":"Failed to delete plugin")}},handleApprove:async(Y,te)=>{try{const je=await(await fetch(`/api/approvals/${Y}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payloadOverride:te})})).json();je.success?(await se(),await l(),await U()):alert("Action failed: "+je.error)}catch(ae){console.error(ae)}},handleReject:async Y=>{try{await fetch(`/api/approvals/${Y}/reject`,{method:"POST"}),await se(),await U()}catch(te){console.error(te)}}}}function TS(e){const{lang:t,addToast:n,fetchLessons:s,setSelectedLesson:r,setTeacherTab:i}=e,[o,l]=p.useState(!1),[c,u]=p.useState(1),[d,h]=p.useState(""),[m,f]=p.useState("Mathematics"),[g,y]=p.useState(""),[C,w]=p.useState(""),[N,S]=p.useState([{id:"seg-w1",title:"Course Orientation / 课堂导入",type:"intro",duration:"5m",color:"bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100",notes:"Introduce basic goals"},{id:"seg-w2",title:"Subject Core Lecture / 核心精讲",type:"lecture",duration:"20m",color:"bg-indigo-50 text-indigo-700 border-indigo-200 hover:bg-indigo-100",notes:"Present major content frameworks"},{id:"seg-w3",title:"Interactive Lab Work / 实践演练",type:"practice",duration:"15m",color:"bg-green-50 text-green-700 border-green-200 hover:bg-green-100",notes:"Provide collaborative assignments on terminal or board"},{id:"seg-w4",title:"Wrap up / 随堂总结与答疑",type:"summary",duration:"5m",color:"bg-purple-50 text-purple-700 border-purple-200 hover:bg-purple-100",notes:"Reflect and assign task"}]),[E,I]=p.useState(!1);return{isCourseWizardOpen:o,setIsCourseWizardOpen:l,wizardStep:c,setWizardStep:u,wizardCourseTitle:d,setWizardCourseTitle:h,wizardCourseCategory:m,setWizardCourseCategory:f,wizardCourseDescription:g,setWizardCourseDescription:y,wizardCourseContent:C,setWizardCourseContent:w,wizardCourseTimeline:N,setWizardCourseTimeline:S,wizardIsSubmitting:E,setWizardIsSubmitting:I,handleDeployWizardCourse:async()=>{if(!d.trim()){alert(t==="zh"?"请输入课程标题!":"Please provide a course title!");return}I(!0);try{const z=C.trim()||`Course outline for ${d} (${m})`,D=await fetch("/api/lessons",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:d,content:z})});if(D.ok){const _=(await D.json()).result?.lessonId;_&&await fetch(`/api/lessons/${_}/timeline`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({timeline:N})}),await s(),_&&(r(_),i("lesson_editor")),n(t==="zh"?"⭐ 课程发布成功":"⭐ Course Deployed Successfully",t==="zh"?`课程《${d}》已成功保存到核心SQLite并已自动激活!`:`Course "${d}" is now live in SQLite and auto-activated.`,"success"),l(!1),h(""),f("Mathematics"),y(""),w(""),u(1)}else n("Error","SQLite save failed","warning")}catch(z){console.error(z),n("Error","Launch Exception","warning")}finally{I(!1)}}}}function IS(){const[e,t]=p.useState(!1),[n,s]=p.useState(null),[r,i]=p.useState("scan_lesson"),[o,l]=p.useState(""),[c,u]=p.useState(""),[d,h]=p.useState(!1),[m,f]=p.useState([]),[g,y]=p.useState([]),[C,w]=p.useState(!1),[N,S]=p.useState({}),[E,I]=p.useState(10),[k,z]=p.useState("quiz"),D=p.useRef(N);return p.useEffect(()=>{D.current=N},[N]),{isQuizGeneratorOpen:e,setIsQuizGeneratorOpen:t,quizGeneratorClassId:n,setQuizGeneratorClassId:s,quizGenMode:r,setQuizGenMode:i,quizGenSelectedLessonId:o,setQuizGenSelectedLessonId:l,quizGenTopic:c,setQuizGenTopic:u,isGeneratingSuggestions:d,setIsGeneratingSuggestions:h,suggestedObjectives:m,setSuggestedObjectives:f,suggestedQuestions:g,setSuggestedQuestions:y,savingQuiz:C,setSavingQuiz:w,quizStudentAnswers:N,setQuizStudentAnswers:S,quizGenTimeLimit:E,setQuizGenTimeLimit:I,quizStudentAnswersRef:D,subAssignmentTab:k,setSubAssignmentTab:z}}function AS(e){const{lang:t,classes:n,expandedClassId:s,fetchClasses:r,fetchClassStudents:i,handleExportAllClassesCombined:o}=e,[l,c]=p.useState(!1),[u,d]=p.useState(new Set),[h,m]=p.useState(new Set),[f,g]=p.useState(null),[y,C]=p.useState(""),[w,N]=p.useState(""),[S,E]=p.useState("");return{batchMode:l,setBatchMode:c,selectedClassIds:u,setSelectedClassIds:d,selectedStudentIds:h,setSelectedStudentIds:m,batchPicker:f,setBatchPicker:g,batchPickerLesson:y,setBatchPickerLesson:C,batchPickerDate:w,setBatchPickerDate:N,batchPickerTargetClass:S,setBatchPickerTargetClass:E,toggleClassSelection:j=>{d($=>{const x=new Set($);return x.has(j)?x.delete(j):x.add(j),x})},toggleSelectAllClasses:()=>{d(j=>j.size===n.length&&n.length>0?new Set:new Set(n.map($=>$.id)))},toggleStudentSelection:j=>{m($=>{const x=new Set($);return x.has(j)?x.delete(j):x.add(j),x})},toggleSelectAllStudents:j=>{m($=>$.size===j.length&&j.length>0?new Set:new Set(j.map(x=>x.id)))},handleBatchDeleteClasses:async()=>{if(u.size!==0&&confirm(t==="zh"?`确认彻底删除选中的 ${u.size} 个班级吗?该操作不可恢复。`:`Delete ${u.size} selected classes permanently?`)){for(const j of u)await fetch(`/api/classes/${j}`,{method:"DELETE"});d(new Set),await r()}},handleBatchExportClasses:async()=>{u.size!==0&&await o(n.filter(j=>u.has(j.id)))},handleBatchSetPasscode:async()=>{if(u.size===0)return;const j=window.prompt(t==="zh"?"请输入临时班级密码(留空则清除):":"Enter temporary passcode (leave empty to clear):");if(j!==null){for(const $ of u)await fetch(`/api/classes/${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({class_passcode:j===""?null:j})});d(new Set),await r()}},handleBatchScheduleClasses:()=>{u.size!==0&&(C(""),N(new Date().toISOString().split("T")[0]),g("schedule"))},handleBatchDeleteStudents:async()=>{if(!(h.size===0||!s)&&confirm(t==="zh"?`确认彻底删除选中的 ${h.size} 名学生账号吗?将删除其全部关联数据,不可恢复。`:`Permanently delete ${h.size} selected student accounts?`)){for(const j of h)await fetch(`/api/students/${j}`,{method:"DELETE"});m(new Set),await i(s)}},handleBatchResetPassword:async()=>{if(h.size===0||!s)return;const j=window.prompt(t==="zh"?"请输入要为选中学生设置的新密码:":"Enter new password for selected students:");if(!(j===null||j.trim()==="")){for(const $ of h)await fetch(`/api/students/${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:j})});m(new Set),await i(s)}},handleBatchTransferStudents:()=>{h.size===0||!s||(E(""),g("transfer"))},handleBatchSetLockedLesson:()=>{h.size===0||!s||(C(""),g("lockedLesson"))},confirmBatchPicker:async()=>{if(s){if(f==="schedule"){if(!y){alert(t==="zh"?"请选择课程":"Please select a lesson");return}for(const j of u)await fetch(`/api/classes/${j}/schedules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:y,scheduledDate:w+" 09:00:00",status:"scheduled"})});d(new Set)}else if(f==="lockedLesson"){if(!y){alert(t==="zh"?"请选择课程":"Please select a lesson");return}for(const j of h)await fetch(`/api/students/${j}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({locked_lesson_id:y})});m(new Set)}else if(f==="transfer"){if(!S||S===s){alert(t==="zh"?"请选择不同的目标班级":"Please select a different target class");return}for(const j of h)await fetch(`/api/classes/${s}/students/${j}`,{method:"DELETE"}),await fetch(`/api/classes/${S}/students`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:j})});m(new Set)}g(null),s&&await i(s)}}}}function zS(){const[e,t]=p.useState([]),[n,s]=p.useState(!1),[r,i]=p.useState({lab_id:null,seats:[]}),[o,l]=p.useState(!1),[c,u]=p.useState([]),[d,h]=p.useState({}),[m,f]=p.useState({}),[g,y]=p.useState(null),[C,w]=p.useState(""),[N,S]=p.useState(""),E=p.useCallback(async()=>{try{s(!0);const F=await fetch("/api/labs");F.ok&&t(await F.json())}catch(F){console.error(F)}finally{s(!1)}},[]),I=p.useCallback(async F=>{try{const _=await fetch(`/api/classes/${F}/seats`);if(_.ok){const A=await _.json();i(A)}}catch(_){console.error(_)}},[]),k=p.useCallback(async()=>{try{const F=new Date().toISOString().split("T")[0],_=await fetch(`/api/schedules/today?date=${F}`);if(_.ok){const A=await _.json();A.success&&A.schedules&&u(A.schedules)}}catch(F){console.warn("Failed to fetch today schedules",F)}},[]),z=p.useCallback(async F=>{try{const _=await fetch(`/api/classes/${F}/schedules`);if(_.ok){const A=await _.json();h(L=>({...L,[F]:A}))}}catch{}},[]),D=p.useCallback(async F=>{try{const _=await fetch(`/api/schedules/${F}/attendance`);if(_.ok){const A=await _.json();f(L=>({...L,[F]:A}))}}catch{}},[]);return{computerLabs:e,setComputerLabs:t,loadingLabs:n,setLoadingLabs:s,fetchLabs:E,classSeats:r,setClassSeats:i,savingSeats:o,setSavingSeats:l,fetchClassSeats:I,todaySchedules:c,setTodaySchedules:u,fetchTodaySchedules:k,classSchedulesMap:d,setClassSchedulesMap:h,fetchClassSchedules:z,scheduleAttendanceMap:m,setScheduleAttendanceMap:f,fetchScheduleAttendance:D,expandedScheduleId:g,setExpandedScheduleId:y,newScheduleDate:C,setNewScheduleDate:w,newScheduleLessonId:N,setNewScheduleLessonId:S}}function _S(e){const{selectedLesson:t,lessons:n,setLessons:s}=e,[r,i]=p.useState([]),[o,l]=p.useState("seg-1"),[c,u]=p.useState(null),[d,h]=p.useState(null),[m,f]=p.useState("none"),[g,y]=p.useState(null),[C,w]=p.useState(!0),N=p.useRef(null),S=async(E,I)=>{f("saving");try{(await fetch(`/api/lessons/${E}/timeline`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({timeline:I})})).ok?(s(z=>z.map(D=>D.id===E?{...D,timeline:JSON.stringify(I)}:D)),i(I),f("saved"),y(new Date)):f("error")}catch(k){console.error("Failed to save timeline:",k),f("error")}};return p.useEffect(()=>{if(t){const E=n.find(I=>I.id===t);if(E){let I=[];if(E.timeline)try{I=typeof E.timeline=="string"?JSON.parse(E.timeline):E.timeline}catch{I=[{id:"seg-1",title:"开场准备",type:"intro",duration:"5m",color:"bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100"},{id:"seg-2",title:"讲授新课",type:"lecture",duration:"20m",color:"bg-indigo-50 text-indigo-700 border-indigo-200 hover:bg-indigo-100"},{id:"seg-3",title:"互动练习",type:"practice",duration:"15m",color:"bg-green-50 text-green-700 border-green-200 hover:bg-green-100"},{id:"seg-4",title:"课堂总结",type:"summary",duration:"5m",color:"bg-purple-50 text-purple-700 border-purple-200 hover:bg-purple-100"}]}else I=[{id:"seg-1",title:"开场准备",type:"intro",duration:"5m",color:"bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100"},{id:"seg-2",title:"讲授新课",type:"lecture",duration:"20m",color:"bg-indigo-50 text-indigo-700 border-indigo-200 hover:bg-indigo-100"},{id:"seg-3",title:"互动练习",type:"practice",duration:"15m",color:"bg-green-50 text-green-700 border-green-200 hover:bg-green-100"},{id:"seg-4",title:"课堂总结",type:"summary",duration:"5m",color:"bg-purple-50 text-purple-700 border-purple-200 hover:bg-purple-100"}];i(I);const k=N.current!==t;N.current=t,I.length>0?(k||!I.some(z=>z.id===o))&&l(I[0].id):l(null)}}},[t,n]),{timelineSegments:r,setTimelineSegments:i,activeSegmentId:o,setActiveSegmentId:l,segmentToEdit:c,setSegmentToEdit:u,draggedSegmentIdx:d,setDraggedSegmentIdx:h,editorSaveStatus:m,setEditorSaveStatus:f,editorLastSavedTime:g,setEditorLastSavedTime:y,editorPanelsExpanded:C,setEditorPanelsExpanded:w,saveTimeline:S}}function LS(e,t,n){const[s,r]=p.useState(new Set),[i,o]=p.useState(null),[l,c]=p.useState(!1),u=p.useMemo(()=>{if(e!=="student"||!t)return[];const h=[],m=t.assignments||[];for(const g of m)if(!g.submission_status)h.push({id:`new-${g.id}`,type:"new_assignment",title:n==="zh"?"新发布作业":"New Assignment",message:n==="zh"?`您有一项新作业:"${g.title}"`:`You have a new assignment: ${g.title}`,date:g.created_at,relatedId:g.id});else if(g.submission_status==="graded"){const y=!!g.feedback;h.push({id:`graded-${g.id}`,type:"graded",title:y?n==="zh"?"收到新成绩与反馈":"Grade & Feedback Posted":n==="zh"?"新成绩发布":"Assignment Graded",message:y?n==="zh"?`您的作业"${g.title}"已评分,得分:${g.score}%。反馈:"${g.feedback}"`:`Your assignment "${g.title}" was graded. Score: ${g.score}%. Teacher feedback: "${g.feedback}"`:n==="zh"?`您的作业"${g.title}"已评分,得分:${g.score}%`:`Your assignment "${g.title}" was graded. Score: ${g.score}%`,date:g.submitted_at||g.created_at,relatedId:g.id})}const f=t.rollcalls||[];for(const g of f)h.push({id:g.id,type:"rollcall_picked",title:n==="zh"?"⚡️ 随机提问选中通知":"⚡️ Random Pick Notification",message:n==="zh"?`您已被老师在课程"${g.lesson_title||"课堂"}"中随机选中提问!请立即确认您的出勤与注意。`:`You have been randomly picked by the teacher in lesson "${g.lesson_title||"Class"}"! Please pay immediate attention.`,date:g.picked_time,relatedId:g.lesson_id});return h.sort((g,y)=>y.date-g.date)},[e,t,n]),d=p.useMemo(()=>u.filter(h=>!s.has(h.id)),[u,s]);return{studentNotifications:u,unreadNotifications:d,readNotifications:s,setReadNotifications:r,selectedNotificationForModal:i,setSelectedNotificationForModal:o,isNotificationsOpen:l,setIsNotificationsOpen:c}}function uu(e){if(e==null)return"";const t=String(e);return t.includes(",")||t.includes('"')||t.includes(`
|
|
146
|
+
`)?`"${t.replace(/"/g,'""')}"`:t}async function RS(e){const{classId:t,className:n,students:s,dashData:r,lang:i,addToast:o,setIsGeneratingPDFReport:l}=e;l(c=>({...c,[t]:!0}));try{if(!r){o(i==="zh"?"暂无班级评分数据":"No Class Performance Data",i==="zh"?"请确保在此班级加载了作业与测验。":"Please check if assignments or quizzes are present for this class.","warning");return}const c=r.performance||[],u=r.assignments||[],d={};s.forEach(T=>{d[T.id]={id:T.id,name:T.name,totalGradesSum:0,gradedCount:0,submittedCount:0,totalCount:0}}),c.forEach(T=>{const W=T.student_id;d[W]&&(d[W].totalCount++,(T.submission_status==="submitted"||T.submission_status==="graded")&&d[W].submittedCount++,T.score!==null&&T.score!==void 0&&(d[W].totalGradesSum+=T.score,d[W].gradedCount++))});const h=Object.values(d).map(T=>{const W=T.gradedCount>0?T.totalGradesSum/T.gradedCount:0,j=T.totalCount>0?T.submittedCount/T.totalCount*100:0;return{...T,avgScore:W,submissionRate:j}});h.sort((T,W)=>W.avgScore-T.avgScore);let m=0,f=0,g=0,y=0;c.forEach(T=>{y++,(T.submission_status==="submitted"||T.submission_status==="graded")&&g++,T.score!==null&&T.score!==void 0&&(m+=T.score,f++)});const C=f>0?m/f:0,w=y>0?g/y*100:0,N={};u.forEach(T=>{N[T.id]={id:T.id,title:T.title,scores:[],submittedCount:0,totalCount:0}}),c.forEach(T=>{const W=T.assignment_id;N[W]&&(N[W].totalCount++,(T.submission_status==="submitted"||T.submission_status==="graded")&&N[W].submittedCount++,T.score!==null&&T.score!==void 0&&N[W].scores.push(T.score))});const S=Object.values(N).map(T=>{const W=T.scores.length,j=T.scores.reduce((b,J)=>b+J,0),$=W>0?j/W:0,x=W>0?Math.max(...T.scores):0,oe=W>0?Math.min(...T.scores):0,pe=T.totalCount>0?T.submittedCount/T.totalCount*100:0;return{...T,avg:$,max:x,min:oe,subRate:pe}}),E=new ap({orientation:"p",unit:"mm",format:"a4"}),I=[15,23,42],k=[79,70,229],z=[51,65,85],D=[226,232,240],F=T=>{E.setDrawColor(D[0],D[1],D[2]),E.setLineWidth(.3),E.line(14,T,196,T)};E.setFillColor(I[0],I[1],I[2]),E.rect(0,0,210,42,"F"),E.setTextColor(255,255,255),E.setFont("helvetica","bold"),E.setFontSize(20),E.text("CLASS PERFORMANCE REPORT",14,18),E.setFont("helvetica","normal"),E.setFontSize(10),E.setTextColor(194,205,225),E.text("Academic Insights • Generative Report Summary",14,25),E.text(`Classroom: ${n} | Date: ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,14,32),E.setFillColor(k[0],k[1],k[2]),E.rect(172,10,24,24,"F"),E.setFont("helvetica","bold"),E.setFontSize(14),E.setTextColor(255,255,255),E.text("OS",180,26);let _=52;E.setTextColor(I[0],I[1],I[2]),E.setFont("helvetica","bold"),E.setFontSize(12),E.text("I. EXECUTIVE OVERVIEW",14,_),_+=6;const A=[["Classroom/Subject Name",n],["Total Enrolled Students",`${s.length} student(s)`],["Curriculum Items (Assignments/Quizzes)",`${u.length} items`],["Global Assignment Submission Rate",`${w.toFixed(1)}%`],["Class Average Performance Score",`${C.toFixed(1)}%`]];E.autoTable({startY:_,head:[["Metric Indicator","Class-wide Metric Value"]],body:A,theme:"striped",headStyles:{fillColor:I,textColor:[255,255,255],fontStyle:"bold",fontSize:9},bodyStyles:{textColor:z,fontSize:9.5},margin:{left:14,right:14}}),_=E.lastAutoTable.finalY+12,E.setTextColor(I[0],I[1],I[2]),E.setFont("helvetica","bold"),E.setFontSize(12),E.text("II. STUDENT RANKING DISTRIBUTION",14,_),_+=6;const L=h.map((T,W)=>{let j="Excellent";return T.avgScore>=90?j="Excellent (A)":T.avgScore>=75?j="Good (B)":T.avgScore>=60?j="Satisfactory (C)":j="Needs Improvement (D)",[`${W+1}`,T.name,`${T.submittedCount}/${T.totalCount} (${T.submissionRate.toFixed(0)}%)`,`${T.avgScore.toFixed(1)}%`,j]});E.autoTable({startY:_,head:[["Rank","Student Name","Completion Rate","Average Score","Academic Standing Tier"]],body:L,theme:"grid",headStyles:{fillColor:k,textColor:[255,255,255],fontStyle:"bold",fontSize:9.5},bodyStyles:{textColor:z,fontSize:9.5},alternateRowStyles:{fillColor:[248,250,252]},columnStyles:{0:{cellWidth:15,halign:"center",fontStyle:"bold"},1:{fontStyle:"bold"},2:{halign:"center"},3:{halign:"center",fontStyle:"bold"}},margin:{left:14,right:14}}),_=E.lastAutoTable.finalY+12,_>210&&(E.addPage(),_=20),E.setTextColor(I[0],I[1],I[2]),E.setFont("helvetica","bold"),E.setFontSize(12),E.text("III. ASSIGNMENT PERFORMANCE METRICS",14,_),_+=6;const O=S.map(T=>[T.title,`${T.subRate.toFixed(0)}%`,`${T.avg.toFixed(1)}%`,`${T.min.toFixed(0)}% - ${T.max.toFixed(0)}%`]);E.autoTable({startY:_,head:[["Assignment/Quiz Title","Submission Rate","Average Grade","Range (Min - Max)"]],body:O.length>0?O:[["No assignment performance records found.","-","-","-"]],theme:"striped",headStyles:{fillColor:[100,116,139],textColor:[255,255,255],fontStyle:"bold",fontSize:9.5},bodyStyles:{textColor:z,fontSize:9.5},columnStyles:{1:{halign:"center"},2:{halign:"center",fontStyle:"bold"},3:{halign:"center"}},margin:{left:14,right:14}}),_=E.lastAutoTable.finalY+15,F(275),E.setFontSize(8),E.setTextColor(148,163,184),E.text("Generated by OpenLearn Next • Educational Operating System",14,282),E.text("Page 1 of 1 • Internal Educational Audit",196,282,{align:"right"});const R=n.replace(/[^a-z0-9]/gi,"_").toLowerCase(),P=new Date().toISOString().split("T")[0];E.save(`Class_Report_${R}_${P}.pdf`),o(i==="zh"?"📄 PDF 报告导出完成":"📄 PDF Report Generated",i==="zh"?`班级【${n}】的综合学情 PDF 报告已生成并下载。`:`Class performance report for ${n} saved to your device.`,"success")}catch(c){console.error("PDF Generation Failed:",c),o(i==="zh"?"❌ PDF 报告生成失败":"❌ PDF Report Failed",c.message||"Error occurred during PDF generation","warning")}finally{l(c=>({...c,[t]:!1}))}}function MS(e){const{className:t,students:n,dashData:s,qWeight:r=40,aWeight:i=60,overrides:o={}}=e;if(!s||!s.assignments){alert("No performance data available to export. Please open the dashboard to load class data first.");return}if(n.length===0){alert("No students in this class to export grades for.");return}const l=s.assignments||[],c=s.performance||[],u=l.map(S=>{let E="assignment";if(o[S.id])E=o[S.id];else{const I=S.content&&S.content.startsWith('{"quizType":"mcq_learning_objectives"'),k=S.title&&(S.title.toLowerCase().includes("quiz")||S.title.toLowerCase().includes("test")||S.title.includes("测验")||S.title.includes("测试"));E=I||k?"quiz":"assignment"}return{...S,category:E}}),d=["Student Name","Student Email"];u.forEach(S=>{const E=S.category==="quiz"?"Quiz":"Assignment";d.push(`${E}: ${S.title}`)}),d.push("Quizzes Average","Assignments Average",`Weighted Average (${r}% Quizzes, ${i}% Assignments)`,"Simple Average Score","Submitted Count","Total Items");const h=[d];n.forEach(S=>{const E=[S.name,S.email];let I=0,k=0,z=0,D=0,F=0,_=0,A=0;u.forEach(j=>{const $=c.find(x=>x.assignment_id===j.id&&x.student_id===S.id);if($&&$.score!==null&&$.score!==void 0){E.push(`${$.score}%`);const x=Number($.score);j.category==="quiz"?(I+=x,k++):(z+=x,D++),F+=x,_++,A++}else $&&$.submission_status==="submitted"?(E.push("Pending Grade"),A++):E.push("Not Submitted")});const L=k>0?Math.round(I/k):null,O=D>0?Math.round(z/D):null;let R="N/A";if(L!==null&&O!==null){const j=L*(r/100)+O*(i/100);R=`${Math.round(j)}%`}else L!==null?R=`${L}%`:O!==null&&(R=`${O}%`);const P=L!==null?`${L}%`:"N/A",T=O!==null?`${O}%`:"N/A",W=_>0?`${Math.round(F/_)}%`:"N/A";E.push(P,T,R,W,`${A}`,`${l.length}`),h.push(E.map(uu))});const m=h.map(S=>S.join(",")).join(`
|
|
147
|
+
`),f=new Blob(["\uFEFF"+m],{type:"text/csv;charset=utf-8;"}),g=URL.createObjectURL(f),y=document.createElement("a"),C=t.replace(/[^a-z0-9]/gi,"_").toLowerCase(),w=new Date().toISOString().split("T")[0],N=`${C}_grades_report_${w}.csv`;y.setAttribute("href",g),y.setAttribute("download",N),y.style.visibility="hidden",document.body.appendChild(y),y.click(),document.body.removeChild(y),URL.revokeObjectURL(g)}function OS(e){const{exportClassId:t,classStudentsMap:n,classDashboardMap:s,quizzesWeight:r,assignmentsWeight:i,customCategoryOverrides:o,lang:l}=e;if(!t)return null;const c=n[t]||[],u=s[t];if(!u||!u.assignments||c.length===0)return null;const d=u.assignments||[],h=u.performance||[],m=d.map(C=>{let w="assignment";if(o[C.id])w=o[C.id];else{const N=C.content&&C.content.startsWith('{"quizType":"mcq_learning_objectives"'),S=C.title&&(C.title.toLowerCase().includes("quiz")||C.title.toLowerCase().includes("test")||C.title.includes("测验")||C.title.includes("测试"));w=N||S?"quiz":"assignment"}return{...C,category:w}}),f=["Student Name","Student Email"];m.forEach(C=>{const w=C.category==="quiz"?"Quiz":"Assignment";f.push(`${w}: ${C.title}`)}),f.push("Quizzes Average","Assignments Average",`Weighted Average (${r}% Quizzes, ${i}% Assignments)`,"Simple Average Score","Submitted Count","Total Items");const g=[];return c.slice(0,5).forEach(C=>{const w=[C.name,C.email];let N=0,S=0,E=0,I=0,k=0,z=0,D=0;m.forEach(P=>{const T=h.find(W=>W.assignment_id===P.id&&W.student_id===C.id);if(T&&T.score!==null&&T.score!==void 0){w.push(`${T.score}%`);const W=Number(T.score);P.category==="quiz"?(N+=W,S++):(E+=W,I++),k+=W,z++,D++}else T&&T.submission_status==="submitted"?(w.push(l==="zh"?"待评分":"Pending Grade"),D++):w.push(l==="zh"?"未提交":"Not Submitted")});const F=S>0?Math.round(N/S):null,_=I>0?Math.round(E/I):null;let A="N/A";if(F!==null&&_!==null){const P=F*(r/100)+_*(i/100);A=`${Math.round(P)}%`}else F!==null?A=`${F}%`:_!==null&&(A=`${_}%`);const L=F!==null?`${F}%`:"N/A",O=_!==null?`${_}%`:"N/A",R=z>0?`${Math.round(k/z)}%`:"N/A";w.push(L,O,A,R,`${D}`,`${d.length}`),g.push(w)}),{headers:f,rows:g,totalStudents:c.length}}function DS(e){const{classes:t,classStudentsMap:n,classDashboardMap:s,lang:r}=e,o=[["Class Name","Student Name","Student Email","Quizzes Average","Assignments Average","Calculated Weighted Score (40% Quiz / 60% Assignment)","Simple Average Score","Submitted Count","Total Items"]];if(t.forEach(d=>{const h=n[d.id]||[],m=s[d.id];if(!m||!m.assignments||h.length===0)return;const f=m.assignments||[],g=f.map(y=>{const C=y.content&&y.content.startsWith('{"quizType":"mcq_learning_objectives"'),w=y.title&&(y.title.toLowerCase().includes("quiz")||y.title.toLowerCase().includes("test")||y.title.includes("测验")||y.title.includes("测试"));return{...y,category:C||w?"quiz":"assignment"}});h.forEach(y=>{let C=0,w=0,N=0,S=0,E=0,I=0;g.forEach(A=>{const L=m.performance?.find(O=>O.student_id===y.id&&O.assignment_id===A.id&&O.submission_status==="graded"&&O.score!==null);if(L){const O=Number(L.score);E+=O,I++,A.category==="quiz"?(C+=O,w++):(N+=O,S++)}});const k=w>0?Math.round(C/w):null,z=S>0?Math.round(N/S):null;let D=0;k!==null&&z!==null?D=Math.round(k*.4+z*.6):k!==null?D=Math.round(k):z!==null&&(D=Math.round(z));const F=I>0?Math.round(E/I):0,_=[d.name,y.name,y.email,k!==null?`${k}%`:"N/A",z!==null?`${z}%`:"N/A",`${D}%`,`${F}%`,`${I}`,`${f.length}`];o.push(_)})}),o.length<=1){alert(r==="zh"?"暂无可导出的成绩数据。请确保班级中有已评分的作业。":"No graded performance data available to export.");return}const l="data:text/csv;charset=utf-8,\uFEFF"+o.map(d=>d.map(uu).join(",")).join(`
|
|
148
|
+
`),c=encodeURI(l),u=document.createElement("a");u.setAttribute("href",c),u.setAttribute("download",`All_Classes_Combined_Grades_${new Date().toISOString().slice(0,10)}.csv`),document.body.appendChild(u),u.click(),document.body.removeChild(u)}function FS(e){const{lang:t,classes:n,classStudentsMap:s,classDashboardMap:r,fetchClassStudents:i,fetchClassDashboard:o,fetchClassProgress:l,addToast:c=()=>{}}=e,[u,d]=p.useState(!1),[h,m]=p.useState(""),[f,g]=p.useState(""),[y,C]=p.useState(40),[w,N]=p.useState(60),[S,E]=p.useState({}),[I,k]=p.useState(!1),[z,D]=p.useState(!1),[F,_]=p.useState(null),[A,L]=p.useState(!1),[O,R]=p.useState({}),P=p.useCallback(b=>{const J=Math.min(100,Math.max(0,b));C(J),N(100-J)},[]),T=p.useCallback(b=>{const J=Math.min(100,Math.max(0,b));N(J),C(100-J)},[]),W=p.useMemo(()=>OS({exportClassId:h,classStudentsMap:s,classDashboardMap:r,quizzesWeight:y,assignmentsWeight:w,customCategoryOverrides:S,lang:t}),[h,y,w,S,s,r,t]),j=p.useCallback(async(b,J)=>{_(b);try{await i(b),await o(b),await l(b),m(b),g(J),C(40),N(60),E({}),d(!0)}catch(U){console.error(U)}finally{_(null),k(!1)}},[i,o,l]),$=p.useCallback((b,J,U=40,Q=60,re={})=>{MS({className:J,students:s[b]||[],dashData:r[b],qWeight:U,aWeight:Q,overrides:re})},[s,r]),x=p.useCallback(async(b,J)=>{await i(b),await o(b),await l(b),await RS({classId:b,className:J,students:s[b]||[],dashData:r[b],lang:t,addToast:c,setIsGeneratingPDFReport:R})},[s,r,t,c,i,o,l]),oe=p.useCallback(async()=>{L(!0);try{await DS({classes:n,classStudentsMap:s,classDashboardMap:r,lang:t})}catch(b){console.error("Export all classes error:",b)}finally{L(!1),k(!1)}},[n,s,r,t]),pe=p.useCallback((b,J)=>{const U=r[J];if(!U||!U.performance)return null;const Q=Date.now()-2592e6,se=U.performance.filter(le=>le.student_id===b).filter(le=>le.submitted_at&&le.submitted_at>=Q&&le.score!==null&&le.score!==void 0);if(se.length===0)return null;const me=se.reduce((le,Ve)=>le+Number(Ve.score),0)/se.length;return me<60?Math.round(me):null},[r]);return{isExportWeightModalOpen:u,setIsExportWeightModalOpen:d,exportClassId:h,setExportClassId:m,exportClassName:f,setExportClassName:g,quizzesWeight:y,setQuizzesWeight:C,assignmentsWeight:w,setAssignmentsWeight:N,customCategoryOverrides:S,setCustomCategoryOverrides:E,exportDropdownOpen:I,setExportDropdownOpen:k,exportTooltipOpen:z,setExportTooltipOpen:D,loadingExportClassId:F,setLoadingExportClassId:_,isExportingAllCombined:A,setIsExportingAllCombined:L,isGeneratingPDFReport:O,setIsGeneratingPDFReport:R,handleQuizzesWeightChange:P,handleAssignmentsWeightChange:T,csvPreviewData:W,triggerExportForClass:j,handleExportGrades:$,handleGeneratePDFReport:x,handleExportAllClassesCombined:oe,get30DayAverageWarning:pe}}function BS(e){const[t,n]=p.useState(""),[s,r]=p.useState("recent"),[i,o]=p.useState(!1),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[h,m]=p.useState(null),f=p.useMemo(()=>{let g=[...e];if(t.trim()){const y=t.toLowerCase();g=g.filter(C=>C.title.toLowerCase().includes(y)||C.content.toLowerCase().includes(y))}if(i&&(g=g.filter(y=>(y.enrollment_count||0)>0)),l&&(g=g.filter(y=>y.content&&y.content.trim().length>0)),u){const y=new Date(new Date().getFullYear(),new Date().getMonth(),1).getTime();g=g.filter(C=>(C.created_at||0)>=y)}return s==="recent"?g.sort((y,C)=>(C.created_at||0)-(y.created_at||0)):s==="alphabetical"?g.sort((y,C)=>y.title.localeCompare(C.title)):s==="enrollment"&&g.sort((y,C)=>(C.enrollment_count||0)-(y.enrollment_count||0)),g},[e,t,s,i,l,u]);return{lessonsSearchQuery:t,setLessonsSearchQuery:n,lessonsSortOrder:s,setLessonsSortOrder:r,filterEnrollment:i,setFilterEnrollment:o,filterHasContent:l,setFilterHasContent:c,filterThisMonth:u,setFilterThisMonth:d,copyingLessonId:h,setCopyingLessonId:m,filteredAndSortedLessons:f}}function vl(e,t){let n="",s="",r="";e==="class"?(n=t==="zh"?"班级及学生批量导入模板.csv":"class_import_template.csv",s="Class Name,Class Desc,Student Name,Student Email",r=t==="zh"?`高一A班,基础英语课程,李明,liming@example.com
|
|
149
|
+
高一A班,基础英语课程,王华,wanghua@example.com`:`Class 101,Introduction to English,John Doe,john@example.com
|
|
150
|
+
Class 101,Introduction to English,Jane Smith,jane@example.com`):(n=t==="zh"?"学生批量导入模板.csv":"student_import_template.csv",s="Student Name,Student Email",r=t==="zh"?`张三,zhangsan@example.com
|
|
151
|
+
李四,lisi@example.com`:`Alice Cooper,alice@example.com
|
|
152
|
+
Bob Dylan,bob@example.com`);const i=new Blob(["\uFEFF"+s+`
|
|
153
|
+
`+r],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.setAttribute("download",n),document.body.appendChild(l),l.click(),document.body.removeChild(l)}async function $S(e,t){const{lang:n,fetchClasses:s,fetchStudents:r}=t;return new Promise((i,o)=>{const l=new FileReader;l.onload=async c=>{try{const u=c.target?.result;if(!u)throw new Error("File content is empty");let d=[],h=[],m=!0;if(e.name.endsWith(".json")){const f=JSON.parse(u);if(!Array.isArray(f))throw new Error("JSON structure must be an array");f.some(y=>y.className||y.name&&(y.students||y.classDescription))?(m=!0,d=f.map(y=>{const C=y.name||y.className||y.class_name,w=y.description||y.classDescription||"",N=y.students||y.studentList||[],S=(Array.isArray(N)?N:[]).map(E=>({name:E.name||E.studentName||"",email:E.email||E.studentEmail||""})).filter(E=>E.name);return{name:C,description:w,students:S}}).filter(y=>y.name)):(m=!1,h=f.map(y=>({name:y.name||y.studentName||y.student_name||"",email:y.email||y.studentEmail||y.student_email||""})).filter(y=>y.name))}else{const f=u.split(/\r?\n/);if(f.length<2)throw new Error("CSV has empty or insufficient data");const g=f[0].split(",").map(S=>S.trim().toLowerCase()),y=g.findIndex(S=>S.includes("class name")||S.includes("班级名称")||S.includes("班级")||S.includes("classname")||S.includes("class_name")),C=g.findIndex(S=>S.includes("class desc")||S.includes("班级描述")||S.includes("描述")||S.includes("class_desc")),w=g.findIndex(S=>S.includes("student name")||S.includes("学生姓名")||S.includes("姓名")||S.includes("学生")||S.includes("studentname")||S.includes("student_name")),N=g.findIndex(S=>S.includes("student email")||S.includes("学生邮箱")||S.includes("邮箱")||S.includes("email")||S.includes("studentemail")||S.includes("student_email"));if(w===-1)throw new Error('CSV is missing column: "Student Name" (学生姓名/姓名/学生)');if(y!==-1){m=!0;const S={};for(let E=1;E<f.length;E++){const I=f[E].trim();if(!I)continue;const z=(I.match(/(".*?"|[^",]+)(?=\s*,|\s*$)/g)||I.split(",")).map(L=>L.replace(/^"|"$/g,"").trim()),D=z[y];if(!D)continue;const F=C!==-1&&z[C]||"",_=w!==-1&&z[w]||"",A=N!==-1&&z[N]||"";S[D]||(S[D]={name:D,description:F,students:[]}),_&&S[D].students.push({name:_,email:A})}d=Object.values(S)}else{m=!1;for(let S=1;S<f.length;S++){const E=f[S].trim();if(!E)continue;const k=(E.match(/(".*?"|[^",]+)(?=\s*,|\s*$)/g)||E.split(",")).map(F=>F.replace(/^"|"$/g,"").trim()),z=w!==-1&&k[w]||"",D=N!==-1&&k[N]||"";z&&h.push({name:z,email:D})}}}if(m){if(d.length===0)throw new Error("No valid class elements found inside file.");const f=await fetch("/api/classes/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({classes:d})});if(!f.ok){const y=await f.json();throw new Error(y.error||"Server importation failed")}const g=await f.json();await s(),await r(),i({success:!0,message:n==="zh"?`成功导入 ${g.imported.length} 个班级数据!`:`Successfully imported ${g.imported.length} classes data!`})}else{if(h.length===0)throw new Error("No valid student elements found inside file.");const f=await fetch("/api/students/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({students:h})});if(!f.ok){const y=await f.json();throw new Error(y.error||"Server student importation failed")}const g=await f.json();await r(),i({success:!0,message:n==="zh"?`成功导入 ${g.imported.filter(y=>y.new).length} 名新学者,匹配并更新了其中的 ${g.imported.filter(y=>!y.new).length} 名同学!`:`Successfully imported ${g.imported.filter(y=>y.new).length} new students and updated ${g.imported.filter(y=>!y.new).length} existing ones!`})}}catch(u){o(u)}},l.onerror=()=>{o(new Error("Failed to read file from disk."))},l.readAsText(e)})}function VS(e,t){return new Promise((n,s)=>{const r=new FileReader;r.onload=i=>{try{const o=i.target?.result;if(!o)throw new Error("Empty CSV file");const l=o.split(/\r?\n/);if(l.length<2)throw new Error(t==="zh"?"CSV 文件行数不足,请包含标题和至少一行数据。":"CSV is missing content or headers.");const c=l[0].split(",").map(m=>m.trim().toLowerCase()),u=c.findIndex(m=>m.includes("title")||m.includes("标题")||m.includes("课程")),d=c.findIndex(m=>m.includes("content")||m.includes("内容")||m.includes("正文"));if(u===-1||d===-1)throw new Error(t==="zh"?'CSV 缺少必要表头列:必须包含 "Title"(课程标题)和 "Content"(课程内容)。':'CSV must contain "Title" and "Content" headers.');const h=[];for(let m=1;m<l.length;m++){const f=l[m].trim();if(!f)continue;const y=(f.match(/(".*?"|[^",]+)(?=\s*,|\s*$)/g)||f.split(",")).map(N=>N.replace(/^"|"$/g,"").trim()),C=y[u],w=y[d];C&&w&&h.push({title:C,content:w})}if(h.length===0)throw new Error(t==="zh"?"未能从 CSV 解析出有效课程数据。":"No valid courses found in CSV.");n(h)}catch(o){s(o)}},r.onerror=()=>{s(new Error(t==="zh"?"无法读取选取的 CSV 文件!":"Failure to read the CSV!"))},r.readAsText(e)})}async function US(e,t){const{lang:n,setImportProgress:s,fetchLessons:r}=t;let i=0;for(let o=0;o<e.length;o++){const l=e[o];try{const c=await fetch("/api/lessons",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:l.title,content:l.content})});if(c.ok)i++;else{const u=await c.json();console.warn(`Failed to import item ${o+1}:`,u)}}catch(c){console.warn(`Error importing item ${o+1}:`,c)}s(o+1)}return i>0?(await r(),{success:!0}):{success:!1,errorMsg:n==="zh"?"所有课程项导入均失败。请检查控制台或格式。":"Failed to import any of the courses. Please check your console or schema."}}const HS=30,Cl=(e,t)=>Math.min(e,t.length);function go(e){const t=new Date(e.timestamp).toLocaleString(),n=[`### [${e.type.toUpperCase()}] ${e.title}`,`- **发生时间**: ${t}`,`- **页面路径**: ${e.url||"N/A"}`,`- **错误摘要**: ${e.message}`];return e.endpoint&&n.push(`- **请求接口**: \`${e.endpoint}\` (HTTP ${e.status||"Unknown"})`),e.componentStack&&n.push("- **组件堆栈**:","```",e.componentStack.trim(),"```"),e.stack&&n.push("- **调用栈 (Stack Trace)**:","```",e.stack.trim(),"```"),n.join(`
|
|
154
|
+
`)}function qS(e){const t=new Date().toLocaleString(),n=typeof window<"u"?window.location.href:"Unknown",s=typeof navigator<"u"?navigator.userAgent:"Unknown";if(e.length===0)return`# 🛠️ OpenLearn 系统诊断报告
|
|
155
|
+
- 生成时间: ${t}
|
|
156
|
+
- 暂无记录的系统异常。`;const r=["# 🛠️ OpenLearn 系统异常诊断报告",`- **生成时间**: ${t}`,`- **当前页面**: ${n}`,`- **异常总数**: ${e.length} 项`,`- **运行环境**: ${s}`,"","---",""].join(`
|
|
157
|
+
`),i=e.map((o,l)=>`#### 错误 #${l+1} (${o.type.toUpperCase()})
|
|
158
|
+
`+go(o)).join(`
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
`);return`${r}${i}`}const en=bt((e,t)=>({errors:[],isErrorCenterOpen:!1,unreadCount:0,addError:n=>{const s=Date.now(),r=n.url||(typeof window<"u"?window.location.href:""),i=n.userAgent||(typeof navigator<"u"?navigator.userAgent:""),o=t().errors.findIndex(c=>c.type===n.type&&c.message===n.message&&s-c.timestamp<2e3);if(o>=0)return t().errors[o];const l={id:`err_${s}_${Math.random().toString(36).slice(2,7)}`,timestamp:n.timestamp||s,url:r,userAgent:i,type:n.type,title:n.title,message:n.message,stack:n.stack,componentStack:n.componentStack,endpoint:n.endpoint,status:n.status};return e(c=>{const u=[l,...c.errors].slice(0,HS);return{errors:u,unreadCount:Cl(c.unreadCount+1,u)}}),l},removeError:n=>e(s=>{const r=s.errors.filter(i=>i.id!==n);return{errors:r,unreadCount:Cl(s.unreadCount,r)}}),clearErrors:()=>e({errors:[],unreadCount:0}),setIsErrorCenterOpen:n=>e({isErrorCenterOpen:n,unreadCount:n?0:t().unreadCount}),markAllRead:()=>e({unreadCount:0})}));function Cn(e){return Is(en,e||(t=>t))}function WS(){const e=Cn(w=>w.errors),t=Cn(w=>w.isErrorCenterOpen),n=Cn(w=>w.setIsErrorCenterOpen),s=Cn(w=>w.clearErrors),r=Cn(w=>w.removeError),[i,o]=p.useState(!1),[l,c]=p.useState(null),[u,d]=p.useState(new Set),[h,m]=p.useState(!1),f=w=>{d(N=>{const S=new Set(N);return S.has(w)?S.delete(w):S.add(w),S})},g=async()=>{const w=qS(e);await Ns(w)&&(o(!0),setTimeout(()=>o(!1),2500))},y=async(w,N)=>{w.stopPropagation();const S=go(N);await Ns(S)&&(c(N.id),setTimeout(()=>c(null),2500))},C=w=>{switch(w){case"react":return a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-rose-100 text-rose-700 dark:bg-rose-950/60 dark:text-rose-400 border border-rose-200 dark:border-rose-800",children:"React"});case"api":return a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-purple-100 text-purple-700 dark:bg-purple-950/60 dark:text-purple-400 border border-purple-200 dark:border-purple-800",children:"API 5xx"});case"promise":return a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-amber-100 text-amber-700 dark:bg-amber-950/60 dark:text-amber-400 border border-amber-200 dark:border-amber-800",children:"Promise"});default:return a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-bold bg-blue-100 text-blue-700 dark:bg-blue-950/60 dark:text-blue-400 border border-blue-200 dark:border-blue-800",children:"Runtime"})}};return a.jsxs(a.Fragment,{children:[e.length>0&&!t&&!h&&a.jsxs(Ti.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,scale:.9},className:"fixed bottom-5 left-5 z-40 flex items-center gap-2 bg-slate-900/90 hover:bg-slate-900 backdrop-blur-md text-white px-3.5 py-2 rounded-2xl shadow-xl border border-rose-500/40 cursor-pointer select-none transition-all group",onClick:()=>n(!0),id:"system-error-pill",children:[a.jsxs("div",{className:"relative flex items-center justify-center",children:[a.jsx("span",{className:"animate-ping absolute inline-flex h-3 w-3 rounded-full bg-rose-400 opacity-75"}),a.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-rose-500"})]}),a.jsx($i,{size:15,className:"text-rose-400 group-hover:scale-110 transition-transform"}),a.jsxs("div",{className:"text-xs font-semibold flex items-center gap-1.5",children:[a.jsx("span",{children:"捕获到"}),a.jsx("span",{className:"bg-rose-500/80 text-white font-mono px-1.5 py-0.2 rounded-md text-xs font-bold",children:e.length}),a.jsx("span",{children:"处系统异常"})]}),a.jsx("button",{type:"button",className:"text-xs font-bold text-rose-300 hover:text-white bg-white/10 hover:bg-white/20 px-2 py-0.5 rounded-lg transition-colors ml-1",children:"查看与复制"}),a.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),m(!0)},className:"text-gray-400 hover:text-gray-200 p-0.5 hover:bg-white/10 rounded transition-colors ml-0.5",title:"暂时隐藏胶囊",children:a.jsx(ot,{size:13})})]}),a.jsx(zc,{children:t&&a.jsx("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-xs flex items-center justify-center p-4 z-50 overflow-hidden select-text",children:a.jsxs(Ti.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-gray-800 rounded-2xl shadow-2xl w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden text-gray-900 dark:text-gray-100",children:[a.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 dark:border-gray-800 flex items-center justify-between bg-gray-50/80 dark:bg-slate-850/80 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"p-2 bg-rose-500/10 text-rose-600 dark:text-rose-400 border border-rose-500/20 rounded-xl",children:a.jsx(rp,{size:18})}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2",children:[a.jsx("span",{children:"系统异常诊断中心 (System Diagnostics)"}),a.jsxs("span",{className:"text-xs font-normal text-gray-500 dark:text-gray-400",children:["(",e.length," 项记录)"]})]}),a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"自动捕获运行时、Promise 及接口 5xx 异常,支持一键导出 Markdown 格式排查报告。"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{type:"button",onClick:g,disabled:e.length===0,className:`px-3 py-1.5 rounded-lg text-xs font-bold transition-all flex items-center gap-1.5 shadow-xs cursor-pointer ${i?"bg-emerald-600 text-white":"bg-indigo-600 hover:bg-indigo-700 text-white disabled:opacity-40 disabled:cursor-not-allowed"}`,title:"复制所有异常报告为 Markdown 文本",children:[i?a.jsx(yt,{size:13}):a.jsx(An,{size:13}),a.jsx("span",{children:i?"已复制全部!":"一键复制全部诊断日志"})]}),a.jsx("button",{type:"button",onClick:s,disabled:e.length===0,className:"p-1.5 text-gray-500 hover:text-rose-600 dark:text-gray-400 dark:hover:text-rose-400 hover:bg-gray-100 dark:hover:bg-slate-800 rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",title:"清空记录",children:a.jsx(Al,{size:16})}),a.jsx("button",{type:"button",onClick:()=>n(!1),className:"p-1.5 text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-slate-800 rounded-lg transition-colors cursor-pointer",children:a.jsx(ot,{size:16})})]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 min-h-0 bg-slate-50/50 dark:bg-slate-950/30",children:e.length===0?a.jsxs("div",{className:"py-16 text-center text-gray-400 dark:text-gray-500 space-y-2",children:[a.jsx(yt,{size:32,className:"mx-auto text-emerald-500 opacity-80"}),a.jsx("p",{className:"text-sm font-semibold",children:"暂无捕获到的系统异常"}),a.jsx("p",{className:"text-xs opacity-75",children:"系统运行顺畅,所有模块均在正常状态下运作。"})]}):e.map((w,N)=>{const S=u.has(w.id),E=l===w.id;return a.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-gray-200 dark:border-gray-800 rounded-xl overflow-hidden shadow-2xs hover:border-gray-300 dark:hover:border-gray-700 transition-colors",children:[a.jsxs("div",{onClick:()=>f(w.id),className:"px-4 py-3 flex items-start justify-between gap-3 cursor-pointer select-none hover:bg-gray-50/50 dark:hover:bg-slate-850/50 transition-colors",children:[a.jsxs("div",{className:"flex items-start gap-2.5 min-w-0 flex-1",children:[a.jsx("span",{className:"text-gray-400 mt-0.5 shrink-0",children:S?a.jsx(Ps,{size:15}):a.jsx(Ml,{size:15})}),a.jsxs("div",{className:"space-y-1 min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[C(w.type),a.jsxs("span",{className:"font-bold text-xs text-gray-900 dark:text-gray-100 truncate",children:["#",e.length-N," ",w.title]}),a.jsx("span",{className:"text-xs text-gray-400 font-mono",children:new Date(w.timestamp).toLocaleTimeString()})]}),a.jsx("p",{className:"text-xs text-rose-600 dark:text-rose-400 font-mono break-all line-clamp-2",children:w.message}),w.endpoint&&a.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate",children:["接口: ",w.endpoint]})]})]}),a.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a.jsxs("button",{type:"button",onClick:I=>y(I,w),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition-all flex items-center gap-1 cursor-pointer ${E?"bg-emerald-600 text-white":"bg-gray-100 hover:bg-gray-200 text-gray-700 dark:bg-slate-800 dark:hover:bg-slate-700 dark:text-gray-200"}`,title:"一键复制此条错误报告",children:[E?a.jsx(yt,{size:11}):a.jsx(An,{size:11}),a.jsx("span",{children:E?"已复制":"复制"})]}),a.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),r(w.id)},className:"p-1 text-gray-400 hover:text-rose-600 rounded transition-colors cursor-pointer",title:"移除此项",children:a.jsx(ot,{size:13})})]})]}),S&&a.jsxs("div",{className:"px-4 py-3 bg-slate-900 text-slate-200 border-t border-gray-100 dark:border-gray-800 text-xs font-mono space-y-2.5",children:[a.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400 border-b border-slate-800 pb-1.5",children:[a.jsxs("span",{children:["页面地址: ",w.url||"未知"]}),a.jsxs("span",{children:["时间: ",new Date(w.timestamp).toLocaleString()]})]}),w.stack&&a.jsxs("div",{children:[a.jsx("span",{className:"text-rose-400 font-bold block mb-1",children:"Stack Trace:"}),a.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-48 overflow-y-auto opacity-90",children:w.stack})]}),w.componentStack&&a.jsxs("div",{className:"pt-2 border-t border-slate-800",children:[a.jsx("span",{className:"text-amber-400 font-bold block mb-1",children:"Component Stack:"}),a.jsx("pre",{className:"whitespace-pre-wrap text-xs leading-relaxed max-h-36 overflow-y-auto opacity-80",children:w.componentStack})]})]})]},w.id)})})]})})})]})}function GS(){p.useEffect(()=>{if(typeof window>"u")return;const e=r=>{const i=r.reason,o=i instanceof Error?i.message:typeof i=="string"?i:JSON.stringify(i)||"Unhandled promise rejection",l=i instanceof Error?i.stack:void 0;en.getState().addError({type:"promise",title:"未捕获的异步异常 (Unhandled Promise)",message:o,stack:l}),console.warn("[GlobalErrorCapture] Caught unhandled rejection:",i)},t=r=>{if(!r.message&&!r.error)return;const i=r.message||(r.error?.message??"Unknown script error"),o=r.error?.stack;en.getState().addError({type:"runtime",title:"JavaScript 运行时错误 (Runtime Error)",message:i,stack:o}),console.warn("[GlobalErrorCapture] Caught window error:",r.error||r.message)},n=window.fetch,s=async(...r)=>{try{const i=await n(...r);if(!i.ok&&i.status>=500)try{const l=await i.clone().text();let c="";try{const h=JSON.parse(l);c=h.error||h.message||h.details||l}catch{c=l.slice(0,300)}const u=r[0],d=typeof u=="string"?u:u instanceof Request?u.url:String(u);en.getState().addError({type:"api",title:`服务端接口错误 (HTTP ${i.status})`,message:c||`Request failed with status ${i.status}`,endpoint:d,status:i.status})}catch{}return i}catch(i){const o=r[0],l=typeof o=="string"?o:o instanceof Request?o.url:String(o);throw l&&(l.startsWith("/api")||l.includes("/api/"))&&en.getState().addError({type:"api",title:"网络请求失败 (Network Disconnected / Error)",message:i?.message||"Failed to fetch API endpoint",endpoint:l,stack:i?.stack}),i}};return window.fetch=s,window.addEventListener("unhandledrejection",e),window.addEventListener("error",t),()=>{window.fetch=n,window.removeEventListener("unhandledrejection",e),window.removeEventListener("error",t)}},[])}function QS(e){return"#/"+e}function kl(e){const t=e.replace(/^#/,"");return!t||t==="/"?null:t.replace(/^\//,"")}Vb();const El="openlearnv2.agentProviderId";function JS(){GS();const e=he(v=>v.lang),t=he(v=>v.setLang),n=aa[e]??aa.zh,[s,r]=p.useState(!1),i=typeof window<"u"&&(new URLSearchParams(window.location.search).get("mode")==="student_live"||window.location.hash.includes("student_live")),o=typeof window<"u"?new URLSearchParams(window.location.search).get("studentId"):null,l=typeof window<"u"?new URLSearchParams(window.location.search).get("lessonId"):null;typeof window<"u"&&new URLSearchParams(window.location.search).get("classId");const[c,u]=p.useState(!0),[d,h]=p.useState(null),m=he(v=>v.liveClassSelectedClassId),f=he(v=>v.setLiveClassSelectedClassId),g=he(v=>v.liveClassIsActive),y=he(v=>v.setLiveClassIsActive),[C,w]=p.useState(0),[N,S]=p.useState([]),[E,I]=p.useState(new Map),k=Nc(),[z,D]=p.useState([]),[F,_]=p.useState({}),[A,L]=p.useState([]),[O,R]=p.useState(0),[P,T]=p.useState(!1),[W,j]=p.useState(null),[$,x]=p.useState(!1),[oe,pe]=p.useState("system"),[b,J]=p.useState(null),[U,Q]=p.useState([]),[re,se]=p.useState(!1),[we,me]=p.useState(!1),le=async()=>{try{se(!0);const v=await fetch("/api/resources");if(v.ok){const B=await v.json();Q(B)}}catch(v){console.warn("Error fetching library resources:",v)}finally{se(!1)}};Je.useEffect(()=>{As.getState().initTheme(),Xt.getState().initFontSize();const v=B=>{(B.ctrlKey||B.metaKey)&&B.altKey&&(B.key==="+"||B.key==="="?(B.preventDefault(),Xt.getState().increaseScale()):B.key==="-"||B.key==="_"?(B.preventDefault(),Xt.getState().decreaseScale()):B.key==="0"&&(B.preventDefault(),Xt.getState().resetScale()))};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[]),Je.useEffect(()=>{$&&le()},[$]);const Ve=he(v=>v.lessons),wt=he(v=>v.setLessons),{lessonsSearchQuery:Ft,setLessonsSearchQuery:St,lessonsSortOrder:vt,setLessonsSortOrder:_t,filterEnrollment:Y,setFilterEnrollment:te,filterHasContent:ae,setFilterHasContent:je,filterThisMonth:Ue,setFilterThisMonth:He,copyingLessonId:ct,setCopyingLessonId:Ne,filteredAndSortedLessons:M}=BS(Ve),[H,K]=p.useState([]),Z=he(v=>v.selectedLesson),X=he(v=>v.setSelectedLesson),Pe=he(v=>v.elements),Ze=he(v=>v.setElements),[Fe,tt]=p.useState(!1),[ut,ge]=p.useState("idle"),[nt,_e]=p.useState(0),[Fs,Dn]=p.useState(0),[Bs,Ct]=p.useState(""),[Bt,ln]=p.useState([]),[$s,Vs]=p.useState(!1),[Us,Hs]=p.useState(!1),[qs,Ws]=p.useState("agent"),[Gs,Qs]=p.useState(!1),[Ce,Js]=p.useState([]),[Zs,Ys]=p.useState([]),[cn,un]=p.useState(null),[Fn,Ks]=p.useState(""),$t=he(v=>v.classes),Xs=he(v=>v.setClasses),Re=he(v=>v.students),Bn=he(v=>v.setStudents),{computerLabs:er,fetchLabs:$n,todaySchedules:tr,fetchTodaySchedules:Vt,classSchedulesMap:nr,fetchClassSchedules:xe,scheduleAttendanceMap:sr,fetchScheduleAttendance:rr,expandedScheduleId:ir,setExpandedScheduleId:or,newScheduleDate:ar,setNewScheduleDate:lr,newScheduleLessonId:cr,setNewScheduleLessonId:ur}=zS(),[Lt,dr]=p.useState(null),hr=p.useRef(null),fr=v=>{dr(v),hr.current=v},[Vn,Un]=p.useState({}),[pr,mr]=p.useState(null),Hn=p.useRef(null),[dn,hn]=p.useState(null),Ye=v=>{const B=em(v);B&&hn({type:v,data:{...B.defaultData}})},gr=async v=>{dn&&await Hn.current?.addElementAtCenter(dn.type,v),hn(null)},ye=he(v=>v.session),Rt=he(v=>v.setSession),qn=he(v=>v.siteInfo),Wn=he(v=>v.setSiteInfo),[Le,dt]=p.useState("teacher"),[xr,yr]=p.useState(!0),[Gn,Ut]=p.useState(!0),[br,ht]=p.useState("normal");p.useEffect(()=>{if(!ye)return;const v=async()=>{try{const q=await fetch("/api/db-status");if(q.ok){const G=await q.json().catch(()=>({}));G.status==="warning"||G.warning?ht("warning"):ht("normal"),Ut(!0)}else q.status===429||q.status===503?(ht("warning"),Ut(!0)):(ht("error"),Ut(!1))}catch{ht("error"),Ut(!1)}};v();const B=setInterval(v,5e3);return()=>clearInterval(B)},[ye]),p.useEffect(()=>{(async()=>{try{const B=await fetch("/api/auth/session");if(B.ok){const q=await B.json();if(q.session)if(Rt(q.session),i){dt("student"),We("lesson");const G=o||q.session.studentId;G&&pn(G),l&&X(l),jt()}else dt(q.session.role),q.session.role==="student"&&q.session.studentId&&(pn(q.session.studentId),jt())}}catch(B){console.warn("Session check failed",B)}finally{yr(!1)}})()},[]),p.useEffect(()=>{(async()=>{try{const B=await fetch("/api/site-settings");if(B.ok){const q=await B.json();Wn({siteName:q.siteName||"",slogan:q.slogan||"",logoUrl:q.logoUrl||null})}}catch(B){console.warn("Failed to fetch site settings:",B)}})()},[]);const Ht=he(v=>v.teacherTab),Ke=he(v=>v.setTeacherTab);p.useEffect(()=>{const v=()=>{const q=kl(window.location.hash);q&&q!==Ee.getState().teacherTab&&Ke(q)};window.addEventListener("hashchange",v);const B=kl(window.location.hash);return B&&Ke(B),()=>window.removeEventListener("hashchange",v)},[Ke]),p.useEffect(()=>{const v=QS(Ht);window.location.hash!==v&&(window.location.hash=v)},[Ht,Ke]);const[du,wr]=p.useState(!1),[hu,fu]=p.useState(!1),[pu,mu]=p.useState(!1);p.useEffect(()=>{ye?.subRole==="administrator"&&localStorage.getItem("edu_os_tour_completed")!=="true"&&wr(!0)},[ye]);const gu=async v=>{await Wt(),await ft(),await Vt().catch(()=>{}),f(v.classId),X(v.lessonId),y(!0),Ae(e==="zh"?"示范课堂准备就绪":"Demo Classroom Ready",e==="zh"?"示范班级与课件已加载,已自动开启授课状态!":"Demo class & courseware loaded. Live class session is now active!","success")};p.useEffect(()=>{Ht==="live_class"&&r(!0)},[Ht]);const{timelineSegments:xu,activeSegmentId:Sr,setActiveSegmentId:fn,draggedSegmentIdx:yu,setDraggedSegmentIdx:bu,editorSaveStatus:wu,setEditorSaveStatus:Su,editorLastSavedTime:vu,setEditorLastSavedTime:Cu,editorPanelsExpanded:ku,setEditorPanelsExpanded:Eu,saveTimeline:ju}=_S({selectedLesson:Z,lessons:Ve,setLessons:wt}),[ue,pn]=p.useState(null),[vr,Nu]=p.useState(null),[Pu,Tu]=p.useState(!1),Ae=(v,B,q="info")=>{const G=Math.random().toString(36).substring(2,9);Ee.getState().addToast({id:G,title:v,message:B,type:q}),setTimeout(()=>{Ee.getState().removeToast(G)},6e3)},qe=Le==="student"&&(!!ue&&!!Re.find(v=>v.id===ue)?.locked_lesson_id||Pu),Cr=()=>{Ae(e==="zh"?"🔒 全班专注锁定":"🔒 Class Focus Locked",e==="zh"?"老师已开启全班专注锁定,暂时无法切换页面,请跟随教师当前授课内容。":"The teacher locked the class focus. Navigation is disabled — please follow the current lesson.","warning")},ft=async()=>{try{const v=await fetch("/api/lessons");if(v.ok){const B=await v.json();wt(B),!Ee.getState().selectedLesson&&B.length>0&&X(B[0].id)}}catch(v){console.warn("Failed to fetch lessons",v)}},xo=p.useRef(()=>{}),yo=TS({lang:e,addToast:Ae,fetchLessons:ft,setSelectedLesson:X,setTeacherTab:Ke}),{isCourseWizardOpen:xv,setIsCourseWizardOpen:Iu,wizardStep:yv,setWizardStep:Au,wizardCourseTitle:bv,setWizardCourseTitle:wv,wizardCourseCategory:Sv,setWizardCourseCategory:vv,wizardCourseDescription:Cv,setWizardCourseDescription:kv,wizardCourseContent:Ev,setWizardCourseContent:jv,wizardCourseTimeline:Nv,setWizardCourseTimeline:Pv,wizardIsSubmitting:Tv,handleDeployWizardCourse:Iv}=yo,{plugins:kt,fetchPlugins:zu,aiProviders:pt,fetchAIProviders:_u,testingProviderId:Lu,storeTab:Ru,setStoreTab:Mu,pluginCode:Ou,setPluginCode:Du,installingPlugin:Fu,events:Bu,fetchEvents:$u,approvals:Vu,fetchApprovals:Uu,scoreOverrides:Hu,setScoreOverrides:qu,handleInstallPlugin:Wu,handleZipPluginUpload:Gu,handleTogglePlugin:Qu,handleDeletePlugin:Ju,handleApprove:Zu,handleReject:Yu}=PS({session:ye,host:k,lang:e,addToast:Ae,setChatLog:v=>xo.current(v),setTeacherTab:Ke,fetchLessons:ft}),[Mt,bo]=p.useState(()=>typeof window>"u"?"":window.localStorage.getItem(El)||""),kr=pt.some(v=>v.id===Mt)?Mt:pt[0]?.id||"",Ku=pt.find(v=>v.id===kr)||null,[Et,wo]=p.useState("dashboard"),So=p.useRef(qe),vo=p.useRef(Et);p.useEffect(()=>{So.current=qe,vo.current=Et},[qe,Et]),p.useEffect(()=>{qe&&(u(!0),wo("lesson"))},[qe]);const We=v=>{const B=typeof v=="function"?v(vo.current):v;if(So.current&&B!=="lesson"){Cr();return}wo(v)},[Co,qt]=p.useState("whiteboard"),[Xu,ed]=p.useState(null),[mt,Qn]=p.useState(null),[td,ko]=p.useState(!1),[nd,Eo]=p.useState(null),[sd,jo]=p.useState("whiteboard"),[rd,id]=p.useState("none"),[od,ad]=p.useState("none"),[ld,No]=p.useState(!0);p.useEffect(()=>{Et!=="lesson"&&No(!0)},[Et]);const Po=IS(),{isQuizGeneratorOpen:Av,setIsQuizGeneratorOpen:cd,quizGeneratorClassId:zv,setQuizGeneratorClassId:ud,quizGenMode:_v,setQuizGenMode:dd,quizGenSelectedLessonId:Lv,setQuizGenSelectedLessonId:hd,quizGenTopic:Rv,setQuizGenTopic:fd,isGeneratingSuggestions:Mv,setIsGeneratingSuggestions:Ov,suggestedObjectives:Dv,setSuggestedObjectives:pd,suggestedQuestions:Fv,setSuggestedQuestions:md,savingQuiz:Bv,setSavingQuiz:$v,quizStudentAnswers:gd,setQuizStudentAnswers:To,quizGenTimeLimit:Vv,setQuizGenTimeLimit:Uv,quizStudentAnswersRef:xd,subAssignmentTab:yd,setSubAssignmentTab:Io}=Po,[bd,wd]=p.useState(""),[Sd,vd]=p.useState("all"),[Cd,kd]=p.useState("grid"),[Ed,jd]=p.useState({}),[Nd,Pd]=p.useState({}),[Td,Id]=p.useState({}),Ao=LS(Le,vr,e),{studentNotifications:Ad,unreadNotifications:zd,readNotifications:zo,setReadNotifications:Jn,selectedNotificationForModal:_d,setSelectedNotificationForModal:Ld,isNotificationsOpen:Rd,setIsNotificationsOpen:Md}=Ao;p.useEffect(()=>{ue&&fetch(`/api/students/${ue}/read_notifications`).then(v=>v.ok?v.json():[]).then(v=>{Jn(new Set(v))}).catch(v=>{console.warn("Failed to load read notifications from DB",v),Jn(new Set)})},[ue]);const Od=p.useRef(null),Dd=v=>{mr(v),Od.current=v},[Fd,Bd]=p.useState({}),[$d,Vd]=p.useState({}),[Hv,qv]=p.useState({}),[Wv,Gv]=p.useState({}),[Ud,Qv]=p.useState(null),[Hd,qd]=p.useState("dueDate"),[Jv,Zv]=p.useState(null),[Wd,Gd]=p.useState({}),[Qd,_o]=p.useState(!1),[Jd,Lo]=p.useState(!1),[Zd,Er]=p.useState(null),[Yd,jr]=p.useState(null),[Nr,Kd]=p.useState(null),Xd=p.useRef(null),Ro=v=>{Kd(v),Xd.current=v};p.useEffect(()=>{typeof window<"u"&&window.localStorage.setItem(El,Mt)},[Mt]),p.useEffect(()=>{pt.length>0&&!pt.some(v=>v.id===Mt)&&bo(pt[0].id)},[pt,Mt]);const eh=async(v,B,q)=>{try{if((await fetch(`/api/classes/${v}/schedules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:B,scheduledDate:q})})).ok)return await xe(v),!0}catch(G){console.error("Quick schedule class failed",G)}return!1},th=async(v,B,q)=>{try{const G=B||q||"Assignment",Te=await fetch(`/api/classes/${v}/assignments/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:G})});if(Te.ok){const gt=await Te.json().catch(()=>({}));return await mn(v),gt.id||"assignment-created"}}catch(G){console.error("Quick generate assignment failed",G)}return null},nh=async(v,B)=>{try{const q=await fetch("/api/lessons",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:v,content:B})});if(q.ok){const G=await q.json().catch(()=>({}));return await ft(),G.id||"lesson-created"}}catch(q){console.error("Quick create lesson failed",q)}return""},sh=()=>{vl("class",e)},rh=async v=>{if(v){if(!v.name.toLowerCase().endsWith(".csv")){ge("error"),Ct(e==="zh"?"只支持包含 .csv 后缀名的文件!":"Only files ending in .csv are supported!");return}ge("parsing"),Ct("");try{const B=await VS(v,e);ln(B),ge("idle")}catch(B){ge("error"),Ct(B.message||String(B))}}},ih=async()=>{if(Bt.length===0)return;ge("importing"),_e(0),Dn(Bt.length);const v=await US(Bt,{lang:e,setImportProgress:_e,fetchLessons:ft});v.success?ge("success"):(ge("error"),Ct(v.errorMsg||""))},oh=async v=>{const B=await fetch(`/api/lessons/${v}`,{method:"DELETE"});if(!B.ok){const q=await B.json().catch(()=>({}));throw new Error(q.error||"Failed to delete course")}await ft(),Z===v&&X(null),Ae(e==="zh"?"课程已删除":"Course Deleted",e==="zh"?"课程及其所有关联数据已被删除。":"The course and all associated data have been deleted.","success")},ah=async v=>{Ne(v);try{const B=await fetch(`/api/lessons/${v}/clone`,{method:"POST"});if(!B.ok){const q=await B.json().catch(()=>({}));throw new Error(q.error||"Failed to copy course")}await ft(),Ae(e==="zh"?"复制成功":"Course Copied",e==="zh"?"课程已成功复制。":"Course has been copied successfully.","success")}catch(B){Ae(e==="zh"?"复制失败":"Copy Failed",B.message||(e==="zh"?"复制课程时发生错误。":"An error occurred while copying the course."),"error")}finally{Ne(null)}},Mo=async()=>{try{const v=await fetch("/api/commands/registered");if(!v.ok)return;const B=v.headers.get("content-type");if(B&&B.includes("application/json")){const q=await v.json();Array.isArray(q)&&K(q)}}catch(v){console.warn("Failed to fetch registered commands",v)}},lh=async v=>{if(ye)try{const B=await fetch(`/api/vfs${v?`?parentId=${v}`:""}`);if(B.ok){const q=await B.json();Js(q)}}catch(B){console.warn("Failed to fetch VFS nodes",B)}},ch=async()=>{try{const v=await fetch("/api/processes");v.ok&&Ys(await v.json())}catch{}},Wt=async()=>{try{const v=await fetch("/api/classes");v.ok&&Xs(await v.json())}catch{}},jt=async()=>{try{const v=await fetch("/api/students");v.ok&&Bn(await v.json())}catch{}},Gt=async v=>{try{const B=await fetch(`/api/classes/${v}/students`);if(B.ok){const q=await B.json();Un(G=>({...G,[v]:q}))}}catch{}},Pr=async v=>{try{const B=await fetch(`/api/classes/${v}/progress`);if(B.ok){const q=await B.json();Vd(G=>({...G,[v]:q}))}}catch{}},[Tr,uh]=p.useState({}),mn=async v=>{try{const B=await fetch(`/api/classes/${v}/dashboard`);if(B.ok){const q=await B.json();uh(G=>({...G,[v]:q}))}}catch{}},dh=FS({lang:e,classes:$t,classStudentsMap:Vn,classDashboardMap:Tr,fetchClassStudents:Gt,fetchClassDashboard:mn,fetchClassProgress:Pr}),{isExportWeightModalOpen:hh,setIsExportWeightModalOpen:Oo,exportClassId:fh,setExportClassId:ph,exportClassName:mh,setExportClassName:gh,quizzesWeight:xh,setQuizzesWeight:Do,assignmentsWeight:yh,setAssignmentsWeight:Fo,customCategoryOverrides:bh,setCustomCategoryOverrides:Bo,exportDropdownOpen:wh,setExportDropdownOpen:Sh,exportTooltipOpen:vh,setExportTooltipOpen:Ch,loadingExportClassId:kh,isExportingAllCombined:Eh,isGeneratingPDFReport:jh,handleQuizzesWeightChange:Nh,handleAssignmentsWeightChange:Ph,csvPreviewData:Th,triggerExportForClass:Ih,handleExportGrades:Ah,handleGeneratePDFReport:zh,handleExportAllClassesCombined:$o,get30DayAverageWarning:_h}=dh,Vo=AS({lang:e,classes:$t,expandedClassId:Lt,fetchClasses:Wt,fetchClassStudents:Gt,handleExportAllClassesCombined:$o}),{batchMode:Lh,setBatchMode:Rh,selectedClassIds:Mh,setSelectedClassIds:Oh,selectedStudentIds:Dh,setSelectedStudentIds:Fh,batchPicker:Yv,setBatchPicker:Kv,batchPickerLesson:Xv,setBatchPickerLesson:eC,batchPickerDate:tC,setBatchPickerDate:nC,batchPickerTargetClass:sC,setBatchPickerTargetClass:rC,toggleClassSelection:Bh,toggleSelectAllClasses:$h,toggleStudentSelection:Vh,toggleSelectAllStudents:Uh,handleBatchDeleteClasses:Hh,handleBatchExportClasses:qh,handleBatchSetPasscode:Wh,handleBatchScheduleClasses:Gh,handleBatchDeleteStudents:Qh,handleBatchResetPassword:Jh,handleBatchTransferStudents:Zh,handleBatchSetLockedLesson:Yh,confirmBatchPicker:iC}=Vo,Ir=async v=>{try{const B=await fetch(`/api/students/${v}/dashboard`);if(B.ok){const q=await B.json();Nu(q),q.profile&&q.profile.locked_lesson_id&&(X(q.profile.locked_lesson_id),We("lesson"))}}catch{}},Kh=async(v=!1)=>{if(!mt)return;const q=mt?.content&&mt.content.startsWith('{"quizType":"mcq_learning_objectives"')?JSON.stringify(xd.current):"Submitted via Whiteboard";try{(await fetch(`/api/assignments/${mt.id}/submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:ue,content:q})})).ok&&(v&&alert("Time is up! Your assessment was successfully submitted automatically."),await Ir(ue),We("dashboard"),Qn(null))}catch(G){console.error(G)}};p.useEffect(()=>{if(ye&&Le==="student"&&ue){Ir(ue);const v=Re.find(B=>B.id===ue);v&&v.locked_lesson_id&&(X(v.locked_lesson_id),We("lesson"))}},[ye,Le,ue,Re]);const Xh=p.useRef(Le),ef=p.useRef(ue),tf=p.useRef(e),nf=p.useRef(Re),sf=p.useRef(Ae),Zn=p.useRef(new Set);p.useRef(new Set),p.useEffect(()=>{Xh.current=Le},[Le]),p.useEffect(()=>{ef.current=ue},[ue]),p.useEffect(()=>{tf.current=e},[e]),p.useEffect(()=>{nf.current=Re},[Re]),p.useEffect(()=>{sf.current=Ae},[Ae]),p.useEffect(()=>{if(!k.isInitialized()||kt.length===0)return;const v=ke.getState(),B=kt.filter(G=>G.status==="active");for(const G of B){if(!G.has_frontend||Zn.current.has(G.id))continue;const Te=v.activePlugins.find(xt=>xt.id===G.id),gt=!!(Te&&G.version&&Te.version!==G.version);if(!(!Te||gt||Te.state!==be.ACTIVE&&Te.state!==be.ACTIVATING))continue;Zn.current.add(G.id);const qo=()=>{if(!v.activePlugins.find(xt=>xt.id===G.id))v.addPlugin({id:G.id,name:G.name,version:G.version,state:be.INSTALLED,executionMode:"inline"});else if(gt)try{ke.setState(xt=>({activePlugins:xt.activePlugins.map(gn=>gn.id===G.id?{...gn,version:G.version,name:G.name}:gn)}))}catch{}try{const xt=JSON.parse(G.manifest);k.activateRemotePlugin(G.id,xt).catch(gn=>{console.error(`[App] Failed to activate remote plugin "${G.name}":`,gn)}).finally(()=>{Zn.current.delete(G.id)})}catch(xt){Zn.current.delete(G.id),console.error(`[App] Failed to parse manifest for plugin "${G.name}":`,xt)}};Te&&Te.state===be.ACTIVE&>?k.deactivatePlugin(G.id).catch(()=>{}).finally(qo):qo()}const q=kt.filter(G=>G.status!=="active");for(const G of q){if(!G.has_frontend)continue;const Te=v.activePlugins.find(gt=>gt.id===G.id);Te&&Te.state===be.ACTIVE&&k.deactivatePlugin(G.id).catch(gt=>{console.error(`[App] Failed to deactivate remote plugin "${G.name}":`,gt)})}},[kt,k]),Je.useEffect(()=>{if(!k.isInitialized()||kt.length===0)return;const v=ke.getState();for(const B of kt)B.status==="active"&&(v.dashboardVisibility.has(B.id)||v.setDashboardVisibility(B.id,!0))},[kt,k]);const rf=async v=>{if(Le==="student"&&ue&&Z)try{await fetch(`/api/students/${ue}/progress`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:Z,completed:v===100,progressPercent:v})})}catch(B){console.error("Failed to update student progress:",B)}},of=async(v,B)=>{try{const q=await fetch(`/api/classes/${v}/lessons/${B}/progress`);q.ok&&L(await q.json())}catch{}};p.useEffect(()=>{m&&Z?of(m,Z):L([])},[m,Z]),p.useEffect(()=>{m&&Gt(m)},[m]);const af=async v=>{try{const B=await fetch(`/api/students/${v}/progress`);if(B.ok){const q=await B.json();Bd(G=>({...G,[v]:q}))}}catch{}},Uo=async v=>{try{const B=await fetch(`/api/processes/${v}/logs`);if(B.ok){const q=await B.json();Ks(q.logs||""),un(v)}}catch{}},Nt=async v=>{const q=await(await fetch(`/api/lessons/${v}/whiteboard`)).json();Ze(q)},lf=p.useRef(null);p.useRef(null);const cf=p.useRef(null);p.useEffect(()=>{lf.current=Z},[Z]),p.useEffect(()=>{cf.current=mt},[mt]),Wc(ye);const{chatLog:uf,setChatLog:df,input:hf,setInput:ff,loading:pf,chatAttachments:mf,setChatAttachments:gf,handleChatFileChange:xf,handleChatDrop:yf,handleSend:bf,handleClearAgentMemory:wf}=Pw({lang:e,t:n,selectedLesson:Z,effectiveAgentProviderId:kr,expandedClassId:Lt,fetchLessons:ft,fetchClasses:Wt,fetchStudents:jt,fetchClassStudents:Gt,fetchClassProgress:Pr,fetchClassDashboard:mn,fetchElements:Nt});xo.current=df,Nw({session:ye,showProcessLogs:cn,activeStudentId:ue,currentVfsParent:Nr,selectedLesson:Z,selectedAssignment:mt,expandedClassId:Lt,fetchLessons:ft,fetchPlugins:zu,fetchRegisteredCommands:Mo,fetchEvents:$u,fetchApprovals:Uu,fetchProcesses:ch,fetchClasses:Wt,fetchTodaySchedules:Vt,fetchStudents:jt,fetchLabs:$n,fetchVfs:lh,fetchProcessLogs:Uo,fetchClassStudents:Gt,fetchElements:Nt});const{socketRef:Sf}=jS({session:ye,host:k,activeRole:Le,activeStudentId:ue,selectedLesson:Z,activeSegmentId:Sr,studentViewStatus:Et,lang:e,students:Re,addToast:Ae,setOnlineStudentIds:D,setActiveStudentLessons:_,setLessons:wt,setActiveSegmentId:fn,setLiveClassStudentProgress:L,setLiveClassAcknowledgedMap:I,setLiveClassFeed:S,setSelectedLesson:X,setStudentViewStatus:We,studentLessonTab:Co,setStudentLessonTab:qt,selectedAssignment:mt,setSelectedAssignment:Qn,setLocalProgressPercent:R,fetchStudentDashboard:Ir,fetchStudents:jt,fetchElements:Nt}),vf=v=>{vl(v,e)},Cf=async v=>{Lo(!0),Er(null),jr(null);try{const B=await $S(v,{lang:e,fetchClasses:Wt,fetchStudents:jt});jr(B.message)}catch(B){Er(B.message||String(B))}finally{Lo(!1)}},kf=()=>{t(e==="zh"?"en":"zh")},Ef=p.useCallback(v=>{Rt(v),v.role==="teacher"?(dt("teacher"),Ke("dashboard")):(dt("student"),pn(v.studentId),jt())},[]),Ho=async()=>{try{await fetch("/api/auth/logout",{method:"POST"})}catch(v){console.error("Logout failed",v)}Rt(null)},[jf,Ar]=p.useState(!1);return p.useEffect(()=>{if(!i)return;const v=new ua;v.requestHandshake();const B=v.onMessage(q=>{switch(q.type){case"TEACHER_INIT_STATE":{const G=q.payload;G.selectedLesson&&(X(G.selectedLesson),Nt(G.selectedLesson)),G.activeSegmentId&&fn(G.activeSegmentId),G.activeTab&&qt(G.activeTab),G.liveClassTimeRemaining!==void 0&&w(G.liveClassTimeRemaining),G.fullscreenElementId!==void 0&&(tn.getState().setRemoteFullscreenElementId(G.fullscreenElementId),G.fullscreenElementId&&qt("whiteboard")),We("lesson");break}case"TEACHER_CHANGE_LESSON":{c&&q.payload.lessonId&&(X(q.payload.lessonId),Nt(q.payload.lessonId),We("lesson"));break}case"TEACHER_CHANGE_SEGMENT":{c&&q.payload.segmentId&&fn(q.payload.segmentId);break}case"TEACHER_CHANGE_TAB":{c&&q.payload.tab&&qt(q.payload.tab);break}case"TEACHER_LOCK_CLASS":{Tu(!!q.payload.locked),q.payload.locked?(u(!0),We("lesson"),Ae(e==="zh"?"🔒 全班专注锁定":"🔒 Class Focus Lock",e==="zh"?"老师已开启全班专注锁定,界面将保持同步授课。":"Teacher locked screen for class.","warning")):Ae(e==="zh"?"🔓 屏幕已解锁":"🔓 Screen Unlocked",e==="zh"?"老师已解除锁定,您可以自由浏览或答题。":"Screen unlocked.","info");break}case"TEACHER_PICK_STUDENT":{(!ue||ue===q.payload.studentId||o===q.payload.studentId)&&h(q.payload);break}case"TEACHER_SYNC_TIMER":{w(q.payload.timeRemaining);break}case"TEACHER_PING_STUDENT":{(!ue||ue===q.payload.studentId)&&Ae(e==="zh"?"⚠️ 课堂提醒":"⚠️ Classroom Alert",q.payload.message||(e==="zh"?"老师提醒您集中注意力跟上教学进度!":"Please keep up with class!"),"warning");break}case"TEACHER_BROADCAST_FULLSCREEN":{const{elementId:G,lessonId:Te}=q.payload;tn.getState().setRemoteFullscreenElementId(G),G&&(Te&&Te!==Z&&(X(Te),Nt(Te)),We("lesson"),qt("whiteboard"));break}}});return()=>{B(),v.destroy()}},[i,c,ue,o,e]),xr?a.jsxs("div",{className:"min-h-screen bg-slate-900 flex flex-col items-center justify-center p-4 relative overflow-hidden font-sans",children:[a.jsx(Bi,{size:48,className:"text-indigo-500 animate-spin"}),a.jsx("span",{className:"text-white text-sm mt-4 font-semibold tracking-wide",children:e==="zh"?"正在连接安全核心数据库...":"Connecting Secure OS Core Database..."})]}):ye?a.jsx(a.Fragment,{children:a.jsxs("div",{className:"flex h-screen bg-app text-main font-sans transition-colors duration-150",children:[a.jsxs("div",{className:"flex-1 flex flex-col bg-app h-full overflow-hidden",children:[ye?.role==="teacher"&&Le==="student"&&!i&&a.jsxs("div",{className:"bg-gradient-to-r from-amber-500 via-amber-600 to-orange-500 text-white px-6 py-1.5 flex items-center justify-between text-xs font-medium shadow-sm z-30 shrink-0 border-b border-amber-600/30",children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsxs("span",{className:"bg-black/20 text-amber-100 px-2 py-0.5 rounded font-bold uppercase tracking-wider text-xs flex items-center gap-1",children:[a.jsx(Ts,{size:12}),e==="zh"?"学生模拟模式":"Student View Mode"]}),a.jsx("span",{children:e==="zh"?`您当前正在以学生身份(${Re.find(v=>v.id===ue)?.name||"未选择"})预览系统界面与交互。`:`You are currently previewing the platform as student (${Re.find(v=>v.id===ue)?.name||"None"}).`})]}),a.jsxs("button",{type:"button",onClick:()=>dt("teacher"),className:"bg-white text-amber-800 hover:bg-amber-50 active:bg-amber-100 font-bold px-3 py-1 rounded-md shadow-xs transition-all flex items-center gap-1.5 cursor-pointer text-xs",children:[a.jsx(Oi,{size:13}),e==="zh"?"退出模拟并返回教师端":"Exit Student View"]})]}),i?a.jsxs("header",{className:"h-13 bg-surface/95 backdrop-blur-md border-b border-theme px-4 flex items-center justify-between z-20 shrink-0 select-none shadow-xs",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-tr from-pink-500 to-rose-600 flex items-center justify-center text-white font-black shadow-sm text-sm",children:"🎓"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h1",{className:"text-sm font-black text-main tracking-wide",children:e==="zh"?"互动课堂 · 学生端":"Interactive Classroom · Student Client"}),a.jsxs("span",{className:"flex items-center gap-1 text-xs font-bold text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded-full",children:[a.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse"}),e==="zh"?"已与教师中控台实时联动":"Synced with Teacher"]})]}),a.jsxs("div",{className:"text-xs text-muted flex items-center gap-2",children:[a.jsx("span",{children:ue?`学生: ${Re.find(v=>v.id===ue)?.name||ue}`:"学生端"}),a.jsx("span",{children:"•"}),a.jsx("span",{children:Z?`课节: ${Ve.find(v=>v.id===Z)?.title||Z}`:"等待教师推流课节..."})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>{if(qe){Cr();return}u(!c)},disabled:qe,className:`px-3 py-1.5 rounded-lg text-xs font-bold border transition-all flex items-center gap-1.5 shadow-2xs ${qe?"cursor-not-allowed":"cursor-pointer"} ${c?"bg-indigo-50 dark:bg-indigo-950/40 text-indigo-600 dark:text-indigo-400 border-indigo-200 dark:border-indigo-800":"bg-surface text-muted border-theme hover:text-main"} ${qe?"opacity-70":""}`,title:qe?e==="zh"?"全班专注锁定中,已强制跟随教师步调":"Class focus is locked; following the teacher is enforced":e==="zh"?"开启后,教师端切换课节/环节/Tab时,学生端将自动同步跟随":"Follow teacher navigation",children:[a.jsx(Ol,{size:12,className:c?"animate-spin":""}),a.jsx("span",{children:e==="zh"?`跟随教师步调: ${c?"开":"关"}`:`Follow Teacher: ${c?"ON":"OFF"}`})]}),a.jsx(Hl,{lang:e}),a.jsx("button",{type:"button",onClick:()=>{document.fullscreenElement?document.exitFullscreen().catch(()=>{}):document.documentElement.requestFullscreen().catch(()=>{})},className:"p-1.5 text-muted hover:text-main rounded-lg border border-theme hover:bg-surface-secondary transition-colors cursor-pointer",title:e==="zh"?"切换全屏":"Toggle Fullscreen",children:a.jsx(ip,{size:14})}),a.jsx("button",{type:"button",onClick:()=>window.close(),className:"px-2.5 py-1.5 text-xs font-bold text-rose-600 hover:text-rose-700 bg-rose-50 dark:bg-rose-950/30 border border-rose-200 dark:border-rose-900 rounded-lg transition-colors cursor-pointer",title:e==="zh"?"关闭学生端Tab":"Close Tab",children:e==="zh"?"关闭Tab":"Close Tab"})]})]}):a.jsx(Qp,{activeRole:Le,setActiveRole:dt,lang:e,teacherTab:Ht,studentViewStatus:Et,session:ye,activeStudentId:ue,students:Re,studentDashboardData:vr,isNotificationsOpen:Rd,studentNotifications:Ad,unreadNotifications:zd,readNotifications:zo,selectedNotificationForModal:_d,dbConnected:Gn,dbStatus:br,siteInfo:qn,setActiveStudentId:pn,setReadNotifications:Jn,setIsSystemResourceLibraryOpen:x,setProfileOpen:Ar,setTeacherTab:Ke,setStudentViewStatus:We,setIsNotificationsOpen:Md,setSelectedNotificationForModal:Ld,handleLogout:Ho,toggleLanguage:kf,isStudentLocked:qe,onBlockedNavigate:Cr}),a.jsx(Zp,{open:jf,session:ye,lang:e,onClose:()=>Ar(!1),onSaved:v=>{ye&&Rt({...ye,name:v}),Ar(!1)},onAvatar:v=>{ye&&Rt({...ye,avatar:v??void 0})}}),a.jsx(Wb,{students:Re,activeStudentId:ue,isStudentLocked:qe,studentViewStatus:Et,studentDashboardData:vr,readNotifications:zo,setReadNotifications:Jn,addToast:Ae,lang:e,setSelectedLesson:X,setStudentViewStatus:We,setSelectedAssignment:Qn,setQuizStudentAnswers:To,setSubAssignmentTab:Io,lessons:Ve,selectedLesson:Z,studentFullscreenPanel:od,setStudentFullscreenPanel:ad,timelineSegments:xu,activeSegmentId:Sr,setActiveSegmentId:fn,localProgressPercent:O,setLocalProgressPercent:R,updateStudentProgress:rf,isStudentLessonContentCollapsed:ld,setIsStudentLessonContentCollapsed:No,studentLessonTab:Co,setStudentLessonTab:qt,elements:Pe,activeRole:Le,fetchElements:Nt,currentVfsParent:Nr,setCurrentVfsParent:Ro,vfsNodes:Ce,studentSelectedCourseware:Xu,setStudentSelectedCourseware:ed,selectedAssignment:mt,quizStudentAnswers:gd,submitQuizAssignment:Kh,subAssignmentTab:yd,mainNavCollapsed:s,setMainNavCollapsed:r,teacherTab:Ht,setTeacherTab:Ke,session:ye,todaySchedules:tr,t:n,classes:$t,approvals:Vu,processes:Zs,isApprovalsCollapsed:hu,setIsApprovalsCollapsed:fu,isProcessesCollapsed:pu,setIsProcessesCollapsed:mu,scoreOverrides:Hu,setScoreOverrides:qu,handleApprove:Zu,handleReject:Yu,showLogs:Gs,setShowLogs:Qs,processLogsContent:Fn,showProcessLogs:cn,fetchProcessLogs:Uo,setShowProcessLogs:un,handleQuickScheduleClass:eh,handleQuickGenerateAssignment:th,handleQuickCreateLesson:nh,setActiveRole:dt,editorSaveStatus:wu,setEditorSaveStatus:Su,editorLastSavedTime:vu,setEditorLastSavedTime:Cu,setIsLessonPreviewVisible:ko,setPreviewLessonTab:jo,setPreviewSelectedCourseware:Eo,handlePaletteActivate:Ye,draggedSegmentIdx:yu,setDraggedSegmentIdx:bu,saveTimeline:ju,editorPanelsExpanded:ku,setEditorPanelsExpanded:Eu,whiteboardRef:Hn,paletteEdit:dn,handlePaletteConfirm:gr,setPaletteEdit:hn,plugins:kt,liveClassSelectedClassId:m,setLiveClassSelectedClassId:f,liveClassIsActive:g,setLiveClassIsActive:y,liveClassTimeRemaining:C,setLiveClassTimeRemaining:w,liveClassFeed:N,setLiveClassFeed:S,liveClassAcknowledgedMap:E,setLiveClassAcknowledgedMap:I,onlineStudentIds:z,activeStudentLessons:F,liveClassStudentProgress:A,storeTab:Ru,setStoreTab:Mu,pluginCode:Ou,setPluginCode:Du,installingPlugin:Fu,onInstall:Wu,onZipUpload:Gu,onToggle:Qu,onDelete:Ju,lessonsSearchQuery:Ft,setLessonsSearchQuery:St,lessonsSortOrder:vt,setLessonsSortOrder:_t,filteredLessons:M,onOpenImportLessons:()=>{ge("idle"),_e(0),Dn(0),Ct(""),ln([]),tt(!0)},onOpenCourseWizard:()=>{Au(1),Iu(!0)},onViewCourse:v=>{Ke("lesson_editor"),X(v)},onDeleteCourse:oh,onCopyCourse:ah,filterEnrollment:Y,setFilterEnrollment:te,filterHasContent:ae,setFilterHasContent:je,filterThisMonth:Ue,setFilterThisMonth:He,copyingLessonId:ct,onSchedulesUpdated:Vt,onLogout:Ho,aiProviders:pt,testingProviderId:Lu,onAIProvidersChanged:_u,onTriggerTour:()=>wr(!0),siteInfo:qn,onSiteInfoChanged:Wn,computerLabs:er,onRefresh:$n,registeredCommands:H,fetchRegisteredCommands:Mo,batchMode:Lh,selectedClassIds:Mh,setSelectedClassIds:Oh,setSelectedStudentIds:Fh,setBatchMode:Rh,expandedClassId:Lt,setExpandedClassId:fr,exportTooltipOpen:vh,setExportTooltipOpen:Ch,exportDropdownOpen:wh,setExportDropdownOpen:Sh,isExportingAllCombined:Eh,loadingExportClassId:kh,classStudentsMap:Vn,setClassStudentsMap:Un,expandedStudentId:pr,setExpandedStudentId:Dd,selectedStudentIds:Dh,rosterViewMode:Cd,setRosterViewMode:kd,rosterSearchQuery:bd,setRosterSearchQuery:wd,rosterTagFilter:Sd,setRosterTagFilter:vd,toggleSelectAllStudents:Uh,handleBatchDeleteStudents:Qh,handleBatchResetPassword:Jh,handleBatchTransferStudents:Zh,handleBatchSetLockedLesson:Yh,toggleStudentSelection:Vh,get30DayAverageWarning:_h,studentProgressMap:Fd,studentActiveTabs:Td,setStudentActiveTabs:Id,setStudents:Bn,fetchClassStudents:Gt,fetchStudents:jt,parseCSV:Fp,setImportError:Er,setImportSuccess:jr,setShowImportModal:_o,fetchClasses:Wt,classSubmissionFilters:Ed,setClassSubmissionFilters:jd,classActiveTabs:Nd,setClassActiveTabs:Pd,classProgressMap:$d,classSchedulesMap:nr,classDashboardMap:Tr,assignmentSortOrder:Hd,setAssignmentSortOrder:qd,isGeneratingPDFReport:jh,handleGeneratePDFReport:zh,setExportClassId:ph,setExportClassName:gh,setQuizzesWeight:Do,setAssignmentsWeight:Fo,setCustomCategoryOverrides:Bo,setIsExportWeightModalOpen:Oo,isGeneratingAssignment:Ud,setQuizGeneratorClassId:ud,setQuizGenMode:dd,setQuizGenSelectedLessonId:hd,setQuizGenTopic:fd,setSuggestedObjectives:pd,setSuggestedQuestions:md,setIsQuizGeneratorOpen:cd,setActiveStudentId:pn,isGrading:Wd,setIsGrading:Gd,fetchClassDashboard:mn,newScheduleDate:ar,setNewScheduleDate:lr,newScheduleLessonId:cr,setNewScheduleLessonId:ur,expandedScheduleId:ir,setExpandedScheduleId:or,fetchScheduleAttendance:rr,scheduleAttendanceMap:sr,toggleSelectAllClasses:$h,handleBatchDeleteClasses:Hh,handleBatchExportClasses:qh,handleBatchSetPasscode:Wh,handleBatchScheduleClasses:Gh,handleExportAllClassesCombined:$o,triggerExportForClass:Ih,fetchClassProgress:Pr,fetchClassSchedules:xe,fetchStudentProgress:af,toggleClassSelection:Bh,socketRef:Sf,setShowCoursewareHub:me,fetchTodaySchedules:Vt})]}),a.jsx(lw,{showRightSidebar:Us,setShowRightSidebar:Hs,rightSidebarTab:qs,setRightSidebarTab:Ws,effectiveAgentProviderId:kr,agentProviderId:Mt,setAgentProviderId:bo,aiProviders:pt,selectedAgentProvider:Ku,chatLog:uf,loading:pf,input:hf,setInput:ff,handleSend:bf,chatAttachments:mf,setChatAttachments:gf,handleChatFileChange:xf,handleChatDrop:yf,onClearAgentMemory:wf,events:Bu,lang:e,t:n}),a.jsx(vw,{lang:e,t:n,courseWizard:yo,quizGenerator:Po,classBatch:Vo,studentNotificationsHook:Ao,showImportModal:Qd,setShowImportModal:_o,handleImportFile:Cf,importError:Zd,importSuccess:Yd,isImporting:Jd,downloadCSVTemplate:vf,addToast:Ae,generateTemplateContent:zb,isImportLessonsOpen:Fe,setIsImportLessonsOpen:tt,importStatus:ut,setIsDraggingImport:Vs,handleCSVFileChange:rh,downloadCsvTemplate:sh,isDraggingImport:$s,previewImportData:Bt,setPreviewImportData:ln,setImportStatus:ge,importProgress:nt,importProgressTotal:Fs,importErrorMsg:Bs,setImportErrorMsg:Ct,handleCSVImportSubmit:ih,lessons:Ve,fetchClassDashboard:mn,isLessonPreviewVisible:td,setIsLessonPreviewVisible:ko,selectedLesson:Z,previewFullscreenPanel:rd,setPreviewFullscreenPanel:id,previewLessonTab:sd,setPreviewLessonTab:jo,activeRole:Le,elements:Pe,activeSegmentId:Sr,setActiveSegmentId:fn,fetchElements:Nt,currentVfsParent:Nr,setCurrentVfsParent:Ro,vfsNodes:Ce,previewSelectedCourseware:nd,setPreviewSelectedCourseware:Eo,showProcessLogs:cn,setShowProcessLogs:un,processLogsContent:Fn,isCloudDriveOpen:P,setIsCloudDriveOpen:T,cloudDrivePreviewNode:W,setCloudDrivePreviewNode:j,isSystemResourceLibraryOpen:$,setIsSystemResourceLibraryOpen:x,systemResourceTab:oe,setSystemResourceTab:pe,selectedLibraryResourceId:b,setSelectedLibraryResourceId:J,loadingLibraryResources:re,libraryResources:U,fetchLibraryResources:le,classes:$t,expandedClassId:Lt,isExportWeightModalOpen:hh,setIsExportWeightModalOpen:Oo,quizzesWeight:xh,setQuizzesWeight:Do,assignmentsWeight:yh,setAssignmentsWeight:Fo,handleQuizzesWeightChange:Nh,handleAssignmentsWeightChange:Ph,customCategoryOverrides:bh,setCustomCategoryOverrides:Bo,classDashboardMap:Tr,exportClassId:fh,exportClassName:mh,csvPreviewData:Th,handleExportGrades:Ah,setSelectedAssignment:Qn,setStudentViewStatus:We,setQuizStudentAnswers:To,setSubAssignmentTab:Io,isTourOpen:du,setIsTourOpen:wr,handleSeedSuccess:gu,setTeacherTab:Ke,showCoursewareHub:we,setShowCoursewareHub:me}),d&&a.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/60 backdrop-blur-xs flex items-center justify-center p-4 animate-in fade-in duration-200",children:a.jsxs("div",{className:"bg-surface border-2 border-amber-500 rounded-2xl shadow-2xl p-6 max-w-md w-full text-center space-y-4 animate-in zoom-in-95 duration-300",children:[a.jsx("div",{className:"w-16 h-16 bg-amber-500/20 text-amber-500 rounded-full flex items-center justify-center mx-auto animate-bounce",children:a.jsx(_n,{size:36})}),a.jsx("h3",{className:"text-xl font-black text-main",children:e==="zh"?"⚡️ 闪电点名:老师选中了你!":"⚡️ Classroom Pick: Teacher Selected You!"}),a.jsx("p",{className:"text-sm text-muted",children:e==="zh"?a.jsxs(a.Fragment,{children:["老师在课堂点名中抽中了【",a.jsx("span",{className:"font-bold text-amber-600 dark:text-amber-400",children:d.studentName}),"】,请立即集中注意力参与课堂互动回答!"]}):a.jsxs(a.Fragment,{children:["The teacher selected"," ",a.jsx("span",{className:"font-bold text-amber-600 dark:text-amber-400",children:d.studentName})," ","to answer in class. Please respond now!"]})}),a.jsx("div",{className:"pt-2",children:a.jsxs("button",{type:"button",onClick:()=>{const v=new ua;v.acknowledgePick(d.studentId),v.destroy(),h(null),Ae(e==="zh"?"🙋♂️ 已确认答到":"🙋♂️ Acknowledged",e==="zh"?"已向老师中控台发送举手答到信号!":"Sent acknowledge signal to teacher!","success")},className:"w-full py-3 bg-gradient-to-r from-amber-500 to-orange-600 hover:from-amber-600 hover:to-orange-700 text-white font-black text-sm rounded-xl shadow-lg shadow-amber-500/30 transition-all active:scale-95 cursor-pointer flex items-center justify-center gap-2",children:[a.jsx(Ln,{size:18}),a.jsx("span",{children:e==="zh"?"🙋♂️ 我已准备好 / 确认答到 (反馈给老师)":"🙋♂️ Ready / Acknowledge to Teacher"})]})})]})}),a.jsx(aw,{}),a.jsx(WS,{})]})}):a.jsx(Bp,{onLoginSuccess:Ef,lang:e})}class ZS{constructor(){this.services=new Map}async register(t,n){if(this.services.has(t))throw new Error(`Service already registered: ${t}`);this.services.set(t,n)}async resolve(t){const n=this.services.get(t);if(!n)throw new Error(`No provider registered for token: ${t}`);return n}async unregister(t){this.services.delete(t)}has(t){return this.services.has(t)}list(){return Array.from(this.services.entries()).map(([t,n])=>({name:t,instance:n}))}}const YS=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}\./i;function KS(e,t){const n=t+".";return e.startsWith(n)||YS.test(e)?e:n+e}let XS=0;function ev(e,t){const s={student_id:"teacher_preview",student_name:"Teacher (Preview)",class_id:"",attempt_id:`att_srcdoc_${t}_${Date.now()}_${++XS}`},r={uuid:t,name:"Whiteboard HTML Applet"};return`<!DOCTYPE html>
|
|
163
|
+
<html><head>
|
|
164
|
+
<script>
|
|
165
|
+
window.__LMS_STUDENT__ = ${JSON.stringify(s)};
|
|
166
|
+
window.__LMS_COURSEWARE__ = ${JSON.stringify(r)};
|
|
167
|
+
(function() {
|
|
168
|
+
try {
|
|
169
|
+
// Override window.postMessage (self-targeting, always works)
|
|
170
|
+
var origPM = window.postMessage;
|
|
171
|
+
window.postMessage = function(msg, targetOrigin, transfer) {
|
|
172
|
+
var origin = (targetOrigin === 'null' || targetOrigin === null) ? '*' : targetOrigin;
|
|
173
|
+
try { return origPM.call(this, msg, origin, transfer); }
|
|
174
|
+
catch(err) { if (err.name === 'SyntaxError') return origPM.call(this, msg, '*', transfer); throw err; }
|
|
175
|
+
};
|
|
176
|
+
// Shadow window.parent / window.top with Proxy to intercept .postMessage()
|
|
177
|
+
// Direct assignment (window.parent.postMessage = ...) silently fails on cross-origin WindowProxy
|
|
178
|
+
function proxyWin(realRef, propName) {
|
|
179
|
+
try {
|
|
180
|
+
var safePost = function(msg, targetOrigin, transfer) {
|
|
181
|
+
var origin = (targetOrigin === 'null' || targetOrigin === null) ? '*' : targetOrigin;
|
|
182
|
+
try { return realRef.postMessage.call(realRef, msg, origin, transfer); }
|
|
183
|
+
catch(err) { if (err.name === 'SyntaxError') return realRef.postMessage.call(realRef, msg, '*', transfer); throw err; }
|
|
184
|
+
};
|
|
185
|
+
var px = new Proxy(realRef, {
|
|
186
|
+
get: function(t, p) {
|
|
187
|
+
if (p === 'postMessage') return safePost;
|
|
188
|
+
try { var v = t[p]; return typeof v === 'function' ? v.bind(t) : v; } catch(e) { return undefined; }
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
Object.defineProperty(window, propName, { get: function() { return px; }, configurable: true });
|
|
192
|
+
} catch(e) {}
|
|
193
|
+
}
|
|
194
|
+
if (window.parent && window.parent !== window) proxyWin(window.parent, 'parent');
|
|
195
|
+
try { if (window.top && window.top !== window) proxyWin(window.top, 'top'); } catch(e) {}
|
|
196
|
+
} catch(e) {}
|
|
197
|
+
})();
|
|
198
|
+
<\/script>
|
|
199
|
+
<script src="/bridge.js"><\/script>
|
|
200
|
+
</head><body>
|
|
201
|
+
${e||""}
|
|
202
|
+
</body></html>`}class tv{constructor(){this.loaders=new Map}register(t,n){this.loaders.set(t.id,{impl:t,pluginId:n})}unregister(t,n){const s=this.loaders.get(t);s&&(n&&s.pluginId!==n||this.loaders.delete(t))}unregisterPlugin(t){for(const[n,s]of this.loaders)s.pluginId===t&&this.loaders.delete(n)}resolve(t,n){for(const{impl:s}of this.loaders.values())try{const r=s.resolve(t,n);if(r)return r}catch{}return null}}const bs=new tv,nv=4;let as=0;const Mi=new Set;function jl(){return as>=nv?null:(as+=1,()=>{as=Math.max(0,as-1);for(const e of Mi)e()})}function sv(e){return Mi.add(e),()=>{Mi.delete(e)}}function rv(e,t){const[n,s]=p.useState(!e),[r,i]=p.useState(!1),o=p.useRef(null);return p.useEffect(()=>{if(!e||n)return;const l=t.current;if(!l)return;if(typeof IntersectionObserver>"u"){s(!0);return}const c=new IntersectionObserver(u=>{u.some(d=>d.isIntersecting)&&(s(!0),c.disconnect())},{rootMargin:"200px"});return c.observe(l),()=>c.disconnect()},[e,n,t]),p.useEffect(()=>{if(!n){o.current?.(),o.current=null,i(!1);return}const l=jl();if(l)o.current=l,i(!0);else{const c=sv(()=>{const u=jl();u&&(c(),o.current=u,i(!0))});return()=>c()}},[n]),p.useEffect(()=>()=>{o.current?.()},[]),r}function iv({data:e,lessonId:t,className:n,title:s,lazy:r=!0}){const i=Je.useRef(null),o=rv(r,i),{theme:l}=As(),{scale:c}=Xt(),u=()=>{Gc(l,Hi(l)),Qc(c)},d=bs.resolve(e,{lessonId:t}),h=e.coursewareUuid?`/runtime/${e.coursewareUuid}/`:e.resourceId?`/api/resources/${e.resourceId}/`:d??void 0;return a.jsx("div",{ref:i,className:n??"w-full h-full",children:o?a.jsx("iframe",{className:"w-full h-full border-none",src:h,srcDoc:h?void 0:ev(e.code||"",t),sandbox:"allow-scripts allow-forms allow-downloads",referrerPolicy:"no-referrer",title:s??e.title??"Interactive Courseware",credentialless:"true",onLoad:u}):a.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-gray-400 bg-slate-50 rounded-xl",children:"课件未加载"})})}class ov{constructor(){this.renderers=new Map}register(t,n,s){this.renderers.set(t,{impl:n,pluginId:s})}get(t){return this.renderers.get(t)?.impl}has(t){return this.renderers.has(t)}unregister(t,n){const s=this.renderers.get(t);s&&(n&&s.pluginId!==n||this.renderers.delete(t))}unregisterPlugin(t){for(const[n,s]of this.renderers)s.pluginId===t&&this.renderers.delete(n)}}const ws=new ov,SC=({type:e,title:t,data:n,containerSize:s,onClose:r,lessonId:i,dismissible:o=!0,readOnly:l=!1})=>{Je.useEffect(()=>{if(!o)return;const f=g=>{g.key==="Escape"&&r()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[r,o]);const c=o?r:()=>{},u=ws.get(e),[d,h]=p.useState({width:window.innerWidth,height:window.innerHeight});p.useEffect(()=>{const f=()=>h({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[]);const m=a.jsx("div",{className:"fixed inset-0 z-[99999] bg-black/60 flex items-center justify-center",style:{pointerEvents:"auto"},children:a.jsxs("div",{className:"relative bg-white rounded-xl shadow-2xl overflow-hidden flex flex-col",style:{width:Math.max(400,d.width-32),height:Math.max(300,d.height-32)},children:[a.jsxs("div",{className:"bg-indigo-50 text-indigo-700 px-4 py-2 flex justify-between items-center text-sm font-semibold border-b border-indigo-100 shrink-0",children:[a.jsx("span",{className:"truncate",children:t}),o?a.jsxs("button",{onClick:r,className:"p-1.5 hover:bg-indigo-200/50 rounded-lg text-indigo-600 hover:text-indigo-900 transition-colors cursor-pointer flex items-center gap-1 text-xs",children:[a.jsx(Ko,{size:14})," 退出全屏"]}):a.jsx("span",{className:`px-2 py-1 rounded-md text-xs font-bold flex items-center gap-1 select-none ${l?"bg-amber-100 text-amber-800 border border-amber-300":"bg-indigo-100 text-indigo-600"}`,title:l?"教师已开启全班专注锁定,当前为只读演示视图":"由教师端控制,无法在本地退出",children:l?"🔒 全班专注锁定中 · 演示视图":a.jsxs(a.Fragment,{children:[a.jsx(Ko,{size:12})," 教师同步视图"]})})]}),o&&a.jsx("div",{className:"absolute top-3 right-3 z-10",children:a.jsx("button",{onClick:r,className:"w-8 h-8 flex items-center justify-center rounded-full bg-black/20 hover:bg-black/40 text-white transition-colors cursor-pointer",title:"关闭 (ESC)",children:a.jsx(ot,{size:16})})}),a.jsxs("div",{className:"flex-1 overflow-auto p-6 relative",style:{pointerEvents:l?"none":"auto"},children:[u?a.jsx(u,{elementType:e,data:n,onClose:c,containerSize:d,lessonId:i}):a.jsx(lv,{elementType:e,data:n,onClose:c,containerSize:d,lessonId:i}),l&&a.jsx("div",{"data-testid":"fullscreen-readonly-lock-cover",className:"absolute inset-0 z-50 cursor-not-allowed bg-transparent select-none",style:{pointerEvents:"auto"},title:"🔒 全班专注锁定中:组件为只读跟随模式",onClick:f=>{f.stopPropagation(),f.preventDefault()},onPointerDown:f=>{f.stopPropagation(),f.preventDefault()}})]})]})});return Pf.createPortal(m,document.body)},av=[{field:"text",icon:"📝",label:"文本"},{field:"markdown",icon:"📄",label:"Markdown"},{field:"code",icon:"💻",label:"代码"},{field:"question",icon:"❓",label:"测验",extra:["options"]},{field:"equation",icon:"📐",label:"公式"},{field:"url",icon:"🔗",label:"链接"},{field:"src",icon:"🖼",label:"图片"},{field:"coursewareUuid",icon:"📚",label:"课件"}];function lv({data:e,lessonId:t}){const n=av.find(l=>e[l.field]!==void 0&&e[l.field]!==null&&e[l.field]!=="");if(!n)return a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-gray-500",children:[a.jsx(Di,{size:48,className:"opacity-30"}),a.jsx("div",{className:"text-sm font-medium",children:"自动识别渲染"}),a.jsx("pre",{className:"text-xs text-left bg-gray-50 border rounded-lg p-4 max-w-full max-h-80 overflow-auto font-mono",children:JSON.stringify(e,null,2)})]});const{field:s,icon:r,label:i,extra:o}=n;if(s==="markdown")return a.jsx("div",{className:"prose prose-sm max-w-none",children:a.jsx(Sb,{children:String(e.markdown)})});if(s==="code")return a.jsx("textarea",{value:String(e.code),readOnly:!0,className:"w-full h-full p-4 bg-gray-900 text-green-400 font-mono text-sm rounded-xl resize-none"});if(s==="text")return a.jsx("div",{className:"flex items-start h-full",children:a.jsx("div",{className:"text-lg whitespace-pre-wrap leading-relaxed",children:String(e.text)})});if(s==="question"){const l=Array.isArray(e.options)?e.options:[];return a.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[a.jsx("h3",{className:"text-xl font-bold text-gray-800",children:e.question}),a.jsx("div",{className:"flex flex-col gap-3",children:l.map((c,u)=>a.jsxs("div",{className:"px-5 py-4 text-left bg-gray-50 border-2 border-gray-200 rounded-xl text-base",children:[a.jsxs("span",{className:"font-bold text-indigo-600 mr-3",children:["ABCDEFGHIJKLMNOPQRSTUVWXYZ"[u],"."]}),c]},u))})]})}return s==="url"?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("a",{href:String(e.url),target:"_blank",rel:"noopener noreferrer",className:"text-indigo-600 underline text-lg",children:String(e.url)})}):s==="src"?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("img",{src:String(e.src),alt:"",className:"max-w-full max-h-full object-contain rounded-lg"})}):s==="coursewareUuid"?a.jsx(iv,{data:{coursewareUuid:String(e.coursewareUuid)},lessonId:t,className:"w-full h-full rounded-xl border"}):s==="equation"?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:"text-2xl font-mono text-gray-800 bg-gray-50 px-8 py-4 rounded-xl border",children:String(e.equation)})}):a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-4xl mb-2",children:r}),a.jsx("div",{className:"text-lg font-semibold text-gray-800",children:i}),a.jsx("pre",{className:"mt-4 text-xs text-gray-500 max-w-md overflow-auto",children:JSON.stringify(e,null,2)})]})})}class cv{constructor(){this.editors=new Map}register(t,n,s){this.editors.set(t,{impl:n,pluginId:s})}get(t){return this.editors.get(t)?.impl}has(t){return this.editors.has(t)}unregister(t,n){const s=this.editors.get(t);s&&(n&&s.pluginId!==n||this.editors.delete(t))}unregisterPlugin(t){for(const[n,s]of this.editors)s.pluginId===t&&this.editors.delete(n)}}const ci=new cv,uv=["@openlearn/frontend:IFrontendAPI","@openlearn/frontend:ISocketService","@openlearn/frontend:IUIService","@openlearn/frontend:IStorageService","@openlearn/frontend:ISemesterGradeService"];class dv{constructor(t){this.registry=null,this.initialized=!1,this.sourceCodes=new Map,this.pluginModules=new Map,this.workerManager=null,this.moduleLoader=t?.moduleLoader??this.defaultModuleLoader}setWorkerManager(t){this.workerManager=t}async initialize(t,n,s,r){const i=new ZS;await i.register(Ka,t),await i.register(Xa,n),await i.register(el,s),await i.register(tl,r),await i.register(Ub,new hv(t)),this.registry=i,this.initialized=!0,ke.getState().initialize(i)}getRegistry(){return this.registry}isInitialized(){return this.initialized}async installPlugin(t,n){this.sourceCodes.set(t.id,n),ke.getState().addPlugin({id:t.id,name:t.name,version:t.version,state:be.INSTALLED,executionMode:"inline"})}async activateRemotePlugin(t,n){const s=ke.getState(),r=s.activePlugins.find(i=>i.id===t);if(!(r&&(r.state===be.ACTIVE||r.state===be.ACTIVATING))){s.updatePluginState(t,be.ACTIVATING);try{const i=`/plugins/${t}/frontend.js`,o=await fetch(i);if(!o.ok)throw new Error(`Failed to fetch frontend.js for plugin "${t}": HTTP ${o.status}`);let l=await o.text();window.HostSharedDeps&&(l=pv(l));const c=new Blob([l],{type:"text/javascript"}),u=URL.createObjectURL(c);let d;try{d=await import(u)}finally{URL.revokeObjectURL(u)}const h=d.default??d;if(typeof h.activate!="function")throw new Error("Invalid remote frontend plugin: missing activate function");const m=await this.buildContext(t,n);await Promise.race([h.activate(m),new Promise((f,g)=>setTimeout(()=>g(new Error("Activation timeout (5000ms)")),5e3))]),this.pluginModules.set(t,{manifest:n,activate:h.activate,deactivate:typeof h.deactivate=="function"?h.deactivate:void 0}),s.updatePluginState(t,be.ACTIVE)}catch(i){throw console.error(`[FrontendPluginHost] Failed to activate remote plugin "${t}":`,i),s.updatePluginState(t,be.ERROR),this.unregisterPluginResources(t),i}}}async activatePlugin(t){const n=ke.getState(),s=n.activePlugins.find(r=>r.id===t);if(!s)throw new Error(`Plugin not found: ${t}`);if(s.executionMode==="worker")return this.activateWorkerPlugin(t,s);if(s.executionMode!=="inline")throw new Error(`Unsupported execution mode for activation: ${s.executionMode}`);n.updatePluginState(t,be.ACTIVATING);try{const r=this.sourceCodes.get(t);if(!r)throw new Error(`No source code found for plugin: ${t}`);const i=await this.moduleLoader(r),o=i.default??i,l=o.manifest??i.manifest,c=o.activate??i.activate,u=o.deactivate??i.deactivate;if(!l||typeof c!="function")throw new Error("Invalid plugin: missing manifest or activate function");if(l.id!==t)throw new Error(`Manifest id mismatch: expected "${t}", got "${l.id}"`);if(l.classroomTools)for(const h of l.classroomTools)n.registerExtensionPoint("classroom.tool",{id:h.id,label:h.name,icon:h.icon,component:()=>Promise.resolve({default:(()=>null)}),pluginId:t});const d=await this.buildContext(t,l);await Promise.race([c(d),new Promise((h,m)=>setTimeout(()=>m(new Error("Activation timeout (5000ms)")),5e3))]),this.pluginModules.set(t,{manifest:l,activate:c,deactivate:typeof u=="function"?u:void 0}),n.updatePluginState(t,be.ACTIVE)}catch(r){throw n.updatePluginState(t,be.ERROR),this.unregisterPluginResources(t),r}}async activateWorkerPlugin(t,n){if(!this.workerManager)throw new Error(`Cannot activate plugin "${t}" in worker mode: BrowserWorkerManager not set. Call setWorkerManager() first.`);const s=ke.getState(),r=this.sourceCodes.get(t);if(!r)throw new Error(`No source code found for plugin: ${t}`);const i={id:t,name:n.name,version:n.version};s.updatePluginState(t,be.ACTIVATING);try{let o;if(this.registry)try{o=await this.registry.resolve("@openlearn/frontend:ISocketService")}catch{}const{serviceHost:l}=await this.workerManager.createWorker(t,i,r,uv,o);this.pluginModules.set(t,{manifest:i,activate:async()=>{},deactivate:async()=>{await this.workerManager.terminateWorker(t)}}),s.updatePluginState(t,be.ACTIVE)}catch(o){throw s.updatePluginState(t,be.ERROR),this.unregisterPluginResources(t),o}}async deactivatePlugin(t){const n=ke.getState(),s=n.activePlugins.find(r=>r.id===t);if(!(!s||s.state!==be.ACTIVE)){n.updatePluginState(t,be.DEACTIVATING);try{const r=this.pluginModules.get(t);r?.deactivate&&await Promise.race([r.deactivate(),new Promise((i,o)=>setTimeout(()=>o(new Error("Deactivation timeout (5000ms)")),5e3))])}catch(r){console.error(`[FrontendPluginHost] Deactivation error for "${t}":`,r)}finally{this.unregisterPluginResources(t),this.pluginModules.delete(t),n.updatePluginState(t,be.INACTIVE)}}}async uninstallPlugin(t){const n=ke.getState();n.activePlugins.find(r=>r.id===t)?.state===be.ACTIVE&&await this.deactivatePlugin(t);try{await fetch(`/api/plugins/${t}`,{method:"DELETE"})}catch(r){console.error(`[FrontendPluginHost] Failed to DELETE plugin "${t}" on server:`,r)}this.sourceCodes.delete(t),this.pluginModules.delete(t),this.unregisterPluginResources(t),n.removePlugin(t)}getExtensions(t){return ke.getState().getExtensions(t)}unregisterPluginResources(t){ke.getState().unregisterPluginExtensionPoints(t),ws.unregisterPlugin(t),ci.unregisterPlugin(t),bs.unregisterPlugin(t),En.unregisterPlugin(t)}async defaultModuleLoader(t){const n=new Blob([t],{type:"text/javascript"}),s=URL.createObjectURL(n);try{return await import(s)}finally{URL.revokeObjectURL(s)}}async buildContext(t,n){if(!this.registry)throw new Error("FrontendPluginHost not initialized");const s=await this.registry.resolve(Ka),r=await this.registry.resolve(Xa),i=await this.registry.resolve(el),o=await this.registry.resolve(tl);return{services:{frontendApi:s,socketService:r,uiService:i,storageService:o},pluginId:t,manifest:n,ui:{registerExtensionPoint:(l,c)=>{ke.getState().registerExtensionPoint(l,{...c,pluginId:t})},unregisterExtensionPoint:(l,c)=>{ke.getState().unregisterExtensionPoint(l,c)},registerFullscreenRenderer:(l,c)=>{ws.register(l,c,t)},unregisterFullscreenRenderer:l=>{ws.unregister(l,t)},registerPropertyEditor:(l,c)=>{ci.register(l,c,t)},unregisterPropertyEditor:l=>{ci.unregister(l,t)},registerCoursewareSource:l=>{bs.register(l,t)},unregisterCoursewareSource:l=>{bs.unregister(l,t)},registerPaletteItem:l=>{En.register(l,t)},unregisterPaletteItem:l=>{En.unregister(l,t)}},navigation:{getTeacherTab:()=>Ee.getState().teacherTab,setTeacherTab:l=>Ee.getState().setTeacherTab(l),setSelectedLesson:l=>Ee.getState().setSelectedLesson(l),subscribeTeacherTab:l=>{let c=Ee.getState().teacherTab;return Ee.subscribe(u=>{const d=u.teacherTab;d!==c&&(c=d,l(d))})}},context:{get:()=>{const l=Ee.getState();return{lessonId:l.selectedLesson,classId:l.liveClassSelectedClassId}},subscribe:l=>{const c=Ee.getState();let u={lessonId:c.selectedLesson,classId:c.liveClassSelectedClassId};return Ee.subscribe(d=>{const h={lessonId:d.selectedLesson,classId:d.liveClassSelectedClassId};(h.lessonId!==u.lessonId||h.classId!==u.classId)&&(u=h,l(h))})}},invokeCommand:async(l,c)=>{if(!s)throw new Error(`Plugin "${t}" cannot invoke command: frontendApi is not available. Has FrontendPluginHost initialized?`);const u=KS(l,n.id),d=await s.post("/api/plugins/execute-command",{type:u,payload:c});if(d.success&&d.result!==void 0)return d.result;throw new Error(d.error||"Command execution failed")},registerPanel:l=>{const c=l.slot||"teacher.dashboard.widget";ke.getState().registerExtensionPoint(c,{...l,pluginId:t})},registerMenu:l=>{const c=l.slot||"teacher.panel";ke.getState().registerExtensionPoint(c,{...l,pluginId:t})},registerToolbarButton:l=>{ke.getState().registerExtensionPoint("classroom.tool",{...l,pluginId:t})}}}}class hv{constructor(t){this.frontendApi=t}async saveSemesterGrade(t,n,s){const r=await this.frontendApi.post("/api/grade-sync",{lessonId:t,studentId:n,grade:s});if(!r.success)throw new Error(r.error||"Failed to sync semester grade")}}const Nl={react:"window.HostSharedDeps.React","react-dom":"window.HostSharedDeps.ReactDOM","react-dom/client":"(window.HostSharedDeps.ReactDOMClient || window.HostSharedDeps.ReactDOM)","react/jsx-runtime":"window.HostSharedDeps.jsxRuntime",recharts:"window.HostSharedDeps.Recharts","lucide-react":"window.HostSharedDeps.LucideReact"};function Pl(e){return e.split(",").map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^type\s+/,"")).map(t=>t.replace(/\s+as\s+/,": ")).join(", ")}function fv(e,t){e=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").trim();const n=[],s=e.match(/^([a-zA-Z_$][\w$]*)\s*,\s*\*\s*as\s+([a-zA-Z_$][\w$]*)$/);if(s)return n.push(`const ${s[1]} = ${t}?.default ?? ${t};`),n.push(`const ${s[2]} = ${t};`),n.join(" ");const r=e.match(/^([a-zA-Z_$][\w$]*)\s*,\s*\{([\s\S]*)\}$/);if(r){const c=r[1],u=Pl(r[2]);return n.push(`const ${c} = ${t}?.default ?? ${t};`),u&&n.push(`const { ${u} } = ${t};`),n.join(" ")}const i=e.match(/^\*\s*as\s+([a-zA-Z_$][\w$]*)$/);if(i)return`const ${i[1]} = ${t};`;const o=e.match(/^\{([\s\S]*)\}$/);if(o)return`const { ${Pl(o[1])} } = ${t};`;const l=e.match(/^([a-zA-Z_$][\w$]*)$/);return l?`const ${l[1]} = ${t}?.default ?? ${t};`:null}function pv(e){let t=e.replace(/import\s+['"]([^'"]+)['"];?/g,(n,s)=>Nl[s]?`/* [HostSharedDeps] ${n} */`:n);return t=t.replace(/import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"];?/g,(n,s,r)=>{const i=Nl[r];if(!i)return n;const o=fv(s,i);return o||n}),t}class mv extends Je.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null,copied:!1,showDetails:!1},this.handleCopy=async()=>{const{error:n,errorInfo:s}=this.state;if(!n)return;const r=go({type:"react",title:"React 组件渲染致命异常",message:n.message||String(n),stack:n.stack,componentStack:s?.componentStack||void 0,timestamp:Date.now(),url:typeof window<"u"?window.location.href:""});await Ns(r)&&(this.setState({copied:!0}),setTimeout(()=>this.setState({copied:!1}),2500))},this.handleReset=()=>{this.setState({hasError:!1,error:null,errorInfo:null,copied:!1,showDetails:!1})},this.handleGoHome=()=>{typeof window<"u"&&(window.location.href="/")},this.props=t}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){this.setState({errorInfo:n}),en.getState().addError({type:"react",title:"React 组件渲染异常",message:t?.message||String(t),stack:t?.stack,componentStack:n?.componentStack||void 0}),console.error("[GlobalErrorBoundary] Unhandled React render exception:",t,n)}render(){if(this.state.hasError){const{error:t,errorInfo:n,copied:s,showDetails:r}=this.state,i=this.props.fallbackTitle||"界面渲染遇到意外错误";return a.jsx("div",{className:"min-h-screen bg-slate-50 dark:bg-slate-950 flex items-center justify-center p-4 select-text",children:a.jsxs("div",{className:"max-w-2xl w-full bg-white dark:bg-slate-900 rounded-2xl shadow-xl border border-rose-200 dark:border-rose-900/60 overflow-hidden",children:[a.jsxs("div",{className:"bg-gradient-to-r from-rose-500 to-red-600 px-6 py-5 text-white flex items-center gap-3.5",children:[a.jsx("div",{className:"p-2.5 bg-white/20 rounded-xl backdrop-blur-xs shrink-0",children:a.jsx(op,{size:24,className:"text-white"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h1",{className:"text-lg font-bold leading-snug",children:i}),a.jsx("p",{className:"text-xs text-rose-100 mt-0.5",children:"OpenLearn 捕获到界面异常,已阻止整页崩溃并为您保留了诊断报告。"})]})]}),a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider block mb-1.5",children:"错误摘要 (Error Summary)"}),a.jsxs("div",{className:"bg-rose-50 dark:bg-rose-950/40 border border-rose-200 dark:border-rose-900/50 rounded-xl p-3.5 text-rose-900 dark:text-rose-200 text-sm font-mono break-all",children:[t?.name,": ",t?.message||"未知异常"]})]}),a.jsxs("div",{className:"border border-gray-200 dark:border-gray-800 rounded-xl overflow-hidden",children:[a.jsxs("button",{type:"button",onClick:()=>this.setState({showDetails:!r}),className:"w-full px-4 py-2.5 bg-gray-50 dark:bg-slate-800/60 hover:bg-gray-100 dark:hover:bg-slate-800 flex items-center justify-between text-xs font-semibold text-gray-700 dark:text-gray-300 transition-colors cursor-pointer",children:[a.jsx("span",{children:"查看调用堆栈与排查信息"}),r?a.jsx(Ps,{size:14}):a.jsx(Ml,{size:14})]}),r&&a.jsxs("div",{className:"p-4 bg-slate-900 text-slate-200 text-xs font-mono max-h-64 overflow-y-auto space-y-3 leading-relaxed",children:[t?.stack&&a.jsxs("div",{children:[a.jsx("span",{className:"text-rose-400 font-bold block mb-1",children:"Stack Trace:"}),a.jsx("pre",{className:"whitespace-pre-wrap text-xs opacity-90",children:t.stack})]}),n?.componentStack&&a.jsxs("div",{className:"pt-2 border-t border-slate-800",children:[a.jsx("span",{className:"text-amber-400 font-bold block mb-1",children:"Component Stack:"}),a.jsx("pre",{className:"whitespace-pre-wrap text-xs opacity-80",children:n.componentStack})]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{type:"button",onClick:this.handleCopy,className:`px-4 py-2 rounded-xl text-xs font-bold transition-all flex items-center gap-1.5 shadow-sm cursor-pointer ${s?"bg-emerald-600 text-white shadow-emerald-600/30":"bg-indigo-600 hover:bg-indigo-700 text-white shadow-indigo-600/30"}`,children:[s?a.jsx(yt,{size:14}):a.jsx(An,{size:14}),a.jsx("span",{children:s?"✓ 诊断报告已复制!":"一键复制错误报告"})]}),a.jsxs("button",{type:"button",onClick:this.handleReset,className:"px-3.5 py-2 rounded-xl text-xs font-semibold bg-gray-100 dark:bg-slate-800 hover:bg-gray-200 dark:hover:bg-slate-700 text-gray-700 dark:text-gray-200 transition-colors flex items-center gap-1.5 cursor-pointer",children:[a.jsx(Ol,{size:14}),a.jsx("span",{children:"重新加载界面"})]})]}),a.jsxs("button",{type:"button",onClick:this.handleGoHome,className:"px-3 py-2 rounded-xl text-xs font-medium text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-100 transition-colors flex items-center gap-1 cursor-pointer",children:[a.jsx(_l,{size:14}),a.jsx("span",{children:"返回系统主页"})]})]})]})]})})}return this.props.children}}window.React=ui;window.ReactDOM=di;window.HostSharedDeps={React:ui,ReactDOM:di,ReactDOMClient:Go,Recharts:oa,LucideReact:Xo,jsxRuntime:Wo,react:ui,"react-dom":di,"react-dom/client":Go,"react/jsx-runtime":Wo,recharts:oa,"lucide-react":Xo};const gv=new dv;Tf.createRoot(document.getElementById("root")).render(a.jsx(p.StrictMode,{children:a.jsx(mv,{children:a.jsx(jb,{host:gv,children:a.jsx(JS,{})})})}));export{zc as A,gC as C,Ib as D,yC as E,SC as F,iv as H,Sb as M,Kp as P,he as a,mC as b,xC as c,ua as d,zb as e,Ew as f,em as g,As as h,Xt as i,pC as j,wC as k,ys as l,Ti as m,En as n,ws as o,ci as p,Gc as q,KS as r,Hi as s,ke as u};
|