openlearn-next 0.2.1 → 0.2.2

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.
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-reveal-DcQQzuI9.css"])))=>i.map(i=>d[i]);
2
- import{j as i,U as Fh,C as Vl,L as ZU,H as JU,b as Bh,B as uD,c as cp,S as An,d as Qr,G as Wo,D as Ol,X as Lr,K as QU,P as e0,T as va,A as Ls,e as Go,f as dv,F as ls,g as Vd,R as gs,h as Na,i as fD,E as dp,k as FS,l as Yo,m as Pn,n as Qi,o as jf,p as ys,q as Sr,r as Md,s as Bs,W as ea,M as uv,a as fv,t as Dl,u as cj,v as sf,w as eq,x as hD,y as dj,z as Qa,I as Nn,J as so,N as uj,O as NC,Q as BS,V as D0,Y as up,Z as tq,_ as Ws,$ as pD,a0 as rq,a1 as nq,a2 as sq,a3 as fp,a4 as ns,a5 as io,a6 as iq,a7 as Wd,a8 as VS,a9 as Hb,aa as WS,ab as SC,ac as Vh,ad as Wh,ae as Uo,af as US,ag as Ai,ah as aq,ai as mD,aj as gD,ak as xD,al as qS,am as M0,an as Kb,ao as oq,ap as lq,aq as Gb,ar as fj,as as Yb,at as cq,au as dq,av as uq,aw as vD,ax as t0,ay as fq,az as bD,aA as Fu,aB as hq,aC as yD,aD as _x,aE as wD,aF as pq,aG as mq,aH as gq,aI as xq,aJ as vq,aK as bq,aL as yq,aM as HS,aN as wq,aO as jq,aP as Nq,aQ as Sq,aR as Aq,aS as Pq,aT as kq,aU as Cq,aV as KS,aW as Tx,aX as Eh,aY as AC,aZ as Eq,a_ as _q,a$ as PC,b0 as Tq,b1 as Oq,b2 as kC,b3 as Wg,b4 as Iq,b5 as Lq,b6 as zq,b7 as Dq,b8 as Mq,b9 as Rq,ba as $q}from"./whiteboard-BpCj1CQU.js";import{r as m,R as ss,g as ho,d as CC,e as GS,a as YS,f as XS,h as jD,i as Fq}from"./vendor-konva-GivUq6dt.js";import{_ as _h}from"./courseware-BfnpYR-P.js";import{n as Bq}from"./vendor-pptx-CJ3I-KT0.js";/* empty css */const Vq=e=>{const t=e.split(/\r?\n/);if(t.length<2)return[];const r=t[0],n=[",",";"," "];let s=",",a=0;n.forEach(p=>{const g=r.split(p).length;g>a&&(a=g,s=p)});const o=p=>{const g=[];let v=!1,x="";for(let b=0;b<p.length;b++){const j=p[b];j==='"'?v=!v:j===s&&!v?(g.push(x.trim()),x=""):x+=j}return g.push(x.trim()),g},l=o(r).map(p=>p.toLowerCase().replace(/["'\r]/g,"").trim()),c=l.findIndex(p=>p.includes("name")||p.includes("student")||p.includes("姓名")||p.includes("学生")),d=l.findIndex(p=>p.includes("email")||p.includes("mail")||p.includes("邮箱")),u=c>=0?c:0,f=d>=0?d:1,h=[];for(let p=1;p<t.length;p++){if(!t[p].trim())continue;const g=o(t[p]),v=g[u]?g[u].replace(/["'\r]/g,"").trim():"",x=g[f]?g[f].replace(/["'\r]/g,"").trim():"";v&&h.push({name:v,email:x})}return h},EC={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"}};function Wq({session:e,lang:t,onLogout:r,onProfile:n}){const[s,a]=m.useState(!1),o=m.useRef(null);m.useEffect(()=>{if(!s)return;const c=d=>{o.current&&!o.current.contains(d.target)&&a(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const l=(c,d)=>t==="zh"?c:d;return i.jsxs("div",{className:"relative",ref:o,children:[i.jsxs("button",{type:"button",onClick:()=>a(c=>!c),"aria-haspopup":"menu","aria-expanded":s,title:e.name,className:"flex items-center gap-1 rounded-full p-1 hover:bg-gray-100 transition-colors cursor-pointer",children:[i.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?i.jsx("img",{src:e.avatar,alt:e.name,className:"w-full h-full object-cover"}):i.jsx(Fh,{size:20})}),i.jsx(Vl,{size:14,className:`text-gray-400 transition-transform duration-200 ${s?"rotate-180":""}`})]}),s&&i.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:[i.jsxs("div",{className:"px-4 py-2 border-b border-gray-100",children:[i.jsx("p",{className:"text-sm font-semibold text-gray-800 truncate",title:e.name,children:e.name}),i.jsx("p",{className:"text-xs text-gray-400 truncate",children:e.username})]}),i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{a(!1),n()},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:[i.jsx(Fh,{size:16,className:"text-gray-400"}),l("个人资料","Profile")]}),i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{a(!1),r()},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:[i.jsx(ZU,{size:16}),l("注销登录","Sign Out")]})]})]})}function Uq(e){const{activeRole:t,lang:r,teacherTab:n,studentViewStatus:s,session:a,activeStudentId:o,students:l,studentDashboardData:c,isNotificationsOpen:d,studentNotifications:u,unreadNotifications:f,readNotifications:h,dbConnected:p,dbStatus:g,siteInfo:v,setActiveStudentId:x,setReadNotifications:b,setIsSystemResourceLibraryOpen:j,setProfileOpen:N,setTeacherTab:w,setStudentViewStatus:A,setIsNotificationsOpen:P,setSelectedNotificationForModal:E,handleLogout:T,toggleLanguage:C}=e;return i.jsxs("header",{className:"h-16 border-b border-gray-200 bg-white flex items-center px-6 justify-between shrink-0 shadow-sm relative z-20",children:[i.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[i.jsxs("button",{onClick:()=>{t==="teacher"?w("dashboard"):t==="student"&&A("dashboard")},className:"flex items-center gap-2.5 shrink-0 hover:opacity-80 transition-opacity cursor-pointer",title:r==="zh"?"返回系统总览":"Back to Dashboard",children:[v.logoUrl?i.jsx("img",{src:v.logoUrl,alt:"site logo",className:"h-8 w-8 object-contain rounded-lg shrink-0"}):i.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"}),i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("span",{className:"text-base font-black text-slate-900 tracking-tight",children:v.siteName||"OpenLearn Next"}),i.jsxs("span",{className:"text-[10px] font-medium text-slate-400 tracking-tight",children:["v","0.2.1"]}),v.slogan&&i.jsx("span",{className:"hidden md:inline text-xs text-slate-400 font-normal truncate max-w-[200px]",children:v.slogan})]})]}),i.jsxs("button",{onClick:()=>{t==="teacher"?w("dashboard"):t==="student"&&A("dashboard")},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors cursor-pointer ${t==="teacher"&&n==="dashboard"||t==="student"&&s==="dashboard"?"bg-indigo-50 text-indigo-700":"text-slate-600 hover:text-indigo-600 hover:bg-slate-100"}`,children:[i.jsx(JU,{size:16}),r==="zh"?"系统总览":"Dashboard"]}),t==="student"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-slate-300 font-light text-lg select-none",children:"/"}),i.jsxs("h2",{className:"font-semibold text-gray-800 tracking-tight flex items-center gap-2",children:[i.jsx(Bh,{size:20,className:"text-gray-400"}),"Student Dashboard"]})]}),t==="student"&&a.role==="teacher"&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-gray-500",children:"View as:"}),i.jsxs("select",{className:"border border-gray-200 rounded p-1 text-sm bg-white",value:o||"",onChange:I=>x(I.target.value),children:[i.jsx("option",{value:"",children:"-- Select Student --"}),l.map(I=>i.jsx("option",{value:I.id,children:I.name},I.id))]})]})]}),i.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[t==="student"&&o&&c&&i.jsxs("div",{className:"relative",children:[i.jsxs("button",{onClick:()=>P(!d),className:"relative p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:[i.jsx(uD,{size:20}),f.length>0&&i.jsx("span",{className:"absolute top-1 right-1 bg-red-500 text-white text-[10px] font-bold px-1.5 py-0.5 rounded-full flex items-center justify-center min-w-[18px]",children:f.length})]}),d&&i.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:[i.jsxs("div",{className:"p-3 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[i.jsx("h3",{className:"font-semibold text-gray-800",children:"Notifications"}),f.length>0&&i.jsx("button",{onClick:async()=>{if(!o)return;try{const _=u.filter(L=>!h.has(L.id)).map(L=>fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:L.id})}));await Promise.all(_)}catch(_){console.error(_)}const I=new Set(h);u.forEach(_=>I.add(_.id)),b(I)},className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium",children:"Mark all as read"})]}),i.jsx("div",{className:"max-h-96 overflow-y-auto",children:u.length===0?i.jsx("div",{className:"p-4 text-center text-sm text-gray-500 italic",children:"No notifications."}):i.jsx("div",{className:"divide-y divide-gray-100",children:u.map(I=>{const _=!h.has(I.id);return i.jsx("div",{className:`p-3 hover:bg-gray-50 cursor-pointer ${_?"bg-indigo-50/30":""}`,onClick:()=>{if(_){o&&fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:I.id})}).catch(console.error);const $=new Set(h);$.add(I.id),b($)}const L=c?.assignments?.find($=>$.id===I.relatedId);E({...I,assignment:L}),P(!1)},children:i.jsxs("div",{className:"flex gap-3",children:[i.jsx("div",{className:"mt-0.5",children:I.type==="new_assignment"?i.jsx(cp,{size:16,className:"text-indigo-500"}):I.type==="rollcall_picked"?i.jsx(An,{size:16,className:"text-amber-500 animate-pulse"}):i.jsx(Qr,{size:16,className:"text-green-500"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:`text-sm ${_?"font-semibold text-gray-900":"font-medium text-gray-700"}`,children:I.title}),i.jsx("div",{className:`text-xs mt-0.5 ${_?"text-gray-600":"text-gray-500"}`,children:I.message})]}),_&&i.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500 mt-1"})]})},I.id)})})})]})]}),i.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-1.5 hover:text-indigo-600 transition-colors bg-white px-3 py-1.5 rounded-md border border-gray-200 shadow-sm font-medium cursor-pointer",children:[i.jsx(Wo,{size:14,className:"text-emerald-500 animate-pulse"}),r==="zh"?"系统资源库":"System Resource Library"]}),i.jsx("button",{onClick:C,title:r==="zh"?"Switch to English":"切换为中文",className:"p-2 hover:bg-slate-100 text-slate-600 hover:text-indigo-600 transition-colors bg-white rounded-lg border border-gray-200 shadow-3xs flex items-center justify-center shrink-0 cursor-pointer",children:i.jsx(Wo,{size:16})}),(()=>{const I=g==="error"||!p?{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:r==="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:r==="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:r==="zh"?"SQLite 数据库连接正常":"SQLite DB Connected & Normal"};return i.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 ${I.bg}`,title:I.label,children:[i.jsx(Ol,{size:15}),i.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2.5 w-2.5",children:[i.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${I.ping}`}),i.jsx("span",{className:`relative inline-flex rounded-full h-2.5 w-2.5 ${I.dot}`})]})]})})(),i.jsx(Wq,{session:a,lang:r,onLogout:T,onProfile:()=>N(!0)})]})]})}function qq({open:e,session:t,lang:r,onClose:n,onSaved:s,onAvatar:a}){const[o,l]=m.useState(t.name),[c,d]=m.useState(!1),[u,f]=m.useState(null),h=m.useRef(null),[p,g]=m.useState(!1),[v,x]=m.useState(null),[b,j]=m.useState(!1),[N,w]=m.useState(""),[A,P]=m.useState(""),[E,T]=m.useState(""),[C,I]=m.useState(!1),[_,L]=m.useState(null),[$,z]=m.useState(!1);if(!e)return null;const R=(U,F)=>r==="zh"?U:F,J=t.role==="teacher"?t.subRole==="administrator"?R("管理员","Administrator"):R("教师","Teacher"):R("学生","Student"),Z=o.trim(),q=Z.length>0&&Z!==t.name,Y=async()=>{if(!(!q||c)){d(!0),f(null);try{const U=await fetch("/api/auth/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Z})}),F=await U.json();if(!U.ok){f(F.error||(r==="zh"?"保存失败":"Save failed"));return}s(F.name??Z)}catch{f(r==="zh"?"网络错误,请重试":"Network error, please retry")}finally{d(!1)}}},de=N.length>0&&A.length>=8&&/[a-zA-Z]/.test(A)&&/[0-9]/.test(A)&&A===E,H=async()=>{if(!(!de||C)){I(!0),L(null);try{const U=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:N,newPassword:A})}),F=await U.json();if(!U.ok){L(F.error||(r==="zh"?"修改失败":"Change failed"));return}z(!0),w(""),P(""),T(""),j(!1)}catch{L(r==="zh"?"网络错误,请重试":"Network error, please retry")}finally{I(!1)}}},M=async U=>{const F=U.target.files?.[0];if(U.target.value="",!!F){g(!0),x(null);try{const se=await new Promise((ee,ie)=>{const xe=new FileReader;xe.onload=()=>ee(xe.result),xe.onerror=()=>ie(xe.error),xe.readAsDataURL(F)}),ue=await fetch("/api/auth/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:F.name,base64Data:se})}),re=await ue.json();if(!ue.ok){x(re.error||(r==="zh"?"上传失败":"Upload failed"));return}a?.(re.avatar)}catch{x(r==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}}},V=async()=>{g(!0),x(null);try{const U=await fetch("/api/auth/avatar",{method:"DELETE"}),F=await U.json().catch(()=>({}));if(!U.ok){x(F.error||(r==="zh"?"移除失败":"Remove failed"));return}a?.(null)}catch{x(r==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}};return i.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4",onClick:n,children:i.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden",onClick:U=>U.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[i.jsx("h3",{className:"font-semibold text-gray-800",children:R("个人资料","Profile")}),i.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:i.jsx(Lr,{size:18})})]}),i.jsxs("div",{className:"p-5 space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.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?i.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full object-cover"}):i.jsx(Fh,{size:28})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-base font-semibold text-gray-800 truncate",children:t.name}),i.jsx("p",{className:"text-xs text-gray-400",children:J}),i.jsxs("div",{className:"mt-1.5 flex items-center gap-3",children:[i.jsx("button",{type:"button",onClick:()=>h.current?.click(),disabled:p,className:"text-xs text-indigo-600 hover:text-indigo-800 disabled:opacity-50 cursor-pointer",children:p?R("上传中…","Uploading…"):t.avatar?R("更换头像","Change avatar"):R("上传头像","Upload avatar")}),t.avatar&&i.jsx("button",{type:"button",onClick:V,disabled:p,className:"text-xs text-rose-500 hover:text-rose-700 disabled:opacity-50 cursor-pointer",children:R("移除","Remove")})]}),i.jsx("input",{ref:h,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:M})]})]}),v&&i.jsx("p",{className:"text-xs text-rose-500",children:v}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:R("显示名称","Display Name")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{value:o,onChange:U=>l(U.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"}),i.jsx("button",{onClick:Y,disabled:!q||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?R("保存中…","Saving…"):R("保存","Save")})]}),u&&i.jsx("p",{className:"text-xs text-rose-500 mt-1",children:u})]}),i.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:[i.jsx(QU,{size:16,className:"text-gray-400"}),R("修改密码","Change Password")]}),!b&&!$&&i.jsx("button",{onClick:()=>{j(!0),L(null)},className:"text-sm text-indigo-600 hover:text-indigo-800 cursor-pointer",children:R("修改","Edit")})]}),$&&i.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-sm text-emerald-600",children:[i.jsx(Qr,{size:16}),R("密码已修改,其他设备的登录已失效","Password changed. Other devices were logged out.")]}),b&&i.jsxs("div",{className:"mt-3 space-y-3",children:[i.jsx("input",{type:"password",value:N,onChange:U=>w(U.target.value),placeholder:R("当前密码","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"}),i.jsx("input",{type:"password",value:A,onChange:U=>P(U.target.value),placeholder:R("新密码(≥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"}),i.jsx("input",{type:"password",value:E,onChange:U=>T(U.target.value),placeholder:R("确认新密码","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"}),_&&i.jsx("p",{className:"text-xs text-rose-500",children:_}),i.jsxs("div",{className:"flex gap-2 justify-end",children:[i.jsx("button",{onClick:()=>{j(!1),w(""),P(""),T(""),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:R("取消","Cancel")}),i.jsx("button",{onClick:H,disabled:!de||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",children:C?R("提交中…","Submitting…"):R("提交","Submit")})]})]})]}),i.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-gray-400",children:R("用户名(登录账号)","Username (login)")}),i.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-[60%]",title:t.username,children:t.username||"-"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-gray-400",children:R("角色","Role")}),i.jsx("span",{className:"text-sm font-medium text-gray-700",children:J})]})]})]})]})})}const r0={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"}},Hq=[{id:"present",labelZh:"内容呈现",labelEn:"Content"},{id:"assess",labelZh:"评估互动",labelEn:"Assessment"},{id:"manage",labelZh:"课堂管理",labelEn:"Classroom"}],ND=[{type:"presentation",labelZh:"课件演示",labelEn:"Slides Deck",descriptionZh:"Markdown 幻灯片",descriptionEn:"Markdown slides",icon:e0,color:"violet",group:"present",defaultData:{markdown:`# Title Slide
2
+ import{j as i,U as Fh,C as Vl,L as ZU,H as JU,b as Bh,B as uD,c as cp,S as An,d as Qr,G as Wo,D as Ol,X as Lr,K as QU,P as e0,T as va,A as Ls,e as Go,f as dv,F as ls,g as Vd,R as gs,h as Na,i as fD,E as dp,k as FS,l as Yo,m as Pn,n as Qi,o as jf,p as ys,q as Sr,r as Md,s as Bs,W as ea,M as uv,a as fv,t as Dl,u as cj,v as sf,w as eq,x as hD,y as dj,z as Qa,I as Nn,J as so,N as uj,O as NC,Q as BS,V as D0,Y as up,Z as tq,_ as Ws,$ as pD,a0 as rq,a1 as nq,a2 as sq,a3 as fp,a4 as ns,a5 as io,a6 as iq,a7 as Wd,a8 as VS,a9 as Hb,aa as WS,ab as SC,ac as Vh,ad as Wh,ae as Uo,af as US,ag as Ai,ah as aq,ai as mD,aj as gD,ak as xD,al as qS,am as M0,an as Kb,ao as oq,ap as lq,aq as Gb,ar as fj,as as Yb,at as cq,au as dq,av as uq,aw as vD,ax as t0,ay as fq,az as bD,aA as Fu,aB as hq,aC as yD,aD as _x,aE as wD,aF as pq,aG as mq,aH as gq,aI as xq,aJ as vq,aK as bq,aL as yq,aM as HS,aN as wq,aO as jq,aP as Nq,aQ as Sq,aR as Aq,aS as Pq,aT as kq,aU as Cq,aV as KS,aW as Tx,aX as Eh,aY as AC,aZ as Eq,a_ as _q,a$ as PC,b0 as Tq,b1 as Oq,b2 as kC,b3 as Wg,b4 as Iq,b5 as Lq,b6 as zq,b7 as Dq,b8 as Mq,b9 as Rq,ba as $q}from"./whiteboard-Dp8tFXTO.js";import{r as m,R as ss,g as ho,d as CC,e as GS,a as YS,f as XS,h as jD,i as Fq}from"./vendor-konva-GivUq6dt.js";import{_ as _h}from"./courseware-CL7gjXZj.js";import{n as Bq}from"./vendor-pptx-CJ3I-KT0.js";/* empty css */const Vq=e=>{const t=e.split(/\r?\n/);if(t.length<2)return[];const r=t[0],n=[",",";"," "];let s=",",a=0;n.forEach(p=>{const g=r.split(p).length;g>a&&(a=g,s=p)});const o=p=>{const g=[];let v=!1,x="";for(let b=0;b<p.length;b++){const j=p[b];j==='"'?v=!v:j===s&&!v?(g.push(x.trim()),x=""):x+=j}return g.push(x.trim()),g},l=o(r).map(p=>p.toLowerCase().replace(/["'\r]/g,"").trim()),c=l.findIndex(p=>p.includes("name")||p.includes("student")||p.includes("姓名")||p.includes("学生")),d=l.findIndex(p=>p.includes("email")||p.includes("mail")||p.includes("邮箱")),u=c>=0?c:0,f=d>=0?d:1,h=[];for(let p=1;p<t.length;p++){if(!t[p].trim())continue;const g=o(t[p]),v=g[u]?g[u].replace(/["'\r]/g,"").trim():"",x=g[f]?g[f].replace(/["'\r]/g,"").trim():"";v&&h.push({name:v,email:x})}return h},EC={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"}};function Wq({session:e,lang:t,onLogout:r,onProfile:n}){const[s,a]=m.useState(!1),o=m.useRef(null);m.useEffect(()=>{if(!s)return;const c=d=>{o.current&&!o.current.contains(d.target)&&a(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const l=(c,d)=>t==="zh"?c:d;return i.jsxs("div",{className:"relative",ref:o,children:[i.jsxs("button",{type:"button",onClick:()=>a(c=>!c),"aria-haspopup":"menu","aria-expanded":s,title:e.name,className:"flex items-center gap-1 rounded-full p-1 hover:bg-gray-100 transition-colors cursor-pointer",children:[i.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?i.jsx("img",{src:e.avatar,alt:e.name,className:"w-full h-full object-cover"}):i.jsx(Fh,{size:20})}),i.jsx(Vl,{size:14,className:`text-gray-400 transition-transform duration-200 ${s?"rotate-180":""}`})]}),s&&i.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:[i.jsxs("div",{className:"px-4 py-2 border-b border-gray-100",children:[i.jsx("p",{className:"text-sm font-semibold text-gray-800 truncate",title:e.name,children:e.name}),i.jsx("p",{className:"text-xs text-gray-400 truncate",children:e.username})]}),i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{a(!1),n()},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:[i.jsx(Fh,{size:16,className:"text-gray-400"}),l("个人资料","Profile")]}),i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{a(!1),r()},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:[i.jsx(ZU,{size:16}),l("注销登录","Sign Out")]})]})]})}function Uq(e){const{activeRole:t,lang:r,teacherTab:n,studentViewStatus:s,session:a,activeStudentId:o,students:l,studentDashboardData:c,isNotificationsOpen:d,studentNotifications:u,unreadNotifications:f,readNotifications:h,dbConnected:p,dbStatus:g,siteInfo:v,setActiveStudentId:x,setReadNotifications:b,setIsSystemResourceLibraryOpen:j,setProfileOpen:N,setTeacherTab:w,setStudentViewStatus:A,setIsNotificationsOpen:P,setSelectedNotificationForModal:E,handleLogout:T,toggleLanguage:C}=e;return i.jsxs("header",{className:"h-16 border-b border-gray-200 bg-white flex items-center px-6 justify-between shrink-0 shadow-sm relative z-20",children:[i.jsxs("div",{className:"flex items-center gap-4 sm:gap-6",children:[i.jsxs("button",{onClick:()=>{t==="teacher"?w("dashboard"):t==="student"&&A("dashboard")},className:"flex items-center gap-2.5 shrink-0 hover:opacity-80 transition-opacity cursor-pointer",title:r==="zh"?"返回系统总览":"Back to Dashboard",children:[v.logoUrl?i.jsx("img",{src:v.logoUrl,alt:"site logo",className:"h-8 w-8 object-contain rounded-lg shrink-0"}):i.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"}),i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsx("span",{className:"text-base font-black text-slate-900 tracking-tight",children:v.siteName||"OpenLearn Next"}),i.jsxs("span",{className:"text-[10px] font-medium text-slate-400 tracking-tight",children:["v","0.2.1"]}),v.slogan&&i.jsx("span",{className:"hidden md:inline text-xs text-slate-400 font-normal truncate max-w-[200px]",children:v.slogan})]})]}),i.jsxs("button",{onClick:()=>{t==="teacher"?w("dashboard"):t==="student"&&A("dashboard")},className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors cursor-pointer ${t==="teacher"&&n==="dashboard"||t==="student"&&s==="dashboard"?"bg-indigo-50 text-indigo-700":"text-slate-600 hover:text-indigo-600 hover:bg-slate-100"}`,children:[i.jsx(JU,{size:16}),r==="zh"?"系统总览":"Dashboard"]}),t==="student"&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-slate-300 font-light text-lg select-none",children:"/"}),i.jsxs("h2",{className:"font-semibold text-gray-800 tracking-tight flex items-center gap-2",children:[i.jsx(Bh,{size:20,className:"text-gray-400"}),"Student Dashboard"]})]}),t==="student"&&a.role==="teacher"&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-gray-500",children:"View as:"}),i.jsxs("select",{className:"border border-gray-200 rounded p-1 text-sm bg-white",value:o||"",onChange:I=>x(I.target.value),children:[i.jsx("option",{value:"",children:"-- Select Student --"}),l.map(I=>i.jsx("option",{value:I.id,children:I.name},I.id))]})]})]}),i.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[t==="student"&&o&&c&&i.jsxs("div",{className:"relative",children:[i.jsxs("button",{onClick:()=>P(!d),className:"relative p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors",children:[i.jsx(uD,{size:20}),f.length>0&&i.jsx("span",{className:"absolute top-1 right-1 bg-red-500 text-white text-[10px] font-bold px-1.5 py-0.5 rounded-full flex items-center justify-center min-w-[18px]",children:f.length})]}),d&&i.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:[i.jsxs("div",{className:"p-3 border-b border-gray-100 flex justify-between items-center bg-gray-50",children:[i.jsx("h3",{className:"font-semibold text-gray-800",children:"Notifications"}),f.length>0&&i.jsx("button",{onClick:async()=>{if(!o)return;try{const _=u.filter(L=>!h.has(L.id)).map(L=>fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:L.id})}));await Promise.all(_)}catch(_){console.error(_)}const I=new Set(h);u.forEach(_=>I.add(_.id)),b(I)},className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium",children:"Mark all as read"})]}),i.jsx("div",{className:"max-h-96 overflow-y-auto",children:u.length===0?i.jsx("div",{className:"p-4 text-center text-sm text-gray-500 italic",children:"No notifications."}):i.jsx("div",{className:"divide-y divide-gray-100",children:u.map(I=>{const _=!h.has(I.id);return i.jsx("div",{className:`p-3 hover:bg-gray-50 cursor-pointer ${_?"bg-indigo-50/30":""}`,onClick:()=>{if(_){o&&fetch(`/api/students/${o}/read_notifications`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notificationId:I.id})}).catch(console.error);const $=new Set(h);$.add(I.id),b($)}const L=c?.assignments?.find($=>$.id===I.relatedId);E({...I,assignment:L}),P(!1)},children:i.jsxs("div",{className:"flex gap-3",children:[i.jsx("div",{className:"mt-0.5",children:I.type==="new_assignment"?i.jsx(cp,{size:16,className:"text-indigo-500"}):I.type==="rollcall_picked"?i.jsx(An,{size:16,className:"text-amber-500 animate-pulse"}):i.jsx(Qr,{size:16,className:"text-green-500"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:`text-sm ${_?"font-semibold text-gray-900":"font-medium text-gray-700"}`,children:I.title}),i.jsx("div",{className:`text-xs mt-0.5 ${_?"text-gray-600":"text-gray-500"}`,children:I.message})]}),_&&i.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500 mt-1"})]})},I.id)})})})]})]}),i.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-1.5 hover:text-indigo-600 transition-colors bg-white px-3 py-1.5 rounded-md border border-gray-200 shadow-sm font-medium cursor-pointer",children:[i.jsx(Wo,{size:14,className:"text-emerald-500 animate-pulse"}),r==="zh"?"系统资源库":"System Resource Library"]}),i.jsx("button",{onClick:C,title:r==="zh"?"Switch to English":"切换为中文",className:"p-2 hover:bg-slate-100 text-slate-600 hover:text-indigo-600 transition-colors bg-white rounded-lg border border-gray-200 shadow-3xs flex items-center justify-center shrink-0 cursor-pointer",children:i.jsx(Wo,{size:16})}),(()=>{const I=g==="error"||!p?{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:r==="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:r==="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:r==="zh"?"SQLite 数据库连接正常":"SQLite DB Connected & Normal"};return i.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 ${I.bg}`,title:I.label,children:[i.jsx(Ol,{size:15}),i.jsxs("span",{className:"absolute -top-0.5 -right-0.5 flex h-2.5 w-2.5",children:[i.jsx("span",{className:`animate-ping absolute inline-flex h-full w-full rounded-full opacity-75 ${I.ping}`}),i.jsx("span",{className:`relative inline-flex rounded-full h-2.5 w-2.5 ${I.dot}`})]})]})})(),i.jsx(Wq,{session:a,lang:r,onLogout:T,onProfile:()=>N(!0)})]})]})}function qq({open:e,session:t,lang:r,onClose:n,onSaved:s,onAvatar:a}){const[o,l]=m.useState(t.name),[c,d]=m.useState(!1),[u,f]=m.useState(null),h=m.useRef(null),[p,g]=m.useState(!1),[v,x]=m.useState(null),[b,j]=m.useState(!1),[N,w]=m.useState(""),[A,P]=m.useState(""),[E,T]=m.useState(""),[C,I]=m.useState(!1),[_,L]=m.useState(null),[$,z]=m.useState(!1);if(!e)return null;const R=(U,F)=>r==="zh"?U:F,J=t.role==="teacher"?t.subRole==="administrator"?R("管理员","Administrator"):R("教师","Teacher"):R("学生","Student"),Z=o.trim(),q=Z.length>0&&Z!==t.name,Y=async()=>{if(!(!q||c)){d(!0),f(null);try{const U=await fetch("/api/auth/profile",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Z})}),F=await U.json();if(!U.ok){f(F.error||(r==="zh"?"保存失败":"Save failed"));return}s(F.name??Z)}catch{f(r==="zh"?"网络错误,请重试":"Network error, please retry")}finally{d(!1)}}},de=N.length>0&&A.length>=8&&/[a-zA-Z]/.test(A)&&/[0-9]/.test(A)&&A===E,H=async()=>{if(!(!de||C)){I(!0),L(null);try{const U=await fetch("/api/auth/change-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPassword:N,newPassword:A})}),F=await U.json();if(!U.ok){L(F.error||(r==="zh"?"修改失败":"Change failed"));return}z(!0),w(""),P(""),T(""),j(!1)}catch{L(r==="zh"?"网络错误,请重试":"Network error, please retry")}finally{I(!1)}}},M=async U=>{const F=U.target.files?.[0];if(U.target.value="",!!F){g(!0),x(null);try{const se=await new Promise((ee,ie)=>{const xe=new FileReader;xe.onload=()=>ee(xe.result),xe.onerror=()=>ie(xe.error),xe.readAsDataURL(F)}),ue=await fetch("/api/auth/avatar",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:F.name,base64Data:se})}),re=await ue.json();if(!ue.ok){x(re.error||(r==="zh"?"上传失败":"Upload failed"));return}a?.(re.avatar)}catch{x(r==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}}},V=async()=>{g(!0),x(null);try{const U=await fetch("/api/auth/avatar",{method:"DELETE"}),F=await U.json().catch(()=>({}));if(!U.ok){x(F.error||(r==="zh"?"移除失败":"Remove failed"));return}a?.(null)}catch{x(r==="zh"?"网络错误,请重试":"Network error, please retry")}finally{g(!1)}};return i.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4",onClick:n,children:i.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden",onClick:U=>U.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-gray-100",children:[i.jsx("h3",{className:"font-semibold text-gray-800",children:R("个人资料","Profile")}),i.jsx("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 cursor-pointer",children:i.jsx(Lr,{size:18})})]}),i.jsxs("div",{className:"p-5 space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.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?i.jsx("img",{src:t.avatar,alt:t.name,className:"w-full h-full object-cover"}):i.jsx(Fh,{size:28})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("p",{className:"text-base font-semibold text-gray-800 truncate",children:t.name}),i.jsx("p",{className:"text-xs text-gray-400",children:J}),i.jsxs("div",{className:"mt-1.5 flex items-center gap-3",children:[i.jsx("button",{type:"button",onClick:()=>h.current?.click(),disabled:p,className:"text-xs text-indigo-600 hover:text-indigo-800 disabled:opacity-50 cursor-pointer",children:p?R("上传中…","Uploading…"):t.avatar?R("更换头像","Change avatar"):R("上传头像","Upload avatar")}),t.avatar&&i.jsx("button",{type:"button",onClick:V,disabled:p,className:"text-xs text-rose-500 hover:text-rose-700 disabled:opacity-50 cursor-pointer",children:R("移除","Remove")})]}),i.jsx("input",{ref:h,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:M})]})]}),v&&i.jsx("p",{className:"text-xs text-rose-500",children:v}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm text-gray-500 mb-1",children:R("显示名称","Display Name")}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{value:o,onChange:U=>l(U.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"}),i.jsx("button",{onClick:Y,disabled:!q||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?R("保存中…","Saving…"):R("保存","Save")})]}),u&&i.jsx("p",{className:"text-xs text-rose-500 mt-1",children:u})]}),i.jsxs("div",{className:"border-t border-gray-100 pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"text-sm font-medium text-gray-700 flex items-center gap-2",children:[i.jsx(QU,{size:16,className:"text-gray-400"}),R("修改密码","Change Password")]}),!b&&!$&&i.jsx("button",{onClick:()=>{j(!0),L(null)},className:"text-sm text-indigo-600 hover:text-indigo-800 cursor-pointer",children:R("修改","Edit")})]}),$&&i.jsxs("p",{className:"mt-2 flex items-center gap-1.5 text-sm text-emerald-600",children:[i.jsx(Qr,{size:16}),R("密码已修改,其他设备的登录已失效","Password changed. Other devices were logged out.")]}),b&&i.jsxs("div",{className:"mt-3 space-y-3",children:[i.jsx("input",{type:"password",value:N,onChange:U=>w(U.target.value),placeholder:R("当前密码","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"}),i.jsx("input",{type:"password",value:A,onChange:U=>P(U.target.value),placeholder:R("新密码(≥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"}),i.jsx("input",{type:"password",value:E,onChange:U=>T(U.target.value),placeholder:R("确认新密码","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"}),_&&i.jsx("p",{className:"text-xs text-rose-500",children:_}),i.jsxs("div",{className:"flex gap-2 justify-end",children:[i.jsx("button",{onClick:()=>{j(!1),w(""),P(""),T(""),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:R("取消","Cancel")}),i.jsx("button",{onClick:H,disabled:!de||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",children:C?R("提交中…","Submitting…"):R("提交","Submit")})]})]})]}),i.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-gray-400",children:R("用户名(登录账号)","Username (login)")}),i.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-[60%]",title:t.username,children:t.username||"-"})]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm text-gray-400",children:R("角色","Role")}),i.jsx("span",{className:"text-sm font-medium text-gray-700",children:J})]})]})]})]})})}const r0={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"}},Hq=[{id:"present",labelZh:"内容呈现",labelEn:"Content"},{id:"assess",labelZh:"评估互动",labelEn:"Assessment"},{id:"manage",labelZh:"课堂管理",labelEn:"Classroom"}],ND=[{type:"presentation",labelZh:"课件演示",labelEn:"Slides Deck",descriptionZh:"Markdown 幻灯片",descriptionEn:"Markdown slides",icon:e0,color:"violet",group:"present",defaultData:{markdown:`# Title Slide
3
3
  ---
4
4
  ## Slide 2`},editFields:[{key:"markdown",labelZh:"幻灯片内容 (Markdown)",labelEn:"Slides Content (Markdown)",kind:"textarea",placeholderZh:`# 标题
5
5
  ---
@@ -17,7 +17,7 @@ import{j as i,U as Fh,C as Vl,L as ZU,H as JU,b as Bh,B as uD,c as cp,S as An,d
17
17
  }
18
18
  `),()=>{l.current?.removeAttribute("data-motion-pop-id"),E.contains(P)&&E.removeChild(P)}},[t]),i.jsx(TY,{isPresent:t,childRef:l,sizeRef:c,pop:a,children:a===!1?e:m.cloneElement(e,{ref:f})})}const IY=({children:e,initial:t,isPresent:r,onExitComplete:n,custom:s,presenceAffectsLayout:a,mode:o,anchorX:l,anchorY:c,root:d})=>{const u=JS(LY),f=m.useId();let h=!0,p=m.useMemo(()=>(h=!1,{id:f,initial:t,isPresent:r,custom:s,onExitComplete:g=>{u.set(g,!0);for(const v of u.values())if(!v)return;n&&n()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[r,u,n]);return a&&h&&(p={...p}),m.useMemo(()=>{u.forEach((g,v)=>u.set(v,!1))},[r]),m.useEffect(()=>{!r&&!u.size&&n&&n()},[r]),e=i.jsx(OY,{pop:o==="popLayout",isPresent:r,anchorX:l,anchorY:c,root:d,children:e}),i.jsx(Xb.Provider,{value:p,children:e})};function LY(){return new Map}function r8(e=!0){const t=m.useContext(Xb);if(t===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:s}=t,a=m.useId();m.useEffect(()=>{if(e)return s(a)},[e]);const o=m.useCallback(()=>e&&n&&n(a),[a,n,e]);return!r&&n?[!1,o]:[!0]}const Hg=e=>e.key||"";function I4(e){const t=[];return m.Children.forEach(e,r=>{m.isValidElement(r)&&t.push(r)}),t}const ty=({children:e,custom:t,initial:r=!0,onExitComplete:n,presenceAffectsLayout:s=!0,mode:a="sync",propagate:o=!1,anchorX:l="left",anchorY:c="top",root:d})=>{const[u,f]=r8(o),h=m.useMemo(()=>I4(e),[e]),p=o&&!u?[]:h.map(Hg),g=m.useRef(!0),v=m.useRef(h),x=JS(()=>new Map),b=m.useRef(new Set),[j,N]=m.useState(h),[w,A]=m.useState(h);SD(()=>{g.current=!1,v.current=h;for(let T=0;T<w.length;T++){const C=Hg(w[T]);p.includes(C)?(x.delete(C),b.current.delete(C)):x.get(C)!==!0&&x.set(C,!1)}},[w,p.length,p.join("-")]);const P=[];if(h!==j){let T=[...h];for(let C=0;C<w.length;C++){const I=w[C],_=Hg(I);p.includes(_)||(T.splice(C,0,I),P.push(I))}return a==="wait"&&P.length&&(T=P),A(I4(T)),N(h),null}const{forceRender:E}=m.useContext(ZS);return i.jsx(i.Fragment,{children:w.map(T=>{const C=Hg(T),I=o&&!u?!1:h===w||p.includes(C),_=()=>{if(b.current.has(C))return;if(x.has(C))b.current.add(C),x.set(C,!0);else return;let L=!0;x.forEach($=>{$||(L=!1)}),L&&(E?.(),A(v.current),o&&f?.(),n&&n())};return i.jsx(IY,{isPresent:I,initial:!g.current||r?void 0:!1,custom:t,presenceAffectsLayout:s,mode:a,root:d,onExitComplete:I?void 0:_,anchorX:l,anchorY:c,children:T},C)})})},n8=m.createContext({strict:!1}),L4={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 z4=!1;function zY(){if(z4)return;const e={};for(const t in L4)e[t]={isEnabled:r=>L4[t].some(n=>!!r[n])};CM(e),z4=!0}function s8(){return zY(),wG()}function DY(e){const t=s8();for(const r in e)t[r]={...t[r],...e[r]};CM(t)}const MY=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 yv(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||MY.has(e)}let i8=e=>!yv(e);function RY(e){typeof e=="function"&&(i8=t=>t.startsWith("on")?!yv(t):e(t))}try{RY(require("@emotion/is-prop-valid").default)}catch{}function $Y(e,t,r){const n={};for(const s in e)s==="values"&&typeof e.values=="object"||Is(e[s])||(i8(s)||r===!0&&yv(s)||!t&&!yv(s)||e.draggable&&s.startsWith("onDrag"))&&(n[s]=e[s]);return n}const ry=m.createContext({});function FY(e,t){if(ey(e)){const{initial:r,animate:n}=e;return{initial:r===!1||a0(r)?r:void 0,animate:a0(n)?n:void 0}}return e.inherit!==!1?t:{}}function BY(e){const{initial:t,animate:r}=FY(e,m.useContext(ry));return m.useMemo(()=>({initial:t,animate:r}),[D4(t),D4(r)])}function D4(e){return Array.isArray(e)?e.join(" "):e}const PA=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function a8(e,t,r){for(const n in t)!Is(t[n])&&!DM(n,r)&&(e[n]=t[n])}function VY({transformTemplate:e},t){return m.useMemo(()=>{const r=PA();return NA(r,t,e),Object.assign({},r.vars,r.style)},[t])}function WY(e,t){const r=e.style||{},n={};return a8(n,r,e),Object.assign(n,VY(e,t)),n}function UY(e,t){const r={},n=WY(e,t);return e.drag&&e.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(r.tabIndex=0),r.style=n,r}const o8=()=>({...PA(),attrs:{}});function qY(e,t,r,n){const s=m.useMemo(()=>{const a=o8();return RM(a,t,FM(n),e.transformTemplate,e.style),{...a.attrs,style:{...a.style}}},[t]);if(e.style){const a={};a8(a,e.style,e),s.style={...a,...s.style}}return s}const HY=["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 kA(e){return typeof e!="string"||e.includes("-")?!1:!!(HY.indexOf(e)>-1||/[A-Z]/u.test(e))}function KY(e,t,r,{latestValues:n},s,a=!1,o){const c=(o??kA(e)?qY:UY)(t,n,s,e),d=$Y(t,typeof e=="string",a),u=e!==m.Fragment?{...d,...c,ref:r}:{},{children:f}=t,h=m.useMemo(()=>Is(f)?f.get():f,[f]);return m.createElement(e,{...u,children:h})}function GY({scrapeMotionValuesFromProps:e,createRenderState:t},r,n,s){return{latestValues:YY(r,n,s,e),renderState:t()}}function YY(e,t,r,n){const s={},a=n(e,{});for(const h in a)s[h]=$x(a[h]);let{initial:o,animate:l}=e;const c=ey(e),d=PM(e);t&&d&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let u=r?r.initial===!1:!1;u=u||o===!1;const f=u?l:o;if(f&&typeof f!="boolean"&&!Qb(f)){const h=Array.isArray(f)?f:[f];for(let p=0;p<h.length;p++){const g=mA(e,h[p]);if(g){const{transitionEnd:v,transition:x,...b}=g;for(const j in b){let N=b[j];if(Array.isArray(N)){const w=u?N.length-1:0;N=N[w]}N!==null&&(s[j]=N)}for(const j in v)s[j]=v[j]}}}return s}const l8=e=>(t,r)=>{const n=m.useContext(ry),s=m.useContext(Xb),a=()=>GY(e,t,n,s);return r?a():JS(a)},XY=l8({scrapeMotionValuesFromProps:SA,createRenderState:PA}),ZY=l8({scrapeMotionValuesFromProps:BM,createRenderState:o8}),JY=Symbol.for("motionComponentSymbol");function QY(e,t,r){const n=m.useRef(r);m.useInsertionEffect(()=>{n.current=r});const s=m.useRef(null);return m.useCallback(a=>{a&&e.onMount?.(a),t&&(a?t.mount(a):t.unmount());const o=n.current;if(typeof o=="function")if(a){const l=o(a);typeof l=="function"&&(s.current=l)}else s.current?(s.current(),s.current=null):o(a);else o&&(o.current=a)},[t])}const c8=m.createContext({});function hh(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function eX(e,t,r,n,s,a){const{visualElement:o}=m.useContext(ry),l=m.useContext(n8),c=m.useContext(Xb),d=m.useContext(AA),u=d.reducedMotion,f=d.skipAnimations,h=m.useRef(null),p=m.useRef(!1);n=n||l.renderer,!h.current&&n&&(h.current=n(e,{visualState:t,parent:o,props:r,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:f,isSVG:a}),p.current&&h.current&&(h.current.manuallyAnimateOnMount=!0));const g=h.current,v=m.useContext(c8);g&&!g.projection&&s&&(g.type==="html"||g.type==="svg")&&tX(h.current,r,s,v);const x=m.useRef(!1);m.useInsertionEffect(()=>{g&&x.current&&g.update(r,c)});const b=r[mM],j=m.useRef(!!b&&typeof window<"u"&&!window.MotionHandoffIsComplete?.(b)&&window.MotionHasOptimisedAnimation?.(b));return SD(()=>{p.current=!0,g&&(x.current=!0,window.MotionIsMounted=!0,g.updateFeatures(),g.scheduleRenderMicrotask(),j.current&&g.animationState&&g.animationState.animateChanges())}),m.useEffect(()=>{g&&(!j.current&&g.animationState&&g.animationState.animateChanges(),j.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(b)}),j.current=!1),g.enteringChildren=void 0)}),g}function tX(e,t,r,n){const{layoutId:s,layout:a,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:d,layoutAnchor:u,layoutCrossfade:f}=t;e.projection=new r(e.latestValues,t["data-framer-portal-id"]?void 0:d8(e.parent)),e.projection.setOptions({layoutId:s,layout:a,alwaysMeasureLayout:!!o||l&&hh(l),visualElement:e,animationType:typeof a=="string"?a:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:c,layoutRoot:d,layoutAnchor:u})}function d8(e){if(e)return e.options.allowProjection!==!1?e.projection:d8(e.parent)}function uw(e,{forwardMotionProps:t=!1,type:r}={},n,s){n&&DY(n);const a=r?r==="svg":kA(e),o=a?ZY:XY;function l(d,u){let f;const h={...m.useContext(AA),...d,layoutId:rX(d)},{isStatic:p}=h,g=BY(d),v=o(d,p);if(!p&&typeof window<"u"){nX();const x=sX(h);f=x.MeasureLayout,g.visualElement=eX(e,v,h,s,x.ProjectionNode,a)}return i.jsxs(ry.Provider,{value:g,children:[f&&g.visualElement?i.jsx(f,{visualElement:g.visualElement,...h}):null,KY(e,d,QY(v,g.visualElement,u),v,p,t,a)]})}l.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=m.forwardRef(l);return c[JY]=e,c}function rX({layoutId:e}){const t=m.useContext(ZS).id;return t&&e!==void 0?t+"-"+e:e}function nX(e,t){m.useContext(n8).strict}function sX(e){const t=s8(),{drag:r,layout:n}=t;if(!r&&!n)return{};const s={...r,...n};return{MeasureLayout:r?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function iX(e,t){if(typeof Proxy>"u")return uw;const r=new Map,n=(a,o)=>uw(a,o,e,t),s=(a,o)=>n(a,o);return new Proxy(s,{get:(a,o)=>o==="create"?n:(r.has(o)||r.set(o,uw(o,void 0,e,t)),r.get(o))})}const aX=(e,t)=>t.isSVG??kA(e)?new VM(t):new MM(t,{allowProjection:e!==m.Fragment});let oX=class extends Zd{constructor(t){super(t),t.animationState||(t.animationState=VG(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Qb(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:r}=this.node.prevProps||{};t!==r&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},lX=0,cX=class extends Zd{constructor(){super(...arguments),this.id=lX++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===n)return;if(t&&n===!1){if(this.isExitComplete){const{initial:a,custom:o}=this.node.getProps();if(typeof a=="string"||typeof a=="object"&&a!==null&&!Array.isArray(a)){const l=Xu(this.node,a,o);if(l){const{transition:c,transitionEnd:d,...u}=l;for(const f in u)this.node.getValue(f)?.jump(u[f])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const s=this.node.animationState.setActive("exit",!t);r&&!t&&s.then(()=>{this.isExitComplete=!0,r(this.id)})}mount(){const{register:t,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),t&&(this.unmount=t(this.id))}unmount(){}};const dX={animation:{Feature:oX},exit:{Feature:cX}};function B0(e){return{point:{x:e.pageX,y:e.pageY}}}const uX=e=>t=>yA(t)&&e(t,B0(t));function Fm(e,t,r,n){return o0(e,t,uX(r),n)}const u8=({current:e})=>e?e.ownerDocument.defaultView:null,M4=(e,t)=>Math.abs(e-t);function fX(e,t){const r=M4(e.x,t.x),n=M4(e.y,t.y);return Math.sqrt(r**2+n**2)}const R4=new Set(["auto","scroll"]);let f8=class{constructor(t,r,{transformPagePoint:n,contextWindow:s=window,dragSnapToOrigin:a=!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=p=>{this.handleScroll(p.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Kg(this.lastRawMoveEventInfo,this.transformPagePoint));const p=fw(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,v=fX(p.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!v)return;const{point:x}=p,{timestamp:b}=ni;this.history.push({...x,timestamp:b});const{onStart:j,onMove:N}=this.handlers;g||(j&&j(this.lastMoveEvent,p),this.startEvent=this.lastMoveEvent),N&&N(this.lastMoveEvent,p)},this.handlePointerMove=(p,g)=>{this.lastMoveEvent=p,this.lastRawMoveEventInfo=g,this.lastMoveEventInfo=Kg(g,this.transformPagePoint),cn.update(this.updatePoint,!0)},this.handlePointerUp=(p,g)=>{this.end();const{onEnd:v,onSessionEnd:x,resumeAnimation:b}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&b&&b(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const j=fw(p.type==="pointercancel"?this.lastMoveEventInfo:Kg(g,this.transformPagePoint),this.history);this.startEvent&&v&&v(p,j),x&&x(p,j)},!yA(t))return;this.dragSnapToOrigin=a,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=o,this.contextWindow=s||window;const c=B0(t),d=Kg(c,this.transformPagePoint),{point:u}=d,{timestamp:f}=ni;this.history=[{...u,timestamp:f}];const{onSessionStart:h}=r;h&&h(t,fw(d,this.history)),this.removeListeners=R0(Fm(this.contextWindow,"pointermove",this.handlePointerMove),Fm(this.contextWindow,"pointerup",this.handlePointerUp),Fm(this.contextWindow,"pointercancel",this.handlePointerUp)),l&&this.startScrollTracking(l)}startScrollTracking(t){let r=t.parentElement;for(;r;){const n=getComputedStyle(r);(R4.has(n.overflowX)||R4.has(n.overflowY))&&this.scrollPositions.set(r,{x:r.scrollLeft,y:r.scrollTop}),r=r.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 r=this.scrollPositions.get(t);if(!r)return;const n=t===window,s=n?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},a={x:s.x-r.x,y:s.y-r.y};a.x===0&&a.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=a.x,this.lastMoveEventInfo.point.y+=a.y):this.history.length>0&&(this.history[0].x-=a.x,this.history[0].y-=a.y),this.scrollPositions.set(t,s),cn.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),qd(this.updatePoint)}};function Kg(e,t){return t?{point:t(e.point)}:e}function $4(e,t){return{x:e.x-t.x,y:e.y-t.y}}function fw({point:e},t){return{point:e,delta:$4(e,h8(t)),offset:$4(e,hX(t)),velocity:pX(t,.1)}}function hX(e){return e[0]}function h8(e){return e[e.length-1]}function pX(e,t){if(e.length<2)return{x:0,y:0};let r=e.length-1,n=null;const s=h8(e);for(;r>=0&&(n=e[r],!(s.timestamp-n.timestamp>ta(t)));)r--;if(!n)return{x:0,y:0};n===e[0]&&e.length>2&&s.timestamp-n.timestamp>ta(t)*2&&(n=e[1]);const a=eo(s.timestamp-n.timestamp);if(a===0)return{x:0,y:0};const o={x:(s.x-n.x)/a,y:(s.y-n.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function mX(e,{min:t,max:r},n){return t!==void 0&&e<t?e=n?Jr(t,e,n.min):Math.max(e,t):r!==void 0&&e>r&&(e=n?Jr(r,e,n.max):Math.min(e,r)),e}function F4(e,t,r){return{min:t!==void 0?e.min+t:void 0,max:r!==void 0?e.max+r-(e.max-e.min):void 0}}function gX(e,{top:t,left:r,bottom:n,right:s}){return{x:F4(e.x,r,s),y:F4(e.y,t,n)}}function B4(e,t){let r=t.min-e.min,n=t.max-e.max;return t.max-t.min<e.max-e.min&&([r,n]=[n,r]),{min:r,max:n}}function xX(e,t){return{x:B4(e.x,t.x),y:B4(e.y,t.y)}}function vX(e,t){let r=.5;const n=Di(e),s=Di(t);return s>n?r=qh(t.min,t.max-n,e.min):n>s&&(r=qh(e.min,e.max-s,t.min)),Wl(0,1,r)}function bX(e,t){const r={};return t.min!==void 0&&(r.min=t.min-e.min),t.max!==void 0&&(r.max=t.max-e.min),r}const Mj=.35;function yX(e=Mj){return e===!1?e=0:e===!0&&(e=Mj),{x:V4(e,"left","right"),y:V4(e,"top","bottom")}}function V4(e,t,r){return{min:W4(e,t),max:W4(e,r)}}function W4(e,t){return typeof e=="number"?e:e[t]||0}const wX=new WeakMap;let jX=class{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=hs(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const a=f=>{r&&this.snapToCursor(B0(f).point),this.stopAnimation()},o=(f,h)=>{const{drag:p,dragPropagation:g,onDragStart:v}=this.getProps();if(p&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=QK(p),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=h,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),kl(b=>{let j=this.getAxisMotionValue(b).get()||0;if(Ml.test(j)){const{projection:N}=this.visualElement;if(N&&N.layout){const w=N.layout.layoutBox[b];w&&(j=Di(w)*(parseFloat(j)/100))}}this.originPoint[b]=j}),v&&cn.update(()=>v(f,h),!1,!0),kj(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},l=(f,h)=>{this.latestPointerEvent=f,this.latestPanInfo=h;const{dragPropagation:p,dragDirectionLock:g,onDirectionLock:v,onDrag:x}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:b}=h;if(g&&this.currentDirection===null){this.currentDirection=SX(b),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",h.point,b),this.updateAxis("y",h.point,b),this.visualElement.render(),x&&cn.update(()=>x(f,h),!1,!0)},c=(f,h)=>{this.latestPointerEvent=f,this.latestPanInfo=h,this.stop(f,h),this.latestPointerEvent=null,this.latestPanInfo=null},d=()=>{const{dragSnapToOrigin:f}=this.getProps();(f||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:u}=this.getProps();this.panSession=new f8(t,{onSessionStart:a,onStart:o,onMove:l,onSessionEnd:c,resumeAnimation:d},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:n,contextWindow:u8(this.visualElement),element:this.visualElement.current})}stop(t,r){const n=t||this.latestPointerEvent,s=r||this.latestPanInfo,a=this.isDragging;if(this.cancel(),!a||!s||!n)return;const{velocity:o}=s;this.startAnimation(o);const{onDragEnd:l}=this.getProps();l&&cn.postRender(()=>l(n,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:r}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),r&&r.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,r,n){const{drag:s}=this.getProps();if(!n||!Gg(t,s,this.currentDirection))return;const a=this.getAxisMotionValue(t);let o=this.originPoint[t]+n[t];this.constraints&&this.constraints[t]&&(o=mX(o,this.constraints[t],this.elastic[t])),a.set(o)}resolveConstraints(){const{dragConstraints:t,dragElastic:r}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,s=this.constraints;t&&hh(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&n?this.constraints=gX(n.layoutBox,t):this.constraints=!1,this.elastic=yX(r),s!==this.constraints&&!hh(t)&&n&&this.constraints&&!this.hasMutatedConstraints&&kl(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=bX(n.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:r}=this.getProps();if(!t||!hh(t))return!1;const n=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;s.root&&(s.root.scroll=void 0,s.root.updateScroll());const a=AG(n,s.root,this.visualElement.getTransformPagePoint());let o=xX(s.layout.layoutBox,a);if(r){const l=r(jG(o));this.hasMutatedConstraints=!!l,l&&(o=TM(l))}return o}startAnimation(t){const{drag:r,dragMomentum:n,dragElastic:s,dragTransition:a,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},d=kl(u=>{if(!Gg(u,r,this.currentDirection))return;let f=c&&c[u]||{};(o===!0||o===u)&&(f={min:0,max:0});const h=s?200:1e6,p=s?40:1e7,g={type:"inertia",velocity:n?t[u]:0,bounceStiffness:h,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...a,...f};return this.startAxisValueAnimation(u,g)});return Promise.all(d).then(l)}startAxisValueAnimation(t,r){const n=this.getAxisMotionValue(t);return kj(this.visualElement,t),n.start(pA(t,n,0,r,this.visualElement,!1))}stopAnimation(){kl(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const r=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps()[r];return s||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){kl(r=>{const{drag:n}=this.getProps();if(!Gg(r,n,this.currentDirection))return;const{projection:s}=this.visualElement,a=this.getAxisMotionValue(r);if(s&&s.layout){const{min:o,max:l}=s.layout.layoutBox[r],c=a.get()||0;a.set(t[r]-Jr(o,l,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!hh(r)||!n||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};kl(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();s[o]=vX({min:c,max:c},this.constraints[o])}});const{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),kl(o=>{if(!Gg(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:d}=this.constraints[o];l.set(Jr(c,d,s[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;wX.set(this.visualElement,this);const t=this.visualElement.current,r=Fm(t,"pointerdown",d=>{const{drag:u,dragListener:f=!0}=this.getProps(),h=d.target,p=h!==t&&iG(h);u&&f&&!p&&this.start(d)});let n;const s=()=>{const{dragConstraints:d}=this.getProps();hh(d)&&d.current&&(this.constraints=this.resolveRefConstraints(),n||(n=NX(t,d.current,()=>this.scalePositionWithinConstraints())))},{projection:a}=this.visualElement,o=a.addEventListener("measure",s);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),cn.read(s);const l=o0(window,"resize",()=>this.scalePositionWithinConstraints()),c=a.addEventListener("didUpdate",(({delta:d,hasLayoutChanged:u})=>{this.isDragging&&u&&(kl(f=>{const h=this.getAxisMotionValue(f);h&&(this.originPoint[f]+=d[f].translate,h.set(h.get()+d[f].translate))}),this.visualElement.render())}));return()=>{l(),r(),o(),c&&c(),n&&n()}}getProps(){const t=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:s=!1,dragConstraints:a=!1,dragElastic:o=Mj,dragMomentum:l=!0}=t;return{...t,drag:r,dragDirectionLock:n,dragPropagation:s,dragConstraints:a,dragElastic:o,dragMomentum:l}}};function U4(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function NX(e,t,r){const n=ZC(e,U4(r)),s=ZC(t,U4(r));return()=>{n(),s()}}function Gg(e,t,r){return(t===!0||t===e)&&(r===null||r===e)}function SX(e,t=10){let r=null;return Math.abs(e.y)>t?r="y":Math.abs(e.x)>t&&(r="x"),r}let AX=class extends Zd{constructor(t){super(t),this.removeGroupControls=ao,this.removeListeners=ao,this.controls=new jX(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ao}update(){const{dragControls:t}=this.node.getProps(),{dragControls:r}=this.node.prevProps||{};t!==r&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}};const hw=e=>(t,r)=>{e&&cn.update(()=>e(t,r),!1,!0)};let PX=class extends Zd{constructor(){super(...arguments),this.removePointerDownListener=ao}onPointerDown(t){this.session=new f8(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:u8(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:r,onPan:n,onPanEnd:s}=this.node.getProps();return{onSessionStart:hw(t),onStart:hw(r),onMove:hw(n),onEnd:(a,o)=>{delete this.session,s&&cn.postRender(()=>s(a,o))}}}mount(){this.removePointerDownListener=Fm(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},pw=!1,kX=class extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:r,switchLayoutGroup:n,layoutId:s}=this.props,{projection:a}=t;a&&(r.group&&r.group.add(a),n&&n.register&&s&&n.register(a),pw&&a.root.didUpdate(),a.addEventListener("animationComplete",()=>{this.safeToRemove()}),a.setOptions({...a.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Fx.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:r,visualElement:n,drag:s,isPresent:a}=this.props,{projection:o}=n;return o&&(o.isPresent=a,t.layoutDependency!==r&&o.setOptions({...o.options,layoutDependency:r}),pw=!0,s||t.layoutDependency!==r||r===void 0||t.isPresent!==a?o.willUpdate():this.safeToRemove(),t.isPresent!==a&&(a?o.promote():o.relegate()||cn.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:r}=this.props,{projection:n}=t;n&&(n.options.layoutAnchor=r,n.root.didUpdate(),bA.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:s}=t;pw=!0,s&&(s.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(s),n&&n.deregister&&n.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}};function p8(e){const[t,r]=r8(),n=m.useContext(ZS);return i.jsx(kX,{...e,layoutGroup:n,switchLayoutGroup:m.useContext(c8),isPresent:t,safeToRemove:r})}const CX={pan:{Feature:PX},drag:{Feature:AX,ProjectionNode:t8,MeasureLayout:p8}};function q4(e,t,r){const{props:n}=e;e.animationState&&n.whileHover&&e.animationState.setActive("whileHover",r==="Start");const s="onHover"+r,a=n[s];a&&cn.postRender(()=>a(t,B0(t)))}let EX=class extends Zd{mount(){const{current:t}=this.node;t&&(this.unmount=tG(t,(r,n)=>(q4(this.node,n,"Start"),s=>q4(this.node,s,"End"))))}unmount(){}},_X=class extends Zd{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=R0(o0(this.node.current,"focus",()=>this.onFocus()),o0(this.node.current,"blur",()=>this.onBlur()))}unmount(){}};function H4(e,t,r){const{props:n}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&n.whileTap&&e.animationState.setActive("whileTap",r==="Start");const s="onTap"+(r==="End"?"":r),a=n[s];a&&cn.postRender(()=>a(t,B0(t)))}let TX=class extends Zd{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=oG(t,(s,a)=>(H4(this.node,a,"Start"),(o,{success:l})=>H4(this.node,o,l?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:n?.tap===!1})}unmount(){}};const Rj=new WeakMap,mw=new WeakMap,OX=e=>{const t=Rj.get(e.target);t&&t(e)},IX=e=>{e.forEach(OX)};function LX({root:e,...t}){const r=e||document;mw.has(r)||mw.set(r,{});const n=mw.get(r),s=JSON.stringify(t);return n[s]||(n[s]=new IntersectionObserver(IX,{root:e,...t})),n[s]}function zX(e,t,r){const n=LX(t);return Rj.set(e,r),n.observe(e),()=>{Rj.delete(e),n.unobserve(e)}}const DX={some:0,all:1};let MX=class extends Zd{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();const{viewport:t={}}=this.node.getProps(),{root:r,margin:n,amount:s="some",once:a}=t,o={root:r?r.current:void 0,rootMargin:n,threshold:typeof s=="number"?s:DX[s]},l=c=>{const{isIntersecting:d}=c;if(this.isInView===d||(this.isInView=d,a&&!d&&this.hasEnteredView))return;d&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",d);const{onViewportEnter:u,onViewportLeave:f}=this.node.getProps(),h=d?u:f;h&&h(c)};this.stopObserver=zX(this.node.current,o,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:r}=this.node;["amount","margin","root"].some(RX(t,r))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function RX({viewport:e={}},{viewport:t={}}={}){return r=>e[r]!==t[r]}const $X={inView:{Feature:MX},tap:{Feature:TX},focus:{Feature:_X},hover:{Feature:EX}},FX={layout:{ProjectionNode:t8,MeasureLayout:p8}},BX={...dX,...$X,...CX,...FX},Fi=iX(BX,aX);function CA(e){return typeof e=="object"&&!Array.isArray(e)}function m8(e,t,r,n){return e==null?[]:typeof e=="string"&&CA(t)?vA(e,r,n):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(s=>s!=null):[e]}function VX(e,t,r){return e*(t+1)+r*t}function K4(e,t,r,n){return typeof t=="number"?t:t.startsWith("-")||t.startsWith("+")?Math.max(0,e+parseFloat(t)):t==="<"?r:t.startsWith("<")?Math.max(0,r+parseFloat(t.slice(1))):n.get(t)??e}function WX(e,t,r){for(let n=0;n<e.length;n++){const s=e[n];s.at>t&&s.at<r&&(Uh(e,s),n--)}}function UX(e,t,r,n,s,a){WX(e,s,a);for(let o=0;o<t.length;o++)e.push({value:t[o],at:Jr(s,a,n[o]),easing:$D(r,o)})}function qX(e,t,r=0){const n=t+1+t*r;for(let s=0;s<e.length;s++)e[s]=e[s]/n}function HX(e,t){return e.at===t.at?e.value===null?1:t.value===null?-1:0:e.at-t.at}const KX="easeInOut",GX=20;function YX(e,{defaultTransition:t={},...r}={},n,s){const a=t.duration||.3,o=new Map,l=new Map,c={},d=new Map;let u=0,f=0,h=0;for(let p=0;p<e.length;p++){const g=e[p];if(typeof g=="string"){d.set(g,f);continue}else if(!Array.isArray(g)){d.set(g.name,K4(f,g.at,u,d));continue}let[v,x,b={}]=g;b.at!==void 0&&(f=K4(f,b.at,u,d));let j=0;const N=(w,A,P,E=0,T=0)=>{const C=XX(w),{delay:I=0,times:_=eM(C),type:L=t.type||"keyframes",repeat:$,repeatType:z,repeatDelay:R=0,...J}=A;let{ease:Z=t.ease||"easeOut",duration:q}=A;const Y=typeof I=="function"?I(E,T):I,de=C.length,H=fA(L)?L:s?.[L||"keyframes"];if(de<=2&&H){let F=100;if(de===2&&QX(C)){const re=C[1]-C[0];F=Math.abs(re)}const se={...t,...J};q!==void 0&&(se.duration=ta(q));const ue=ZD(se,F,H);Z=ue.ease,q=ue.duration}q??(q=a);const M=f+Y;_.length===1&&_[0]===0&&(_[1]=1);const V=_.length-C.length;if(V>0&&QD(_,V),C.length===1&&C.unshift(null),$&&$<GX){const F=q>0?R/q:0;q=VX(q,$,R);const se=[...C],ue=[..._];Z=Array.isArray(Z)?[...Z]:[Z];const re=[...Z],ee=z==="reverse"||z==="mirror";let ie=se,xe=re;ee&&(ie=[...se].reverse(),z==="reverse"&&(xe=[...re].reverse().map(fe=>typeof fe=="function"?rA(fe):fe)));for(let fe=0;fe<$;fe++){const Ee=ee&&fe%2===0,ke=Ee?ie:se,Q=Ee?xe:re,Me=(fe+1)*(1+F);F>0&&(C.push(C[C.length-1]),_.push(Me),Z.push("linear")),C.push(...ke);for(let Xe=0;Xe<ke.length;Xe++)_.push(ue[Xe]+Me),Z.push(Xe===0?"linear":$D(Q,Xe-1))}qX(_,$,F)}const U=M+q;UX(P,C,Z,_,M,U),j=Math.max(Y+q,j),h=Math.max(U,h)};if(Is(v)){const w=G4(v,l);N(x,b,Y4("default",w))}else{const w=m8(v,x,n,c),A=w.length;for(let P=0;P<A;P++){x=x,b=b;const E=w[P],T=G4(E,l);for(const C in x)N(x[C],ZX(b,C),Y4(C,T),P,A)}}u=f,f+=j}return l.forEach((p,g)=>{for(const v in p){const x=p[v];x.sort(HX);const b=[],j=[],N=[];for(let E=0;E<x.length;E++){const{at:T,value:C,easing:I}=x[E];b.push(C),j.push(qh(0,h,T)),N.push(I||"easeOut")}j[0]!==0&&(j.unshift(0),b.unshift(b[0]),N.unshift(KX)),j[j.length-1]!==1&&(j.push(1),b.push(null)),o.has(g)||o.set(g,{keyframes:{},transition:{}});const w=o.get(g);w.keyframes[v]=b;const{type:A,...P}=t;w.transition[v]={...P,duration:h,ease:N,times:j,...r}}}),o}function G4(e,t){return!t.has(e)&&t.set(e,{}),t.get(e)}function Y4(e,t){return t[e]||(t[e]=[]),t[e]}function XX(e){return Array.isArray(e)?e:[e]}function ZX(e,t){return e&&e[t]?{...e,...e[t]}:{...e}}const JX=e=>typeof e=="number",QX=e=>e.every(JX);function eZ(e){const t={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},r=Jb(e)&&!AM(e)?new VM(t):new MM(t);r.mount(e),i0.set(e,r)}function tZ(e){const t={presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}},r=new OG(t);r.mount(e),i0.set(e,r)}function rZ(e,t){return Is(e)||typeof e=="number"||typeof e=="string"&&!CA(t)}function g8(e,t,r,n){const s=[];if(rZ(e,t))s.push(ZM(e,CA(t)&&t.default||t,r&&(r.default||r)));else{if(e==null)return s;const a=m8(e,t,n),o=a.length;for(let l=0;l<o;l++){const c=a[l],d=c instanceof Element?eZ:tZ;i0.has(c)||d(c);const u=i0.get(c),f={...r};"delay"in f&&typeof f.delay=="function"&&(f.delay=f.delay(l,o)),s.push(...xA(u,{...t,transition:f},{}))}}return s}function nZ(e,t,r){const n=[],s=e.map(o=>{if(Array.isArray(o)&&typeof o[0]=="function"){const l=o[0],c=af(0);return c.on("change",l),o.length===1?[c,[0,1]]:o.length===2?[c,[0,1],o[1]]:[c,o[1],o[2]]}return o});return YX(s,t,r,{spring:s0}).forEach(({keyframes:o,transition:l},c)=>{n.push(...g8(c,o,l))}),n}function sZ(e){return Array.isArray(e)&&e.some(Array.isArray)}function iZ(e={}){const{scope:t,reduceMotion:r,skipAnimations:n}=e;function s(a,o,l){let c=[],d;const u={};if(r!==void 0&&(u.reduceMotion=r),n!==void 0&&(u.skipAnimations=n),sZ(a)){const{onComplete:h,...p}=o||{};typeof h=="function"&&(d=h),c=nZ(a,{...u,...p},t)}else{const{onComplete:h,...p}=l||{};typeof h=="function"&&(d=h),c=g8(a,o,{...u,...p},t)}const f=new jK(c);return d&&f.finished.then(d),t&&(t.animations.push(f),f.finished.then(()=>{Uh(t.animations,f)})),f}return s}const aZ=iZ();function oZ(e){const{isCourseWizardOpen:t,setIsCourseWizardOpen:r,lang:n,wizardStep:s,setWizardStep:a,wizardIsSubmitting:o,wizardCourseTitle:l,setWizardCourseTitle:c,wizardCourseDescription:d,setWizardCourseDescription:u,wizardCourseCategory:f,setWizardCourseCategory:h,wizardCourseTimeline:p,setWizardCourseTimeline:g,wizardCourseContent:v,setWizardCourseContent:x,addToast:b,generateTemplateContent:j,handleDeployWizardCourse:N}=e;return i.jsx(i.Fragment,{children:t&&i.jsx("div",{className:"fixed inset-0 bg-gray-900/50 backdrop-blur-sm flex items-center justify-center p-4 md:p-6 z-50 overflow-y-auto text-gray-850",children:i.jsxs(Fi.div,{initial:{opacity:0,y:15,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98},className:"bg-white border text-gray-900 border-gray-250 rounded-2xl shadow-2xl w-full max-w-4xl flex flex-col overflow-hidden max-h-[92vh] font-sans text-left",children:[i.jsxs("div",{className:"p-4 md:p-5 border-b border-gray-100 flex items-center justify-between bg-slate-50 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-indigo-50 border border-indigo-100 rounded-lg text-indigo-650",children:i.jsx(Pn,{size:20,className:"animate-pulse"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-bold text-gray-850 text-base md:text-lg",children:n==="zh"?"⭐ 互动课程发布与时间轴向导":"⭐ Course Design Guide & Wizard"}),i.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:n==="zh"?"遵循系统设计法,逐步构建您的学科专属教案与课堂时间轴流程。":"Follow best practices to define curriculum content, timeline segments, and deploy."})]})]}),i.jsx("button",{onClick:()=>r(!1),className:"text-gray-400 hover:text-gray-650 font-bold p-1 rounded-lg hover:bg-gray-150 transition-all text-xl leading-none",children:"×"})]}),i.jsx("div",{className:"px-6 py-4.5 border-b border-gray-50 bg-slate-50/50 flex items-center justify-between gap-2 shrink-0 select-none",children:[{step:1,zh:"1内容选题",en:"1 Background"},{step:2,zh:"2课堂脉络",en:"2 Timeslots"},{step:3,zh:"3编写大纲",en:"3 Syllabus"},{step:4,zh:"4总览部署",en:"4 Deploy"}].map((w,A)=>{const P=s===w.step,E=s>w.step;return i.jsxs(m.Fragment,{children:[i.jsxs("div",{onClick:()=>!o&&a(w.step),className:`flex items-center gap-2 cursor-pointer transition-all ${P?"text-indigo-650 font-boldScale":E?"text-emerald-600 font-medium":"text-gray-400 hover:text-gray-600"}`,children:[i.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] border ${P?"bg-indigo-600 border-indigo-600 text-white shadow-xs font-bold":E?"bg-emerald-50 border-emerald-500 text-emerald-600 font-bold":"bg-white border-gray-250 text-gray-500"}`,children:E?"✓":w.step}),i.jsx("span",{className:"text-xs font-semibold hidden sm:inline",children:n==="zh"?w.zh:w.en})]}),A<3&&i.jsx("div",{className:`flex-1 h-0.5 max-w-[40px] md:max-w-none transition-all ${s>w.step?"bg-emerald-500":"bg-gray-200"}`})]},w.step)})}),i.jsxs("div",{className:"flex-grow overflow-y-auto p-5 md:p-6 space-y-5",children:[s===1&&i.jsxs("div",{className:"space-y-4 animate-in fade-in duration-200 text-left",children:[i.jsxs("div",{className:"bg-indigo-50/70 py-3.5 px-4.5 rounded-xl border border-indigo-100 text-xs text-indigo-750 font-sans leading-relaxed flex items-start gap-2",children:[i.jsx(An,{size:16,className:"text-indigo-500 shrink-0 mt-0.5 animate-bounce"}),i.jsxs("div",{children:[i.jsx("strong",{children:n==="zh"?"设计理念:":"Instructional ConceptTip:"}),i.jsx("p",{className:"mt-0.5",children:n==="zh"?"一个高品质的课程往往始于明确的选题背景。选择适当的学科科目分类,系统不仅会按您的选择在后续步骤推荐量身定做的教案摸板,还可以一键预装适合该学科的课堂互动时间轴模板。":"Selecting a clear title and specific subject category helps pre-populate customized Markdown content outlines and specialized scheduling presets."})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 font-sans",children:[i.jsxs("div",{className:"md:col-span-2 space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider mb-2",children:n==="zh"?"📍 课程/课件名称 *":"📍 Course Title *"}),i.jsx("input",{type:"text",required:!0,value:l,onChange:w=>c(w.target.value),placeholder:n==="zh"?"例:西方哲学:康德的三大批判、Python编程入门、高中物理电路并联原理":"e.g. Introduction to regressions, Western Philosophies, Lever Principles",className:"w-full px-4 py-3 border border-gray-250 rounded-xl focus:outline-none focus:ring-2 focus:ring-indigo-500 text-gray-800 text-sm shadow-xs"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider mb-2",children:n==="zh"?"🎯 课程设计简介与要点说明 (Objectives)":"🎯 Description & Lesson Objectives"}),i.jsx("textarea",{rows:4,value:d,onChange:w=>u(w.target.value),placeholder:n==="zh"?"在此处编写您的授课背景、面向学段及最关键的 2-3 个核心教学总目标。":"Write a short description stating learning outcomes and student prerequisite goals.",className:"w-full p-4 border border-gray-255 rounded-xl focus:outline-none focus:ring-2 focus:ring-indigo-500 text-gray-800 text-sm shadow-xs resize-none"})]})]}),i.jsxs("div",{className:"col-span-1 border-l border-gray-100 md:pl-6 space-y-4 text-left",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider mb-2",children:n==="zh"?"🎨 学部科目分类":"🎨 Subject Category"}),i.jsxs("select",{value:f,onChange:w=>{h(w.target.value)},className:"w-full bg-white border border-gray-250 text-gray-755 font-bold px-3 py-2.5 rounded-xl focus:outline-none focus:ring-2 focus:ring-indigo-500 shadow-xs text-sm cursor-pointer",children:[i.jsx("option",{value:"Mathematics",children:n==="zh"?"📐 基础数学与几何":"📐 Mathematics"}),i.jsx("option",{value:"ComputerScience",children:n==="zh"?"💻 计算机软件与人工智能":"💻 Computer Science"}),i.jsx("option",{value:"Literature",children:n==="zh"?"✍️ 语言文字与阅读理解":"✍️ Literature & Writing"}),i.jsx("option",{value:"Physics",children:n==="zh"?"⚡ 物理实验与自然探索":"⚡ Physics & Science"}),i.jsx("option",{value:"History",children:n==="zh"?"🏛️ 历史脉络与人地分析":"🏛️ History & Humanities"}),i.jsx("option",{value:"Art",children:n==="zh"?"🎨 交互设计与先锋创意艺术":"🎨 Visual Arts & Design"}),i.jsx("option",{value:"Other",children:n==="zh"?"🔮 交叉素养与综合学习":"🔮 General & Other"})]})]}),i.jsxs("div",{className:"bg-slate-50 p-4 rounded-xl border border-gray-100 space-y-2 select-none text-left",children:[i.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-wider block",children:n==="zh"?"科目时间轴专家建议":"SUBJECT HEURISTICS"}),i.jsxs("div",{className:"text-xs text-gray-600 leading-relaxed font-sans mt-1",children:[f==="Mathematics"&&(n==="zh"?"💡 数学:偏向理论推演。推荐 20分公式精讲 + 15分黑板实践互动,强化基础。":"💡 Math recommends: 20m Core Lecture + 15m Practice for theorem grounding."),f==="ComputerScience"&&(n==="zh"?"💡 计算机:偏重编码体验。推荐 15分白板代码推演 + 20分终端实验与分享。":"💡 CS recommends: 15m Algorithms + 20m Interactive workshops on virtual boards."),f==="Literature"&&(n==="zh"?"💡 语文文学:注重文本深度。推荐 10分范文研习 + 20分分组思辨,提升理解。":"💡 Lit recommends: 10m Reading Analysis + 20m Collaborative Discussions."),f==="Physics"&&(n==="zh"?"💡 科学类:逻辑导向。推荐 10分虚拟视频实验 + 20分机理讲解 + 10分钟随堂答卷。":"💡 Science recommends: 10m virtual showcase + 20m principles + 10m evaluation."),f==="History"&&(n==="zh"?"💡 历史人文:情景引入。推荐 15分人文画卷重塑 + 15分史实论驳辩论。":"💡 History recommends: 15m Context Mapping + 15m Interactive Debate panels."),f==="Art"&&(n==="zh"?"💡 视觉创意:自由度高。推荐 10分美术鉴赏 + 25分白板手绘画布互动体验。":"💡 Art recommends: 10m Aesthetics inspiration + 25m real-time board drawing."),f==="Other"&&(n==="zh"?"💡 其他科目:均分各小节时间,循序渐进,打造完整的教学循环闭环。":"💡 Generic: Divide evenly into sequential warm-up, core presentation and quiz.")]})]})]})]})]}),s===2&&i.jsxs("div",{className:"space-y-5 animate-in fade-in duration-200 text-left font-sans",children:[i.jsxs("div",{className:"bg-emerald-50/40 py-3.5 px-4.5 rounded-xl border border-emerald-100 text-xs text-emerald-850 leading-relaxed flex items-start gap-2 text-left",children:[i.jsx(Ls,{size:16,className:"text-emerald-555 shrink-0 mt-0.5 animate-pulse"}),i.jsxs("div",{children:[i.jsx("strong",{children:n==="zh"?"专家课堂时间轴预设:":"Dynamic Class Presets:"}),i.jsx("p",{className:"mt-0.5",children:n==="zh"?"好的教授节奏必须动静相宜。以下提供三种国际领先的精品课件时间节点设计,点击即可一键刷装配置。您也可以在下方自由增删和重新指定每个环节的长短!":"Curating temporal context maximizes classroom retention. Load from predefined templates or tweak the active steps on the dynamic table."})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider mb-2",children:n==="zh"?"💡 点击应用典型课堂框架模板 (Quick Apply)":"💡 Click to Auto-Apply Structure Presets"}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[{id:"preset_standard",title:n==="zh"?"经典 5-20-15-5 讲授模式":"Traditional Dual-Lecture Paradigm",desc:n==="zh"?"由浅入深:先通过场景导入,后精讲,接着在白板配合大屏进行演练。":"Perfect dynamic for most standard classes.",segments:[{id:"seg-preset-1",title:"Course Orientation / 课堂导入",type:"intro",duration:"5m",color:"bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100",notes:"Warm up topic"},{id:"seg-preset-2",title:"Subject Core Lecture / 核心理论精讲",type:"lecture",duration:"20m",color:"bg-indigo-50 text-indigo-700 border-indigo-200 hover:bg-indigo-100",notes:"Main content slide"},{id:"seg-preset-3",title:"Interactive Lab Work / 随堂协同演练",type:"practice",duration:"15m",color:"bg-green-50 text-green-700 border-green-200 hover:bg-green-100",notes:"Exercises & questions"},{id:"seg-preset-4",title:"Wrap up / 课堂成果总结与答疑",type:"summary",duration:"5m",color:"bg-purple-50 text-purple-700 border-purple-200 hover:bg-purple-100",notes:"Check answer notes"}]},{id:"preset_seminar",title:n==="zh"?"主题讨论工作坊模式":"Active Discussion Workshop",desc:n==="zh"?"协同探究:教师5分钟破冰,学生15分钟小组演练,15分钟对决汇报,10分钟定级。":"Discussion and presentation heavy layout.",segments:[{id:"seg-preset-5",title:"Debate Scenario Brief / 讨论情境简述",type:"intro",duration:"5m",color:"bg-amber-50 text-amber-700 border-amber-200 hover:bg-amber-100",notes:"Define debate metrics"},{id:"seg-preset-6",title:"Cooperative Ideation / 精英白板协作设计",type:"practice",duration:"15m",color:"bg-green-50 text-green-700 border-green-200 hover:bg-green-100",notes:"Joint workspace analysis"},{id:"seg-preset-7",title:"Student Team Presentation / 各小组交互汇报",type:"lecture",duration:"15m",color:"bg-indigo-50 text-indigo-700 border-indigo-200 hover:bg-indigo-100",notes:"Group screen sharing"},{id:"seg-preset-8",title:"Review & Grade Feedback / 教师深度对标点评",type:"summary",duration:"10m",color:"bg-purple-50 text-purple-700 border-purple-200 hover:bg-purple-100",notes:"Score reviews"}]},{id:"preset_flipped",title:n==="zh"?"翻转课堂高强度训练":"Targeted Problem-Solving Sprint",desc:n==="zh"?"应试/解惑突破:10分钟温习,15分钟重难盲点攻坚,15分钟专项题演习。":"Perfect for exams and targeted training courses.",segments:[{id:"seg-preset-9",title:"Blind Spot Evaluation / 温史自学效果自测",type:"intro",duration:"10m",color:"bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100",notes:"Scan quiz"},{id:"seg-preset-10",title:"Advanced Principle Explores / 重难考点极限拆解",type:"lecture",duration:"15m",color:"bg-rose-50 text-rose-700 border-rose-200 hover:bg-rose-100",notes:"Analyse weak metrics"},{id:"seg-preset-11",title:"Mock Solving Battle / 核心精选题实操对抗",type:"practice",duration:"15m",color:"bg-emerald-50 text-emerald-700 border-emerald-200 hover:bg-emerald-100",notes:"Sprint workout"},{id:"seg-preset-12",title:"Anchor Recap / 知识网架构网节点固化",type:"summary",duration:"5m",color:"bg-purple-50 text-purple-700 border-purple-200 hover:bg-purple-100",notes:"Highlight checklist"}]}].map(w=>i.jsxs("button",{type:"button",onClick:()=>{g(w.segments),b(n==="zh"?"预设已刷装":"Preset Configured",n==="zh"?`已将《${w.title}》应用到您当前设计的课程中。`:`Assigned "${w.title}" timeslots.`,"success")},className:"bg-white border rounded-xl p-3 text-left transition-all hover:bg-indigo-50/20 hover:border-indigo-400 cursor-pointer active:scale-98",children:[i.jsx("div",{className:"font-bold text-gray-800 text-xs sm:text-sm",children:w.title}),i.jsx("div",{className:"text-[10px] text-gray-400 mt-1.5 leading-relaxed",children:w.desc})]},w.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2 select-none",children:[i.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:n==="zh"?"📌 流程时间卡编辑 (拖拽或直接对表格字段赋值)":"📌 Custom Timeslot Table (Edit fields directly)"}),i.jsxs("button",{type:"button",onClick:()=>{const w={id:`seg-w-custom-${Date.now()}`,title:n==="zh"?`自理授课阶段 ${p.length+1}`:`Interactive Step ${p.length+1}`,type:"practice",duration:"10m",color:"bg-slate-50 text-slate-700 border-slate-200 hover:bg-slate-100",notes:""};g([...p,w])},className:"flex items-center gap-1 text-[11px] font-bold text-indigo-600 hover:text-indigo-800 cursor-pointer",children:[i.jsx(Qi,{size:12})," ",n==="zh"?"增设阶段":"Append Phase"]})]}),i.jsx("div",{className:"space-y-2 border border-gray-150 rounded-xl p-3.5 bg-gray-50/50",children:p.map((w,A)=>i.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-3 bg-white border border-gray-200 rounded-lg p-2.5 shadow-xs",children:[i.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:[i.jsx("span",{className:"w-5 h-5 rounded-full bg-slate-100 flex items-center justify-center text-[10px] text-gray-500 font-bold shrink-0",children:A+1}),i.jsx("input",{type:"text",value:w.title,onChange:P=>{const E=[...p];E[A].title=P.target.value,g(E)},className:"font-bold text-xs text-gray-800 bg-transparent border-b border-transparent hover:border-gray-200 focus:border-indigo-500 py-0.5 px-1 focus:outline-none focus:bg-gray-50/50 rounded flex-1 sm:w-56",placeholder:"Phase Title"})]}),i.jsxs("div",{className:"flex items-center gap-2.5 w-full sm:w-auto justify-end sm:ml-auto",children:[i.jsxs("div",{className:"flex items-center gap-1 bg-slate-50 border border-gray-200 rounded px-2 py-0.5 shrink-0",children:[i.jsx("span",{className:"text-[10px] font-bold text-gray-400",children:"时长:"}),i.jsx("input",{type:"text",value:w.duration,onChange:P=>{const E=[...p];E[A].duration=P.target.value,g(E)},className:"w-8 text-[11px] text-gray-800 font-extrabold bg-transparent text-center focus:outline-none"})]}),i.jsxs("select",{value:w.type,onChange:P=>{const E=P.target.value,T=[...p];T[A].type=E,E==="intro"?T[A].color="bg-blue-50 text-blue-700 border-blue-200 hover:bg-blue-100":E==="lecture"?T[A].color="bg-indigo-50 text-indigo-700 border-indigo-200 hover:bg-indigo-100":E==="practice"?T[A].color="bg-green-50 text-green-700 border-green-200 hover:bg-green-100":E==="summary"?T[A].color="bg-purple-50 text-purple-700 border-purple-200 hover:bg-purple-100":T[A].color="bg-gray-50 text-gray-700 border-gray-205 hover:bg-gray-100",g(T)},className:"bg-slate-50 border border-gray-200 text-[10px] font-bold text-gray-600 rounded p-1 focus:outline-none cursor-pointer",children:[i.jsx("option",{value:"intro",children:n==="zh"?"温习 / 导入":"Warm-up / Intro"}),i.jsx("option",{value:"lecture",children:n==="zh"?"主体 / 精讲":"Core Lecture"}),i.jsx("option",{value:"practice",children:n==="zh"?"交互白板练习":"Practice Workshop"}),i.jsx("option",{value:"summary",children:n==="zh"?"总结 / 定级":"Wrap-up / Recap"})]}),i.jsx("button",{type:"button",onClick:()=>{if(p.length<=1){alert(n==="zh"?"请保留至少一个核心环节!":"At least one segment must exist.");return}const P=p.filter((E,T)=>T!==A);g(P)},className:"text-gray-400 hover:text-rose-600 font-bold p-1 cursor-pointer text-sm select-none",title:"Delete this segment",children:"×"})]})]},w.id))}),i.jsxs("div",{className:"mt-2 text-[10px] text-right text-gray-500 font-mono select-none",children:[n==="zh"?"📈 环节累加公式:":"📈 Dynamic aggregation formula: ",i.jsx("span",{className:"text-gray-800 font-semibold",children:p.map(w=>w.duration).join(" + ")})]})]})]}),s===3&&i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 animate-in fade-in duration-200 font-sans text-left",children:[i.jsxs("div",{className:"space-y-3 flex flex-col h-full min-h-[360px] text-left",children:[i.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-2",children:[i.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider select-none shrink-0",children:n==="zh"?"✏️ 使用 Markdown 语法编写课时材料":"✏️ Lesson Materials (Markdown)"}),i.jsxs("button",{type:"button",onClick:()=>{const w=j(l,f);x(w),b(n==="zh"?"大纲模板生成成功":"Curriculum Loaded",n==="zh"?"针对所选择的模型和属性已一键刷装教案模板框架。":"Prepopulated Markdown structure.","success")},className:"flex items-center gap-1 text-xs bg-indigo-50 border border-indigo-100 text-indigo-755 hover:bg-indigo-100 px-3 py-1 rounded-lg transition-colors font-bold cursor-pointer",children:[i.jsx(An,{size:13,className:"text-indigo-500 animate-spin"}),n==="zh"?"✨ 一键生成专家级教学大纲模版":"✨ Autofill Outline Template"]})]}),i.jsx("textarea",{rows:14,value:v,onChange:w=>x(w.target.value),placeholder:n==="zh"?`# 西方哲学三大经典原理
19
19
 
20
- 在此输入您的具体内容讲解、白板图形绘制节点、以及课后实践任务大纲...`:"# Course curriculum content",className:"w-full flex-grow p-4 bg-slate-900 text-slate-100 border border-slate-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-indigo-500 font-mono text-xs shadow-inner leading-relaxed text-left"})]}),i.jsxs("div",{className:"space-y-3 flex flex-col h-full border border-gray-150 rounded-xl bg-slate-50/50 p-4 text-left",children:[i.jsxs("span",{className:"block text-xs font-bold text-gray-400 uppercase tracking-wider select-none shrink-0",children:["🖥️ ",n==="zh"?"大纲资料实时交互渲染":"Syllabus Live Context rendering"]}),i.jsx("div",{className:"flex-grow overflow-y-auto bg-white border border-gray-150 rounded-lg p-4 text-xs font-sans text-gray-700 max-h-[380px] overflow-x-hidden text-left select-text",children:v.trim()?i.jsx("div",{className:"markdown-body",children:i.jsx(jf,{children:v})}):i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-400 italic py-16",children:[i.jsx(Pn,{size:32,className:"mb-2 opacity-20 text-indigo-500"}),i.jsx("span",{children:n==="zh"?"教案空无内容,等待输入或一键填充模板...":"Waiting for materials..."})]})})]})]}),s===4&&i.jsxs("div",{className:"space-y-6 animate-in fade-in duration-200 text-center font-sans max-w-xl mx-auto py-3",children:[i.jsx("div",{className:"inline-flex p-3 bg-emerald-50 border border-emerald-100 text-emerald-500 rounded-full",children:i.jsx(Qr,{size:36,className:"animate-pulse text-emerald-555"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-extrabold text-gray-800 text-base md:text-lg",children:n==="zh"?"🚀 互动课程已精心筹备成功!":"🚀 Materials Generated successfully!"}),i.jsx("p",{className:"text-xs text-gray-400 mt-1",children:n==="zh"?"设计与时间轴逻辑全部检验合格。请在下方核验新课卡片,确认无误一键部署入 SQLite 内核数据库。":"Curriculum parameters are ready to boot inside the Secure Host."})]}),i.jsxs("div",{className:"border border-indigo-200 rounded-2xl p-5 bg-linear-to-b from-indigo-50/20 to-white shadow-md text-left space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-indigo-50 pb-3 gap-2",children:[i.jsx("div",{className:"font-bold text-indigo-950 text-base sm:text-lg truncate",children:l||(n==="zh"?"未指定课程主题":"Blank Topic")}),i.jsx("span",{className:"inline-flex px-2 py-0.5 rounded text-[10px] font-extrabold bg-indigo-50 text-indigo-800 uppercase tracking-wide border border-indigo-150 shrink-0",children:f})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4 text-xs",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-400 block tracking-wider text-[10px] font-bold",children:n==="zh"?"教研环节数":"TOTAL STEPS"}),i.jsxs("span",{className:"text-gray-800 font-extrabold text-sm block mt-1",children:[p.length," ",n==="zh"?"项教学环节":"slots"]})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-400 block tracking-wider text-[10px] font-bold",children:n==="zh"?"发布载体引擎":"STORAGE MEDIUM"}),i.jsxs("div",{className:"flex items-center gap-1 text-emerald-650 font-extrabold text-sm mt-1",children:[i.jsx(Ol,{size:11,className:"text-emerald-500"}),i.jsx("span",{children:"SQLite DB"})]})]})]}),i.jsx("div",{className:"bg-slate-50 border border-gray-150 p-3 rounded-lg text-[11px] text-gray-600 line-clamp-2 italic leading-relaxed text-left",children:d||(n==="zh"?"无科目描述内容":"No description written.")}),i.jsxs("div",{className:"space-y-1.5 select-none",children:[i.jsx("span",{className:"text-[10px] font-extrabold text-gray-400 uppercase tracking-wider block",children:n==="zh"?"教学时间轴环流预览":"TIMELINE PROGRESS OVERVIEW"}),i.jsx("div",{className:"flex items-center gap-1 w-full overflow-x-auto py-1",children:p.map((w,A)=>i.jsxs(m.Fragment,{children:[i.jsxs("div",{className:`px-2 py-1 text-[10px] font-bold rounded border truncate max-w-[120px] ${w.color.split(" ")[0]}`,children:[w.title.split(" / ")[0]," (",w.duration,")"]}),A<p.length-1&&i.jsx(ys,{size:11,className:"text-gray-300"})]},w.id))})]})]})]})]}),i.jsxs("div",{className:"p-4 border-t border-gray-105 bg-slate-50 flex justify-between items-center shrink-0",children:[i.jsx("span",{className:"text-[11px] font-bold font-mono text-gray-400 uppercase select-none",children:n==="zh"?"⚙️ SQLITE 写入预检通过":"⚙️ SQLITE VERIFICATION SUCCESS"}),i.jsxs("div",{className:"flex items-center gap-2",children:[s>1&&i.jsx("button",{type:"button",onClick:()=>a(w=>w-1),disabled:o,className:"px-4 py-2 text-xs font-semibold border border-gray-200 text-gray-700 bg-white hover:bg-gray-50 rounded-lg transition-colors cursor-pointer select-none",children:n==="zh"?"上一步":"Back"}),s<4?i.jsx("button",{type:"button",onClick:()=>{if(s===1&&!l.trim()){alert(n==="zh"?"请输入课程课题名称!":"Please type course title to proceed.");return}a(w=>w+1)},className:"px-4.5 py-2 text-xs font-bold bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg shadow-sm flex items-center gap-1 cursor-pointer select-none",children:n==="zh"?"继续前进":"Continue"}):i.jsx("button",{type:"button",onClick:N,disabled:o,className:"px-5 py-2 text-xs font-bold bg-emerald-600 hover:bg-emerald-700 text-white rounded-lg shadow-md flex items-center gap-1.5 cursor-pointer disabled:opacity-50 select-none animate-bounce",children:o?i.jsxs(i.Fragment,{children:[i.jsx(Sr,{size:13,className:"animate-spin"}),i.jsx("span",{children:n==="zh"?"写入底库中...":"Deploying..."})]}):i.jsxs(i.Fragment,{children:[i.jsx(Ol,{size:13}),i.jsx("span",{children:n==="zh"?"部署并激活新课程":"Deploy & Activate"})]})})]})]})]})})})}function lZ(e){const{isImportLessonsOpen:t,setIsImportLessonsOpen:r,lang:n,importStatus:s,setIsDraggingImport:a,handleCSVFileChange:o,downloadCsvTemplate:l,isDraggingImport:c,previewImportData:d,setPreviewImportData:u,setImportStatus:f,importProgress:h,importProgressTotal:p,importErrorMsg:g,setImportErrorMsg:v,handleCSVImportSubmit:x}=e;return i.jsx(i.Fragment,{children:t&&i.jsx("div",{className:"fixed inset-0 bg-gray-900/50 backdrop-blur-sm flex items-center justify-center p-4 md:p-6 z-50 overflow-y-auto text-gray-850",children:i.jsxs(Fi.div,{initial:{opacity:0,y:15,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98},className:"bg-white border text-gray-900 border-gray-250 rounded-2xl shadow-2xl w-full max-w-2xl flex flex-col overflow-hidden max-h-[90vh] font-sans text-left",children:[i.jsxs("div",{className:"p-4 md:p-5 border-b border-gray-100 flex items-center justify-between bg-slate-50 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-indigo-50 border border-indigo-100 rounded-lg text-indigo-650",children:i.jsx(Na,{size:20,className:"animate-pulse"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-bold text-gray-850 text-base md:text-lg",children:n==="zh"?"批量导入课程 (CSV)":"Bulk-Import Courses (CSV)"}),i.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:n==="zh"?"上传包含标准表头的 CSV 教案,一键实现秒级批量底库写入。":"Upload a standard CSV file matching our predefined schema to perform instantaneous bulk curriculum imports."})]})]}),i.jsx("button",{onClick:()=>{s!=="importing"&&r(!1)},disabled:s==="importing",className:"text-gray-400 hover:text-gray-650 font-bold p-1 rounded-lg hover:bg-gray-150 transition-all text-xl leading-none disabled:opacity-40",children:"×"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s==="idle"&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"p-4 bg-indigo-50/50 border border-indigo-100 rounded-xl",children:[i.jsxs("h4",{className:"text-xs font-bold text-indigo-850 uppercase tracking-wide flex items-center gap-1",children:[i.jsx("span",{children:"📌"}),n==="zh"?"预定义数据格式说明":"Predefined Schema Information"]}),i.jsx("p",{className:"text-xs text-indigo-900 mt-1 leading-relaxed",children:n==="zh"?"CSV 文件的首行必须 define 列标题(分大小写且无多余空格),包含以下两项必需内容:":"Your CSV file must include exactly these header columns on the first row (case-insensitive):"}),i.jsxs("ul",{className:"list-disc pl-5 mt-2 text-xs text-indigo-950 space-y-1",children:[i.jsxs("li",{children:[i.jsx("strong",{children:"title"}),": ",n==="zh"?'课程名 (非空,例如 "代数几何")':'Course title (Required, e.g. "Linear Algebra")']}),i.jsxs("li",{children:[i.jsx("strong",{children:"content"}),": ",n==="zh"?"教学大纲 / Markdown 格式的课堂细目":"Syllabus content supporting rich markdown."]})]}),i.jsx("div",{className:"mt-3.5 flex justify-start",children:i.jsxs("button",{onClick:l,className:"flex items-center gap-1 p-2 text-xs font-bold text-indigo-700 bg-white border border-indigo-200 rounded-lg shadow-3xs hover:bg-indigo-50 hover:-translate-y-0.5 hover:shadow-xs transition-all cursor-pointer",children:[i.jsx(Md,{size:12}),n==="zh"?"获取标准 CSV 模板":"Download Template CSV"]})})]}),i.jsxs("div",{onDragOver:b=>{b.preventDefault(),a(!0)},onDragLeave:()=>a(!1),onDrop:b=>{b.preventDefault(),a(!1),b.dataTransfer.files&&b.dataTransfer.files[0]&&o(b.dataTransfer.files[0])},onClick:()=>{document.getElementById("import-csv-file-picker")?.click()},className:`border-2 border-dashed rounded-2xl p-8 text-center cursor-pointer transition-all flex flex-col items-center justify-center min-h-[180px] ${c?"border-indigo-500 bg-indigo-50/70 scale-[1.01]":"border-gray-250 bg-gray-50/50 hover:bg-gray-50 hover:border-indigo-400"}`,children:[i.jsx("input",{id:"import-csv-file-picker",type:"file",accept:".csv",className:"hidden",onChange:b=>{b.target.files&&b.target.files[0]&&o(b.target.files[0])}}),i.jsx("div",{className:"p-3 bg-gray-100 border border-gray-200 rounded-full text-indigo-600 mb-3 group-hover:scale-105 transition-all",children:i.jsx(Na,{size:24})}),i.jsx("span",{className:"text-sm font-bold text-gray-800",children:n==="zh"?"选择 CSV 文件或拖放至此处":"Click to select or drag and drop CSV file here"}),i.jsx("span",{className:"text-xs text-gray-400 mt-1",children:n==="zh"?"支持标准 CSV 文件,最大不超过 5MB":"Supports standard CSV format up to 5MB"})]})]}),s==="parsing"&&d.length>0&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"text-xs font-bold text-emerald-600 bg-emerald-50 border border-emerald-200 px-2.5 py-1 rounded-full",children:["✓ ",n==="zh"?`解析成功:查找到 ${d.length} 门课程`:`Parsed Successfully: Found ${d.length} records`]}),i.jsx("button",{onClick:()=>{u([]),f("idle")},className:"text-xs text-indigo-600 hover:text-indigo-800 font-semibold",children:n==="zh"?"重新上传":"Upload Different File"})]}),i.jsx("div",{className:"border border-gray-200 rounded-xl overflow-hidden shadow-3xs max-h-[300px] overflow-y-auto",children:i.jsxs("table",{className:"w-full text-left text-xs border-collapse",children:[i.jsx("thead",{className:"bg-gray-50 text-gray-600 border-b border-gray-200 font-bold",children:i.jsxs("tr",{children:[i.jsx("th",{className:"p-3 w-1/4",children:n==="zh"?"课程名称":"Course Title"}),i.jsx("th",{className:"p-3 w-3/4",children:n==="zh"?"大纲简介片段":"Syllabus Preview"})]})}),i.jsx("tbody",{className:"divide-y divide-gray-100 bg-white",children:d.map((b,j)=>i.jsxs("tr",{className:"hover:bg-slate-50/50",children:[i.jsx("td",{className:"p-3 font-semibold text-gray-800 align-top truncate max-w-[150px]",title:b.title,children:b.title}),i.jsx("td",{className:"p-3 text-gray-500 font-mono text-[11px] leading-relaxed break-words col-span-2",children:b.content.length>150?b.content.substring(0,150)+"...":b.content||i.jsx("em",{className:"text-gray-300 italic",children:"None"})})]},j))})]})}),i.jsxs("div",{className:"bg-amber-50 border border-amber-100 text-amber-900 text-xs rounded-xl p-3 flex gap-2.5 items-start",children:[i.jsx("span",{className:"text-base leading-none",children:"⚠️"}),i.jsx("p",{className:"leading-relaxed",children:n==="zh"?'请确认课程名称没有与系统已有的课程同名。确认无误后点击下方"开始导入"写入 SQLite。':"Please ensure column details are accurate. Clicking Import will instantly commit all parsed courses into the server SQLite backend."})]})]}),s==="importing"&&i.jsxs("div",{className:"py-8 flex flex-col items-center justify-center space-y-4",children:[i.jsxs("div",{className:"relative w-20 h-20 flex items-center justify-center",children:[i.jsx(Sr,{size:36,className:"text-indigo-600 animate-spin"}),i.jsxs("span",{className:"absolute text-[11px] font-extrabold text-indigo-700",children:[Math.round(h/p*100),"%"]})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("h3",{className:"font-bold text-gray-800 text-sm",children:n==="zh"?"正在写入数据库":"Populating Database Records"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n==="zh"?`正在导入第 ${h} / ${p} 项...`:`Importing item ${h} of ${p}...`})]}),i.jsx("div",{className:"w-full max-w-sm bg-gray-100 h-2 rounded-full overflow-hidden border border-gray-200",children:i.jsx("div",{className:"bg-indigo-600 h-full transition-all duration-300 rounded-full",style:{width:`${h/p*100}%`}})}),i.jsxs("div",{className:"w-full max-w-md bg-gray-50 rounded-xl p-3 border border-gray-150 font-mono text-[10px] text-gray-400 max-h-[140px] overflow-y-auto",children:[i.jsx("div",{children:"[API] POST /api/lessons -> Request batch transaction..."}),d.slice(0,h).map((b,j)=>i.jsx("div",{className:"text-indigo-600 font-bold mt-1",children:`✓ [${j+1}] "${b.title}" -> status 200 (Success)`},j))]})]}),s==="success"&&i.jsxs("div",{className:"py-8 text-center flex flex-col items-center justify-center space-y-4",children:[i.jsx("div",{className:"w-16 h-16 bg-emerald-50 rounded-full flex items-center justify-center border border-emerald-200 text-emerald-600 animate-bounce",children:i.jsx(Qr,{size:32})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-bold text-gray-800 text-base",children:n==="zh"?"🎉 批量导入大功告成":"🎉 Bulk-Import Complete"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1 max-w-md mx-auto",children:n==="zh"?`所有 ${d.length} 门学科教案数据已顺畅写入系统底层 SQLite 数据仓库,现在已可以用于备课。`:`All ${d.length} curriculum lessons records have been successfully saved into security logs and SQLite storage.`})]})]}),s==="error"&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"p-4 bg-rose-50 border border-rose-100 rounded-xl flex gap-3 items-start",children:[i.jsx("span",{className:"text-rose-600 font-bold text-lg leading-none",children:"⚠️"}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-xs font-bold text-rose-850",children:n==="zh"?"数据导入或解析中断":"Import or Parsing Error"}),i.jsx("p",{className:"text-xs text-rose-900 mt-1 leading-relaxed",children:g||(n==="zh"?"未知异常或文件破损。":"An unknown exception or corrupted CSV formatting occurred.")})]})]}),i.jsxs("div",{className:"flex gap-3 justify-end",children:[i.jsx("button",{onClick:()=>{f("idle"),v("")},className:"px-4 py-2 text-xs font-bold text-gray-700 bg-white border border-gray-250 cursor-pointer hover:bg-gray-50 rounded-lg transition-all",children:n==="zh"?"返回重试":"Go Back & Retry"}),i.jsx("button",{onClick:()=>r(!1),className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 cursor-pointer hover:bg-indigo-700 rounded-lg transition-all",children:n==="zh"?"关闭窗口":"Close"})]})]})]}),s!=="idle"&&s!=="error"&&i.jsxs("div",{className:"p-4 md:p-5 border-t border-gray-100 flex items-center justify-between bg-slate-50 shrink-0",children:[i.jsx("button",{onClick:()=>{u([]),f("idle")},disabled:s==="importing",className:"px-4 py-2 text-xs font-bold text-gray-650 bg-white border border-gray-200 hover:bg-gray-100 rounded-lg transition-all disabled:opacity-40 cursor-pointer",children:n==="zh"?"重置重选":"Reset & Clear"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>r(!1),disabled:s==="importing",className:"px-4 py-2 text-xs font-bold text-gray-600 hover:text-gray-800 transition-all disabled:opacity-40 cursor-pointer",children:n==="zh"?"取消":"Cancel"}),s==="parsing"&&i.jsxs("button",{onClick:x,className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg shadow-sm transition-all flex items-center gap-1 cursor-pointer",children:[i.jsx(Bs,{size:12}),n==="zh"?`开始导入 (${d.length} 类)`:`Proceed and Import (${d.length})`]}),s==="success"&&i.jsx("button",{onClick:()=>r(!1),className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg shadow-sm transition-all cursor-pointer",children:n==="zh"?"完成":"Done"})]})]})]})})})}function cZ(e){const{isQuizGeneratorOpen:t,setIsQuizGeneratorOpen:r,lessons:n,quizGenMode:s,setQuizGenMode:a,quizGenSelectedLessonId:o,setQuizGenSelectedLessonId:l,quizGenTopic:c,setQuizGenTopic:d,isGeneratingSuggestions:u,setIsGeneratingSuggestions:f,suggestedObjectives:h,setSuggestedObjectives:p,suggestedQuestions:g,setSuggestedQuestions:v,quizGenTimeLimit:x,setQuizGenTimeLimit:b,savingQuiz:j,setSavingQuiz:N,quizGeneratorClassId:w,fetchClassDashboard:A}=e;return i.jsx(i.Fragment,{children:t&&i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50 overflow-y-auto text-gray-850",children:i.jsxs(Fi.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-3xl flex flex-col overflow-hidden max-h-[90vh]",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ea,{className:"text-indigo-600 animate-pulse",size:20}),i.jsx("h2",{className:"font-bold text-gray-800 text-lg",children:"AI-Objective Quiz Generator"})]}),i.jsx("button",{onClick:()=>r(!1),className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors",children:"×"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[g.length===0&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"bg-indigo-50/80 p-4 rounded-xl border border-indigo-100 text-xs text-indigo-800 leading-relaxed font-sans",children:"Choose a lesson to scan. Our advanced AI model will run a deep semantic scan across the entire lesson curriculum content, discover your core learning objectives, and construct interactive multiple-choice questions aligning precisely with each of them."}),i.jsxs("div",{className:"font-sans",children:[i.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Scan Core Selection Mode"}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("button",{onClick:()=>a("scan_lesson"),className:`p-3 rounded-lg border text-left flex flex-col transition-all ${s==="scan_lesson"?"border-indigo-600 bg-indigo-50/40 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,children:[i.jsx("span",{className:"font-semibold text-sm text-indigo-900",children:"Curriculum Lesson Scanning"}),i.jsx("span",{className:"text-[10px] text-gray-500 mt-1",children:"Examines real Markdown content inside virtual lesson modules."})]}),i.jsxs("button",{onClick:()=>a("topic"),className:`p-3 rounded-lg border text-left flex flex-col transition-all ${s==="topic"?"border-indigo-600 bg-indigo-50/40 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,children:[i.jsx("span",{className:"font-semibold text-sm text-indigo-900",children:"Custom Keyword / Topic"}),i.jsx("span",{className:"text-[10px] text-gray-500 mt-1",children:"Provide a custom prompt keyword or objective manually."})]})]})]}),s==="scan_lesson"?i.jsxs("div",{className:"font-sans",children:[i.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Select Lesson to Scan"}),n.length===0?i.jsx("div",{className:"text-gray-500 text-xs py-3 border rounded border-dashed text-center",children:"No lessons available. Please create a lesson first."}):i.jsxs("select",{value:o,onChange:P=>l(P.target.value),className:"w-full p-2.5 bg-white border border-gray-200 rounded-lg text-sm text-gray-800 focus:border-indigo-500 focus:outline-none shadow-sm",children:[i.jsx("option",{value:"",children:"-- Choose a lesson --"}),n.map(P=>i.jsx("option",{value:P.id,children:P.title},P.id))]})]}):i.jsxs("div",{className:"font-sans",children:[i.jsx("label",{className:"block text-xs font-semibold text-gray-505 uppercase tracking-wider mb-2",children:"Custom Topic Prompt"}),i.jsx("input",{type:"text",placeholder:"e.g. Introduction to React state, Cloud SQL setup...",value:c,onChange:P=>d(P.target.value),className:"w-full p-2.5 bg-white border border-gray-200 rounded-lg text-sm focus:border-indigo-500 focus:outline-none shadow-sm text-gray-800"})]}),i.jsx("div",{className:"pt-4 flex justify-end font-sans",children:i.jsx("button",{disabled:u||s==="scan_lesson"&&!o||s==="topic"&&!c.trim(),onClick:async()=>{f(!0);try{if(s==="scan_lesson"){const P=await fetch(`/api/classes/${w}/assignments/suggest`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:o})});if(P.ok){const E=await P.json();p(E.learningObjectives||[]),v((E.questions||[]).map(T=>({...T,selected:!0})))}else alert("Error generating suggestions. Please make sure the selected lesson has content.")}else(await fetch(`/api/classes/${w}/assignments/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:c})})).ok?(await A(w),r(!1)):alert("Error generating topic quiz.")}catch(P){console.error(P),alert(P.message)}finally{f(!1)}},className:"px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 text-white rounded-lg font-medium text-xs shadow transition flex items-center gap-2",children:u?i.jsxs(i.Fragment,{children:[i.jsx(Sr,{size:16,className:"animate-spin"}),i.jsx("span",{children:"AI Scanning Content..."})]}):i.jsxs(i.Fragment,{children:[i.jsx(ea,{size:16}),i.jsx("span",{children:"Generate Key MCQ Quiz"})]})})})]}),g.length>0&&i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"font-sans",children:[i.jsx("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-2",children:"Identified Core Objectives"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:h.map((P,E)=>i.jsxs("span",{className:"px-2.5 py-1 bg-teal-50 text-teal-800 border border-teal-200 rounded-full text-xs font-semibold",children:["🎯 ",P]},E))})]}),i.jsxs("div",{className:"space-y-4 font-sans",children:[i.jsx("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider font-semibold",children:"Suggested MCQ Questions"}),i.jsx("div",{className:"space-y-3",children:g.map((P,E)=>i.jsxs("div",{className:"p-4 rounded-xl border border-gray-150 bg-gray-50/50 hover:bg-gray-50 transition space-y-3 text-gray-800 text-gray-850",children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-5 h-5 rounded-full bg-indigo-150 text-indigo-700 flex items-center justify-center text-xs font-bold shrink-0",children:E+1}),i.jsxs("span",{className:"text-[10px] font-semibold text-teal-700 bg-teal-50 px-2.5 py-0.5 rounded border border-teal-100",children:["objective: ",P.objective]})]}),i.jsx("input",{type:"checkbox",checked:!!P.selected,onChange:T=>{const C=[...g];C[E].selected=T.target.checked,v(C)},className:"w-4 h-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500"})]}),i.jsx("p",{className:"font-semibold text-gray-800 text-sm leading-relaxed",children:P.question}),i.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs",children:P.options.map((T,C)=>{const I=T===P.correctAnswer;return i.jsxs("div",{className:`p-2 rounded border flex items-center justify-between ${I?"bg-green-50 border-green-200 text-green-955 font-semibold":"bg-white border-gray-100 text-gray-700"}`,children:[i.jsx("span",{children:T}),I&&i.jsx(Qr,{size:12,className:"text-green-600 shrink-0"})]},C)})})]},E))})]}),i.jsxs("div",{className:"pt-4 border-t border-gray-100 flex justify-between items-center font-sans",children:[i.jsx("button",{onClick:()=>{p([]),v([])},className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg text-xs font-semibold transition",children:"Back / Scan New"}),i.jsxs("div",{className:"flex items-center gap-2 border border-indigo-150 bg-indigo-50/50 px-3 py-1.5 rounded-lg text-xs font-semibold text-indigo-900",children:[i.jsx("span",{children:"⏱️ Quiz Time Limit:"}),i.jsxs("select",{value:x,onChange:P=>b(Number(P.target.value)),className:"bg-transparent text-xs text-indigo-950 font-bold focus:outline-none cursor-pointer",children:[i.jsx("option",{className:"text-gray-800",value:0,children:"No Limit"}),i.jsx("option",{className:"text-gray-800",value:1,children:"1 Min"}),i.jsx("option",{className:"text-gray-800",value:2,children:"2 Mins"}),i.jsx("option",{className:"text-gray-800",value:5,children:"5 Mins"}),i.jsx("option",{className:"text-gray-800",value:10,children:"10 Mins"}),i.jsx("option",{className:"text-gray-800",value:15,children:"15 Mins"}),i.jsx("option",{className:"text-gray-800",value:20,children:"20 Mins"}),i.jsx("option",{className:"text-gray-800",value:30,children:"30 Mins"}),i.jsx("option",{className:"text-gray-800",value:45,children:"45 Mins"}),i.jsx("option",{className:"text-gray-800",value:60,children:"60 Mins"})]})]}),i.jsxs("button",{disabled:j||g.filter(P=>P.selected).length===0,onClick:async()=>{N(!0);try{const P=n.find(C=>C.id===o),E=P?P.title:c||"Custom Objective";(await fetch(`/api/classes/${w}/assignments/create-suggested-quiz`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:`MCQ Evaluation: ${E}`,description:"Automatic evaluation based on core learning objectives.",questions:g.filter(C=>C.selected).map(({selected:C,...I})=>I),learningObjectives:h,timeLimit:x})})).ok?(await A(w),r(!1)):alert("Failed to save suggested quiz.")}catch(P){console.error(P),alert(P.message)}finally{N(!1)}},className:"px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-medium text-xs shadow hover:shadow-md transition flex items-center gap-2",children:[j?i.jsx(Sr,{size:16,className:"animate-spin"}):i.jsx(Qr,{size:16}),i.jsx("span",{children:"Create Assessment Quiz"})]})]})]})]})]})})})}const dZ=m.lazy(()=>_h(()=>import("./whiteboard-BpCj1CQU.js").then(e=>e.bb),__vite__mapDeps([0])).then(e=>({default:e.InteractiveWhiteboard}))),V0=m.forwardRef((e,t)=>i.jsx(m.Suspense,{fallback:i.jsx("div",{className:"flex items-center justify-center h-full bg-gray-50",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-500"})}),children:i.jsx(dZ,{ref:t,...e})})),uZ=m.lazy(()=>_h(()=>import("./courseware-BfnpYR-P.js").then(e=>e.i),__vite__mapDeps([0])).then(e=>({default:e.CoursewareViewer})));function EA(e){return i.jsx(m.Suspense,{fallback:i.jsx("div",{className:"flex items-center justify-center h-full bg-gray-50",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-500"})}),children:i.jsx(uZ,{...e})})}function fZ(e){const{isLessonPreviewVisible:t,setIsLessonPreviewVisible:r,lessons:n,selectedLesson:s,previewFullscreenPanel:a,setPreviewFullscreenPanel:o,previewLessonTab:l,setPreviewLessonTab:c,activeRole:d,elements:u,activeSegmentId:f,setActiveSegmentId:h,fetchElements:p,currentVfsParent:g,setCurrentVfsParent:v,vfsNodes:x,previewSelectedCourseware:b,setPreviewSelectedCourseware:j}=e;return i.jsx(i.Fragment,{children:t&&i.jsx("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm flex items-center justify-center p-4 md:p-6 z-[60] overflow-hidden text-gray-850",children:i.jsxs(Fi.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-7xl h-[90vh] flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-indigo-50/70 shrink-0 select-none",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"bg-indigo-600 text-white p-2 rounded-lg shadow-sm",children:i.jsx(dp,{size:18})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-bold text-gray-900 text-base flex items-center gap-2",children:"学生视角预览 (Student Perspective Preview)"}),i.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["正在预览课程: ",i.jsx("span",{className:"font-semibold text-gray-700",children:n.find(N=>N.id===s)?.title})," • 演示同步与交互"]})]})]}),i.jsxs("button",{onClick:()=>r(!1),className:"px-3.5 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-600 hover:text-gray-800 text-xs font-semibold rounded-lg shadow-sm transition-all cursor-pointer flex items-center gap-1 border border-gray-200",children:[i.jsx(Lr,{size:14})," 退出预览"]})]}),i.jsxs("div",{className:"flex-1 flex min-h-0 bg-slate-50/50 p-4 gap-4",children:[i.jsxs("div",{className:`${a==="left"?"w-full":"w-1/3"} bg-white border border-gray-200 rounded-xl p-4 flex flex-col min-h-0 shadow-sm ${a==="right"?"hidden":""} transition-all duration-300`,children:[i.jsxs("div",{className:"text-xs font-bold uppercase tracking-wider text-gray-400 mb-3 border-b border-gray-100 pb-2 flex items-center justify-between shrink-0 select-none",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Pn,{size:14,className:"text-indigo-500"})," Lesson Content (课程内容)"]}),i.jsx("button",{onClick:()=>o(N=>N==="left"?"none":"left"),className:"p-1 hover:bg-gray-100 text-gray-400 hover:text-gray-700 rounded transition-colors cursor-pointer flex items-center gap-1",title:a==="left"?"退出全屏":"全屏",children:a==="left"?i.jsxs(i.Fragment,{children:[i.jsx(uv,{size:13}),i.jsx("span",{className:"text-[10px] font-medium",children:"退出全屏"})]}):i.jsxs(i.Fragment,{children:[i.jsx(fv,{size:13}),i.jsx("span",{className:"text-[10px] font-medium",children:"全屏"})]})})]}),i.jsx("div",{className:"flex-1 overflow-y-auto prose prose-sm prose-indigo max-w-none text-gray-700 pr-1",children:i.jsx(jf,{children:n.find(N=>N.id===s)?.content||""})})]}),i.jsxs("div",{className:`${a==="right"?"w-full flex-grow":"flex-1"} bg-white border border-gray-200 rounded-xl p-4 flex flex-col min-h-0 shadow-sm ${a==="left"?"hidden":""} transition-all duration-300`,children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-3 mb-3 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("button",{onClick:()=>c("whiteboard"),className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all cursor-pointer ${l==="whiteboard"?"bg-indigo-600 text-white shadow-sm":"text-gray-500 hover:bg-gray-100"}`,children:"Interactive Whiteboard"}),i.jsx("button",{onClick:()=>c("courseware"),className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all cursor-pointer ${l==="courseware"?"bg-indigo-600 text-white shadow-sm":"text-gray-500 hover:bg-gray-100"}`,children:"Cloud Apps Viewer"})]}),i.jsx("button",{onClick:()=>o(N=>N==="right"?"none":"right"),className:"p-1 hover:bg-gray-100 text-gray-400 hover:text-gray-700 rounded transition-colors cursor-pointer flex items-center gap-1",title:a==="right"?"退出全屏":"全屏",children:a==="right"?i.jsxs(i.Fragment,{children:[i.jsx(uv,{size:13}),i.jsx("span",{className:"text-[10px] font-medium",children:"退出全屏"})]}):i.jsxs(i.Fragment,{children:[i.jsx(fv,{size:13}),i.jsx("span",{className:"text-[10px] font-medium",children:"全屏"})]})})]}),i.jsx("div",{className:"flex-grow flex-1 min-h-0 flex flex-col h-full relative",children:l==="whiteboard"?i.jsx("div",{className:"flex-grow flex-1 min-h-0 w-full h-full relative rounded-lg overflow-hidden border border-gray-100 flex flex-col",children:i.jsx(V0,{lessonId:s,userRole:d,elements:u,activeSegmentId:f,onSegmentSync:N=>h(N),onElementAdd:async(N,w)=>{await fetch(`/api/lessons/${s}/whiteboard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:N,data:w})}),p(s)},onElementUpdate:async(N,w)=>{await fetch(`/api/lessons/${s}/whiteboard/${N}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:w})}),p(s)},onElementDelete:async N=>{await fetch(`/api/lessons/${s}/whiteboard/${N}`,{method:"DELETE"}),p(s)},onClearBoard:async()=>{await fetch(`/api/lessons/${s}/whiteboard`,{method:"DELETE"}),p(s)},onRefresh:()=>p(s)})}):i.jsxs("div",{className:"flex-grow flex-1 flex gap-4 min-h-0 w-full h-full",children:[i.jsxs("div",{className:"w-52 flex-shrink-0 bg-gray-50 border border-gray-250/70 rounded-xl p-3 flex flex-col min-h-0 h-full animate-none",children:[i.jsx("h4",{className:"text-xs font-bold uppercase tracking-wider text-gray-550 mb-2 border-b border-gray-200 pb-2",children:"Cloud Apps"}),i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1",children:[g!==null&&i.jsxs("button",{onClick:()=>v(null),className:"flex items-center gap-1 p-1.5 text-xs text-indigo-600 w-full hover:bg-gray-255 hover:bg-gray-200 rounded-lg mb-1 font-semibold",children:[i.jsx(ys,{className:"rotate-180",size:14})," Back to Root"]}),x.filter(N=>N.type==="dir").map(N=>i.jsxs("button",{onClick:()=>v(N.id),className:"w-full text-left p-1.5 rounded-lg text-xs text-gray-700 hover:bg-gray-250 hover:bg-gray-200 flex items-center gap-2 group truncate cursor-pointer font-medium",title:N.name,children:[i.jsx(Dl,{size:14,className:"text-indigo-400 shrink-0 group-hover:text-indigo-600"}),i.jsx("span",{className:"truncate",children:N.name})]},N.id)),x.filter(N=>N.type==="file"&&(N.name.endsWith(".html")||N.name.endsWith(".htm")||N.content?.includes("<html"))).length===0?i.jsx("div",{className:"text-xs text-center text-gray-400 italic py-4",children:"No interactive HTML apps found."}):x.filter(N=>N.type==="file"&&(N.name.endsWith(".html")||N.name.endsWith(".htm")||N.content?.includes("<html"))).map(N=>i.jsxs("button",{onClick:()=>j(N.id),className:`w-full text-left p-2 rounded-lg text-xs flex items-center gap-2 truncate transition-colors cursor-pointer font-medium ${b===N.id?"bg-indigo-100 text-indigo-700 font-semibold shadow-xs":"text-gray-600 hover:bg-gray-100"}`,title:N.name,children:[i.jsx(Wo,{size:14,className:"shrink-0 text-indigo-500"}),i.jsx("span",{className:"truncate",children:N.name})]},N.id))]}),i.jsx("div",{className:"mt-2 text-[10px] text-gray-400 leading-tight",children:"Note: Showing HTML courseware from current OS drive directory."})]}),i.jsx("div",{className:"flex-1 relative bg-white border border-gray-100 rounded-xl overflow-hidden min-h-0 h-full shadow-inner flex flex-col",children:i.jsx(EA,{coursewareId:b,onClose:()=>j(null)})})]})})]})]})]})})})}function x8({vfsNodes:e,currentVfsParent:t,setCurrentVfsParent:r,cloudDrivePreviewNode:n,setCloudDrivePreviewNode:s}){return i.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[i.jsxs("div",{className:"w-64 border-r border-gray-100 flex flex-col bg-gray-50 shrink-0",children:[i.jsx("div",{className:"p-3 border-b border-gray-200 flex items-center gap-2",children:i.jsxs("button",{onClick:()=>{r(null),s(null)},className:`text-sm font-medium w-full text-left flex items-center gap-2 p-2 rounded cursor-pointer ${t===null?"bg-indigo-100 text-indigo-800 font-bold":"text-gray-600 hover:bg-gray-200"}`,children:[i.jsx(Dl,{size:16})," Data Root"]})}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[t&&i.jsxs("button",{onClick:()=>r(null),className:"flex items-center gap-2 p-2 text-xs text-indigo-600 w-full hover:bg-gray-200 rounded mb-2 font-medium cursor-pointer",children:[i.jsx(ys,{className:"rotate-180",size:14})," Back to Root"]}),i.jsx("div",{className:"text-xs uppercase font-semibold text-gray-400 px-2 py-1 mb-1",children:"Current Path Nodes"}),e.filter(a=>a.type==="dir").map(a=>i.jsxs("button",{onClick:()=>{r(a.id),s(null)},className:"w-full text-left p-2 rounded text-sm text-gray-700 hover:bg-gray-200 flex items-center gap-2 group mb-1 cursor-pointer",children:[i.jsx(Dl,{size:14,className:"text-indigo-400 group-hover:text-indigo-600"}),i.jsx("span",{className:"truncate",children:a.name})]},a.id))]})]}),i.jsx("div",{className:"flex-1 flex flex-col bg-white overflow-hidden min-w-0",children:n?i.jsxs("div",{className:"flex-1 flex flex-col h-full min-h-0",children:[i.jsxs("div",{className:"p-3 border-b border-gray-100 bg-gray-50 flex items-center gap-2 shrink-0",children:[i.jsx("button",{onClick:()=>s(null),className:"text-gray-500 hover:text-gray-700 cursor-pointer",children:i.jsx(Lr,{size:16})}),i.jsxs("span",{className:"text-sm font-medium text-gray-700",children:["Previewing: ",n.name]})]}),n.name.endsWith(".html")||n.name.endsWith(".htm")||n.content?.includes("<html")?i.jsx("div",{className:"flex-1 relative bg-gray-50",children:i.jsx(EA,{coursewareId:n.id})}):i.jsx("div",{className:"flex-1 overflow-y-auto p-6 bg-white prose prose-sm max-w-none",children:i.jsx(jf,{children:n.content})})]}):i.jsx("div",{className:"flex-1 p-6 overflow-y-auto",children:i.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[e.length===0&&i.jsx("div",{className:"col-span-full h-32 flex items-center justify-center text-sm text-gray-400 italic",children:"This directory is empty."}),e.map(a=>i.jsxs("div",{onClick:()=>{a.type==="dir"?r(a.id):s({id:a.id,name:a.name,content:a.content||"*(Empty file)*"})},className:"border border-gray-200 hover:border-indigo-300 hover:shadow-md cursor-pointer rounded-xl p-4 flex flex-col gap-3 transition-all bg-white",children:[i.jsx("div",{className:"p-3 rounded-xl w-12 h-12 flex items-center justify-center shrink-0 shadow-sm bg-gray-50 border border-gray-100",children:a.type==="dir"?i.jsx(Dl,{size:24,className:"text-indigo-500"}):i.jsx(cj,{size:24,className:"text-gray-500"})}),i.jsx("div",{className:"text-sm font-medium text-gray-800 break-words",children:a.name})]},a.id))]})})})]})}function hZ(e){return e.isOpen?i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:i.jsxs("div",{className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-5xl h-[85vh] flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Dl,{size:20,className:"text-indigo-600"}),i.jsx("h2",{className:"font-semibold text-gray-800 text-lg",children:"Cloud Course Resource Browser"})]}),i.jsx("button",{onClick:e.onClose,className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors cursor-pointer",children:"×"})]}),i.jsx(x8,{...e})]})}):null}function pZ(e){const{isSystemResourceLibraryOpen:t,setIsSystemResourceLibraryOpen:r,lang:n,systemResourceTab:s,setSystemResourceTab:a,selectedLibraryResourceId:o,setSelectedLibraryResourceId:l,vfsNodes:c,currentVfsParent:d,setCurrentVfsParent:u,cloudDrivePreviewNode:f,setCloudDrivePreviewNode:h,loadingLibraryResources:p,libraryResources:g,fetchLibraryResources:v}=e;return i.jsx(i.Fragment,{children:t&&i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:i.jsxs("div",{className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-6xl h-[85vh] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-150",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0 flex-wrap gap-2",children:[i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[i.jsx(Wo,{size:20,className:"text-emerald-500 animate-pulse"}),i.jsx("h2",{className:"font-semibold text-gray-800 text-lg",children:n==="zh"?"系统资源库与应用商城":"System Resource Library"}),i.jsxs("div",{className:"flex items-center gap-1 bg-slate-200/80 p-0.5 rounded-xl border border-slate-300/60 shadow-3xs ml-2",children:[i.jsxs("button",{onClick:()=>a("system"),className:`px-3 py-1 text-xs font-bold rounded-lg transition-all flex items-center gap-1.5 cursor-pointer ${s==="system"?"bg-white text-emerald-800 shadow-2xs font-extrabold":"text-slate-600 hover:text-slate-900"}`,children:[i.jsx(Wo,{size:13,className:"text-emerald-500"}),i.jsx("span",{children:n==="zh"?"互动课件与系统资源":"System Resources"})]}),i.jsxs("button",{onClick:()=>a("cloud"),className:`px-3 py-1 text-xs font-bold rounded-lg transition-all flex items-center gap-1.5 cursor-pointer ${s==="cloud"?"bg-white text-indigo-800 shadow-2xs font-extrabold":"text-slate-600 hover:text-slate-900"}`,children:[i.jsx(Dl,{size:13,className:"text-indigo-500"}),i.jsx("span",{children:n==="zh"?"云端课程资源 (Cloud Drive)":"Cloud Course Resource"})]})]})]}),i.jsx("button",{onClick:()=>{r(!1),l(null)},className:"text-gray-400 hover:text-gray-600 font-bold p-1 overflow-hidden hover:bg-gray-200 rounded transition-colors text-lg inline-flex items-center justify-center w-8 h-8 cursor-pointer",children:"×"})]}),s==="cloud"?i.jsx(x8,{vfsNodes:c,currentVfsParent:d,setCurrentVfsParent:u,cloudDrivePreviewNode:f,setCloudDrivePreviewNode:h}):i.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[i.jsxs("div",{className:"w-80 border-r border-gray-100 bg-slate-50 flex flex-col shrink-0",children:[i.jsxs("div",{className:"p-4 border-b border-gray-200 bg-white space-y-2",children:[i.jsx("span",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1",children:n==="zh"?"上传新资源":"Upload New Resource"}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("label",{className:"flex flex-col items-center justify-center p-3 bg-slate-50 hover:bg-indigo-50 border border-dashed border-gray-300 hover:border-indigo-400 rounded-xl cursor-pointer text-center transition-all group",children:[i.jsx("span",{className:"text-lg mb-1 group-hover:scale-110 transition-transform",children:"📄"}),i.jsx("span",{className:"font-bold text-indigo-600 text-[10px] break-all leading-tight",children:n==="zh"?"单HTML文件":"Single HTML"}),i.jsx("input",{type:"file",accept:".html,.htm",className:"hidden",onChange:async x=>{const b=x.target.files?.[0];if(!b)return;const j=new FileReader;j.onload=async N=>{const w=N.target?.result;try{(await fetch("/api/resources",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name,type:"html",content:w})})).ok&&v()}catch(A){console.error("Library upload failed:",A)}},j.readAsText(b)}})]}),i.jsxs("label",{className:"flex flex-col items-center justify-center p-3 bg-slate-50 hover:bg-teal-50 border border-dashed border-gray-300 hover:border-teal-400 rounded-xl cursor-pointer text-center transition-all group",children:[i.jsx("span",{className:"text-lg mb-1 group-hover:scale-110 transition-transform",children:"📁"}),i.jsx("span",{className:"font-bold text-teal-600 text-[10px] break-all leading-tight",children:n==="zh"?"完整文件夹":"Directory Folder"}),i.jsx("input",{type:"file",webkitdirectory:"",directory:"",multiple:!0,className:"hidden",onChange:async x=>{const b=x.target.files;if(!b||b.length===0)return;const j=[];let N="";for(let w=0;w<b.length;w++){const A=b[w],P=A.webkitRelativePath||A.name;N||(N=P.split("/")[0]||"library_resource");const E=A.name.split(".").pop()?.toLowerCase(),T=["png","jpg","jpeg","gif","webp","ico"].includes(E||"");await new Promise(C=>{const I=new FileReader;I.onload=_=>{const L=_.target?.result;j.push({path:P,content:L}),C()},T?I.readAsDataURL(A):I.readAsText(A)})}try{(await fetch("/api/resources",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N,type:"folder",content:JSON.stringify(j)})})).ok&&v()}catch(w){console.error("Folder upload failed:",w)}}})]})]})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[i.jsx("span",{className:"block text-[10px] font-bold text-gray-400 uppercase tracking-widest pl-1",children:n==="zh"?"当前已存储的资源":"Stored Resources"}),p&&i.jsx("div",{className:"text-center py-8 text-xs text-slate-400",children:"Loading resources..."}),!p&&g.length===0&&i.jsx("div",{className:"text-center py-12 text-xs text-slate-400 italic",children:n==="zh"?"暂无资源,支持拖入或上传文件。":"No resources in library. Upload some above!"}),g.map(x=>{const b=o===x.id;return i.jsxs("div",{onClick:()=>l(x.id),className:`p-2.5 rounded-xl border flex justify-between items-center cursor-pointer transition-all ${b?"bg-indigo-50 border-indigo-200 shadow-xs":"bg-white border-slate-100 hover:border-slate-200 hover:shadow-2xs"}`,children:[i.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[i.jsx("span",{className:"text-base select-none",children:x.type==="folder"?"📁":"📄"}),i.jsxs("div",{className:"text-left min-w-0",children:[i.jsx("div",{className:"text-xs font-semibold text-gray-700 truncate font-sans",title:x.name,children:x.name}),i.jsxs("div",{className:"text-[9px] text-gray-400 mt-0.5 font-mono",children:[new Date(x.created_at).toLocaleDateString()," • ",x.id]})]})]}),i.jsx("button",{onClick:async j=>{j.stopPropagation(),confirm(n==="zh"?`确认删除资源 [${x.name}] 吗?`:`Delete resource [${x.name}]?`)&&(await fetch(`/api/resources/${x.id}`,{method:"DELETE"}),o===x.id&&l(null),v())},className:"p-1 hover:bg-red-50 text-slate-400 hover:text-red-500 rounded-md transition-colors cursor-pointer",title:"Delete",children:i.jsx(Yo,{size:12,className:"shrink-0"})})]},x.id)})]})]}),i.jsx("div",{className:"flex-1 bg-white flex flex-col min-w-0",children:o?i.jsxs("div",{className:"flex-1 flex flex-col h-full min-h-0",children:[i.jsxs("div",{className:"p-3 border-b border-gray-100 bg-gray-50 flex items-center justify-between shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-bold text-gray-700 text-sm",children:n==="zh"?"交互沙箱应用预览:":"Sandbox Live Preview:"}),i.jsxs("span",{className:"text-xs bg-slate-200/70 text-slate-700 px-2 py-0.5 rounded font-mono",children:["/api/resources/",o,"/"]})]}),i.jsx("button",{onClick:()=>l(null),className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium cursor-pointer",children:n==="zh"?"关闭预览":"Close Preview"})]}),i.jsx("div",{className:"flex-1 relative bg-slate-100/50",children:i.jsx("iframe",{src:`/api/resources/${o}/`,sandbox:"allow-scripts",className:"w-full h-full border-none bg-white font-sans",title:"Interactive Resource Preview"})})]}):i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-gray-400 bg-slate-50/50",children:[i.jsx(Wo,{size:48,className:"text-gray-300 mb-3 opacity-60"}),i.jsx("p",{className:"text-sm font-semibold text-gray-600",children:n==="zh"?"未选择资源进行预览":"No Resource Selected"}),i.jsx("p",{className:"text-xs text-center text-gray-400 mt-1 max-w-sm",children:n==="zh"?"请在左侧列表中点击选择要预览/管理的 HTML 单文件或完整 applet 文件夹,右侧即可进行沙箱实时运行。":"Click any resource in the list on the left to preview its interactive live sandbox iframe here."})]})})]})]})})})}function mZ({batchPicker:e,setBatchPicker:t,batchPickerLesson:r,setBatchPickerLesson:n,batchPickerDate:s,setBatchPickerDate:a,batchPickerTargetClass:o,setBatchPickerTargetClass:l,lessons:c,classes:d,expandedClassId:u,confirmBatchPicker:f,lang:h}){return e?i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:i.jsxs(Fi.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-md flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80",children:[i.jsx("h2",{className:"font-bold text-gray-800 text-base",children:e==="schedule"?h==="zh"?"批量排课":"Batch Schedule":e==="lockedLesson"?h==="zh"?"批量设置锁定课程":"Batch Lock Lesson":h==="zh"?"批量转班":"Batch Transfer"}),i.jsx("button",{onClick:()=>t(null),className:"text-gray-400 hover:text-gray-600 text-lg font-bold p-1 hover:bg-gray-200 rounded",children:"×"})]}),i.jsxs("div",{className:"p-5 space-y-4",children:[(e==="schedule"||e==="lockedLesson")&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-semibold text-gray-600",children:h==="zh"?"选择课程":"Select Lesson"}),i.jsxs("select",{value:r,onChange:p=>n(p.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[i.jsx("option",{value:"",children:h==="zh"?"— 请选择 —":"— Select —"}),c.map(p=>i.jsx("option",{value:p.id,children:p.title},p.id))]})]}),e==="schedule"&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-semibold text-gray-600",children:h==="zh"?"上课日期":"Schedule Date"}),i.jsx("input",{type:"date",value:s,onChange:p=>a(p.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),e==="transfer"&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-semibold text-gray-600",children:h==="zh"?"选择目标班级":"Select Target Class"}),i.jsxs("select",{value:o,onChange:p=>l(p.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[i.jsx("option",{value:"",children:h==="zh"?"— 请选择 —":"— Select —"}),d.filter(p=>p.id!==u).map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))]})]})]}),i.jsxs("div",{className:"p-4 border-t border-gray-100 flex justify-end gap-2",children:[i.jsx("button",{onClick:()=>t(null),className:"px-4 py-2 text-sm rounded-lg border border-gray-200 text-gray-600 hover:bg-gray-100 cursor-pointer",children:h==="zh"?"取消":"Cancel"}),i.jsx("button",{onClick:f,className:"px-4 py-2 text-sm rounded-lg bg-indigo-600 text-white hover:bg-indigo-700 cursor-pointer",children:h==="zh"?"确认":"Confirm"})]})]})}):null}function gZ({isExportWeightModalOpen:e,setIsExportWeightModalOpen:t,lang:r,quizzesWeight:n,setQuizzesWeight:s,assignmentsWeight:a,setAssignmentsWeight:o,handleQuizzesWeightChange:l,handleAssignmentsWeightChange:c,customCategoryOverrides:d,setCustomCategoryOverrides:u,classDashboardMap:f,exportClassId:h,exportClassName:p,csvPreviewData:g,handleExportGrades:v}){return e?i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:i.jsxs(Fi.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-2xl flex flex-col overflow-hidden max-h-[85vh]",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(sf,{className:"text-indigo-600 font-sans",size:20}),i.jsx("h2",{className:"font-bold text-gray-800 text-lg font-sans",children:r==="zh"?"导出成绩权重设置":"Grade Export & Weighting Settings"})]}),i.jsx("button",{onClick:()=>t(!1),className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors text-lg",children:"×"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[i.jsx("div",{className:"bg-indigo-50 border border-indigo-150 rounded-xl p-4 text-indigo-800 text-xs font-sans leading-relaxed",children:r==="zh"?"您可以自定义测验与作业在期末成绩(平均分)中的计算权重。系统已根据测验名和内容自动对课程内容进行分类,您可以在下方手动微调分类。":"Customize the calculation weight of quizzes and assignments in the calculated average score. The system automatically classifies items, but you can manually override categorized groups below."}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("h3",{className:"font-bold text-sm text-gray-800 flex items-center gap-2 font-sans",children:[i.jsx(eq,{size:16,className:"text-indigo-500 font-sans"}),r==="zh"?"定义成绩占比权重":"Define Weighting Percentages"]}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 bg-gray-50 p-4 rounded-xl border border-gray-100 font-sans",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-gray-700",children:r==="zh"?"测验权重 (Quizzes)":"Quizzes Weight"}),i.jsxs("span",{className:"text-xs font-bold text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded border border-indigo-100",children:[n,"%"]})]}),i.jsx("input",{type:"range",min:"0",max:"100",value:n,onChange:x=>l(Number(x.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-gray-700",children:r==="zh"?"作业权重 (Assignments)":"Assignments Weight"}),i.jsxs("span",{className:"text-xs font-bold text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded border border-indigo-100",children:[a,"%"]})]}),i.jsx("input",{type:"range",min:"0",max:"100",value:a,onChange:x=>c(Number(x.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"})]})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:()=>{s(50),o(50)},className:"text-[10px] text-gray-500 hover:text-gray-700 bg-white border border-gray-200 hover:bg-gray-50 font-bold px-2.5 py-1 rounded transition-colors cursor-pointer",children:r==="zh"?"均衡配比 50/50":"Balance 50/50"}),i.jsx("button",{type:"button",onClick:()=>{s(40),o(60)},className:"text-[10px] text-gray-500 hover:text-gray-700 bg-white border border-gray-200 hover:bg-gray-50 font-bold px-2.5 py-1 rounded transition-colors cursor-pointer",children:r==="zh"?"推荐配比 40/60":"Recommend 40/60"})]})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("h3",{className:"font-bold text-sm text-gray-800 flex items-center justify-between font-sans",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(hD,{size:16,className:"text-indigo-500"}),r==="zh"?"期末考核项目微调":"Item Categorization Overrides"]}),i.jsx("span",{className:"text-[10px] text-gray-400 font-medium font-sans",children:r==="zh"?`共 ${f[h]?.assignments?.length||0} 项`:`${f[h]?.assignments?.length||0} items total`})]}),i.jsxs("div",{className:"border border-gray-150 rounded-xl overflow-hidden divide-y divide-gray-100 max-h-60 overflow-y-auto bg-white shadow-inner",children:[(f[h]?.assignments||[]).map(x=>{const b=x.content&&x.content.startsWith('{"quizType":"mcq_learning_objectives"'),j=x.title&&(x.title.toLowerCase().includes("quiz")||x.title.toLowerCase().includes("test")||x.title.includes("测验")||x.title.includes("测试")),N=b||j?"quiz":"assignment",w=d[x.id]||N;return i.jsxs("div",{className:"p-3 flex items-center justify-between gap-4 font-sans hover:bg-gray-50/50 transition-colors",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"font-semibold text-xs text-gray-800 truncate",title:x.title,children:x.title}),i.jsx("div",{className:"text-[10px] text-gray-400 truncate mt-0.5",children:x.description||(r==="zh"?"无描述信息":"No description provided")})]}),i.jsxs("div",{className:"flex border border-gray-200 rounded-lg p-0.5 bg-gray-50 shrink-0",children:[i.jsx("button",{type:"button",onClick:()=>u(A=>({...A,[x.id]:"quiz"})),className:`px-2.5 py-1 text-[10px] font-bold rounded-md transition-all cursor-pointer ${w==="quiz"?"bg-indigo-600 text-white shadow":"text-gray-500 hover:text-gray-800 hover:bg-gray-100"}`,children:r==="zh"?"测验":"Quiz"}),i.jsx("button",{type:"button",onClick:()=>u(A=>({...A,[x.id]:"assignment"})),className:`px-2.5 py-1 text-[10px] font-bold rounded-md transition-all cursor-pointer ${w==="assignment"?"bg-emerald-600 text-white shadow":"text-gray-500 hover:text-gray-800 hover:bg-gray-100"}`,children:r==="zh"?"作业":"Assignment"})]})]},x.id)}),(!f[h]?.assignments||f[h].assignments.length===0)&&i.jsx("div",{className:"p-8 text-center text-xs text-gray-400 italic",children:r==="zh"?"此班级暂未创建任何考核项目":"No graded items exist in this class."})]})]}),g&&g.rows.length>0&&i.jsxs("div",{className:"space-y-3 pt-2",children:[i.jsxs("h3",{className:"font-bold text-sm text-gray-800 flex items-center justify-between font-sans",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(va,{size:16,className:"text-emerald-500"}),r==="zh"?"CSV 实时成绩表预览 (前5行数据)":"Live CSV Grade Preview (First 5 Rows)"]}),i.jsx("span",{className:"text-[10px] bg-emerald-50 text-emerald-700 border border-emerald-100 font-bold px-2 py-0.5 rounded shadow-xs font-sans",children:r==="zh"?`展示 5 / ${g.totalStudents} 名学生`:`Showing 5 of ${g.totalStudents} students`})]}),i.jsx("div",{className:"border border-gray-150 rounded-xl overflow-hidden bg-white shadow-xs max-w-full",children:i.jsx("div",{className:"overflow-x-auto max-h-56 overflow-y-auto",children:i.jsxs("table",{className:"w-full border-collapse text-left",children:[i.jsx("thead",{children:i.jsx("tr",{className:"bg-gray-50 border-b border-gray-150 sticky top-0 z-10",children:g.headers.map((x,b)=>{const j=x.includes("Average")||x.includes("Avg")||x.includes("Score"),N=x.includes("Weighted");return i.jsx("th",{className:`p-2.5 text-[10px] font-bold tracking-wider uppercase border-r border-gray-150 whitespace-nowrap font-sans font-semibold ${N?"text-indigo-700 bg-indigo-50/70 border-indigo-150 font-bold":j?"text-emerald-700 bg-emerald-50/70":"text-gray-500"}`,children:x},b)})})}),i.jsx("tbody",{className:"divide-y divide-gray-100",children:g.rows.map((x,b)=>i.jsx("tr",{className:"hover:bg-gray-50/50 transition-colors font-mono text-[10px]",children:x.map((j,N)=>{const w=g.headers[N]||"",A=w.includes("Weighted"),P=w.includes("Average")||w.includes("Avg")||w.includes("Score");return i.jsx("td",{className:`p-2 border-r border-gray-100 font-mono text-[10px] text-gray-700 whitespace-nowrap text-center ${A?"bg-indigo-50/30 font-bold text-indigo-700 border-indigo-100":P?"bg-emerald-50/10 font-semibold text-emerald-800":N<2?"text-left font-sans font-medium":""}`,children:j},N)})},b))})]})})}),i.jsx("p",{className:"text-[10px] text-gray-400 font-sans italic",children:r==="zh"?"* 改变上方权重占比或调整项目分类时,此预览与计算结果会立即实时刷新。":"* Calculations and layout values in this preview refresh dynamically as you tweak sliders and overrides."})]})]}),i.jsxs("div",{className:"p-4 border-t border-gray-100 bg-gray-50/85 flex justify-end gap-2.5 shrink-0",children:[i.jsx("button",{type:"button",onClick:()=>t(!1),className:"px-4 py-2 text-xs font-semibold border border-gray-300 text-gray-700 bg-white rounded-lg hover:bg-gray-100 transition-colors cursor-pointer",children:r==="zh"?"取消":"Cancel"}),i.jsxs("button",{type:"button",disabled:!f[h]?.assignments||f[h].assignments.length===0,onClick:()=>{v(h,p,n,a,d),t(!1)},className:"px-4 py-2 text-xs font-bold bg-indigo-600 text-white border border-indigo-700 rounded-lg hover:bg-indigo-700 hover:shadow shadow-sm transition-all flex items-center gap-1.5 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[i.jsx(Md,{size:14}),r==="zh"?"导出 CSV 成绩表":"Export Grade Sheet"]})]})]})}):null}const xZ=ss.memo(function({onLoginSuccess:t,lang:r}){const[n,s]=m.useState("teacher"),[a,o]=m.useState(null),[l,c]=m.useState(""),[d,u]=m.useState(""),[f,h]=m.useState(""),[p,g]=m.useState(!1),[v,x]=m.useState([]),[b,j]=m.useState(""),[N,w]=m.useState(""),[A,P]=m.useState(""),[E,T]=m.useState(""),[C,I]=m.useState(!1);m.useEffect(()=>{(async()=>{try{const z=await fetch("/api/students");if(z.ok){const R=await z.json();x(R),R.length>0&&j(R[0].id)}}catch(z){console.warn("Failed to fetch student roster for login selection:",z)}})()},[]),m.useEffect(()=>{(async()=>{try{const z=await fetch("/api/site-settings");if(z.ok){const R=await z.json();o(R)}}catch(z){console.warn("Failed to fetch site settings for login branding:",z)}})()},[]);const _=async $=>{if($.preventDefault(),!l.trim()||!d){h(r==="zh"?"请输入完整的用户名和密码。":"Please fill in both key fields.");return}try{h(""),g(!0);const z=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"teacher",username:l.trim(),password:d})});if(z.ok){const R=await z.json();t(R.session)}else{const R=await z.json();h(R.error||(r==="zh"?"用户名或密码不正确":"Invalid username or password"))}}catch{h(r==="zh"?"网络连接异常,请重试":"Network communication failure. Please try again.")}finally{g(!1)}},L=async $=>{$.preventDefault();const z=b||N.trim();if(!z){T(r==="zh"?"请选择或输入学号/学生标识。":"Please select or enter your Student ID.");return}if(!A.trim()){T(r==="zh"?"请输入个人密码或临时班级密码。":"Please enter your personal password or temporary class passcode.");return}try{T(""),I(!0);const R=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"student",studentId:z,password:A.trim()})});if(R.ok){const J=await R.json();t(J.session)}else{const J=await R.json();T(J.error||(r==="zh"?"找不到该学生记录":"Student record not found"))}}catch{T(r==="zh"?"网络连接异常,请重试":"Network connection failure. Please try again.")}finally{I(!1)}};return i.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:[i.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40rem] h-[40rem] rounded-full bg-indigo-500/10 blur-3xl -z-10"}),i.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[35rem] h-[35rem] rounded-full bg-violet-500/10 blur-3xl -z-10"}),i.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:[i.jsxs("div",{className:"text-center mb-8",children:[a?.logoUrl?i.jsx("img",{src:a.logoUrl,alt:a.siteName||"logo",className:"inline-block h-16 w-16 object-contain mb-4 rounded-xl"}):i.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:i.jsx(dj,{size:32})}),i.jsxs("h1",{className:"text-2xl sm:text-3xl font-black text-white tracking-tight flex items-center justify-center gap-2",children:[a?.siteName||"OpenLearn Next"," ",i.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"})]}),i.jsx("p",{className:"text-slate-400 text-xs sm:text-sm mt-2",children:a?.slogan||(r==="zh"?"下一代智能数字化学习系统":"Next-Generation Intelligent Digital Learning Platform")})]}),i.jsxs("div",{className:"flex bg-slate-900 p-1 rounded-xl border border-slate-800 gap-1 mb-6",children:[i.jsxs("button",{onClick:()=>s("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 ${n==="teacher"?"bg-indigo-600 text-white shadow-md":"text-slate-400 hover:text-slate-200 hover:bg-slate-800/40"}`,children:[i.jsx(Qa,{size:14}),r==="zh"?"教师与管理端":"Teacher / Staff Portal"]}),i.jsxs("button",{onClick:()=>s("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 ${n==="student"?"bg-indigo-600 text-white shadow-md":"text-slate-400 hover:text-slate-200 hover:bg-slate-800/40"}`,children:[i.jsx(Nn,{size:14}),r==="zh"?"学生自助端":"Student Self-Service"]})]}),n==="teacher"?i.jsxs("form",{onSubmit:_,className:"space-y-4",children:[f&&i.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:[i.jsx(so,{size:15,className:"shrink-0"}),i.jsx("span",{children:f})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(Fh,{size:13}),r==="zh"?"教工账户名 / username":"Staff Username"]}),i.jsx("input",{type:"text",value:l,onChange:$=>c($.target.value),placeholder:r==="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})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(uj,{size:13}),r==="zh"?"输入登录密码 / password":"Access Password"]}),i.jsx("input",{type:"password",value:d,onChange:$=>u($.target.value),placeholder:r==="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})]}),i.jsxs("button",{type:"submit",disabled:p,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:[i.jsx("span",{children:p?r==="zh"?"鉴权登录中...":"Authorizing...":r==="zh"?"安全验证登录":"Authorized Sign In"}),i.jsx(NC,{size:15})]})]}):i.jsxs("form",{onSubmit:L,className:"space-y-4",children:[E&&i.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:[i.jsx(so,{size:15,className:"shrink-0"}),i.jsx("span",{children:E})]}),v.length>0?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(dj,{size:14}),r==="zh"?"从学生花名册中快速选择":"Quick Access Student Select"]}),i.jsx("select",{value:b,onChange:$=>{j($.target.value),w("")},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:v.map($=>i.jsxs("option",{value:$.id,children:[$.name," (",$.student_number||$.id,")"]},$.id))}),i.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:r==="zh"?"✨ 在沙盒调试中,你可以直接下拉选择已有的学生账户一键登录为该生。":"✨ Sandbox help: Quick select existing students on file to simulate as student."})]}):null,i.jsxs("div",{className:"relative flex py-2 items-center",children:[i.jsx("div",{className:"flex-grow border-t border-slate-850"}),i.jsx("span",{className:"flex-shrink mx-3 text-[10px] font-bold text-slate-500 uppercase tracking-wider",children:r==="zh"?"或手动输入学号":"Or input key manually"}),i.jsx("div",{className:"flex-grow border-t border-slate-850"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(Fh,{size:13}),r==="zh"?"学号 / Student ID":"Student Access Key"]}),i.jsx("input",{type:"text",value:N,onChange:$=>{w($.target.value),j("")},placeholder:r==="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"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(uj,{size:13}),r==="zh"?"个人密码 / 临时班级密码":"Personal Password / Class Passcode"]}),i.jsx("input",{type:"password",required:!0,value:A,onChange:$=>P($.target.value),placeholder:r==="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"})]}),i.jsxs("button",{type:"submit",disabled:C,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:[i.jsx("span",{children:C?r==="zh"?"正在连接学生终端...":"Entering Desk...":r==="zh"?"登录学生智慧桌面":"Login Interactive Desk"}),i.jsx(NC,{size:15})]})]})]})]})});function vZ({isOpen:e,onClose:t,lang:r,onSeedSuccess:n,onJumpTab:s}){const[a,o]=m.useState(0),[l,c]=m.useState(!1),[d,u]=m.useState(null),[f,h]=m.useState(null),[p,g]=m.useState({display:"none"}),[v,x]=m.useState({display:"none"}),b=m.useRef(null),j=[{targetId:"",title:r==="zh"?"欢迎来到 OpenLearn Next V2 平台!":"Welcome to OpenLearn Next V2!",content:r==="zh"?"本平台为数字课堂提供智能白板与教学插件生态托管。下面我们将通过 4 步带您快速完成初始化并体验一堂数字互动课程。":"Welcome! This platform provides interactive whiteboards and educational plugin hosting. Let's set up your first class in 4 quick steps."},{targetId:"nav_btn_admin_directory",title:r==="zh"?"第 1 步:一键初始化示例课程":"Step 1: Initialize Example Class",content:r==="zh"?"在开始授课前,我们需要一个授课班级。请点击下方的按钮,系统将自动在数据库中为您建立示例班级、添加 5 名演示学生(小明、小红等),并自动排定一节今日的白板创意编程示范课!":"Before teaching, we need a classroom session. Click the button below to seed a demo class, add 5 sample students (Xiao Ming, Xiao Hong, etc.), and schedule today's creative programming class!",actionable:!0},{targetId:"navigation_sidebar",title:r==="zh"?"第 2 步:了解系统导航菜单":"Step 2: Tour System Navigation",content:r==="zh"?"初始化成功后,您可以在「系统导航」的「班级管理」中查看学生名册及座位表,或在「课程管理」中编辑白板教案。在「插件中心」中,您还可以安装/停用丰富的第三方小工具。":'After setup, explore the sidebar! Use "Classes & Students" to manage student profiles, "Courses" to edit whiteboards, and "Plugins" to manage tools.'},{targetId:"nav_btn_live_class",title:r==="zh"?"第 3 步:进入互动课堂开启体验":"Step 3: Launch Live Classroom",content:r==="zh"?"一切就绪!点击下方的「一键开课并进入课堂」,系统将为您自动进入示范课堂并展开互动白板。您可以在白板上下发测验、进行实时统计,学生端也将实时接收广播。":'All set! Click "Launch Classroom" to enter the live room. You can draw on the whiteboard, push quizzes, and view live stats, while student clients auto-sync.'}],N=async()=>{c(!0);try{const P=await fetch("/api/admin/seed-demo",{method:"POST"});if(P.ok){const E=await P.json();E.success&&(h({classId:E.classId,className:"人工智能与创意编程示范班"}),n({classId:E.classId,scheduleId:E.scheduleId,lessonId:E.lessonId}),setTimeout(()=>{o(2)},1500))}else{const E=await P.json().catch(()=>({error:"未知错误"}));u(r==="zh"?`初始化失败:${E.error||"请检查服务器日志"}`:`Failed: ${E.error||"Check server logs"}`)}}catch(P){console.error("Failed to seed demo data:",P),u(r==="zh"?`网络错误:${P.message||"请检查服务器是否运行"}`:`Network error: ${P.message||"Check if server is running"}`)}finally{c(!1)}},w=()=>{localStorage.setItem("edu_os_tour_completed","true"),s("live_class"),t()};if(m.useEffect(()=>{if(!e)return;const P=j[a];if(!P||!P.targetId){g({display:"none"}),x({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e4,width:"420px",maxWidth:"90vw"});return}const E=()=>{const C=document.getElementById(P.targetId);if(!C){g({display:"none"}),x({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e4,width:"420px",maxWidth:"90vw"});return}const I=C.getBoundingClientRect(),_=6;g({display:"block",position:"fixed",top:`${I.top-_}px`,left:`${I.left-_}px`,width:`${I.width+_*2}px`,height:`${I.height+_*2}px`,boxShadow:"0 0 0 9999px rgba(15, 23, 42, 0.65)",border:"2px dashed #6366f1",borderRadius:"12px",zIndex:9999,pointerEvents:"none",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)"});const L=360;let $=I.left+I.width+16,z=I.top;$+L>window.innerWidth&&($=Math.max(16,I.left-L-16)),z+240>window.innerHeight&&(z=Math.max(16,window.innerHeight-250)),x({display:"block",position:"fixed",top:`${z}px`,left:`${$}px`,width:`${L}px`,zIndex:1e4,transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)"})};E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0);const T=setInterval(E,300);return()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0),clearInterval(T)}},[e,a]),!e)return null;const A=j[a];return i.jsxs("div",{className:"fixed inset-0 overflow-hidden select-none",style:{zIndex:9998},children:[A&&!A.targetId&&i.jsx("div",{className:"fixed inset-0 bg-slate-900/65 backdrop-blur-2xs transition-opacity",onClick:t}),i.jsx("div",{style:p}),i.jsxs("div",{ref:b,style:v,className:"bg-white rounded-2xl border border-slate-150/60 shadow-2xl p-5 md:p-6 text-gray-900 font-sans flex flex-col justify-between",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between items-start mb-3",children:[i.jsxs("h3",{className:"font-extrabold text-sm md:text-base text-gray-900 flex items-center gap-1.5 leading-tight",children:[i.jsx(An,{size:16,className:"text-indigo-500 animate-pulse shrink-0"}),A.title]}),i.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 rounded-lg p-0.5 transition-colors cursor-pointer",children:i.jsx(Lr,{size:16})})]}),i.jsx("p",{className:"text-xs md:text-sm text-gray-600 leading-relaxed font-medium mb-5 whitespace-pre-wrap",children:A.content}),A.actionable&&i.jsx("div",{className:"bg-slate-50 border border-slate-200/80 rounded-xl p-3.5 mb-5 flex flex-col items-center justify-center",children:f?i.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 text-xs font-bold animate-bounce",children:[i.jsx(BS,{size:12,className:"fill-emerald-600"}),r==="zh"?"示范课程与学生名册初始化成功!":"Demo classes successfully initialized!"]}):i.jsx("button",{onClick:N,disabled:l,className:"w-full flex items-center justify-center gap-1.5 py-2.5 px-4 bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs md:text-sm rounded-lg hover:shadow-md transition-all cursor-pointer disabled:bg-indigo-400",children:l?i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsxs("svg",{className:"animate-spin h-4 w-4 text-white",fill:"none",viewBox:"0 0 24 24",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),r==="zh"?"正在创建数据库记录...":"Initializing DB records..."]}):i.jsxs(i.Fragment,{children:[i.jsx(An,{size:14,className:"animate-pulse"}),r==="zh"?"一键初始化示范数据":"Initialize Example Data"]})})})]}),i.jsxs("div",{className:"flex items-center justify-between border-t border-slate-100 pt-4 shrink-0",children:[i.jsx("div",{className:"flex items-center gap-1.5",children:j.map((P,E)=>i.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${E===a?"w-4 bg-indigo-600":"w-1.5 bg-slate-200"}`},E))}),i.jsxs("div",{className:"flex items-center gap-2",children:[a>0?i.jsxs("button",{onClick:()=>o(P=>P-1),className:"flex items-center gap-1 px-3 py-1.5 border border-slate-200 rounded-lg text-xs font-semibold text-slate-600 hover:bg-slate-50 transition-colors cursor-pointer",children:[i.jsx(D0,{size:12}),r==="zh"?"上一步":"Back"]}):i.jsx("button",{onClick:t,className:"px-3 py-1.5 border border-slate-200 rounded-lg text-xs font-semibold text-slate-500 hover:bg-slate-50 transition-colors cursor-pointer",children:r==="zh"?"跳过向导":"Skip Tour"}),a<j.length-1?i.jsxs("button",{onClick:()=>o(P=>P+1),className:"flex items-center gap-1 px-3 py-1.5 bg-slate-900 text-white rounded-lg text-xs font-semibold hover:bg-slate-800 transition-colors cursor-pointer",children:[r==="zh"?"下一步":"Next",i.jsx(ys,{size:12})]}):i.jsxs("button",{onClick:w,className:"flex items-center gap-1 px-4 py-1.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-xs font-bold shadow-sm transition-colors cursor-pointer",children:[r==="zh"?"结束引导并开课":"Launch Classroom",i.jsx(An,{size:12})]})]})]})]})]})}const Ul=Object.create(null);Ul.open="0";Ul.close="1";Ul.ping="2";Ul.pong="3";Ul.message="4";Ul.upgrade="5";Ul.noop="6";const Bx=Object.create(null);Object.keys(Ul).forEach(e=>{Bx[Ul[e]]=e});const $j={type:"error",data:"parser error"},v8=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",b8=typeof ArrayBuffer=="function",y8=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,_A=({type:e,data:t},r,n)=>v8&&t instanceof Blob?r?n(t):X4(t,n):b8&&(t instanceof ArrayBuffer||y8(t))?r?n(t):X4(new Blob([t]),n):n(Ul[e]+(t||"")),X4=(e,t)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];t("b"+(n||""))},r.readAsDataURL(e)};function Z4(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let gw;function bZ(e,t){if(v8&&e.data instanceof Blob)return e.data.arrayBuffer().then(Z4).then(t);if(b8&&(e.data instanceof ArrayBuffer||y8(e.data)))return t(Z4(e.data));_A(e,!1,r=>{gw||(gw=new TextEncoder),t(gw.encode(r))})}const J4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Om=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<J4.length;e++)Om[J4.charCodeAt(e)]=e;const yZ=e=>{let t=e.length*.75,r=e.length,n,s=0,a,o,l,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const d=new ArrayBuffer(t),u=new Uint8Array(d);for(n=0;n<r;n+=4)a=Om[e.charCodeAt(n)],o=Om[e.charCodeAt(n+1)],l=Om[e.charCodeAt(n+2)],c=Om[e.charCodeAt(n+3)],u[s++]=a<<2|o>>4,u[s++]=(o&15)<<4|l>>2,u[s++]=(l&3)<<6|c&63;return d},wZ=typeof ArrayBuffer=="function",TA=(e,t)=>{if(typeof e!="string")return{type:"message",data:w8(e,t)};const r=e.charAt(0);return r==="b"?{type:"message",data:jZ(e.substring(1),t)}:Bx[r]?e.length>1?{type:Bx[r],data:e.substring(1)}:{type:Bx[r]}:$j},jZ=(e,t)=>{if(wZ){const r=yZ(e);return w8(r,t)}else return{base64:!0,data:e}},w8=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},j8="",NZ=(e,t)=>{const r=e.length,n=new Array(r);let s=0;e.forEach((a,o)=>{_A(a,!1,l=>{n[o]=l,++s===r&&t(n.join(j8))})})},SZ=(e,t)=>{const r=e.split(j8),n=[];for(let s=0;s<r.length;s++){const a=TA(r[s],t);if(n.push(a),a.type==="error")break}return n};function AZ(){return new TransformStream({transform(e,t){bZ(e,r=>{const n=r.length;let s;if(n<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,n);else if(n<65536){s=new Uint8Array(3);const a=new DataView(s.buffer);a.setUint8(0,126),a.setUint16(1,n)}else{s=new Uint8Array(9);const a=new DataView(s.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(n))}e.data&&typeof e.data!="string"&&(s[0]|=128),t.enqueue(s),t.enqueue(r)})}})}let xw;function Yg(e){return e.reduce((t,r)=>t+r.length,0)}function Xg(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let s=0;s<t;s++)r[s]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function PZ(e,t){xw||(xw=new TextDecoder);const r=[];let n=0,s=-1,a=!1;return new TransformStream({transform(o,l){for(r.push(o);;){if(n===0){if(Yg(r)<1)break;const c=Xg(r,1);a=(c[0]&128)===128,s=c[0]&127,s<126?n=3:s===126?n=1:n=2}else if(n===1){if(Yg(r)<2)break;const c=Xg(r,2);s=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),n=3}else if(n===2){if(Yg(r)<8)break;const c=Xg(r,8),d=new DataView(c.buffer,c.byteOffset,c.length),u=d.getUint32(0);if(u>Math.pow(2,21)-1){l.enqueue($j);break}s=u*Math.pow(2,32)+d.getUint32(4),n=3}else{if(Yg(r)<s)break;const c=Xg(r,s);l.enqueue(TA(a?c:xw.decode(c),t)),n=0}if(s===0||s>e){l.enqueue($j);break}}}})}const N8=4;function xs(e){if(e)return kZ(e)}function kZ(e){for(var t in xs.prototype)e[t]=xs.prototype[t];return e}xs.prototype.on=xs.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};xs.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};xs.prototype.off=xs.prototype.removeListener=xs.prototype.removeAllListeners=xs.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,s=0;s<r.length;s++)if(n=r[s],n===t||n.fn===t){r.splice(s,1);break}return r.length===0&&delete this._callbacks["$"+e],this};xs.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,s=r.length;n<s;++n)r[n].apply(this,t)}return this};xs.prototype.emitReserved=xs.prototype.emit;xs.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};xs.prototype.hasListeners=function(e){return!!this.listeners(e).length};const ny=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,r)=>r(t,0),Za=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),CZ="arraybuffer";function S8(e,...t){return t.reduce((r,n)=>(e.hasOwnProperty(n)&&(r[n]=e[n]),r),{})}const EZ=Za.setTimeout,_Z=Za.clearTimeout;function sy(e,t){t.useNativeTimers?(e.setTimeoutFn=EZ.bind(Za),e.clearTimeoutFn=_Z.bind(Za)):(e.setTimeoutFn=Za.setTimeout.bind(Za),e.clearTimeoutFn=Za.clearTimeout.bind(Za))}const TZ=1.33;function OZ(e){return typeof e=="string"?IZ(e):Math.ceil((e.byteLength||e.size)*TZ)}function IZ(e){let t=0,r=0;for(let n=0,s=e.length;n<s;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}function A8(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function LZ(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}function zZ(e){let t={},r=e.split("&");for(let n=0,s=r.length;n<s;n++){let a=r[n].split("=");t[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return t}class DZ extends Error{constructor(t,r,n){super(t),this.description=r,this.context=n,this.type="TransportError"}}class OA extends xs{constructor(t){super(),this.writable=!1,sy(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,r,n){return super.emitReserved("error",new DZ(t,r,n)),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 r=TA(t,this.socket.binaryType);this.onPacket(r)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,r={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_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 r=LZ(t);return r.length?"?"+r:""}}class MZ extends OA{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const r=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};SZ(t,this.socket.binaryType).forEach(r),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,NZ(t,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=A8()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(t,r)}}let P8=!1;try{P8=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const RZ=P8;function $Z(){}class FZ extends MZ{constructor(t){if(super(t),typeof location<"u"){const r=location.protocol==="https:";let n=location.port;n||(n=r?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||n!==t.port}}doWrite(t,r){const n=this.request({method:"POST",data:t});n.on("success",r),n.on("error",(s,a)=>{this.onError("xhr post error",s,a)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=t}}class Rl extends xs{constructor(t,r,n){super(),this.createRequest=t,sy(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var t;const r=S8(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let s in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(s)&&n.setRequestHeader(s,this._opts.extraHeaders[s])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var s;n.readyState===3&&((s=this._opts.cookieJar)===null||s===void 0||s.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(s){this.setTimeoutFn(()=>{this._onError(s)},0);return}typeof document<"u"&&(this._index=Rl.requestsCount++,Rl.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=$Z,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Rl.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()}}Rl.requestsCount=0;Rl.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Q4);else if(typeof addEventListener=="function"){const e="onpagehide"in Za?"pagehide":"unload";addEventListener(e,Q4,!1)}}function Q4(){for(let e in Rl.requests)Rl.requests.hasOwnProperty(e)&&Rl.requests[e].abort()}const BZ=(function(){const e=k8({xdomain:!1});return e&&e.responseType!==null})();class VZ extends FZ{constructor(t){super(t);const r=t&&t.forceBase64;this.supportsBinary=BZ&&!r}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Rl(k8,this.uri(),t)}}function k8(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||RZ))return new XMLHttpRequest}catch{}if(!t)try{return new Za[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const C8=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class WZ extends OA{get name(){return"websocket"}doOpen(){const t=this.uri(),r=this.opts.protocols,n=C8?{}:S8(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,r,n)}catch(s){return this.emitReserved("error",s)}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 r=0;r<t.length;r++){const n=t[r],s=r===t.length-1;_A(n,this.supportsBinary,a=>{try{this.doWrite(n,a)}catch{}s&&ny(()=>{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",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=A8()),this.supportsBinary||(r.b64=1),this.createUri(t,r)}}const vw=Za.WebSocket||Za.MozWebSocket;class UZ extends WZ{createSocket(t,r,n){return C8?new vw(t,r,n):r?new vw(t,r):new vw(t)}doWrite(t,r){this.ws.send(r)}}class qZ extends OA{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 r=PZ(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=t.readable.pipeThrough(r).getReader(),s=AZ();s.readable.pipeTo(t.writable),this._writer=s.writable.getWriter();const a=()=>{n.read().then(({done:l,value:c})=>{l||(this.onPacket(c),a())}).catch(l=>{})};a();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 r=0;r<t.length;r++){const n=t[r],s=r===t.length-1;this._writer.write(n).then(()=>{s&&ny(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const HZ={websocket:UZ,webtransport:qZ,polling:VZ},KZ=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,GZ=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Fj(e){if(e.length>8e3)throw"URI too long";const t=e,r=e.indexOf("["),n=e.indexOf("]");r!=-1&&n!=-1&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let s=KZ.exec(e||""),a={},o=14;for(;o--;)a[GZ[o]]=s[o]||"";return r!=-1&&n!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=YZ(a,a.path),a.queryKey=XZ(a,a.query),a}function YZ(e,t){const r=/\/{2,9}/g,n=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&n.splice(0,1),t.slice(-1)=="/"&&n.splice(n.length-1,1),n}function XZ(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,s,a){s&&(r[s]=a)}),r}const Bj=typeof addEventListener=="function"&&typeof removeEventListener=="function",Vx=[];Bj&&addEventListener("offline",()=>{Vx.forEach(e=>e())},!1);class Rd extends xs{constructor(t,r){if(super(),this.binaryType=CZ,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(r=t,t=null),t){const n=Fj(t);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=Fj(r.host).host);sy(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(n=>{const s=n.prototype.name;this.transports.push(s),this._transportsByName[s]=n}),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},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=zZ(this.opts.query)),Bj&&(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"})},Vx.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const r=Object.assign({},this.opts.query);r.EIO=N8,r.transport=t,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Rd.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(t);r.open(),this.setTransport(r)}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",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",Rd.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 r=new Error("server error");r.code=t.data,this._onError(r);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 r=1;for(let n=0;n<this.writeBuffer.length;n++){const s=this.writeBuffer[n].data;if(s&&(r+=OZ(s)),n>0&&r>this._maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ny(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,n){return this._sendPacket("message",t,r,n),this}send(t,r,n){return this._sendPacket("message",t,r,n),this}_sendPacket(t,r,n,s){if(typeof r=="function"&&(s=r,r=void 0),typeof n=="function"&&(s=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const a={type:t,data:r,options:n};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),s&&this.once("flush",s),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():t()}):this.upgrading?n():t()),this}_onError(t){if(Rd.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,r){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(),Bj&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=Vx.indexOf(this._offlineEventListener);n!==-1&&Vx.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}}Rd.protocol=N8;class ZZ extends Rd{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 r=this.createTransport(t),n=!1;Rd.priorWebsocketSuccess=!1;const s=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",f=>{if(!n)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Rd.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(u(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=r.name,this.emitReserved("upgradeError",h)}}))};function a(){n||(n=!0,u(),r.close(),r=null)}const o=f=>{const h=new Error("probe error: "+f);h.transport=r.name,a(),this.emitReserved("upgradeError",h)};function l(){o("transport closed")}function c(){o("socket closed")}function d(f){r&&f.name!==r.name&&a()}const u=()=>{r.removeListener("open",s),r.removeListener("error",o),r.removeListener("close",l),this.off("close",c),this.off("upgrading",d)};r.once("open",s),r.once("error",o),r.once("close",l),this.once("close",c),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{n||r.open()},200):r.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const r=[];for(let n=0;n<t.length;n++)~this.transports.indexOf(t[n])&&r.push(t[n]);return r}}let JZ=class extends ZZ{constructor(t,r={}){const n=typeof t=="object"?t:r;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(s=>HZ[s]).filter(s=>!!s)),super(t,n)}};function QZ(e,t="",r){let n=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),n=Fj(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const a=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+a+":"+n.port+t,n.href=n.protocol+"://"+a+(r&&r.port===n.port?"":":"+n.port),n}const eJ=typeof ArrayBuffer=="function",tJ=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,E8=Object.prototype.toString,rJ=typeof Blob=="function"||typeof Blob<"u"&&E8.call(Blob)==="[object BlobConstructor]",nJ=typeof File=="function"||typeof File<"u"&&E8.call(File)==="[object FileConstructor]";function IA(e){return eJ&&(e instanceof ArrayBuffer||tJ(e))||rJ&&e instanceof Blob||nJ&&e instanceof File}function Wx(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(Wx(e[r]))return!0;return!1}if(IA(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Wx(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&Wx(e[r]))return!0;return!1}function sJ(e){const t=[],r=e.data,n=e;return n.data=Vj(r,t),n.attachments=t.length,{packet:n,buffers:t}}function Vj(e,t){if(!e)return e;if(IA(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=Vj(e[n],t);return r}else if(typeof e=="object"&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=Vj(e[n],t));return r}return e}function iJ(e,t){return e.data=Wj(e.data,t),delete e.attachments,e}function Wj(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 r=0;r<e.length;r++)e[r]=Wj(e[r],t);else if(typeof e=="object")for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=Wj(e[r],t));return e}const aJ=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var br;(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"})(br||(br={}));class oJ{constructor(t){this.replacer=t}encode(t){return(t.type===br.EVENT||t.type===br.ACK)&&Wx(t)?this.encodeAsBinary({type:t.type===br.EVENT?br.BINARY_EVENT:br.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let r=""+t.type;return(t.type===br.BINARY_EVENT||t.type===br.BINARY_ACK)&&(r+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(r+=t.nsp+","),t.id!=null&&(r+=t.id),t.data!=null&&(r+=JSON.stringify(t.data,this.replacer)),r}encodeAsBinary(t){const r=sJ(t),n=this.encodeAsString(r.packet),s=r.buffers;return s.unshift(n),s}}class LA extends xs{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);const n=r.type===br.BINARY_EVENT;n||r.type===br.BINARY_ACK?(r.type=n?br.EVENT:br.ACK,this.reconstructor=new lJ(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(IA(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0;const n={type:Number(t.charAt(0))};if(br[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===br.BINARY_EVENT||n.type===br.BINARY_ACK){const a=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);const o=t.substring(a,r);if(o!=Number(o)||t.charAt(r)!=="-")throw new Error("Illegal attachments");const l=Number(o);if(!cJ(l)||l<0)throw new Error("Illegal attachments");if(l>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=l}if(t.charAt(r+1)==="/"){const a=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););n.nsp=t.substring(a,r)}else n.nsp="/";const s=t.charAt(r+1);if(s!==""&&Number(s)==s){const a=r+1;for(;++r;){const o=t.charAt(r);if(o==null||Number(o)!=o){--r;break}if(r===t.length)break}n.id=Number(t.substring(a,r+1))}if(t.charAt(++r)){const a=this.tryParse(t.substr(r));if(LA.isPayloadValid(n.type,a))n.data=a;else throw new Error("invalid payload")}return n}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case br.CONNECT:return e3(r);case br.DISCONNECT:return r===void 0;case br.CONNECT_ERROR:return typeof r=="string"||e3(r);case br.EVENT:case br.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&aJ.indexOf(r[0])===-1);case br.ACK:case br.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class lJ{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const r=iJ(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const cJ=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function e3(e){return Object.prototype.toString.call(e)==="[object Object]"}const dJ=Object.freeze(Object.defineProperty({__proto__:null,Decoder:LA,Encoder:oJ,get PacketType(){return br}},Symbol.toStringTag,{value:"Module"}));function Mo(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const uJ=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class _8 extends xs{constructor(t,r,n){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=r,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Mo(t,"open",this.onopen.bind(this)),Mo(t,"packet",this.onpacket.bind(this)),Mo(t,"error",this.onerror.bind(this)),Mo(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,...r){var n,s,a;if(uJ.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(r.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const o={type:br.EVENT,data:r};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const u=this.ids++,f=r.pop();this._registerAckCallback(u,f),o.id=u}const l=(s=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||s===void 0?void 0:s.writable,c=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!l||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,r){var n;const s=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(s===void 0){this.acks[t]=r;return}const a=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);r.call(this,new Error("operation has timed out"))},s),o=(...l)=>{this.io.clearTimeoutFn(a),r.apply(this,l)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...r){return new Promise((n,s)=>{const a=(o,l)=>o?s(o):n(l);a.withError=!0,r.push(a),this.emit(t,...r)})}_addToQueue(t){let r;typeof t[t.length-1]=="function"&&(r=t.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((s,...a)=>(this._queue[0],s!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(s)):(this._queue.shift(),r&&r(null,...a)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!t||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.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:br.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,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(n=>String(n.id)===t)){const n=this.acks[t];delete this.acks[t],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case br.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 br.EVENT:case br.BINARY_EVENT:this.onevent(t);break;case br.ACK:case br.BINARY_ACK:this.onack(t);break;case br.DISCONNECT:this.ondisconnect();break;case br.CONNECT_ERROR:this.destroy();const n=new Error(t.data.message);n.data=t.data.data,this.emitReserved("connect_error",n);break}}onevent(t){const r=t.data||[];t.id!=null&&r.push(this.ack(t.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.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 r=this;let n=!1;return function(...s){n||(n=!0,r.packet({type:br.ACK,id:t,data:s}))}}onack(t){const r=this.acks[t.id];typeof r=="function"&&(delete this.acks[t.id],r.withError&&t.data.unshift(null),r.apply(this,t.data))}onconnect(t,r){this.id=t,this.recovered=r&&this._pid===r,this._pid=r,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:br.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 r=this._anyListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,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 r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,t.data)}}}function gp(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}gp.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-r:e+r}return Math.min(e,this.max)|0};gp.prototype.reset=function(){this.attempts=0};gp.prototype.setMin=function(e){this.ms=e};gp.prototype.setMax=function(e){this.max=e};gp.prototype.setJitter=function(e){this.jitter=e};class Uj extends xs{constructor(t,r){var n;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(r=t,t=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,sy(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new gp({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=t;const s=r.parser||dJ;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=r.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 r;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(r=this.backoff)===null||r===void 0||r.setMin(t),this)}randomizationFactor(t){var r;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(r=this.backoff)===null||r===void 0||r.setJitter(t),this)}reconnectionDelayMax(t){var r;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(r=this.backoff)===null||r===void 0||r.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 JZ(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const s=Mo(r,"open",function(){n.onopen(),t&&t()}),a=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=Mo(r,"error",a);if(this._timeout!==!1){const l=this._timeout,c=this.setTimeoutFn(()=>{s(),a(new Error("timeout")),r.close()},l);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(s),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(Mo(t,"ping",this.onping.bind(this)),Mo(t,"data",this.ondata.bind(this)),Mo(t,"error",this.onerror.bind(this)),Mo(t,"close",this.onclose.bind(this)),Mo(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(r){this.onclose("parse error",r)}}ondecoded(t){ny(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,r){let n=this.nsps[t];return n?this._autoConnect&&!n.active&&n.connect():(n=new _8(this,t,r),this.nsps[t]=n),n}_destroy(t){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(t){const r=this.encoder.encode(t);for(let n=0;n<r.length;n++)this.engine.write(r[n],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,r){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,r),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 r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(s=>{s?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",s)):t.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const pm={};function Bm(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const r=QZ(e,t.path||"/socket.io"),n=r.source,s=r.id,a=r.path,o=pm[s]&&a in pm[s].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let c;return l?c=new Uj(n,t):(pm[s]||(pm[s]=new Uj(n,t)),c=pm[s]),r.query&&!t.query&&(t.query=r.queryKey),c.socket(r.path,t)}Object.assign(Bm,{Manager:Uj,Socket:_8,io:Bm,connect:Bm});function Vr(e){"@babel/helpers - typeof";return Vr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vr(e)}var Xo=Uint8Array,ba=Uint16Array,zA=Int32Array,DA=new Xo([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),MA=new Xo([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),t3=new Xo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),T8=function(e,t){for(var r=new ba(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var s=new zA(r[30]),n=1;n<30;++n)for(var a=r[n];a<r[n+1];++a)s[a]=a-r[n]<<5|n;return{b:r,r:s}},O8=T8(DA,2),fJ=O8.b,qj=O8.r;fJ[28]=258,qj[258]=28;var hJ=T8(MA,0),r3=hJ.r,Hj=new ba(32768);for(var Sn=0;Sn<32768;++Sn){var Pd=(Sn&43690)>>1|(Sn&21845)<<1;Pd=(Pd&52428)>>2|(Pd&13107)<<2,Pd=(Pd&61680)>>4|(Pd&3855)<<4,Hj[Sn]=((Pd&65280)>>8|(Pd&255)<<8)>>1}var Vm=(function(e,t,r){for(var n=e.length,s=0,a=new ba(t);s<n;++s)e[s]&&++a[e[s]-1];var o=new ba(t);for(s=1;s<t;++s)o[s]=o[s-1]+a[s-1]<<1;var l;if(r){l=new ba(1<<t);var c=15-t;for(s=0;s<n;++s)if(e[s])for(var d=s<<4|e[s],u=t-e[s],f=o[e[s]-1]++<<u,h=f|(1<<u)-1;f<=h;++f)l[Hj[f]>>c]=d}else for(l=new ba(n),s=0;s<n;++s)e[s]&&(l[s]=Hj[o[e[s]-1]++]>>15-e[s]);return l}),of=new Xo(288);for(var Sn=0;Sn<144;++Sn)of[Sn]=8;for(var Sn=144;Sn<256;++Sn)of[Sn]=9;for(var Sn=256;Sn<280;++Sn)of[Sn]=7;for(var Sn=280;Sn<288;++Sn)of[Sn]=8;var wv=new Xo(32);for(var Sn=0;Sn<32;++Sn)wv[Sn]=5;var pJ=Vm(of,9,0),mJ=Vm(wv,5,0),I8=function(e){return(e+7)/8|0},gJ=function(e,t,r){return(r==null||r>e.length)&&(r=e.length),new Xo(e.subarray(t,r))},kc=function(e,t,r){r<<=t&7;var n=t/8|0;e[n]|=r,e[n+1]|=r>>8},mm=function(e,t,r){r<<=t&7;var n=t/8|0;e[n]|=r,e[n+1]|=r>>8,e[n+2]|=r>>16},bw=function(e,t){for(var r=[],n=0;n<e.length;++n)e[n]&&r.push({s:n,f:e[n]});var s=r.length,a=r.slice();if(!s)return{t:z8,l:0};if(s==1){var o=new Xo(r[0].s+1);return o[r[0].s]=1,{t:o,l:1}}r.sort(function(A,P){return A.f-P.f}),r.push({s:-1,f:25001});var l=r[0],c=r[1],d=0,u=1,f=2;for(r[0]={s:-1,f:l.f+c.f,l,r:c};u!=s-1;)l=r[r[d].f<r[f].f?d++:f++],c=r[d!=u&&r[d].f<r[f].f?d++:f++],r[u++]={s:-1,f:l.f+c.f,l,r:c};for(var h=a[0].s,n=1;n<s;++n)a[n].s>h&&(h=a[n].s);var p=new ba(h+1),g=Kj(r[u-1],p,0);if(g>t){var n=0,v=0,x=g-t,b=1<<x;for(a.sort(function(P,E){return p[E.s]-p[P.s]||P.f-E.f});n<s;++n){var j=a[n].s;if(p[j]>t)v+=b-(1<<g-p[j]),p[j]=t;else break}for(v>>=x;v>0;){var N=a[n].s;p[N]<t?v-=1<<t-p[N]++-1:++n}for(;n>=0&&v;--n){var w=a[n].s;p[w]==t&&(--p[w],++v)}g=t}return{t:new Xo(p),l:g}},Kj=function(e,t,r){return e.s==-1?Math.max(Kj(e.l,t,r+1),Kj(e.r,t,r+1)):t[e.s]=r},n3=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new ba(++t),n=0,s=e[0],a=1,o=function(c){r[n++]=c},l=1;l<=t;++l)if(e[l]==s&&l!=t)++a;else{if(!s&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(s),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(s);a=1,s=e[l]}return{c:r.subarray(0,n),n:t}},gm=function(e,t){for(var r=0,n=0;n<t.length;++n)r+=e[n]*t[n];return r},L8=function(e,t,r){var n=r.length,s=I8(t+2);e[s]=n&255,e[s+1]=n>>8,e[s+2]=e[s]^255,e[s+3]=e[s+1]^255;for(var a=0;a<n;++a)e[s+a+4]=r[a];return(s+4+n)*8},s3=function(e,t,r,n,s,a,o,l,c,d,u){kc(t,u++,r),++s[256];for(var f=bw(s,15),h=f.t,p=f.l,g=bw(a,15),v=g.t,x=g.l,b=n3(h),j=b.c,N=b.n,w=n3(v),A=w.c,P=w.n,E=new ba(19),T=0;T<j.length;++T)++E[j[T]&31];for(var T=0;T<A.length;++T)++E[A[T]&31];for(var C=bw(E,7),I=C.t,_=C.l,L=19;L>4&&!I[t3[L-1]];--L);var $=d+5<<3,z=gm(s,of)+gm(a,wv)+o,R=gm(s,h)+gm(a,v)+o+14+3*L+gm(E,I)+2*E[16]+3*E[17]+7*E[18];if(c>=0&&$<=z&&$<=R)return L8(t,u,e.subarray(c,c+d));var J,Z,q,Y;if(kc(t,u,1+(R<z)),u+=2,R<z){J=Vm(h,p,0),Z=h,q=Vm(v,x,0),Y=v;var de=Vm(I,_,0);kc(t,u,N-257),kc(t,u+5,P-1),kc(t,u+10,L-4),u+=14;for(var T=0;T<L;++T)kc(t,u+3*T,I[t3[T]]);u+=3*L;for(var H=[j,A],M=0;M<2;++M)for(var V=H[M],T=0;T<V.length;++T){var U=V[T]&31;kc(t,u,de[U]),u+=I[U],U>15&&(kc(t,u,V[T]>>5&127),u+=V[T]>>12)}}else J=pJ,Z=of,q=mJ,Y=wv;for(var T=0;T<l;++T){var F=n[T];if(F>255){var U=F>>18&31;mm(t,u,J[U+257]),u+=Z[U+257],U>7&&(kc(t,u,F>>23&31),u+=DA[U]);var se=F&31;mm(t,u,q[se]),u+=Y[se],se>3&&(mm(t,u,F>>5&8191),u+=MA[se])}else mm(t,u,J[F]),u+=Z[F]}return mm(t,u,J[256]),u+Z[256]},xJ=new zA([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),z8=new Xo(0),vJ=function(e,t,r,n,s,a){var o=a.z||e.length,l=new Xo(n+o+5*(1+Math.ceil(o/7e3))+s),c=l.subarray(n,l.length-s),d=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var f=xJ[t-1],h=f>>13,p=f&8191,g=(1<<r)-1,v=a.p||new ba(32768),x=a.h||new ba(g+1),b=Math.ceil(r/3),j=2*b,N=function(ke){return(e[ke]^e[ke+1]<<b^e[ke+2]<<j)&g},w=new zA(25e3),A=new ba(288),P=new ba(32),E=0,T=0,C=a.i||0,I=0,_=a.w||0,L=0;C+2<o;++C){var $=N(C),z=C&32767,R=x[$];if(v[z]=R,x[$]=z,_<=C){var J=o-C;if((E>7e3||I>24576)&&(J>423||!d)){u=s3(e,c,0,w,A,P,T,I,L,C-L,u),I=E=T=0,L=C;for(var Z=0;Z<286;++Z)A[Z]=0;for(var Z=0;Z<30;++Z)P[Z]=0}var q=2,Y=0,de=p,H=z-R&32767;if(J>2&&$==N(C-H))for(var M=Math.min(h,J)-1,V=Math.min(32767,C),U=Math.min(258,J);H<=V&&--de&&z!=R;){if(e[C+q]==e[C+q-H]){for(var F=0;F<U&&e[C+F]==e[C+F-H];++F);if(F>q){if(q=F,Y=H,F>M)break;for(var se=Math.min(H,F-2),ue=0,Z=0;Z<se;++Z){var re=C-H+Z&32767,ee=v[re],ie=re-ee&32767;ie>ue&&(ue=ie,R=re)}}}z=R,R=v[z],H+=z-R&32767}if(Y){w[I++]=268435456|qj[q]<<18|r3[Y];var xe=qj[q]&31,fe=r3[Y]&31;T+=DA[xe]+MA[fe],++A[257+xe],++P[fe],_=C+q,++E}else w[I++]=e[C],++A[e[C]]}}for(C=Math.max(C,_);C<o;++C)w[I++]=e[C],++A[e[C]];u=s3(e,c,d,w,A,P,T,I,L,C-L,u),d||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=x,a.p=v,a.i=C,a.w=_)}else{for(var C=a.w||0;C<o+d;C+=65535){var Ee=C+65535;Ee>=o&&(c[u/8|0]=d,Ee=o),u=L8(c,u+1,e.subarray(C,Ee))}a.i=o}return gJ(l,0,n+I8(u)+s)},D8=function(){var e=1,t=0;return{p:function(r){for(var n=e,s=t,a=r.length|0,o=0;o!=a;){for(var l=Math.min(o+2655,a);o<l;++o)s+=n+=r[o];n=(n&65535)+15*(n>>16),s=(s&65535)+15*(s>>16)}e=n,t=s},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},bJ=function(e,t,r,n,s){if(!s&&(s={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new Xo(a.length+e.length);o.set(a),o.set(e,a.length),e=o,s.w=a.length}return vJ(e,t.level==null?6:t.level,t.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,r,n,s)},M8=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},yJ=function(e,t){var r=t.level,n=r==0?0:r<6?1:r==9?3:2;if(e[0]=120,e[1]=n<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var s=D8();s.p(t.dictionary),M8(e,2,s.d())}};function Gj(e,t){t||(t={});var r=D8();r.p(e);var n=bJ(e,t,t.dictionary?6:2,4);return yJ(n,t),M8(n,n.length-4,r.d()),n}var wJ=typeof TextDecoder<"u"&&new TextDecoder,jJ=0;try{wJ.decode(z8,{stream:!0}),jJ=1}catch{}function NJ(e){if(Array.isArray(e))return e}function SJ(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,s,a,o,l=[],c=!0,d=!1;try{if(a=(r=r.call(e)).next,t!==0)for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(u){d=!0,s=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw s}}return l}}function i3(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function AJ(e,t){if(e){if(typeof e=="string")return i3(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i3(e,t):void 0}}function PJ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
20
+ 在此输入您的具体内容讲解、白板图形绘制节点、以及课后实践任务大纲...`:"# Course curriculum content",className:"w-full flex-grow p-4 bg-slate-900 text-slate-100 border border-slate-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-indigo-500 font-mono text-xs shadow-inner leading-relaxed text-left"})]}),i.jsxs("div",{className:"space-y-3 flex flex-col h-full border border-gray-150 rounded-xl bg-slate-50/50 p-4 text-left",children:[i.jsxs("span",{className:"block text-xs font-bold text-gray-400 uppercase tracking-wider select-none shrink-0",children:["🖥️ ",n==="zh"?"大纲资料实时交互渲染":"Syllabus Live Context rendering"]}),i.jsx("div",{className:"flex-grow overflow-y-auto bg-white border border-gray-150 rounded-lg p-4 text-xs font-sans text-gray-700 max-h-[380px] overflow-x-hidden text-left select-text",children:v.trim()?i.jsx("div",{className:"markdown-body",children:i.jsx(jf,{children:v})}):i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-400 italic py-16",children:[i.jsx(Pn,{size:32,className:"mb-2 opacity-20 text-indigo-500"}),i.jsx("span",{children:n==="zh"?"教案空无内容,等待输入或一键填充模板...":"Waiting for materials..."})]})})]})]}),s===4&&i.jsxs("div",{className:"space-y-6 animate-in fade-in duration-200 text-center font-sans max-w-xl mx-auto py-3",children:[i.jsx("div",{className:"inline-flex p-3 bg-emerald-50 border border-emerald-100 text-emerald-500 rounded-full",children:i.jsx(Qr,{size:36,className:"animate-pulse text-emerald-555"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-extrabold text-gray-800 text-base md:text-lg",children:n==="zh"?"🚀 互动课程已精心筹备成功!":"🚀 Materials Generated successfully!"}),i.jsx("p",{className:"text-xs text-gray-400 mt-1",children:n==="zh"?"设计与时间轴逻辑全部检验合格。请在下方核验新课卡片,确认无误一键部署入 SQLite 内核数据库。":"Curriculum parameters are ready to boot inside the Secure Host."})]}),i.jsxs("div",{className:"border border-indigo-200 rounded-2xl p-5 bg-linear-to-b from-indigo-50/20 to-white shadow-md text-left space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-indigo-50 pb-3 gap-2",children:[i.jsx("div",{className:"font-bold text-indigo-950 text-base sm:text-lg truncate",children:l||(n==="zh"?"未指定课程主题":"Blank Topic")}),i.jsx("span",{className:"inline-flex px-2 py-0.5 rounded text-[10px] font-extrabold bg-indigo-50 text-indigo-800 uppercase tracking-wide border border-indigo-150 shrink-0",children:f})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4 text-xs",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-400 block tracking-wider text-[10px] font-bold",children:n==="zh"?"教研环节数":"TOTAL STEPS"}),i.jsxs("span",{className:"text-gray-800 font-extrabold text-sm block mt-1",children:[p.length," ",n==="zh"?"项教学环节":"slots"]})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-400 block tracking-wider text-[10px] font-bold",children:n==="zh"?"发布载体引擎":"STORAGE MEDIUM"}),i.jsxs("div",{className:"flex items-center gap-1 text-emerald-650 font-extrabold text-sm mt-1",children:[i.jsx(Ol,{size:11,className:"text-emerald-500"}),i.jsx("span",{children:"SQLite DB"})]})]})]}),i.jsx("div",{className:"bg-slate-50 border border-gray-150 p-3 rounded-lg text-[11px] text-gray-600 line-clamp-2 italic leading-relaxed text-left",children:d||(n==="zh"?"无科目描述内容":"No description written.")}),i.jsxs("div",{className:"space-y-1.5 select-none",children:[i.jsx("span",{className:"text-[10px] font-extrabold text-gray-400 uppercase tracking-wider block",children:n==="zh"?"教学时间轴环流预览":"TIMELINE PROGRESS OVERVIEW"}),i.jsx("div",{className:"flex items-center gap-1 w-full overflow-x-auto py-1",children:p.map((w,A)=>i.jsxs(m.Fragment,{children:[i.jsxs("div",{className:`px-2 py-1 text-[10px] font-bold rounded border truncate max-w-[120px] ${w.color.split(" ")[0]}`,children:[w.title.split(" / ")[0]," (",w.duration,")"]}),A<p.length-1&&i.jsx(ys,{size:11,className:"text-gray-300"})]},w.id))})]})]})]})]}),i.jsxs("div",{className:"p-4 border-t border-gray-105 bg-slate-50 flex justify-between items-center shrink-0",children:[i.jsx("span",{className:"text-[11px] font-bold font-mono text-gray-400 uppercase select-none",children:n==="zh"?"⚙️ SQLITE 写入预检通过":"⚙️ SQLITE VERIFICATION SUCCESS"}),i.jsxs("div",{className:"flex items-center gap-2",children:[s>1&&i.jsx("button",{type:"button",onClick:()=>a(w=>w-1),disabled:o,className:"px-4 py-2 text-xs font-semibold border border-gray-200 text-gray-700 bg-white hover:bg-gray-50 rounded-lg transition-colors cursor-pointer select-none",children:n==="zh"?"上一步":"Back"}),s<4?i.jsx("button",{type:"button",onClick:()=>{if(s===1&&!l.trim()){alert(n==="zh"?"请输入课程课题名称!":"Please type course title to proceed.");return}a(w=>w+1)},className:"px-4.5 py-2 text-xs font-bold bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg shadow-sm flex items-center gap-1 cursor-pointer select-none",children:n==="zh"?"继续前进":"Continue"}):i.jsx("button",{type:"button",onClick:N,disabled:o,className:"px-5 py-2 text-xs font-bold bg-emerald-600 hover:bg-emerald-700 text-white rounded-lg shadow-md flex items-center gap-1.5 cursor-pointer disabled:opacity-50 select-none animate-bounce",children:o?i.jsxs(i.Fragment,{children:[i.jsx(Sr,{size:13,className:"animate-spin"}),i.jsx("span",{children:n==="zh"?"写入底库中...":"Deploying..."})]}):i.jsxs(i.Fragment,{children:[i.jsx(Ol,{size:13}),i.jsx("span",{children:n==="zh"?"部署并激活新课程":"Deploy & Activate"})]})})]})]})]})})})}function lZ(e){const{isImportLessonsOpen:t,setIsImportLessonsOpen:r,lang:n,importStatus:s,setIsDraggingImport:a,handleCSVFileChange:o,downloadCsvTemplate:l,isDraggingImport:c,previewImportData:d,setPreviewImportData:u,setImportStatus:f,importProgress:h,importProgressTotal:p,importErrorMsg:g,setImportErrorMsg:v,handleCSVImportSubmit:x}=e;return i.jsx(i.Fragment,{children:t&&i.jsx("div",{className:"fixed inset-0 bg-gray-900/50 backdrop-blur-sm flex items-center justify-center p-4 md:p-6 z-50 overflow-y-auto text-gray-850",children:i.jsxs(Fi.div,{initial:{opacity:0,y:15,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98},className:"bg-white border text-gray-900 border-gray-250 rounded-2xl shadow-2xl w-full max-w-2xl flex flex-col overflow-hidden max-h-[90vh] font-sans text-left",children:[i.jsxs("div",{className:"p-4 md:p-5 border-b border-gray-100 flex items-center justify-between bg-slate-50 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-indigo-50 border border-indigo-100 rounded-lg text-indigo-650",children:i.jsx(Na,{size:20,className:"animate-pulse"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-bold text-gray-850 text-base md:text-lg",children:n==="zh"?"批量导入课程 (CSV)":"Bulk-Import Courses (CSV)"}),i.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:n==="zh"?"上传包含标准表头的 CSV 教案,一键实现秒级批量底库写入。":"Upload a standard CSV file matching our predefined schema to perform instantaneous bulk curriculum imports."})]})]}),i.jsx("button",{onClick:()=>{s!=="importing"&&r(!1)},disabled:s==="importing",className:"text-gray-400 hover:text-gray-650 font-bold p-1 rounded-lg hover:bg-gray-150 transition-all text-xl leading-none disabled:opacity-40",children:"×"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[s==="idle"&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"p-4 bg-indigo-50/50 border border-indigo-100 rounded-xl",children:[i.jsxs("h4",{className:"text-xs font-bold text-indigo-850 uppercase tracking-wide flex items-center gap-1",children:[i.jsx("span",{children:"📌"}),n==="zh"?"预定义数据格式说明":"Predefined Schema Information"]}),i.jsx("p",{className:"text-xs text-indigo-900 mt-1 leading-relaxed",children:n==="zh"?"CSV 文件的首行必须 define 列标题(分大小写且无多余空格),包含以下两项必需内容:":"Your CSV file must include exactly these header columns on the first row (case-insensitive):"}),i.jsxs("ul",{className:"list-disc pl-5 mt-2 text-xs text-indigo-950 space-y-1",children:[i.jsxs("li",{children:[i.jsx("strong",{children:"title"}),": ",n==="zh"?'课程名 (非空,例如 "代数几何")':'Course title (Required, e.g. "Linear Algebra")']}),i.jsxs("li",{children:[i.jsx("strong",{children:"content"}),": ",n==="zh"?"教学大纲 / Markdown 格式的课堂细目":"Syllabus content supporting rich markdown."]})]}),i.jsx("div",{className:"mt-3.5 flex justify-start",children:i.jsxs("button",{onClick:l,className:"flex items-center gap-1 p-2 text-xs font-bold text-indigo-700 bg-white border border-indigo-200 rounded-lg shadow-3xs hover:bg-indigo-50 hover:-translate-y-0.5 hover:shadow-xs transition-all cursor-pointer",children:[i.jsx(Md,{size:12}),n==="zh"?"获取标准 CSV 模板":"Download Template CSV"]})})]}),i.jsxs("div",{onDragOver:b=>{b.preventDefault(),a(!0)},onDragLeave:()=>a(!1),onDrop:b=>{b.preventDefault(),a(!1),b.dataTransfer.files&&b.dataTransfer.files[0]&&o(b.dataTransfer.files[0])},onClick:()=>{document.getElementById("import-csv-file-picker")?.click()},className:`border-2 border-dashed rounded-2xl p-8 text-center cursor-pointer transition-all flex flex-col items-center justify-center min-h-[180px] ${c?"border-indigo-500 bg-indigo-50/70 scale-[1.01]":"border-gray-250 bg-gray-50/50 hover:bg-gray-50 hover:border-indigo-400"}`,children:[i.jsx("input",{id:"import-csv-file-picker",type:"file",accept:".csv",className:"hidden",onChange:b=>{b.target.files&&b.target.files[0]&&o(b.target.files[0])}}),i.jsx("div",{className:"p-3 bg-gray-100 border border-gray-200 rounded-full text-indigo-600 mb-3 group-hover:scale-105 transition-all",children:i.jsx(Na,{size:24})}),i.jsx("span",{className:"text-sm font-bold text-gray-800",children:n==="zh"?"选择 CSV 文件或拖放至此处":"Click to select or drag and drop CSV file here"}),i.jsx("span",{className:"text-xs text-gray-400 mt-1",children:n==="zh"?"支持标准 CSV 文件,最大不超过 5MB":"Supports standard CSV format up to 5MB"})]})]}),s==="parsing"&&d.length>0&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"text-xs font-bold text-emerald-600 bg-emerald-50 border border-emerald-200 px-2.5 py-1 rounded-full",children:["✓ ",n==="zh"?`解析成功:查找到 ${d.length} 门课程`:`Parsed Successfully: Found ${d.length} records`]}),i.jsx("button",{onClick:()=>{u([]),f("idle")},className:"text-xs text-indigo-600 hover:text-indigo-800 font-semibold",children:n==="zh"?"重新上传":"Upload Different File"})]}),i.jsx("div",{className:"border border-gray-200 rounded-xl overflow-hidden shadow-3xs max-h-[300px] overflow-y-auto",children:i.jsxs("table",{className:"w-full text-left text-xs border-collapse",children:[i.jsx("thead",{className:"bg-gray-50 text-gray-600 border-b border-gray-200 font-bold",children:i.jsxs("tr",{children:[i.jsx("th",{className:"p-3 w-1/4",children:n==="zh"?"课程名称":"Course Title"}),i.jsx("th",{className:"p-3 w-3/4",children:n==="zh"?"大纲简介片段":"Syllabus Preview"})]})}),i.jsx("tbody",{className:"divide-y divide-gray-100 bg-white",children:d.map((b,j)=>i.jsxs("tr",{className:"hover:bg-slate-50/50",children:[i.jsx("td",{className:"p-3 font-semibold text-gray-800 align-top truncate max-w-[150px]",title:b.title,children:b.title}),i.jsx("td",{className:"p-3 text-gray-500 font-mono text-[11px] leading-relaxed break-words col-span-2",children:b.content.length>150?b.content.substring(0,150)+"...":b.content||i.jsx("em",{className:"text-gray-300 italic",children:"None"})})]},j))})]})}),i.jsxs("div",{className:"bg-amber-50 border border-amber-100 text-amber-900 text-xs rounded-xl p-3 flex gap-2.5 items-start",children:[i.jsx("span",{className:"text-base leading-none",children:"⚠️"}),i.jsx("p",{className:"leading-relaxed",children:n==="zh"?'请确认课程名称没有与系统已有的课程同名。确认无误后点击下方"开始导入"写入 SQLite。':"Please ensure column details are accurate. Clicking Import will instantly commit all parsed courses into the server SQLite backend."})]})]}),s==="importing"&&i.jsxs("div",{className:"py-8 flex flex-col items-center justify-center space-y-4",children:[i.jsxs("div",{className:"relative w-20 h-20 flex items-center justify-center",children:[i.jsx(Sr,{size:36,className:"text-indigo-600 animate-spin"}),i.jsxs("span",{className:"absolute text-[11px] font-extrabold text-indigo-700",children:[Math.round(h/p*100),"%"]})]}),i.jsxs("div",{className:"text-center",children:[i.jsx("h3",{className:"font-bold text-gray-800 text-sm",children:n==="zh"?"正在写入数据库":"Populating Database Records"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n==="zh"?`正在导入第 ${h} / ${p} 项...`:`Importing item ${h} of ${p}...`})]}),i.jsx("div",{className:"w-full max-w-sm bg-gray-100 h-2 rounded-full overflow-hidden border border-gray-200",children:i.jsx("div",{className:"bg-indigo-600 h-full transition-all duration-300 rounded-full",style:{width:`${h/p*100}%`}})}),i.jsxs("div",{className:"w-full max-w-md bg-gray-50 rounded-xl p-3 border border-gray-150 font-mono text-[10px] text-gray-400 max-h-[140px] overflow-y-auto",children:[i.jsx("div",{children:"[API] POST /api/lessons -> Request batch transaction..."}),d.slice(0,h).map((b,j)=>i.jsx("div",{className:"text-indigo-600 font-bold mt-1",children:`✓ [${j+1}] "${b.title}" -> status 200 (Success)`},j))]})]}),s==="success"&&i.jsxs("div",{className:"py-8 text-center flex flex-col items-center justify-center space-y-4",children:[i.jsx("div",{className:"w-16 h-16 bg-emerald-50 rounded-full flex items-center justify-center border border-emerald-200 text-emerald-600 animate-bounce",children:i.jsx(Qr,{size:32})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-bold text-gray-800 text-base",children:n==="zh"?"🎉 批量导入大功告成":"🎉 Bulk-Import Complete"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1 max-w-md mx-auto",children:n==="zh"?`所有 ${d.length} 门学科教案数据已顺畅写入系统底层 SQLite 数据仓库,现在已可以用于备课。`:`All ${d.length} curriculum lessons records have been successfully saved into security logs and SQLite storage.`})]})]}),s==="error"&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"p-4 bg-rose-50 border border-rose-100 rounded-xl flex gap-3 items-start",children:[i.jsx("span",{className:"text-rose-600 font-bold text-lg leading-none",children:"⚠️"}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-xs font-bold text-rose-850",children:n==="zh"?"数据导入或解析中断":"Import or Parsing Error"}),i.jsx("p",{className:"text-xs text-rose-900 mt-1 leading-relaxed",children:g||(n==="zh"?"未知异常或文件破损。":"An unknown exception or corrupted CSV formatting occurred.")})]})]}),i.jsxs("div",{className:"flex gap-3 justify-end",children:[i.jsx("button",{onClick:()=>{f("idle"),v("")},className:"px-4 py-2 text-xs font-bold text-gray-700 bg-white border border-gray-250 cursor-pointer hover:bg-gray-50 rounded-lg transition-all",children:n==="zh"?"返回重试":"Go Back & Retry"}),i.jsx("button",{onClick:()=>r(!1),className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 cursor-pointer hover:bg-indigo-700 rounded-lg transition-all",children:n==="zh"?"关闭窗口":"Close"})]})]})]}),s!=="idle"&&s!=="error"&&i.jsxs("div",{className:"p-4 md:p-5 border-t border-gray-100 flex items-center justify-between bg-slate-50 shrink-0",children:[i.jsx("button",{onClick:()=>{u([]),f("idle")},disabled:s==="importing",className:"px-4 py-2 text-xs font-bold text-gray-650 bg-white border border-gray-200 hover:bg-gray-100 rounded-lg transition-all disabled:opacity-40 cursor-pointer",children:n==="zh"?"重置重选":"Reset & Clear"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>r(!1),disabled:s==="importing",className:"px-4 py-2 text-xs font-bold text-gray-600 hover:text-gray-800 transition-all disabled:opacity-40 cursor-pointer",children:n==="zh"?"取消":"Cancel"}),s==="parsing"&&i.jsxs("button",{onClick:x,className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg shadow-sm transition-all flex items-center gap-1 cursor-pointer",children:[i.jsx(Bs,{size:12}),n==="zh"?`开始导入 (${d.length} 类)`:`Proceed and Import (${d.length})`]}),s==="success"&&i.jsx("button",{onClick:()=>r(!1),className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 rounded-lg shadow-sm transition-all cursor-pointer",children:n==="zh"?"完成":"Done"})]})]})]})})})}function cZ(e){const{isQuizGeneratorOpen:t,setIsQuizGeneratorOpen:r,lessons:n,quizGenMode:s,setQuizGenMode:a,quizGenSelectedLessonId:o,setQuizGenSelectedLessonId:l,quizGenTopic:c,setQuizGenTopic:d,isGeneratingSuggestions:u,setIsGeneratingSuggestions:f,suggestedObjectives:h,setSuggestedObjectives:p,suggestedQuestions:g,setSuggestedQuestions:v,quizGenTimeLimit:x,setQuizGenTimeLimit:b,savingQuiz:j,setSavingQuiz:N,quizGeneratorClassId:w,fetchClassDashboard:A}=e;return i.jsx(i.Fragment,{children:t&&i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50 overflow-y-auto text-gray-850",children:i.jsxs(Fi.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-3xl flex flex-col overflow-hidden max-h-[90vh]",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ea,{className:"text-indigo-600 animate-pulse",size:20}),i.jsx("h2",{className:"font-bold text-gray-800 text-lg",children:"AI-Objective Quiz Generator"})]}),i.jsx("button",{onClick:()=>r(!1),className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors",children:"×"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[g.length===0&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"bg-indigo-50/80 p-4 rounded-xl border border-indigo-100 text-xs text-indigo-800 leading-relaxed font-sans",children:"Choose a lesson to scan. Our advanced AI model will run a deep semantic scan across the entire lesson curriculum content, discover your core learning objectives, and construct interactive multiple-choice questions aligning precisely with each of them."}),i.jsxs("div",{className:"font-sans",children:[i.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Scan Core Selection Mode"}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("button",{onClick:()=>a("scan_lesson"),className:`p-3 rounded-lg border text-left flex flex-col transition-all ${s==="scan_lesson"?"border-indigo-600 bg-indigo-50/40 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,children:[i.jsx("span",{className:"font-semibold text-sm text-indigo-900",children:"Curriculum Lesson Scanning"}),i.jsx("span",{className:"text-[10px] text-gray-500 mt-1",children:"Examines real Markdown content inside virtual lesson modules."})]}),i.jsxs("button",{onClick:()=>a("topic"),className:`p-3 rounded-lg border text-left flex flex-col transition-all ${s==="topic"?"border-indigo-600 bg-indigo-50/40 ring-2 ring-indigo-100":"border-gray-200 hover:border-gray-300"}`,children:[i.jsx("span",{className:"font-semibold text-sm text-indigo-900",children:"Custom Keyword / Topic"}),i.jsx("span",{className:"text-[10px] text-gray-500 mt-1",children:"Provide a custom prompt keyword or objective manually."})]})]})]}),s==="scan_lesson"?i.jsxs("div",{className:"font-sans",children:[i.jsx("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2",children:"Select Lesson to Scan"}),n.length===0?i.jsx("div",{className:"text-gray-500 text-xs py-3 border rounded border-dashed text-center",children:"No lessons available. Please create a lesson first."}):i.jsxs("select",{value:o,onChange:P=>l(P.target.value),className:"w-full p-2.5 bg-white border border-gray-200 rounded-lg text-sm text-gray-800 focus:border-indigo-500 focus:outline-none shadow-sm",children:[i.jsx("option",{value:"",children:"-- Choose a lesson --"}),n.map(P=>i.jsx("option",{value:P.id,children:P.title},P.id))]})]}):i.jsxs("div",{className:"font-sans",children:[i.jsx("label",{className:"block text-xs font-semibold text-gray-505 uppercase tracking-wider mb-2",children:"Custom Topic Prompt"}),i.jsx("input",{type:"text",placeholder:"e.g. Introduction to React state, Cloud SQL setup...",value:c,onChange:P=>d(P.target.value),className:"w-full p-2.5 bg-white border border-gray-200 rounded-lg text-sm focus:border-indigo-500 focus:outline-none shadow-sm text-gray-800"})]}),i.jsx("div",{className:"pt-4 flex justify-end font-sans",children:i.jsx("button",{disabled:u||s==="scan_lesson"&&!o||s==="topic"&&!c.trim(),onClick:async()=>{f(!0);try{if(s==="scan_lesson"){const P=await fetch(`/api/classes/${w}/assignments/suggest`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:o})});if(P.ok){const E=await P.json();p(E.learningObjectives||[]),v((E.questions||[]).map(T=>({...T,selected:!0})))}else alert("Error generating suggestions. Please make sure the selected lesson has content.")}else(await fetch(`/api/classes/${w}/assignments/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({topic:c})})).ok?(await A(w),r(!1)):alert("Error generating topic quiz.")}catch(P){console.error(P),alert(P.message)}finally{f(!1)}},className:"px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 text-white rounded-lg font-medium text-xs shadow transition flex items-center gap-2",children:u?i.jsxs(i.Fragment,{children:[i.jsx(Sr,{size:16,className:"animate-spin"}),i.jsx("span",{children:"AI Scanning Content..."})]}):i.jsxs(i.Fragment,{children:[i.jsx(ea,{size:16}),i.jsx("span",{children:"Generate Key MCQ Quiz"})]})})})]}),g.length>0&&i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"font-sans",children:[i.jsx("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-2",children:"Identified Core Objectives"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:h.map((P,E)=>i.jsxs("span",{className:"px-2.5 py-1 bg-teal-50 text-teal-800 border border-teal-200 rounded-full text-xs font-semibold",children:["🎯 ",P]},E))})]}),i.jsxs("div",{className:"space-y-4 font-sans",children:[i.jsx("div",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider font-semibold",children:"Suggested MCQ Questions"}),i.jsx("div",{className:"space-y-3",children:g.map((P,E)=>i.jsxs("div",{className:"p-4 rounded-xl border border-gray-150 bg-gray-50/50 hover:bg-gray-50 transition space-y-3 text-gray-800 text-gray-850",children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-5 h-5 rounded-full bg-indigo-150 text-indigo-700 flex items-center justify-center text-xs font-bold shrink-0",children:E+1}),i.jsxs("span",{className:"text-[10px] font-semibold text-teal-700 bg-teal-50 px-2.5 py-0.5 rounded border border-teal-100",children:["objective: ",P.objective]})]}),i.jsx("input",{type:"checkbox",checked:!!P.selected,onChange:T=>{const C=[...g];C[E].selected=T.target.checked,v(C)},className:"w-4 h-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500"})]}),i.jsx("p",{className:"font-semibold text-gray-800 text-sm leading-relaxed",children:P.question}),i.jsx("div",{className:"grid grid-cols-2 gap-2 text-xs",children:P.options.map((T,C)=>{const I=T===P.correctAnswer;return i.jsxs("div",{className:`p-2 rounded border flex items-center justify-between ${I?"bg-green-50 border-green-200 text-green-955 font-semibold":"bg-white border-gray-100 text-gray-700"}`,children:[i.jsx("span",{children:T}),I&&i.jsx(Qr,{size:12,className:"text-green-600 shrink-0"})]},C)})})]},E))})]}),i.jsxs("div",{className:"pt-4 border-t border-gray-100 flex justify-between items-center font-sans",children:[i.jsx("button",{onClick:()=>{p([]),v([])},className:"px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg text-xs font-semibold transition",children:"Back / Scan New"}),i.jsxs("div",{className:"flex items-center gap-2 border border-indigo-150 bg-indigo-50/50 px-3 py-1.5 rounded-lg text-xs font-semibold text-indigo-900",children:[i.jsx("span",{children:"⏱️ Quiz Time Limit:"}),i.jsxs("select",{value:x,onChange:P=>b(Number(P.target.value)),className:"bg-transparent text-xs text-indigo-950 font-bold focus:outline-none cursor-pointer",children:[i.jsx("option",{className:"text-gray-800",value:0,children:"No Limit"}),i.jsx("option",{className:"text-gray-800",value:1,children:"1 Min"}),i.jsx("option",{className:"text-gray-800",value:2,children:"2 Mins"}),i.jsx("option",{className:"text-gray-800",value:5,children:"5 Mins"}),i.jsx("option",{className:"text-gray-800",value:10,children:"10 Mins"}),i.jsx("option",{className:"text-gray-800",value:15,children:"15 Mins"}),i.jsx("option",{className:"text-gray-800",value:20,children:"20 Mins"}),i.jsx("option",{className:"text-gray-800",value:30,children:"30 Mins"}),i.jsx("option",{className:"text-gray-800",value:45,children:"45 Mins"}),i.jsx("option",{className:"text-gray-800",value:60,children:"60 Mins"})]})]}),i.jsxs("button",{disabled:j||g.filter(P=>P.selected).length===0,onClick:async()=>{N(!0);try{const P=n.find(C=>C.id===o),E=P?P.title:c||"Custom Objective";(await fetch(`/api/classes/${w}/assignments/create-suggested-quiz`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:`MCQ Evaluation: ${E}`,description:"Automatic evaluation based on core learning objectives.",questions:g.filter(C=>C.selected).map(({selected:C,...I})=>I),learningObjectives:h,timeLimit:x})})).ok?(await A(w),r(!1)):alert("Failed to save suggested quiz.")}catch(P){console.error(P),alert(P.message)}finally{N(!1)}},className:"px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-medium text-xs shadow hover:shadow-md transition flex items-center gap-2",children:[j?i.jsx(Sr,{size:16,className:"animate-spin"}):i.jsx(Qr,{size:16}),i.jsx("span",{children:"Create Assessment Quiz"})]})]})]})]})]})})})}const dZ=m.lazy(()=>_h(()=>import("./whiteboard-Dp8tFXTO.js").then(e=>e.bb),__vite__mapDeps([0])).then(e=>({default:e.InteractiveWhiteboard}))),V0=m.forwardRef((e,t)=>i.jsx(m.Suspense,{fallback:i.jsx("div",{className:"flex items-center justify-center h-full bg-gray-50",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-500"})}),children:i.jsx(dZ,{ref:t,...e})})),uZ=m.lazy(()=>_h(()=>import("./courseware-CL7gjXZj.js").then(e=>e.i),__vite__mapDeps([0])).then(e=>({default:e.CoursewareViewer})));function EA(e){return i.jsx(m.Suspense,{fallback:i.jsx("div",{className:"flex items-center justify-center h-full bg-gray-50",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-500"})}),children:i.jsx(uZ,{...e})})}function fZ(e){const{isLessonPreviewVisible:t,setIsLessonPreviewVisible:r,lessons:n,selectedLesson:s,previewFullscreenPanel:a,setPreviewFullscreenPanel:o,previewLessonTab:l,setPreviewLessonTab:c,activeRole:d,elements:u,activeSegmentId:f,setActiveSegmentId:h,fetchElements:p,currentVfsParent:g,setCurrentVfsParent:v,vfsNodes:x,previewSelectedCourseware:b,setPreviewSelectedCourseware:j}=e;return i.jsx(i.Fragment,{children:t&&i.jsx("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm flex items-center justify-center p-4 md:p-6 z-[60] overflow-hidden text-gray-850",children:i.jsxs(Fi.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-7xl h-[90vh] flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-indigo-50/70 shrink-0 select-none",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"bg-indigo-600 text-white p-2 rounded-lg shadow-sm",children:i.jsx(dp,{size:18})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-bold text-gray-900 text-base flex items-center gap-2",children:"学生视角预览 (Student Perspective Preview)"}),i.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["正在预览课程: ",i.jsx("span",{className:"font-semibold text-gray-700",children:n.find(N=>N.id===s)?.title})," • 演示同步与交互"]})]})]}),i.jsxs("button",{onClick:()=>r(!1),className:"px-3.5 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-600 hover:text-gray-800 text-xs font-semibold rounded-lg shadow-sm transition-all cursor-pointer flex items-center gap-1 border border-gray-200",children:[i.jsx(Lr,{size:14})," 退出预览"]})]}),i.jsxs("div",{className:"flex-1 flex min-h-0 bg-slate-50/50 p-4 gap-4",children:[i.jsxs("div",{className:`${a==="left"?"w-full":"w-1/3"} bg-white border border-gray-200 rounded-xl p-4 flex flex-col min-h-0 shadow-sm ${a==="right"?"hidden":""} transition-all duration-300`,children:[i.jsxs("div",{className:"text-xs font-bold uppercase tracking-wider text-gray-400 mb-3 border-b border-gray-100 pb-2 flex items-center justify-between shrink-0 select-none",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Pn,{size:14,className:"text-indigo-500"})," Lesson Content (课程内容)"]}),i.jsx("button",{onClick:()=>o(N=>N==="left"?"none":"left"),className:"p-1 hover:bg-gray-100 text-gray-400 hover:text-gray-700 rounded transition-colors cursor-pointer flex items-center gap-1",title:a==="left"?"退出全屏":"全屏",children:a==="left"?i.jsxs(i.Fragment,{children:[i.jsx(uv,{size:13}),i.jsx("span",{className:"text-[10px] font-medium",children:"退出全屏"})]}):i.jsxs(i.Fragment,{children:[i.jsx(fv,{size:13}),i.jsx("span",{className:"text-[10px] font-medium",children:"全屏"})]})})]}),i.jsx("div",{className:"flex-1 overflow-y-auto prose prose-sm prose-indigo max-w-none text-gray-700 pr-1",children:i.jsx(jf,{children:n.find(N=>N.id===s)?.content||""})})]}),i.jsxs("div",{className:`${a==="right"?"w-full flex-grow":"flex-1"} bg-white border border-gray-200 rounded-xl p-4 flex flex-col min-h-0 shadow-sm ${a==="left"?"hidden":""} transition-all duration-300`,children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-3 mb-3 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("button",{onClick:()=>c("whiteboard"),className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all cursor-pointer ${l==="whiteboard"?"bg-indigo-600 text-white shadow-sm":"text-gray-500 hover:bg-gray-100"}`,children:"Interactive Whiteboard"}),i.jsx("button",{onClick:()=>c("courseware"),className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all cursor-pointer ${l==="courseware"?"bg-indigo-600 text-white shadow-sm":"text-gray-500 hover:bg-gray-100"}`,children:"Cloud Apps Viewer"})]}),i.jsx("button",{onClick:()=>o(N=>N==="right"?"none":"right"),className:"p-1 hover:bg-gray-100 text-gray-400 hover:text-gray-700 rounded transition-colors cursor-pointer flex items-center gap-1",title:a==="right"?"退出全屏":"全屏",children:a==="right"?i.jsxs(i.Fragment,{children:[i.jsx(uv,{size:13}),i.jsx("span",{className:"text-[10px] font-medium",children:"退出全屏"})]}):i.jsxs(i.Fragment,{children:[i.jsx(fv,{size:13}),i.jsx("span",{className:"text-[10px] font-medium",children:"全屏"})]})})]}),i.jsx("div",{className:"flex-grow flex-1 min-h-0 flex flex-col h-full relative",children:l==="whiteboard"?i.jsx("div",{className:"flex-grow flex-1 min-h-0 w-full h-full relative rounded-lg overflow-hidden border border-gray-100 flex flex-col",children:i.jsx(V0,{lessonId:s,userRole:d,elements:u,activeSegmentId:f,onSegmentSync:N=>h(N),onElementAdd:async(N,w)=>{await fetch(`/api/lessons/${s}/whiteboard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:N,data:w})}),p(s)},onElementUpdate:async(N,w)=>{await fetch(`/api/lessons/${s}/whiteboard/${N}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:w})}),p(s)},onElementDelete:async N=>{await fetch(`/api/lessons/${s}/whiteboard/${N}`,{method:"DELETE"}),p(s)},onClearBoard:async()=>{await fetch(`/api/lessons/${s}/whiteboard`,{method:"DELETE"}),p(s)},onRefresh:()=>p(s)})}):i.jsxs("div",{className:"flex-grow flex-1 flex gap-4 min-h-0 w-full h-full",children:[i.jsxs("div",{className:"w-52 flex-shrink-0 bg-gray-50 border border-gray-250/70 rounded-xl p-3 flex flex-col min-h-0 h-full animate-none",children:[i.jsx("h4",{className:"text-xs font-bold uppercase tracking-wider text-gray-550 mb-2 border-b border-gray-200 pb-2",children:"Cloud Apps"}),i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1",children:[g!==null&&i.jsxs("button",{onClick:()=>v(null),className:"flex items-center gap-1 p-1.5 text-xs text-indigo-600 w-full hover:bg-gray-255 hover:bg-gray-200 rounded-lg mb-1 font-semibold",children:[i.jsx(ys,{className:"rotate-180",size:14})," Back to Root"]}),x.filter(N=>N.type==="dir").map(N=>i.jsxs("button",{onClick:()=>v(N.id),className:"w-full text-left p-1.5 rounded-lg text-xs text-gray-700 hover:bg-gray-250 hover:bg-gray-200 flex items-center gap-2 group truncate cursor-pointer font-medium",title:N.name,children:[i.jsx(Dl,{size:14,className:"text-indigo-400 shrink-0 group-hover:text-indigo-600"}),i.jsx("span",{className:"truncate",children:N.name})]},N.id)),x.filter(N=>N.type==="file"&&(N.name.endsWith(".html")||N.name.endsWith(".htm")||N.content?.includes("<html"))).length===0?i.jsx("div",{className:"text-xs text-center text-gray-400 italic py-4",children:"No interactive HTML apps found."}):x.filter(N=>N.type==="file"&&(N.name.endsWith(".html")||N.name.endsWith(".htm")||N.content?.includes("<html"))).map(N=>i.jsxs("button",{onClick:()=>j(N.id),className:`w-full text-left p-2 rounded-lg text-xs flex items-center gap-2 truncate transition-colors cursor-pointer font-medium ${b===N.id?"bg-indigo-100 text-indigo-700 font-semibold shadow-xs":"text-gray-600 hover:bg-gray-100"}`,title:N.name,children:[i.jsx(Wo,{size:14,className:"shrink-0 text-indigo-500"}),i.jsx("span",{className:"truncate",children:N.name})]},N.id))]}),i.jsx("div",{className:"mt-2 text-[10px] text-gray-400 leading-tight",children:"Note: Showing HTML courseware from current OS drive directory."})]}),i.jsx("div",{className:"flex-1 relative bg-white border border-gray-100 rounded-xl overflow-hidden min-h-0 h-full shadow-inner flex flex-col",children:i.jsx(EA,{coursewareId:b,onClose:()=>j(null)})})]})})]})]})]})})})}function x8({vfsNodes:e,currentVfsParent:t,setCurrentVfsParent:r,cloudDrivePreviewNode:n,setCloudDrivePreviewNode:s}){return i.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[i.jsxs("div",{className:"w-64 border-r border-gray-100 flex flex-col bg-gray-50 shrink-0",children:[i.jsx("div",{className:"p-3 border-b border-gray-200 flex items-center gap-2",children:i.jsxs("button",{onClick:()=>{r(null),s(null)},className:`text-sm font-medium w-full text-left flex items-center gap-2 p-2 rounded cursor-pointer ${t===null?"bg-indigo-100 text-indigo-800 font-bold":"text-gray-600 hover:bg-gray-200"}`,children:[i.jsx(Dl,{size:16})," Data Root"]})}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[t&&i.jsxs("button",{onClick:()=>r(null),className:"flex items-center gap-2 p-2 text-xs text-indigo-600 w-full hover:bg-gray-200 rounded mb-2 font-medium cursor-pointer",children:[i.jsx(ys,{className:"rotate-180",size:14})," Back to Root"]}),i.jsx("div",{className:"text-xs uppercase font-semibold text-gray-400 px-2 py-1 mb-1",children:"Current Path Nodes"}),e.filter(a=>a.type==="dir").map(a=>i.jsxs("button",{onClick:()=>{r(a.id),s(null)},className:"w-full text-left p-2 rounded text-sm text-gray-700 hover:bg-gray-200 flex items-center gap-2 group mb-1 cursor-pointer",children:[i.jsx(Dl,{size:14,className:"text-indigo-400 group-hover:text-indigo-600"}),i.jsx("span",{className:"truncate",children:a.name})]},a.id))]})]}),i.jsx("div",{className:"flex-1 flex flex-col bg-white overflow-hidden min-w-0",children:n?i.jsxs("div",{className:"flex-1 flex flex-col h-full min-h-0",children:[i.jsxs("div",{className:"p-3 border-b border-gray-100 bg-gray-50 flex items-center gap-2 shrink-0",children:[i.jsx("button",{onClick:()=>s(null),className:"text-gray-500 hover:text-gray-700 cursor-pointer",children:i.jsx(Lr,{size:16})}),i.jsxs("span",{className:"text-sm font-medium text-gray-700",children:["Previewing: ",n.name]})]}),n.name.endsWith(".html")||n.name.endsWith(".htm")||n.content?.includes("<html")?i.jsx("div",{className:"flex-1 relative bg-gray-50",children:i.jsx(EA,{coursewareId:n.id})}):i.jsx("div",{className:"flex-1 overflow-y-auto p-6 bg-white prose prose-sm max-w-none",children:i.jsx(jf,{children:n.content})})]}):i.jsx("div",{className:"flex-1 p-6 overflow-y-auto",children:i.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[e.length===0&&i.jsx("div",{className:"col-span-full h-32 flex items-center justify-center text-sm text-gray-400 italic",children:"This directory is empty."}),e.map(a=>i.jsxs("div",{onClick:()=>{a.type==="dir"?r(a.id):s({id:a.id,name:a.name,content:a.content||"*(Empty file)*"})},className:"border border-gray-200 hover:border-indigo-300 hover:shadow-md cursor-pointer rounded-xl p-4 flex flex-col gap-3 transition-all bg-white",children:[i.jsx("div",{className:"p-3 rounded-xl w-12 h-12 flex items-center justify-center shrink-0 shadow-sm bg-gray-50 border border-gray-100",children:a.type==="dir"?i.jsx(Dl,{size:24,className:"text-indigo-500"}):i.jsx(cj,{size:24,className:"text-gray-500"})}),i.jsx("div",{className:"text-sm font-medium text-gray-800 break-words",children:a.name})]},a.id))]})})})]})}function hZ(e){return e.isOpen?i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:i.jsxs("div",{className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-5xl h-[85vh] flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Dl,{size:20,className:"text-indigo-600"}),i.jsx("h2",{className:"font-semibold text-gray-800 text-lg",children:"Cloud Course Resource Browser"})]}),i.jsx("button",{onClick:e.onClose,className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors cursor-pointer",children:"×"})]}),i.jsx(x8,{...e})]})}):null}function pZ(e){const{isSystemResourceLibraryOpen:t,setIsSystemResourceLibraryOpen:r,lang:n,systemResourceTab:s,setSystemResourceTab:a,selectedLibraryResourceId:o,setSelectedLibraryResourceId:l,vfsNodes:c,currentVfsParent:d,setCurrentVfsParent:u,cloudDrivePreviewNode:f,setCloudDrivePreviewNode:h,loadingLibraryResources:p,libraryResources:g,fetchLibraryResources:v}=e;return i.jsx(i.Fragment,{children:t&&i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:i.jsxs("div",{className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-6xl h-[85vh] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-150",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0 flex-wrap gap-2",children:[i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[i.jsx(Wo,{size:20,className:"text-emerald-500 animate-pulse"}),i.jsx("h2",{className:"font-semibold text-gray-800 text-lg",children:n==="zh"?"系统资源库与应用商城":"System Resource Library"}),i.jsxs("div",{className:"flex items-center gap-1 bg-slate-200/80 p-0.5 rounded-xl border border-slate-300/60 shadow-3xs ml-2",children:[i.jsxs("button",{onClick:()=>a("system"),className:`px-3 py-1 text-xs font-bold rounded-lg transition-all flex items-center gap-1.5 cursor-pointer ${s==="system"?"bg-white text-emerald-800 shadow-2xs font-extrabold":"text-slate-600 hover:text-slate-900"}`,children:[i.jsx(Wo,{size:13,className:"text-emerald-500"}),i.jsx("span",{children:n==="zh"?"互动课件与系统资源":"System Resources"})]}),i.jsxs("button",{onClick:()=>a("cloud"),className:`px-3 py-1 text-xs font-bold rounded-lg transition-all flex items-center gap-1.5 cursor-pointer ${s==="cloud"?"bg-white text-indigo-800 shadow-2xs font-extrabold":"text-slate-600 hover:text-slate-900"}`,children:[i.jsx(Dl,{size:13,className:"text-indigo-500"}),i.jsx("span",{children:n==="zh"?"云端课程资源 (Cloud Drive)":"Cloud Course Resource"})]})]})]}),i.jsx("button",{onClick:()=>{r(!1),l(null)},className:"text-gray-400 hover:text-gray-600 font-bold p-1 overflow-hidden hover:bg-gray-200 rounded transition-colors text-lg inline-flex items-center justify-center w-8 h-8 cursor-pointer",children:"×"})]}),s==="cloud"?i.jsx(x8,{vfsNodes:c,currentVfsParent:d,setCurrentVfsParent:u,cloudDrivePreviewNode:f,setCloudDrivePreviewNode:h}):i.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[i.jsxs("div",{className:"w-80 border-r border-gray-100 bg-slate-50 flex flex-col shrink-0",children:[i.jsxs("div",{className:"p-4 border-b border-gray-200 bg-white space-y-2",children:[i.jsx("span",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1",children:n==="zh"?"上传新资源":"Upload New Resource"}),i.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[i.jsxs("label",{className:"flex flex-col items-center justify-center p-3 bg-slate-50 hover:bg-indigo-50 border border-dashed border-gray-300 hover:border-indigo-400 rounded-xl cursor-pointer text-center transition-all group",children:[i.jsx("span",{className:"text-lg mb-1 group-hover:scale-110 transition-transform",children:"📄"}),i.jsx("span",{className:"font-bold text-indigo-600 text-[10px] break-all leading-tight",children:n==="zh"?"单HTML文件":"Single HTML"}),i.jsx("input",{type:"file",accept:".html,.htm",className:"hidden",onChange:async x=>{const b=x.target.files?.[0];if(!b)return;const j=new FileReader;j.onload=async N=>{const w=N.target?.result;try{(await fetch("/api/resources",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name,type:"html",content:w})})).ok&&v()}catch(A){console.error("Library upload failed:",A)}},j.readAsText(b)}})]}),i.jsxs("label",{className:"flex flex-col items-center justify-center p-3 bg-slate-50 hover:bg-teal-50 border border-dashed border-gray-300 hover:border-teal-400 rounded-xl cursor-pointer text-center transition-all group",children:[i.jsx("span",{className:"text-lg mb-1 group-hover:scale-110 transition-transform",children:"📁"}),i.jsx("span",{className:"font-bold text-teal-600 text-[10px] break-all leading-tight",children:n==="zh"?"完整文件夹":"Directory Folder"}),i.jsx("input",{type:"file",webkitdirectory:"",directory:"",multiple:!0,className:"hidden",onChange:async x=>{const b=x.target.files;if(!b||b.length===0)return;const j=[];let N="";for(let w=0;w<b.length;w++){const A=b[w],P=A.webkitRelativePath||A.name;N||(N=P.split("/")[0]||"library_resource");const E=A.name.split(".").pop()?.toLowerCase(),T=["png","jpg","jpeg","gif","webp","ico"].includes(E||"");await new Promise(C=>{const I=new FileReader;I.onload=_=>{const L=_.target?.result;j.push({path:P,content:L}),C()},T?I.readAsDataURL(A):I.readAsText(A)})}try{(await fetch("/api/resources",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N,type:"folder",content:JSON.stringify(j)})})).ok&&v()}catch(w){console.error("Folder upload failed:",w)}}})]})]})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[i.jsx("span",{className:"block text-[10px] font-bold text-gray-400 uppercase tracking-widest pl-1",children:n==="zh"?"当前已存储的资源":"Stored Resources"}),p&&i.jsx("div",{className:"text-center py-8 text-xs text-slate-400",children:"Loading resources..."}),!p&&g.length===0&&i.jsx("div",{className:"text-center py-12 text-xs text-slate-400 italic",children:n==="zh"?"暂无资源,支持拖入或上传文件。":"No resources in library. Upload some above!"}),g.map(x=>{const b=o===x.id;return i.jsxs("div",{onClick:()=>l(x.id),className:`p-2.5 rounded-xl border flex justify-between items-center cursor-pointer transition-all ${b?"bg-indigo-50 border-indigo-200 shadow-xs":"bg-white border-slate-100 hover:border-slate-200 hover:shadow-2xs"}`,children:[i.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[i.jsx("span",{className:"text-base select-none",children:x.type==="folder"?"📁":"📄"}),i.jsxs("div",{className:"text-left min-w-0",children:[i.jsx("div",{className:"text-xs font-semibold text-gray-700 truncate font-sans",title:x.name,children:x.name}),i.jsxs("div",{className:"text-[9px] text-gray-400 mt-0.5 font-mono",children:[new Date(x.created_at).toLocaleDateString()," • ",x.id]})]})]}),i.jsx("button",{onClick:async j=>{j.stopPropagation(),confirm(n==="zh"?`确认删除资源 [${x.name}] 吗?`:`Delete resource [${x.name}]?`)&&(await fetch(`/api/resources/${x.id}`,{method:"DELETE"}),o===x.id&&l(null),v())},className:"p-1 hover:bg-red-50 text-slate-400 hover:text-red-500 rounded-md transition-colors cursor-pointer",title:"Delete",children:i.jsx(Yo,{size:12,className:"shrink-0"})})]},x.id)})]})]}),i.jsx("div",{className:"flex-1 bg-white flex flex-col min-w-0",children:o?i.jsxs("div",{className:"flex-1 flex flex-col h-full min-h-0",children:[i.jsxs("div",{className:"p-3 border-b border-gray-100 bg-gray-50 flex items-center justify-between shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-bold text-gray-700 text-sm",children:n==="zh"?"交互沙箱应用预览:":"Sandbox Live Preview:"}),i.jsxs("span",{className:"text-xs bg-slate-200/70 text-slate-700 px-2 py-0.5 rounded font-mono",children:["/api/resources/",o,"/"]})]}),i.jsx("button",{onClick:()=>l(null),className:"text-xs text-indigo-600 hover:text-indigo-800 font-medium cursor-pointer",children:n==="zh"?"关闭预览":"Close Preview"})]}),i.jsx("div",{className:"flex-1 relative bg-slate-100/50",children:i.jsx("iframe",{src:`/api/resources/${o}/`,sandbox:"allow-scripts",className:"w-full h-full border-none bg-white font-sans",title:"Interactive Resource Preview"})})]}):i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-gray-400 bg-slate-50/50",children:[i.jsx(Wo,{size:48,className:"text-gray-300 mb-3 opacity-60"}),i.jsx("p",{className:"text-sm font-semibold text-gray-600",children:n==="zh"?"未选择资源进行预览":"No Resource Selected"}),i.jsx("p",{className:"text-xs text-center text-gray-400 mt-1 max-w-sm",children:n==="zh"?"请在左侧列表中点击选择要预览/管理的 HTML 单文件或完整 applet 文件夹,右侧即可进行沙箱实时运行。":"Click any resource in the list on the left to preview its interactive live sandbox iframe here."})]})})]})]})})})}function mZ({batchPicker:e,setBatchPicker:t,batchPickerLesson:r,setBatchPickerLesson:n,batchPickerDate:s,setBatchPickerDate:a,batchPickerTargetClass:o,setBatchPickerTargetClass:l,lessons:c,classes:d,expandedClassId:u,confirmBatchPicker:f,lang:h}){return e?i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:i.jsxs(Fi.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-md flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80",children:[i.jsx("h2",{className:"font-bold text-gray-800 text-base",children:e==="schedule"?h==="zh"?"批量排课":"Batch Schedule":e==="lockedLesson"?h==="zh"?"批量设置锁定课程":"Batch Lock Lesson":h==="zh"?"批量转班":"Batch Transfer"}),i.jsx("button",{onClick:()=>t(null),className:"text-gray-400 hover:text-gray-600 text-lg font-bold p-1 hover:bg-gray-200 rounded",children:"×"})]}),i.jsxs("div",{className:"p-5 space-y-4",children:[(e==="schedule"||e==="lockedLesson")&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-semibold text-gray-600",children:h==="zh"?"选择课程":"Select Lesson"}),i.jsxs("select",{value:r,onChange:p=>n(p.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[i.jsx("option",{value:"",children:h==="zh"?"— 请选择 —":"— Select —"}),c.map(p=>i.jsx("option",{value:p.id,children:p.title},p.id))]})]}),e==="schedule"&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-semibold text-gray-600",children:h==="zh"?"上课日期":"Schedule Date"}),i.jsx("input",{type:"date",value:s,onChange:p=>a(p.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),e==="transfer"&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{className:"text-xs font-semibold text-gray-600",children:h==="zh"?"选择目标班级":"Select Target Class"}),i.jsxs("select",{value:o,onChange:p=>l(p.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[i.jsx("option",{value:"",children:h==="zh"?"— 请选择 —":"— Select —"}),d.filter(p=>p.id!==u).map(p=>i.jsx("option",{value:p.id,children:p.name},p.id))]})]})]}),i.jsxs("div",{className:"p-4 border-t border-gray-100 flex justify-end gap-2",children:[i.jsx("button",{onClick:()=>t(null),className:"px-4 py-2 text-sm rounded-lg border border-gray-200 text-gray-600 hover:bg-gray-100 cursor-pointer",children:h==="zh"?"取消":"Cancel"}),i.jsx("button",{onClick:f,className:"px-4 py-2 text-sm rounded-lg bg-indigo-600 text-white hover:bg-indigo-700 cursor-pointer",children:h==="zh"?"确认":"Confirm"})]})]})}):null}function gZ({isExportWeightModalOpen:e,setIsExportWeightModalOpen:t,lang:r,quizzesWeight:n,setQuizzesWeight:s,assignmentsWeight:a,setAssignmentsWeight:o,handleQuizzesWeightChange:l,handleAssignmentsWeightChange:c,customCategoryOverrides:d,setCustomCategoryOverrides:u,classDashboardMap:f,exportClassId:h,exportClassName:p,csvPreviewData:g,handleExportGrades:v}){return e?i.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:i.jsxs(Fi.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-2xl flex flex-col overflow-hidden max-h-[85vh]",children:[i.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(sf,{className:"text-indigo-600 font-sans",size:20}),i.jsx("h2",{className:"font-bold text-gray-800 text-lg font-sans",children:r==="zh"?"导出成绩权重设置":"Grade Export & Weighting Settings"})]}),i.jsx("button",{onClick:()=>t(!1),className:"text-gray-400 hover:text-gray-600 font-bold p-1 hover:bg-gray-200 rounded transition-colors text-lg",children:"×"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[i.jsx("div",{className:"bg-indigo-50 border border-indigo-150 rounded-xl p-4 text-indigo-800 text-xs font-sans leading-relaxed",children:r==="zh"?"您可以自定义测验与作业在期末成绩(平均分)中的计算权重。系统已根据测验名和内容自动对课程内容进行分类,您可以在下方手动微调分类。":"Customize the calculation weight of quizzes and assignments in the calculated average score. The system automatically classifies items, but you can manually override categorized groups below."}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("h3",{className:"font-bold text-sm text-gray-800 flex items-center gap-2 font-sans",children:[i.jsx(eq,{size:16,className:"text-indigo-500 font-sans"}),r==="zh"?"定义成绩占比权重":"Define Weighting Percentages"]}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 bg-gray-50 p-4 rounded-xl border border-gray-100 font-sans",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-gray-700",children:r==="zh"?"测验权重 (Quizzes)":"Quizzes Weight"}),i.jsxs("span",{className:"text-xs font-bold text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded border border-indigo-100",children:[n,"%"]})]}),i.jsx("input",{type:"range",min:"0",max:"100",value:n,onChange:x=>l(Number(x.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-gray-700",children:r==="zh"?"作业权重 (Assignments)":"Assignments Weight"}),i.jsxs("span",{className:"text-xs font-bold text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded border border-indigo-100",children:[a,"%"]})]}),i.jsx("input",{type:"range",min:"0",max:"100",value:a,onChange:x=>c(Number(x.target.value)),className:"w-full h-1.5 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-indigo-600"})]})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:()=>{s(50),o(50)},className:"text-[10px] text-gray-500 hover:text-gray-700 bg-white border border-gray-200 hover:bg-gray-50 font-bold px-2.5 py-1 rounded transition-colors cursor-pointer",children:r==="zh"?"均衡配比 50/50":"Balance 50/50"}),i.jsx("button",{type:"button",onClick:()=>{s(40),o(60)},className:"text-[10px] text-gray-500 hover:text-gray-700 bg-white border border-gray-200 hover:bg-gray-50 font-bold px-2.5 py-1 rounded transition-colors cursor-pointer",children:r==="zh"?"推荐配比 40/60":"Recommend 40/60"})]})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("h3",{className:"font-bold text-sm text-gray-800 flex items-center justify-between font-sans",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(hD,{size:16,className:"text-indigo-500"}),r==="zh"?"期末考核项目微调":"Item Categorization Overrides"]}),i.jsx("span",{className:"text-[10px] text-gray-400 font-medium font-sans",children:r==="zh"?`共 ${f[h]?.assignments?.length||0} 项`:`${f[h]?.assignments?.length||0} items total`})]}),i.jsxs("div",{className:"border border-gray-150 rounded-xl overflow-hidden divide-y divide-gray-100 max-h-60 overflow-y-auto bg-white shadow-inner",children:[(f[h]?.assignments||[]).map(x=>{const b=x.content&&x.content.startsWith('{"quizType":"mcq_learning_objectives"'),j=x.title&&(x.title.toLowerCase().includes("quiz")||x.title.toLowerCase().includes("test")||x.title.includes("测验")||x.title.includes("测试")),N=b||j?"quiz":"assignment",w=d[x.id]||N;return i.jsxs("div",{className:"p-3 flex items-center justify-between gap-4 font-sans hover:bg-gray-50/50 transition-colors",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"font-semibold text-xs text-gray-800 truncate",title:x.title,children:x.title}),i.jsx("div",{className:"text-[10px] text-gray-400 truncate mt-0.5",children:x.description||(r==="zh"?"无描述信息":"No description provided")})]}),i.jsxs("div",{className:"flex border border-gray-200 rounded-lg p-0.5 bg-gray-50 shrink-0",children:[i.jsx("button",{type:"button",onClick:()=>u(A=>({...A,[x.id]:"quiz"})),className:`px-2.5 py-1 text-[10px] font-bold rounded-md transition-all cursor-pointer ${w==="quiz"?"bg-indigo-600 text-white shadow":"text-gray-500 hover:text-gray-800 hover:bg-gray-100"}`,children:r==="zh"?"测验":"Quiz"}),i.jsx("button",{type:"button",onClick:()=>u(A=>({...A,[x.id]:"assignment"})),className:`px-2.5 py-1 text-[10px] font-bold rounded-md transition-all cursor-pointer ${w==="assignment"?"bg-emerald-600 text-white shadow":"text-gray-500 hover:text-gray-800 hover:bg-gray-100"}`,children:r==="zh"?"作业":"Assignment"})]})]},x.id)}),(!f[h]?.assignments||f[h].assignments.length===0)&&i.jsx("div",{className:"p-8 text-center text-xs text-gray-400 italic",children:r==="zh"?"此班级暂未创建任何考核项目":"No graded items exist in this class."})]})]}),g&&g.rows.length>0&&i.jsxs("div",{className:"space-y-3 pt-2",children:[i.jsxs("h3",{className:"font-bold text-sm text-gray-800 flex items-center justify-between font-sans",children:[i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx(va,{size:16,className:"text-emerald-500"}),r==="zh"?"CSV 实时成绩表预览 (前5行数据)":"Live CSV Grade Preview (First 5 Rows)"]}),i.jsx("span",{className:"text-[10px] bg-emerald-50 text-emerald-700 border border-emerald-100 font-bold px-2 py-0.5 rounded shadow-xs font-sans",children:r==="zh"?`展示 5 / ${g.totalStudents} 名学生`:`Showing 5 of ${g.totalStudents} students`})]}),i.jsx("div",{className:"border border-gray-150 rounded-xl overflow-hidden bg-white shadow-xs max-w-full",children:i.jsx("div",{className:"overflow-x-auto max-h-56 overflow-y-auto",children:i.jsxs("table",{className:"w-full border-collapse text-left",children:[i.jsx("thead",{children:i.jsx("tr",{className:"bg-gray-50 border-b border-gray-150 sticky top-0 z-10",children:g.headers.map((x,b)=>{const j=x.includes("Average")||x.includes("Avg")||x.includes("Score"),N=x.includes("Weighted");return i.jsx("th",{className:`p-2.5 text-[10px] font-bold tracking-wider uppercase border-r border-gray-150 whitespace-nowrap font-sans font-semibold ${N?"text-indigo-700 bg-indigo-50/70 border-indigo-150 font-bold":j?"text-emerald-700 bg-emerald-50/70":"text-gray-500"}`,children:x},b)})})}),i.jsx("tbody",{className:"divide-y divide-gray-100",children:g.rows.map((x,b)=>i.jsx("tr",{className:"hover:bg-gray-50/50 transition-colors font-mono text-[10px]",children:x.map((j,N)=>{const w=g.headers[N]||"",A=w.includes("Weighted"),P=w.includes("Average")||w.includes("Avg")||w.includes("Score");return i.jsx("td",{className:`p-2 border-r border-gray-100 font-mono text-[10px] text-gray-700 whitespace-nowrap text-center ${A?"bg-indigo-50/30 font-bold text-indigo-700 border-indigo-100":P?"bg-emerald-50/10 font-semibold text-emerald-800":N<2?"text-left font-sans font-medium":""}`,children:j},N)})},b))})]})})}),i.jsx("p",{className:"text-[10px] text-gray-400 font-sans italic",children:r==="zh"?"* 改变上方权重占比或调整项目分类时,此预览与计算结果会立即实时刷新。":"* Calculations and layout values in this preview refresh dynamically as you tweak sliders and overrides."})]})]}),i.jsxs("div",{className:"p-4 border-t border-gray-100 bg-gray-50/85 flex justify-end gap-2.5 shrink-0",children:[i.jsx("button",{type:"button",onClick:()=>t(!1),className:"px-4 py-2 text-xs font-semibold border border-gray-300 text-gray-700 bg-white rounded-lg hover:bg-gray-100 transition-colors cursor-pointer",children:r==="zh"?"取消":"Cancel"}),i.jsxs("button",{type:"button",disabled:!f[h]?.assignments||f[h].assignments.length===0,onClick:()=>{v(h,p,n,a,d),t(!1)},className:"px-4 py-2 text-xs font-bold bg-indigo-600 text-white border border-indigo-700 rounded-lg hover:bg-indigo-700 hover:shadow shadow-sm transition-all flex items-center gap-1.5 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:[i.jsx(Md,{size:14}),r==="zh"?"导出 CSV 成绩表":"Export Grade Sheet"]})]})]})}):null}const xZ=ss.memo(function({onLoginSuccess:t,lang:r}){const[n,s]=m.useState("teacher"),[a,o]=m.useState(null),[l,c]=m.useState(""),[d,u]=m.useState(""),[f,h]=m.useState(""),[p,g]=m.useState(!1),[v,x]=m.useState([]),[b,j]=m.useState(""),[N,w]=m.useState(""),[A,P]=m.useState(""),[E,T]=m.useState(""),[C,I]=m.useState(!1);m.useEffect(()=>{(async()=>{try{const z=await fetch("/api/students");if(z.ok){const R=await z.json();x(R),R.length>0&&j(R[0].id)}}catch(z){console.warn("Failed to fetch student roster for login selection:",z)}})()},[]),m.useEffect(()=>{(async()=>{try{const z=await fetch("/api/site-settings");if(z.ok){const R=await z.json();o(R)}}catch(z){console.warn("Failed to fetch site settings for login branding:",z)}})()},[]);const _=async $=>{if($.preventDefault(),!l.trim()||!d){h(r==="zh"?"请输入完整的用户名和密码。":"Please fill in both key fields.");return}try{h(""),g(!0);const z=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"teacher",username:l.trim(),password:d})});if(z.ok){const R=await z.json();t(R.session)}else{const R=await z.json();h(R.error||(r==="zh"?"用户名或密码不正确":"Invalid username or password"))}}catch{h(r==="zh"?"网络连接异常,请重试":"Network communication failure. Please try again.")}finally{g(!1)}},L=async $=>{$.preventDefault();const z=b||N.trim();if(!z){T(r==="zh"?"请选择或输入学号/学生标识。":"Please select or enter your Student ID.");return}if(!A.trim()){T(r==="zh"?"请输入个人密码或临时班级密码。":"Please enter your personal password or temporary class passcode.");return}try{T(""),I(!0);const R=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entrance:"student",studentId:z,password:A.trim()})});if(R.ok){const J=await R.json();t(J.session)}else{const J=await R.json();T(J.error||(r==="zh"?"找不到该学生记录":"Student record not found"))}}catch{T(r==="zh"?"网络连接异常,请重试":"Network connection failure. Please try again.")}finally{I(!1)}};return i.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:[i.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40rem] h-[40rem] rounded-full bg-indigo-500/10 blur-3xl -z-10"}),i.jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[35rem] h-[35rem] rounded-full bg-violet-500/10 blur-3xl -z-10"}),i.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:[i.jsxs("div",{className:"text-center mb-8",children:[a?.logoUrl?i.jsx("img",{src:a.logoUrl,alt:a.siteName||"logo",className:"inline-block h-16 w-16 object-contain mb-4 rounded-xl"}):i.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:i.jsx(dj,{size:32})}),i.jsxs("h1",{className:"text-2xl sm:text-3xl font-black text-white tracking-tight flex items-center justify-center gap-2",children:[a?.siteName||"OpenLearn Next"," ",i.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"})]}),i.jsx("p",{className:"text-slate-400 text-xs sm:text-sm mt-2",children:a?.slogan||(r==="zh"?"下一代智能数字化学习系统":"Next-Generation Intelligent Digital Learning Platform")})]}),i.jsxs("div",{className:"flex bg-slate-900 p-1 rounded-xl border border-slate-800 gap-1 mb-6",children:[i.jsxs("button",{onClick:()=>s("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 ${n==="teacher"?"bg-indigo-600 text-white shadow-md":"text-slate-400 hover:text-slate-200 hover:bg-slate-800/40"}`,children:[i.jsx(Qa,{size:14}),r==="zh"?"教师与管理端":"Teacher / Staff Portal"]}),i.jsxs("button",{onClick:()=>s("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 ${n==="student"?"bg-indigo-600 text-white shadow-md":"text-slate-400 hover:text-slate-200 hover:bg-slate-800/40"}`,children:[i.jsx(Nn,{size:14}),r==="zh"?"学生自助端":"Student Self-Service"]})]}),n==="teacher"?i.jsxs("form",{onSubmit:_,className:"space-y-4",children:[f&&i.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:[i.jsx(so,{size:15,className:"shrink-0"}),i.jsx("span",{children:f})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(Fh,{size:13}),r==="zh"?"教工账户名 / username":"Staff Username"]}),i.jsx("input",{type:"text",value:l,onChange:$=>c($.target.value),placeholder:r==="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})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(uj,{size:13}),r==="zh"?"输入登录密码 / password":"Access Password"]}),i.jsx("input",{type:"password",value:d,onChange:$=>u($.target.value),placeholder:r==="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})]}),i.jsxs("button",{type:"submit",disabled:p,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:[i.jsx("span",{children:p?r==="zh"?"鉴权登录中...":"Authorizing...":r==="zh"?"安全验证登录":"Authorized Sign In"}),i.jsx(NC,{size:15})]})]}):i.jsxs("form",{onSubmit:L,className:"space-y-4",children:[E&&i.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:[i.jsx(so,{size:15,className:"shrink-0"}),i.jsx("span",{children:E})]}),v.length>0?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(dj,{size:14}),r==="zh"?"从学生花名册中快速选择":"Quick Access Student Select"]}),i.jsx("select",{value:b,onChange:$=>{j($.target.value),w("")},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:v.map($=>i.jsxs("option",{value:$.id,children:[$.name," (",$.student_number||$.id,")"]},$.id))}),i.jsx("p",{className:"text-[10px] text-slate-500 font-medium",children:r==="zh"?"✨ 在沙盒调试中,你可以直接下拉选择已有的学生账户一键登录为该生。":"✨ Sandbox help: Quick select existing students on file to simulate as student."})]}):null,i.jsxs("div",{className:"relative flex py-2 items-center",children:[i.jsx("div",{className:"flex-grow border-t border-slate-850"}),i.jsx("span",{className:"flex-shrink mx-3 text-[10px] font-bold text-slate-500 uppercase tracking-wider",children:r==="zh"?"或手动输入学号":"Or input key manually"}),i.jsx("div",{className:"flex-grow border-t border-slate-850"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(Fh,{size:13}),r==="zh"?"学号 / Student ID":"Student Access Key"]}),i.jsx("input",{type:"text",value:N,onChange:$=>{w($.target.value),j("")},placeholder:r==="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"})]}),i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("label",{className:"text-xs font-medium text-slate-400 flex items-center gap-1.5",children:[i.jsx(uj,{size:13}),r==="zh"?"个人密码 / 临时班级密码":"Personal Password / Class Passcode"]}),i.jsx("input",{type:"password",required:!0,value:A,onChange:$=>P($.target.value),placeholder:r==="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"})]}),i.jsxs("button",{type:"submit",disabled:C,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:[i.jsx("span",{children:C?r==="zh"?"正在连接学生终端...":"Entering Desk...":r==="zh"?"登录学生智慧桌面":"Login Interactive Desk"}),i.jsx(NC,{size:15})]})]})]})]})});function vZ({isOpen:e,onClose:t,lang:r,onSeedSuccess:n,onJumpTab:s}){const[a,o]=m.useState(0),[l,c]=m.useState(!1),[d,u]=m.useState(null),[f,h]=m.useState(null),[p,g]=m.useState({display:"none"}),[v,x]=m.useState({display:"none"}),b=m.useRef(null),j=[{targetId:"",title:r==="zh"?"欢迎来到 OpenLearn Next V2 平台!":"Welcome to OpenLearn Next V2!",content:r==="zh"?"本平台为数字课堂提供智能白板与教学插件生态托管。下面我们将通过 4 步带您快速完成初始化并体验一堂数字互动课程。":"Welcome! This platform provides interactive whiteboards and educational plugin hosting. Let's set up your first class in 4 quick steps."},{targetId:"nav_btn_admin_directory",title:r==="zh"?"第 1 步:一键初始化示例课程":"Step 1: Initialize Example Class",content:r==="zh"?"在开始授课前,我们需要一个授课班级。请点击下方的按钮,系统将自动在数据库中为您建立示例班级、添加 5 名演示学生(小明、小红等),并自动排定一节今日的白板创意编程示范课!":"Before teaching, we need a classroom session. Click the button below to seed a demo class, add 5 sample students (Xiao Ming, Xiao Hong, etc.), and schedule today's creative programming class!",actionable:!0},{targetId:"navigation_sidebar",title:r==="zh"?"第 2 步:了解系统导航菜单":"Step 2: Tour System Navigation",content:r==="zh"?"初始化成功后,您可以在「系统导航」的「班级管理」中查看学生名册及座位表,或在「课程管理」中编辑白板教案。在「插件中心」中,您还可以安装/停用丰富的第三方小工具。":'After setup, explore the sidebar! Use "Classes & Students" to manage student profiles, "Courses" to edit whiteboards, and "Plugins" to manage tools.'},{targetId:"nav_btn_live_class",title:r==="zh"?"第 3 步:进入互动课堂开启体验":"Step 3: Launch Live Classroom",content:r==="zh"?"一切就绪!点击下方的「一键开课并进入课堂」,系统将为您自动进入示范课堂并展开互动白板。您可以在白板上下发测验、进行实时统计,学生端也将实时接收广播。":'All set! Click "Launch Classroom" to enter the live room. You can draw on the whiteboard, push quizzes, and view live stats, while student clients auto-sync.'}],N=async()=>{c(!0);try{const P=await fetch("/api/admin/seed-demo",{method:"POST"});if(P.ok){const E=await P.json();E.success&&(h({classId:E.classId,className:"人工智能与创意编程示范班"}),n({classId:E.classId,scheduleId:E.scheduleId,lessonId:E.lessonId}),setTimeout(()=>{o(2)},1500))}else{const E=await P.json().catch(()=>({error:"未知错误"}));u(r==="zh"?`初始化失败:${E.error||"请检查服务器日志"}`:`Failed: ${E.error||"Check server logs"}`)}}catch(P){console.error("Failed to seed demo data:",P),u(r==="zh"?`网络错误:${P.message||"请检查服务器是否运行"}`:`Network error: ${P.message||"Check if server is running"}`)}finally{c(!1)}},w=()=>{localStorage.setItem("edu_os_tour_completed","true"),s("live_class"),t()};if(m.useEffect(()=>{if(!e)return;const P=j[a];if(!P||!P.targetId){g({display:"none"}),x({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e4,width:"420px",maxWidth:"90vw"});return}const E=()=>{const C=document.getElementById(P.targetId);if(!C){g({display:"none"}),x({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e4,width:"420px",maxWidth:"90vw"});return}const I=C.getBoundingClientRect(),_=6;g({display:"block",position:"fixed",top:`${I.top-_}px`,left:`${I.left-_}px`,width:`${I.width+_*2}px`,height:`${I.height+_*2}px`,boxShadow:"0 0 0 9999px rgba(15, 23, 42, 0.65)",border:"2px dashed #6366f1",borderRadius:"12px",zIndex:9999,pointerEvents:"none",transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)"});const L=360;let $=I.left+I.width+16,z=I.top;$+L>window.innerWidth&&($=Math.max(16,I.left-L-16)),z+240>window.innerHeight&&(z=Math.max(16,window.innerHeight-250)),x({display:"block",position:"fixed",top:`${z}px`,left:`${$}px`,width:`${L}px`,zIndex:1e4,transition:"all 0.25s cubic-bezier(0.4, 0, 0.2, 1)"})};E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0);const T=setInterval(E,300);return()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0),clearInterval(T)}},[e,a]),!e)return null;const A=j[a];return i.jsxs("div",{className:"fixed inset-0 overflow-hidden select-none",style:{zIndex:9998},children:[A&&!A.targetId&&i.jsx("div",{className:"fixed inset-0 bg-slate-900/65 backdrop-blur-2xs transition-opacity",onClick:t}),i.jsx("div",{style:p}),i.jsxs("div",{ref:b,style:v,className:"bg-white rounded-2xl border border-slate-150/60 shadow-2xl p-5 md:p-6 text-gray-900 font-sans flex flex-col justify-between",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between items-start mb-3",children:[i.jsxs("h3",{className:"font-extrabold text-sm md:text-base text-gray-900 flex items-center gap-1.5 leading-tight",children:[i.jsx(An,{size:16,className:"text-indigo-500 animate-pulse shrink-0"}),A.title]}),i.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 rounded-lg p-0.5 transition-colors cursor-pointer",children:i.jsx(Lr,{size:16})})]}),i.jsx("p",{className:"text-xs md:text-sm text-gray-600 leading-relaxed font-medium mb-5 whitespace-pre-wrap",children:A.content}),A.actionable&&i.jsx("div",{className:"bg-slate-50 border border-slate-200/80 rounded-xl p-3.5 mb-5 flex flex-col items-center justify-center",children:f?i.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 text-xs font-bold animate-bounce",children:[i.jsx(BS,{size:12,className:"fill-emerald-600"}),r==="zh"?"示范课程与学生名册初始化成功!":"Demo classes successfully initialized!"]}):i.jsx("button",{onClick:N,disabled:l,className:"w-full flex items-center justify-center gap-1.5 py-2.5 px-4 bg-indigo-600 hover:bg-indigo-700 text-white font-bold text-xs md:text-sm rounded-lg hover:shadow-md transition-all cursor-pointer disabled:bg-indigo-400",children:l?i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsxs("svg",{className:"animate-spin h-4 w-4 text-white",fill:"none",viewBox:"0 0 24 24",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),r==="zh"?"正在创建数据库记录...":"Initializing DB records..."]}):i.jsxs(i.Fragment,{children:[i.jsx(An,{size:14,className:"animate-pulse"}),r==="zh"?"一键初始化示范数据":"Initialize Example Data"]})})})]}),i.jsxs("div",{className:"flex items-center justify-between border-t border-slate-100 pt-4 shrink-0",children:[i.jsx("div",{className:"flex items-center gap-1.5",children:j.map((P,E)=>i.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${E===a?"w-4 bg-indigo-600":"w-1.5 bg-slate-200"}`},E))}),i.jsxs("div",{className:"flex items-center gap-2",children:[a>0?i.jsxs("button",{onClick:()=>o(P=>P-1),className:"flex items-center gap-1 px-3 py-1.5 border border-slate-200 rounded-lg text-xs font-semibold text-slate-600 hover:bg-slate-50 transition-colors cursor-pointer",children:[i.jsx(D0,{size:12}),r==="zh"?"上一步":"Back"]}):i.jsx("button",{onClick:t,className:"px-3 py-1.5 border border-slate-200 rounded-lg text-xs font-semibold text-slate-500 hover:bg-slate-50 transition-colors cursor-pointer",children:r==="zh"?"跳过向导":"Skip Tour"}),a<j.length-1?i.jsxs("button",{onClick:()=>o(P=>P+1),className:"flex items-center gap-1 px-3 py-1.5 bg-slate-900 text-white rounded-lg text-xs font-semibold hover:bg-slate-800 transition-colors cursor-pointer",children:[r==="zh"?"下一步":"Next",i.jsx(ys,{size:12})]}):i.jsxs("button",{onClick:w,className:"flex items-center gap-1 px-4 py-1.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-xs font-bold shadow-sm transition-colors cursor-pointer",children:[r==="zh"?"结束引导并开课":"Launch Classroom",i.jsx(An,{size:12})]})]})]})]})]})}const Ul=Object.create(null);Ul.open="0";Ul.close="1";Ul.ping="2";Ul.pong="3";Ul.message="4";Ul.upgrade="5";Ul.noop="6";const Bx=Object.create(null);Object.keys(Ul).forEach(e=>{Bx[Ul[e]]=e});const $j={type:"error",data:"parser error"},v8=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",b8=typeof ArrayBuffer=="function",y8=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,_A=({type:e,data:t},r,n)=>v8&&t instanceof Blob?r?n(t):X4(t,n):b8&&(t instanceof ArrayBuffer||y8(t))?r?n(t):X4(new Blob([t]),n):n(Ul[e]+(t||"")),X4=(e,t)=>{const r=new FileReader;return r.onload=function(){const n=r.result.split(",")[1];t("b"+(n||""))},r.readAsDataURL(e)};function Z4(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let gw;function bZ(e,t){if(v8&&e.data instanceof Blob)return e.data.arrayBuffer().then(Z4).then(t);if(b8&&(e.data instanceof ArrayBuffer||y8(e.data)))return t(Z4(e.data));_A(e,!1,r=>{gw||(gw=new TextEncoder),t(gw.encode(r))})}const J4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Om=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<J4.length;e++)Om[J4.charCodeAt(e)]=e;const yZ=e=>{let t=e.length*.75,r=e.length,n,s=0,a,o,l,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const d=new ArrayBuffer(t),u=new Uint8Array(d);for(n=0;n<r;n+=4)a=Om[e.charCodeAt(n)],o=Om[e.charCodeAt(n+1)],l=Om[e.charCodeAt(n+2)],c=Om[e.charCodeAt(n+3)],u[s++]=a<<2|o>>4,u[s++]=(o&15)<<4|l>>2,u[s++]=(l&3)<<6|c&63;return d},wZ=typeof ArrayBuffer=="function",TA=(e,t)=>{if(typeof e!="string")return{type:"message",data:w8(e,t)};const r=e.charAt(0);return r==="b"?{type:"message",data:jZ(e.substring(1),t)}:Bx[r]?e.length>1?{type:Bx[r],data:e.substring(1)}:{type:Bx[r]}:$j},jZ=(e,t)=>{if(wZ){const r=yZ(e);return w8(r,t)}else return{base64:!0,data:e}},w8=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},j8="",NZ=(e,t)=>{const r=e.length,n=new Array(r);let s=0;e.forEach((a,o)=>{_A(a,!1,l=>{n[o]=l,++s===r&&t(n.join(j8))})})},SZ=(e,t)=>{const r=e.split(j8),n=[];for(let s=0;s<r.length;s++){const a=TA(r[s],t);if(n.push(a),a.type==="error")break}return n};function AZ(){return new TransformStream({transform(e,t){bZ(e,r=>{const n=r.length;let s;if(n<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,n);else if(n<65536){s=new Uint8Array(3);const a=new DataView(s.buffer);a.setUint8(0,126),a.setUint16(1,n)}else{s=new Uint8Array(9);const a=new DataView(s.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(n))}e.data&&typeof e.data!="string"&&(s[0]|=128),t.enqueue(s),t.enqueue(r)})}})}let xw;function Yg(e){return e.reduce((t,r)=>t+r.length,0)}function Xg(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let s=0;s<t;s++)r[s]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function PZ(e,t){xw||(xw=new TextDecoder);const r=[];let n=0,s=-1,a=!1;return new TransformStream({transform(o,l){for(r.push(o);;){if(n===0){if(Yg(r)<1)break;const c=Xg(r,1);a=(c[0]&128)===128,s=c[0]&127,s<126?n=3:s===126?n=1:n=2}else if(n===1){if(Yg(r)<2)break;const c=Xg(r,2);s=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),n=3}else if(n===2){if(Yg(r)<8)break;const c=Xg(r,8),d=new DataView(c.buffer,c.byteOffset,c.length),u=d.getUint32(0);if(u>Math.pow(2,21)-1){l.enqueue($j);break}s=u*Math.pow(2,32)+d.getUint32(4),n=3}else{if(Yg(r)<s)break;const c=Xg(r,s);l.enqueue(TA(a?c:xw.decode(c),t)),n=0}if(s===0||s>e){l.enqueue($j);break}}}})}const N8=4;function xs(e){if(e)return kZ(e)}function kZ(e){for(var t in xs.prototype)e[t]=xs.prototype[t];return e}xs.prototype.on=xs.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};xs.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};xs.prototype.off=xs.prototype.removeListener=xs.prototype.removeAllListeners=xs.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,s=0;s<r.length;s++)if(n=r[s],n===t||n.fn===t){r.splice(s,1);break}return r.length===0&&delete this._callbacks["$"+e],this};xs.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){r=r.slice(0);for(var n=0,s=r.length;n<s;++n)r[n].apply(this,t)}return this};xs.prototype.emitReserved=xs.prototype.emit;xs.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};xs.prototype.hasListeners=function(e){return!!this.listeners(e).length};const ny=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,r)=>r(t,0),Za=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),CZ="arraybuffer";function S8(e,...t){return t.reduce((r,n)=>(e.hasOwnProperty(n)&&(r[n]=e[n]),r),{})}const EZ=Za.setTimeout,_Z=Za.clearTimeout;function sy(e,t){t.useNativeTimers?(e.setTimeoutFn=EZ.bind(Za),e.clearTimeoutFn=_Z.bind(Za)):(e.setTimeoutFn=Za.setTimeout.bind(Za),e.clearTimeoutFn=Za.clearTimeout.bind(Za))}const TZ=1.33;function OZ(e){return typeof e=="string"?IZ(e):Math.ceil((e.byteLength||e.size)*TZ)}function IZ(e){let t=0,r=0;for(let n=0,s=e.length;n<s;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}function A8(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function LZ(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}function zZ(e){let t={},r=e.split("&");for(let n=0,s=r.length;n<s;n++){let a=r[n].split("=");t[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return t}class DZ extends Error{constructor(t,r,n){super(t),this.description=r,this.context=n,this.type="TransportError"}}class OA extends xs{constructor(t){super(),this.writable=!1,sy(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,r,n){return super.emitReserved("error",new DZ(t,r,n)),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 r=TA(t,this.socket.binaryType);this.onPacket(r)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,r={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(r)}_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 r=LZ(t);return r.length?"?"+r:""}}class MZ extends OA{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const r=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||r()})),this.writable||(n++,this.once("drain",function(){--n||r()}))}else r()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const r=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};SZ(t,this.socket.binaryType).forEach(r),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,NZ(t,r=>{this.doWrite(r,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",r=this.query||{};return this.opts.timestampRequests!==!1&&(r[this.opts.timestampParam]=A8()),!this.supportsBinary&&!r.sid&&(r.b64=1),this.createUri(t,r)}}let P8=!1;try{P8=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const RZ=P8;function $Z(){}class FZ extends MZ{constructor(t){if(super(t),typeof location<"u"){const r=location.protocol==="https:";let n=location.port;n||(n=r?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||n!==t.port}}doWrite(t,r){const n=this.request({method:"POST",data:t});n.on("success",r),n.on("error",(s,a)=>{this.onError("xhr post error",s,a)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(r,n)=>{this.onError("xhr poll error",r,n)}),this.pollXhr=t}}class Rl extends xs{constructor(t,r,n){super(),this.createRequest=t,sy(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var t;const r=S8(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let s in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(s)&&n.setRequestHeader(s,this._opts.extraHeaders[s])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var s;n.readyState===3&&((s=this._opts.cookieJar)===null||s===void 0||s.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(s){this.setTimeoutFn(()=>{this._onError(s)},0);return}typeof document<"u"&&(this._index=Rl.requestsCount++,Rl.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=$Z,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Rl.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()}}Rl.requestsCount=0;Rl.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Q4);else if(typeof addEventListener=="function"){const e="onpagehide"in Za?"pagehide":"unload";addEventListener(e,Q4,!1)}}function Q4(){for(let e in Rl.requests)Rl.requests.hasOwnProperty(e)&&Rl.requests[e].abort()}const BZ=(function(){const e=k8({xdomain:!1});return e&&e.responseType!==null})();class VZ extends FZ{constructor(t){super(t);const r=t&&t.forceBase64;this.supportsBinary=BZ&&!r}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Rl(k8,this.uri(),t)}}function k8(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||RZ))return new XMLHttpRequest}catch{}if(!t)try{return new Za[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const C8=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class WZ extends OA{get name(){return"websocket"}doOpen(){const t=this.uri(),r=this.opts.protocols,n=C8?{}:S8(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,r,n)}catch(s){return this.emitReserved("error",s)}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 r=0;r<t.length;r++){const n=t[r],s=r===t.length-1;_A(n,this.supportsBinary,a=>{try{this.doWrite(n,a)}catch{}s&&ny(()=>{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",r=this.query||{};return this.opts.timestampRequests&&(r[this.opts.timestampParam]=A8()),this.supportsBinary||(r.b64=1),this.createUri(t,r)}}const vw=Za.WebSocket||Za.MozWebSocket;class UZ extends WZ{createSocket(t,r,n){return C8?new vw(t,r,n):r?new vw(t,r):new vw(t)}doWrite(t,r){this.ws.send(r)}}class qZ extends OA{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 r=PZ(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=t.readable.pipeThrough(r).getReader(),s=AZ();s.readable.pipeTo(t.writable),this._writer=s.writable.getWriter();const a=()=>{n.read().then(({done:l,value:c})=>{l||(this.onPacket(c),a())}).catch(l=>{})};a();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 r=0;r<t.length;r++){const n=t[r],s=r===t.length-1;this._writer.write(n).then(()=>{s&&ny(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const HZ={websocket:UZ,webtransport:qZ,polling:VZ},KZ=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,GZ=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Fj(e){if(e.length>8e3)throw"URI too long";const t=e,r=e.indexOf("["),n=e.indexOf("]");r!=-1&&n!=-1&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let s=KZ.exec(e||""),a={},o=14;for(;o--;)a[GZ[o]]=s[o]||"";return r!=-1&&n!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=YZ(a,a.path),a.queryKey=XZ(a,a.query),a}function YZ(e,t){const r=/\/{2,9}/g,n=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&n.splice(0,1),t.slice(-1)=="/"&&n.splice(n.length-1,1),n}function XZ(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,s,a){s&&(r[s]=a)}),r}const Bj=typeof addEventListener=="function"&&typeof removeEventListener=="function",Vx=[];Bj&&addEventListener("offline",()=>{Vx.forEach(e=>e())},!1);class Rd extends xs{constructor(t,r){if(super(),this.binaryType=CZ,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(r=t,t=null),t){const n=Fj(t);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=Fj(r.host).host);sy(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(n=>{const s=n.prototype.name;this.transports.push(s),this._transportsByName[s]=n}),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},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=zZ(this.opts.query)),Bj&&(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"})},Vx.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const r=Object.assign({},this.opts.query);r.EIO=N8,r.transport=t,this.id&&(r.sid=this.id);const n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Rd.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const r=this.createTransport(t);r.open(),this.setTransport(r)}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",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",Rd.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 r=new Error("server error");r.code=t.data,this._onError(r);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 r=1;for(let n=0;n<this.writeBuffer.length;n++){const s=this.writeBuffer[n].data;if(s&&(r+=OZ(s)),n>0&&r>this._maxPayload)return this.writeBuffer.slice(0,n);r+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ny(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,n){return this._sendPacket("message",t,r,n),this}send(t,r,n){return this._sendPacket("message",t,r,n),this}_sendPacket(t,r,n,s){if(typeof r=="function"&&(s=r,r=void 0),typeof n=="function"&&(s=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const a={type:t,data:r,options:n};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),s&&this.once("flush",s),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},n=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():t()}):this.upgrading?n():t()),this}_onError(t){if(Rd.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,r){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(),Bj&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=Vx.indexOf(this._offlineEventListener);n!==-1&&Vx.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}}Rd.protocol=N8;class ZZ extends Rd{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 r=this.createTransport(t),n=!1;Rd.priorWebsocketSuccess=!1;const s=()=>{n||(r.send([{type:"ping",data:"probe"}]),r.once("packet",f=>{if(!n)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;Rd.priorWebsocketSuccess=r.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(u(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=r.name,this.emitReserved("upgradeError",h)}}))};function a(){n||(n=!0,u(),r.close(),r=null)}const o=f=>{const h=new Error("probe error: "+f);h.transport=r.name,a(),this.emitReserved("upgradeError",h)};function l(){o("transport closed")}function c(){o("socket closed")}function d(f){r&&f.name!==r.name&&a()}const u=()=>{r.removeListener("open",s),r.removeListener("error",o),r.removeListener("close",l),this.off("close",c),this.off("upgrading",d)};r.once("open",s),r.once("error",o),r.once("close",l),this.once("close",c),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{n||r.open()},200):r.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const r=[];for(let n=0;n<t.length;n++)~this.transports.indexOf(t[n])&&r.push(t[n]);return r}}let JZ=class extends ZZ{constructor(t,r={}){const n=typeof t=="object"?t:r;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(s=>HZ[s]).filter(s=>!!s)),super(t,n)}};function QZ(e,t="",r){let n=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),n=Fj(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const a=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+a+":"+n.port+t,n.href=n.protocol+"://"+a+(r&&r.port===n.port?"":":"+n.port),n}const eJ=typeof ArrayBuffer=="function",tJ=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,E8=Object.prototype.toString,rJ=typeof Blob=="function"||typeof Blob<"u"&&E8.call(Blob)==="[object BlobConstructor]",nJ=typeof File=="function"||typeof File<"u"&&E8.call(File)==="[object FileConstructor]";function IA(e){return eJ&&(e instanceof ArrayBuffer||tJ(e))||rJ&&e instanceof Blob||nJ&&e instanceof File}function Wx(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(Wx(e[r]))return!0;return!1}if(IA(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Wx(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&Wx(e[r]))return!0;return!1}function sJ(e){const t=[],r=e.data,n=e;return n.data=Vj(r,t),n.attachments=t.length,{packet:n,buffers:t}}function Vj(e,t){if(!e)return e;if(IA(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=Vj(e[n],t);return r}else if(typeof e=="object"&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=Vj(e[n],t));return r}return e}function iJ(e,t){return e.data=Wj(e.data,t),delete e.attachments,e}function Wj(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 r=0;r<e.length;r++)e[r]=Wj(e[r],t);else if(typeof e=="object")for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=Wj(e[r],t));return e}const aJ=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var br;(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"})(br||(br={}));class oJ{constructor(t){this.replacer=t}encode(t){return(t.type===br.EVENT||t.type===br.ACK)&&Wx(t)?this.encodeAsBinary({type:t.type===br.EVENT?br.BINARY_EVENT:br.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let r=""+t.type;return(t.type===br.BINARY_EVENT||t.type===br.BINARY_ACK)&&(r+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(r+=t.nsp+","),t.id!=null&&(r+=t.id),t.data!=null&&(r+=JSON.stringify(t.data,this.replacer)),r}encodeAsBinary(t){const r=sJ(t),n=this.encodeAsString(r.packet),s=r.buffers;return s.unshift(n),s}}class LA extends xs{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);const n=r.type===br.BINARY_EVENT;n||r.type===br.BINARY_ACK?(r.type=n?br.EVENT:br.ACK,this.reconstructor=new lJ(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(IA(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0;const n={type:Number(t.charAt(0))};if(br[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===br.BINARY_EVENT||n.type===br.BINARY_ACK){const a=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);const o=t.substring(a,r);if(o!=Number(o)||t.charAt(r)!=="-")throw new Error("Illegal attachments");const l=Number(o);if(!cJ(l)||l<0)throw new Error("Illegal attachments");if(l>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=l}if(t.charAt(r+1)==="/"){const a=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););n.nsp=t.substring(a,r)}else n.nsp="/";const s=t.charAt(r+1);if(s!==""&&Number(s)==s){const a=r+1;for(;++r;){const o=t.charAt(r);if(o==null||Number(o)!=o){--r;break}if(r===t.length)break}n.id=Number(t.substring(a,r+1))}if(t.charAt(++r)){const a=this.tryParse(t.substr(r));if(LA.isPayloadValid(n.type,a))n.data=a;else throw new Error("invalid payload")}return n}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case br.CONNECT:return e3(r);case br.DISCONNECT:return r===void 0;case br.CONNECT_ERROR:return typeof r=="string"||e3(r);case br.EVENT:case br.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&aJ.indexOf(r[0])===-1);case br.ACK:case br.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class lJ{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const r=iJ(this.reconPack,this.buffers);return this.finishedReconstruction(),r}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const cJ=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function e3(e){return Object.prototype.toString.call(e)==="[object Object]"}const dJ=Object.freeze(Object.defineProperty({__proto__:null,Decoder:LA,Encoder:oJ,get PacketType(){return br}},Symbol.toStringTag,{value:"Module"}));function Mo(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const uJ=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class _8 extends xs{constructor(t,r,n){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=r,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Mo(t,"open",this.onopen.bind(this)),Mo(t,"packet",this.onpacket.bind(this)),Mo(t,"error",this.onerror.bind(this)),Mo(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,...r){var n,s,a;if(uJ.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(r.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(r),this;const o={type:br.EVENT,data:r};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof r[r.length-1]=="function"){const u=this.ids++,f=r.pop();this._registerAckCallback(u,f),o.id=u}const l=(s=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||s===void 0?void 0:s.writable,c=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!l||(c?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,r){var n;const s=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(s===void 0){this.acks[t]=r;return}const a=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);r.call(this,new Error("operation has timed out"))},s),o=(...l)=>{this.io.clearTimeoutFn(a),r.apply(this,l)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...r){return new Promise((n,s)=>{const a=(o,l)=>o?s(o):n(l);a.withError=!0,r.push(a),this.emit(t,...r)})}_addToQueue(t){let r;typeof t[t.length-1]=="function"&&(r=t.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((s,...a)=>(this._queue[0],s!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),r&&r(s)):(this._queue.shift(),r&&r(null,...a)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const r=this._queue[0];r.pending&&!t||(r.pending=!0,r.tryCount++,this.flags=r.flags,this.emit.apply(this,r.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:br.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,r){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,r),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(n=>String(n.id)===t)){const n=this.acks[t];delete this.acks[t],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case br.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 br.EVENT:case br.BINARY_EVENT:this.onevent(t);break;case br.ACK:case br.BINARY_ACK:this.onack(t);break;case br.DISCONNECT:this.ondisconnect();break;case br.CONNECT_ERROR:this.destroy();const n=new Error(t.data.message);n.data=t.data.data,this.emitReserved("connect_error",n);break}}onevent(t){const r=t.data||[];t.id!=null&&r.push(this.ack(t.id)),this.connected?this.emitEvent(r):this.receiveBuffer.push(Object.freeze(r))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const r=this._anyListeners.slice();for(const n of r)n.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 r=this;let n=!1;return function(...s){n||(n=!0,r.packet({type:br.ACK,id:t,data:s}))}}onack(t){const r=this.acks[t.id];typeof r=="function"&&(delete this.acks[t.id],r.withError&&t.data.unshift(null),r.apply(this,t.data))}onconnect(t,r){this.id=t,this.recovered=r&&this._pid===r,this._pid=r,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:br.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 r=this._anyListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,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 r=this._anyOutgoingListeners;for(let n=0;n<r.length;n++)if(t===r[n])return r.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const r=this._anyOutgoingListeners.slice();for(const n of r)n.apply(this,t.data)}}}function gp(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}gp.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-r:e+r}return Math.min(e,this.max)|0};gp.prototype.reset=function(){this.attempts=0};gp.prototype.setMin=function(e){this.ms=e};gp.prototype.setMax=function(e){this.max=e};gp.prototype.setJitter=function(e){this.jitter=e};class Uj extends xs{constructor(t,r){var n;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(r=t,t=void 0),r=r||{},r.path=r.path||"/socket.io",this.opts=r,sy(this,r),this.reconnection(r.reconnection!==!1),this.reconnectionAttempts(r.reconnectionAttempts||1/0),this.reconnectionDelay(r.reconnectionDelay||1e3),this.reconnectionDelayMax(r.reconnectionDelayMax||5e3),this.randomizationFactor((n=r.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new gp({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(r.timeout==null?2e4:r.timeout),this._readyState="closed",this.uri=t;const s=r.parser||dJ;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=r.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 r;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(r=this.backoff)===null||r===void 0||r.setMin(t),this)}randomizationFactor(t){var r;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(r=this.backoff)===null||r===void 0||r.setJitter(t),this)}reconnectionDelayMax(t){var r;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(r=this.backoff)===null||r===void 0||r.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 JZ(this.uri,this.opts);const r=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const s=Mo(r,"open",function(){n.onopen(),t&&t()}),a=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=Mo(r,"error",a);if(this._timeout!==!1){const l=this._timeout,c=this.setTimeoutFn(()=>{s(),a(new Error("timeout")),r.close()},l);this.opts.autoUnref&&c.unref(),this.subs.push(()=>{this.clearTimeoutFn(c)})}return this.subs.push(s),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(Mo(t,"ping",this.onping.bind(this)),Mo(t,"data",this.ondata.bind(this)),Mo(t,"error",this.onerror.bind(this)),Mo(t,"close",this.onclose.bind(this)),Mo(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(r){this.onclose("parse error",r)}}ondecoded(t){ny(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,r){let n=this.nsps[t];return n?this._autoConnect&&!n.active&&n.connect():(n=new _8(this,t,r),this.nsps[t]=n),n}_destroy(t){const r=Object.keys(this.nsps);for(const n of r)if(this.nsps[n].active)return;this._close()}_packet(t){const r=this.encoder.encode(t);for(let n=0;n<r.length;n++)this.engine.write(r[n],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,r){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,r),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 r=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(s=>{s?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",s)):t.onreconnect()}))},r);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const pm={};function Bm(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const r=QZ(e,t.path||"/socket.io"),n=r.source,s=r.id,a=r.path,o=pm[s]&&a in pm[s].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let c;return l?c=new Uj(n,t):(pm[s]||(pm[s]=new Uj(n,t)),c=pm[s]),r.query&&!t.query&&(t.query=r.queryKey),c.socket(r.path,t)}Object.assign(Bm,{Manager:Uj,Socket:_8,io:Bm,connect:Bm});function Vr(e){"@babel/helpers - typeof";return Vr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vr(e)}var Xo=Uint8Array,ba=Uint16Array,zA=Int32Array,DA=new Xo([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),MA=new Xo([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),t3=new Xo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),T8=function(e,t){for(var r=new ba(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var s=new zA(r[30]),n=1;n<30;++n)for(var a=r[n];a<r[n+1];++a)s[a]=a-r[n]<<5|n;return{b:r,r:s}},O8=T8(DA,2),fJ=O8.b,qj=O8.r;fJ[28]=258,qj[258]=28;var hJ=T8(MA,0),r3=hJ.r,Hj=new ba(32768);for(var Sn=0;Sn<32768;++Sn){var Pd=(Sn&43690)>>1|(Sn&21845)<<1;Pd=(Pd&52428)>>2|(Pd&13107)<<2,Pd=(Pd&61680)>>4|(Pd&3855)<<4,Hj[Sn]=((Pd&65280)>>8|(Pd&255)<<8)>>1}var Vm=(function(e,t,r){for(var n=e.length,s=0,a=new ba(t);s<n;++s)e[s]&&++a[e[s]-1];var o=new ba(t);for(s=1;s<t;++s)o[s]=o[s-1]+a[s-1]<<1;var l;if(r){l=new ba(1<<t);var c=15-t;for(s=0;s<n;++s)if(e[s])for(var d=s<<4|e[s],u=t-e[s],f=o[e[s]-1]++<<u,h=f|(1<<u)-1;f<=h;++f)l[Hj[f]>>c]=d}else for(l=new ba(n),s=0;s<n;++s)e[s]&&(l[s]=Hj[o[e[s]-1]++]>>15-e[s]);return l}),of=new Xo(288);for(var Sn=0;Sn<144;++Sn)of[Sn]=8;for(var Sn=144;Sn<256;++Sn)of[Sn]=9;for(var Sn=256;Sn<280;++Sn)of[Sn]=7;for(var Sn=280;Sn<288;++Sn)of[Sn]=8;var wv=new Xo(32);for(var Sn=0;Sn<32;++Sn)wv[Sn]=5;var pJ=Vm(of,9,0),mJ=Vm(wv,5,0),I8=function(e){return(e+7)/8|0},gJ=function(e,t,r){return(r==null||r>e.length)&&(r=e.length),new Xo(e.subarray(t,r))},kc=function(e,t,r){r<<=t&7;var n=t/8|0;e[n]|=r,e[n+1]|=r>>8},mm=function(e,t,r){r<<=t&7;var n=t/8|0;e[n]|=r,e[n+1]|=r>>8,e[n+2]|=r>>16},bw=function(e,t){for(var r=[],n=0;n<e.length;++n)e[n]&&r.push({s:n,f:e[n]});var s=r.length,a=r.slice();if(!s)return{t:z8,l:0};if(s==1){var o=new Xo(r[0].s+1);return o[r[0].s]=1,{t:o,l:1}}r.sort(function(A,P){return A.f-P.f}),r.push({s:-1,f:25001});var l=r[0],c=r[1],d=0,u=1,f=2;for(r[0]={s:-1,f:l.f+c.f,l,r:c};u!=s-1;)l=r[r[d].f<r[f].f?d++:f++],c=r[d!=u&&r[d].f<r[f].f?d++:f++],r[u++]={s:-1,f:l.f+c.f,l,r:c};for(var h=a[0].s,n=1;n<s;++n)a[n].s>h&&(h=a[n].s);var p=new ba(h+1),g=Kj(r[u-1],p,0);if(g>t){var n=0,v=0,x=g-t,b=1<<x;for(a.sort(function(P,E){return p[E.s]-p[P.s]||P.f-E.f});n<s;++n){var j=a[n].s;if(p[j]>t)v+=b-(1<<g-p[j]),p[j]=t;else break}for(v>>=x;v>0;){var N=a[n].s;p[N]<t?v-=1<<t-p[N]++-1:++n}for(;n>=0&&v;--n){var w=a[n].s;p[w]==t&&(--p[w],++v)}g=t}return{t:new Xo(p),l:g}},Kj=function(e,t,r){return e.s==-1?Math.max(Kj(e.l,t,r+1),Kj(e.r,t,r+1)):t[e.s]=r},n3=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new ba(++t),n=0,s=e[0],a=1,o=function(c){r[n++]=c},l=1;l<=t;++l)if(e[l]==s&&l!=t)++a;else{if(!s&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(s),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(s);a=1,s=e[l]}return{c:r.subarray(0,n),n:t}},gm=function(e,t){for(var r=0,n=0;n<t.length;++n)r+=e[n]*t[n];return r},L8=function(e,t,r){var n=r.length,s=I8(t+2);e[s]=n&255,e[s+1]=n>>8,e[s+2]=e[s]^255,e[s+3]=e[s+1]^255;for(var a=0;a<n;++a)e[s+a+4]=r[a];return(s+4+n)*8},s3=function(e,t,r,n,s,a,o,l,c,d,u){kc(t,u++,r),++s[256];for(var f=bw(s,15),h=f.t,p=f.l,g=bw(a,15),v=g.t,x=g.l,b=n3(h),j=b.c,N=b.n,w=n3(v),A=w.c,P=w.n,E=new ba(19),T=0;T<j.length;++T)++E[j[T]&31];for(var T=0;T<A.length;++T)++E[A[T]&31];for(var C=bw(E,7),I=C.t,_=C.l,L=19;L>4&&!I[t3[L-1]];--L);var $=d+5<<3,z=gm(s,of)+gm(a,wv)+o,R=gm(s,h)+gm(a,v)+o+14+3*L+gm(E,I)+2*E[16]+3*E[17]+7*E[18];if(c>=0&&$<=z&&$<=R)return L8(t,u,e.subarray(c,c+d));var J,Z,q,Y;if(kc(t,u,1+(R<z)),u+=2,R<z){J=Vm(h,p,0),Z=h,q=Vm(v,x,0),Y=v;var de=Vm(I,_,0);kc(t,u,N-257),kc(t,u+5,P-1),kc(t,u+10,L-4),u+=14;for(var T=0;T<L;++T)kc(t,u+3*T,I[t3[T]]);u+=3*L;for(var H=[j,A],M=0;M<2;++M)for(var V=H[M],T=0;T<V.length;++T){var U=V[T]&31;kc(t,u,de[U]),u+=I[U],U>15&&(kc(t,u,V[T]>>5&127),u+=V[T]>>12)}}else J=pJ,Z=of,q=mJ,Y=wv;for(var T=0;T<l;++T){var F=n[T];if(F>255){var U=F>>18&31;mm(t,u,J[U+257]),u+=Z[U+257],U>7&&(kc(t,u,F>>23&31),u+=DA[U]);var se=F&31;mm(t,u,q[se]),u+=Y[se],se>3&&(mm(t,u,F>>5&8191),u+=MA[se])}else mm(t,u,J[F]),u+=Z[F]}return mm(t,u,J[256]),u+Z[256]},xJ=new zA([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),z8=new Xo(0),vJ=function(e,t,r,n,s,a){var o=a.z||e.length,l=new Xo(n+o+5*(1+Math.ceil(o/7e3))+s),c=l.subarray(n,l.length-s),d=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var f=xJ[t-1],h=f>>13,p=f&8191,g=(1<<r)-1,v=a.p||new ba(32768),x=a.h||new ba(g+1),b=Math.ceil(r/3),j=2*b,N=function(ke){return(e[ke]^e[ke+1]<<b^e[ke+2]<<j)&g},w=new zA(25e3),A=new ba(288),P=new ba(32),E=0,T=0,C=a.i||0,I=0,_=a.w||0,L=0;C+2<o;++C){var $=N(C),z=C&32767,R=x[$];if(v[z]=R,x[$]=z,_<=C){var J=o-C;if((E>7e3||I>24576)&&(J>423||!d)){u=s3(e,c,0,w,A,P,T,I,L,C-L,u),I=E=T=0,L=C;for(var Z=0;Z<286;++Z)A[Z]=0;for(var Z=0;Z<30;++Z)P[Z]=0}var q=2,Y=0,de=p,H=z-R&32767;if(J>2&&$==N(C-H))for(var M=Math.min(h,J)-1,V=Math.min(32767,C),U=Math.min(258,J);H<=V&&--de&&z!=R;){if(e[C+q]==e[C+q-H]){for(var F=0;F<U&&e[C+F]==e[C+F-H];++F);if(F>q){if(q=F,Y=H,F>M)break;for(var se=Math.min(H,F-2),ue=0,Z=0;Z<se;++Z){var re=C-H+Z&32767,ee=v[re],ie=re-ee&32767;ie>ue&&(ue=ie,R=re)}}}z=R,R=v[z],H+=z-R&32767}if(Y){w[I++]=268435456|qj[q]<<18|r3[Y];var xe=qj[q]&31,fe=r3[Y]&31;T+=DA[xe]+MA[fe],++A[257+xe],++P[fe],_=C+q,++E}else w[I++]=e[C],++A[e[C]]}}for(C=Math.max(C,_);C<o;++C)w[I++]=e[C],++A[e[C]];u=s3(e,c,d,w,A,P,T,I,L,C-L,u),d||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=x,a.p=v,a.i=C,a.w=_)}else{for(var C=a.w||0;C<o+d;C+=65535){var Ee=C+65535;Ee>=o&&(c[u/8|0]=d,Ee=o),u=L8(c,u+1,e.subarray(C,Ee))}a.i=o}return gJ(l,0,n+I8(u)+s)},D8=function(){var e=1,t=0;return{p:function(r){for(var n=e,s=t,a=r.length|0,o=0;o!=a;){for(var l=Math.min(o+2655,a);o<l;++o)s+=n+=r[o];n=(n&65535)+15*(n>>16),s=(s&65535)+15*(s>>16)}e=n,t=s},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},bJ=function(e,t,r,n,s){if(!s&&(s={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new Xo(a.length+e.length);o.set(a),o.set(e,a.length),e=o,s.w=a.length}return vJ(e,t.level==null?6:t.level,t.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,r,n,s)},M8=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},yJ=function(e,t){var r=t.level,n=r==0?0:r<6?1:r==9?3:2;if(e[0]=120,e[1]=n<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var s=D8();s.p(t.dictionary),M8(e,2,s.d())}};function Gj(e,t){t||(t={});var r=D8();r.p(e);var n=bJ(e,t,t.dictionary?6:2,4);return yJ(n,t),M8(n,n.length-4,r.d()),n}var wJ=typeof TextDecoder<"u"&&new TextDecoder,jJ=0;try{wJ.decode(z8,{stream:!0}),jJ=1}catch{}function NJ(e){if(Array.isArray(e))return e}function SJ(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,s,a,o,l=[],c=!0,d=!1;try{if(a=(r=r.call(e)).next,t!==0)for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(u){d=!0,s=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw s}}return l}}function i3(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function AJ(e,t){if(e){if(typeof e=="string")return i3(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i3(e,t):void 0}}function PJ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
21
21
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function a3(e,t){return NJ(e)||SJ(e,t)||AJ(e,t)||PJ()}function o3(e,t="utf8"){return new TextDecoder(t).decode(e)}const kJ=new TextEncoder;function CJ(e){return kJ.encode(e)}const EJ=1024*8,_J=(()=>{const e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),yw={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class RA{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=EJ,r={}){let n=!1;typeof t=="number"?t=new ArrayBuffer(t):(n=!0,this.lastWrittenByte=t.byteLength);const s=r.offset?r.offset>>>0:0,a=t.byteLength-s;let o=s;(ArrayBuffer.isView(t)||t instanceof RA)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+s),t=t.buffer),n?this.lastWrittenByte=a:this.lastWrittenByte=0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(t===void 0)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){const n=(this.offset+t)*2,s=new Uint8Array(n);s.set(new Uint8Array(this.buffer)),this.buffer=s.buffer,this.length=n,this.byteLength=n,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,r){const n=yw[r].BYTES_PER_ELEMENT*t,s=this.byteOffset+this.offset,a=this.buffer.slice(s,s+n);if(this.littleEndian===_J&&r!=="uint8"&&r!=="int8"){const l=new Uint8Array(this.buffer.slice(s,s+n));l.reverse();const c=new yw[r](l.buffer);return this.offset+=n,c.reverse(),c}const o=new yw[r](a);return this.offset+=n,o}readInt16(){const t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){const t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){const t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){const t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){const t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){const t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){const t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){const t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let r="";for(let n=0;n<t;n++)r+=this.readChar();return r}readUtf8(t=1){return o3(this.readBytes(t))}decodeText(t=1,r="utf8"){return o3(this.readBytes(t),r)}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let r=0;r<t.length;r++)this._data.setUint8(this.offset++,t[r]);return this._updateLastWrittenByte(),this}writeInt16(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(t){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(t){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(t){return this.writeUint8(t.charCodeAt(0))}writeChars(t){for(let r=0;r<t.length;r++)this.writeUint8(t.charCodeAt(r));return this}writeUtf8(t){return this.writeBytes(CJ(t))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function xp(e){let t=e.length;for(;--t>=0;)e[t]=0}const TJ=3,OJ=258,R8=29,IJ=256,LJ=IJ+1+R8,$8=30,zJ=512,DJ=new Array((LJ+2)*2);xp(DJ);const MJ=new Array($8*2);xp(MJ);const RJ=new Array(zJ);xp(RJ);const $J=new Array(OJ-TJ+1);xp($J);const FJ=new Array(R8);xp(FJ);const BJ=new Array($8);xp(BJ);const VJ=(e,t,r,n)=>{let s=e&65535|0,a=e>>>16&65535|0,o=0;for(;r!==0;){o=r>2e3?2e3:r,r-=o;do s=s+t[n++]|0,a=a+s|0;while(--o);s%=65521,a%=65521}return s|a<<16|0};var Yj=VJ;const WJ=()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t},UJ=new Uint32Array(WJ()),qJ=(e,t,r,n)=>{const s=UJ,a=n+r;e^=-1;for(let o=n;o<a;o++)e=e>>>8^s[(e^t[o])&255];return e^-1};var jl=qJ,Xj={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},F8={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const HJ=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var KJ=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(const n in r)HJ(r,n)&&(e[n]=r[n])}}return e},GJ=e=>{let t=0;for(let n=0,s=e.length;n<s;n++)t+=e[n].length;const r=new Uint8Array(t);for(let n=0,s=0,a=e.length;n<a;n++){let o=e[n];r.set(o,s),s+=o.length}return r},B8={assign:KJ,flattenChunks:GJ};let V8=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{V8=!1}const l0=new Uint8Array(256);for(let e=0;e<256;e++)l0[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;l0[254]=l0[254]=1;var YJ=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,r,n,s,a,o=e.length,l=0;for(s=0;s<o;s++)r=e.charCodeAt(s),(r&64512)===55296&&s+1<o&&(n=e.charCodeAt(s+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),s++)),l+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(l),a=0,s=0;a<l;s++)r=e.charCodeAt(s),(r&64512)===55296&&s+1<o&&(n=e.charCodeAt(s+1),(n&64512)===56320&&(r=65536+(r-55296<<10)+(n-56320),s++)),r<128?t[a++]=r:r<2048?(t[a++]=192|r>>>6,t[a++]=128|r&63):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|r&63):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|r&63);return t};const XJ=(e,t)=>{if(t<65534&&e.subarray&&V8)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r};var ZJ=(e,t)=>{const r=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,s;const a=new Array(r*2);for(s=0,n=0;n<r;){let o=e[n++];if(o<128){a[s++]=o;continue}let l=l0[o];if(l>4){a[s++]=65533,n+=l-1;continue}for(o&=l===2?31:l===3?15:7;l>1&&n<r;)o=o<<6|e[n++]&63,l--;if(l>1){a[s++]=65533;continue}o<65536?a[s++]=o:(o-=65536,a[s++]=55296|o>>10&1023,a[s++]=56320|o&1023)}return XJ(a,s)},JJ=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+l0[e[r]]>t?r:t},Zj={string2buf:YJ,buf2string:ZJ,utf8border:JJ};function QJ(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var eQ=QJ;const Zg=16209,tQ=16191;var rQ=function(t,r){let n,s,a,o,l,c,d,u,f,h,p,g,v,x,b,j,N,w,A,P,E,T,C,I;const _=t.state;n=t.next_in,C=t.input,s=n+(t.avail_in-5),a=t.next_out,I=t.output,o=a-(r-t.avail_out),l=a+(t.avail_out-257),c=_.dmax,d=_.wsize,u=_.whave,f=_.wnext,h=_.window,p=_.hold,g=_.bits,v=_.lencode,x=_.distcode,b=(1<<_.lenbits)-1,j=(1<<_.distbits)-1;e:do{g<15&&(p+=C[n++]<<g,g+=8,p+=C[n++]<<g,g+=8),N=v[p&b];t:for(;;){if(w=N>>>24,p>>>=w,g-=w,w=N>>>16&255,w===0)I[a++]=N&65535;else if(w&16){A=N&65535,w&=15,w&&(g<w&&(p+=C[n++]<<g,g+=8),A+=p&(1<<w)-1,p>>>=w,g-=w),g<15&&(p+=C[n++]<<g,g+=8,p+=C[n++]<<g,g+=8),N=x[p&j];r:for(;;){if(w=N>>>24,p>>>=w,g-=w,w=N>>>16&255,w&16){if(P=N&65535,w&=15,g<w&&(p+=C[n++]<<g,g+=8,g<w&&(p+=C[n++]<<g,g+=8)),P+=p&(1<<w)-1,P>c){t.msg="invalid distance too far back",_.mode=Zg;break e}if(p>>>=w,g-=w,w=a-o,P>w){if(w=P-w,w>u&&_.sane){t.msg="invalid distance too far back",_.mode=Zg;break e}if(E=0,T=h,f===0){if(E+=d-w,w<A){A-=w;do I[a++]=h[E++];while(--w);E=a-P,T=I}}else if(f<w){if(E+=d+f-w,w-=f,w<A){A-=w;do I[a++]=h[E++];while(--w);if(E=0,f<A){w=f,A-=w;do I[a++]=h[E++];while(--w);E=a-P,T=I}}}else if(E+=f-w,w<A){A-=w;do I[a++]=h[E++];while(--w);E=a-P,T=I}for(;A>2;)I[a++]=T[E++],I[a++]=T[E++],I[a++]=T[E++],A-=3;A&&(I[a++]=T[E++],A>1&&(I[a++]=T[E++]))}else{E=a-P;do I[a++]=I[E++],I[a++]=I[E++],I[a++]=I[E++],A-=3;while(A>2);A&&(I[a++]=I[E++],A>1&&(I[a++]=I[E++]))}}else if((w&64)===0){N=x[(N&65535)+(p&(1<<w)-1)];continue r}else{t.msg="invalid distance code",_.mode=Zg;break e}break}}else if((w&64)===0){N=v[(N&65535)+(p&(1<<w)-1)];continue t}else if(w&32){_.mode=tQ;break e}else{t.msg="invalid literal/length code",_.mode=Zg;break e}break}}while(n<s&&a<l);A=g>>3,n-=A,g-=A<<3,p&=(1<<g)-1,t.next_in=n,t.next_out=a,t.avail_in=n<s?5+(s-n):5-(n-s),t.avail_out=a<l?257+(l-a):257-(a-l),_.hold=p,_.bits=g};const nh=15,l3=852,c3=592,d3=0,ww=1,u3=2,nQ=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),sQ=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),iQ=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),aQ=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),oQ=(e,t,r,n,s,a,o,l)=>{const c=l.bits;let d=0,u=0,f=0,h=0,p=0,g=0,v=0,x=0,b=0,j=0,N,w,A,P,E,T=null,C;const I=new Uint16Array(nh+1),_=new Uint16Array(nh+1);let L=null,$,z,R;for(d=0;d<=nh;d++)I[d]=0;for(u=0;u<n;u++)I[t[r+u]]++;for(p=c,h=nh;h>=1&&I[h]===0;h--);if(p>h&&(p=h),h===0)return s[a++]=1<<24|64<<16|0,s[a++]=1<<24|64<<16|0,l.bits=1,0;for(f=1;f<h&&I[f]===0;f++);for(p<f&&(p=f),x=1,d=1;d<=nh;d++)if(x<<=1,x-=I[d],x<0)return-1;if(x>0&&(e===d3||h!==1))return-1;for(_[1]=0,d=1;d<nh;d++)_[d+1]=_[d]+I[d];for(u=0;u<n;u++)t[r+u]!==0&&(o[_[t[r+u]]++]=u);if(e===d3?(T=L=o,C=20):e===ww?(T=nQ,L=sQ,C=257):(T=iQ,L=aQ,C=0),j=0,u=0,d=f,E=a,g=p,v=0,A=-1,b=1<<p,P=b-1,e===ww&&b>l3||e===u3&&b>c3)return 1;for(;;){$=d-v,o[u]+1<C?(z=0,R=o[u]):o[u]>=C?(z=L[o[u]-C],R=T[o[u]-C]):(z=96,R=0),N=1<<d-v,w=1<<g,f=w;do w-=N,s[E+(j>>v)+w]=$<<24|z<<16|R|0;while(w!==0);for(N=1<<d-1;j&N;)N>>=1;if(N!==0?(j&=N-1,j+=N):j=0,u++,--I[d]===0){if(d===h)break;d=t[r+o[u]]}if(d>p&&(j&P)!==A){for(v===0&&(v=p),E+=f,g=d-v,x=1<<g;g+v<h&&(x-=I[g+v],!(x<=0));)g++,x<<=1;if(b+=1<<g,e===ww&&b>l3||e===u3&&b>c3)return 1;A=j&P,s[A]=p<<24|g<<16|E-a|0}}return j!==0&&(s[E+j]=d-v<<24|64<<16|0),l.bits=p,0};var Wm=oQ;const lQ=0,W8=1,U8=2,{Z_FINISH:f3,Z_BLOCK:cQ,Z_TREES:Jg,Z_OK:lf,Z_STREAM_END:dQ,Z_NEED_DICT:uQ,Z_STREAM_ERROR:lo,Z_DATA_ERROR:q8,Z_MEM_ERROR:H8,Z_BUF_ERROR:fQ,Z_DEFLATED:h3}=F8,iy=16180,p3=16181,m3=16182,g3=16183,x3=16184,v3=16185,b3=16186,y3=16187,w3=16188,j3=16189,jv=16190,Cc=16191,jw=16192,N3=16193,Nw=16194,S3=16195,A3=16196,P3=16197,k3=16198,Qg=16199,ex=16200,C3=16201,E3=16202,_3=16203,T3=16204,O3=16205,Sw=16206,I3=16207,L3=16208,Ln=16209,K8=16210,G8=16211,hQ=852,pQ=592,mQ=15,gQ=mQ,z3=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function xQ(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Nf=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<iy||t.mode>G8?1:0},Y8=e=>{if(Nf(e))return lo;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=iy,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(hQ),t.distcode=t.distdyn=new Int32Array(pQ),t.sane=1,t.back=-1,lf},X8=e=>{if(Nf(e))return lo;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Y8(e)},Z8=(e,t)=>{let r;if(Nf(e))return lo;const n=e.state;return t<0?(r=0,t=-t):(r=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?lo:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,X8(e))},J8=(e,t)=>{if(!e)return lo;const r=new xQ;e.state=r,r.strm=e,r.window=null,r.mode=iy;const n=Z8(e,t);return n!==lf&&(e.state=null),n},vQ=e=>J8(e,gQ);let D3=!0,Aw,Pw;const bQ=e=>{if(D3){Aw=new Int32Array(512),Pw=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Wm(W8,e.lens,0,288,Aw,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Wm(U8,e.lens,0,32,Pw,0,e.work,{bits:5}),D3=!1}e.lencode=Aw,e.lenbits=9,e.distcode=Pw,e.distbits=5},Q8=(e,t,r,n)=>{let s;const a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):(s=a.wsize-a.wnext,s>n&&(s=n),a.window.set(t.subarray(r-n,r-n+s),a.wnext),n-=s,n?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=s,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=s))),0},yQ=(e,t)=>{let r,n,s,a,o,l,c,d,u,f,h,p,g,v,x=0,b,j,N,w,A,P,E,T;const C=new Uint8Array(4);let I,_;const L=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Nf(e)||!e.output||!e.input&&e.avail_in!==0)return lo;r=e.state,r.mode===Cc&&(r.mode=jw),o=e.next_out,s=e.output,c=e.avail_out,a=e.next_in,n=e.input,l=e.avail_in,d=r.hold,u=r.bits,f=l,h=c,T=lf;e:for(;;)switch(r.mode){case iy:if(r.wrap===0){r.mode=jw;break}for(;u<16;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if(r.wrap&2&&d===35615){r.wbits===0&&(r.wbits=15),r.check=0,C[0]=d&255,C[1]=d>>>8&255,r.check=jl(r.check,C,2,0),d=0,u=0,r.mode=p3;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((d&255)<<8)+(d>>8))%31){e.msg="incorrect header check",r.mode=Ln;break}if((d&15)!==h3){e.msg="unknown compression method",r.mode=Ln;break}if(d>>>=4,u-=4,E=(d&15)+8,r.wbits===0&&(r.wbits=E),E>15||E>r.wbits){e.msg="invalid window size",r.mode=Ln;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=d&512?j3:Cc,d=0,u=0;break;case p3:for(;u<16;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if(r.flags=d,(r.flags&255)!==h3){e.msg="unknown compression method",r.mode=Ln;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=Ln;break}r.head&&(r.head.text=d>>8&1),r.flags&512&&r.wrap&4&&(C[0]=d&255,C[1]=d>>>8&255,r.check=jl(r.check,C,2,0)),d=0,u=0,r.mode=m3;case m3:for(;u<32;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}r.head&&(r.head.time=d),r.flags&512&&r.wrap&4&&(C[0]=d&255,C[1]=d>>>8&255,C[2]=d>>>16&255,C[3]=d>>>24&255,r.check=jl(r.check,C,4,0)),d=0,u=0,r.mode=g3;case g3:for(;u<16;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}r.head&&(r.head.xflags=d&255,r.head.os=d>>8),r.flags&512&&r.wrap&4&&(C[0]=d&255,C[1]=d>>>8&255,r.check=jl(r.check,C,2,0)),d=0,u=0,r.mode=x3;case x3:if(r.flags&1024){for(;u<16;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}r.length=d,r.head&&(r.head.extra_len=d),r.flags&512&&r.wrap&4&&(C[0]=d&255,C[1]=d>>>8&255,r.check=jl(r.check,C,2,0)),d=0,u=0}else r.head&&(r.head.extra=null);r.mode=v3;case v3:if(r.flags&1024&&(p=r.length,p>l&&(p=l),p&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+p),E)),r.flags&512&&r.wrap&4&&(r.check=jl(r.check,n,p,a)),l-=p,a+=p,r.length-=p),r.length))break e;r.length=0,r.mode=b3;case b3:if(r.flags&2048){if(l===0)break e;p=0;do E=n[a+p++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E));while(E&&p<l);if(r.flags&512&&r.wrap&4&&(r.check=jl(r.check,n,p,a)),l-=p,a+=p,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=y3;case y3:if(r.flags&4096){if(l===0)break e;p=0;do E=n[a+p++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E));while(E&&p<l);if(r.flags&512&&r.wrap&4&&(r.check=jl(r.check,n,p,a)),l-=p,a+=p,E)break e}else r.head&&(r.head.comment=null);r.mode=w3;case w3:if(r.flags&512){for(;u<16;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if(r.wrap&4&&d!==(r.check&65535)){e.msg="header crc mismatch",r.mode=Ln;break}d=0,u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Cc;break;case j3:for(;u<32;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}e.adler=r.check=z3(d),d=0,u=0,r.mode=jv;case jv:if(r.havedict===0)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=l,r.hold=d,r.bits=u,uQ;e.adler=r.check=1,r.mode=Cc;case Cc:if(t===cQ||t===Jg)break e;case jw:if(r.last){d>>>=u&7,u-=u&7,r.mode=Sw;break}for(;u<3;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}switch(r.last=d&1,d>>>=1,u-=1,d&3){case 0:r.mode=N3;break;case 1:if(bQ(r),r.mode=Qg,t===Jg){d>>>=2,u-=2;break e}break;case 2:r.mode=A3;break;case 3:e.msg="invalid block type",r.mode=Ln}d>>>=2,u-=2;break;case N3:for(d>>>=u&7,u-=u&7;u<32;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if((d&65535)!==(d>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Ln;break}if(r.length=d&65535,d=0,u=0,r.mode=Nw,t===Jg)break e;case Nw:r.mode=S3;case S3:if(p=r.length,p){if(p>l&&(p=l),p>c&&(p=c),p===0)break e;s.set(n.subarray(a,a+p),o),l-=p,a+=p,c-=p,o+=p,r.length-=p;break}r.mode=Cc;break;case A3:for(;u<14;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if(r.nlen=(d&31)+257,d>>>=5,u-=5,r.ndist=(d&31)+1,d>>>=5,u-=5,r.ncode=(d&15)+4,d>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Ln;break}r.have=0,r.mode=P3;case P3:for(;r.have<r.ncode;){for(;u<3;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}r.lens[L[r.have++]]=d&7,d>>>=3,u-=3}for(;r.have<19;)r.lens[L[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,I={bits:r.lenbits},T=Wm(lQ,r.lens,0,19,r.lencode,0,r.work,I),r.lenbits=I.bits,T){e.msg="invalid code lengths set",r.mode=Ln;break}r.have=0,r.mode=k3;case k3:for(;r.have<r.nlen+r.ndist;){for(;x=r.lencode[d&(1<<r.lenbits)-1],b=x>>>24,j=x>>>16&255,N=x&65535,!(b<=u);){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if(N<16)d>>>=b,u-=b,r.lens[r.have++]=N;else{if(N===16){for(_=b+2;u<_;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if(d>>>=b,u-=b,r.have===0){e.msg="invalid bit length repeat",r.mode=Ln;break}E=r.lens[r.have-1],p=3+(d&3),d>>>=2,u-=2}else if(N===17){for(_=b+3;u<_;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}d>>>=b,u-=b,E=0,p=3+(d&7),d>>>=3,u-=3}else{for(_=b+7;u<_;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}d>>>=b,u-=b,E=0,p=11+(d&127),d>>>=7,u-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Ln;break}for(;p--;)r.lens[r.have++]=E}}if(r.mode===Ln)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=Ln;break}if(r.lenbits=9,I={bits:r.lenbits},T=Wm(W8,r.lens,0,r.nlen,r.lencode,0,r.work,I),r.lenbits=I.bits,T){e.msg="invalid literal/lengths set",r.mode=Ln;break}if(r.distbits=6,r.distcode=r.distdyn,I={bits:r.distbits},T=Wm(U8,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,I),r.distbits=I.bits,T){e.msg="invalid distances set",r.mode=Ln;break}if(r.mode=Qg,t===Jg)break e;case Qg:r.mode=ex;case ex:if(l>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=l,r.hold=d,r.bits=u,rQ(e,h),o=e.next_out,s=e.output,c=e.avail_out,a=e.next_in,n=e.input,l=e.avail_in,d=r.hold,u=r.bits,r.mode===Cc&&(r.back=-1);break}for(r.back=0;x=r.lencode[d&(1<<r.lenbits)-1],b=x>>>24,j=x>>>16&255,N=x&65535,!(b<=u);){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if(j&&(j&240)===0){for(w=b,A=j,P=N;x=r.lencode[P+((d&(1<<w+A)-1)>>w)],b=x>>>24,j=x>>>16&255,N=x&65535,!(w+b<=u);){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}d>>>=w,u-=w,r.back+=w}if(d>>>=b,u-=b,r.back+=b,r.length=N,j===0){r.mode=O3;break}if(j&32){r.back=-1,r.mode=Cc;break}if(j&64){e.msg="invalid literal/length code",r.mode=Ln;break}r.extra=j&15,r.mode=C3;case C3:if(r.extra){for(_=r.extra;u<_;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}r.length+=d&(1<<r.extra)-1,d>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=E3;case E3:for(;x=r.distcode[d&(1<<r.distbits)-1],b=x>>>24,j=x>>>16&255,N=x&65535,!(b<=u);){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if((j&240)===0){for(w=b,A=j,P=N;x=r.distcode[P+((d&(1<<w+A)-1)>>w)],b=x>>>24,j=x>>>16&255,N=x&65535,!(w+b<=u);){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}d>>>=w,u-=w,r.back+=w}if(d>>>=b,u-=b,r.back+=b,j&64){e.msg="invalid distance code",r.mode=Ln;break}r.offset=N,r.extra=j&15,r.mode=_3;case _3:if(r.extra){for(_=r.extra;u<_;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}r.offset+=d&(1<<r.extra)-1,d>>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Ln;break}r.mode=T3;case T3:if(c===0)break e;if(p=h-c,r.offset>p){if(p=r.offset-p,p>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Ln;break}p>r.wnext?(p-=r.wnext,g=r.wsize-p):g=r.wnext-p,p>r.length&&(p=r.length),v=r.window}else v=s,g=o-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do s[o++]=v[g++];while(--p);r.length===0&&(r.mode=ex);break;case O3:if(c===0)break e;s[o++]=r.length,c--,r.mode=ex;break;case Sw:if(r.wrap){for(;u<32;){if(l===0)break e;l--,d|=n[a++]<<u,u+=8}if(h-=c,e.total_out+=h,r.total+=h,r.wrap&4&&h&&(e.adler=r.check=r.flags?jl(r.check,s,h,o-h):Yj(r.check,s,h,o-h)),h=c,r.wrap&4&&(r.flags?d:z3(d))!==r.check){e.msg="incorrect data check",r.mode=Ln;break}d=0,u=0}r.mode=I3;case I3:if(r.wrap&&r.flags){for(;u<32;){if(l===0)break e;l--,d+=n[a++]<<u,u+=8}if(r.wrap&4&&d!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=Ln;break}d=0,u=0}r.mode=L3;case L3:T=dQ;break e;case Ln:T=q8;break e;case K8:return H8;case G8:default:return lo}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=l,r.hold=d,r.bits=u,(r.wsize||h!==e.avail_out&&r.mode<Ln&&(r.mode<Sw||t!==f3))&&Q8(e,e.output,e.next_out,h-e.avail_out),f-=e.avail_in,h-=e.avail_out,e.total_in+=f,e.total_out+=h,r.total+=h,r.wrap&4&&h&&(e.adler=r.check=r.flags?jl(r.check,s,h,e.next_out-h):Yj(r.check,s,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Cc?128:0)+(r.mode===Qg||r.mode===Nw?256:0),(f===0&&h===0||t===f3)&&T===lf&&(T=fQ),T},wQ=e=>{if(Nf(e))return lo;let t=e.state;return t.window&&(t.window=null),e.state=null,lf},jQ=(e,t)=>{if(Nf(e))return lo;const r=e.state;return(r.wrap&2)===0?lo:(r.head=t,t.done=!1,lf)},NQ=(e,t)=>{const r=t.length;let n,s,a;return Nf(e)||(n=e.state,n.wrap!==0&&n.mode!==jv)?lo:n.mode===jv&&(s=1,s=Yj(s,t,r,0),s!==n.check)?q8:(a=Q8(e,t,r,r),a?(n.mode=K8,H8):(n.havedict=1,lf))};var SQ=X8,AQ=Z8,PQ=Y8,kQ=vQ,CQ=J8,EQ=yQ,_Q=wQ,TQ=jQ,OQ=NQ,IQ="pako inflate (from Nodeca project)",Oc={inflateReset:SQ,inflateReset2:AQ,inflateResetKeep:PQ,inflateInit:kQ,inflateInit2:CQ,inflate:EQ,inflateEnd:_Q,inflateGetHeader:TQ,inflateSetDictionary:OQ,inflateInfo:IQ};function LQ(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var zQ=LQ;const eR=Object.prototype.toString,{Z_NO_FLUSH:DQ,Z_FINISH:MQ,Z_OK:c0,Z_STREAM_END:kw,Z_NEED_DICT:Cw,Z_STREAM_ERROR:RQ,Z_DATA_ERROR:M3,Z_MEM_ERROR:$Q}=F8;function W0(e){this.options=B8.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eQ,this.strm.avail_out=0;let r=Oc.inflateInit2(this.strm,t.windowBits);if(r!==c0)throw new Error(Xj[r]);if(this.header=new zQ,Oc.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Zj.string2buf(t.dictionary):eR.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Oc.inflateSetDictionary(this.strm,t.dictionary),r!==c0)))throw new Error(Xj[r])}W0.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize,s=this.options.dictionary;let a,o,l;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?MQ:DQ,eR.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),a=Oc.inflate(r,o),a===Cw&&s&&(a=Oc.inflateSetDictionary(r,s),a===c0?a=Oc.inflate(r,o):a===M3&&(a=Cw));r.avail_in>0&&a===kw&&r.state.wrap>0&&e[r.next_in]!==0;)Oc.inflateReset(r),a=Oc.inflate(r,o);switch(a){case RQ:case M3:case Cw:case $Q:return this.onEnd(a),this.ended=!0,!1}if(l=r.avail_out,r.next_out&&(r.avail_out===0||a===kw))if(this.options.to==="string"){let c=Zj.utf8border(r.output,r.next_out),d=r.next_out-c,u=Zj.buf2string(r.output,c);r.next_out=d,r.avail_out=n-d,d&&r.output.set(r.output.subarray(c,c+d),0),this.onData(u)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(!(a===c0&&l===0)){if(a===kw)return a=Oc.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(r.avail_in===0)break}}return!0};W0.prototype.onData=function(e){this.chunks.push(e)};W0.prototype.onEnd=function(e){e===c0&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=B8.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function FQ(e,t){const r=new W0(t);if(r.push(e),r.err)throw r.msg||Xj[r.err];return r.result}var BQ=W0,VQ=FQ,WQ={Inflate:BQ,inflate:VQ};const{Inflate:UQ,inflate:qQ}=WQ;var R3=UQ,HQ=qQ;const tR=[];for(let e=0;e<256;e++){let t=e;for(let r=0;r<8;r++)t&1?t=3988292384^t>>>1:t=t>>>1;tR[e]=t}const $3=4294967295;function KQ(e,t,r){let n=e;for(let s=0;s<r;s++)n=tR[(n^t[s])&255]^n>>>8;return n}function GQ(e,t){return(KQ($3,e,t)^$3)>>>0}function F3(e,t,r){const n=e.readUint32(),s=GQ(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(s!==n)throw new Error(`CRC mismatch for chunk ${r}. Expected ${n}, found ${s}`)}function rR(e,t,r){for(let n=0;n<r;n++)t[n]=e[n]}function nR(e,t,r,n){let s=0;for(;s<n;s++)t[s]=e[s];for(;s<r;s++)t[s]=e[s]+t[s-n]&255}function sR(e,t,r,n){let s=0;if(r.length===0)for(;s<n;s++)t[s]=e[s];else for(;s<n;s++)t[s]=e[s]+r[s]&255}function iR(e,t,r,n,s){let a=0;if(r.length===0){for(;a<s;a++)t[a]=e[a];for(;a<n;a++)t[a]=e[a]+(t[a-s]>>1)&255}else{for(;a<s;a++)t[a]=e[a]+(r[a]>>1)&255;for(;a<n;a++)t[a]=e[a]+(t[a-s]+r[a]>>1)&255}}function aR(e,t,r,n,s){let a=0;if(r.length===0){for(;a<s;a++)t[a]=e[a];for(;a<n;a++)t[a]=e[a]+t[a-s]&255}else{for(;a<s;a++)t[a]=e[a]+r[a]&255;for(;a<n;a++)t[a]=e[a]+YQ(t[a-s],r[a],r[a-s])&255}}function YQ(e,t,r){const n=e+t-r,s=Math.abs(n-e),a=Math.abs(n-t),o=Math.abs(n-r);return s<=a&&s<=o?e:a<=o?t:r}function XQ(e,t,r,n,s,a){switch(e){case 0:rR(t,r,s);break;case 1:nR(t,r,s,a);break;case 2:sR(t,r,n,s);break;case 3:iR(t,r,n,s,a);break;case 4:aR(t,r,n,s,a);break;default:throw new Error(`Unsupported filter: ${e}`)}}const ZQ=new Uint16Array([255]),JQ=new Uint8Array(ZQ.buffer),QQ=JQ[0]===255;function eee(e){const{data:t,width:r,height:n,channels:s,depth:a}=e,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],l=Math.ceil(a/8)*s,c=new Uint8Array(n*r*l);let d=0;for(let u=0;u<7;u++){const f=o[u],h=Math.ceil((r-f.x)/f.xStep),p=Math.ceil((n-f.y)/f.yStep);if(h<=0||p<=0)continue;const g=h*l,v=new Uint8Array(g);for(let x=0;x<p;x++){const b=t[d++],j=t.subarray(d,d+g);d+=g;const N=new Uint8Array(g);XQ(b,j,N,v,g,l),v.set(N);for(let w=0;w<h;w++){const A=f.x+w*f.xStep,P=f.y+x*f.yStep;if(!(A>=r||P>=n))for(let E=0;E<l;E++)c[(P*r+A)*l+E]=N[w*l+E]}}}if(a===16){const u=new Uint16Array(c.buffer);if(QQ)for(let f=0;f<u.length;f++)u[f]=tee(u[f]);return u}else return c}function tee(e){return(e&255)<<8|e>>8&255}const ree=new Uint16Array([255]),nee=new Uint8Array(ree.buffer),see=nee[0]===255,iee=new Uint8Array(0);function B3(e){const{data:t,width:r,height:n,channels:s,depth:a}=e,o=Math.ceil(a/8)*s,l=Math.ceil(a/8*s*r),c=new Uint8Array(n*l);let d=iee,u=0,f,h;for(let p=0;p<n;p++){switch(f=t.subarray(u+1,u+1+l),h=c.subarray(p*l,(p+1)*l),t[u]){case 0:rR(f,h,l);break;case 1:nR(f,h,l,o);break;case 2:sR(f,h,d,l);break;case 3:iR(f,h,d,l,o);break;case 4:aR(f,h,d,l,o);break;default:throw new Error(`Unsupported filter: ${t[u]}`)}d=h,u+=l+1}if(a===16){const p=new Uint16Array(c.buffer);if(see)for(let g=0;g<p.length;g++)p[g]=aee(p[g]);return p}else return c}function aee(e){return(e&255)<<8|e>>8&255}const Ux=Uint8Array.of(137,80,78,71,13,10,26,10);function V3(e){if(!oee(e.readBytes(Ux.length)))throw new Error("wrong PNG signature")}function oee(e){if(e.length<Ux.length)return!1;for(let t=0;t<Ux.length;t++)if(e[t]!==Ux[t])return!1;return!0}const lee="tEXt",cee=0,oR=new TextDecoder("latin1");function dee(e){if(fee(e),e.length===0||e.length>79)throw new Error("keyword length must be between 1 and 79")}const uee=/^[\u0000-\u00FF]*$/;function fee(e){if(!uee.test(e))throw new Error("invalid latin1 text")}function hee(e,t,r){const n=lR(t);e[n]=pee(t,r-n.length-1)}function lR(e){for(e.mark();e.readByte()!==cee;);const t=e.offset;e.reset();const r=oR.decode(e.readBytes(t-e.offset-1));return e.skip(1),dee(r),r}function pee(e,t){return oR.decode(e.readBytes(t))}const ga={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},Ew={UNKNOWN:-1,DEFLATE:0},W3={UNKNOWN:-1,ADAPTIVE:0},_w={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},tx={NONE:0,BACKGROUND:1,PREVIOUS:2},Tw={SOURCE:0,OVER:1};class mee extends RA{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;constructor(t,r={}){super(t);const{checkCrc:n=!1}=r;this._checkCrc=n,this._inflator=new R3,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=Ew.UNKNOWN,this._filterMethod=W3.UNKNOWN,this._interlaceMethod=_w.UNKNOWN,this._colorType=ga.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(V3(this);!this._end;){const t=this.readUint32(),r=this.readChars(4);this.decodeChunk(t,r)}return this.decodeImage(),this._png}decodeApng(){for(V3(this);!this._end;){const t=this.readUint32(),r=this.readChars(4);this.decodeApngChunk(t,r)}return this.decodeApngImage(),this._apng}decodeChunk(t,r){const n=this.offset;switch(r){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case lee:hee(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t);break}if(this.offset-n!==t)throw new Error(`Length mismatch while decoding chunk ${r}`);this._checkCrc?F3(this,t+4,r):this.skip(4)}decodeApngChunk(t,r){const n=this.offset;switch(r!=="fdAT"&&r!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),r){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,r),this.offset=n+t;break}if(this.offset-n!==t)throw new Error(`Length mismatch while decoding chunk ${r}`);this._checkCrc?F3(this,t+4,r):this.skip(4)}decodeIHDR(){const t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=gee(this.readUint8());const r=this.readUint8();this._colorType=r;let n;switch(r){case ga.GREYSCALE:n=1;break;case ga.TRUECOLOUR:n=3;break;case ga.INDEXED_COLOUR:n=1;break;case ga.GREYSCALE_ALPHA:n=2;break;case ga.TRUECOLOUR_ALPHA:n=4;break;case ga.UNKNOWN:default:throw new Error(`Unknown color type: ${r}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==Ew.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const t={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(t)}decodePLTE(t){if(t%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${t}`);const r=t/3;this._hasPalette=!0;const n=[];this._palette=n;for(let s=0;s<r;s++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(t){this._writingDataChunks=!0;const r=t,n=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,n,r)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(t)}decodeFDAT(t){this._writingDataChunks=!0;let r=t,n=this.offset+this.byteOffset;if(n+=4,r-=4,this._inflator.push(new Uint8Array(this.buffer,n,r)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(t)}decodetRNS(t){switch(this._colorType){case ga.GREYSCALE:case ga.TRUECOLOUR:{if(t%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${t}`);if(t/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${t/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let r=0;r<t/2;r++)this._transparency[r]=this.readUint16();break}case ga.INDEXED_COLOUR:{if(t>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${t} vs ${this._palette.length})`);let r=0;for(;r<t;r++){const n=this.readByte();this._palette[r].push(n)}for(;r<this._palette.length;r++)this._palette[r].push(255);break}case ga.UNKNOWN:case ga.GREYSCALE_ALPHA:case ga.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(t){const r=lR(this),n=this.readUint8();if(n!==Ew.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${n}`);const s=this.readBytes(t-r.length-2);this._png.iccEmbeddedProfile={name:r,profile:HQ(s)}}decodepHYs(){const t=this.readUint32(),r=this.readUint32(),n=this.readByte();this._png.resolution={x:t,y:r,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let t=0;t<this._numberOfFrames;t++){const r={sequenceNumber:this._frames[t].sequenceNumber,delayNumber:this._frames[t].delayNumber,delayDenominator:this._frames[t].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(t);if(n){if(n.data=B3({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),t===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)r.data=n.data;else{const s=this._apng.frames.at(t-1);this.disposeFrame(n,s,r),this.addFrameDataToCanvas(r,n)}this._apng.frames.push(r)}}return this._apng}disposeFrame(t,r,n){switch(t.disposeOp){case tx.NONE:break;case tx.BACKGROUND:for(let s=0;s<this._png.height;s++)for(let a=0;a<this._png.width;a++){const o=(s*t.width+a)*this._png.channels;for(let l=0;l<this._png.channels;l++)n.data[o+l]=0}break;case tx.PREVIOUS:n.data.set(r.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(t,r){const n=1<<this._png.depth,s=(a,o)=>{const l=((a+r.yOffset)*this._png.width+r.xOffset+o)*this._png.channels,c=(a*r.width+o)*this._png.channels;return{index:l,frameIndex:c}};switch(r.blendOp){case Tw.SOURCE:for(let a=0;a<r.height;a++)for(let o=0;o<r.width;o++){const{index:l,frameIndex:c}=s(a,o);for(let d=0;d<this._png.channels;d++)t.data[l+d]=r.data[c+d]}break;case Tw.OVER:for(let a=0;a<r.height;a++)for(let o=0;o<r.width;o++){const{index:l,frameIndex:c}=s(a,o);for(let d=0;d<this._png.channels;d++){const u=r.data[c+this._png.channels-1]/n,f=d%(this._png.channels-1)===0?1:r.data[c+d],h=Math.floor(u*f+(1-u)*t.data[l+d]);t.data[l+d]+=h}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);const t=this._isAnimated?(this._frames?.at(0)).data:this._inflator.result;if(this._filterMethod!==W3.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===_w.NO_INTERLACE)this._png.data=B3({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===_w.ADAM7)this._png.data=eee({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const t=this._inflator.result,r=this._frames.at(-1);r?r.data=t:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:tx.NONE,blendOp:Tw.SOURCE,data:t}),this._inflator=new R3,this._writingDataChunks=!1}}function gee(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw new Error(`invalid bit depth: ${e}`);return e}var U3;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.METRE=1]="METRE"})(U3||(U3={}));function xee(e,t){return new mee(e,t).decode()}var Kt=(function(){return typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this})();function Ow(){Kt.console&&typeof Kt.console.log=="function"&&Kt.console.log.apply(Kt.console,arguments)}var on={log:Ow,warn:function(e){Kt.console&&(typeof Kt.console.warn=="function"?Kt.console.warn.apply(Kt.console,arguments):Ow.call(null,arguments))},error:function(e){Kt.console&&(typeof Kt.console.error=="function"?Kt.console.error.apply(Kt.console,arguments):Ow(e))}};function Iw(e,t,r){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.onload=function(){Iu(n.response,t,r)},n.onerror=function(){on.error("could not download file")},n.send()}function q3(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function rx(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var Iu=Kt.saveAs||((typeof window>"u"?"undefined":Vr(window))!=="object"||window!==Kt?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(e,t,r){var n=Kt.URL||Kt.webkitURL,s=document.createElement("a");t=t||e.name||"download",s.download=t,s.rel="noopener",typeof e=="string"?(s.href=e,s.origin!==location.origin?q3(s.href)?Iw(e,t,r):rx(s,s.target="_blank"):rx(s)):(s.href=n.createObjectURL(e),setTimeout(function(){n.revokeObjectURL(s.href)},4e4),setTimeout(function(){rx(s)},0))}:"msSaveOrOpenBlob"in navigator?function(e,t,r){if(t=t||e.name||"download",typeof e=="string")if(q3(e))Iw(e,t,r);else{var n=document.createElement("a");n.href=e,n.target="_blank",setTimeout(function(){rx(n)})}else navigator.msSaveOrOpenBlob((function(s,a){return a===void 0?a={autoBom:!1}:Vr(a)!=="object"&&(on.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(s.type)?new Blob(["\uFEFF",s],{type:s.type}):s})(e,r),t)}:function(e,t,r,n){if((n=n||open("","_blank"))&&(n.document.title=n.document.body.innerText="downloading..."),typeof e=="string")return Iw(e,t,r);var s=e.type==="application/octet-stream",a=/constructor/i.test(Kt.HTMLElement)||Kt.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||s&&a)&&(typeof FileReader>"u"?"undefined":Vr(FileReader))==="object"){var l=new FileReader;l.onloadend=function(){var u=l.result;u=o?u:u.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=u:location=u,n=null},l.readAsDataURL(e)}else{var c=Kt.URL||Kt.webkitURL,d=c.createObjectURL(e);n?n.location=d:location.href=d,n=null,setTimeout(function(){c.revokeObjectURL(d)},4e4)}});/**
22
22
  * A class to parse color values
23
23
  * @author Stoyan Stefanov <sstoo@gmail.com>
@@ -156,7 +156,7 @@ T* `):k.join(` Tj
156
156
  endobj\r
157
157
  `},r.outline.count_r=function(n,s){for(var a=0;a<s.children.length;a++)n.count++,this.count_r(n,s.children[a]);return n.count}}])})(Ot.API),(function(e){var t=[192,193,194,195,196,197,198,199];e.processJPEG=function(r,n,s,a,o,l){var c,d=this.decode.DCT_DECODE,u=null;if(typeof r=="string"||this.__addimage__.isArrayBuffer(r)||this.__addimage__.isArrayBufferView(r)){switch(r=o||r,r=this.__addimage__.isArrayBuffer(r)?new Uint8Array(r):r,c=(function(f){for(var h,p=256*f.charCodeAt(4)+f.charCodeAt(5),g=f.length,v={width:0,height:0,numcomponents:1},x=4;x<g;x+=2){if(x+=p,t.indexOf(f.charCodeAt(x+1))!==-1){h=256*f.charCodeAt(x+5)+f.charCodeAt(x+6),v={width:256*f.charCodeAt(x+7)+f.charCodeAt(x+8),height:h,numcomponents:f.charCodeAt(x+9)};break}p=256*f.charCodeAt(x+2)+f.charCodeAt(x+3)}return v})(r=this.__addimage__.isArrayBufferView(r)?this.__addimage__.arrayBufferToBinaryString(r):r),c.numcomponents){case 1:l=this.color_spaces.DEVICE_GRAY;break;case 4:l=this.color_spaces.DEVICE_CMYK;break;case 3:l=this.color_spaces.DEVICE_RGB}u={data:r,width:c.width,height:c.height,colorSpace:l,bitsPerComponent:8,filter:d,index:n,alias:s}}return u}})(Ot.API),Ot.API.processPNG=function(e,t,r,n){if(this.__addimage__.isArrayBuffer(e)&&(e=new Uint8Array(e)),this.__addimage__.isArrayBufferView(e)){var s,a=xee(e,{checkCrc:!0}),o=a.width,l=a.height,c=a.channels,d=a.palette,u=a.depth;s=d&&c===1?(function(T){for(var C=T.width,I=T.height,_=T.data,L=T.palette,$=T.depth,z=!1,R=[],J=[],Z=void 0,q=!1,Y=0,de=0;de<L.length;de++){var H=a3(L[de],4),M=H[0],V=H[1],U=H[2],F=H[3];R.push(M,V,U),F!=null&&(F===0?(Y++,J.length<1&&J.push(de)):F<255&&(q=!0))}if(q||Y>1){z=!0,J=void 0;var se=C*I;Z=new Uint8Array(se);for(var ue=new DataView(_.buffer),re=0;re<se;re++){var ee=Rw(ue,re,$),ie=a3(L[ee],4)[3];Z[re]=ie}}else Y===0&&(J=void 0);return{colorSpace:"Indexed",colorsPerPixel:1,sMaskBitsPerComponent:z?8:void 0,colorBytes:_,alphaBytes:Z,needSMask:z,palette:R,mask:J}})(a):c===2||c===4?(function(T){for(var C=T.data,I=T.width,_=T.height,L=T.channels,$=T.depth,z=L===2?"DeviceGray":"DeviceRGB",R=L-1,J=I*_,Z=R,q=J*Z,Y=1*J,de=Math.ceil(q*$/8),H=Math.ceil(Y*$/8),M=new Uint8Array(de),V=new Uint8Array(H),U=new DataView(C.buffer),F=new DataView(M.buffer),se=new DataView(V.buffer),ue=!1,re=0;re<J;re++){for(var ee=re*L,ie=0;ie<Z;ie++)cE(F,Rw(U,ee+ie,$),re*Z+ie,$);var xe=Rw(U,ee+Z,$);xe<(1<<$)-1&&(ue=!0),cE(se,xe,1*re,$)}return{colorSpace:z,colorsPerPixel:R,sMaskBitsPerComponent:ue?$:void 0,colorBytes:M,alphaBytes:V,needSMask:ue}})(a):(function(T){var C=T.data,I=T.channels===1?"DeviceGray":"DeviceRGB";return{colorSpace:I,colorsPerPixel:I==="DeviceGray"?1:3,colorBytes:C instanceof Uint16Array?(function(_){for(var L=_.length,$=new Uint8Array(2*L),z=new DataView($.buffer,$.byteOffset,$.byteLength),R=0;R<L;R++)z.setUint16(2*R,_[R],!1);return $})(C):C,needSMask:!1}})(a);var f,h,p,g=s,v=g.colorSpace,x=g.colorsPerPixel,b=g.sMaskBitsPerComponent,j=g.colorBytes,N=g.alphaBytes,w=g.needSMask,A=g.palette,P=g.mask,E=null;return n!==Ot.API.image_compression.NONE&&typeof Gj=="function"?(E=(function(T){var C;switch(T){case Ot.API.image_compression.FAST:C=11;break;case Ot.API.image_compression.MEDIUM:C=13;break;case Ot.API.image_compression.SLOW:C=14;break;default:C=12}return C})(n),f=this.decode.FLATE_DECODE,h="/Predictor ".concat(E," /Colors ").concat(x," /BitsPerComponent ").concat(u," /Columns ").concat(o),e=sE(j,Math.ceil(o*x*u/8),x,u,n),w&&(p=sE(N,Math.ceil(o*b/8),1,b,n))):(f=void 0,h=void 0,e=j,w&&(p=N)),(this.__addimage__.isArrayBuffer(e)||this.__addimage__.isArrayBufferView(e))&&(e=this.__addimage__.arrayBufferToBinaryString(e)),(p&&this.__addimage__.isArrayBuffer(p)||this.__addimage__.isArrayBufferView(p))&&(p=this.__addimage__.arrayBufferToBinaryString(p)),{alias:r,data:e,index:t,filter:f,decodeParameters:h,transparency:P,palette:A,sMask:p,predictor:E,width:o,height:l,bitsPerComponent:u,sMaskBitsPerComponent:b,colorSpace:v}}},(function(e){e.processGIF89A=function(t,r,n,s){var a=new Ree(t),o=a.width,l=a.height,c=[];a.decodeAndBlitFrameRGBA(0,c);var d={data:c,width:o,height:l},u=new $w(100).encode(d,100);return e.processJPEG.call(this,u,r,n,s)},e.processGIF87A=e.processGIF89A})(Ot.API),Oo.prototype.parseHeader=function(){if(this.fileSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.reserved=this.datav.getUint32(this.pos,!0),this.pos+=4,this.offset=this.datav.getUint32(this.pos,!0),this.pos+=4,this.headerSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.width=this.datav.getUint32(this.pos,!0),this.pos+=4,this.height=this.datav.getInt32(this.pos,!0),this.pos+=4,this.planes=this.datav.getUint16(this.pos,!0),this.pos+=2,this.bitPP=this.datav.getUint16(this.pos,!0),this.pos+=2,this.compress=this.datav.getUint32(this.pos,!0),this.pos+=4,this.rawSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.hr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.vr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.colors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.importantColors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.bitPP===16&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var e=this.colors===0?1<<this.bitPP:this.colors;this.palette=new Array(e);for(var t=0;t<e;t++){var r=this.datav.getUint8(this.pos++,!0),n=this.datav.getUint8(this.pos++,!0),s=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0);this.palette[t]={red:s,green:n,blue:r,quad:a}}}this.height<0&&(this.height*=-1,this.bottom_up=!1)},Oo.prototype.parseBGR=function(){this.pos=this.offset;var e="bit"+this.bitPP,t=this.width*this.height*4;if(t>536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");this.data=new Uint8Array(t);try{this[e]()}catch(r){on.log("bit decode error:"+r)}},Oo.prototype.bit1=function(){var e,t=Math.ceil(this.width/8),r=t%4;for(e=this.height-1;e>=0;e--){for(var n=this.bottom_up?e:this.height-1-e,s=0;s<t;s++)for(var a=this.datav.getUint8(this.pos++,!0),o=n*this.width*4+8*s*4,l=0;l<8&&8*s+l<this.width;l++){var c=this.palette[a>>7-l&1];this.data[o+4*l]=c.blue,this.data[o+4*l+1]=c.green,this.data[o+4*l+2]=c.red,this.data[o+4*l+3]=255}r!==0&&(this.pos+=4-r)}},Oo.prototype.bit4=function(){for(var e=Math.ceil(this.width/2),t=e%4,r=this.height-1;r>=0;r--){for(var n=this.bottom_up?r:this.height-1-r,s=0;s<e;s++){var a=this.datav.getUint8(this.pos++,!0),o=n*this.width*4+2*s*4,l=a>>4,c=15&a,d=this.palette[l];if(this.data[o]=d.blue,this.data[o+1]=d.green,this.data[o+2]=d.red,this.data[o+3]=255,2*s+1>=this.width)break;d=this.palette[c],this.data[o+4]=d.blue,this.data[o+4+1]=d.green,this.data[o+4+2]=d.red,this.data[o+4+3]=255}t!==0&&(this.pos+=4-t)}},Oo.prototype.bit8=function(){for(var e=this.width%4,t=this.height-1;t>=0;t--){for(var r=this.bottom_up?t:this.height-1-t,n=0;n<this.width;n++){var s=this.datav.getUint8(this.pos++,!0),a=r*this.width*4+4*n;if(s<this.palette.length){var o=this.palette[s];this.data[a]=o.red,this.data[a+1]=o.green,this.data[a+2]=o.blue,this.data[a+3]=255}else this.data[a]=255,this.data[a+1]=255,this.data[a+2]=255,this.data[a+3]=255}e!==0&&(this.pos+=4-e)}},Oo.prototype.bit15=function(){for(var e=this.width%3,t=parseInt("11111",2),r=this.height-1;r>=0;r--){for(var n=this.bottom_up?r:this.height-1-r,s=0;s<this.width;s++){var a=this.datav.getUint16(this.pos,!0);this.pos+=2;var o=(a&t)/t*255|0,l=(a>>5&t)/t*255|0,c=(a>>10&t)/t*255|0,d=a>>15?255:0,u=n*this.width*4+4*s;this.data[u]=c,this.data[u+1]=l,this.data[u+2]=o,this.data[u+3]=d}this.pos+=e}},Oo.prototype.bit16=function(){for(var e=this.width%3,t=parseInt("11111",2),r=parseInt("111111",2),n=this.height-1;n>=0;n--){for(var s=this.bottom_up?n:this.height-1-n,a=0;a<this.width;a++){var o=this.datav.getUint16(this.pos,!0);this.pos+=2;var l=(o&t)/t*255|0,c=(o>>5&r)/r*255|0,d=(o>>11)/t*255|0,u=s*this.width*4+4*a;this.data[u]=d,this.data[u+1]=c,this.data[u+2]=l,this.data[u+3]=255}this.pos+=e}},Oo.prototype.bit24=function(){for(var e=this.height-1;e>=0;e--){for(var t=this.bottom_up?e:this.height-1-e,r=0;r<this.width;r++){var n=this.datav.getUint8(this.pos++,!0),s=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=t*this.width*4+4*r;this.data[o]=a,this.data[o+1]=s,this.data[o+2]=n,this.data[o+3]=255}this.pos+=this.width%4}},Oo.prototype.bit32=function(){for(var e=this.height-1;e>=0;e--)for(var t=this.bottom_up?e:this.height-1-e,r=0;r<this.width;r++){var n=this.datav.getUint8(this.pos++,!0),s=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=this.datav.getUint8(this.pos++,!0),l=t*this.width*4+4*r;this.data[l]=a,this.data[l+1]=s,this.data[l+2]=n,this.data[l+3]=o}},Oo.prototype.getData=function(){return this.data},(function(e){e.processBMP=function(t,r,n,s){var a=new Oo(t,!1),o=a.width,l=a.height,c={data:a.getData(),width:o,height:l},d=new $w(100).encode(c,100);return e.processJPEG.call(this,d,r,n,s)}})(Ot.API),uE.prototype.getData=function(){return this.data},(function(e){e.processWEBP=function(t,r,n,s){var a=new uE(t),o=a.width,l=a.height,c={data:a.getData(),width:o,height:l},d=new $w(100).encode(c,100);return e.processJPEG.call(this,d,r,n,s)}})(Ot.API),Ot.API.processRGBA=function(e,t,r){for(var n=e.data,s=n.length,a=new Uint8Array(s/4*3),o=new Uint8Array(s/4),l=0,c=0,d=0;d<s;d+=4){var u=n[d],f=n[d+1],h=n[d+2],p=n[d+3];a[l++]=u,a[l++]=f,a[l++]=h,o[c++]=p}var g=this.__addimage__.arrayBufferToBinaryString(a);return{alpha:this.__addimage__.arrayBufferToBinaryString(o),data:g,index:t,alias:r,colorSpace:"DeviceRGB",bitsPerComponent:8,width:e.width,height:e.height}},Ot.API.setLanguage=function(e){return this.internal.languageSettings===void 0&&(this.internal.languageSettings={},this.internal.languageSettings.isSubscribed=!1),{af:"Afrikaans",sq:"Albanian",ar:"Arabic (Standard)","ar-DZ":"Arabic (Algeria)","ar-BH":"Arabic (Bahrain)","ar-EG":"Arabic (Egypt)","ar-IQ":"Arabic (Iraq)","ar-JO":"Arabic (Jordan)","ar-KW":"Arabic (Kuwait)","ar-LB":"Arabic (Lebanon)","ar-LY":"Arabic (Libya)","ar-MA":"Arabic (Morocco)","ar-OM":"Arabic (Oman)","ar-QA":"Arabic (Qatar)","ar-SA":"Arabic (Saudi Arabia)","ar-SY":"Arabic (Syria)","ar-TN":"Arabic (Tunisia)","ar-AE":"Arabic (U.A.E.)","ar-YE":"Arabic (Yemen)",an:"Aragonese",hy:"Armenian",as:"Assamese",ast:"Asturian",az:"Azerbaijani",eu:"Basque",be:"Belarusian",bn:"Bengali",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",zh:"Chinese","zh-HK":"Chinese (Hong Kong)","zh-CN":"Chinese (PRC)","zh-SG":"Chinese (Singapore)","zh-TW":"Chinese (Taiwan)",cv:"Chuvash",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch (Standard)","nl-BE":"Dutch (Belgian)",en:"English","en-AU":"English (Australia)","en-BZ":"English (Belize)","en-CA":"English (Canada)","en-IE":"English (Ireland)","en-JM":"English (Jamaica)","en-NZ":"English (New Zealand)","en-PH":"English (Philippines)","en-ZA":"English (South Africa)","en-TT":"English (Trinidad & Tobago)","en-GB":"English (United Kingdom)","en-US":"English (United States)","en-ZW":"English (Zimbabwe)",eo:"Esperanto",et:"Estonian",fo:"Faeroese",fj:"Fijian",fi:"Finnish",fr:"French (Standard)","fr-BE":"French (Belgium)","fr-CA":"French (Canada)","fr-FR":"French (France)","fr-LU":"French (Luxembourg)","fr-MC":"French (Monaco)","fr-CH":"French (Switzerland)",fy:"Frisian",fur:"Friulian",gd:"Gaelic (Scots)","gd-IE":"Gaelic (Irish)",gl:"Galacian",ka:"Georgian",de:"German (Standard)","de-AT":"German (Austria)","de-DE":"German (Germany)","de-LI":"German (Liechtenstein)","de-LU":"German (Luxembourg)","de-CH":"German (Switzerland)",el:"Greek",gu:"Gujurati",ht:"Haitian",he:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",iu:"Inuktitut",ga:"Irish",it:"Italian (Standard)","it-CH":"Italian (Switzerland)",ja:"Japanese",kn:"Kannada",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ky:"Kirghiz",tlh:"Klingon",ko:"Korean","ko-KP":"Korean (North Korea)","ko-KR":"Korean (South Korea)",la:"Latin",lv:"Latvian",lt:"Lithuanian",lb:"Luxembourgish",mk:"North Macedonia",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mo:"Moldavian",nv:"Navajo",ng:"Ndonga",ne:"Nepali",no:"Norwegian",nb:"Norwegian (Bokmal)",nn:"Norwegian (Nynorsk)",oc:"Occitan",or:"Oriya",om:"Oromo",fa:"Persian","fa-IR":"Persian/Iran",pl:"Polish",pt:"Portuguese","pt-BR":"Portuguese (Brazil)",pa:"Punjabi","pa-IN":"Punjabi (India)","pa-PK":"Punjabi (Pakistan)",qu:"Quechua",rm:"Rhaeto-Romanic",ro:"Romanian","ro-MO":"Romanian (Moldavia)",ru:"Russian","ru-MO":"Russian (Moldavia)",sz:"Sami (Lappish)",sg:"Sango",sa:"Sanskrit",sc:"Sardinian",sd:"Sindhi",si:"Singhalese",sr:"Serbian",sk:"Slovak",sl:"Slovenian",so:"Somani",sb:"Sorbian",es:"Spanish","es-AR":"Spanish (Argentina)","es-BO":"Spanish (Bolivia)","es-CL":"Spanish (Chile)","es-CO":"Spanish (Colombia)","es-CR":"Spanish (Costa Rica)","es-DO":"Spanish (Dominican Republic)","es-EC":"Spanish (Ecuador)","es-SV":"Spanish (El Salvador)","es-GT":"Spanish (Guatemala)","es-HN":"Spanish (Honduras)","es-MX":"Spanish (Mexico)","es-NI":"Spanish (Nicaragua)","es-PA":"Spanish (Panama)","es-PY":"Spanish (Paraguay)","es-PE":"Spanish (Peru)","es-PR":"Spanish (Puerto Rico)","es-ES":"Spanish (Spain)","es-UY":"Spanish (Uruguay)","es-VE":"Spanish (Venezuela)",sx:"Sutu",sw:"Swahili",sv:"Swedish","sv-FI":"Swedish (Finland)","sv-SV":"Swedish (Sweden)",ta:"Tamil",tt:"Tatar",te:"Teluga",th:"Thai",tig:"Tigre",ts:"Tsonga",tn:"Tswana",tr:"Turkish",tk:"Turkmen",uk:"Ukrainian",hsb:"Upper Sorbian",ur:"Urdu",ve:"Venda",vi:"Vietnamese",vo:"Volapuk",wa:"Walloon",cy:"Welsh",xh:"Xhosa",ji:"Yiddish",zu:"Zulu"}[e]!==void 0&&(this.internal.languageSettings.languageCode=e,this.internal.languageSettings.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",function(){this.internal.write("/Lang ("+this.internal.languageSettings.languageCode+")")}),this.internal.languageSettings.isSubscribed=!0)),this},ih=Ot.API,sx=ih.getCharWidthsArray=function(e,t){var r,n,s=(t=t||{}).font||this.internal.getFont(),a=t.fontSize||this.internal.getFontSize(),o=t.charSpace||this.internal.getCharSpace(),l=t.widths?t.widths:s.metadata.Unicode.widths,c=l.fof?l.fof:1,d=t.kerning?t.kerning:s.metadata.Unicode.kerning,u=d.fof?d.fof:1,f=t.doKerning!==!1,h=0,p=e.length,g=0,v=l[0]||c,x=[];for(r=0;r<p;r++)n=e.charCodeAt(r),typeof s.metadata.widthOfString=="function"?x.push((s.metadata.widthOfGlyph(s.metadata.characterToGlyph(n))+o*(1e3/a)||0)/1e3):(h=f&&Vr(d[n])==="object"&&!isNaN(parseInt(d[n][g],10))?d[n][g]/u:0,x.push((l[n]||v)/c+h)),g=n;return x},tE=ih.getStringUnitWidth=function(e,t){var r=(t=t||{}).fontSize||this.internal.getFontSize(),n=t.font||this.internal.getFont(),s=t.charSpace||this.internal.getCharSpace();return ih.processArabic&&(e=ih.processArabic(e)),typeof n.metadata.widthOfString=="function"?n.metadata.widthOfString(e,r,s)/r:sx.apply(this,arguments).reduce(function(a,o){return a+o},0)},rE=function(e,t,r,n){for(var s=[],a=0,o=e.length,l=0;a!==o&&l+t[a]<r;)l+=t[a],a++;s.push(e.slice(0,a));var c=a;for(l=0;a!==o;)l+t[a]>n&&(s.push(e.slice(c,a)),l=0,c=a),l+=t[a],a++;return c!==a&&s.push(e.slice(c,a)),s},nE=function(e,t,r){r||(r={});var n,s,a,o,l,c,d,u=[],f=[u],h=r.textIndent||0,p=0,g=0,v=e.split(" "),x=sx.apply(this,[" ",r])[0];if(c=r.lineIndent===-1?v[0].length+2:r.lineIndent||0){var b=Array(c).join(" "),j=[];v.map(function(w){(w=w.split(/\s*\n/)).length>1?j=j.concat(w.map(function(A,P){return(P&&A.length?`
158
158
  `:"")+A})):j.push(w[0])}),v=j,c=tE.apply(this,[b,r])}for(a=0,o=v.length;a<o;a++){var N=0;if(n=v[a],c&&n[0]==`
159
- `&&(n=n.substr(1),N=1),h+p+(g=(s=sx.apply(this,[n,r])).reduce(function(w,A){return w+A},0))>t||N){if(g>t){for(l=rE.apply(this,[n,s,t-(h+p),t]),u.push(l.shift()),u=[l.pop()];l.length;)f.push([l.shift()]);g=s.slice(n.length-(u[0]?u[0].length:0)).reduce(function(w,A){return w+A},0)}else u=[n];f.push(u),h=g+c,p=x}else u.push(n),h+=p+g,p=x}return d=c?function(w,A){return(A?b:"")+w.join(" ")}:function(w){return w.join(" ")},f.map(d)},ih.splitTextToSize=function(e,t,r){var n,s=(r=r||{}).fontSize||this.internal.getFontSize(),a=function(u){if(u.widths&&u.kerning)return{widths:u.widths,kerning:u.kerning};var f=this.internal.getFont(u.fontName,u.fontStyle),h="Unicode";return f.metadata[h]?{widths:f.metadata[h].widths||{0:1},kerning:f.metadata[h].kerning||{}}:{font:f.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}.call(this,r);n=Array.isArray(e)?e:String(e).split(/\r?\n/);var o=1*this.internal.scaleFactor*t/s;a.textIndent=r.textIndent?1*r.textIndent*this.internal.scaleFactor/s:0,a.lineIndent=r.lineIndent;var l,c,d=[];for(l=0,c=n.length;l<c;l++)d=d.concat(nE.apply(this,[n[l],o,a]));return d},(function(e){e.__fontmetrics__=e.__fontmetrics__||{};for(var t="0123456789abcdef",r="klmnopqrstuvwxyz",n={},s={},a=0;a<16;a++)n[r[a]]=t[a],s[t[a]]=r[a];var o=function(h){return"0x"+parseInt(h,10).toString(16)},l=e.__fontmetrics__.compress=function(h){var p,g,v,x,b=["{"];for(var j in h){if(p=h[j],isNaN(parseInt(j,10))?g="'"+j+"'":(j=parseInt(j,10),g=(g=o(j).slice(2)).slice(0,-1)+s[g.slice(-1)]),typeof p=="number")p<0?(v=o(p).slice(3),x="-"):(v=o(p).slice(2),x=""),v=x+v.slice(0,-1)+s[v.slice(-1)];else{if(Vr(p)!=="object")throw new Error("Don't know what to do with value type "+Vr(p)+".");v=l(p)}b.push(g+v)}return b.push("}"),b.join("")},c=e.__fontmetrics__.uncompress=function(h){if(typeof h!="string")throw new Error("Invalid argument passed to uncompress.");for(var p,g,v,x,b={},j=1,N=b,w=[],A="",P="",E=h.length-1,T=1;T<E;T+=1)(x=h[T])=="'"?p?(v=p.join(""),p=void 0):p=[]:p?p.push(x):x=="{"?(w.push([N,v]),N={},v=void 0):x=="}"?((g=w.pop())[0][g[1]]=N,v=void 0,N=g[0]):x=="-"?j=-1:v===void 0?n.hasOwnProperty(x)?(A+=n[x],v=parseInt(A,16)*j,j=1,A=""):A+=x:n.hasOwnProperty(x)?(P+=n[x],N[v]=parseInt(P,16)*j,j=1,v=void 0,P=""):P+=x;return b},d={codePages:["WinAnsiEncoding"],WinAnsiEncoding:c("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}")},u={Unicode:{Courier:d,"Courier-Bold":d,"Courier-BoldOblique":d,"Courier-Oblique":d,Helvetica:d,"Helvetica-Bold":d,"Helvetica-BoldOblique":d,"Helvetica-Oblique":d,"Times-Roman":d,"Times-Bold":d,"Times-BoldItalic":d,"Times-Italic":d}},f={Unicode:{"Courier-Oblique":c("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-BoldItalic":c("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"),"Helvetica-Bold":c("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),Courier:c("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-BoldOblique":c("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Bold":c("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"),Symbol:c("{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"),Helvetica:c("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"),"Helvetica-BoldOblique":c("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),ZapfDingbats:c("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-Bold":c("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Italic":c("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"),"Times-Roman":c("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"),"Helvetica-Oblique":c("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}")}};e.events.push(["addFont",function(h){var p=h.font,g=f.Unicode[p.postScriptName];g&&(p.metadata.Unicode={},p.metadata.Unicode.widths=g.widths,p.metadata.Unicode.kerning=g.kerning);var v=u.Unicode[p.postScriptName];v&&(p.metadata.Unicode.encoding=v,p.encoding=v.codePages[0])}])})(Ot.API),(function(e){var t=function(r){for(var n=r.length,s=new Uint8Array(n),a=0;a<n;a++)s[a]=r.charCodeAt(a);return s};e.API.events.push(["addFont",function(r){var n=void 0,s=r.font,a=r.instance;if(!s.isStandardFont){if(a===void 0)throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('"+s.postScriptName+"').");if(typeof(n=a.existsFileInVFS(s.postScriptName)===!1?a.loadFile(s.postScriptName):a.getFileFromVFS(s.postScriptName))!="string")throw new Error("Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('"+s.postScriptName+"').");(function(o,l){l=/^\x00\x01\x00\x00/.test(l)?t(l):t(qx(l)),o.metadata=e.API.TTFFont.open(l),o.metadata.Unicode=o.metadata.Unicode||{encoding:{},kerning:{},widths:[]},o.metadata.glyIdsUsed=[0]})(s,n)}}])})(Ot),Ot.API.addSvgAsImage=function(e,t,r,n,s,a,o,l){if(isNaN(t)||isNaN(r))throw on.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(n)||isNaN(s))throw on.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var c=document.createElement("canvas");c.width=n,c.height=s;var d=c.getContext("2d");d.fillStyle="#fff",d.fillRect(0,0,c.width,c.height);var u={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},f=this;return(Kt.canvg?Promise.resolve(Kt.canvg):_h(()=>import("./index.es-S9HBYdjC.js"),__vite__mapDeps([0]))).catch(function(h){return Promise.reject(new Error("Could not load canvg: "+h))}).then(function(h){return h.default?h.default:h}).then(function(h){return h.fromString(d,e,u)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(h){return h.render(u)}).then(function(){f.addImage(c.toDataURL("image/jpeg",1),t,r,n,s,o,l)})},Ot.API.putTotalPages=function(e){var t,r=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(t=new RegExp(e,"g"),r=this.internal.getNumberOfPages()):(t=new RegExp(this.pdfEscape16(e,this.internal.getFont()),"g"),r=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var n=1;n<=this.internal.getNumberOfPages();n++)for(var s=0;s<this.internal.pages[n].length;s++)this.internal.pages[n][s]=this.internal.pages[n][s].replace(t,r);return this},Ot.API.viewerPreferences=function(e,t){var r;e=e||{},t=t||!1;var n,s,a,o={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},l=Object.keys(o),c=[],d=0,u=0,f=0;function h(g,v){var x,b=!1;for(x=0;x<g.length;x+=1)g[x]===v&&(b=!0);return b}if(this.internal.viewerpreferences===void 0&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),r=this.internal.viewerpreferences.configuration,e==="reset"||t===!0){var p=l.length;for(f=0;f<p;f+=1)r[l[f]].value=r[l[f]].defaultValue,r[l[f]].explicitSet=!1}if(Vr(e)==="object"){for(s in e)if(a=e[s],h(l,s)&&a!==void 0){if(r[s].type==="boolean"&&typeof a=="boolean")r[s].value=a;else if(r[s].type==="name"&&h(r[s].valueSet,a))r[s].value=a;else if(r[s].type==="integer"&&Number.isInteger(a))r[s].value=a;else if(r[s].type==="array"){for(d=0;d<a.length;d+=1)if(n=!0,a[d].length===1&&typeof a[d][0]=="number")c.push(String(a[d]-1));else if(a[d].length>1){for(u=0;u<a[d].length;u+=1)typeof a[d][u]!="number"&&(n=!1);n===!0&&c.push([a[d][0]-1,a[d][1]-1].join(" "))}r[s].value="["+c.join(" ")+"]"}else r[s].value=r[s].defaultValue;r[s].explicitSet=!0}}return this.internal.viewerpreferences.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",function(){var g,v=[];for(g in r)r[g].explicitSet===!0&&(r[g].type==="name"?v.push("/"+g+" /"+r[g].value):v.push("/"+g+" "+r[g].value));v.length!==0&&this.internal.write(`/ViewerPreferences
159
+ `&&(n=n.substr(1),N=1),h+p+(g=(s=sx.apply(this,[n,r])).reduce(function(w,A){return w+A},0))>t||N){if(g>t){for(l=rE.apply(this,[n,s,t-(h+p),t]),u.push(l.shift()),u=[l.pop()];l.length;)f.push([l.shift()]);g=s.slice(n.length-(u[0]?u[0].length:0)).reduce(function(w,A){return w+A},0)}else u=[n];f.push(u),h=g+c,p=x}else u.push(n),h+=p+g,p=x}return d=c?function(w,A){return(A?b:"")+w.join(" ")}:function(w){return w.join(" ")},f.map(d)},ih.splitTextToSize=function(e,t,r){var n,s=(r=r||{}).fontSize||this.internal.getFontSize(),a=function(u){if(u.widths&&u.kerning)return{widths:u.widths,kerning:u.kerning};var f=this.internal.getFont(u.fontName,u.fontStyle),h="Unicode";return f.metadata[h]?{widths:f.metadata[h].widths||{0:1},kerning:f.metadata[h].kerning||{}}:{font:f.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}.call(this,r);n=Array.isArray(e)?e:String(e).split(/\r?\n/);var o=1*this.internal.scaleFactor*t/s;a.textIndent=r.textIndent?1*r.textIndent*this.internal.scaleFactor/s:0,a.lineIndent=r.lineIndent;var l,c,d=[];for(l=0,c=n.length;l<c;l++)d=d.concat(nE.apply(this,[n[l],o,a]));return d},(function(e){e.__fontmetrics__=e.__fontmetrics__||{};for(var t="0123456789abcdef",r="klmnopqrstuvwxyz",n={},s={},a=0;a<16;a++)n[r[a]]=t[a],s[t[a]]=r[a];var o=function(h){return"0x"+parseInt(h,10).toString(16)},l=e.__fontmetrics__.compress=function(h){var p,g,v,x,b=["{"];for(var j in h){if(p=h[j],isNaN(parseInt(j,10))?g="'"+j+"'":(j=parseInt(j,10),g=(g=o(j).slice(2)).slice(0,-1)+s[g.slice(-1)]),typeof p=="number")p<0?(v=o(p).slice(3),x="-"):(v=o(p).slice(2),x=""),v=x+v.slice(0,-1)+s[v.slice(-1)];else{if(Vr(p)!=="object")throw new Error("Don't know what to do with value type "+Vr(p)+".");v=l(p)}b.push(g+v)}return b.push("}"),b.join("")},c=e.__fontmetrics__.uncompress=function(h){if(typeof h!="string")throw new Error("Invalid argument passed to uncompress.");for(var p,g,v,x,b={},j=1,N=b,w=[],A="",P="",E=h.length-1,T=1;T<E;T+=1)(x=h[T])=="'"?p?(v=p.join(""),p=void 0):p=[]:p?p.push(x):x=="{"?(w.push([N,v]),N={},v=void 0):x=="}"?((g=w.pop())[0][g[1]]=N,v=void 0,N=g[0]):x=="-"?j=-1:v===void 0?n.hasOwnProperty(x)?(A+=n[x],v=parseInt(A,16)*j,j=1,A=""):A+=x:n.hasOwnProperty(x)?(P+=n[x],N[v]=parseInt(P,16)*j,j=1,v=void 0,P=""):P+=x;return b},d={codePages:["WinAnsiEncoding"],WinAnsiEncoding:c("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}")},u={Unicode:{Courier:d,"Courier-Bold":d,"Courier-BoldOblique":d,"Courier-Oblique":d,Helvetica:d,"Helvetica-Bold":d,"Helvetica-BoldOblique":d,"Helvetica-Oblique":d,"Times-Roman":d,"Times-Bold":d,"Times-BoldItalic":d,"Times-Italic":d}},f={Unicode:{"Courier-Oblique":c("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-BoldItalic":c("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"),"Helvetica-Bold":c("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),Courier:c("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-BoldOblique":c("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Bold":c("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"),Symbol:c("{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"),Helvetica:c("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"),"Helvetica-BoldOblique":c("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),ZapfDingbats:c("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-Bold":c("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Italic":c("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"),"Times-Roman":c("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"),"Helvetica-Oblique":c("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}")}};e.events.push(["addFont",function(h){var p=h.font,g=f.Unicode[p.postScriptName];g&&(p.metadata.Unicode={},p.metadata.Unicode.widths=g.widths,p.metadata.Unicode.kerning=g.kerning);var v=u.Unicode[p.postScriptName];v&&(p.metadata.Unicode.encoding=v,p.encoding=v.codePages[0])}])})(Ot.API),(function(e){var t=function(r){for(var n=r.length,s=new Uint8Array(n),a=0;a<n;a++)s[a]=r.charCodeAt(a);return s};e.API.events.push(["addFont",function(r){var n=void 0,s=r.font,a=r.instance;if(!s.isStandardFont){if(a===void 0)throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('"+s.postScriptName+"').");if(typeof(n=a.existsFileInVFS(s.postScriptName)===!1?a.loadFile(s.postScriptName):a.getFileFromVFS(s.postScriptName))!="string")throw new Error("Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('"+s.postScriptName+"').");(function(o,l){l=/^\x00\x01\x00\x00/.test(l)?t(l):t(qx(l)),o.metadata=e.API.TTFFont.open(l),o.metadata.Unicode=o.metadata.Unicode||{encoding:{},kerning:{},widths:[]},o.metadata.glyIdsUsed=[0]})(s,n)}}])})(Ot),Ot.API.addSvgAsImage=function(e,t,r,n,s,a,o,l){if(isNaN(t)||isNaN(r))throw on.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(n)||isNaN(s))throw on.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var c=document.createElement("canvas");c.width=n,c.height=s;var d=c.getContext("2d");d.fillStyle="#fff",d.fillRect(0,0,c.width,c.height);var u={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},f=this;return(Kt.canvg?Promise.resolve(Kt.canvg):_h(()=>import("./index.es-D071ILbD.js"),__vite__mapDeps([0]))).catch(function(h){return Promise.reject(new Error("Could not load canvg: "+h))}).then(function(h){return h.default?h.default:h}).then(function(h){return h.fromString(d,e,u)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(h){return h.render(u)}).then(function(){f.addImage(c.toDataURL("image/jpeg",1),t,r,n,s,o,l)})},Ot.API.putTotalPages=function(e){var t,r=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(t=new RegExp(e,"g"),r=this.internal.getNumberOfPages()):(t=new RegExp(this.pdfEscape16(e,this.internal.getFont()),"g"),r=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var n=1;n<=this.internal.getNumberOfPages();n++)for(var s=0;s<this.internal.pages[n].length;s++)this.internal.pages[n][s]=this.internal.pages[n][s].replace(t,r);return this},Ot.API.viewerPreferences=function(e,t){var r;e=e||{},t=t||!1;var n,s,a,o={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},l=Object.keys(o),c=[],d=0,u=0,f=0;function h(g,v){var x,b=!1;for(x=0;x<g.length;x+=1)g[x]===v&&(b=!0);return b}if(this.internal.viewerpreferences===void 0&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),r=this.internal.viewerpreferences.configuration,e==="reset"||t===!0){var p=l.length;for(f=0;f<p;f+=1)r[l[f]].value=r[l[f]].defaultValue,r[l[f]].explicitSet=!1}if(Vr(e)==="object"){for(s in e)if(a=e[s],h(l,s)&&a!==void 0){if(r[s].type==="boolean"&&typeof a=="boolean")r[s].value=a;else if(r[s].type==="name"&&h(r[s].valueSet,a))r[s].value=a;else if(r[s].type==="integer"&&Number.isInteger(a))r[s].value=a;else if(r[s].type==="array"){for(d=0;d<a.length;d+=1)if(n=!0,a[d].length===1&&typeof a[d][0]=="number")c.push(String(a[d]-1));else if(a[d].length>1){for(u=0;u<a[d].length;u+=1)typeof a[d][u]!="number"&&(n=!1);n===!0&&c.push([a[d][0]-1,a[d][1]-1].join(" "))}r[s].value="["+c.join(" ")+"]"}else r[s].value=r[s].defaultValue;r[s].explicitSet=!0}}return this.internal.viewerpreferences.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",function(){var g,v=[];for(g in r)r[g].explicitSet===!0&&(r[g].type==="name"?v.push("/"+g+" /"+r[g].value):v.push("/"+g+" "+r[g].value));v.length!==0&&this.internal.write(`/ViewerPreferences
160
160
  <<
161
161
  `+v.join(`
162
162
  `)+`
@@ -671,7 +671,7 @@ db.prepare(\`INSERT INTO \${tableName} ...\`).run(...);
671
671
  `)&&!tt?(ct==="\r"&&ur===`
672
672
  `&&pr++,lt.push(mt.trim()),lt.length>0&&lt.some(Wn=>Wn!=="")&&Ze.push(lt),lt=[],mt=""):mt+=ct}if((mt||lt.length>0)&&(lt.push(mt.trim()),lt.some(pr=>pr!=="")&&Ze.push(lt)),Ze.length===0)throw new Error(e==="zh"?"未在 CSV 文件中找到任何有效行。":"No valid lines resolved in the CSV.");const Ye=Ze[0].map(pr=>pr.toLowerCase().replace(/['"]/g,"").trim()),Ke=Ye.indexOf("title"),dr=Ye.indexOf("content");if(Ke===-1||dr===-1)throw new Error(e==="zh"?'找不到必填列。您的 CSV 文件首行必须包含 "title" 和 "content" 列。':'Required columns not found. First row of CSV must contain "title" and "content" headers.');const hr=[];for(let pr=1;pr<Ze.length;pr++){const ct=Ze[pr],ur=ct[Ke]||"",Wn=ct[dr]||"";ur.trim()&&hr.push({title:ur,content:Wn})}if(hr.length===0)throw new Error(e==="zh"?"找到表头,但数据行为空或包含空白课程标题。":"Headers resolved but no courses were found in data rows.");Oa(hr)}catch(je){cs("error"),$n(je.message||String(je))}},ce.onerror=()=>{cs("error"),$n(e==="zh"?"无法读取选取的 CSV 文件!":"Failure to read the CSV!")},ce.readAsText(K)},lr=async()=>{if(aa.length===0)return;cs("importing"),ac(0),lc(aa.length);let K=0;for(let ce=0;ce<aa.length;ce++){const ve=aa[ce];try{const je=await fetch("/api/lessons",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:ve.title,content:ve.content})});if(je.ok)K++;else{const Ze=await je.json();console.warn(`Failed to import item ${ce+1}:`,Ze)}}catch(je){console.warn(`Error importing item ${ce+1}:`,je)}ac(ce+1)}K>0?(cs("success"),await Gr()):(cs("error"),$n(e==="zh"?"所有课程项导入均失败。请检查控制台或格式。":"Failed to import any of the courses. Please check your console or schema."))},Gr=async()=>{try{const K=await fetch("/api/lessons");if(K.ok){const ce=await K.json();ue(ce),!at&&ce.length>0&&It(ce[0].id)}}catch(K){console.warn("Failed to fetch lessons",K)}},$t=async()=>{try{const K=await fetch("/api/plugins");if(K.ok){const ce=await K.json();Me(ce)}}catch(K){console.warn("Failed to fetch plugins",K)}};ss.useEffect(()=>{$r==="plugins"&&$t()},[$r]);const wt=async()=>{try{const K=await fetch("/api/commands/registered");if(!K.ok)return;const ce=K.headers.get("content-type");if(ce&&ce.includes("application/json")){const ve=await K.json();Array.isArray(ve)&&ke(ve)}}catch(K){console.warn("Failed to fetch registered commands",K)}},Je=async K=>{try{const ce=await fetch(`/api/vfs${K?`?parentId=${K}`:""}`);if(ce.ok){const ve=await ce.json();di(ve)}}catch(ce){console.warn("Failed to fetch VFS nodes",ce)}},Tn=async()=>{try{const K=await fetch("/api/events");K.ok&&tn(await K.json())}catch{}},Ut=async()=>{try{const K=await fetch("/api/approvals");K.ok&&cl(await K.json())}catch{}},cr=async()=>{try{const K=await fetch("/api/processes");K.ok&&ld(await K.json())}catch{}},jr=async()=>{try{const K=await fetch("/api/classes");K.ok&&Rt(await K.json())}catch{}},Bn=async()=>{try{const K=new Date().toISOString().split("T")[0],ce=await fetch(`/api/schedules/today?date=${K}`);if(ce.ok){const ve=await ce.json();ve.success&&ve.schedules&&Wp(ve.schedules)}}catch(K){console.warn("Failed to fetch today schedules",K)}},nn=async()=>{try{const K=await fetch("/api/students");K.ok&&$f(await K.json())}catch{}},fn=async()=>{try{sm(!0);const K=await fetch("/api/labs");K.ok&&O1(await K.json())}catch(K){console.error(K)}finally{sm(!1)}},sn=async K=>{try{const ce=await fetch(`/api/classes/${K}/students`);if(ce.ok){const ve=await ce.json();dc(je=>({...je,[K]:ve}))}}catch{}},ti=K=>{Da(ce=>{const ve=new Set(ce);return ve.has(K)?ve.delete(K):ve.add(K),ve})},ts=()=>{Da(K=>K.size===Ms.length&&Ms.length>0?new Set:new Set(Ms.map(ce=>ce.id)))},xr=K=>{la(ce=>{const ve=new Set(ce);return ve.has(K)?ve.delete(K):ve.add(K),ve})},Or=K=>{la(ce=>ce.size===K.length&&K.length>0?new Set:new Set(K.map(ve=>ve.id)))},On=async()=>{if(Ci.size!==0&&confirm(e==="zh"?`确认彻底删除选中的 ${Ci.size} 个班级吗?该操作不可恢复。`:`Delete ${Ci.size} selected classes permanently?`)){for(const K of Ci)await fetch(`/api/classes/${K}`,{method:"DELETE"});Da(new Set),await jr()}},Ir=async()=>{Ci.size!==0&&await Ua(Ms.filter(K=>Ci.has(K.id)))},Ps=async()=>{if(Ci.size===0)return;const K=window.prompt(e==="zh"?"请输入临时班级密码(留空则清除):":"Enter temporary passcode (leave empty to clear):");if(K!==null){for(const ce of Ci)await fetch(`/api/classes/${ce}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({class_passcode:K===""?null:K})});Da(new Set),await jr()}},pa=()=>{Ci.size!==0&&(uc(""),ou(new Date().toISOString().split("T")[0]),wo("schedule"))},Vn=async()=>{if(!(us.size===0||!Hs)&&confirm(e==="zh"?`确认彻底删除选中的 ${us.size} 名学生账号吗?将删除其全部关联数据,不可恢复。`:`Permanently delete ${us.size} selected student accounts?`)){for(const K of us)await fetch(`/api/students/${K}`,{method:"DELETE"});la(new Set),await sn(Hs)}},ui=async()=>{if(us.size===0||!Hs)return;const K=window.prompt(e==="zh"?"请输入要为选中学生设置的新密码:":"Enter new password for selected students:");if(!(K===null||K.trim()==="")){for(const ce of us)await fetch(`/api/students/${ce}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:K})});la(new Set),await sn(Hs)}},Br=()=>{us.size===0||!Hs||($a(""),wo("transfer"))},rs=()=>{us.size===0||!Hs||(uc(""),wo("lockedLesson"))},_i=async()=>{if(Hs){if(Ma==="schedule"){if(!Ra){alert(e==="zh"?"请选择课程":"Please select a lesson");return}for(const K of Ci)await fetch(`/api/classes/${K}/schedules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:Ra,scheduledDate:fc+" 09:00:00",status:"scheduled"})});Da(new Set)}else if(Ma==="lockedLesson"){if(!Ra){alert(e==="zh"?"请选择课程":"Please select a lesson");return}for(const K of us)await fetch(`/api/students/${K}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({locked_lesson_id:Ra})});la(new Set)}else if(Ma==="transfer"){if(!qi||qi===Hs){alert(e==="zh"?"请选择不同的目标班级":"Please select a different target class");return}for(const K of us)await fetch(`/api/classes/${Hs}/students/${K}`,{method:"DELETE"}),await fetch(`/api/classes/${qi}/students`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:K})});la(new Set)}wo(null),Hs&&await sn(Hs)}},fs=async K=>{try{const ce=await fetch(`/api/classes/${K}/progress`);if(ce.ok){const ve=await ce.json();gu(je=>({...je,[K]:ve}))}}catch{}},[Hn,Ti]=m.useState({}),[fi,Oi]=m.useState({}),[Yr,Ii]=m.useState({}),[ma,Ac]=m.useState(null),[ko,ks]=m.useState(""),[Xf,lm]=m.useState(""),Ha=async K=>{try{const ce=await fetch(`/api/classes/${K}/dashboard`);if(ce.ok){const ve=await ce.json();Ti(je=>({...je,[K]:ve}))}}catch{}},xu=ss.useMemo(()=>{if(!bd)return null;const K=fl[bd]||[],ce=Hn[bd];if(!ce||!ce.assignments||K.length===0)return null;const ve=ce.assignments||[],je=ce.performance||[],Ze=ve.map(Ye=>{let Ke="assignment";if(Qs[Ye.id])Ke=Qs[Ye.id];else{const dr=Ye.content&&Ye.content.startsWith('{"quizType":"mcq_learning_objectives"'),hr=Ye.title&&(Ye.title.toLowerCase().includes("quiz")||Ye.title.toLowerCase().includes("test")||Ye.title.includes("测验")||Ye.title.includes("测试"));Ke=dr||hr?"quiz":"assignment"}return{...Ye,category:Ke}}),lt=["Student Name","Student Email"];Ze.forEach(Ye=>{const Ke=Ye.category==="quiz"?"Quiz":"Assignment";lt.push(`${Ke}: ${Ye.title}`)}),lt.push("Quizzes Average","Assignments Average",`Weighted Average (${pu}% Quizzes, ${Sc}% Assignments)`,"Simple Average Score","Submitted Count","Total Items");const tt=[];return K.slice(0,5).forEach(Ye=>{const Ke=[Ye.name,Ye.email];let dr=0,hr=0,pr=0,ct=0,ur=0,Wn=0,ft=0;Ze.forEach(Ki=>{const Gi=je.find(mi=>mi.assignment_id===Ki.id&&mi.student_id===Ye.id);if(Gi&&Gi.score!==null&&Gi.score!==void 0){Ke.push(`${Gi.score}%`);const mi=Number(Gi.score);Ki.category==="quiz"?(dr+=mi,hr++):(pr+=mi,ct++),ur+=mi,Wn++,ft++}else Gi&&Gi.submission_status==="submitted"?(Ke.push(e==="zh"?"待评分":"Pending Grade"),ft++):Ke.push(e==="zh"?"未提交":"Not Submitted")});const Nr=hr>0?Math.round(dr/hr):null,In=ct>0?Math.round(pr/ct):null;let Cs="N/A";if(Nr!==null&&In!==null){const Ki=Nr*(pu/100)+In*(Sc/100);Cs=`${Math.round(Ki)}%`}else Nr!==null?Cs=`${Nr}%`:In!==null&&(Cs=`${In}%`);const or=Nr!==null?`${Nr}%`:"N/A",Mr=In!==null?`${In}%`:"N/A",vr=Wn>0?`${Math.round(ur/Wn)}%`:"N/A";Ke.push(or,Mr,Cs,vr,`${ft}`,`${ve.length}`),tt.push(Ke)}),{headers:lt,rows:tt,totalStudents:K.length}},[bd,pu,Sc,Qs,fl,Hn,e]),V1=(K,ce,ve=40,je=60,Ze={})=>{const lt=fl[K]||[],tt=Hn[K];if(!tt||!tt.assignments){alert("No performance data available to export. Please open the dashboard to load class data first.");return}if(lt.length===0){alert("No students in this class to export grades for.");return}const mt=tt.assignments||[],Ye=tt.performance||[],Ke=or=>{if(or==null)return"";const Mr=String(or);return Mr.includes(",")||Mr.includes('"')||Mr.includes(`
673
673
  `)?`"${Mr.replace(/"/g,'""')}"`:Mr},dr=mt.map(or=>{let Mr="assignment";if(Ze[or.id])Mr=Ze[or.id];else{const vr=or.content&&or.content.startsWith('{"quizType":"mcq_learning_objectives"'),Ki=or.title&&(or.title.toLowerCase().includes("quiz")||or.title.toLowerCase().includes("test")||or.title.includes("测验")||or.title.includes("测试"));Mr=vr||Ki?"quiz":"assignment"}return{...or,category:Mr}}),hr=["Student Name","Student Email"];dr.forEach(or=>{const Mr=or.category==="quiz"?"Quiz":"Assignment";hr.push(`${Mr}: ${or.title}`)}),hr.push("Quizzes Average","Assignments Average",`Weighted Average (${ve}% Quizzes, ${je}% Assignments)`,"Simple Average Score","Submitted Count","Total Items");const pr=[hr];lt.forEach(or=>{const Mr=[or.name,or.email];let vr=0,Ki=0,Gi=0,mi=0,Sd=0,nt=0,bn=0;dr.forEach(th=>{const Au=Ye.find(rh=>rh.assignment_id===th.id&&rh.student_id===or.id);if(Au&&Au.score!==null&&Au.score!==void 0){Mr.push(`${Au.score}%`);const rh=Number(Au.score);th.category==="quiz"?(vr+=rh,Ki++):(Gi+=rh,mi++),Sd+=rh,nt++,bn++}else Au&&Au.submission_status==="submitted"?(Mr.push("Pending Grade"),bn++):Mr.push("Not Submitted")});const gi=Ki>0?Math.round(vr/Ki):null,Ad=mi>0?Math.round(Gi/mi):null;let eh="N/A";if(gi!==null&&Ad!==null){const th=gi*(ve/100)+Ad*(je/100);eh=`${Math.round(th)}%`}else gi!==null?eh=`${gi}%`:Ad!==null&&(eh=`${Ad}%`);const Z1=gi!==null?`${gi}%`:"N/A",J1=Ad!==null?`${Ad}%`:"N/A",Q1=nt>0?`${Math.round(Sd/nt)}%`:"N/A";Mr.push(Z1,J1,eh,Q1,`${bn}`,`${mt.length}`),pr.push(Mr.map(Ke))});const ct=pr.map(or=>or.join(",")).join(`
674
- `),ur=new Blob(["\uFEFF"+ct],{type:"text/csv;charset=utf-8;"}),Wn=URL.createObjectURL(ur),ft=document.createElement("a"),Nr=ce.replace(/[^a-z0-9]/gi,"_").toLowerCase(),In=new Date().toISOString().split("T")[0],Cs=`${Nr}_grades_report_${In}.csv`;ft.setAttribute("href",Wn),ft.setAttribute("download",Cs),ft.style.visibility="hidden",document.body.appendChild(ft),ft.click(),document.body.removeChild(ft),URL.revokeObjectURL(Wn)},W1=(K,ce)=>{const ve=Hn[ce];if(!ve||!ve.performance)return null;const je=Date.now()-2592e6,lt=ve.performance.filter(Ye=>Ye.student_id===K).filter(Ye=>Ye.submitted_at&&Ye.submitted_at>=je&&Ye.score!==null&&Ye.score!==void 0);if(lt.length===0)return null;const mt=lt.reduce((Ye,Ke)=>Ye+Number(Ke.score),0)/lt.length;return mt<60?Math.round(mt):null},Zf=async K=>{try{const ce=await fetch(`/api/classes/${K}/schedules`);if(ce.ok){const ve=await ce.json();Oi(je=>({...je,[K]:ve}))}}catch{}},bl=async K=>{try{const ce=await fetch(`/api/schedules/${K}/attendance`);if(ce.ok){const ve=await ce.json();Ii(je=>({...je,[K]:ve}))}}catch{}},vu=async K=>{try{const ce=await fetch(`/api/students/${K}/dashboard`);if(ce.ok){const ve=await ce.json();Xs(ve),ve.profile&&ve.profile.locked_lesson_id&&(It(ve.profile.locked_lesson_id),ua("lesson"))}}catch{}},U1=async(K=!1)=>{if(!Ei)return;const ve=Ei?.content&&Ei.content.startsWith('{"quizType":"mcq_learning_objectives"')?JSON.stringify(Gp.current):"Submitted via Whiteboard";try{(await fetch(`/api/assignments/${Ei.id}/submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:Er,content:ve})})).ok&&(K&&alert("Time is up! Your assessment was successfully submitted automatically."),await vu(Er),ua("dashboard"),xc(null))}catch(je){console.error(je)}};m.useEffect(()=>{if(k&&ye==="student"&&Er){vu(Er);const K=bo.find(ce=>ce.id===Er);K&&K.locked_lesson_id&&(It(K.locked_lesson_id),ua("lesson"))}},[k,ye,Er,bo]);const wd=m.useRef(ye),hi=m.useRef(Er),pi=m.useRef(e),cm=m.useRef(bo),dm=m.useRef(vn),Pc=m.useRef(new Set),bu=m.useRef(new Set);m.useEffect(()=>{wd.current=ye},[ye]),m.useEffect(()=>{hi.current=Er},[Er]),m.useEffect(()=>{pi.current=e},[e]),m.useEffect(()=>{cm.current=bo},[bo]),m.useEffect(()=>{dm.current=vn},[vn]),m.useEffect(()=>{if(!x.isInitialized()||Q.length===0)return;const K=ns.getState(),ce=Q.filter(je=>je.status==="active");for(const je of ce){if(!je.has_frontend||Pc.current.has(je.id))continue;const Ze=K.activePlugins.find(Ye=>Ye.id===je.id),lt=!!(Ze&&je.version&&Ze.version!==je.version);if(!(!Ze||lt||Ze.state!==Kn.ACTIVE&&Ze.state!==Kn.ACTIVATING))continue;Pc.current.add(je.id);const mt=()=>{if(!K.activePlugins.find(Ye=>Ye.id===je.id))K.addPlugin({id:je.id,name:je.name,version:je.version,state:Kn.INSTALLED,executionMode:"inline"});else if(lt)try{ns.setState(Ye=>({activePlugins:Ye.activePlugins.map(Ke=>Ke.id===je.id?{...Ke,version:je.version,name:je.name}:Ke)}))}catch{}try{const Ye=JSON.parse(je.manifest);x.activateRemotePlugin(je.id,Ye).catch(Ke=>{console.error(`[App] Failed to activate remote plugin "${je.name}":`,Ke)}).finally(()=>{Pc.current.delete(je.id)})}catch(Ye){Pc.current.delete(je.id),console.error(`[App] Failed to parse manifest for plugin "${je.name}":`,Ye)}};Ze&&Ze.state===Kn.ACTIVE&&lt?x.deactivatePlugin(je.id).catch(()=>{}).finally(mt):mt()}const ve=Q.filter(je=>je.status!=="active");for(const je of ve){if(!je.has_frontend)continue;const Ze=K.activePlugins.find(lt=>lt.id===je.id);Ze&&Ze.state===Kn.ACTIVE&&x.deactivatePlugin(je.id).catch(lt=>{console.error(`[App] Failed to deactivate remote plugin "${je.name}":`,lt)})}},[Q,x]),ss.useEffect(()=>{if(!x.isInitialized()||Q.length===0)return;const K=ns.getState();for(const ce of Q)ce.status==="active"&&(K.dashboardVisibility.has(ce.id)||K.setDashboardVisibility(ce.id,!0))},[Q,x]),m.useEffect(()=>{if(!k)return;const K=Bm();return v.current=K,x.isInitialized()||x.initialize(new nre,new Rq(K),new sre(dm.current),new ire("__app__")),wd.current==="student"&&hi.current&&K.emit("register-student",{studentId:hi.current,name:cm.current.find(ce=>ce.id===hi.current)?.name||hi.current}),K.emit("join-room","whiteboard-broadcast"),K.on("presence-update",ce=>{console.log("[Socket] presence-update received:",ce),j(ce.onlineStudentIds),w(ce.activeStudentLessons)}),K.on("lesson-progress-mode-changed",ce=>{console.log("[Socket] lesson-progress-mode-changed received:",ce);const{lessonId:ve,progressMode:je,progressConditions:Ze}=ce;ue(lt=>lt.map(tt=>tt.id===ve?{...tt,progress_mode:je,progress_conditions:Ze}:tt))}),K.on("student-active-segment-changed",ce=>{console.log("[Socket] student-active-segment-changed received:",ce);const{activeSegmentId:ve}=ce;Fa(ve)}),K.on("student-pinged",ce=>{console.log("[Socket] student-pinged received:",ce);const ve=ce.message||(pi.current==="zh"?"⚠️ 学习进度预警:老师注意到您的进度有些落后,请抓紧时间跟上!":"⚠️ Progress Alert: The teacher noticed you are falling behind. Please keep up!");vn(pi.current==="zh"?"⚠️ 学习进度预警":"⚠️ Progress Warning",ve,"warning")}),K.on("student-progress-updated",ce=>{console.log("[Socket] student-progress-updated received:",ce);const{studentId:ve,lessonId:je,progressPercent:Ze,completed:lt}=ce;P(tt=>{const mt=tt.findIndex(Ye=>Ye.student_id===ve);if(mt!==-1){const Ye=[...tt];return Ye[mt]={...Ye[mt],progress_percent:Ze,completed:lt?1:0},Ye}else return[...tt,{student_id:ve,progress_percent:Ze,completed:lt?1:0}]})}),K.on("assignment-graded-toast",ce=>{if(console.log("[Socket] assignment-graded-toast received on client:",ce),wd.current==="student"&&hi.current&&ce.studentId===hi.current){const ve=ce.assignmentTitle||ce.assignmentId,je=pi.current==="zh"?`您的作业"${ve}"已完成评分!得分:${ce.score}%。建议反馈已收到,快去查看。`:`Your assignment "${ve}" was graded. Score: ${ce.score}%. Tutoring feedback has been posted.`;vn(pi.current==="zh"?"🎓 作业已评分":"🎓 Assignment Graded",je,"success"),vu(hi.current)}}),K.on("student-picked",ce=>{if(console.log("[Socket] student-picked received on client:",ce),wd.current==="student"&&hi.current&&ce.studentId===hi.current){const ve=pi.current==="zh"?"闪电警报!您已被老师在课程随机提问点名中抽中!请立即集中注意力参与课堂。":"Attention alert! You have been randomly picked by the teacher! Please pay immediate attention.";vn(pi.current==="zh"?"⚡️ 随机点名提问":"⚡️ Classroom Pick Alert",ve,"warning"),vu(hi.current)}h(ve=>[{id:`feed-pick-${ce.studentId}-${ce.pickedTime||Date.now()}`,time:new Date(ce.pickedTime||Date.now()).toLocaleTimeString(),type:"picked",message:pi.current==="zh"?`点名互动:随机抽中学生【${ce.studentName}】。`:`Classroom Pick: Randomly selected student "${ce.studentName}".`},...ve])}),K.on("student-acknowledged",ce=>{console.log("[Socket] student-acknowledged received on client:",ce);const{studentId:ve,notificationId:je}=ce;g(Ze=>{const lt=new Map(Ze);return lt.set(ve,!0),lt}),h(Ze=>[{id:`feed-ack-${ve}-${Date.now()}`,time:new Date().toLocaleTimeString(),type:"checkin",message:pi.current==="zh"?`学生已确认收到提问点名(学生 ID: ${ve})。`:`Student acknowledged the classroom call (Student ID: ${ve}).`},...Ze]),nn()}),K.on("class-lock-status-changed",ce=>{console.log("[Socket] class-lock-status-changed received on client:",ce);const{classId:ve,lessonId:je,locked:Ze}=ce;wd.current==="student"&&hi.current?(nn().then(()=>{Ze&&je&&(It(je),ua("lesson"),vn(pi.current==="zh"?"🔒 课程已被锁定":"🔒 Lesson Locked",pi.current==="zh"?"老师已锁定当前授课,您将无法切换到其他页面。":"The teacher has locked the active lesson. You cannot leave this page.","info"))}),vu(hi.current)):nn()}),K.on("whiteboard-sync",ce=>{const{roomId:ve,type:je}=ce||{};je==="refresh"&&ve&&(yl(ve),!jd.current&&wd.current==="student"&&(It(ve),ua("lesson")),K.emit("join-room",ve))}),()=>{K.disconnect(),v.current=null}},[k,ye,Er]),m.useEffect(()=>{v.current&&ye==="student"&&Er&&(da==="lesson"&&at?(v.current.emit("enter-lesson",{studentId:Er,lessonId:at}),fetch(`/api/students/${Er}/progress`).then(K=>K.json()).then(K=>{if(Array.isArray(K)){const ce=K.find(ve=>ve.lesson_id===at);T(ce?ce.progress_percent:0)}}).catch(console.error)):v.current.emit("leave-lesson",{studentId:Er}))},[da,at,ye,Er]);const yu=async K=>{if(ye==="student"&&Er&&at)try{await fetch(`/api/students/${Er}/progress`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:at,completed:K===100,progressPercent:K})})}catch(ce){console.error("Failed to update student progress:",ce)}},Rg=async(K,ce)=>{try{const ve=await fetch(`/api/classes/${K}/lessons/${ce}/progress`);ve.ok&&P(await ve.json())}catch{}};m.useEffect(()=>{ye==="teacher"&&at&&ca&&v.current&&v.current.emit("teacher-broadcast-segment",{lessonId:at,activeSegmentId:ca})},[ca,at,ye]),m.useEffect(()=>{a&&at?Rg(a,at):P([])},[a,at]),m.useEffect(()=>{a&&sn(a)},[a]);const q1=async K=>{try{const ce=await fetch(`/api/students/${K}/progress`);if(ce.ok){const ve=await ce.json();Gf(je=>({...je,[K]:ve}))}}catch{}},wu=async K=>{try{const ce=await fetch(`/api/processes/${K}/logs`);if(ce.ok){const ve=await ce.json();cc(ve.logs||""),ul(K)}}catch{}},yl=async K=>{const ve=await(await fetch(`/api/lessons/${K}/whiteboard`)).json();nr(ve)},jd=m.useRef(null),Co=m.useRef(null),ju=m.useRef(null);m.useEffect(()=>{jd.current=at},[at]),m.useEffect(()=>{ju.current=Ei},[Ei]),m.useEffect(()=>{if(!k)return;const K=async ce=>{const ve=ce.data;if(!ve||typeof ve!="object")return;let je=ve.attempt_id,Ze=ve.uuid,lt=ve.type||"",tt=ve.payload||ve;if(!je&&ce.source)try{const Ke=Array.from(document.querySelectorAll("iframe")).find(dr=>dr.contentWindow===ce.source);if(Ke&&Ke.contentWindow){const dr=Ke.contentWindow;dr.__LMS_STUDENT__?.attempt_id&&(je=dr.__LMS_STUDENT__.attempt_id),dr.__LMS_COURSEWARE__?.uuid&&(Ze=dr.__LMS_COURSEWARE__.uuid)}}catch{}if(!je)return;const mt=lt==="LMS_SUBMIT"||lt==="LMS_FINISH"||lt==="submit"||lt==="finish"||lt==="completed"||tt&&typeof tt=="object"&&(tt.score!==void 0||tt.grade!==void 0||tt.result!==void 0||tt.points!==void 0),Ye=lt==="LMS_SAVE_PROGRESS"||lt==="saveProgress";if(mt)try{await fetch(`/api/courseware/attempts/${je}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:tt?.score??tt?.grade??tt?.result??tt?.points??void 0,comment:tt?.comment??tt?.feedback??tt?.note??void 0,completion:tt?.completion??1,status:"submitted",extra:tt})})}catch(Ke){console.error("Failed to submit attempt data to backend:",Ke)}else if(Ye)try{await fetch(`/api/courseware/attempts/${je}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:tt?.score??tt?.grade??tt?.result??tt?.points??void 0,comment:tt?.comment??tt?.feedback??void 0,completion:tt?.completion??void 0,status:"inprogress",extra:tt})})}catch(Ke){console.error("Failed to save progress to backend:",Ke)}else try{await fetch(`/api/courseware/attempts/${je}/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventType:lt||"log",payload:tt})})}catch(Ke){console.error("Failed to log event to backend:",Ke)}};return window.addEventListener("message",K),()=>{window.removeEventListener("message",K)}},[k]);const $g=async(K,ce)=>{Ia("saving");try{(await fetch(`/api/lessons/${K}/timeline`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({timeline:ce})})).ok?(ue(je=>je.map(Ze=>Ze.id===K?{...Ze,timeline:JSON.stringify(ce)}:Ze)),hl(ce),Ia("saved"),xo(new Date)):Ia("error")}catch(ve){console.error("Failed to save timeline:",ve),Ia("error")}};m.useEffect(()=>{if(at){const K=se.find(ce=>ce.id===at);if(K){let ce=[];if(K.timeline)try{ce=typeof K.timeline=="string"?JSON.parse(K.timeline):K.timeline}catch{ce=[{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 ce=[{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"}];hl(ce);const ve=Co.current!==at;Co.current=at,ce.length>0?(ve||!ce.some(je=>je.id===ca))&&Fa(ce[0].id):Fa(null)}}},[at,se]),m.useEffect(()=>{if(!k)return;Gr(),$t(),wt(),Tn(),Ut(),cr(),jr(),Bn(),nn(),fn(),Je(le.current);let K=!1;const ce=setInterval(async()=>{if(!K){K=!0;try{await Tn(),await Gr(),await Ut(),await cr(),await jr(),await Bn().catch(()=>{}),await nn(),await fn(),await Je(le.current),await wt(),Ns&&await wu(Ns),Ks.current&&await sn(Ks.current),jd.current&&await yl(jd.current),ju.current&&await yl(`assignment-${ju.current.id}-student-${Er||ju.current.student_id}`)}finally{K=!1}}},2e3);return()=>clearInterval(ce)},[k,Ns,Er]),m.useEffect(()=>{Je(ge)},[ge]),m.useEffect(()=>{at&&yl(at)},[at]);const H1=K=>{K.target.files&&Array.from(K.target.files).forEach(ce=>{const ve=new FileReader;ve.onload=je=>{je.target?.result&&oe(Ze=>[...Ze,{name:ce.name,content:je.target.result}])},ce.name.endsWith(".zip")?ve.readAsDataURL(ce):ve.readAsText(ce)})},Fg=K=>{K.preventDefault(),K.dataTransfer.files&&Array.from(K.dataTransfer.files).forEach(ce=>{const ve=new FileReader;ve.onload=je=>{je.target?.result&&oe(Ze=>[...Ze,{name:ce.name,content:je.target.result}])},ce.name.endsWith(".zip")?ve.readAsDataURL(ce):ve.readAsText(ce)})},Nd=K=>{let ce="",ve="",je="";K==="class"?(ce=e==="zh"?"班级及学生批量导入模板.csv":"class_import_template.csv",ve="Class Name,Class Desc,Student Name,Student Email",je=e==="zh"?`高一A班,基础英语课程,李明,liming@example.com
674
+ `),ur=new Blob(["\uFEFF"+ct],{type:"text/csv;charset=utf-8;"}),Wn=URL.createObjectURL(ur),ft=document.createElement("a"),Nr=ce.replace(/[^a-z0-9]/gi,"_").toLowerCase(),In=new Date().toISOString().split("T")[0],Cs=`${Nr}_grades_report_${In}.csv`;ft.setAttribute("href",Wn),ft.setAttribute("download",Cs),ft.style.visibility="hidden",document.body.appendChild(ft),ft.click(),document.body.removeChild(ft),URL.revokeObjectURL(Wn)},W1=(K,ce)=>{const ve=Hn[ce];if(!ve||!ve.performance)return null;const je=Date.now()-2592e6,lt=ve.performance.filter(Ye=>Ye.student_id===K).filter(Ye=>Ye.submitted_at&&Ye.submitted_at>=je&&Ye.score!==null&&Ye.score!==void 0);if(lt.length===0)return null;const mt=lt.reduce((Ye,Ke)=>Ye+Number(Ke.score),0)/lt.length;return mt<60?Math.round(mt):null},Zf=async K=>{try{const ce=await fetch(`/api/classes/${K}/schedules`);if(ce.ok){const ve=await ce.json();Oi(je=>({...je,[K]:ve}))}}catch{}},bl=async K=>{try{const ce=await fetch(`/api/schedules/${K}/attendance`);if(ce.ok){const ve=await ce.json();Ii(je=>({...je,[K]:ve}))}}catch{}},vu=async K=>{try{const ce=await fetch(`/api/students/${K}/dashboard`);if(ce.ok){const ve=await ce.json();Xs(ve),ve.profile&&ve.profile.locked_lesson_id&&(It(ve.profile.locked_lesson_id),ua("lesson"))}}catch{}},U1=async(K=!1)=>{if(!Ei)return;const ve=Ei?.content&&Ei.content.startsWith('{"quizType":"mcq_learning_objectives"')?JSON.stringify(Gp.current):"Submitted via Whiteboard";try{(await fetch(`/api/assignments/${Ei.id}/submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({studentId:Er,content:ve})})).ok&&(K&&alert("Time is up! Your assessment was successfully submitted automatically."),await vu(Er),ua("dashboard"),xc(null))}catch(je){console.error(je)}};m.useEffect(()=>{if(k&&ye==="student"&&Er){vu(Er);const K=bo.find(ce=>ce.id===Er);K&&K.locked_lesson_id&&(It(K.locked_lesson_id),ua("lesson"))}},[k,ye,Er,bo]);const wd=m.useRef(ye),hi=m.useRef(Er),pi=m.useRef(e),cm=m.useRef(bo),dm=m.useRef(vn),Pc=m.useRef(new Set),bu=m.useRef(new Set);m.useEffect(()=>{wd.current=ye},[ye]),m.useEffect(()=>{hi.current=Er},[Er]),m.useEffect(()=>{pi.current=e},[e]),m.useEffect(()=>{cm.current=bo},[bo]),m.useEffect(()=>{dm.current=vn},[vn]),m.useEffect(()=>{if(!x.isInitialized()||Q.length===0)return;const K=ns.getState(),ce=Q.filter(je=>je.status==="active");for(const je of ce){if(!je.has_frontend||Pc.current.has(je.id))continue;const Ze=K.activePlugins.find(Ye=>Ye.id===je.id),lt=!!(Ze&&je.version&&Ze.version!==je.version);if(!(!Ze||lt||Ze.state!==Kn.ACTIVE&&Ze.state!==Kn.ACTIVATING))continue;Pc.current.add(je.id);const mt=()=>{if(!K.activePlugins.find(Ye=>Ye.id===je.id))K.addPlugin({id:je.id,name:je.name,version:je.version,state:Kn.INSTALLED,executionMode:"inline"});else if(lt)try{ns.setState(Ye=>({activePlugins:Ye.activePlugins.map(Ke=>Ke.id===je.id?{...Ke,version:je.version,name:je.name}:Ke)}))}catch{}try{const Ye=JSON.parse(je.manifest);x.activateRemotePlugin(je.id,Ye).catch(Ke=>{console.error(`[App] Failed to activate remote plugin "${je.name}":`,Ke)}).finally(()=>{Pc.current.delete(je.id)})}catch(Ye){Pc.current.delete(je.id),console.error(`[App] Failed to parse manifest for plugin "${je.name}":`,Ye)}};Ze&&Ze.state===Kn.ACTIVE&&lt?x.deactivatePlugin(je.id).catch(()=>{}).finally(mt):mt()}const ve=Q.filter(je=>je.status!=="active");for(const je of ve){if(!je.has_frontend)continue;const Ze=K.activePlugins.find(lt=>lt.id===je.id);Ze&&Ze.state===Kn.ACTIVE&&x.deactivatePlugin(je.id).catch(lt=>{console.error(`[App] Failed to deactivate remote plugin "${je.name}":`,lt)})}},[Q,x]),ss.useEffect(()=>{if(!x.isInitialized()||Q.length===0)return;const K=ns.getState();for(const ce of Q)ce.status==="active"&&(K.dashboardVisibility.has(ce.id)||K.setDashboardVisibility(ce.id,!0))},[Q,x]),m.useEffect(()=>{if(!k)return;const K=Bm();return v.current=K,x.isInitialized()||x.initialize(new nre,new Rq(K),new sre(dm.current),new ire("__app__")),wd.current==="student"&&hi.current&&K.emit("register-student",{studentId:hi.current,name:cm.current.find(ce=>ce.id===hi.current)?.name||hi.current}),K.emit("join-room","whiteboard-broadcast"),K.on("presence-update",ce=>{console.log("[Socket] presence-update received:",ce),j(ce.onlineStudentIds),w(ce.activeStudentLessons)}),K.on("lesson-progress-mode-changed",ce=>{console.log("[Socket] lesson-progress-mode-changed received:",ce);const{lessonId:ve,progressMode:je,progressConditions:Ze}=ce;ue(lt=>lt.map(tt=>tt.id===ve?{...tt,progress_mode:je,progress_conditions:Ze}:tt))}),K.on("student-active-segment-changed",ce=>{console.log("[Socket] student-active-segment-changed received:",ce);const{activeSegmentId:ve}=ce;Fa(ve)}),K.on("student-pinged",ce=>{console.log("[Socket] student-pinged received:",ce);const ve=ce.message||(pi.current==="zh"?"⚠️ 学习进度预警:老师注意到您的进度有些落后,请抓紧时间跟上!":"⚠️ Progress Alert: The teacher noticed you are falling behind. Please keep up!");vn(pi.current==="zh"?"⚠️ 学习进度预警":"⚠️ Progress Warning",ve,"warning")}),K.on("student-progress-updated",ce=>{console.log("[Socket] student-progress-updated received:",ce);const{studentId:ve,lessonId:je,progressPercent:Ze,completed:lt}=ce;P(tt=>{const mt=tt.findIndex(Ye=>Ye.student_id===ve);if(mt!==-1){const Ye=[...tt];return Ye[mt]={...Ye[mt],progress_percent:Ze,completed:lt?1:0},Ye}else return[...tt,{student_id:ve,progress_percent:Ze,completed:lt?1:0}]})}),K.on("assignment-graded-toast",ce=>{if(console.log("[Socket] assignment-graded-toast received on client:",ce),wd.current==="student"&&hi.current&&ce.studentId===hi.current){const ve=ce.assignmentTitle||ce.assignmentId,je=pi.current==="zh"?`您的作业"${ve}"已完成评分!得分:${ce.score}%。建议反馈已收到,快去查看。`:`Your assignment "${ve}" was graded. Score: ${ce.score}%. Tutoring feedback has been posted.`;vn(pi.current==="zh"?"🎓 作业已评分":"🎓 Assignment Graded",je,"success"),vu(hi.current)}}),K.on("student-picked",ce=>{if(console.log("[Socket] student-picked received on client:",ce),wd.current==="student"&&hi.current&&ce.studentId===hi.current){const ve=pi.current==="zh"?"闪电警报!您已被老师在课程随机提问点名中抽中!请立即集中注意力参与课堂。":"Attention alert! You have been randomly picked by the teacher! Please pay immediate attention.";vn(pi.current==="zh"?"⚡️ 随机点名提问":"⚡️ Classroom Pick Alert",ve,"warning"),vu(hi.current)}h(ve=>[{id:`feed-pick-${ce.studentId}-${ce.pickedTime||Date.now()}`,time:new Date(ce.pickedTime||Date.now()).toLocaleTimeString(),type:"picked",message:pi.current==="zh"?`点名互动:随机抽中学生【${ce.studentName}】。`:`Classroom Pick: Randomly selected student "${ce.studentName}".`},...ve])}),K.on("student-acknowledged",ce=>{console.log("[Socket] student-acknowledged received on client:",ce);const{studentId:ve,notificationId:je}=ce;g(Ze=>{const lt=new Map(Ze);return lt.set(ve,!0),lt}),h(Ze=>[{id:`feed-ack-${ve}-${Date.now()}`,time:new Date().toLocaleTimeString(),type:"checkin",message:pi.current==="zh"?`学生已确认收到提问点名(学生 ID: ${ve})。`:`Student acknowledged the classroom call (Student ID: ${ve}).`},...Ze]),nn()}),K.on("class-lock-status-changed",ce=>{console.log("[Socket] class-lock-status-changed received on client:",ce);const{classId:ve,lessonId:je,locked:Ze}=ce;wd.current==="student"&&hi.current?(nn().then(()=>{Ze&&je&&(It(je),ua("lesson"),vn(pi.current==="zh"?"🔒 课程已被锁定":"🔒 Lesson Locked",pi.current==="zh"?"老师已锁定当前授课,您将无法切换到其他页面。":"The teacher has locked the active lesson. You cannot leave this page.","info"))}),vu(hi.current)):nn()}),K.on("whiteboard-sync",ce=>{const{roomId:ve,type:je}=ce||{};je==="refresh"&&ve&&(yl(ve),!jd.current&&wd.current==="student"&&(It(ve),ua("lesson")),K.emit("join-room",ve))}),()=>{K.disconnect(),v.current=null}},[k,ye,Er]),m.useEffect(()=>{v.current&&ye==="student"&&Er&&(da==="lesson"&&at?(v.current.emit("enter-lesson",{studentId:Er,lessonId:at}),fetch(`/api/students/${Er}/progress`).then(K=>K.json()).then(K=>{if(Array.isArray(K)){const ce=K.find(ve=>ve.lesson_id===at);T(ce?ce.progress_percent:0)}}).catch(console.error)):v.current.emit("leave-lesson",{studentId:Er}))},[da,at,ye,Er]);const yu=async K=>{if(ye==="student"&&Er&&at)try{await fetch(`/api/students/${Er}/progress`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lessonId:at,completed:K===100,progressPercent:K})})}catch(ce){console.error("Failed to update student progress:",ce)}},Rg=async(K,ce)=>{try{const ve=await fetch(`/api/classes/${K}/lessons/${ce}/progress`);ve.ok&&P(await ve.json())}catch{}};m.useEffect(()=>{ye==="teacher"&&at&&ca&&v.current&&v.current.emit("teacher-broadcast-segment",{lessonId:at,activeSegmentId:ca})},[ca,at,ye]),m.useEffect(()=>{a&&at?Rg(a,at):P([])},[a,at]),m.useEffect(()=>{a&&sn(a)},[a]);const q1=async K=>{try{const ce=await fetch(`/api/students/${K}/progress`);if(ce.ok){const ve=await ce.json();Gf(je=>({...je,[K]:ve}))}}catch{}},wu=async K=>{try{const ce=await fetch(`/api/processes/${K}/logs`);if(ce.ok){const ve=await ce.json();cc(ve.logs||""),ul(K)}}catch{}},yl=async K=>{const ve=await(await fetch(`/api/lessons/${K}/whiteboard`)).json();nr(ve)},jd=m.useRef(null),Co=m.useRef(null),ju=m.useRef(null);m.useEffect(()=>{jd.current=at},[at]),m.useEffect(()=>{ju.current=Ei},[Ei]),m.useEffect(()=>{if(!k)return;const K=async ce=>{const ve=ce.data;if(!ve||typeof ve!="object")return;ce.origin&&ce.origin!=="null"&&ce.origin;let je=ve.attempt_id,Ze=ve.uuid,lt=ve.type||"",tt=ve.payload||ve;if(!je&&ce.source)try{const Ke=Array.from(document.querySelectorAll("iframe")).find(dr=>dr.contentWindow===ce.source);if(Ke&&Ke.contentWindow){const dr=Ke.contentWindow;dr.__LMS_STUDENT__?.attempt_id&&(je=dr.__LMS_STUDENT__.attempt_id),dr.__LMS_COURSEWARE__?.uuid&&(Ze=dr.__LMS_COURSEWARE__.uuid)}}catch{}if(!je)return;const mt=lt==="LMS_SUBMIT"||lt==="LMS_FINISH"||lt==="submit"||lt==="finish"||lt==="completed"||tt&&typeof tt=="object"&&(tt.score!==void 0||tt.grade!==void 0||tt.result!==void 0||tt.points!==void 0),Ye=lt==="LMS_SAVE_PROGRESS"||lt==="saveProgress";if(mt)try{await fetch(`/api/courseware/attempts/${je}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:tt?.score??tt?.grade??tt?.result??tt?.points??void 0,comment:tt?.comment??tt?.feedback??tt?.note??void 0,completion:tt?.completion??1,status:"submitted",extra:tt})})}catch(Ke){console.error("Failed to submit attempt data to backend:",Ke)}else if(Ye)try{await fetch(`/api/courseware/attempts/${je}/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({score:tt?.score??tt?.grade??tt?.result??tt?.points??void 0,comment:tt?.comment??tt?.feedback??void 0,completion:tt?.completion??void 0,status:"inprogress",extra:tt})})}catch(Ke){console.error("Failed to save progress to backend:",Ke)}else try{await fetch(`/api/courseware/attempts/${je}/log`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventType:lt||"log",payload:tt})})}catch(Ke){console.error("Failed to log event to backend:",Ke)}};return window.addEventListener("message",K),()=>{window.removeEventListener("message",K)}},[k]);const $g=async(K,ce)=>{Ia("saving");try{(await fetch(`/api/lessons/${K}/timeline`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({timeline:ce})})).ok?(ue(je=>je.map(Ze=>Ze.id===K?{...Ze,timeline:JSON.stringify(ce)}:Ze)),hl(ce),Ia("saved"),xo(new Date)):Ia("error")}catch(ve){console.error("Failed to save timeline:",ve),Ia("error")}};m.useEffect(()=>{if(at){const K=se.find(ce=>ce.id===at);if(K){let ce=[];if(K.timeline)try{ce=typeof K.timeline=="string"?JSON.parse(K.timeline):K.timeline}catch{ce=[{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 ce=[{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"}];hl(ce);const ve=Co.current!==at;Co.current=at,ce.length>0?(ve||!ce.some(je=>je.id===ca))&&Fa(ce[0].id):Fa(null)}}},[at,se]),m.useEffect(()=>{if(!k)return;Gr(),$t(),wt(),Tn(),Ut(),cr(),jr(),Bn(),nn(),fn(),Je(le.current);let K=!1;const ce=setInterval(async()=>{if(!K){K=!0;try{await Tn(),await Gr(),await Ut(),await cr(),await jr(),await Bn().catch(()=>{}),await nn(),await fn(),await Je(le.current),await wt(),Ns&&await wu(Ns),Ks.current&&await sn(Ks.current),jd.current&&await yl(jd.current),ju.current&&await yl(`assignment-${ju.current.id}-student-${Er||ju.current.student_id}`)}finally{K=!1}}},2e3);return()=>clearInterval(ce)},[k,Ns,Er]),m.useEffect(()=>{Je(ge)},[ge]),m.useEffect(()=>{at&&yl(at)},[at]);const H1=K=>{K.target.files&&Array.from(K.target.files).forEach(ce=>{const ve=new FileReader;ve.onload=je=>{je.target?.result&&oe(Ze=>[...Ze,{name:ce.name,content:je.target.result}])},ce.name.endsWith(".zip")?ve.readAsDataURL(ce):ve.readAsText(ce)})},Fg=K=>{K.preventDefault(),K.dataTransfer.files&&Array.from(K.dataTransfer.files).forEach(ce=>{const ve=new FileReader;ve.onload=je=>{je.target?.result&&oe(Ze=>[...Ze,{name:ce.name,content:je.target.result}])},ce.name.endsWith(".zip")?ve.readAsDataURL(ce):ve.readAsText(ce)})},Nd=K=>{let ce="",ve="",je="";K==="class"?(ce=e==="zh"?"班级及学生批量导入模板.csv":"class_import_template.csv",ve="Class Name,Class Desc,Student Name,Student Email",je=e==="zh"?`高一A班,基础英语课程,李明,liming@example.com
675
675
  高一A班,基础英语课程,王华,wanghua@example.com`:`Class 101,Introduction to English,John Doe,john@example.com
676
676
  Class 101,Introduction to English,Jane Smith,jane@example.com`):(ce=e==="zh"?"学生批量导入模板.csv":"student_import_template.csv",ve="Student Name,Student Email",je=e==="zh"?`张三,zhangsan@example.com
677
677
  李四,lisi@example.com`:`Alice Cooper,alice@example.com