1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2026-02-04 07:53:11 +00:00
Classworks/assets/index-C4pR7dAk.js

17 lines
180 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-Ck0Pnd4f.js","./index-btKy2yxc.css","./dataProvider-BZ0EQWiW.js","./serverRotation-TSbwZ9RQ.js"])))=>i.map(i=>d[i]);
import{V as jt,a as Ht,_ as pt}from"./ExamConfigEditor-DSJ1EgID.js";import{_ as W,k as S,s as re,j as b,o as c,w as i,c as s,l as _,q as j,t as u,v as D,x as L,y,z as V,i as r,A as p,B as w,C as g,D as vt,F as E,E as Qe,T as Ke,G as U,d as fe,H as J,I as oe,n as he,J as be,K as ve,L as Ie,M as X,N as tt,O as qe,P as we,Q as Se,R as Je,S as xe,U as Kt,W as qt,X as Ae,Y as yt,Z as Ye,$ as Wt,a0 as $,a1 as G,a2 as $e,a3 as Pe,a4 as st,a5 as Gt,a6 as Qt,a7 as Jt,a8 as kt,a9 as bt,aa as xt,ab as Oe,ac as Xe,ad as nt,ae as Le,af as Yt,ag as it,ah as Ee,ai as Ve,aj as Xt,ak as Ne}from"./index-Ck0Pnd4f.js";import{V as Ce}from"./VTextField-C6VOv1Py.js";import{V as Ze,a as Zt}from"./VTooltip-BqVq3svk.js";import{V as O}from"./VChip-C4TXrZae.js";import{s as es,g as wt,j as We,o as ce,a as ts,l as ss}from"./socketClient-CbzMnGVD.js";import{p as at,s as ns,a as ot,V as is,_ as St}from"./VCombobox-BctCYhAJ.js";import{f as as,s as os,c as Ct}from"./deviceEvents-DSVBBN-K.js";import{V as ue,a as ne}from"./VRow-D_zZfsym.js";import{V as ls,a as lt}from"./VPagination-CAsEj5TO.js";import{V as Ue}from"./VTextarea-Akjtg06o.js";import{d as Z,a as Be,g as _t,b as me,k as rs}from"./dataProvider-BZ0EQWiW.js";import{V as rt,a as dt,b as ds,c as us}from"./VAppBarTitle-N2z58aj8.js";import{V as Dt}from"./VContainer-_5I3ogXr.js";import{V as ut}from"./VForm-Jb3Esqve.js";import{V as Ge}from"./VSwitch-B-2xPqHI.js";import{V as cs}from"./filter-BOxM3LRL.js";import{V as _e}from"./VAlert-WqxdeiRc.js";import{V as ms,a as ct,b as mt,c as ft}from"./VExpansionPanels-B6fkQj5C.js";import"./VSkeletonLoader-LZ55LBTh.js";import"./VCheckboxBtn-DWqkYNT7.js";import"./VSheet-DJg5eIit.js";import"./serverRotation-TSbwZ9RQ.js";const fs={name:"RandomPicker",props:{studentList:{type:Array,required:!0},attendance:{type:Object,required:!0,default:()=>({absent:[],late:[],exclude:[]})}},data(){return{dialog:!1,count:S("randomPicker.defaultCount"),isPickingStarted:!1,isAnimating:!1,pickedStudents:[],animationStudents:[],highlightedIndices:[],animationTimer:null,getSetting:S,tempFilters:{excludeAbsent:S("randomPicker.excludeAbsent"),excludeLate:S("randomPicker.excludeLate"),excludeExcluded:S("randomPicker.excludeExcluded")},pickerMode:S("randomPicker.mode"),minNumber:S("randomPicker.minNumber"),maxNumber:S("randomPicker.maxNumber")}},computed:{absentCount(){return this.attendance.absent?this.attendance.absent.length:0},lateCount(){return this.attendance.late?this.attendance.late.length:0},excludedCount(){return this.attendance.exclude?this.attendance.exclude.length:0},numberModeStudents(){if(this.pickerMode!=="number")return[];const t=[];for(let e=this.minNumber;e<=this.maxNumber;e++)t.push(e.toString().padStart(2,"0")+"号");return t},filteredStudents(){return this.pickerMode==="number"?this.numberModeStudents:!this.studentList||!this.studentList.length?[]:this.studentList.filter(t=>!(this.tempFilters.excludeAbsent&&this.attendance.absent.includes(t)||this.tempFilters.excludeLate&&this.attendance.late.includes(t)||this.tempFilters.excludeExcluded&&this.attendance.exclude.includes(t)))},availableStudents(){return this.filteredStudents},maxAllowedCount(){return Math.min(10,this.filteredStudents.length)},remainingStudents(){return this.filteredStudents.filter(t=>!this.pickedStudents.includes(t))}},watch:{dialog(t){t?(this.count=S("randomPicker.defaultCount"),this.isPickingStarted=!1,this.isAnimating=!1,this.pickedStudents=[],this.tempFilters={excludeAbsent:S("randomPicker.excludeAbsent"),excludeLate:S("randomPicker.excludeLate"),excludeExcluded:S("randomPicker.excludeExcluded")}):this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=null)},tempFilters:{handler(){this.count>this.maxAllowedCount&&(this.count=Math.max(1,this.maxAllowedCount))},deep:!0},pickerMode:{handler(t){re("randomPicker.mode",t)}},minNumber:{handler(t){t>this.maxNumber&&(this.minNumber=this.maxNumber),t<1&&(this.minNumber=1),re("randomPicker.minNumber",this.minNumber)}},maxNumber:{handler(t){t<this.minNumber&&(this.maxNumber=this.minNumber),t>100&&(this.maxNumber=100),re("randomPicker.maxNumber",this.maxNumber)}}},methods:{open(){this.dialog=!0},incrementCount(){this.count<this.maxAllowedCount&&this.count++},decrementCount(){this.count>1&&this.count--},startPicking(){this.filteredStudents.length!==0&&(this.isPickingStarted=!0,S("randomPicker.animation")?this.startAnimation():this.finishPicking())},startAnimation(){this.isAnimating=!0,this.animationStudents=this.filteredStudents.map((t,e)=>({id:`student-${e}`,name:t})),this.animateHighlight()},animateHighlight(){let e=0;const a=50,l=()=>{this.highlightedIndices=[];const n=[];for(let d=0;d<this.count;d++){let m;do m=Math.floor(Math.random()*this.animationStudents.length);while(n.includes(m));n.push(m)}this.highlightedIndices=n,e++;const o=a+e*20;e<5?this.animationTimer=setTimeout(l,o):setTimeout(()=>{this.finishPicking()},500)};l()},finishPicking(){this.isAnimating=!1;const t=[...this.filteredStudents].sort(()=>.5-Math.random());this.pickedStudents=t.slice(0,this.count)},resetPicker(){this.isPickingStarted=!1,this.isAnimating=!1,this.pickedStudents=[],this.animationTimer&&(clearTimeout(this.animationTimer),this.animationTimer=null)},refreshSingleStudent(t){if(this.remainingStudents.length===0)return;const e=Math.floor(Math.random()*this.remainingStudents.length),a=this.remainingStudents[e];this.pickedStudents[t]=a;const l=document.querySelectorAll(".result-card");l[t]&&(l[t].classList.add("refresh-animation"),setTimeout(()=>{l[t].classList.remove("refresh-animation")},500))}}},hs={class:"d-flex justify-center align-center counter-container"},gs={class:"count-display mx-8"},ps={class:"text-h2 font-weight-bold"},vs={class:"mode-switch-container mt-6"},ys={key:0,class:"number-range-container mt-4"},ks={class:"d-flex justify-center align-center gap-4"},bs={class:"mt-4"},xs={key:1,class:"mt-4 text-error"},ws={class:"mt-4 text-caption"},Ss={class:"pa-2"},Cs={key:0},_s={key:1},Ds={key:2},Ts={key:1,class:"d-flex flex-wrap justify-center gap-2 mt-4"},Is={key:0,class:"animation-container"},Es={class:"animation-wrapper"},Ns={key:1,class:"result-container"},Vs={class:"mt-8 d-flex justify-center"};function As(t,e,a,l,n,o){return c(),b(J,{modelValue:n.dialog,"onUpdate:modelValue":e[8]||(e[8]=d=>n.dialog=d),"fullscreen-breakpoint":"sm","max-width":"600",persistent:""},{default:i(()=>[s(_,{border:"",class:"random-picker-card",rounded:"xl"},{default:i(()=>[s(j,{class:"text-h5 d-flex align-center"},{default:i(()=>[s(D,{class:"mr-2",icon:"mdi-account-question"}),e[9]||(e[9]=u(" 随机点名 ",-1)),s(L),s(y,{icon:"mdi-close",variant:"text",onClick:e[0]||(e[0]=d=>n.dialog=!1)})]),_:1}),n.isPickingStarted?(c(),b(V,{key:1,class:"text-center py-6"},{default:i(()=>[n.isAnimating?(c(),p("div",Is,[r("div",Es,[s(Ke,{class:"shuffle-container",name:"shuffle",tag:"div"},{default:i(()=>[(c(!0),p(E,null,U(n.animationStudents,(d,m)=>(c(),p("div",{key:d.id,class:fe([{highlighted:n.highlightedIndices.includes(m)},"student-item"])},g(d.name),3))),128))]),_:1})])])):(c(),p("div",Ns,[e[19]||(e[19]=r("div",{class:"text-h6 mb-4"},"抽取结果",-1)),(c(!0),p(E,null,U(n.pickedStudents,(d,m)=>(c(),b(_,{key:m,class:"mb-2 result-card",color:"primary",variant:"outlined"},{default:i(()=>[s(V,{class:"text-h4 text-center py-4 d-flex align-center justify-center"},{default:i(()=>[u(g(d)+" ",1),s(y,{disabled:o.remainingStudents.length===0,title:o.remainingStudents.length===0?"没有更多可用学生":"重新抽取此学生",class:"ml-2 refresh-btn",icon:"mdi-refresh",size:"small",variant:"text",onClick:f=>o.refreshSingleStudent(m)},null,8,["disabled","title","onClick"])]),_:2},1024)]),_:2},1024))),128)),r("div",Vs,[s(y,{class:"mx-2",color:"primary","prepend-icon":"mdi-refresh",size:"large",onClick:o.resetPicker},{default:i(()=>[...e[17]||(e[17]=[u(" 重新抽取 ",-1)])]),_:1},8,["onClick"]),s(y,{class:"mx-2",color:"grey",size:"large",variant:"outlined",onClick:e[7]||(e[7]=d=>n.dialog=!1)},{default:i(()=>[...e[18]||(e[18]=[u(" 关闭 ",-1)])]),_:1})])]))]),_:1})):(c(),b(V,{key:0,class:"text-center py-6"},{default:i(()=>[e[16]||(e[16]=r("div",{class:"text-h6 mb-4"},"请选择抽取人数",-1)),r("div",hs,[s(y,{disabled:n.count<=1,class:"counter-btn",color:"primary",icon:"mdi-minus",size:"x-large",variant:"tonal",onClick:o.decrementCount},null,8,["disabled","onClick"]),r("div",gs,[r("span",ps,g(n.count),1),e[10]||(e[10]=r("span",{class:"text-subtitle-1 ml-2"},"人",-1))]),s(y,{disabled:n.count>=o.maxAllowedCount,class:"counter-btn",color:"primary",icon:"mdi-plus",size:"x-large",variant:"tonal",onClick:o.incrementCount},null,8,["disabled","onClick"])]),r("div",vs,[s(vt,{modelValue:n.pickerMode,"onUpdate:modelValue":e[1]||(e[1]=d=>n.pickerMode=d),class:"mode-toggle",color:"primary",mandatory:"",rounded:"pill"},{default:i(()=>[s(y,{"prepend-icon":"mdi-account",value:"name"},{default:i(()=>[...e[11]||(e[11]=[u("姓名模式",-1)])]),_:1}),s(y,{"prepend-icon":"mdi-numeric",value:"number"},{default:i(()=>[...e[12]||(e[12]=[u("学号模式",-1)])]),_:1})]),_:1},8,["modelValue"])]),n.pickerMode==="number"?(c(),p("div",ys,[e[14]||(e[14]=r("div",{class:"text-subtitle-1 mb-2"},"学号范围设置",-1)),r("div",ks,[s(Ce,{modelValue:n.minNumber,"onUpdate:modelValue":e[2]||(e[2]=d=>n.minNumber=d),modelModifiers:{number:!0},class:"number-input",density:"compact","hide-details":"",label:"最小值",max:"100",min:"1",type:"number"},null,8,["modelValue"]),e[13]||(e[13]=r("span",{class:"mx-2"},"至",-1)),s(Ce,{modelValue:n.maxNumber,"onUpdate:modelValue":e[3]||(e[3]=d=>n.maxNumber=d),modelModifiers:{number:!0},class:"number-input",density:"compact","hide-details":"",label:"最大值",max:"100",min:"1",type:"number"},null,8,["modelValue"])])])):w("",!0),r("div",bs,[s(y,{disabled:o.filteredStudents.length===0,class:"start-btn",color:"primary","prepend-icon":"mdi-dice-multiple",size:"x-large",onClick:o.startPicking},{default:i(()=>[...e[15]||(e[15]=[u(" 开始抽取 ",-1)])]),_:1},8,["disabled","onClick"])]),o.filteredStudents.length===0?(c(),p("div",xs,[n.pickerMode==="name"?(c(),p(E,{key:0},[u(" 没有可抽取的学生,请调整过滤选项 ")],64)):(c(),p(E,{key:1},[u(" 请设置有效的学号范围 ")],64))])):w("",!0),r("div",ws,[u(" 当前可抽取学生: "+g(o.filteredStudents.length)+"人 ",1),n.pickerMode==="name"?(c(),b(Ze,{key:0,location:"bottom"},{activator:i(({props:d})=>[s(D,Qe({class:"ml-1",icon:"mdi-information-outline",size:"small"},d),null,16)]),default:i(()=>[r("div",Ss,[n.tempFilters.excludeAbsent?(c(),p("div",Cs," • 已排除请假学生 ("+g(o.absentCount)+"人) ",1)):w("",!0),n.tempFilters.excludeLate?(c(),p("div",_s," • 已排除迟到学生 ("+g(o.lateCount)+"人) ",1)):w("",!0),n.tempFilters.excludeExcluded?(c(),p("div",Ds," • 已排除不参与学生 ("+g(o.excludedCount)+"人) ",1)):w("",!0)])]),_:1})):w("",!0),n.pickerMode==="name"?(c(),p("div",Ts,[s(O,{color:n.tempFilters.excludeLate?"warning":"default",variant:n.tempFilters.excludeLate?"elevated":"text",class:"filter-chip","prepend-icon":"mdi-clock-alert",onClick:e[4]||(e[4]=d=>n.tempFilters.excludeLate=!n.tempFilters.excludeLate)},{default:i(()=>[u(g(n.tempFilters.excludeLate?"排除":"包含")+"迟到学生 ",1)]),_:1},8,["color","variant"]),s(O,{color:n.tempFilters.excludeAbsent?"error":"default",variant:n.tempFilters.excludeAbsent?"elevated":"text",class:"filter-chip","prepend-icon":"mdi-account-off",onClick:e[5]||(e[5]=d=>n.tempFilters.excludeAbsent=!n.tempFilters.excludeAbsent)},{default:i(()=>[u(g(n.tempFilters.excludeAbsent?"排除":"包含")+"请假学生 ",1)]),_:1},8,["color","variant"]),s(O,{color:n.tempFilters.excludeExcluded?"grey":"default",variant:n.tempFilters.excludeExcluded?"elevated":"text",class:"filter-chip","prepend-icon":"mdi-account-cancel",onClick:e[6]||(e[6]=d=>n.tempFilters.excludeExcluded=!n.tempFilters.excludeExcluded)},{default:i(()=>[u(g(n.tempFilters.excludeExcluded?"排除":"包含")+"不参与学生 ",1)]),_:1},8,["color","variant"])])):w("",!0)])]),_:1}))]),_:1})]),_:1},8,["modelValue"])}const Tt=W(fs,[["render",As],["__scopeId","data-v-85e7eea6"]]),Us={name:"EventSender",emits:["sent","error"],methods:{async sendEvent(t,e={}){try{return es(t,e),this.$emit("sent",{eventName:t,content:e,timestamp:new Date().toISOString(),success:!0}),{success:!0,eventId:(e==null?void 0:e.eventId)||null,notificationId:(e==null?void 0:e.notificationId)||null}}catch(a){return console.error("发送事件失败:",a),this.$emit("error",{eventName:t,content:e,error:a.message,timestamp:new Date().toISOString(),success:!1}),{success:!1,error:a.message}}},async sendNotification(t,e=!1,a=[],l={},n=null){const o=`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return this.sendEvent("notification",{eventId:o,notificationId:n,message:t,isUrgent:e,targetDevices:a,senderInfo:l})},async sendReceipt(t,e,a={},l=null){const n=`rcpt-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;return this.sendEvent("notification-receipt",{eventId:n,originalEventId:t,notificationId:l,status:e,deviceInfo:a})},async sendDisplayedReceipt(t={},e=null){const a=`disp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;return this.sendEvent("notification-displayed",{eventId:a,notificationId:e,deviceInfo:t})},async sendReadReceipt(t={},e=null){const a=`read-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;return this.sendEvent("notification-read",{eventId:a,notificationId:e,deviceInfo:t})}}},zs={style:{display:"none"}};function Ms(t,e,a,l,n,o){return c(),p("div",zs)}const Fe=W(Us,[["render",Ms]]),$s={name:"UrgentNotification",components:{EventSender:Fe},data(){return{visible:!1,notificationQueue:[],currentIndex:0,autoCloseTimer:null,urgentSoundTimer:null,currentAudio:null}},computed:{currentNotification(){return this.notificationQueue[this.currentIndex]||null},hasNotifications(){return this.notificationQueue.length>0},hasMultipleNotifications(){return this.notificationQueue.length>1},notificationCountText(){return this.hasMultipleNotifications?`${this.currentIndex+1} / ${this.notificationQueue.length}`:""},isUrgent(){var t,e;return((e=(t=this.currentNotification)==null?void 0:t.content)==null?void 0:e.isUrgent)||!1},urgencyColor(){return this.isUrgent?"red darken-2":"blue darken-2"},iconColor(){return"white"},urgencyIcon(){return this.isUrgent?"mdi-alert-circle-outline":"mdi-information-outline"},urgencyTitle(){return this.isUrgent?"🚨 紧急通知":"📢 通知消息"},senderName(){var e,a,l;const t=((e=this.currentNotification)==null?void 0:e.senderInfo)||((l=(a=this.currentNotification)==null?void 0:a.content)==null?void 0:l.senderInfo);return t?t.deviceName||t.deviceType||"未知设备":"未知发送者"},deviceType(){var e,a,l;const t=((e=this.currentNotification)==null?void 0:e.senderInfo)||((l=(a=this.currentNotification)==null?void 0:a.content)==null?void 0:l.senderInfo);return(t==null?void 0:t.deviceType)=="teacher"?"教师":(t==null?void 0:t.deviceType)=="student"?"学生":(t==null?void 0:t.deviceType)=="classroom"?"教室":(t==null?void 0:t.deviceType)||"未知类型"},targetDevices(){var t,e;return((e=(t=this.currentNotification)==null?void 0:t.content)==null?void 0:e.targetDevices)||[]}},beforeUnmount(){this.autoCloseTimer&&clearTimeout(this.autoCloseTimer),this.urgentSoundTimer&&clearInterval(this.urgentSoundTimer),this.stopNotificationSound()},methods:{show(t){var a;if(this.notificationQueue.findIndex(l=>{var n,o;return((n=l.content)==null?void 0:n.notificationId)===((o=t.content)==null?void 0:o.notificationId)})!==-1){console.log("通知已存在,跳过添加");return}this.notificationQueue.push(t),this.visible?(a=t.content)!=null&&a.isUrgent&&!this.isUrgent?(this.currentIndex=this.notificationQueue.length-1,this.sendDisplayedReceipt(),this.playNotificationSound(),this.sendBrowserNotification(t),this.startUrgentSound()):this.sendBrowserNotification(t):(this.currentIndex=this.notificationQueue.length-1,this.visible=!0,this.sendDisplayedReceipt(),this.playNotificationSound(),this.sendBrowserNotification(t),this.isUrgent&&this.startUrgentSound())},close(){var t,e,a,l;try{this.sendReadReceipt(),console.log("已发送已读回执")}catch(n){console.warn("发送已读回执失败:",n)}if((e=(t=this.currentNotification)==null?void 0:t.content)!=null&&e.message){const n=this.isUrgent?"紧急通知":"通知";this.isUrgent?(a=this.$message)==null||a.error(n,`${this.currentNotification.content.message}`):(l=this.$message)==null||l.info(n,`${this.currentNotification.content.message}`)}this.notificationQueue.length>0&&(this.notificationQueue.splice(this.currentIndex,1),this.currentIndex>=this.notificationQueue.length&&(this.currentIndex=Math.max(0,this.notificationQueue.length-1)),this.notificationQueue.length>0?(this.sendDisplayedReceipt(),this.isUrgent?this.startUrgentSound():this.stopUrgentSound()):this.closeWithoutRead())},closeWithoutRead(){this.visible=!1,this.notificationQueue=[],this.currentIndex=0,this.autoCloseTimer&&(clearTimeout(this.autoCloseTimer),this.autoCloseTimer=null),this.stopUrgentSound()},formatTime(t){if(!t)return"";try{const e=new Date(t);if(new Date-e<24*60*60*1e3){const n=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0");return`${n}:${o}`}else{const n=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0");return`${n}/${o}`}}catch{return"无效时间"}},getDeviceTypeLabel(t){return{classroom:"教室设备",student:"学生设备",teacher:"教师设备",admin:"管理员设备",system:"系统设备"}[t]||t},playNotificationSound(){try{this.stopNotificationSound();const t=this.isUrgent?S("notification.urgentSound"):S("notification.singleSound");this.currentAudio=at(t,!1),this.currentAudio||this.playFallbackSound()}catch(t){console.warn("无法播放通知音效:",t),this.playFallbackSound()}},playFallbackSound(){try{const t=new(window.AudioContext||window.webkitAudioContext),e=t.createOscillator(),a=t.createGain();e.connect(a),a.connect(t.destination),e.frequency.value=1e3,e.type="sine",a.gain.value=.3,e.start(),e.stop(t.currentTime+.3)}catch(t){console.warn("无法播放备用音效:",t)}},stopNotificationSound(){this.currentAudio&&(ns(this.currentAudio),this.currentAudio=null)},sendDisplayedReceipt(){var t;try{this.$refs.eventSender&&((t=this.currentNotification)!=null&&t.eventId)&&(this.$refs.eventSender.sendDisplayedReceipt({},this.currentNotification.content.notificationId),console.log("已发送显示回执:",this.currentNotification.eventId))}catch(e){console.warn("发送显示回执失败:",e)}},sendReadReceipt(){var t;try{this.$refs.eventSender&&((t=this.currentNotification)!=null&&t.eventId)&&(this.$refs.eventSender.sendReadReceipt({},this.currentNotification.content.notificationId),console.log("已发送已读回执:",this.currentNotification.eventId))}catch(e){console.warn("发送已读回执失败:",e)}},previousNotification(){this.currentIndex>0&&(this.currentIndex--,this.sendDisplayedReceipt(),this.isUrgent?this.startUrgentSound():this.stopUrgentSound())},nextNotification(){this.currentIndex<this.notificationQueue.length-1&&(this.currentIndex++,this.sendDisplayedReceipt(),this.isUrgent?this.startUrgentSound():this.stopUrgentSound())},startUrgentSound(){this.stopUrgentSound(),this.stopNotificationSound();const t=S("notification.urgentSound");this.currentAudio=at(t,!0),this.currentAudio||(this.urgentSoundTimer=setInterval(()=>{this.visible&&this.isUrgent?this.playFallbackSound():this.stopUrgentSound()},1e3))},stopUrgentSound(){this.urgentSoundTimer&&(clearInterval(this.urgentSoundTimer),this.urgentSoundTimer=null),this.stopNotificationSound()},async sendBrowserNotification(t){var e,a,l,n;if(!("Notification"in window)){console.warn("浏览器不支持通知API");return}try{let o=Notification.permission;if(o==="default"&&(o=await Notification.requestPermission()),o!=="granted"){console.warn("用户未授予通知权限");return}const d=((e=t.content)==null?void 0:e.message)||"新通知",m=t.senderInfo||((a=t.content)==null?void 0:a.senderInfo),f=(m==null?void 0:m.deviceName)||(m==null?void 0:m.deviceType)||"未知发送者",h=((l=t.content)==null?void 0:l.isUrgent)||!1,k=new Notification(h?"🚨 紧急通知":"📢 通知消息",{body:`${d}
来自: ${f}`,icon:"/pwa/image/icon-192.png",badge:"/pwa/image/icon-192.png",tag:((n=t.content)==null?void 0:n.notificationId)||`notification-${Date.now()}`,requireInteraction:h,silent:!1,vibrate:h?[200,100,200,100,200]:[200],timestamp:t.timestamp||Date.now()});k.onclick=()=>{window.focus(),k.close()},h||setTimeout(()=>{k.close()},1e4)}catch(o){console.error("发送浏览器通知失败:",o)}}}},Ps={class:"urgent-title mb-6"},Ls={class:"urgent-subtitle mb-6"},Fs={key:0,class:"navigation-controls mt-6"},Rs={class:"notification-counter mb-3"},Os={class:"navigation-buttons"},Bs={class:"mt-8"};function js(t,e,a,l,n,o){const d=Fe;return c(),p(E,null,[s(J,{modelValue:n.visible,"onUpdate:modelValue":e[0]||(e[0]=m=>n.visible=m),"max-width":"800",persistent:"",transition:"dialog-transition",class:"urgent-notification-dialog"},{default:i(()=>[s(_,{class:"urgent-notification-card",color:o.urgencyColor,elevation:"24"},{default:i(()=>[s(V,null,{default:i(()=>{var m,f,h;return[r("div",Ps,g(((f=(m=o.currentNotification)==null?void 0:m.content)==null?void 0:f.message)||"无内容"),1),r("div",Ls,g(o.senderName)+" "+g(o.deviceType)+" "+g(o.formatTime((h=o.currentNotification)==null?void 0:h.timestamp)),1),o.hasMultipleNotifications?(c(),p("div",Fs,[s(_,{variant:"flat",color:"rgba(255,255,255,0.1)"},{default:i(()=>[s(V,{class:"text-center"},{default:i(()=>[r("div",Rs,[s(O,{color:"white",variant:"flat",size:"small"},{default:i(()=>[u(g(o.notificationCountText),1)]),_:1})]),r("div",Os,[s(y,{disabled:n.currentIndex===0,color:"white",variant:"outlined",size:"small",onClick:o.previousNotification},{default:i(()=>[s(D,null,{default:i(()=>[...e[1]||(e[1]=[u(" mdi-chevron-left ",-1)])]),_:1}),e[2]||(e[2]=u(" 上一个 ",-1))]),_:1},8,["disabled","onClick"]),s(y,{disabled:n.currentIndex===n.notificationQueue.length-1,color:"white",variant:"outlined",size:"small",class:"ml-2",onClick:o.nextNotification},{default:i(()=>[e[4]||(e[4]=u(" 下一个 ",-1)),s(D,null,{default:i(()=>[...e[3]||(e[3]=[u(" mdi-chevron-right ",-1)])]),_:1})]),_:1},8,["disabled","onClick"])])]),_:1})]),_:1})])):w("",!0),r("div",Bs,[s(y,{color:"white",size:"large",variant:"flat",onClick:o.close},{default:i(()=>[s(D,{left:""},{default:i(()=>[...e[5]||(e[5]=[u(" mdi-check ",-1)])]),_:1}),e[6]||(e[6]=u(" 我知道了 ",-1))]),_:1},8,["onClick"])])]}),_:1})]),_:1},8,["color"])]),_:1},8,["modelValue"]),s(d,{ref:"eventSender"},null,512)],64)}const It=W($s,[["render",js],["__scopeId","data-v-6190a823"]]),Hs={name:"ChatWidget",components:{UrgentNotification:It},props:{modelValue:{type:Boolean,default:!1},showButton:{type:Boolean,default:!0},offset:{type:Number,default:16},width:{type:Number,default:380},height:{type:Number,default:520}},emits:["update:modelValue"],data(){return{visible:this.modelValue,text:"",messages:[],allEvents:[],lastVisit:null,unreadCount:0,connected:!1,socketId:"",currentMode:"chat",currentPage:1,itemsPerPage:20,loading:!1,isDestroying:!1,eventStats:{chat:0,kvChanged:0,other:0},cleanupFunctions:[]}},computed:{panelStyle(){return{right:this.offset+"px",bottom:this.offset+"px",width:this.width+"px",height:this.height+"px"}},toggleStyle(){return{right:this.offset+"px",bottom:this.offset+"px"}},canSend(){return!!(S("server.kvToken")&&this.text.trim())},showToggleButton(){return this.$props.showButton&&!this.visible},decoratedMessages(){if(!this.lastVisit)return this.messages;const t=this.messages.findIndex(l=>l.at&&new Date(l.at).getTime()>=new Date(this.lastVisit).getTime());if(t<=0)return this.messages;const e=this.messages.slice(0,t),a=this.messages.slice(t);return[...e,{_id:"divider",_type:"divider"},...a]},currentDisplayItems(){return this.currentMode==="chat"?this.decoratedMessages:this.paginatedEvents},paginatedEvents(){if(this.isDestroying||!this.allEvents)return[];const t=(this.currentPage-1)*this.itemsPerPage,e=t+this.itemsPerPage;return this.allEvents.slice(t,e)},totalPages(){return this.isDestroying||!this.allEvents?1:Math.ceil(this.allEvents.length/this.itemsPerPage)},modeTitle(){return this.currentMode==="chat"?"设备聊天室":"所有事件"}},watch:{modelValue(t){this.visible=t,t&&this.onOpen()}},mounted(){try{const h=localStorage.getItem("chat.lastVisit");h&&(this.lastVisit=h)}catch{}const t=wt();this.connected=!!t.connected,this.socketId=t.id||"",t.on("connect",()=>{this.connected=!0,this.socketId=t.id||""}),t.on("disconnect",()=>{this.connected=!1});const e=S("server.kvToken");e&&We(e);const a=h=>(...k)=>{if(!this.isDestroying)try{h(...k)}catch(I){console.error("ChatWidget 事件处理错误:",I)}},l=ce("chat:message",a(h=>{this.pushMessage(h),this.addEvent({_id:`legacy-chat-${Date.now()}-${Math.random()}`,type:"chat:message",content:h,timestamp:h.at||new Date().toISOString(),senderId:h.senderId,uuid:h.uuid,senderInfo:h.senderInfo})})),n=ce("chat",a(h=>{if(h&&h.content&&h.content.text){const k={text:h.content.text,senderId:h.senderId,at:h.timestamp,uuid:h.senderId,senderInfo:h.senderInfo};this.pushMessage(k),this.addEvent({_id:h.eventId||`chat-${Date.now()}-${Math.random()}`,type:"chat",content:h.content,timestamp:h.timestamp,eventId:h.eventId,senderId:h.senderId,senderInfo:h.senderInfo})}}));this.deviceEventHandler=Ct({onChat:a((h,k)=>{this.pushMessage(h),this.addEvent(k)}),onKvChanged:a((h,k)=>{this.addEvent(k)}),onUrgentNotice:a((h,k)=>{this.addEvent(k),this.showUrgentNotification(k)}),onNotification:a((h,k)=>{console.log("收到通知事件:",h,k),this.addEvent(k),this.showUrgentNotification(k)}),onOtherEvent:a(h=>{(h.type==="urgent-notice"||h.type==="notification")&&this.showUrgentNotification(h),this.addEvent(h)}),enableLegacySupport:!0});const o=ce("device-event",this.deviceEventHandler),d=ce("kv-key-changed",a(h=>{h.content&&h.timestamp?this.addEvent({_id:`kv-${Date.now()}-${Math.random()}`,type:"kv-key-changed",content:h.content,timestamp:h.timestamp,eventId:h.eventId,senderId:h.senderId,senderInfo:h.senderInfo}):this.addEvent({_id:`legacy-kv-${Date.now()}-${Math.random()}`,type:"kv-key-changed",content:h,timestamp:h.updatedAt||new Date().toISOString(),uuid:h.uuid})})),m=ce("urgent-notice",a(h=>{console.log("收到紧急通知:",h),this.addEvent({_id:`urgent-${Date.now()}-${Math.random()}`,type:"urgent-notice",content:h.content||h,timestamp:h.timestamp||new Date().toISOString(),eventId:h.eventId,senderId:h.senderId,senderInfo:h.senderInfo}),this.showUrgentNotification(h)})),f=ce("notification",a(h=>{var k;console.log("收到通知事件:",h),this.addEvent({_id:`notification-${Date.now()}-${Math.random()}`,type:"notification",content:h.content||h,timestamp:h.timestamp||new Date().toISOString(),eventId:h.eventId,senderId:h.senderId,senderInfo:h.senderInfo||((k=h.content)==null?void 0:k.senderInfo)}),this.showUrgentNotification(h)}));this.cleanupFunctions=[l,n,m,f,o,d],this.visible&&this.onOpen()},beforeUnmount(){this.isDestroying=!0,this.cleanupFunctions&&Array.isArray(this.cleanupFunctions)&&this.cleanupFunctions.forEach(t=>{try{typeof t=="function"&&t()}catch(e){console.warn("ChatWidget 清理函数执行失败:",e)}});try{this.offMessage&&this.offMessage(),this.offDeviceEvent&&this.offDeviceEvent(),this.offKvChanged&&this.offKvChanged()}catch(t){console.warn("ChatWidget 旧清理函数执行失败:",t)}this.cleanupFunctions=[],this.messages=[],this.allEvents=[]},methods:{open(){this.visible=!0,this.$emit("update:modelValue",!0),this.onOpen()},close(){this.visible=!1,this.$emit("update:modelValue",!1);try{localStorage.setItem("chat.lastVisit",new Date().toISOString())}catch{}this.unreadCount=0},onOpen(){this.$nextTick(()=>this.scrollToBottom())},insertEmoji(t){this.text+=t,this.$nextTick(()=>{var e,a;if((a=(e=this.$refs.inputRef)==null?void 0:e.$el)!=null&&a.querySelector){const l=this.$refs.inputRef.$el.querySelector("textarea");l==null||l.focus()}})},handleEnter(t){t.shiftKey||this.send()},send(){const t=this.text.trim();if(!t)return;const e={_id:`self-${Date.now()}-${Math.random()}`,text:t,at:new Date().toISOString(),senderId:this.socketId,self:!0,senderInfo:{deviceName:"我",deviceType:"client",isReadOnly:!1}};this.pushMessage(e),this.addEvent({_id:`self-event-${Date.now()}-${Math.random()}`,type:"chat",content:{text:t},timestamp:new Date().toISOString(),senderId:this.socketId,senderInfo:{deviceName:"本设备",deviceType:"client",isReadOnly:!1}}),os(t),this.text=""},pushMessage(t){if(!(this.isDestroying||!t))try{const e={_id:`${t.at||Date.now()}-${Math.random()}`,text:typeof(t==null?void 0:t.text)=="string"?t.text:(t==null?void 0:t.text)||"",at:t.at||new Date().toISOString(),senderId:t.senderId,self:!!(t.senderId&&t.senderId===this.socketId),senderInfo:t.senderInfo||null,deviceName:this.getDeviceName(t.senderInfo,t.senderId===this.socketId)};if(!e.text)return;this.messages.push(e),this.visible||this.unreadCount++,this.$nextTick(()=>{this.isDestroying||this.scrollToBottom()}),this.messages.length>500&&this.messages.shift()}catch(e){console.error("ChatWidget pushMessage 错误:",e)}},formatTime(t){try{const e=new Date(t),a=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0");return`${a}:${l}`}catch{return""}},scrollToBottom(){if(!this.isDestroying)try{const t=this.$refs.listRef;if(!t)return;requestAnimationFrame(()=>{!this.isDestroying&&t&&(t.scrollTop=t.scrollHeight)})}catch(t){console.warn("ChatWidget scrollToBottom 错误:",t)}},addEvent(t){if(!(this.isDestroying||!t))try{this.allEvents.unshift(t),t.type==="chat"||t.type==="chat:message"?this.eventStats.chat++:t.type==="kv-key-changed"?this.eventStats.kvChanged++:this.eventStats.other++,this.allEvents.length>200&&(this.allEvents=this.allEvents.slice(0,200))}catch(e){console.error("ChatWidget addEvent 错误:",e)}},getEventColor(t){switch(t){case"chat":case"chat:message":return"success";case"kv-key-changed":return"info";default:return"warning"}},getEventTypeLabel(t){switch(t){case"chat":case"chat:message":return"聊天";case"kv-key-changed":return"KV变化";default:return t}},formatDeviceInfo(t){return as(t)},getDeviceName(t,e=!1){return e?"我":t?t.deviceName==="realtime"?"系统":t.deviceName||t.deviceType||"未知设备":"未知设备"},showUrgentNotification(t){try{this.$refs.urgentNotification?this.$refs.urgentNotification.show(t):console.warn("紧急通知组件未找到")}catch(e){console.error("显示紧急通知失败:",e)}}}},Ks={class:"text-subtitle-1"},qs={key:0,ref:"listRef",class:"messages"},Ws={key:0,class:"divider-row"},Gs={class:"avatar"},Qs={class:"bubble"},Js={key:0,class:"sender-name"},Ys={class:"text"},Xs={class:"meta"},Zs={key:0,class:"device-name"},en={key:1,class:"events-container"},tn={class:"event-stats mb-3"},sn={class:"text-h6"},nn={class:"text-h6"},an={class:"text-h6"},on={class:"events-list"},ln={class:"d-flex align-center mb-1"},rn={class:"text-caption"},dn={key:0,class:"mb-1 text-caption"},un={class:"event-content"},cn={key:0,class:"chat-content"},mn={key:1,class:"text-caption event-data"},fn={key:0,class:"text-center text-grey pa-4"},hn={key:0,class:"pagination mt-2"};function gn(t,e,a,l,n,o){const d=It;return c(),p(E,null,[o.showToggleButton?(c(),p("div",{key:0,style:he(o.toggleStyle),class:"chat-toggle"},[s(y,{color:"primary",icon:"",variant:"flat",onClick:e[0]||(e[0]=m=>o.open())},{default:i(()=>[s(Zt,{content:n.unreadCount||void 0,"model-value":n.unreadCount>0,color:"error",overlap:""},{default:i(()=>[s(D,null,{default:i(()=>[...e[7]||(e[7]=[u(" mdi-chat ",-1)])]),_:1})]),_:1},8,["content","model-value"])]),_:1})],4)):w("",!0),oe(r("div",{style:he(o.panelStyle),class:"chat-panel"},[s(_,{border:"",class:"chat-card",elevation:"8"},{default:i(()=>[s(j,{class:"d-flex align-center"},{default:i(()=>[s(D,{class:"mr-2"},{default:i(()=>[...e[8]||(e[8]=[u(" mdi-chat-processing ",-1)])]),_:1}),r("span",Ks,g(o.modeTitle),1),s(L),s(vt,{modelValue:n.currentMode,"onUpdate:modelValue":e[1]||(e[1]=m=>n.currentMode=m),class:"mr-2",mandatory:"",size:"small",variant:"outlined"},{default:i(()=>[s(y,{value:"chat",size:"small"},{default:i(()=>[s(D,null,{default:i(()=>[...e[9]||(e[9]=[u("mdi-chat",-1)])]),_:1})]),_:1}),s(y,{value:"events",size:"small"},{default:i(()=>[s(D,null,{default:i(()=>[...e[10]||(e[10]=[u("mdi-format-list-bulleted",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue"]),s(Ze,{location:"top"},{activator:i(({props:m})=>[s(O,Qe({color:n.connected?"success":"grey",size:"x-small"},m,{variant:"tonal"}),{default:i(()=>[u(g(n.connected?"已连接":"未连接"),1)]),_:1},16,["color"])]),default:i(()=>[r("span",null,"Socket "+g(n.socketId||"-"),1)]),_:1}),s(y,{icon:"",variant:"text",onClick:e[2]||(e[2]=m=>o.close())},{default:i(()=>[s(D,null,{default:i(()=>[...e[11]||(e[11]=[u("mdi-close",-1)])]),_:1})]),_:1})]),_:1}),s(ve),s(V,{class:"chat-body"},{default:i(()=>[n.currentMode==="chat"?(c(),p("div",qs,[(c(!0),p(E,null,U(o.decoratedMessages,m=>(c(),p(E,{key:m._id},[m._type==="divider"?(c(),p("div",Ws,[s(ve,{class:"my-2"}),e[12]||(e[12]=r("div",{class:"divider-text"}," 今天 - 上次访问 ",-1)),s(ve,{class:"my-2"})])):(c(),p("div",{key:1,class:fe([{self:m.self},"message-row"])},[r("div",Gs,[s(Ie,{color:m.self?"primary":"grey",size:"24"},{default:i(()=>[s(D,{size:"small"},{default:i(()=>[u(g(m.self?"mdi-account":"mdi-account-outline"),1)]),_:2},1024)]),_:2},1032,["color"])]),r("div",Qs,[!m.self&&m.deviceName?(c(),p("div",Js,g(m.deviceName),1)):w("",!0),r("div",Ys,g(m.text),1),r("div",Xs,[m.self&&m.deviceName?(c(),p("span",Zs,g(m.deviceName)+" • ",1)):w("",!0),u(" "+g(o.formatTime(m.at)),1)])])],2))],64))),128))],512)):(c(),p("div",en,[r("div",tn,[s(ue,{dense:""},{default:i(()=>[s(ne,{cols:"4"},{default:i(()=>[s(_,{color:"success",dark:"",size:"small"},{default:i(()=>[s(V,{class:"text-center pa-2"},{default:i(()=>[r("div",sn,g(n.eventStats.chat),1),e[13]||(e[13]=r("div",{class:"text-caption"}," 聊天 ",-1))]),_:1})]),_:1})]),_:1}),s(ne,{cols:"4"},{default:i(()=>[s(_,{color:"info",dark:"",size:"small"},{default:i(()=>[s(V,{class:"text-center pa-2"},{default:i(()=>[r("div",nn,g(n.eventStats.kvChanged),1),e[14]||(e[14]=r("div",{class:"text-caption"}," KV变化 ",-1))]),_:1})]),_:1})]),_:1}),s(ne,{cols:"4"},{default:i(()=>[s(_,{color:"warning",dark:"",size:"small"},{default:i(()=>[s(V,{class:"text-center pa-2"},{default:i(()=>[r("div",an,g(n.eventStats.other),1),e[15]||(e[15]=r("div",{class:"text-caption"}," 其他 ",-1))]),_:1})]),_:1})]),_:1})]),_:1})]),r("div",on,[(c(!0),p(E,null,U(o.paginatedEvents,m=>(c(),p("div",{key:m._id,class:"event-item mb-2"},[s(_,{color:o.getEventColor(m.type),size:"small",variant:"outlined"},{default:i(()=>[s(V,{class:"pa-2"},{default:i(()=>{var f;return[r("div",ln,[s(O,{color:o.getEventColor(m.type),size:"x-small"},{default:i(()=>[u(g(o.getEventTypeLabel(m.type)),1)]),_:2},1032,["color"]),s(L),r("span",rn,g(o.formatTime(m.timestamp||m.at)),1)]),m.senderInfo?(c(),p("div",dn,[e[16]||(e[16]=r("strong",null,"发送者:",-1)),u(" "+g(o.formatDeviceInfo(m.senderInfo)),1)])):w("",!0),r("div",un,[m.type==="chat"||m.type==="chat:message"?(c(),p("div",cn,g(((f=m.content)==null?void 0:f.text)||m.text),1)):(c(),p("pre",mn,g(JSON.stringify(m.content||m,null,1)),1))])]}),_:2},1024)]),_:2},1032,["color"])]))),128)),n.allEvents.length===0?(c(),p("div",fn," 暂无事件 ")):w("",!0)]),o.totalPages>1?(c(),p("div",hn,[s(ls,{modelValue:n.currentPage,"onUpdate:modelValue":e[3]||(e[3]=m=>n.currentPage=m),length:o.totalPages,"total-visible":3,size:"small"},null,8,["modelValue","length"])])):w("",!0)]))]),_:1}),n.currentMode==="chat"?(c(),b(ve,{key:0})):w("",!0),n.currentMode==="chat"?(c(),b(X,{key:1,class:"chat-input"},{default:i(()=>[s(y,{class:"mr-1",icon:"",variant:"text",onClick:e[4]||(e[4]=m=>o.insertEmoji("😄"))},{default:i(()=>[s(D,null,{default:i(()=>[...e[17]||(e[17]=[u("mdi-emoticon-outline",-1)])]),_:1})]),_:1}),s(Ue,{ref:"inputRef",modelValue:n.text,"onUpdate:modelValue":e[5]||(e[5]=m=>n.text=m),"auto-grow":"",class:"flex-grow-1","hide-details":"",placeholder:"输入消息",rows:"1",variant:"solo",onKeydown:[tt(qe(o.handleEnter,["prevent"]),["enter"]),e[6]||(e[6]=tt(qe(()=>{},["shift","stop"]),["enter"]))]},null,8,["modelValue","onKeydown"]),s(y,{disabled:!o.canSend,class:"ml-2",color:"primary",onClick:o.send},{default:i(()=>[s(D,{start:""},{default:i(()=>[...e[18]||(e[18]=[u(" mdi-send ",-1)])]),_:1}),e[19]||(e[19]=u(" 发送 ",-1))]),_:1},8,["disabled","onClick"])]),_:1})):w("",!0)]),_:1})],4),[[be,n.visible]]),s(d,{ref:"urgentNotification"},null,512)],64)}const Re=W(Hs,[["render",gn],["__scopeId","data-v-1a62ac2a"]]),pn={name:"UrgentTestDialog",components:{ChatWidget:Re,EventSender:Fe},props:{modelValue:{type:Boolean,default:!1}},emits:["update:modelValue"],data(){return{sending:!1,notificationForm:{isUrgent:!1,message:"",isPersistent:!1},sentMessages:[],receiptCleanup:[],persistentNotifications:[],editDialog:!1,editForm:{id:null,message:"",isUrgent:!1,resend:!1},savingEdit:!1,deleteConfirmDialog:!1,itemToDelete:null}},computed:{dialog:{get(){return this.modelValue},set(t){this.$emit("update:modelValue",t)}}},mounted(){this.setupEventListeners(),this.loadPersistentNotifications()},beforeUnmount(){this.cleanup()},methods:{generateNotificationId(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let a=0;a<32;a++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},async sendNotification(){if(this.notificationForm.message.trim()){this.sending=!0;try{const t=this.generateNotificationId(),e=this.notificationForm.message,a=this.notificationForm.isUrgent,l=this.notificationForm.isPersistent,n=await this.$refs.eventSender.sendNotification(e,a,[],{deviceName:"测试设备",deviceType:"system",isReadOnly:!1},t),o=(n==null?void 0:n.eventId)||`msg-${Date.now()}`;if(this.sentMessages.push({id:o,notificationId:t,message:e,isUrgent:a,timestamp:new Date().toISOString(),receipts:{displayed:[],read:[]}}),l)try{const d="notification-list",m=await Z.loadData(d);let f=[];m&&Array.isArray(m)?f=m:m&&m.success!==!1&&Array.isArray(m.data)&&(f=m.data);const h={id:t,message:e,isUrgent:a,timestamp:new Date().toISOString()};f.unshift(h),await Z.saveData(d,f),this.persistentNotifications=f,console.log("常驻通知已保存")}catch(d){console.error("保存常驻通知失败",d)}console.log("通知已发送事件ID:",o,"通知ID:",t),this.resetForm()}catch(t){console.error("发送通知失败:",t)}finally{this.sending=!1}}},resetForm(){this.notificationForm={isUrgent:!1,message:"",isPersistent:!1}},close(){this.dialog=!1},setupEventListeners(){const t=ce("notification-displayed",a=>{console.log("收到显示回执:",a),this.updateReceipt(a,"displayed")}),e=ce("notification-read",a=>{console.log("收到已读回执:",a),this.updateReceipt(a,"read")});this.receiptCleanup.push(t,e)},updateReceipt(t,e){var o,d,m,f,h;const a=t.originalEventId,l=t.notificationId||((o=t.content)==null?void 0:o.notificationId);if(!a&&!l)return;const n=this.sentMessages.find(k=>k.id===a||k.notificationId===l);if(n){const k={senderId:t.senderId||"unknown-sender",deviceName:((d=t.senderInfo)==null?void 0:d.deviceName)||((m=t.deviceInfo)==null?void 0:m.deviceName)||"未知设备",deviceType:((f=t.senderInfo)==null?void 0:f.deviceType)||((h=t.deviceInfo)==null?void 0:h.deviceType)||"unknown",timestamp:new Date().toISOString()};n.receipts[e].find(F=>F.senderId===k.senderId)||(n.receipts[e].push(k),console.log(`更新${e}回执:`,n.id,k))}},cleanup(){this.receiptCleanup.forEach(t=>t()),this.receiptCleanup=[]},formatTime(t){return new Date(t).toLocaleString("zh-CN")},getReceiptStatus(t){return t.read.length>0?"已读":t.displayed.length>0?"已显示":"已发送"},getReceiptColor(t){return t.read.length>0?"success":t.displayed.length>0?"info":"grey"},formatDeviceTime(t){return new Date(t).toLocaleTimeString("zh-CN")},getMainCardColor(t){return t.read.length>0?"success":t.displayed.length>0?"info":"grey"},hasAnyReceipts(t){return t.read.length>0||t.displayed.length>0},getDisplayedOnlyDevices(t){const e=t.read.map(a=>a.senderId);return t.displayed.filter(a=>!e.includes(a.senderId))},openEditDialog(t){this.editForm={id:t.id,message:t.message,isUrgent:t.isUrgent||!1,resend:!1,timestamp:t.timestamp},this.editDialog=!0},async saveEdit(){var t,e;if(this.editForm.message.trim()){this.savingEdit=!0;try{const a=this.persistentNotifications.findIndex(l=>l.id===this.editForm.id);if(a!==-1){if(this.persistentNotifications[a]={...this.persistentNotifications[a],message:this.editForm.message,isUrgent:this.editForm.isUrgent,timestamp:new Date().toISOString()},await Z.saveData("notification-list",this.persistentNotifications),this.editForm.resend){const l=this.editForm.id,n=this.editForm.message,o=this.editForm.isUrgent,d=await this.$refs.eventSender.sendNotification(n,o,[],{deviceName:"测试设备",deviceType:"system",isReadOnly:!1},l),m=(d==null?void 0:d.eventId)||`msg-${Date.now()}`;this.sentMessages.push({id:m,notificationId:l,message:n,isUrgent:o,timestamp:new Date().toISOString(),receipts:{displayed:[],read:[]}})}this.editDialog=!1,(t=this.$message)==null||t.success("已更新")}}catch(a){console.error("保存失败",a),(e=this.$message)==null||e.error("保存失败")}finally{this.savingEdit=!1}}},async loadPersistentNotifications(){try{const t=await Z.loadData("notification-list");t&&Array.isArray(t)?this.persistentNotifications=t:t&&t.success!==!1&&Array.isArray(t.data)?this.persistentNotifications=t.data:this.persistentNotifications=[]}catch(t){console.error("加载常驻通知失败",t)}},async deleteNotification(t){if(confirm("确定要删除这个通知吗?"))try{this.sentMessages=this.sentMessages.filter(a=>a.id!==t),this.persistentNotifications=this.persistentNotifications.filter(a=>a.id!==t),console.log("通知已删除通知ID:",t)}catch(a){console.error("删除通知失败:",a)}},deletePersistentNotification(t){this.itemToDelete=t,this.deleteConfirmDialog=!0},async executeDelete(){var e,a;if(!this.itemToDelete)return;const t=this.itemToDelete;this.deleteConfirmDialog=!1,this.itemToDelete=null;try{this.persistentNotifications=this.persistentNotifications.filter(n=>n.id!==t);const l=this.persistentNotifications.length>0?this.persistentNotifications:{};await Z.saveData("notification-list",l),(e=this.$message)==null||e.success("已删除")}catch(l){console.error("删除失败",l),(a=this.$message)==null||a.error("删除失败")}}}},vn={key:0,class:"text-center text-grey py-4"},yn={key:0,class:"text-center text-grey py-8"},kn={class:"d-flex align-center mb-2"},bn={class:"font-weight-medium"},xn={class:"text-caption font-weight-medium"},wn={class:"text-body-2 mb-3",style:{"max-height":"60px",overflow:"hidden"}},Sn={class:"text-caption"},Cn={key:0},_n={class:"align-center"},Dn={class:"text-body-2 font-weight-medium"},Tn={class:"text-caption mt-1"},In={class:"align-center"},En={class:"text-body-2 font-weight-medium"},Nn={class:"text-caption text-grey"},Vn={class:"text-caption text-grey mt-1"},An={key:1};function Un(t,e,a,l,n,o){const d=Re,m=Fe;return c(),b(J,{modelValue:o.dialog,"onUpdate:modelValue":e[11]||(e[11]=f=>o.dialog=f),fullscreen:"",transition:"dialog-bottom-transition",scrollable:""},{default:i(()=>[s(_,null,{default:i(()=>[s(rt,{dark:"",flat:""},{default:i(()=>[s(dt,null,{default:i(()=>[s(D,{class:"mr-2"},{default:i(()=>[...e[12]||(e[12]=[u(" mdi-chat ",-1)])]),_:1}),e[13]||(e[13]=u(" 发送通知 ",-1))]),_:1}),s(L),s(y,{icon:"mdi-close",onClick:o.close},null,8,["onClick"])]),_:1}),s(V,{class:"pa-0"},{default:i(()=>[s(Dt,null,{default:i(()=>[s(ue,null,{default:i(()=>[s(ne,{cols:"12"},{default:i(()=>[s(_,null,{default:i(()=>[s(V,null,{default:i(()=>[s(ut,null,{default:i(()=>[s(ue,null,{default:i(()=>[s(ne,{cols:"12",md:"6"},{default:i(()=>[s(Ge,{modelValue:n.notificationForm.isUrgent,"onUpdate:modelValue":e[0]||(e[0]=f=>n.notificationForm.isUrgent=f),label:"强调通知",color:"red",inset:""},null,8,["modelValue"]),s(lt,{modelValue:n.notificationForm.isPersistent,"onUpdate:modelValue":e[1]||(e[1]=f=>n.notificationForm.isPersistent=f),label:"常驻展示",color:"primary","hide-details":"",class:"mt-0"},null,8,["modelValue"])]),_:1}),s(ne,{cols:"12"},{default:i(()=>[s(Ue,{modelValue:n.notificationForm.message,"onUpdate:modelValue":e[2]||(e[2]=f=>n.notificationForm.message=f),label:"通知内容",outlined:"",rows:"3",placeholder:"请输入强调通知的内容..."},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1}),s(X,{class:"px-6 pb-6"},{default:i(()=>[s(y,{color:n.notificationForm.isUrgent?"red":"blue",disabled:!n.notificationForm.message.trim(),loading:n.sending,size:"large",variant:"elevated",onClick:o.sendNotification},{default:i(()=>[s(D,{left:""},{default:i(()=>[u(g(n.notificationForm.isUrgent?"mdi-alert-circle":"mdi-information"),1)]),_:1}),u(" "+g(n.notificationForm.isUrgent?"发送强调通知":"发送通知"),1)]),_:1},8,["color","disabled","loading","onClick"]),s(L)]),_:1})]),_:1})]),_:1})]),_:1}),s(ue,{class:"mt-4"},{default:i(()=>[s(ne,{cols:"12"},{default:i(()=>[s(_,null,{default:i(()=>[s(j,null,{default:i(()=>[s(D,{class:"mr-2"},{default:i(()=>[...e[14]||(e[14]=[u("mdi-pin",-1)])]),_:1}),e[15]||(e[15]=u(" 常驻通知管理 ",-1))]),_:1}),s(V,null,{default:i(()=>[n.persistentNotifications.length===0?(c(),p("div",vn," 暂无常驻通知 ")):(c(),b(we,{key:1},{default:i(()=>[(c(!0),p(E,null,U(n.persistentNotifications,f=>(c(),b(Se,{key:f.id,title:f.message,subtitle:o.formatTime(f.timestamp),lines:"two"},{prepend:i(()=>[s(D,{color:f.isUrgent?"error":"primary"},{default:i(()=>[u(g(f.isUrgent?"mdi-alert-circle":"mdi-information"),1)]),_:2},1032,["color"])]),append:i(()=>[s(y,{icon:"mdi-pencil",variant:"text",size:"small",onClick:h=>o.openEditDialog(f)},null,8,["onClick"]),s(y,{icon:"mdi-delete",variant:"text",color:"error",size:"small",onClick:h=>o.deletePersistentNotification(f.id)},null,8,["onClick"])]),_:2},1032,["title","subtitle"]))),128))]),_:1}))]),_:1})]),_:1})]),_:1})]),_:1}),s(ue,{class:"mt-4"},{default:i(()=>[s(ne,{cols:"12"},{default:i(()=>[s(_,null,{default:i(()=>[s(j,null,{default:i(()=>[s(D,{class:"mr-2"},{default:i(()=>[...e[16]||(e[16]=[u(" mdi-history ",-1)])]),_:1}),e[17]||(e[17]=u(" 消息记录 ",-1)),s(L)]),_:1}),s(V,null,{default:i(()=>[n.sentMessages.length===0?(c(),p("div",yn,[s(D,{size:"64",color:"grey-lighten-2"},{default:i(()=>[...e[18]||(e[18]=[u(" mdi-message-outline ",-1)])]),_:1}),e[19]||(e[19]=r("div",{class:"mt-2"}," 暂无发送记录 ",-1))])):(c(),b(ue,{key:1},{default:i(()=>[(c(!0),p(E,null,U(n.sentMessages.slice().reverse(),f=>(c(),b(ne,{key:f.id,cols:"12",md:"6",lg:"4"},{default:i(()=>[s(_,{color:o.getMainCardColor(f.receipts),class:"mb-2"},{default:i(()=>[s(V,null,{default:i(()=>[r("div",kn,[r("span",bn,g(f.isUrgent?"强调通知":"通知"),1),s(L),r("span",xn,g(o.getReceiptStatus(f.receipts)),1)]),r("div",wn,g(f.message),1),r("div",Sn,[r("div",null,"发送时间:"+g(o.formatTime(f.timestamp)),1),r("div",null,"事件ID"+g(f.id),1),r("div",null,"通知ID"+g(f.notificationId),1)])]),_:2},1024)]),_:2},1032,["color"]),o.hasAnyReceipts(f.receipts)?(c(),p("div",Cn,[(c(!0),p(E,null,U(f.receipts.read,h=>(c(),b(_,{key:`${h.senderId}-read`,color:"success",class:"mb-1",size:"small"},{default:i(()=>[s(V,{class:"pa-2"},{default:i(()=>[r("div",_n,[r("span",Dn,g(h.deviceName),1),e[20]||(e[20]=r("br",null,null,-1)),u(" "+g(h.deviceType),1)]),r("div",Tn," 已读于 "+g(o.formatDeviceTime(h.timestamp)),1)]),_:2},1024)]),_:2},1024))),128)),(c(!0),p(E,null,U(o.getDisplayedOnlyDevices(f.receipts),h=>(c(),b(_,{key:`${h.senderId}-displayed`,color:"info-lighten-4",variant:"outlined",class:"mb-1",size:"small"},{default:i(()=>[s(V,{class:"pa-2"},{default:i(()=>[r("div",In,[r("span",En,g(h.deviceName),1),s(L),r("span",Nn,g(h.deviceType=="classroom"?"教室设备上的应用":h.deviceType),1)]),r("div",Vn," 已显示于 "+g(o.formatDeviceTime(h.timestamp)),1)]),_:2},1024)]),_:2},1024))),128))])):(c(),p("div",An,[s(_,{color:"info-lighten-4",variant:"outlined",class:"mb-1",size:"small",title:"无设备在线"},{default:i(()=>[s(V,null,{default:i(()=>[...e[21]||(e[21]=[u(" 如果数秒后任然显示这个提示,则可能没有任何设备在线接收通知。 ",-1)])]),_:1})]),_:1})]))]),_:2},1024))),128))]),_:1}))]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),s(d),s(m,{ref:"eventSender"},null,512),s(J,{modelValue:n.editDialog,"onUpdate:modelValue":e[8]||(e[8]=f=>n.editDialog=f),"max-width":"500",fullscreen:t.$vuetify.display.xs},{default:i(()=>[s(_,null,{default:i(()=>[s(rt,{flat:"",density:"compact"},{default:i(()=>[s(dt,null,{default:i(()=>[...e[22]||(e[22]=[u("编辑常驻通知",-1)])]),_:1}),s(L),s(y,{icon:"mdi-close",onClick:e[3]||(e[3]=f=>n.editDialog=!1)})]),_:1}),s(V,null,{default:i(()=>[s(ut,null,{default:i(()=>[s(Ue,{modelValue:n.editForm.message,"onUpdate:modelValue":e[4]||(e[4]=f=>n.editForm.message=f),label:"通知内容",rows:"3","auto-grow":""},null,8,["modelValue"]),s(Ge,{modelValue:n.editForm.isUrgent,"onUpdate:modelValue":e[5]||(e[5]=f=>n.editForm.isUrgent=f),label:"强调通知",color:"error","hide-details":""},null,8,["modelValue"]),s(lt,{modelValue:n.editForm.resend,"onUpdate:modelValue":e[6]||(e[6]=f=>n.editForm.resend=f),label:"保存并重新发送通知",hint:"勾选后将作为新通知发送给所有在线设备","persistent-hint":""},null,8,["modelValue"])]),_:1})]),_:1}),s(X,null,{default:i(()=>[s(L),s(y,{variant:"text",onClick:e[7]||(e[7]=f=>n.editDialog=!1)},{default:i(()=>[...e[23]||(e[23]=[u("取消",-1)])]),_:1}),s(y,{color:"primary",loading:n.savingEdit,onClick:o.saveEdit},{default:i(()=>[...e[24]||(e[24]=[u("保存",-1)])]),_:1},8,["loading","onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue","fullscreen"]),s(J,{modelValue:n.deleteConfirmDialog,"onUpdate:modelValue":e[10]||(e[10]=f=>n.deleteConfirmDialog=f),"max-width":"400"},{default:i(()=>[s(_,null,{default:i(()=>[s(j,{class:"text-h5"},{default:i(()=>[...e[25]||(e[25]=[u("确认删除",-1)])]),_:1}),s(V,null,{default:i(()=>[...e[26]||(e[26]=[u("确定要删除这条常驻通知吗?此操作无法撤销。",-1)])]),_:1}),s(X,null,{default:i(()=>[s(L),s(y,{color:"grey-darken-1",variant:"text",onClick:e[9]||(e[9]=f=>n.deleteConfirmDialog=!1)},{default:i(()=>[...e[27]||(e[27]=[u("取消",-1)])]),_:1}),s(y,{color:"error",variant:"text",onClick:o.executeDelete},{default:i(()=>[...e[28]||(e[28]=[u("删除",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["modelValue"])}const Et=W(pn,[["render",Un],["__scopeId","data-v-c6850940"]]),zn={name:"FloatingICP"},Mn={"aria-label":"xICP备x号",class:"floating-icp-link",href:"https://beian.miit.gov.cn/",rel:"noopener noreferrer",target:"_blank",style:{display:"none"}};function $n(t,e,a,l,n,o){return c(),p("a",Mn," xICP备x号 ")}const Nt=W(zn,[["render",$n],["__scopeId","data-v-fa73670f"]]),Pn={name:"FloatingToolbar",props:{loading:{type:Boolean,default:!1},unreadCount:{type:Number,default:0},selectedDate:{type:[String,Date],required:!0},isToday:{type:Boolean,required:!0},copyToTodayLoading:{type:Boolean,default:!1}},data(){return{isExpanded:!1}},methods:{handleDateSelect(t){this.$emit("date-select",t)}}},Ln={class:"floating-toolbar-container"};function Fn(t,e,a,l,n,o){return c(),p("div",Ln,[s(Kt,null,{default:i(()=>[s(_,{class:fe([{"toolbar-expanded":n.isExpanded},"floating-toolbar"]),elevation:"4",rounded:"xl"},{default:i(()=>[s(Je,{class:"toolbar-buttons",variant:"text"},{default:i(()=>[oe(s(y,{title:"查看昨天",class:"toolbar-btn",icon:"mdi-chevron-left",variant:"text",onClick:e[0]||(e[0]=d=>t.$emit("prev-day"))},null,512),[[xe]]),oe(s(y,{title:"缩小字体",class:"toolbar-btn",icon:"mdi-format-font-size-decrease",variant:"text",onClick:e[1]||(e[1]=d=>t.$emit("zoom","out"))},null,512),[[xe]]),oe(s(y,{title:"放大字体",class:"toolbar-btn",icon:"mdi-format-font-size-increase",variant:"text",onClick:e[2]||(e[2]=d=>t.$emit("zoom","up"))},null,512),[[xe]]),s(cs,{"close-on-content-click":!1,location:"top"},{activator:i(({props:d})=>[oe(s(y,Qe({title:"选择日期",class:"toolbar-btn",icon:"mdi-calendar"},d,{variant:"text"}),null,16),[[xe]])]),default:i(()=>[s(_,{border:"",class:"date-picker-card"},{default:i(()=>[s(jt,{"model-value":a.selectedDate,color:"primary","onUpdate:modelValue":o.handleDateSelect},null,8,["model-value","onUpdate:modelValue"])]),_:1})]),_:1}),oe(s(y,{loading:a.loading,title:"刷新数据",class:"toolbar-btn",icon:"mdi-refresh",variant:"text",onClick:e[3]||(e[3]=d=>t.$emit("refresh"))},null,8,["loading"]),[[xe]]),a.isToday?w("",!0):oe((c(),b(y,{key:0,title:"查看明天",class:"toolbar-btn",icon:"mdi-chevron-right",variant:"text",onClick:e[4]||(e[4]=d=>t.$emit("next-day"))},null,512)),[[xe]])]),_:1})]),_:1},8,["class"])]),_:1}),s(qt,null,{default:i(()=>[a.isToday?w("",!0):(c(),b(y,{key:0,loading:a.copyToTodayLoading,disabled:a.copyToTodayLoading,class:"side-action-btn",color:"primary",elevation:"4","prepend-icon":"mdi-content-copy",rounded:"xl",size:"large",text:"复制作业内容到今天",onClick:e[5]||(e[5]=d=>t.$emit("copy-to-today"))},{default:i(()=>[...e[6]||(e[6]=[u("复制到今天",-1)])]),_:1},8,["loading","disabled"]))]),_:1})])}const Vt=W(Pn,[["render",Fn],["__scopeId","data-v-7076d3aa"]]),Rn={name:"AttendanceManagementDialog",props:{modelValue:{type:Boolean,required:!0},studentList:{type:Array,required:!0},attendance:{type:Object,required:!0},dateString:{type:String,default:""}},emits:["update:modelValue","save","change"],setup(){const{mobile:t}=Ae();return{mobile:t}},data(){return{attendanceSearch:"",attendanceFilter:[]}},computed:{isMobile(){return S("display.forceDesktopMode")?!1:this.mobile},filteredStudents(){let t=[...this.studentList];if(this.attendanceSearch){const e=this.attendanceSearch.toLowerCase();t=t.filter(a=>a.toLowerCase().includes(e))}return this.attendanceFilter&&this.attendanceFilter.length>0&&(t=t.filter(e=>!!(this.attendanceFilter.includes("present")&&this.isPresent(e)||this.attendanceFilter.includes("absent")&&this.isAbsent(e)||this.attendanceFilter.includes("late")&&this.isLate(e)||this.attendanceFilter.includes("exclude")&&this.isExclude(e)))),t},extractedSurnames(){if(!this.studentList||this.studentList.length===0)return[];const t=new Map;return this.studentList.forEach(e=>{if(e&&e.length>0){const a=e.charAt(0);t.set(a,(t.get(a)||0)+1)}}),Array.from(t.entries()).map(([e,a])=>({name:e,count:a})).sort((e,a)=>{const l=ot(e.name,{toneType:"none"}),n=ot(a.name,{toneType:"none"});return l.localeCompare(n)})}},methods:{toggleFilter(t){const e=this.attendanceFilter.indexOf(t);e===-1?this.attendanceFilter.push(t):this.attendanceFilter.splice(e,1)},isPresent(t){const{absent:e,late:a,exclude:l}=this.attendance;return!e.includes(t)&&!a.includes(t)&&!l.includes(t)},isAbsent(t){return this.attendance.absent.includes(t)},isLate(t){return this.attendance.late.includes(t)},isExclude(t){return this.attendance.exclude.includes(t)},getStudentStatusColor(t){return this.attendance.absent.includes(t)?"error":this.attendance.late.includes(t)?"warning":this.attendance.exclude.includes(t)?"grey":"success"},getStudentStatusIcon(t){return this.attendance.absent.includes(t)?"mdi-account-off":this.attendance.late.includes(t)?"mdi-clock-alert":this.attendance.exclude.includes(t)?"mdi-account-cancel":"mdi-account-check"},removeFromAll(t){const e=this.attendance.absent.indexOf(t);e>-1&&this.attendance.absent.splice(e,1);const a=this.attendance.late.indexOf(t);a>-1&&this.attendance.late.splice(a,1);const l=this.attendance.exclude.indexOf(t);l>-1&&this.attendance.exclude.splice(l,1)},setPresent(t){this.removeFromAll(t),this.$emit("change")},setAbsent(t){this.removeFromAll(t),this.attendance.absent.push(t),this.$emit("change")},setLate(t){this.removeFromAll(t),this.attendance.late.push(t),this.$emit("change")},setExclude(t){this.removeFromAll(t),this.attendance.exclude.push(t),this.$emit("change")},setAllPresent(){this.attendance.absent.splice(0,this.attendance.absent.length),this.attendance.late.splice(0,this.attendance.late.length),this.attendance.exclude.splice(0,this.attendance.exclude.length),this.$emit("change")},setAllAbsent(){this.setAllPresent(),this.attendance.absent.push(...this.studentList),this.$emit("change")},setAllLate(){this.setAllPresent(),this.attendance.late.push(...this.studentList),this.$emit("change")},setAllExclude(){this.setAllPresent(),this.attendance.exclude.push(...this.studentList),this.$emit("change")}}},On={class:"d-flex flex-wrap mt-2 gap-1"},Bn={class:"d-flex flex-wrap mb-4 gap-2"},jn={class:"flex-grow-1"},Hn={class:"d-flex align-center"},Kn={class:"text-subtitle-1"},qn={class:"attendance-actions"},Wn={class:"d-flex flex-wrap gap-2"};function Gn(t,e,a,l,n,o){return c(),b(J,{"model-value":a.modelValue,fullscreen:o.isMobile,"fullscreen-breakpoint":"sm","max-width":"900","onUpdate:modelValue":e[7]||(e[7]=d=>t.$emit("update:modelValue",d))},{default:i(()=>[s(_,null,{default:i(()=>[s(j,{class:"d-flex align-center"},{default:i(()=>[s(D,{class:"mr-2",icon:"mdi-account-group"}),e[8]||(e[8]=u(" 考勤 ",-1)),s(L),o.isMobile?w("",!0):(c(),b(O,{key:0,class:"ml-2",color:"primary",size:"small"},{default:i(()=>[u(g(a.dateString),1)]),_:1})),o.isMobile?(c(),b(y,{key:1,icon:"mdi-close",variant:"text",onClick:e[0]||(e[0]=d=>t.$emit("update:modelValue",!1))})):w("",!0)]),_:1}),s(V,null,{default:i(()=>[s(ue,{class:"mb-4"},{default:i(()=>[s(ne,{cols:"12",md:"12"},{default:i(()=>[s(Ce,{modelValue:n.attendanceSearch,"onUpdate:modelValue":e[1]||(e[1]=d=>n.attendanceSearch=d),clearable:"",hint:"支持筛选姓氏,如输入'孙'可筛选所有姓孙的学生",label:"搜索学生","prepend-inner-icon":"mdi-magnify",variant:"outlined"},null,8,["modelValue"]),r("div",On,[(c(!0),p(E,null,U(o.extractedSurnames,d=>(c(),b(y,{key:d.name,color:n.attendanceSearch===d.name?"primary":"",variant:n.attendanceSearch===d.name?"elevated":"text",onClick:m=>n.attendanceSearch=n.attendanceSearch===d.name?"":d.name},{default:i(()=>[u(g(d.name)+" ("+g(d.count)+") ",1)]),_:2},1032,["color","variant","onClick"]))),128))])]),_:1})]),_:1}),r("div",Bn,[r("div",null,[s(O,{"append-icon":n.attendanceFilter.includes("present")?"mdi-check":"",color:n.attendanceFilter.includes("present")?"success":"",variant:n.attendanceFilter.includes("present")?"elevated":"tonal",class:"px-2 filter-chip","prepend-icon":"mdi-account-check",value:"present",onClick:e[2]||(e[2]=d=>o.toggleFilter("present"))},{default:i(()=>[...e[9]||(e[9]=[u(" 到课 ",-1)])]),_:1},8,["append-icon","color","variant"]),s(O,{"append-icon":n.attendanceFilter.includes("absent")?"mdi-check":"",color:n.attendanceFilter.includes("absent")?"error":"",variant:n.attendanceFilter.includes("absent")?"elevated":"tonal",class:"px-2 filter-chip","prepend-icon":"mdi-account-off",value:"absent",onClick:e[3]||(e[3]=d=>o.toggleFilter("absent"))},{default:i(()=>[...e[10]||(e[10]=[u(" 请假 ",-1)])]),_:1},8,["append-icon","color","variant"]),s(O,{"append-icon":n.attendanceFilter.includes("late")?"mdi-check":"",color:n.attendanceFilter.includes("late")?"warning":"",variant:n.attendanceFilter.includes("late")?"elevated":"tonal",class:"px-2 filter-chip","prepend-icon":"mdi-clock-alert",value:"late",onClick:e[4]||(e[4]=d=>o.toggleFilter("late"))},{default:i(()=>[...e[11]||(e[11]=[u(" 迟到 ",-1)])]),_:1},8,["append-icon","color","variant"]),s(O,{"append-icon":n.attendanceFilter.includes("exclude")?"mdi-check":"",color:n.attendanceFilter.includes("exclude")?"grey":"",variant:n.attendanceFilter.includes("exclude")?"elevated":"tonal",class:"px-2 filter-chip","prepend-icon":"mdi-account-cancel",value:"exclude",onClick:e[5]||(e[5]=d=>o.toggleFilter("exclude"))},{default:i(()=>[...e[12]||(e[12]=[u(" 不参与 ",-1)])]),_:1},8,["append-icon","color","variant"])])]),s(ue,null,{default:i(()=>[(c(!0),p(E,null,U(o.filteredStudents,d=>(c(),b(ne,{key:d,cols:"12",lg:"4",md:"6",sm:"6"},{default:i(()=>[s(_,{border:"",class:"student-card"},{default:i(()=>[s(V,{class:"d-flex align-center pa-2"},{default:i(()=>[r("div",jn,[r("div",Hn,[s(Ie,{color:o.getStudentStatusColor(d),class:"mr-2",size:"24"},{default:i(()=>[s(D,{size:"small"},{default:i(()=>[u(g(o.getStudentStatusIcon(d)),1)]),_:2},1024)]),_:2},1032,["color"]),r("div",Kn,g(d),1)])]),r("div",qn,[s(y,{color:o.isPresent(d)?"success":"",title:"设为到课",icon:"mdi-account-check",size:o.isMobile?"default":"small",variant:"text",onClick:m=>o.setPresent(d)},null,8,["color","size","onClick"]),s(y,{color:o.isAbsent(d)?"error":"",title:"设为请假",icon:"mdi-account-off",size:o.isMobile?"default":"small",variant:"text",onClick:m=>o.setAbsent(d)},null,8,["color","size","onClick"]),s(y,{color:o.isLate(d)?"warning":"",title:"设为迟到",icon:"mdi-clock-alert",size:o.isMobile?"default":"small",variant:"text",onClick:m=>o.setLate(d)},null,8,["color","size","onClick"]),s(y,{color:o.isExclude(d)?"grey":"",title:"设为不参与",icon:"mdi-account-cancel",size:o.isMobile?"default":"small",variant:"text",onClick:m=>o.setExclude(d)},null,8,["color","size","onClick"])])]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1}),s(ue,null,{default:i(()=>[s(ne,{cols:"12",md:"12"},{default:i(()=>[s(_,{class:"mb-4",color:"primary",variant:"tonal"},{default:i(()=>[s(V,null,{default:i(()=>[e[17]||(e[17]=r("div",{class:"text-subtitle-2 mb-2"},"批量操作",-1)),r("div",Wn,[s(y,{class:"flex-grow-1",color:"success","prepend-icon":"mdi-account-check",onClick:o.setAllPresent},{default:i(()=>[...e[13]||(e[13]=[u(" 全部到齐 ",-1)])]),_:1},8,["onClick"]),s(y,{class:"flex-grow-1",color:"error","prepend-icon":"mdi-account-off",onClick:o.setAllAbsent},{default:i(()=>[...e[14]||(e[14]=[u(" 全部请假 ",-1)])]),_:1},8,["onClick"]),s(y,{class:"flex-grow-1",color:"warning","prepend-icon":"mdi-clock-alert",onClick:o.setAllLate},{default:i(()=>[...e[15]||(e[15]=[u(" 全部迟到 ",-1)])]),_:1},8,["onClick"]),s(y,{class:"flex-grow-1",color:"grey","prepend-icon":"mdi-account-cancel",onClick:o.setAllExclude},{default:i(()=>[...e[16]||(e[16]=[u(" 全部不参与 ",-1)])]),_:1},8,["onClick"])])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),s(ve),s(X,null,{default:i(()=>[s(L),s(y,{color:"primary",onClick:e[6]||(e[6]=d=>t.$emit("save"))},{default:i(()=>[s(D,{start:""},{default:i(()=>[...e[18]||(e[18]=[u("mdi-content-save",-1)])]),_:1}),e[19]||(e[19]=u(" 保存 ",-1))]),_:1})]),_:1})]),_:1})]),_:1},8,["model-value","fullscreen"])}const At=W(Rn,[["render",Gn],["__scopeId","data-v-e18ba4e5"]]),Qn={name:"HomeworkEditDialog",props:{modelValue:{type:Boolean,required:!0},title:{type:String,required:!0},initialContent:{type:String,default:""},autoSave:{type:Boolean,default:!1},isEditingPastData:{type:Boolean,default:!1},currentDateString:{type:String,default:""}},emits:["update:modelValue","save"],setup(){const{mobile:t}=Ae();return{mobile:t}},data(){return{content:"",templateData:null,currentLine:"",currentLineStart:0,currentLineEnd:0,quickTexts:["课","题","例","变","T","P"]}},computed:{isMobile(){return S("display.forceDesktopMode")?!1:this.mobile},dialogVisible:{get(){return this.modelValue},set(t){this.$emit("update:modelValue",t)}},subject(){return this.title},hasTemplates(){var t,e;return!!((e=(t=this.templateData)==null?void 0:t.actions)!=null&&e.length||this.subjectBooks||this.commonBooks)},subjectBooks(){var t,e,a;return!this.subject||!((a=(e=(t=this.templateData)==null?void 0:t.subjects)==null?void 0:e[this.subject])!=null&&a.books)?null:this.templateData.subjects[this.subject].books},commonBooks(){var t,e;return(e=(t=this.templateData)==null?void 0:t.commonSubject)!=null&&e.books?this.templateData.commonSubject.books:null},showQuickTools(){return S("display.showQuickTools")},autoSavePromptText(){return S("edit.autoSavePromptText")},manualSavePromptText(){return S("edit.manualSavePromptText")}},watch:{async modelValue(t){if(t){this.content=this.initialContent;try{this.templateData=await Z.loadData("classworks-config-homework-template")}catch(e){console.error("Failed to load homework templates:",e),this.templateData=null}this.$nextTick(()=>{this.$refs.inputRef&&(this.$refs.inputRef.focus(),this.updateCurrentLine())})}}},methods:{handleClose(){const t=this.content.trim();t!==this.initialContent.trim()&&this.$emit("save",t),this.dialogVisible=!1},updateCurrentLine(){const e=this.$refs.inputRef.$el.querySelector("textarea").selectionStart,a=this.content;let l=0;const n=a.split(`
`);for(let o=0;o<n.length;o++){const d=n[o].length,m=l+d;if(e<=m||o===n.length-1){this.currentLine=n[o],this.currentLineStart=l,this.currentLineEnd=m;break}l=m+1}this.currentLine||(this.currentLine="",this.currentLineStart=a.length,this.currentLineEnd=a.length)},isBookSelected(t){return this.currentLine.includes(t)},isPageSelected(t,e){return this.currentLine.includes(e)},handleBookClick(t){if(this.isBookSelected(t)){const e=this.content.split(`
`),a=e.findIndex(l=>l.includes(t));a!==-1&&(e.splice(a,1),this.content=e.join(`
`))}else{const e=this.content.trim().length>0;this.content=(e?this.content.trim()+`
`:"")+t}this.$nextTick(()=>{const e=this.$refs.inputRef.$el.querySelector("textarea");if(e.focus(),!this.isBookSelected(t)){const a=this.content.split(`
`);let l=0;for(let n=0;n<a.length;n++){if(a[n].includes(t)){l+=a[n].length;break}l+=a[n].length+1}e.setSelectionRange(l,l)}this.updateCurrentLine()})},handlePageClick(t,e){if(this.isPageSelected(t,e)){const a=this.currentLineStart,l=this.currentLineEnd,n=this.content.slice(a,l),o=n.lastIndexOf(e);if(o!==-1){const d=n.slice(0,o)+n.slice(o+e.length);this.content=this.content.slice(0,a)+d.trim()+this.content.slice(l)}}else{const a=this.currentLineStart,l=this.currentLineEnd,n=this.content.slice(a,l);this.content=this.content.slice(0,a)+n.trim()+(n.trim().length>0?" ":"")+e+this.content.slice(l)}this.$nextTick(()=>{const a=this.$refs.inputRef.$el.querySelector("textarea");a.focus();const l=this.content.split(`
`);let n=0;for(let o=0;o<l.length&&(n+=l[o].length,!(n>this.currentLineStart));o++)n+=1;a.setSelectionRange(n,n),this.updateCurrentLine()})},insertTemplate(t){const e=this.$refs.inputRef.$el.querySelector("textarea"),a=e.selectionStart,l=e.selectionEnd,n=a>0&&this.content[a-1]!==" "&&this.content[a-1]!==`
`;this.content=this.content.slice(0,a)+(n?" ":"")+t+this.content.slice(l),this.$nextTick(()=>{e.focus();const o=a+t.length+(n?1:0);e.setSelectionRange(o,o),this.updateCurrentLine()})},insertAtCursor(t){if(!t)return;const e=this.$refs.inputRef.$el.querySelector("textarea"),a=e.selectionStart,l=e.selectionEnd;this.content=this.content.slice(0,a)+t+this.content.slice(l),this.$nextTick(()=>{e.focus();const n=a+t.length;e.setSelectionRange(n,n),this.updateCurrentLine()})},deleteLastChar(){const t=this.$refs.inputRef.$el.querySelector("textarea"),e=t.selectionStart,a=t.selectionEnd;e===a?e>0&&(this.content=this.content.slice(0,e-1)+this.content.slice(e),this.$nextTick(()=>{t.focus(),t.setSelectionRange(e-1,e-1),this.updateCurrentLine()})):(this.content=this.content.slice(0,e)+this.content.slice(a),this.$nextTick(()=>{t.focus(),t.setSelectionRange(e,e),this.updateCurrentLine()}))}}},Jn={class:"d-flex"},Yn={class:"flex-grow-1"},Xn={key:0,class:"mt-4"},Zn={key:0,class:"template-buttons"},ei={key:0,class:"pages-container mt-2"},ti={key:0,class:"pages-container mt-2"},si={key:2,class:"button-group"},ni={key:1,class:"text-center text-body-2 text-disabled mt-2"},ii={key:0,class:"quick-tools ml-4",style:{"min-width":"180px"}},ai={class:"numeric-keypad mb-4"},oi={class:"keypad-row"},li={class:"keypad-row"},ri={class:"keypad-row"},di={class:"keypad-row"},ui={class:"keypad-row"},ci={class:"d-flex flex-wrap gap-1"},mi={class:"d-flex flex-column"},fi={class:"text-body-2"};function hi(t,e,a,l,n,o){return c(),b(J,{modelValue:o.dialogVisible,"onUpdate:modelValue":e[5]||(e[5]=d=>o.dialogVisible=d),fullscreen:o.isMobile,"max-width":"900",width:"auto","onClick:outside":o.handleClose},{default:i(()=>[s(_,{border:""},{default:i(()=>[s(j,{class:"d-flex align-center"},{default:i(()=>[u(g(a.title)+" ",1),s(L),s(y,{icon:"mdi-close",variant:"text",onClick:o.handleClose},null,8,["onClick"])]),_:1}),s(yt,null,{default:i(()=>[u(g(a.autoSave?o.autoSavePromptText:o.manualSavePromptText),1)]),_:1}),s(V,null,{default:i(()=>{var d;return[r("div",Jn,[r("div",Yn,[s(Ue,{ref:"inputRef",modelValue:n.content,"onUpdate:modelValue":e[0]||(e[0]=m=>n.content=m),"auto-grow":"",placeholder:"使用换行表示分条",rows:"5",width:o.isMobile?"100%":"480",onClick:o.updateCurrentLine,onKeyup:o.updateCurrentLine},null,8,["modelValue","width","onClick","onKeyup"]),n.templateData?(c(),p("div",Xn,[o.hasTemplates?(c(),p("div",Zn,[o.subjectBooks?(c(!0),p(E,{key:0},U(o.subjectBooks,(m,f)=>(c(),p("div",{key:f,class:"button-group"},[s(O,{color:o.isBookSelected(f)?"success":"default",variant:o.isBookSelected(f)?"elevated":"flat",class:"ma-1 book-chip",onClick:h=>o.handleBookClick(f)},{default:i(()=>[u(g(f),1)]),_:2},1032,["color","variant","onClick"]),o.isBookSelected(f)?(c(),p("div",ei,[(c(!0),p(E,null,U(m,h=>(c(),b(O,{key:h,color:o.isPageSelected(f,h)?"info":"default",variant:o.isPageSelected(f,h)?"elevated":"flat",class:"ma-1",onClick:k=>o.handlePageClick(f,h)},{default:i(()=>[u(g(h),1)]),_:2},1032,["color","variant","onClick"]))),128))])):w("",!0)]))),128)):w("",!0),o.commonBooks?(c(!0),p(E,{key:1},U(o.commonBooks,(m,f)=>(c(),p("div",{key:f,class:"button-group"},[s(O,{color:o.isBookSelected(f)?"success":"default",variant:o.isBookSelected(f)?"elevated":"flat",class:"ma-1 book-chip",onClick:h=>o.handleBookClick(f)},{default:i(()=>[u(g(f),1)]),_:2},1032,["color","variant","onClick"]),o.isBookSelected(f)?(c(),p("div",ti,[(c(!0),p(E,null,U(m,h=>(c(),b(O,{key:h,color:o.isPageSelected(f,h)?"info":"default",variant:o.isPageSelected(f,h)?"elevated":"flat",class:"ma-1",onClick:k=>o.handlePageClick(f,h)},{default:i(()=>[u(g(h),1)]),_:2},1032,["color","variant","onClick"]))),128))])):w("",!0)]))),128)):w("",!0),(d=n.templateData.actions)!=null&&d.length?(c(),p("div",si,[(c(!0),p(E,null,U(n.templateData.actions,m=>(c(),b(O,{key:m,class:"ma-1",color:"primary",variant:"flat",onClick:f=>o.insertTemplate(m)},{default:i(()=>[u(g(m),1)]),_:2},1032,["onClick"]))),128))])):w("",!0)])):(c(),p("div",ni," 暂无可用的模板 "))])):w("",!0)]),o.showQuickTools&&!o.isMobile?(c(),p("div",ii,[r("div",ai,[r("div",oi,[(c(),p(E,null,U(3,m=>s(y,{key:m,class:"keypad-btn",size:"small",variant:"tonal",onClick:f=>o.insertAtCursor(String(m))},{default:i(()=>[u(g(m),1)]),_:2},1032,["onClick"])),64))]),r("div",li,[(c(),p(E,null,U(3,m=>s(y,{key:m,class:"keypad-btn",size:"small",variant:"tonal",onClick:f=>o.insertAtCursor(String(m+3))},{default:i(()=>[u(g(m+3),1)]),_:2},1032,["onClick"])),64))]),r("div",ri,[(c(),p(E,null,U(3,m=>s(y,{key:m,class:"keypad-btn",size:"small",variant:"tonal",onClick:f=>o.insertAtCursor(String(m+6))},{default:i(()=>[u(g(m+6),1)]),_:2},1032,["onClick"])),64))]),r("div",di,[s(y,{class:"keypad-btn",size:"small",variant:"tonal",onClick:e[1]||(e[1]=m=>o.insertAtCursor("-"))},{default:i(()=>[...e[6]||(e[6]=[u(" - ",-1)])]),_:1}),s(y,{class:"keypad-btn",size:"small",variant:"tonal",onClick:e[2]||(e[2]=m=>o.insertAtCursor("0"))},{default:i(()=>[...e[7]||(e[7]=[u(" 0 ",-1)])]),_:1}),s(y,{class:"keypad-btn",color:"error",size:"small",variant:"tonal",onClick:o.deleteLastChar},{default:i(()=>[...e[8]||(e[8]=[u(" ← ",-1)])]),_:1},8,["onClick"])]),r("div",ui,[s(y,{class:"keypad-btn space-btn",size:"small",variant:"tonal",onClick:e[3]||(e[3]=m=>o.insertAtCursor(" "))},{default:i(()=>[...e[9]||(e[9]=[u(" 空格 ",-1)])]),_:1}),s(y,{class:"keypad-btn space-btn",size:"small",variant:"tonal",onClick:e[4]||(e[4]=m=>o.insertAtCursor(`
`))},{default:i(()=>[...e[10]||(e[10]=[u(" 换行 ",-1)])]),_:1})])]),r("div",ci,[(c(!0),p(E,null,U(n.quickTexts,m=>(c(),b(y,{key:m,size:"small",variant:"flat",onClick:f=>o.insertAtCursor(m)},{default:i(()=>[u(g(m),1)]),_:2},1032,["onClick"]))),128))])])):w("",!0)])]}),_:1}),a.isEditingPastData?(c(),b(_e,{key:0,type:"warning",variant:"tonal",class:"mx-4 mb-4",border:"start","border-color":"warning",prominent:""},{prepend:i(()=>[...e[11]||(e[11]=[])]),default:i(()=>[r("div",mi,[e[12]||(e[12]=r("div",{class:"text-h6 mb-1"},"你打算修改历史?",-1)),r("div",fi," 这是 "+g(new Date(a.currentDateString.slice(0,4),a.currentDateString.slice(4,6)-1,a.currentDateString.slice(6,8)).toLocaleDateString())+" 的作业 • 请谨慎操作,确保不会覆盖重要数据 ",1)])]),_:1})):w("",!0),e[13]||(e[13]=r("div",{class:"text-center text-body-2 text-disabled mb-5"}," 点击空白处完成编辑 ",-1))]),_:1})]),_:1},8,["modelValue","fullscreen","onClick:outside"])}const Ut=W(Qn,[["render",hi],["__scopeId","data-v-af72d8a9"]]),gi={name:"AttendanceSidebar",props:{studentList:{type:Array,required:!0},attendance:{type:Object,required:!0},isEditingDisabled:{type:Boolean,default:!1}},emits:["click","disabled-click"],setup(){return{display:Ae()}},methods:{getSetting:S,handleClick(){this.isEditingDisabled?this.$emit("disabled-click"):this.$emit("click")}}},pi={style:{"white-space":"nowrap"}},vi={style:{"white-space":"nowrap"}},yi={style:{"white-space":"nowrap"}},ki={key:0},bi={style:{"white-space":"nowrap"}},xi={style:{"white-space":"nowrap"}},wi={key:0},Si={style:{"white-space":"nowrap"}},Ci={style:{"white-space":"nowrap"}},_i={key:0},Di={style:{"white-space":"nowrap"}};function Ti(t,e,a,l,n,o){return a.studentList&&a.studentList.length?oe((c(),b(ne,{key:0,class:fe([{"cursor-not-allowed":a.isEditingDisabled},"attendance-area no-select"]),cols:"1",onClick:o.handleClick},{default:i(()=>[e[10]||(e[10]=r("h1",null,"出勤",-1)),r("h2",null,[e[0]||(e[0]=r("span",{style:{"white-space":"nowrap"}}," 应到",-1)),e[1]||(e[1]=u(" : ",-1)),r("span",pi,g(a.studentList.length-a.attendance.exclude.length)+"人 ",1)]),r("h2",null,[e[2]||(e[2]=r("span",{style:{"white-space":"nowrap"}}," 实到",-1)),e[3]||(e[3]=u(" : ",-1)),r("span",vi,g(a.studentList.length-a.attendance.absent.length-!o.getSetting("display.lateStudentsArePresent")*a.attendance.late.length-a.attendance.exclude.length)+"人 ",1)]),r("h2",null,[e[4]||(e[4]=r("span",{style:{"white-space":"nowrap"}}," 请假",-1)),e[5]||(e[5]=u(" : ",-1)),r("span",yi,g(a.attendance.absent.length)+"人 ",1)]),(c(!0),p(E,null,U(a.attendance.absent,(d,m)=>(c(),p("h3",{key:"absent-"+m,class:"gray-text"},[l.display.lgAndUp.value?(c(),p("span",ki,g(`${m+1}. `),1)):w("",!0),r("span",bi,g(d),1)]))),128)),r("h2",null,[e[6]||(e[6]=r("span",{style:{"white-space":"nowrap"}},"迟到",-1)),e[7]||(e[7]=u(" : ",-1)),r("span",xi,g(a.attendance.late.length)+"人 ",1)]),(c(!0),p(E,null,U(a.attendance.late,(d,m)=>(c(),p("h3",{key:"late-"+m,class:"gray-text"},[l.display.lgAndUp.value?(c(),p("span",wi,g(`${m+1}. `),1)):w("",!0),r("span",Si,g(d),1)]))),128)),r("h2",null,[e[8]||(e[8]=r("span",{style:{"white-space":"nowrap"}},"不参与",-1)),e[9]||(e[9]=u(" : ",-1)),r("span",Ci,g(a.attendance.exclude.length)+"人 ",1)]),(c(!0),p(E,null,U(a.attendance.exclude,(d,m)=>(c(),p("h3",{key:"exclude-"+m,class:"gray-text"},[l.display.lgAndUp.value?(c(),p("span",_i,g(`${m+1}. `),1)):w("",!0),r("span",Di,g(d),1)]))),128))]),_:1},8,["class","onClick"])),[[xe,a.isEditingDisabled?!1:{class:`text-${["primary","secondary","info","success","warning","error"][Math.floor(Math.random()*6)]}`}]]):w("",!0)}const zt=W(gi,[["render",Ti],["__scopeId","data-v-5a7eaf6a"]]),Ii={class:"d-flex flex-no-wrap justify-space-between"},Ei={class:"pe-4"},Ni={class:"mb-3"},Mt={__name:"PwaInstallCard",setup(t){const e=$(!1),a=$(!1),l=$(!1),n=st({title:"",message:"",links:[]}),o={pending:"待授权",granted:"已完成",denied:"已拒绝",unavailable:"不可用"},d={pending:"mdi-progress-clock",granted:"mdi-check-circle",denied:"mdi-close-circle",unavailable:"mdi-help-circle"},m={pending:"primary",granted:"success",denied:"error",unavailable:"surface-variant"},f=st({pwa:{label:"安装应用",description:"将网站安装为独立应用,便于快速启动",status:"pending"},notification:{label:"通知权限",description:"允许接收作业、考试等通知提醒",status:"pending"},storage:{label:"离线存储",description:"启用持久化存储以获得更稳健的离线体验",status:"pending"}}),h=G(()=>[{key:"pwa",...f.pwa},{key:"notification",...f.notification},{key:"storage",...f.storage}]),k=G(()=>h.value.some(x=>x.status==="pending")),I={pwa:[{text:"MDN - 安装 PWA 指南",desc:"检查浏览器是否支持并手动触发安装",href:"https://developer.mozilla.org/zh-CN/docs/Web/Progressive_web_apps/Guides/Installing"},{text:"Microsoft Edge - PWA 体验",desc:"Edge 浏览器安装与 UX 说明",href:"https://learn.microsoft.com/zh-cn/microsoft-edge/progressive-web-apps/ux"}],notification:[{text:"MDN - 通知权限与用法",desc:"浏览器通知权限的工作方式与调试",href:"https://developer.mozilla.org/zh-CN/docs/Web/API/notification"}],storage:[{text:"MDN - Storage 持久化说明",desc:"了解持久化存储的可用性与申请方式",href:"https://developer.mozilla.org/zh-CN/docs/Web/API/StorageManager/persist"}]};let F;const H=async()=>{var de;if(S("pwa.hideInstallCard")){e.value=!1;return}if(window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone===!0?f.pwa.status="granted":(window.deferredPwaPrompt,f.pwa.status="pending"),typeof Notification>"u")f.notification.status="unavailable";else{const le=Notification.permission;f.notification.status=le==="granted"?"granted":le==="denied"?"denied":"pending"}if((de=navigator.storage)!=null&&de.persisted){const le=await navigator.storage.persisted();f.storage.status=le?"granted":"pending"}else f.storage.status="unavailable";const R=h.value.some(le=>le.status!=="granted");e.value=R},N=async()=>{const x=window.deferredPwaPrompt;if(!x){f.pwa.status="pending",te("pwa","浏览器没有提供安装提示,可按文档手动安装。");return}x.prompt();const{outcome:A}=await x.userChoice;f.pwa.status=A==="accepted"?"granted":"denied",A!=="accepted"&&te("pwa","如果未出现安装弹窗,或被拒绝,请按说明手动安装。"),window.deferredPwaPrompt=null},K=async()=>{if(typeof Notification>"u"){f.notification.status="unavailable",te("notification","当前环境不支持通知 API可查看说明手动开启或更换浏览器。");return}const x=await Gt();f.notification.status=x?"granted":"denied",x||te("notification","通知请求未被授予,请按说明检查浏览器或系统设置。")},Q=async()=>{var A;if(!((A=navigator.storage)!=null&&A.persist)){f.storage.status="unavailable",te("storage","当前浏览器不支持持久化存储,可查看说明或更换浏览器。");return}const x=await Qt();f.storage.status=x?"granted":"denied",x||te("storage","未能启用持久化存储,可按说明检查浏览器或系统设置。")},ge=async()=>{if(!(!k.value||a.value)){a.value=!0;try{await N(),await K(),await Q()}finally{a.value=!1,await H()}}},pe=async x=>{if(!a.value){a.value=!0;try{x==="pwa"?await N():x==="notification"?await K():x==="storage"&&await Q()}finally{a.value=!1,await H()}}},te=(x,A="")=>{x==="pwa"?n.title="如何安装为应用":x==="notification"?n.title="如何开启通知":n.title="如何启用离线存储",n.message=A||"查看以下步骤获取更多说明。",n.links=I[x]||[],l.value=!0},se=()=>{re("pwa.hideInstallCard",!0),e.value=!1},C=()=>{f.pwa.status!=="granted"&&(f.pwa.status="pending"),H()},z=()=>{H()};return Ye(()=>{H(),window.addEventListener("pwa-prompt-ready",C),F=window.matchMedia("(display-mode: standalone)"),F.addEventListener("change",z)}),Wt(()=>{window.removeEventListener("pwa-prompt-ready",C),F&&F.removeEventListener("change",z)}),(x,A)=>e.value?(c(),b(_,{key:0,class:"mb-4",color:"surface-variant",variant:"tonal"},{default:i(()=>[r("div",Ii,[r("div",Ei,[s(j,{class:"text-h6"},{default:i(()=>[...A[2]||(A[2]=[u(" 安装应用与授权 ",-1)])]),_:1}),s(yt,{class:"pb-1"},{default:i(()=>[...A[3]||(A[3]=[u(" 手动点选下方项目请求安装和权限,也可以直接关闭 ",-1)])]),_:1}),s(V,{class:"pt-0 pb-1"},{default:i(()=>[s(we,{density:"comfortable",lines:"two"},{default:i(()=>[(c(!0),p(E,null,U(h.value,R=>(c(),b(Se,{key:R.key,disabled:a.value,onClick:()=>pe(R.key)},{prepend:i(()=>[s(Ie,{color:m[R.status],size:"32",variant:"tonal"},{default:i(()=>[s(D,{icon:d[R.status]},null,8,["icon"])]),_:2},1032,["color"])]),append:i(()=>[s(O,{color:m[R.status],size:"small",variant:"tonal",class:"me-2"},{default:i(()=>[u(g(o[R.status]),1)]),_:2},1032,["color"]),s(y,{variant:"text",icon:"mdi-information",size:"small",disabled:a.value,onClick:qe(()=>te(R.key),["stop"])},null,8,["disabled","onClick"])]),default:i(()=>[s($e,null,{default:i(()=>[u(g(R.label),1)]),_:2},1024),s(Pe,null,{default:i(()=>[u(g(R.description),1)]),_:2},1024)]),_:2},1032,["disabled","onClick"]))),128))]),_:1})]),_:1}),s(X,null,{default:i(()=>[s(y,{class:"ms-2",variant:"outlined",size:"small",onClick:se},{default:i(()=>[...A[4]||(A[4]=[u(" 关闭 ",-1)])]),_:1}),s(y,{class:"ms-2",variant:"elevated",color:"primary",size:"small","prepend-icon":a.value?"mdi-timer-sand":"mdi-shield-check",disabled:!k.value||a.value,onClick:ge},{default:i(()=>[u(g(a.value?"处理中":"一次处理全部"),1)]),_:1},8,["prepend-icon","disabled"])]),_:1})]),s(Ie,{class:"ma-3",size:"100",rounded:"0"},{default:i(()=>[s(D,{icon:"mdi-monitor-cellphone",size:"80"})]),_:1})]),s(J,{modelValue:l.value,"onUpdate:modelValue":A[1]||(A[1]=R=>l.value=R),"max-width":"520"},{default:i(()=>[s(_,null,{default:i(()=>[s(j,{class:"text-h6"},{default:i(()=>[u(g(n.title),1)]),_:1}),s(V,null,{default:i(()=>[r("p",Ni,g(n.message),1),s(we,{density:"comfortable"},{default:i(()=>[(c(!0),p(E,null,U(n.links,(R,de)=>(c(),b(Se,{key:de,href:R.href,target:"_blank",rel:"noopener"},{default:i(()=>[s($e,null,{default:i(()=>[u(g(R.text),1)]),_:2},1024),s(Pe,null,{default:i(()=>[u(g(R.desc),1)]),_:2},1024)]),_:2},1032,["href"]))),128))]),_:1})]),_:1}),s(X,null,{default:i(()=>[s(L),s(y,{variant:"text",onClick:A[0]||(A[0]=R=>l.value=!1)},{default:i(()=>[...A[5]||(A[5]=[u("我知道了",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})):w("",!0)}},Vi={name:"HomeActions",props:{synced:Boolean,loadingUpload:Boolean,showRandomPickerButton:Boolean,showExamScheduleButton:Boolean,showListCardButton:Boolean,showFullscreenButton:Boolean,isFullscreen:Boolean,showAntiScreenBurnCard:Boolean,showTestCardButton:Boolean},emits:["upload","show-sync-message","open-random-picker","toggle-fullscreen","add-test-card"]},Ai={class:"d-flex flex-wrap align-center mt-4"};function Ui(t,e,a,l,n,o){return c(),p(E,null,[r("div",Ai,[a.synced?(c(),b(y,{key:1,color:"success",size:"large",onClick:e[1]||(e[1]=d=>t.$emit("show-sync-message"))},{default:i(()=>[...e[9]||(e[9]=[u(" 同步完成 ",-1)])]),_:1})):(c(),b(y,{key:0,loading:a.loadingUpload,class:"ml-2",color:"error",size:"large",onClick:e[0]||(e[0]=d=>t.$emit("upload"))},{default:i(()=>[...e[8]||(e[8]=[u(" 上传 ",-1)])]),_:1},8,["loading"])),a.showRandomPickerButton?(c(),b(y,{key:2,"append-icon":"mdi-dice-multiple",class:"ml-2",color:"amber","prepend-icon":"mdi-account-question",size:"large",onClick:e[2]||(e[2]=d=>t.$emit("open-random-picker"))},{default:i(()=>[...e[10]||(e[10]=[u(" 随机点名 ",-1)])]),_:1})):w("",!0),a.showExamScheduleButton?(c(),b(Je,{key:3,class:"ml-2",color:"green",variant:"elevated",divided:""},{default:i(()=>[s(y,{"prepend-icon":"mdi-calendar-check",size:"large",onClick:e[3]||(e[3]=d=>t.$router.push("/examschedule"))},{default:i(()=>[...e[11]||(e[11]=[u(" 考试看板 ",-1)])]),_:1}),s(y,{icon:"mdi-plus",size:"large",onClick:e[4]||(e[4]=d=>t.$emit("add-exam-card"))})]),_:1})):w("",!0),a.showListCardButton?(c(),b(y,{key:4,class:"ml-2",color:"primary-darken-1","prepend-icon":"mdi-list-box",size:"large",onClick:e[5]||(e[5]=d=>t.$router.push("/list"))},{default:i(()=>[...e[12]||(e[12]=[u(" 列表 ",-1)])]),_:1})):w("",!0),a.showFullscreenButton?(c(),b(y,{key:5,color:a.isFullscreen?"blue-grey":"blue","prepend-icon":a.isFullscreen?"mdi-fullscreen-exit":"mdi-fullscreen",class:"ml-2",size:"large",onClick:e[6]||(e[6]=d=>t.$emit("toggle-fullscreen"))},{default:i(()=>[u(g(a.isFullscreen?"退出全屏":"全屏显示"),1)]),_:1},8,["color","prepend-icon"])):w("",!0),a.showTestCardButton?(c(),b(y,{key:6,class:"ml-2",color:"purple","prepend-icon":"mdi-test-tube",size:"large",onClick:e[7]||(e[7]=d=>t.$emit("add-test-card"))},{default:i(()=>[...e[13]||(e[13]=[u(" 添加测试卡片 ",-1)])]),_:1})):w("",!0)]),a.showAntiScreenBurnCard?(c(),b(_,{key:0,border:"",class:"mt-4 anti-burn-card",color:"primary",variant:"tonal"},{default:i(()=>[s(j,{class:"text-subtitle-1"},{default:i(()=>[s(D,{icon:"mdi-shield-check",size:"small",start:""}),e[14]||(e[14]=u(" 屏幕保护技术已启用 ",-1))]),_:1}),s(V,{class:"text-body-2"},{default:i(()=>[...e[15]||(e[15]=[r("p",null," 为防止OLED/LCD屏幕烧屏界面元素会定期微调位置。 ",-1),r("p",{class:"text-caption text-grey"}," 此功能不会影响正常使用,仅在长时间静止显示时生效。 ",-1),r("p",{class:"text-caption text-grey"}," 建议在放学后关闭显示器以节约能源。 ",-1)])]),_:1})]),_:1})):w("",!0)],64)}const $t=W(Vi,[["render",Ui]]),zi={name:"RelativeTimeDisplay",props:{time:{type:[String,Date,Number],required:!0}},computed:{displayTime(){if(!this.time)return"";const t=new Date(this.time),e=new Date,a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=new Date(e.getFullYear(),e.getMonth(),e.getDate()),n=a.getTime()-l.getTime(),o=Math.round(n/(1e3*60*60*24));if(o===0)return"今天";if(o===1)return"明天";if(o===2)return"后天";if(o===-1)return"昨天";if(o===-2)return"前天";const d=l.getDay()||7,m=new Date(l);m.setDate(l.getDate()-d+1);const f=new Date(l);if(f.setDate(l.getDate()+(7-d)),a>=m&&a<=f)return["周日","周一","周二","周三","周四","周五","周六"][t.getDay()];const h=t.getMonth()+1,k=t.getDate();return`${h}${k}`}}};function Mi(t,e,a,l,n,o){return c(),p("span",null,g(o.displayTime),1)}const Pt=W(zi,[["render",Mi]]),ze=Jt("exam",{state:()=>({examList:[],exams:{},loadingList:!1,loadingDetails:{}}),actions:{async fetchExamList(){if(!this.loadingList){this.loadingList=!0;try{const t=await Z.loadData("es_list");Array.isArray(t)?this.examList=t:this.examList=[]}catch(t){console.error("Failed to load exam list:",t)}finally{this.loadingList=!1}}},async fetchExam(t){if(this.exams[t])return this.exams[t];if(!this.loadingDetails[t]){this.loadingDetails[t]=!0;try{const e=await Z.loadData(`es_${t}`);return e&&(this.exams[t]=e),e}catch(e){console.error(`Failed to load exam details for ${t}:`,e)}finally{this.loadingDetails[t]=!1}}},async getUpcomingExams(t=25){await this.fetchExamList();const e=[],a=new Date,l=new Date(a.getTime()+2*24*60*60*1e3),n=this.examList.slice(0,t);for(const o of n){let d=this.exams[o.id];d||(d=await this.fetchExam(o.id)),d&&d.examInfos&&Array.isArray(d.examInfos)&&d.examInfos.some(f=>{const h=new Date(f.start);return h>=a&&h<=l})&&e.push({id:o.id,...d})}return e}}}),$i={name:"ConciseExamCard",components:{RelativeTimeDisplay:Pt},props:{examId:{type:String,required:!0},contentStyle:{type:Object,default:()=>({})},readonly:{type:Boolean,default:!1}},computed:{...bt(ze,["exams","loadingDetails"]),exam(){return this.exams[this.examId]},loading(){return this.loadingDetails[this.examId]},groupedExamInfos(){if(!this.exam||!this.exam.examInfos)return[];const t=[...this.exam.examInfos].sort((l,n)=>new Date(l.start)-new Date(n.start)),e=[];let a=null;return t.forEach(l=>{const o=new Date(l.start).toDateString();(!a||a.key!==o)&&(a={key:o,date:l.start,infos:[]},e.push(a)),a.infos.push(l)}),e}},mounted(){this.fetchExam(this.examId)},methods:{...kt(ze,["fetchExam"]),formatTimeOnly(t){if(!t)return"";try{const e=new Date(t),a=e.getHours().toString().padStart(2,"0"),l=e.getMinutes().toString().padStart(2,"0");return`${a}:${l}`}catch{return""}},isPast(t){return t?new Date(t)<new Date:!1}}},Pi={class:"text-truncate"},Li={key:0,class:"d-flex justify-center align-center py-4"},Fi={key:1,class:"d-flex flex-column"},Ri={class:"text-subtitle-2 font-weight-bold text-primary mb-1"},Oi={class:"font-weight-bold mr-2",style:{"font-size":"1.1em"}},Bi={class:"font-weight-medium text-grey-darken-2",style:{"font-size":"0.85em"}},ji={key:2,class:"text-center text-caption text-grey py-2"};function Hi(t,e,a,l,n,o){const d=Pt;return c(),b(_,{border:"",class:"fill-height d-flex flex-column cursor-pointer hover-elevation",elevation:"0",onClick:e[0]||(e[0]=m=>t.$emit("click"))},{default:i(()=>[s(j,{class:"d-flex align-center py-2 px-3 bg-primary-lighten-5 text-subtitle-1 font-weight-bold"},{default:i(()=>{var m;return[r("span",Pi,g(((m=o.exam)==null?void 0:m.examName)||"加载中..."),1)]}),_:1}),s(V,{class:"flex-grow-1 pa-4 overflow-y-auto",style:he(a.contentStyle)},{default:i(()=>[o.loading?(c(),p("div",Li,[s(xt,{indeterminate:"",size:"24",color:"primary"})])):o.exam?(c(),p("div",Fi,[(c(!0),p(E,null,U(o.groupedExamInfos,(m,f)=>(c(),p("div",{key:f,class:"mb-3"},[r("div",Ri,[s(d,{time:m.date},null,8,["time"])]),(c(!0),p(E,null,U(m.infos,(h,k)=>(c(),p("div",{key:k,class:fe(["d-flex align-center justify-space-between py-1 border-b-sm",{"border-none":k===m.infos.length-1,"text-grey":o.isPast(h.end)}])},[r("div",Oi,g(h.name),1),r("div",Bi,g(o.formatTimeOnly(h.start))+" - "+g(o.formatTimeOnly(h.end)),1)],2))),128))]))),128))])):(c(),p("div",ji,"无法加载"))]),_:1},8,["style"])]),_:1})}const Lt=W($i,[["render",Hi],["__scopeId","data-v-33424f55"]]),Ki=["6IO4","5Lmz","6JCd6I6J","5rer","5aW4"],qi=Ki.map(t=>_t.decode(t)),ht=.75,Wi={name:"HitokotoCard",data(){return{enabled:!1,refreshInterval:60,kvConfig:{sources:["zhaoyu"],sensitiveWords:[]},sentence:"",author:"",origin:"",loading:!1,timer:null,unwatch:null,fontSize:28}},computed:{contentStyle(){return{"font-size":`${this.fontSize*ht}px`,"white-space":"pre-wrap","line-height":"1.6","text-align":"left"}},authorStyle(){return{"font-size":`${this.fontSize*ht*.6}px`,"text-align":"left"}}},async mounted(){this.loadLocalSettings(),await this.loadKvSettings(),this.fetchSentence(),this.startTimer(),this.unwatch=Xe(()=>{this.loadLocalSettings(),this.startTimer()})},beforeUnmount(){this.stopTimer(),this.unwatch&&this.unwatch()},methods:{loadLocalSettings(){this.enabled=Oe.getSetting("hitokoto.enabled"),this.refreshInterval=Oe.getSetting("hitokoto.refreshInterval"),this.fontSize=Oe.getSetting("font.size")},async loadKvSettings(){try{const t=await Z.loadData("sentence-info");let e=t;t&&t.data&&(e=t.data),e&&(this.kvConfig={sources:Array.isArray(e.sources)&&e.sources.length>0?e.sources:["zhaoyu"],sensitiveWords:e.sensitiveWords?e.sensitiveWords.split(/[,]/).map(a=>a.trim()).filter(a=>a):[],jinrishiciToken:e.jinrishiciToken})}catch(t){console.error("Failed to load sentence-info",t)}},startTimer(){this.timer&&clearInterval(this.timer),this.refreshInterval>0&&(this.timer=setInterval(this.fetchSentence,this.refreshInterval*1e3))},stopTimer(){this.timer&&clearInterval(this.timer)},async fetchSentence(){if(!this.loading){this.loading=!0;try{const t=this.kvConfig.sources,e=t[Math.floor(Math.random()*t.length)];let a=null,l="",n="",o="";if(e==="hitokoto")a=(await Be.get("https://v1.hitokoto.cn/")).data,l=a.hitokoto,n=a.from_who,o=a.from;else if(e==="zhaoyu"){const d=await Be.get("https://hub.saintic.com/openservice/sentence/all.json");d.data.success&&(a=d.data.data,l=a.sentence||a.content||a.name,n=a.author,o=a.name||a.origin)}else if(e==="jinrishici")if(this.kvConfig.jinrishiciToken){const d=await Be.get("https://v2.jinrishici.com/one.json?client=npm-sdk/1.0&X-User-Token="+encodeURIComponent(this.kvConfig.jinrishiciToken),{});d.data.status==="success"&&(a=d.data.data,l=a.content,n=a.origin.author,o=a.origin.title)}else return console.warn("Jinrishici token missing. Please enable it in settings to generate a token."),this.loading=!1,this.fetchSentence();if(l){if([...qi,...this.kvConfig.sensitiveWords].some(f=>f&&l.includes(f)))return this.loading=!1,this.fetchSentence();this.sentence=l,this.author=n||"",this.origin=o||"未知"}}catch(t){console.error("Failed to fetch sentence",t),this.sentence="获取失败",this.author="",this.origin=""}finally{this.loading=!1}}}}},Gi={key:0,class:"mr-2"},Qi={key:1};function Ji(t,e,a,l,n,o){return c(),b(_,{class:"hitokoto-card",elevation:"2",border:"",rounded:"xl",loading:n.loading,height:"100%",onClick:o.fetchSentence},{default:i(()=>[s(V,{class:"pa-6 d-flex flex-column justify-center",style:{height:"100%"}},{default:i(()=>[r("div",{class:"font-weight-medium mb-4 serif-font",style:he(o.contentStyle)},g(n.sentence),5),r("div",{class:"text-medium-emphasis serif-font",style:he(o.authorStyle)},[n.author?(c(),p("span",Gi,g(n.author),1)):w("",!0),n.origin?(c(),p("span",Qi,"《"+g(n.origin)+"》",1)):w("",!0)],4)]),_:1})]),_:1},8,["loading","onClick"])}const Ft=W(Wi,[["render",Ji],["__scopeId","data-v-de957b7d"]]),Yi={name:"HomeworkGrid",computed:{settings(){return settings}},components:{HitokotoCard:Ft,ConciseExamCard:Lt},props:{sortedItems:{type:Array,required:!0},unusedSubjects:{type:Array,required:!0},emptySubjectDisplay:{type:String,default:"button"},isMobile:{type:Boolean,default:!1},isEditingDisabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})},highlightedCards:{type:Object,default:()=>({})}},emits:["open-dialog","open-attendance","disabled-click"],data(){return{isReadOnlyToken:!1}},async mounted(){this.resizeObserver=new ResizeObserver(()=>{this.resizeAllGridItems()}),this.$refs.gridContainer&&this.resizeObserver.observe(this.$refs.gridContainer),this.$nextTick(()=>{this.resizeAllGridItems(),this.$refs.items&&this.$refs.items.forEach(t=>{t.firstElementChild&&this.resizeObserver.observe(t.firstElementChild)})}),await this.checkReadOnlyStatus()},updated(){this.$nextTick(()=>{this.resizeAllGridItems(),this.$refs.items&&this.$refs.items.forEach(t=>{t.firstElementChild&&this.resizeObserver.observe(t.firstElementChild)})})},beforeUnmount(){this.resizeObserver&&this.resizeObserver.disconnect()},methods:{getSetting:S,async checkReadOnlyStatus(){try{let t=null;if(this.$parent&&this.$parent.$refs&&this.$parent.$refs.studentNameManager?t=this.$parent.$refs.studentNameManager:this.$root&&this.$root.$refs&&this.$root.$refs.studentNameManager&&(t=this.$root.$refs.studentNameManager),t&&typeof t.isReadOnly<"u")this.isReadOnlyToken=t.isReadOnly;else{const{getSetting:e}=await nt(async()=>{const{getSetting:l}=await import("./index-Ck0Pnd4f.js").then(n=>n.cL);return{getSetting:l}},__vite__mapDeps([0,1]),import.meta.url),a=e("server.kvToken");if(a){const{default:l}=await nt(async()=>{const{default:o}=await import("./dataProvider-BZ0EQWiW.js").then(d=>d.e);return{default:o}},__vite__mapDeps([2,0,1,3]),import.meta.url),n=e("server.domain");if(n)try{const o=await l.get(`${n}/kv/_token`,{headers:{Authorization:`Bearer ${a}`}});o.data&&typeof o.data.isReadOnly<"u"&&(this.isReadOnlyToken=o.data.isReadOnly)}catch(o){console.error("获取Token信息失败:",o)}}}}catch(t){console.error("检查只读状态失败:",t)}},resizeGridItem(t){const e=this.$refs.gridContainer;if(!e)return;const a=parseInt(window.getComputedStyle(e).getPropertyValue("grid-auto-rows")),l=parseInt(window.getComputedStyle(e).getPropertyValue("gap")),n=t.firstElementChild;if(!n)return;const o=n.getBoundingClientRect().height,d=Math.ceil((o+l)/(a+l));t.style.gridRowEnd=`span ${d}`},resizeAllGridItems(){const t=this.$refs.items;t&&t.forEach(e=>this.resizeGridItem(e))},handleCardClick(t,e){if(this.isEditingDisabled){this.$emit("disabled-click");return}t==="attendance"?this.$emit("open-attendance"):t==="dialog"&&this.$emit("open-dialog",e)},splitPoint(t){return t.split(`
`).filter(e=>e.trim())},handleMouseMove(t){const e=t.currentTarget,a=e.getBoundingClientRect(),l=(t.clientX-a.left)/a.width*100,n=(t.clientY-a.top)/a.height*100;e.style.setProperty("--x",`${l}%`),e.style.setProperty("--y",`${n}%`)},handleTouchMove(t){if(t.touches.length===1){const e=t.touches[0],a=t.currentTarget,l=a.getBoundingClientRect(),n=(e.clientX-l.left)/l.width*100,o=(e.clientY-l.top)/l.height*100;a.style.setProperty("--x",`${n}%`),a.style.setProperty("--y",`${o}%`)}}}},Xi={ref:"gridContainer",class:"grid-masonry"},Zi=["data-key"],ea={key:0,style:{height:"100%"}},ta={key:1,style:{height:"100%"}},sa={class:"d-flex justify-space-between align-center mb-2"},na={class:"text-h6"},ia={key:0,class:"mb-2"},aa={class:"text-error text-caption mb-1"},oa={class:"d-flex flex-wrap",style:{gap:"4px"}},la={key:1,class:"mb-2"},ra={class:"text-warning text-caption mb-1"},da={class:"d-flex flex-wrap",style:{gap:"4px"}},ua={key:2,class:"mb-2"},ca={class:"text-grey text-caption mb-1"},ma={class:"d-flex flex-wrap",style:{gap:"4px"}},fa={key:3,class:"text-success text-center mt-2"},ha={class:"empty-subjects mt-4"},ga={key:0,class:"d-flex flex-wrap justify-center"},pa={key:2,class:"empty-subjects-grid"};function va(t,e,a,l,n,o){const d=Ft,m=Lt;return c(),p(E,null,[r("div",Xi,[s(Ke,{name:"grid"},{default:i(()=>[(c(!0),p(E,null,U(a.sortedItems,f=>(c(),p("div",{key:f.key,ref_for:!0,ref:"items","data-key":f.key,style:he({order:f.order}),class:"grid-item"},[f.type==="hitokoto"?(c(),p("div",ea,[s(d)])):f.type==="exam"?(c(),p("div",ta,[s(m,{"exam-id":f.data.examId,"content-style":a.contentStyle,onClick:h=>t.$emit("open-exam-detail",f.data.examId)},null,8,["exam-id","content-style","onClick"])])):f.type==="attendance"?(c(),b(_,{key:2,class:fe([{"glow-highlight":a.highlightedCards[f.key],"cursor-not-allowed":a.isEditingDisabled,"cursor-pointer":!a.isEditingDisabled},"glow-track"]),border:"",height:"100%",onClick:e[0]||(e[0]=h=>o.handleCardClick("attendance",null)),onMousemove:o.handleMouseMove,onTouchmove:o.handleTouchMove},{default:i(()=>[s(j,{class:"d-flex align-center"},{default:i(()=>[s(D,{class:"mr-2",color:"primary",icon:"mdi-account-group"}),e[1]||(e[1]=u(" 出勤统计 ",-1))]),_:1}),s(V,null,{default:i(()=>[r("div",sa,[e[2]||(e[2]=r("span",null,"应到/实到",-1)),r("span",na,g(f.data.total-f.data.exclude.length)+"/"+g(f.data.total-f.data.absent.length-!o.getSetting("display.lateStudentsArePresent")*f.data.late.length-f.data.exclude.length),1)]),s(ve,{class:"mb-2"}),f.data.absent.length>0?(c(),p("div",ia,[r("div",aa,"请假 ("+g(f.data.absent.length)+")",1),r("div",oa,[(c(!0),p(E,null,U(f.data.absent,h=>(c(),b(O,{key:h,color:"error",size:"x-small",variant:"flat"},{default:i(()=>[u(g(h),1)]),_:2},1024))),128))])])):w("",!0),f.data.late.length>0?(c(),p("div",la,[r("div",ra,"迟到 ("+g(f.data.late.length)+")",1),r("div",da,[(c(!0),p(E,null,U(f.data.late,h=>(c(),b(O,{key:h,color:"warning",size:"x-small",variant:"flat"},{default:i(()=>[u(g(h),1)]),_:2},1024))),128))])])):w("",!0),f.data.exclude.length>0?(c(),p("div",ua,[r("div",ca,"不参与 ("+g(f.data.exclude.length)+")",1),r("div",ma,[(c(!0),p(E,null,U(f.data.exclude,h=>(c(),b(O,{key:h,color:"grey",size:"x-small",variant:"flat"},{default:i(()=>[u(g(h),1)]),_:2},1024))),128))])])):w("",!0),f.data.absent.length===0&&f.data.late.length===0&&f.data.exclude.length===0?(c(),p("div",fa," 全勤 ")):w("",!0)]),_:2},1024)]),_:2},1032,["class","onMousemove","onTouchmove"])):f.type==="custom"?(c(),b(_,{key:3,class:fe([{"glow-highlight":a.highlightedCards[f.key],"cursor-not-allowed":a.isEditingDisabled,"cursor-pointer":!a.isEditingDisabled},"glow-track"]),border:"",height:"100%",onClick:h=>o.handleCardClick("dialog",f.key),onMousemove:o.handleMouseMove,onTouchmove:o.handleTouchMove},{default:i(()=>[s(j,{class:"text-primary"},{default:i(()=>[s(D,{class:"mr-2",icon:"mdi-card-text-outline",size:"small"}),u(" "+g(f.name),1)]),_:2},1024),s(V,{style:he(a.contentStyle)},{default:i(()=>[u(g(f.content),1)]),_:2},1032,["style"])]),_:2},1032,["class","onClick","onMousemove","onTouchmove"])):(c(),b(_,{key:4,class:fe([{"glow-highlight":a.highlightedCards[f.key],"cursor-not-allowed":a.isEditingDisabled,"cursor-pointer":!a.isEditingDisabled},"glow-track"]),border:"",height:"100%",onClick:h=>o.handleCardClick("dialog",f.key),onMousemove:o.handleMouseMove,onTouchmove:o.handleTouchMove},{default:i(()=>[s(j,null,{default:i(()=>[u(g(f.name),1)]),_:2},1024),s(V,{style:he(a.contentStyle)},{default:i(()=>[s(we,null,{default:i(()=>[(c(!0),p(E,null,U(o.splitPoint(f.content),h=>(c(),b(Se,{key:h},{default:i(()=>[u(g(h),1)]),_:2},1024))),128))]),_:2},1024)]),_:2},1032,["style"])]),_:2},1032,["class","onClick","onMousemove","onTouchmove"]))],12,Zi))),128))]),_:1})],512),r("div",ha,[a.isMobile?(c(),p("div",ga,[(c(!0),p(E,null,U(a.unusedSubjects,f=>(c(),b(O,{key:f.name,class:"ma-1",color:"primary",variant:"tonal",onClick:h=>o.handleCardClick("dialog",f.name)},{default:i(()=>[s(D,{start:"",size:"small"},{default:i(()=>[u(g(n.isReadOnlyToken?"mdi-cancel":"mdi-plus"),1)]),_:1}),u(" "+g(f.name),1)]),_:2},1032,["onClick"]))),128))])):a.emptySubjectDisplay==="button"?(c(),b(Je,{key:1,divided:"",variant:"tonal"},{default:i(()=>[(c(!0),p(E,null,U(a.unusedSubjects,f=>(c(),b(y,{key:f.name,onClick:h=>o.handleCardClick("dialog",f.name)},{default:i(()=>[s(D,{start:""},{default:i(()=>[u(g(n.isReadOnlyToken?"mdi-cancel":"mdi-plus"),1)]),_:1}),u(" "+g(f.name),1)]),_:2},1032,["onClick"]))),128))]),_:1})):(c(),p("div",pa,[s(Ke,{name:"v-list"},{default:i(()=>[(c(!0),p(E,null,U(a.unusedSubjects,f=>(c(),b(_,{key:f.name,border:"",class:"empty-subject-card",onClick:h=>o.handleCardClick("dialog",f.name)},{default:i(()=>[s(j,{class:"text-subtitle-1"},{default:i(()=>[u(g(f.name),1)]),_:2},1024),s(V,{class:"text-center"},{default:i(()=>[n.isReadOnlyToken?(c(),p(E,{key:0},[s(D,{color:"grey",size:"small"},{default:i(()=>[...e[3]||(e[3]=[u(" mdi-cancel ",-1)])]),_:1}),e[4]||(e[4]=r("div",{class:"text-caption text-grey"}," 当日无作业 ",-1))],64)):(c(),p(E,{key:1},[s(D,{color:"grey",size:"small"},{default:i(()=>[...e[5]||(e[5]=[u(" mdi-plus ",-1)])]),_:1}),e[6]||(e[6]=r("div",{class:"text-caption text-grey"}," 点击添加作业 ",-1))],64))]),_:1})]),_:2},1032,["onClick"]))),128))]),_:1})]))])],64)}const Rt=W(Yi,[["render",va],["__scopeId","data-v-97399635"]]),ya={key:0,class:"mt-2 text-caption text-medium-emphasis"},ka={class:"mt-2 mb-4"},ba={class:"d-flex flex-wrap gap-2"},xa={key:0,class:"ms-1 text-error"},wa={__name:"StudentNameManager",emits:["token-info-updated"],setup(t,{expose:e,emit:a}){const l=a,n=$(!1),o=$(""),d=$([]),m=$(""),f=$(!1),h=$(""),k=$(null),I=$([]),F=$(""),H=$(""),N=$({name:"",isHeadTeacher:!1,subjects:[]}),K=G(()=>{var T;return((T=k.value)==null?void 0:T.deviceType)==="student"}),Q=G(()=>{var T;return((T=k.value)==null?void 0:T.deviceType)==="teacher"}),ge=G(()=>{var T;return((T=k.value)==null?void 0:T.isReadOnly)===!0}),pe=G(()=>{var T;return((T=k.value)==null?void 0:T.note)||"设置名称"}),te=G(()=>!!se.value),se=G(()=>S("server.kvToken")),C=G(()=>S("server.provider")),z=G(()=>C.value==="kv-server"||C.value==="classworkscloud"),x=G(()=>K.value?"设置学生姓名":Q.value?"设置教师姓名":"设置姓名"),A=G(()=>I.value),R=async()=>{var T;if(!(!z.value||!se.value))try{const M=S("server.domain");if(!M)return;const B=await me.get(`${M}/kv/_token`,{headers:{Authorization:`Bearer ${se.value}`}});if(k.value=B.data,k.value.deviceType==="student"){m.value=k.value.note||"";const P=(await me.get(`${M}/kv/classworks-list-main`,{headers:{Authorization:`Bearer ${se.value}`}})).data.value||[];if(d.value=Array.isArray(P)?P:[],d.value.length>0){const q=k.value.note||"",ye=d.value.some(ke=>ke.name===q);(!q||!ye)&&(n.value=!0,o.value="")}return}if(k.value.deviceType==="teacher"){H.value=k.value.note||"";try{const P=(await me.get(`${M}/kv/classworks-list-teacher`,{headers:{Authorization:`Bearer ${se.value}`}})).data.value||[];I.value=Array.isArray(P)?P:[]}catch(Y){((T=Y==null?void 0:Y.response)==null?void 0:T.status)===404?(console.log("教师列表不存在,初始化为空"),I.value=[]):(console.error("加载教师列表失败:",Y),I.value=[])}if(I.value.length>0){const Y=k.value.note||"",P=I.value.some(q=>q.name===Y);(!Y||!P)&&(n.value=!0,F.value="")}return}}catch(M){console.error("检查学生姓名状态失败:",M)}},de=async()=>{var T,M,B,Y;if(!(!o.value||f.value)){h.value="",f.value=!0;try{const P=S("server.domain"),q=se.value;(await me.post(`${P}/apps/tokens/${q}/set-student-name`,{name:o.value})).data.success&&(m.value=o.value,n.value=!1,await R(),l("token-info-updated"))}catch(P){const q=(T=P==null?void 0:P.response)==null?void 0:T.status;q===400?h.value="该名称不在学生列表中,请选择正确的姓名":q===403?h.value="只有学生类型的 Token 可以设置姓名":q===404?h.value="设备未设置学生列表或 Token 不存在":h.value=((Y=(B=(M=P==null?void 0:P.response)==null?void 0:M.data)==null?void 0:B.error)==null?void 0:Y.message)||(P==null?void 0:P.message)||"设置失败,请稍后重试"}finally{f.value=!1}}},le=async()=>{var T,M,B,Y,P;if(!(!N.value.name||f.value)){h.value="",f.value=!0;try{const q=S("server.domain"),ye=se.value,ke={name:N.value.name.trim(),isHeadTeacher:!!N.value.isHeadTeacher,subjects:Array.isArray(N.value.subjects)?N.value.subjects.filter(Te=>Te&&String(Te).trim()).map(Te=>String(Te).trim()):[]},et=I.value.findIndex(Te=>Te.name===ke.name);et>=0?I.value[et]=ke:I.value.push(ke);const De=await Z.saveData("classworks-list-teacher",I.value);if((De==null?void 0:De.success)===!1)throw new Error(((T=De==null?void 0:De.error)==null?void 0:T.message)||"保存列表失败");(await me.post(`${q}/apps/tokens/${ye}/set-teacher-name`,{name:ke.name})).data.success&&(H.value=ke.name,n.value=!1,await R(),l("token-info-updated"))}catch(q){const ye=(M=q==null?void 0:q.response)==null?void 0:M.status;ye===400?h.value="该名称不在教师列表中,请选择正确的姓名":ye===403?h.value="只有教师类型的 Token 可以设置姓名":ye===404?h.value="设备未设置教师列表或 Token 不存在":h.value=((P=(Y=(B=q==null?void 0:q.response)==null?void 0:B.data)==null?void 0:Y.error)==null?void 0:P.message)||(q==null?void 0:q.message)||"设置失败,请稍后重试"}finally{f.value=!1}}},ie=T=>{N.value.name=T.name,N.value.isHeadTeacher=T.isHeadTeacher||!1,N.value.subjects=Array.isArray(T.subjects)?[...T.subjects]:[]},v=()=>{n.value=!1},ae=async()=>{if(console.log("StudentNameManager.openDialog called"),console.log("isStudentToken:",K.value),console.log("studentList.length:",d.value.length),console.log("currentStudentName:",m.value),K.value){const T=await Z.loadData("classworks-list-main");d.value=Array.isArray(T==null?void 0:T.value)?T.value:Array.isArray(T)?T:[],d.value.length===0?(console.log("Student list is empty, trying to load..."),await R(),o.value=m.value,n.value=!0):(o.value=m.value,n.value=!0);return}if(Q.value){try{const T=await Z.loadData("classworks-list-teacher");I.value=Array.isArray(T==null?void 0:T.value)?T.value:Array.isArray(T)?T:[]}catch{console.log("教师列表不存在或加载失败,允许手动创建"),I.value=[]}if(N.value={name:H.value,isHeadTeacher:!1,subjects:[]},H.value){const T=I.value.find(M=>M.name===H.value);T&&(N.value.isHeadTeacher=T.isHeadTeacher||!1,N.value.subjects=Array.isArray(T.subjects)?[...T.subjects]:[])}n.value=!0,console.log("Dialog opened (teacher), showDialog:",n.value);return}console.log("Not a student/teacher token, cannot open dialog")};return Le(se,()=>{R()}),Xe(()=>{R()}),Le(k,()=>{l("token-info-updated")},{deep:!0}),Ye(()=>{R()}),e({checkStudentNameStatus:R,openDialog:ae,currentStudentName:m,currentTeacherName:H,isStudentToken:K,isTeacherToken:Q,isReadOnly:ge,displayName:pe,hasToken:te,tokenInfo:k}),(T,M)=>(c(),p(E,null,[s(J,{modelValue:n.value,"onUpdate:modelValue":M[4]||(M[4]=B=>n.value=B),"max-width":"720",persistent:""},{default:i(()=>[s(_,null,{default:i(()=>[s(j,null,{default:i(()=>[u(g(x.value),1)]),_:1}),s(V,null,{default:i(()=>[K.value?(c(),p(E,{key:0},[M[5]||(M[5]=r("div",{class:"mb-2"}," 请从列表中选择您的姓名: ",-1)),s(Ht,{modelValue:o.value,"onUpdate:modelValue":M[0]||(M[0]=B=>o.value=B),items:d.value,clearable:"","hide-details":"","item-title":"name","item-value":"name",label:"学生姓名",placeholder:"选择您的姓名"},null,8,["modelValue","items"]),d.value.length>0?(c(),p("div",ya," 共 "+g(d.value.length)+" 位学生 ",1)):w("",!0)],64)):Q.value?(c(),p(E,{key:1},[s(Ce,{modelValue:N.value.name,"onUpdate:modelValue":M[1]||(M[1]=B=>N.value.name=B),label:"教师姓名",placeholder:"输入姓名或从下方建议中选择",clearable:""},null,8,["modelValue"]),r("div",ka,[r("div",ba,[(c(!0),p(E,null,U(A.value,B=>(c(),b(O,{key:B.name,size:"small",onClick:Y=>ie(B)},{default:i(()=>[u(g(B.name)+" ",1),B.isHeadTeacher?(c(),p("span",xa," 👨‍🏫 ")):w("",!0)]),_:2},1032,["onClick"]))),128))])]),s(Ge,{modelValue:N.value.isHeadTeacher,"onUpdate:modelValue":M[2]||(M[2]=B=>N.value.isHeadTeacher=B),inset:"",color:"primary",label:N.value.isHeadTeacher?"班主任":"非班主任"},null,8,["modelValue","label"]),s(is,{modelValue:N.value.subjects,"onUpdate:modelValue":M[3]||(M[3]=B=>N.value.subjects=B),multiple:"",chips:"",clearable:"",label:"任教科目",hint:"可直接输入并回车添加多个科目","persistent-hint":""},null,8,["modelValue"])],64)):w("",!0),h.value?(c(),b(_e,{key:2,class:"mt-3",type:"error",variant:"tonal"},{default:i(()=>[u(g(h.value),1)]),_:1})):w("",!0)]),_:1}),s(X,null,{default:i(()=>[s(y,{variant:"text",onClick:v},{default:i(()=>[...M[6]||(M[6]=[u(" 稍后设置 ",-1)])]),_:1}),s(L),K.value?(c(),b(y,{key:0,disabled:!o.value||f.value,loading:f.value,color:"primary",onClick:de},{default:i(()=>[...M[7]||(M[7]=[u(" 确认 ",-1)])]),_:1},8,["disabled","loading"])):Q.value?(c(),b(y,{key:1,disabled:!N.value.name||f.value,loading:f.value,color:"primary",onClick:le},{default:i(()=>[...M[8]||(M[8]=[u(" 确认 ",-1)])]),_:1},8,["disabled","loading"])):w("",!0)]),_:1})]),_:1})]),_:1},8,["modelValue"]),Yt(T.$slots,"header-display",{isStudent:K.value,openDialog:ae,studentName:m.value,teacherName:H.value},void 0)],64))}},Ot=W(wa,[["__scopeId","data-v-cebbe710"]]),Sa={class:"text-center mb-6"},Ca={class:"text-body-2"},_a={class:"form-section"},Da={__name:"DeviceAuthDialog",props:{showCancel:{type:Boolean,default:!1},preconfig:{type:Object,default:null}},emits:["success","cancel"],setup(t,{expose:e,emit:a}){const l=t,n=a,o=$({namespace:"",password:""}),d=$(!1),m=$("");Le(()=>l.preconfig,h=>{h&&(console.log("应用预配置数据:",h),o.value.namespace=h.namespace||"",o.value.password=h.password||"",h.autoExecute&&h.namespace?(console.log("检测到自动执行标志且有命名空间,自动执行认证"),setTimeout(()=>{f()},300)):h.namespace&&console.log("预配置数据已填入,等待手动认证"))},{immediate:!0,deep:!0});const f=async()=>{var h,k,I,F,H;if(!(!o.value.namespace||d.value)){m.value="",d.value=!0;try{const N=S("server.domain");if(!N)throw new Error("未配置服务器域名");const K=await me.post(`${N}/apps/auth/token`,{namespace:o.value.namespace,password:o.value.password||void 0,appId:"d158067f53627d2b98babe8bffd2fd7d"});if(!K.data.success)throw new Error("设备验证失败");const Q=K.data;re("server.kvToken",Q.token),(h=Q.device)!=null&&h.uuid&&re("device.uuid",Q.device.uuid),n("success",Q)}catch(N){const K=(k=N==null?void 0:N.response)==null?void 0:k.status;K===401||K===403?m.value="密码错误或无权限访问":K===404?m.value="设备不存在,请检查 namespace 是否正确":m.value=((H=(F=(I=N==null?void 0:N.response)==null?void 0:I.data)==null?void 0:F.error)==null?void 0:H.message)||(N==null?void 0:N.message)||"认证失败,请稍后重试"}finally{d.value=!1}}};return e({reset:()=>{o.value={namespace:"",password:""},m.value=""}}),(h,k)=>(c(),b(_,{class:"auth-card"},{default:i(()=>[s(V,{class:"pa-8"},{default:i(()=>[r("div",Sa,[s(D,{class:"mb-4",color:"success",size:"80"},{default:i(()=>[...k[4]||(k[4]=[u(" mdi-account-key ",-1)])]),_:1}),k[5]||(k[5]=r("h2",{class:"text-h4 mb-3"}," 设备认证 ",-1)),k[6]||(k[6]=r("p",{class:"text-body-1 text-medium-emphasis"}," 输入你在 Classworks KV 获取的认证信息 ",-1))]),s(_,{class:"pa-4 mb-6",color:"info",variant:"tonal"},{default:i(()=>[r("div",Ca,[s(D,{class:"mr-2",size:"20"},{default:i(()=>[...k[7]||(k[7]=[u(" mdi-information ",-1)])]),_:1}),k[8]||(k[8]=u(" 对于已有UUID的用户您应当使用UUID与您的密码登录。 ",-1))])]),_:1}),r("div",_a,[s(Ce,{modelValue:o.value.namespace,"onUpdate:modelValue":k[0]||(k[0]=I=>o.value.namespace=I),class:"mb-4","hide-details":"auto",label:"命名空间","prepend-inner-icon":"mdi-identifier",variant:"outlined"},null,8,["modelValue"]),s(Ce,{modelValue:o.value.password,"onUpdate:modelValue":k[1]||(k[1]=I=>o.value.password=I),label:"认证码","prepend-inner-icon":"mdi-lock-outline",type:"text",variant:"outlined"},null,8,["modelValue"]),m.value?(c(),b(_e,{key:0,class:"mt-4",closable:"",type:"error",variant:"tonal","onClick:close":k[2]||(k[2]=I=>m.value="")},{default:i(()=>[u(g(m.value),1)]),_:1})):w("",!0)])]),_:1}),s(X,{class:"pa-6 pt-0"},{default:i(()=>[t.showCancel?(c(),b(y,{key:0,size:"large",variant:"text",onClick:k[3]||(k[3]=I=>h.$emit("cancel"))},{default:i(()=>[...k[9]||(k[9]=[u(" 取消 ",-1)])]),_:1})):w("",!0),s(L),s(y,{disabled:!o.value.namespace||d.value,loading:d.value,class:"px-8",color:"primary",size:"x-large",variant:"elevated",onClick:f},{default:i(()=>[s(D,{size:"24",start:""},{default:i(()=>[...k[10]||(k[10]=[u(" mdi-login ",-1)])]),_:1}),k[11]||(k[11]=r("span",{class:"text-h6"},"认证并登录",-1))]),_:1},8,["disabled","loading"])]),_:1})]),_:1}))}},Ta=W(Da,[["__scopeId","data-v-9e8d02e4"]]),Ia={__name:"TokenInputDialog",props:{showCancel:{type:Boolean,default:!1}},emits:["success","cancel"],setup(t,{expose:e,emit:a}){const l=a,n=$(""),o=$(!1),d=$(""),m=async()=>{var f,h,k;if(!(!n.value||o.value)){d.value="",o.value=!0;try{const I=S("server.domain");if(!I)throw new Error("未配置服务器域名");await me.get(`${I}/kv/_info`,{headers:{Accept:"application/json","x-app-token":n.value}}),re("server.kvToken",n.value),l("success")}catch(I){const F=(f=I==null?void 0:I.response)==null?void 0:f.status;F===401||F===403?d.value="Token 无效或无权限,请确认后重试":F===404?d.value="命名空间不存在或服务器未就绪":d.value=((k=(h=I==null?void 0:I.response)==null?void 0:h.data)==null?void 0:k.message)||(I==null?void 0:I.message)||"验证失败,请稍后重试"}finally{o.value=!1}}};return e({reset:()=>{n.value="",d.value=""}}),(f,h)=>(c(),b(_,null,{default:i(()=>[s(j,null,{default:i(()=>[...h[2]||(h[2]=[u("输入授权 Token",-1)])]),_:1}),s(V,null,{default:i(()=>[s(Ce,{modelValue:n.value,"onUpdate:modelValue":h[0]||(h[0]=k=>n.value=k),clearable:"",density:"comfortable","hide-details":"auto",label:"KV 授权 Token",placeholder:"粘贴从授权页面获取的 Token",variant:"outlined"},null,8,["modelValue"]),d.value?(c(),b(_e,{key:0,class:"mt-3",type:"error",variant:"tonal"},{default:i(()=>[u(g(d.value),1)]),_:1})):w("",!0)]),_:1}),s(X,null,{default:i(()=>[s(L),t.showCancel?(c(),b(y,{key:0,variant:"text",onClick:h[1]||(h[1]=k=>f.$emit("cancel"))},{default:i(()=>[...h[3]||(h[3]=[u(" 取消 ",-1)])]),_:1})):w("",!0),s(y,{disabled:!n.value||o.value,loading:o.value,color:"primary",onClick:m},{default:i(()=>[...h[4]||(h[4]=[u(" 保存 Token ",-1)])]),_:1},8,["disabled","loading"])]),_:1})]),_:1}))}},Ea={__name:"AlternativeCodeDialog",props:{showCancel:{type:Boolean,default:!1}},emits:["submit","cancel"],setup(t,{expose:e,emit:a}){const l=a,n=$(""),o=()=>{n.value&&l("submit",n.value)};return e({reset:()=>{n.value=""}}),(d,m)=>(c(),b(_,null,{default:i(()=>[s(j,null,{default:i(()=>[...m[2]||(m[2]=[u("输入替代代码",-1)])]),_:1}),s(V,null,{default:i(()=>[s(Ue,{modelValue:n.value,"onUpdate:modelValue":m[0]||(m[0]=f=>n.value=f),density:"comfortable","hide-details":"auto",label:"替代代码",placeholder:"请输入替代代码",rows:"5",variant:"outlined"},null,8,["modelValue"]),s(_e,{class:"mt-3",type:"info",variant:"tonal"},{default:i(()=>[...m[3]||(m[3]=[u(" 替代代码功能暂未实现,敬请期待 ",-1)])]),_:1})]),_:1}),s(X,null,{default:i(()=>[s(L),t.showCancel?(c(),b(y,{key:0,variant:"text",onClick:m[1]||(m[1]=f=>d.$emit("cancel"))},{default:i(()=>[...m[4]||(m[4]=[u(" 取消 ",-1)])]),_:1})):w("",!0),s(y,{disabled:!n.value,color:"primary",onClick:o},{default:i(()=>[...m[5]||(m[5]=[u(" 提交 ",-1)])]),_:1},8,["disabled"])]),_:1})]),_:1}))}},ee=[];for(let t=0;t<256;++t)ee.push((t+256).toString(16).slice(1));function Na(t,e=0){return(ee[t[e+0]]+ee[t[e+1]]+ee[t[e+2]]+ee[t[e+3]]+"-"+ee[t[e+4]]+ee[t[e+5]]+"-"+ee[t[e+6]]+ee[t[e+7]]+"-"+ee[t[e+8]]+ee[t[e+9]]+"-"+ee[t[e+10]]+ee[t[e+11]]+ee[t[e+12]]+ee[t[e+13]]+ee[t[e+14]]+ee[t[e+15]]).toLowerCase()}let je;const Va=new Uint8Array(16);function Aa(){if(!je){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");je=crypto.getRandomValues.bind(crypto)}return je(Va)}const Ua=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),gt={randomUUID:Ua};function za(t,e,a){var n;t=t||{};const l=t.random??((n=t.rng)==null?void 0:n.call(t))??Aa();if(l.length<16)throw new Error("Random bytes length must be >= 16");return l[6]=l[6]&15|64,l[8]=l[8]&63|128,Na(l)}function Ma(t,e,a){return gt.randomUUID&&!t?gt.randomUUID():za(t)}const $a={class:"step-content"},Pa={class:"text-center mb-6"},La={class:"step-content"},Fa={class:"relationship-diagram"},Ra={class:"diagram-item"},Oa={class:"text-center"},Ba={class:"diagram-description mt-3"},ja={class:"diagram-connector"},Ha={class:"diagram-item"},Ka={class:"text-center"},qa={class:"diagram-description mt-3"},Wa={class:"step-content"},Ga={class:"button-group"},Qa={class:"d-flex flex-column align-center py-2"},Ja={class:"d-flex flex-column align-center py-2"},Ya={class:"step-content"},Xa={class:"text-center mb-6"},Za={class:"step-content"},eo={class:"text-center mb-6"},to={class:"d-flex flex-column flex-sm-row align-center"},so={class:"flex-grow-1"},no={class:"text-h6 font-weight-bold"},io={class:"text-h5 mb-6"},ao={class:"text-subtitle-2"},oo={class:"d-flex align-center"},lo={class:"d-flex align-center"},ro={class:"step-content"},uo={class:"text-center mb-6"},co={class:"d-flex align-center mb-3"},mo={class:"text-h6 font-weight-medium"},fo={key:0,class:"text-body-2 mb-2"},ho={class:"mb-2"},go={class:"device-code"},po={key:1,class:"text-body-2 text-error"},vo={class:"log-box"},yo={key:0,class:"text-caption text-medium-emphasis"},ko={class:"d-flex flex-wrap gap-2 mt-4"},Me=5,bo={__name:"FirstTimeGuide",emits:["close","success"],setup(t,{emit:e}){const a=e,l=S("server.authDomain"),n=$(1),o=$(""),d=$("idle"),m=$(""),f=$(null),h=$(null),k=$([]),I=$({1:!1,2:!1,3:!1,4:!1}),F=()=>{n.value<Me&&n.value++},H=()=>{n.value>1&&n.value--},N=ie=>{o.value=ie,F()},K=()=>{a("close")},Q=()=>{window.open(l,"_blank")},ge=()=>{n.value=5},pe=G(()=>Object.values(I.value).filter(Boolean).length/4*100),te=G(()=>d.value==="success"?"success":d.value==="error"?"error":"primary"),se=G(()=>d.value==="success"?"mdi-check-circle":d.value==="error"?"mdi-alert-circle":d.value==="registering"?"mdi-progress-clock":"mdi-rocket-launch"),C=G(()=>d.value==="success"?"完成!设备已创建":d.value==="error"?"创建失败":d.value==="registering"?"正在执行…":"准备开始"),z=ie=>{const v=new Date,ae=String(v.getHours()).padStart(2,"0"),T=String(v.getMinutes()).padStart(2,"0"),M=String(v.getSeconds()).padStart(2,"0");k.value.push({time:`${ae}:${T}:${M}`,message:ie})},x=()=>"Classworks",A=async()=>{var ie,v,ae;if(d.value!=="registering"){d.value="registering",m.value="",k.value=[],I.value={1:!1,2:!1,3:!1,4:!1};try{z("正在生成设备信息…");const T=Ma(),M=x(),B=S("server.domain");I.value[1]=!0,z("向服务器注册设备…");const Y=await me.post(`${B}/devices`,{uuid:T,deviceName:M});I.value[2]=!0,f.value={uuid:T,deviceName:M,createdAt:new Date().toISOString(),registered:!0},localStorage.setItem("Classworks_progressive_device",JSON.stringify(f.value)),z("获取访问令牌…");try{const P=await me.post(`${B}/apps/auth/token`,{namespace:T,password:"",appId:"d158067f53627d2b98babe8bffd2fd7d"});P.data&&P.data.token?(h.value=P.data,re("server.kvToken",P.data.token),(ie=P.data.device)!=null&&ie.uuid&&re("device.uuid",P.data.device.uuid),z("已获取 Token 并写入配置")):z("未返回 Token您可以稍后在授权页完成配置")}catch(P){console.warn("自动获取 Token 失败:",P),z("自动获取 Token 失败,可在授权页手动完成")}I.value[3]=!0,z("完成!您可以应用令牌或前往授权页面继续配置"),I.value[4]=!0,d.value="success"}catch(T){console.error("设备注册失败:",T),m.value=((ae=(v=T.response)==null?void 0:v.data)==null?void 0:ae.message)||T.message||"网络连接失败",z("失败:"+m.value),d.value="error"}}},R=()=>{d.value="idle",m.value="",k.value=[],I.value={1:!1,2:!1,3:!1,4:!1}},de=()=>{const ie=f.value;if(!(ie!=null&&ie.uuid))return;const ae=`${S("server.authDomain")}/?uuid=${encodeURIComponent(ie.uuid)}&tolinktoaccount=true`;window.open(ae,"_blank")},le=()=>{h.value&&a("success",h.value),a("close")};return(ie,v)=>(c(),b(_,{class:"guide-card"},{default:i(()=>[s(it,{"model-value":n.value/Me*100,color:"primary",height:"6"},null,8,["model-value"]),s(V,{class:"pa-8"},{default:i(()=>[oe(r("div",$a,[r("div",Pa,[s(D,{class:"mb-4",color:"primary",size:"80"},{default:i(()=>[...v[2]||(v[2]=[u(" mdi-hand-wave ",-1)])]),_:1}),v[3]||(v[3]=r("h2",{class:"text-h4 mb-3"}," 欢迎使用 Classworks ",-1)),v[4]||(v[4]=r("p",{class:"text-body-1 text-medium-emphasis"}," 适用于班级大屏的作业板小工具 ",-1))])],512),[[be,n.value===1]]),oe(r("div",La,[v[17]||(v[17]=r("h3",{class:"text-h5 mb-6 text-center"}," Classworks 和 Classworks KV 的关系 ",-1)),s(_,{class:"pa-6 mb-6",color:"primary",variant:"tonal"},{default:i(()=>[r("div",Fa,[r("div",Ra,[s(_,{class:"pa-4",color:"blue-darken-1",elevation:"8"},{default:i(()=>[r("div",Oa,[s(D,{color:"white",size:"60"},{default:i(()=>[...v[5]||(v[5]=[u(" mdi-laptop ",-1)])]),_:1}),v[6]||(v[6]=r("h4",{class:"text-h6 text-white mt-2"}," Classworks ",-1)),v[7]||(v[7]=r("p",{class:"text-caption text-white mt-1"}," 作业板应用 ",-1))])]),_:1}),r("div",Ba,[s(O,{class:"mb-2",color:"blue",size:"small",variant:"flat"},{default:i(()=>[...v[8]||(v[8]=[u(" 前端应用 ",-1)])]),_:1}),v[9]||(v[9]=r("div",{class:"text-body-2"},[u(" • 显示作业内容"),r("br"),u(" • 管理班级信息"),r("br"),u(" • 提供用户界面 ")],-1))])]),r("div",ja,[s(D,{color:"primary",size:"40"},{default:i(()=>[...v[10]||(v[10]=[u(" mdi-swap-horizontal ",-1)])]),_:1}),v[11]||(v[11]=r("div",{class:"text-caption font-weight-bold mt-2"}," 数据同步 ",-1))]),r("div",Ha,[s(_,{class:"pa-4",color:"green-darken-1",elevation:"8"},{default:i(()=>[r("div",Ka,[s(D,{color:"white",size:"60"},{default:i(()=>[...v[12]||(v[12]=[u(" mdi-cloud-sync ",-1)])]),_:1}),v[13]||(v[13]=r("h4",{class:"text-h6 text-white mt-2"}," Classworks KV ",-1)),v[14]||(v[14]=r("p",{class:"text-caption text-white mt-1"}," 云端数据库 ",-1))])]),_:1}),r("div",qa,[s(O,{class:"mb-2",color:"green",size:"small",variant:"flat"},{default:i(()=>[...v[15]||(v[15]=[u(" 后端服务 ",-1)])]),_:1}),v[16]||(v[16]=r("div",{class:"text-body-2"},[u(" • 存储作业数据"),r("br"),u(" • 多设备同步"),r("br"),u(" • 权限管理 ")],-1))])])])]),_:1})],512),[[be,n.value===2]]),oe(r("div",Wa,[v[25]||(v[25]=r("h3",{class:"text-h5 mb-6 text-center"}," 你需要在多个设备上查看作业吗? ",-1)),s(_,{class:"mb-6 pa-4",color:"info",variant:"tonal"},{default:i(()=>[...v[18]||(v[18]=[r("div",{class:"text-body-2"}," 比如:在家里电脑、手机上查看,或者多个教室设备共享数据 ",-1)])]),_:1}),r("div",Ga,[s(y,{block:"",class:"mb-4 py-6",color:"primary",size:"x-large",variant:"elevated",onClick:v[0]||(v[0]=ae=>N("cloud"))},{default:i(()=>[r("div",Qa,[s(D,{class:"mb-2",size:"40"},{default:i(()=>[...v[19]||(v[19]=[u(" mdi-cloud-check ",-1)])]),_:1}),v[20]||(v[20]=r("span",{class:"text-h6"},"需要,使用云同步",-1)),v[21]||(v[21]=r("span",{class:"text-caption mt-1"},"多设备访问",-1))])]),_:1}),s(y,{block:"",class:"py-6",size:"x-large",variant:"outlined",onClick:v[1]||(v[1]=ae=>N("local"))},{default:i(()=>[r("div",Ja,[s(D,{class:"mb-2",size:"40"},{default:i(()=>[...v[22]||(v[22]=[u(" mdi-laptop ",-1)])]),_:1}),v[23]||(v[23]=r("span",{class:"text-h6"},"不需要,只用这台设备",-1)),v[24]||(v[24]=r("span",{class:"text-caption mt-1"},"本地存储",-1))])]),_:1})])],512),[[be,n.value===3]]),oe(r("div",Ya,[r("div",Xa,[s(D,{class:"mb-4",color:"success",size:"80"},{default:i(()=>[...v[26]||(v[26]=[u(" mdi-check-circle ",-1)])]),_:1}),v[28]||(v[28]=r("h3",{class:"text-h5 mb-4"}," 您可以使用本地模式 ",-1)),s(_,{class:"pa-4 text-left",variant:"tonal"},{default:i(()=>[...v[27]||(v[27]=[r("div",{class:"text-body-1 mb-2"}," 此数据将存储在您的浏览器中如果您的浏览器不支持IndexedDB可能会出现问题。如果您经常清除浏览器数据请谨慎使用本地模式。 ",-1),r("div",{class:"text-body-1 mb-2"}," 在刚才地方点击使用本地模式的按钮使用。 ",-1)])]),_:1})])],512),[[be,n.value===4&&o.value==="local"]]),oe(r("div",Za,[r("div",eo,[s(D,{class:"mb-4",color:"primary",size:"80"},{default:i(()=>[...v[29]||(v[29]=[u(" mdi-cloud-cog ",-1)])]),_:1}),v[30]||(v[30]=r("h3",{class:"text-h5 mb-4"}," 需要先设置云端账号 ",-1))]),s(_,{class:"pa-6 mb-6",variant:"tonal"},{default:i(()=>[r("div",to,[r("div",so,[v[32]||(v[32]=r("h4",{class:"text-h6 font-weight-bold mb-2"}," 自动注册设备 ",-1)),v[33]||(v[33]=r("p",{class:"text-body-2 mb-3 text-medium-emphasis"}," 通过引导式流程自动创建设备、获取令牌并完成初始化。适合首次体验或快速部署多终端。 ",-1)),s(y,{color:"primary","prepend-icon":"mdi-flash",size:"large",variant:"elevated",onClick:ge},{default:i(()=>[...v[31]||(v[31]=[u(" 自动注册 ",-1)])]),_:1})])])]),_:1}),v[41]||(v[41]=r("div",{class:"mb-6"}," 也可以手动前往 Classworks KV 控制台获取认证信息: ",-1)),s(_,{color:Ee(l)=="https://kv.houlang.cloud"?"primary":"error",variant:Ee(l)=="https://kv.houlang.cloud"?"elevated":"outlined",class:"pa-6 mb-6",onClick:Q},{default:i(()=>[s(D,{class:"mb-3",size:"48"},{default:i(()=>[...v[34]||(v[34]=[u(" mdi-open-in-new ",-1)])]),_:1}),r("h4",no," 请访问 "+g(Ee(l)=="https://kv.houlang.cloud"?"Classworks KV":"自定义的 Classworks KV 实例 ")+" 控制台 ",1),r("div",io,g(Ee(l)),1),r("h6",ao,g(Ee(l)=="https://kv.houlang.cloud"?"此实例由 Classworks KV 官方提供":"此链接由您的实例、预配代码或管理员管理,当前可能不是 Classworks KV 官方的实例地址。"),1)]),_:1},8,["color","variant"]),s(ms,{class:"mt-6",variant:"accordion"},{default:i(()=>[s(ct,null,{default:i(()=>[s(mt,null,{default:i(()=>[r("div",oo,[s(D,{class:"mr-3",color:"warning"},{default:i(()=>[...v[35]||(v[35]=[u(" mdi-help-circle ",-1)])]),_:1}),v[36]||(v[36]=r("span",{class:"text-subtitle-1 font-weight-medium"},"我以前已经使用过 Classworks KV",-1))])]),_:1}),s(ft,null,{default:i(()=>[s(_,{class:"pa-4",color:"success",variant:"tonal"},{default:i(()=>[...v[37]||(v[37]=[r("div",{class:"text-body-2 mb-2"},[u(" 如果您之前已经使用过 Classworks KV可以直接使用您的 "),r("strong",null,"UUID命名空间"),u(" 和 "),r("strong",null,"设置的密码"),u(" 进行认证。 ")],-1),r("div",{class:"text-body-2"},' 返回上一页,点击"已注册"按钮,输入您的认证信息即可登录。 ',-1)])]),_:1})]),_:1})]),_:1}),s(ct,null,{default:i(()=>[s(mt,null,{default:i(()=>[r("div",lo,[s(D,{class:"mr-3",color:"info"},{default:i(()=>[...v[38]||(v[38]=[u(" mdi-help-circle ",-1)])]),_:1}),v[39]||(v[39]=r("span",{class:"text-subtitle-1 font-weight-medium"},"我如何配置不同类型的设备?",-1))])]),_:1}),s(ft,null,{default:i(()=>[s(_,{class:"pa-4",color:"info",variant:"tonal"},{default:i(()=>[...v[40]||(v[40]=[r("div",{class:"text-body-2 mb-2"},[u(" 不同的密码对应不同的设备类型,这将由 "),r("strong",null,"管理员管理"),u("。 ")],-1),r("div",{class:"text-body-2 mb-2"}," 例如: ",-1),r("ul",{class:"text-body-2 ml-4"},[r("li",{class:"mb-1"}," 班级大屏使用一个密码 "),r("li",{class:"mb-1"}," 教师设备使用另一个密码 "),r("li",null,"学生设备使用不同的密码")],-1),r("div",{class:"text-body-2 mt-3"}," 请联系您的管理员获取对应设备类型的密码。 ",-1)])]),_:1})]),_:1})]),_:1})]),_:1})],512),[[be,n.value===4&&o.value==="cloud"]]),oe(r("div",ro,[r("div",uo,[s(Ie,{class:"mb-4",color:"primary",size:"80",variant:"tonal"},{default:i(()=>[s(D,{size:"48"},{default:i(()=>[...v[42]||(v[42]=[u(" mdi-rocket-launch ",-1)])]),_:1})]),_:1}),v[43]||(v[43]=r("h3",{class:"text-h5 font-weight-bold mb-2"}," 渐进式注册 ",-1)),v[44]||(v[44]=r("p",{class:"text-body-2 text-medium-emphasis"}," 您可以暂时不配置 Classworks KV ",-1))]),s(it,{"model-value":pe.value,class:"mb-6",color:"primary",height:"8",rounded:""},null,8,["model-value"]),s(ue,null,{default:i(()=>[s(ne,{cols:"12"},{default:i(()=>[s(_,{color:te.value,variant:"tonal"},{default:i(()=>[s(Ve,null,{default:i(()=>[r("div",co,[s(D,{color:te.value,class:"mr-2",size:"32"},{default:i(()=>[u(g(se.value),1)]),_:1},8,["color"]),r("div",mo,g(C.value),1)]),f.value?(c(),p("div",fo,[r("div",ho,[v[45]||(v[45]=r("strong",null,"设备名称:",-1)),u(g(f.value.deviceName),1)]),r("div",null,[v[46]||(v[46]=r("strong",null,"设备 UUID",-1)),r("code",go,g(f.value.uuid),1)])])):w("",!0),d.value==="error"?(c(),p("div",po,g(m.value),1)):w("",!0)]),_:1})]),_:1},8,["color"])]),_:1}),s(ne,{cols:"12"},{default:i(()=>[s(_,{variant:"outlined"},{default:i(()=>[s(Ve,null,{default:i(()=>[v[47]||(v[47]=r("div",{class:"text-subtitle-2 font-weight-medium mb-3"}," 过程日志 ",-1)),r("div",vo,[(c(!0),p(E,null,U(k.value,(ae,T)=>(c(),p("div",{key:T,class:"text-caption log-line"},g(ae.time)+" · "+g(ae.message),1))),128)),k.value.length?w("",!0):(c(),p("div",yo," 等待开始… "))])]),_:1})]),_:1})]),_:1})]),_:1}),r("div",ko,[d.value==="idle"?(c(),b(y,{key:0,color:"primary","prepend-icon":"mdi-play",size:"large",onClick:A},{default:i(()=>[...v[48]||(v[48]=[u(" 开始创建 ",-1)])]),_:1})):w("",!0),d.value==="error"?(c(),b(y,{key:1,color:"error","prepend-icon":"mdi-refresh",variant:"outlined",onClick:R},{default:i(()=>[...v[49]||(v[49]=[u(" 重试 ",-1)])]),_:1})):w("",!0),d.value==="registering"?(c(),b(y,{key:2,loading:!0,color:"primary","prepend-icon":"mdi-progress-clock",variant:"tonal"},{default:i(()=>[...v[50]||(v[50]=[u(" 正在执行… ",-1)])]),_:1})):w("",!0),d.value==="success"?(c(),b(y,{key:3,color:"success","prepend-icon":"mdi-check-circle",size:"large",variant:"elevated",onClick:le},{default:i(()=>[...v[51]||(v[51]=[u(" 应用令牌并关闭 ",-1)])]),_:1})):w("",!0),d.value==="success"?(c(),b(y,{key:4,color:"primary","prepend-icon":"mdi-open-in-new",size:"large",variant:"outlined",onClick:de},{default:i(()=>[...v[52]||(v[52]=[u(" 前往绑定账户 ",-1)])]),_:1})):w("",!0)])],512),[[be,n.value===5]])]),_:1}),s(X,{class:"pa-6 pt-0"},{default:i(()=>[n.value>1?(c(),b(y,{key:0,size:"large",variant:"text",onClick:H},{default:i(()=>[s(D,{start:""},{default:i(()=>[...v[53]||(v[53]=[u(" mdi-chevron-left ",-1)])]),_:1}),v[54]||(v[54]=u(" 上一步 ",-1))]),_:1})):w("",!0),s(L),n.value<Me&&n.value!==4?(c(),b(y,{key:1,disabled:n.value===3&&!o.value,color:"primary",size:"large",variant:"elevated",onClick:F},{default:i(()=>[v[56]||(v[56]=u(" 下一步 ",-1)),s(D,{end:""},{default:i(()=>[...v[55]||(v[55]=[u(" mdi-chevron-right ",-1)])]),_:1})]),_:1},8,["disabled"])):w("",!0),n.value===Me||n.value===4?(c(),b(y,{key:2,color:"primary",size:"large",variant:"elevated",onClick:K},{default:i(()=>[...v[57]||(v[57]=[u(" 关闭 ",-1)])]),_:1})):w("",!0)]),_:1})]),_:1}))}},xo=W(bo,[["__scopeId","data-v-817c6e0e"]]),wo={key:0,class:"init-overlay"},So={class:"init-container"},Co={class:"main-card-row"},_o={class:"card-horizontal-layout"},Do={class:"card-icon-wrapper"},To={class:"card-horizontal-layout"},Io={class:"card-icon-wrapper"},Eo={class:"card-horizontal-layout"},No={class:"card-icon-wrapper"},Vo={class:"options-buttons"},Ao={__name:"InitServiceChooser",props:{preconfig:{type:Object,default:()=>({namespace:null,authCode:null,autoOpen:!1,autoExecute:!1})}},emits:["done"],setup(t,{emit:e}){const a=t,l=e,n=$(!1),o=$(!1),d=$(!1),m=$(!1),f=$(!1),h=$(null),k=G(()=>S("server.provider")),I=G(()=>k.value==="kv-server"||k.value==="classworkscloud"),F=G(()=>S("server.kvToken")),H=G(()=>{var z;return(z=a.preconfig)!=null&&z.namespace?{namespace:a.preconfig.namespace,password:a.preconfig.authCode||"",autoExecute:a.preconfig.autoExecute||!1}:null}),N=()=>{const z=window.location.pathname,x=z==="/"||z==="/index"||z==="/index.html",A=I.value&&(!F.value||F.value==="");n.value=x&&A};Le(()=>a.preconfig,z=>{z!=null&&z.autoOpen&&(z!=null&&z.namespace)&&n.value&&(console.log("检测到预配数据,自动打开设备认证对话框"),setTimeout(()=>{d.value=!0},500))},{immediate:!0,deep:!0}),Ye(()=>{N()});const K=()=>{const z=S("server.authDomain"),x="d158067f53627d2b98babe8bffd2fd7d",A=window.location.origin,R=encodeURIComponent(`${A}/authorizecallback`),de=S("device.uuid")||"00000000-0000-4000-8000-000000000000";let le=`${z}/authorize?app_id=${x}&mode=callback&callback_url=${R}&remark=Classworks 自动授权 来自${window.location.hostname} ${new Date().toLocaleString()}`;de!=="00000000-0000-4000-8000-000000000000"&&(le+=`&uuid=${encodeURIComponent(de)}`),window.location.href=le},Q=z=>{o.value=!1,console.log("渐进式注册成功:",z),N(),l("done")},ge=z=>{var x;d.value=!1,console.log("认证成功:",z),(x=a.preconfig)!=null&&x.namespace&&console.log(`预配数据认证成功: ${a.preconfig.namespace}`),N(),l("done")},pe=()=>{m.value=!1,N(),l("done")},te=z=>{console.log("替代代码:",z),f.value=!1},se=()=>{re("server.provider","kv-local"),n.value=!1,window.location.reload(),l("done")},C=()=>{window.open(S("server.authDomain"),"_blank")};return(z,x)=>n.value?(c(),p("div",wo,[r("div",So,[x[22]||(x[22]=r("div",{class:"init-header"},[r("div",{class:"title"}," 欢迎使用 Classworks "),r("div",{class:"subtitle"}," 请选择你的使用方式 ")],-1)),r("div",Co,[s(_,{class:"main-service-card gradient-new clickable",elevation:"4",onClick:x[0]||(x[0]=A=>o.value=!0)},{default:i(()=>[s(Ve,null,{default:i(()=>[r("div",_o,[r("div",Do,[s(D,{color:"primary",size:"48"},{default:i(()=>[...x[12]||(x[12]=[u(" mdi-new-box ",-1)])]),_:1})]),x[13]||(x[13]=r("div",{class:"card-content"},[r("div",{class:"text-h6 font-weight-bold"}," 初次使用 "),r("div",{class:"text-body-2 text-medium-emphasis mt-1"}," 了解 Classworks KV 并开始使用 ")],-1))])]),_:1})]),_:1}),s(_,{class:"main-service-card gradient-registered clickable",elevation:"4",onClick:x[1]||(x[1]=A=>d.value=!0)},{default:i(()=>[s(Ve,null,{default:i(()=>[r("div",To,[r("div",Io,[s(D,{color:"success",size:"48"},{default:i(()=>[...x[14]||(x[14]=[u(" mdi-account-check ",-1)])]),_:1})]),x[15]||(x[15]=r("div",{class:"card-content"},[r("div",{class:"text-h6 font-weight-bold"}," 已注册 "),r("div",{class:"text-body-2 text-medium-emphasis mt-1"}," 使用设备 Namespace 登录 ")],-1))])]),_:1})]),_:1}),s(_,{class:"main-service-card clickable",elevation:"4",onClick:C},{default:i(()=>[s(Ve,null,{default:i(()=>[r("div",Eo,[r("div",No,[s(D,{color:"info",size:"48"},{default:i(()=>[...x[16]||(x[16]=[u(" mdi-database-cog ",-1)])]),_:1})]),x[17]||(x[17]=r("div",{class:"card-content"},[r("div",{class:"text-h6 font-weight-bold"}," Classworks KV "),r("div",{class:"text-body-2 text-medium-emphasis mt-1"}," 打开云端控制台管理数据 ")],-1))])]),_:1})]),_:1})]),r("div",Vo,[s(y,{"prepend-icon":"mdi-laptop",size:"small",variant:"tonal",onClick:se},{default:i(()=>[...x[18]||(x[18]=[u(" 使用本地模式 ",-1)])]),_:1}),s(y,{"prepend-icon":"mdi-flash",size:"small",variant:"tonal",onClick:K},{default:i(()=>[...x[19]||(x[19]=[u(" 授权码式授权(弃用) ",-1)])]),_:1}),s(y,{"prepend-icon":"mdi-key",size:"small",variant:"tonal",onClick:x[2]||(x[2]=A=>m.value=!0)},{default:i(()=>[...x[20]||(x[20]=[u(" 输入 Token ",-1)])]),_:1}),s(y,{"prepend-icon":"mdi-code-tags",size:"small",variant:"tonal",onClick:x[3]||(x[3]=A=>f.value=!0)},{default:i(()=>[...x[21]||(x[21]=[u(" 输入替代代码 ",-1)])]),_:1})]),x[23]||(x[23]=r("div",{class:"footer-hint"}," 完成授权后可使用作业同步、考试看板等在线功能。 ",-1))]),s(J,{modelValue:o.value,"onUpdate:modelValue":x[5]||(x[5]=A=>o.value=A),"max-width":"600"},{default:i(()=>[s(xo,{onClose:x[4]||(x[4]=A=>o.value=!1),onSuccess:Q})]),_:1},8,["modelValue"]),s(J,{modelValue:d.value,"onUpdate:modelValue":x[7]||(x[7]=A=>d.value=A),"max-width":"500"},{default:i(()=>[s(Ta,{ref_key:"deviceAuthDialog",ref:h,preconfig:H.value,"show-cancel":!0,onCancel:x[6]||(x[6]=A=>d.value=!1),onSuccess:ge},null,8,["preconfig"])]),_:1},8,["modelValue"]),s(J,{modelValue:m.value,"onUpdate:modelValue":x[9]||(x[9]=A=>m.value=A),"max-width":"500"},{default:i(()=>[s(Ia,{"show-cancel":!0,onCancel:x[8]||(x[8]=A=>m.value=!1),onSuccess:pe})]),_:1},8,["modelValue"]),s(J,{modelValue:f.value,"onUpdate:modelValue":x[11]||(x[11]=A=>f.value=A),"max-width":"500"},{default:i(()=>[s(Ea,{"show-cancel":!0,onCancel:x[10]||(x[10]=A=>f.value=!1),onSubmit:te})]),_:1},8,["modelValue"])])):w("",!0)}},Bt=W(Ao,[["__scopeId","data-v-cbfbc6db"]]),Uo={name:"ExamScheduleCard",props:{examId:{type:String,required:!0},contentStyle:{type:Object,default:()=>({})}},computed:{...bt(ze,["exams","loadingDetails"]),exam(){return this.exams[this.examId]},loading(){return this.loadingDetails[this.examId]}},mounted(){this.fetchExam(this.examId)},methods:{...kt(ze,["fetchExam"]),formatTime(t){if(!t)return"";try{const e=new Date(t),a=(e.getMonth()+1).toString().padStart(2,"0"),l=e.getDate().toString().padStart(2,"0"),n=e.getHours().toString().padStart(2,"0"),o=e.getMinutes().toString().padStart(2,"0");return`${a}-${l} ${n}:${o}`}catch{return t}}}},zo={class:"text-truncate"},Mo={key:0,class:"d-flex justify-center align-center fill-height",style:{"min-height":"200px"}},$o={class:"d-flex align-center mb-1"},Po={class:"font-weight-medium"},Lo={class:"d-flex align-center"},Fo={class:"font-weight-medium"},Ro={key:2,class:"d-flex flex-column align-center justify-center fill-height text-grey mt-4"};function Oo(t,e,a,l,n,o){return c(),b(_,{class:"fill-height d-flex flex-column rounded-xl",elevation:"2"},{default:i(()=>[s(j,{class:"d-flex align-center py-3 px-4 bg-primary text-white"},{default:i(()=>{var d;return[s(D,{class:"mr-2"},{default:i(()=>[...e[1]||(e[1]=[u("mdi-calendar-clock",-1)])]),_:1}),r("span",zo,g(((d=o.exam)==null?void 0:d.examName)||"加载中..."),1),s(L),s(y,{icon:"mdi-close",variant:"text",density:"comfortable",onClick:e[0]||(e[0]=m=>t.$emit("close"))})]}),_:1}),s(V,{class:"flex-grow-1 pa-4 overflow-y-auto",style:he(a.contentStyle)},{default:i(()=>[o.loading?(c(),p("div",Mo,[s(xt,{indeterminate:"",color:"primary"})])):o.exam?(c(),p(E,{key:1},[o.exam.message?(c(),b(_e,{key:0,color:"info",variant:"tonal",class:"mb-4 text-body-1",border:"start",density:"compact"},{default:i(()=>[u(g(o.exam.message),1)]),_:1})):w("",!0),s(we,{density:"comfortable",class:"pa-0 bg-transparent"},{default:i(()=>[(c(!0),p(E,null,U(o.exam.examInfos,(d,m)=>(c(),b(Se,{key:m,class:"px-0 mb-3"},{prepend:i(()=>[s(Ie,{color:"primary",variant:"tonal",size:"large",class:"mr-3 font-weight-bold elevation-1"},{default:i(()=>[u(g(d.name.charAt(0)),1)]),_:2},1024)]),default:i(()=>[s($e,{class:"font-weight-bold text-h6 mb-1"},{default:i(()=>[u(g(d.name),1)]),_:2},1024),s(Pe,{class:"text-body-1"},{default:i(()=>[r("div",$o,[s(D,{size:"small",color:"success",class:"mr-2"},{default:i(()=>[...e[2]||(e[2]=[u("mdi-clock-start",-1)])]),_:1}),r("span",Po,g(o.formatTime(d.start)),1)]),r("div",Lo,[s(D,{size:"small",color:"error",class:"mr-2"},{default:i(()=>[...e[3]||(e[3]=[u("mdi-clock-end",-1)])]),_:1}),r("span",Fo,g(o.formatTime(d.end)),1)])]),_:2},1024)]),_:2},1024))),128))]),_:1})],64)):(c(),p("div",Ro,[s(D,{size:"large",class:"mb-2"},{default:i(()=>[...e[4]||(e[4]=[u("mdi-alert-circle-outline",-1)])]),_:1}),e[5]||(e[5]=u(" 无法加载考试信息 ",-1))]))]),_:1},8,["style"])]),_:1})}const Bo=W(Uo,[["render",Oo],["__scopeId","data-v-52dc8ca5"]]);function He(t,e){let a=null;return function(...l){a&&clearTimeout(a),a=setTimeout(()=>{t.apply(this,l)},e)}}function jo(t,e){let a=null,l=0;return function(...n){const o=Date.now();o-l<e?(a&&clearTimeout(a),a=setTimeout(()=>{l=o,t.apply(this,n)},e)):(l=o,t.apply(this,n))}}const Ho={name:"Classworks 作业板",components:{MessageLog:St,RandomPicker:Tt,FloatingToolbar:Vt,FloatingICP:Nt,HomeworkEditDialog:Ut,InitServiceChooser:Bt,ChatWidget:Re,StudentNameManager:Ot,UrgentTestDialog:Et,AttendanceSidebar:zt,AttendanceManagementDialog:At,HomeworkGrid:Rt,HomeActions:$t,PwaInstallCard:Mt,ExamScheduleCard:Bo,ExamConfigEditor:pt},setup(){const{mobile:t}=Ae(),e=ze();return{mobile:t,examStore:e}},data(){const t=[{name:"语文",order:0},{name:"数学",order:1},{name:"英语",order:2},{name:"物理",order:3},{name:"化学",order:4},{name:"生物",order:5},{name:"政治",order:6},{name:"历史",order:7},{name:"地理",order:8},{name:"其他",order:9}];return{showAddExamDialog:!1,showExamDetailDialog:!1,selectedExamId:null,upcomingExams:[],dataKey:"",provider:"",useDisplay:Ae,state:{classNumber:"",namespaceInfo:null,deviceName:"",studentList:[],boardData:{homework:{},attendance:{absent:[],late:[],exclude:[]}},dialogVisible:!1,dialogTitle:"",textarea:"",dateString:"",synced:!1,attendDialogVisible:!1,contentStyle:{"font-size":`${S("font.size")}px`},uploadLoading:!1,downloadLoading:!1,snackbar:!1,snackbarText:"",fontSize:S("font.size"),datePickerDialog:!1,selectedDate:new Date().toISOString().split("T")[0].replace(/-/g,""),selectedDateObj:new Date,refreshInterval:null,showNoDataMessage:!1,noDataMessage:"",isToday:!1,attendanceDialog:!1,availableSubjects:t,isFullscreen:!1},loading:{download:!1,upload:!1,students:!1,copyToToday:!1},debouncedUpload:null,debouncedAttendanceSave:null,throttledReflow:null,sortedItemsCache:{key:"",value:[]},confirmDialog:{show:!1,resolve:null,reject:null},urlConfigDialog:{show:!1,config:null,changes:[],validSettings:{},confirmHandler:null,cancelHandler:null,icons:{}},settingsTick:0,isChatOpen:!1,highlightedCards:{},tokenDisplayInfo:{show:!1,readonly:!1,text:"",color:"primary",variant:"tonal",icon:"mdi-account",disabled:!1},realtimeInfo:{show:!1,time:"",key:""},$offKvChanged:null,$offConnect:null,debouncedRealtimeRefresh:null,preconfigData:{namespace:null,authCode:null,autoOpen:!1,autoExecute:!1},urgentTestDialog:!1,tokenInfo:null,persistentNotifications:[],notificationDetailDialog:!1,currentNotification:null}},computed:{isMobile(){return S("display.forceDesktopMode")?!1:this.mobile},titleText(){var d,m;const t=((m=(d=this.state.namespaceInfo)==null?void 0:d.device)==null?void 0:m.name)||this.state.classNumber||"高三八班",e=this.getToday(),a=new Date(e);a.setDate(a.getDate()-1);const l=this.state.dateString,n=this.formatDate(e),o=this.formatDate(a);return l===n?t+" - 今天的作业":l===o?t+" - 昨天的作业":`${t} - ${l}的作业`},sortedItems(){const t=[];this.isMobile&&t.push({key:"attendance-card",name:"出勤统计",type:"attendance",data:{total:this.state.studentList.length,absent:this.state.boardData.attendance.absent,late:this.state.boardData.attendance.late,exclude:this.state.boardData.attendance.exclude}});for(const e in this.state.boardData.homework)if(e.startsWith("exam-")){const a=this.state.boardData.homework[e];t.push({key:e,name:"考试安排",type:"exam",data:{examId:a.examId},order:-100,rowSpan:200})}for(const e of this.state.availableSubjects){const a=e.name,l=this.state.boardData.homework[a];if(l&&l.content){const o=100+l.content.split(`
`).filter(d=>d.trim()).length*24;t.push({key:a,name:a,type:"homework",content:l.content,order:e.order,rowSpan:o})}}S("hitokoto.enabled")&&t.push({key:"hitokoto-card",name:"一言",type:"hitokoto",order:9998,rowSpan:150});for(const e in this.state.boardData.homework)if(e.startsWith("custom-")){const a=this.state.boardData.homework[e],n=100+a.content.split(`
`).filter(o=>o.trim()).length*24;t.push({key:e,name:a.name,type:"custom",content:a.content,order:9999,rowSpan:n})}return t.sort((e,a)=>e.order-a.order),t},unusedSubjects(){const t=Object.keys(this.state.boardData.homework).filter(e=>{var a;return(a=this.state.boardData.homework[e].content)==null?void 0:a.trim()});return this.state.availableSubjects.filter(e=>!t.includes(e.name)).sort((e,a)=>e.order-a.order)},emptySubjects(){return this.emptySubjectDisplay!=="button"?[]:this.unusedSubjects},autoSave(){return S("edit.autoSave")},blockNonTodayAutoSave(){return S("edit.blockNonTodayAutoSave")},isToday(){const t=(()=>{const e=new Date,a=e.getFullYear(),l=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${a}${l}${n}`})();return this.state.dateString===t},canAutoSave(){return this.autoSave&&(!this.blockNonTodayAutoSave||this.isToday)},needConfirmSave(){return!this.isToday&&this.confirmNonTodaySave},shouldShowBlockedMessage(){return!this.isToday&&this.autoSave&&this.blockNonTodayAutoSave},refreshBeforeEdit(){return S("edit.refreshBeforeEdit")},emptySubjectDisplay(){return S("display.emptySubjectDisplay")},dynamicSort(){return S("display.dynamicSort")},isEditingDisabled(){if(this.state.uploadLoading||this.state.downloadLoading)return!0;const t=this.$refs.studentNameManager;return!!(t!=null&&t.isReadOnly||!this.canEditCurrentDate)},unreadCount(){var t;return((t=this.$refs.messageLog)==null?void 0:t.unreadCount)||0},showRandomPickerButton(){return S("randomPicker.enabled")},showListCardButton(){return S("display.showListCard")},confirmNonTodaySave(){return S("edit.confirmNonTodaySave")},blockPastDataEdit(){return S("edit.blockPastDataEdit")},shouldShowSaveConfirm(){return!this.isToday&&this.confirmNonTodaySave},shouldBlockAutoSave(){return!this.isToday&&this.autoSave&&this.blockNonTodayAutoSave},canEditCurrentDate(){return this.isToday?!0:!this.blockPastDataEdit},isEditingPastData(){return!this.isToday},showFullscreenButton(){return S("display.showFullscreenButton")},showExamScheduleButton(){return S("display.showExamScheduleButton")},showAntiScreenBurnCard(){return S("display.showAntiScreenBurnCard")},showTestCardButton(){return S("developer.enabled")},shouldShowInit(){var n;const t=S("server.provider"),e=t==="kv-server"||t==="classworkscloud",a=S("server.kvToken"),l=((n=this.$route)==null?void 0:n.path)==="/";return this.settingsTick,l&&e&&(!a||a==="")},hasExamCard(){for(const t in this.state.boardData.homework)if(t.startsWith("exam-"))return!0;return!1},shouldShowUrgentTestButton(){const t=S("server.provider");return!(t==="kv-server"||t==="classworkscloud")||!S("server.kvToken")||!this.tokenInfo?!1:this.tokenInfo.deviceType==="teacher"||this.tokenInfo.deviceType==="classroom"},subjectOrder(){return[...this.state.availableSubjects].sort((t,e)=>t.order-e.order).map(t=>t.name)}},watch:{homeworkData:{handler(){this.$nextTick(()=>{this.$refs.waterfall&&this.$refs.waterfall.reflow()})},deep:!0},"$vuetify.display.width":{handler(){this.throttledReflow()},deep:!0},"state.attendanceDialog":{handler(t){this.handleAttendanceDialogClose(t)}}},created(){this.debouncedUpload=He(this.uploadData,2e3),this.debouncedAttendanceSave=He(async()=>{this.autoSave&&await this.trySave(!0)},2e3),this.throttledReflow=jo(()=>{this.$refs.gridContainer&&this.optimizeGridLayout(this.sortedItems)},200)},async mounted(){try{this.updateBackendUrl(),await this.initializeData(),await this.loadDeviceInfo(),this.setupAutoRefresh(),this.unwatchSettings=Xe(()=>{this.updateSettings()}),this.$nextTick(()=>{const t=this.$refs.studentNameManager;t&&(this.studentNameInfo.name=t.currentStudentName||t.currentTeacherName||"",this.studentNameInfo.isStudent=t.isStudentToken,this.studentNameInfo.isTeacher=t.isTeacherToken,this.studentNameInfo.openDialog=()=>t.openDialog(),this.$watch(()=>t.currentStudentName,e=>{this.studentNameInfo.name=e,this.updateTokenDisplayInfo()}),this.$watch(()=>t.currentTeacherName,e=>{t.isTeacherToken&&(this.studentNameInfo.name=e,this.updateTokenDisplayInfo())}),this.$watch(()=>t.isStudentToken,e=>{this.studentNameInfo.isStudent=e,this.updateTokenDisplayInfo()}),this.$watch(()=>t.isTeacherToken,e=>{this.studentNameInfo.isTeacher=e,this.updateTokenDisplayInfo()}))}),document.addEventListener("fullscreenchange",this.fullscreenChangeHandler),document.addEventListener("webkitfullscreenchange",this.fullscreenChangeHandler),document.addEventListener("mozfullscreenchange",this.fullscreenChangeHandler),document.addEventListener("MSFullscreenChange",this.fullscreenChangeHandler),this.checkHashForRandomPicker(),window.addEventListener("hashchange",this.checkHashForRandomPicker),this.setupRealtimeChannel(),this.$nextTick(()=>{this.updateTokenDisplayInfo()}),await this.loadTokenInfo(),this.loadPersistentNotifications()}catch(t){console.error("初始化失败:",t),this.showError("初始化失败,请刷新页面重试")}},beforeUnmount(){this.unwatchSettings&&this.unwatchSettings(),this.state.refreshInterval&&clearInterval(this.state.refreshInterval),document.removeEventListener("fullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("webkitfullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("mozfullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("MSFullscreenChange",this.fullscreenChangeHandler),window.removeEventListener("hashchange",this.checkHashForRandomPicker);try{this.$offKvChanged&&typeof this.$offKvChanged=="function"&&(this.$offKvChanged(),this.$offKvChanged=null),this.$offDeviceEvent&&typeof this.$offDeviceEvent=="function"&&(this.$offDeviceEvent(),this.$offDeviceEvent=null),this.$offConnect&&typeof this.$offConnect=="function"&&(this.$offConnect(),this.$offConnect=null),ss()}catch(t){console.warn("主页面事件清理失败:",t)}},methods:{async loadDeviceInfo(){var t;try{const e=S("server.provider");if(!(e==="kv-server"||e==="classworkscloud"))return;const l=await rs.loadNamespaceInfo();if(l&&l.success===!1)return;this.state.namespaceInfo=l||null,this.state.deviceName=((t=l==null?void 0:l.account)==null?void 0:t.deviceName)||""}catch(e){console.warn("加载设备信息失败:",e)}},async loadTokenInfo(){try{const t=S("server.provider");if(!(t==="kv-server"||t==="classworkscloud"))return;const a=S("server.kvToken");if(!a)return;const l=S("server.domain");if(!l)return;const n=await me.get(`${l}/kv/_token`,{headers:{Authorization:`Bearer ${a}`}});this.tokenInfo=n.data,console.log("Token info loaded:",this.tokenInfo)}catch(t){console.warn("Failed to load token info:",t),this.tokenInfo=null}},updateTokenDisplayInfo(){const t=this.$refs.studentNameManager;if(!t||!t.hasToken){this.tokenDisplayInfo.show=!1,this.tokenDisplayInfo.readonly=!1;return}const e=t.displayName,a=t.isReadOnly,l=t.isStudentToken,n=t.isTeacherToken;if(this.tokenDisplayInfo.readonly=a,!l&&!n){this.tokenDisplayInfo.show=!1;return}this.tokenDisplayInfo.text=e,this.tokenDisplayInfo.color="primary",this.tokenDisplayInfo.icon=n?"mdi-school":"mdi-account",this.tokenDisplayInfo.disabled=a,this.tokenDisplayInfo.show=!0},handleTokenChipClick(){console.log("Token chip clicked");const t=this.$refs.studentNameManager;console.log("Manager:",t),console.log("Is student token:",t==null?void 0:t.isStudentToken),console.log("Is teacher token:",t==null?void 0:t.isTeacherToken),t&&(t.isStudentToken||t.isTeacherToken)?(console.log("Opening dialog..."),t.openDialog()):console.log("Cannot open dialog - conditions not met")},ensureDate(t){if(t instanceof Date)return t;if(typeof t=="string"){const e=new Date(t);if(!isNaN(e.getTime()))return e}return new Date},formatDate(t){const e=this.ensureDate(t),a=e.getFullYear(),l=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${a}${l}${n}`},formatTime(t){return t?new Date(t).toLocaleString():""},getToday(){return new Date},async initializeData(){this.parsePreconfigData();const t=await this.parseUrlConfig(),a=new URLSearchParams(window.location.search).get("date"),l=this.getToday();let n=l;if(a){if(/^\d{8}$/.test(a)){const o=a.substring(0,4),d=a.substring(4,6),m=a.substring(6,8);n=new Date(`${o}-${d}-${m}`)}else n=new Date(a);isNaN(n.getTime())&&(n=l)}if(this.state.dateString=this.formatDate(n),this.state.selectedDate=this.state.dateString,this.state.selectedDateObj=n,this.state.isToday=this.formatDate(n)===this.formatDate(l),!t){this.provider=S("server.provider");const o=S("server.classNumber");this.state.classNumber=o}await Promise.all([this.downloadData(),this.loadConfig()]),await this.examStore.fetchExamList();for(const o of this.examStore.examList)this.examStore.fetchExam(o.id);this.checkUpcomingExams()},async checkUpcomingExams(){this.upcomingExams=await this.examStore.getUpcomingExams()},loadExamCards(){},saveExamCards(){},addExamCard(t,e=!1,a=!1){const l=`exam-${t}`;!e&&this.state.boardData.homework[l]?delete this.state.boardData.homework[l]:this.state.boardData.homework[l]={type:"exam",examId:t,name:"考试安排",content:""},this.state.synced=!1,a||this.trySave(!0)},openExamDetail(t){this.selectedExamId=t,this.showExamDetailDialog=!0},removeCurrentExamCard(){this.selectedExamId&&(this.addExamCard(this.selectedExamId),this.showExamDetailDialog=!1)},async onExamConfigSaved(){this.selectedExamId&&(delete this.examStore.exams[this.selectedExamId],await this.examStore.fetchExam(this.selectedExamId),this.$message.success("保存成功","考试配置已更新"))},onExamConfigDeleted(){this.removeCurrentExamCard(),this.$message.success("删除成功","考试配置已删除")},isExamCardAdded(t){return!!this.state.boardData.homework[`exam-${t}`]},removeExamCard(t){},addAllUpcomingExams(){let t=0;for(const e of this.upcomingExams)this.isExamCardAdded(e.id)||(this.addExamCard(e.id,!0,!0),t++);t>0?(this.trySave(!0),this.$message.success("添加成功",`已添加 ${t} 个考试安排`)):this.$message.info("提示","所有考试已添加")},async downloadData(t=!1){var e,a,l;if(!this.loading.download)try{this.loading.download=!0;const n=await Z.loadData("classworks-data-"+this.state.dateString);if(n.success==!1)if(n.error.code==="NOT_FOUND")this.state.showNoDataMessage=!0,this.state.noDataMessage=n.error.message,(t||!this.state.boardData||!this.state.boardData.homework&&!this.state.boardData.attendance)&&(this.state.boardData={homework:{},attendance:{absent:[],late:[],exclude:[]}});else throw new Error(n.error.message);else this.state.boardData={homework:n.homework||{},attendance:{absent:((e=n.attendance)==null?void 0:e.absent)||[],late:((a=n.attendance)==null?void 0:a.late)||[],exclude:((l=n.attendance)==null?void 0:l.exclude)||[]}},this.state.synced=!0,this.state.showNoDataMessage=!1,this.$message.success("下载成功","数据已更新")}catch(n){console.error("数据加载失败:",n),this.$message.error("下载失败",n.message),(t||!this.state.boardData||!this.state.boardData.homework&&!this.state.boardData.attendance)&&(this.state.boardData={homework:{},attendance:{absent:[],late:[],exclude:[]}})}finally{this.loading.download=!1}},async trySave(t=!1){if(t&&!this.canAutoSave)return this.shouldShowBlockedMessage&&this.showMessage("需要手动保存","已禁止自动保存非当天数据","warning"),!1;if(!t&&this.needConfirmSave)try{await this.showConfirmDialog()}catch{return!1}try{return await this.uploadData(),!0}catch(e){return this.$message.error("保存失败",e.message||"请重试"),!1}},async handleClose(){var a;if(!this.currentEditSubject)return;const t=this.state.textarea.trim(),e=((a=this.state.boardData.homework[this.currentEditSubject])==null?void 0:a.content)||"";if(t!==e.trim()){if(!t&&this.currentEditSubject.startsWith("custom-")){delete this.state.boardData.homework[this.currentEditSubject],this.state.synced=!1,this.autoSave&&await this.trySave(!0),this.state.dialogVisible=!1;return}this.state.boardData.homework[this.currentEditSubject].type==="custom"?this.state.boardData.homework[this.currentEditSubject].content=t:this.state.boardData.homework[this.currentEditSubject]={content:t},this.state.synced=!1,this.autoSave&&await this.trySave(!0)}this.state.dialogVisible=!1},async uploadData(){if(!this.loading.upload)try{this.loading.upload=!0;const t=await Z.saveData("classworks-data-"+this.state.dateString,this.state.boardData);if(t.success==!1)throw new Error(t.error.message);this.state.synced=!0,this.$message.success(t.message||"保存成功")}finally{this.loading.upload=!1}},async loadConfig(){try{try{const t=await Z.loadData("classworks-list-main");t.success!=!1&&Array.isArray(t)&&(this.state.studentList=t.map(e=>e.name))}catch(t){console.warn("Failed to load student list from dedicated key, falling back to config",t)}await this.loadSubjects()}catch(t){console.error("加载配置失败:",t),this.$message.error("加载配置失败",t.message)}},async loadSubjects(){try{const t=await Z.loadData("classworks-config-subject");t&&Array.isArray(t)&&(this.state.availableSubjects=t)}catch(t){console.warn("Failed to load subject configuration:",t)}},showSyncMessage(){this.$message.success("数据已同步","数据已完成与服务器同步")},async openDialog(t){var e;if(this.isEditingDisabled){const a=this.$refs.studentNameManager;a!=null&&a.isReadOnly?this.$message.warning("无法编辑","当前使用的是只读令牌"):this.canEditCurrentDate?this.$message.warning("无法编辑","数据加载中,请稍候"):this.$message.warning("无法编辑","已禁止编辑过往数据");return}if(t.startsWith("custom-")){this.currentEditSubject=t,this.state.dialogTitle=this.state.boardData.homework[t].name,this.state.textarea=this.state.boardData.homework[t].content,this.state.dialogVisible=!0;return}if(this.refreshBeforeEdit)try{await this.downloadData()}catch(a){console.error("刷新数据失败:",a),this.$message.error("刷新数据失败,可能显示的不是最新数据")}this.currentEditSubject=t,this.state.boardData.homework[t]||(this.state.boardData.homework[t]={content:""}),this.state.dialogTitle=((e=this.state.availableSubjects.find(a=>a.name===t))==null?void 0:e.name)||t,this.state.textarea=this.state.boardData.homework[t].content,this.state.dialogVisible=!0},async handleHomeworkSave(t){this.currentEditSubject&&(this.state.boardData.homework[this.currentEditSubject].type==="custom"?this.state.boardData.homework[this.currentEditSubject].content=t:this.state.boardData.homework[this.currentEditSubject]={content:t},this.state.synced=!1,this.autoSave&&await this.trySave(!0))},setAttendanceArea(){if(this.isEditingDisabled){this.handleDisabledClick();return}this.state.attendanceDialog=!0},handleDisabledClick(){const t=this.$refs.studentNameManager;t!=null&&t.isReadOnly?this.$message.warning("无法编辑","当前使用的是只读令牌"):this.canEditCurrentDate?this.$message.warning("无法编辑","数据加载中,请稍候"):this.$message.warning("无法编辑","已禁止编辑过往数据")},zoom(t){t==="up"&&this.state.fontSize<100?this.state.fontSize+=2:t==="out"&&this.state.fontSize>16&&(this.state.fontSize-=2),this.state.contentStyle={"font-size":`${this.state.fontSize}px`},re("font.size",this.state.fontSize)},updateBackendUrl(){const t=S("server.provider"),e=S("server.classNumber");this.provider=t,this.state.classNumber=e},setupAutoRefresh(){const t=S("refresh.auto"),e=S("refresh.interval");this.state.refreshInterval&&clearInterval(this.state.refreshInterval),t&&(this.state.refreshInterval=setInterval(()=>{this.shouldSkipRefresh()||(this.downloadData(),this.loadPersistentNotifications())},e*1e3))},shouldSkipRefresh(){return!!(this.state.dialogVisible||this.state.attendanceDialog||this.confirmDialog.show||this.state.datePickerDialog||this.loading.upload||this.loading.download||!this.state.synced)},updateSettings(){this.state.fontSize=S("font.size"),this.state.contentStyle={"font-size":`${this.state.fontSize}px`},this.setupAutoRefresh(),this.updateBackendUrl(),this.loadDeviceInfo(),this.loadTokenInfo(),this.settingsTick++},async handleDateSelect(t){if(t)try{const e=this.ensureDate(t),a=this.formatDate(e);if(a===this.state.dateString)return;this.state.dateString=a,this.state.selectedDate=a,this.state.selectedDateObj=e,this.state.isToday=a===this.formatDate(this.getToday()),await Promise.all([this.downloadData(!0),this.loadSubjects()])}catch(e){console.error("Date processing error:",e),this.$message.error("日期处理错误","请重新选择日期")}},setupRealtimeChannel(){try{const t=S("server.kvToken");if(!t){console.warn("未配置 KV Token无法加入实时频道");return}wt(),We(t),this.$offConnect=ts(()=>We(t)),this.debouncedRealtimeRefresh||(this.debouncedRealtimeRefresh=He(async()=>{var h,k,I;const l=JSON.parse(JSON.stringify(this.state.boardData.homework));await this.downloadData();const n=new Date,o=String(n.getHours()).padStart(2,"0"),d=String(n.getMinutes()).padStart(2,"0"),m=String(n.getSeconds()).padStart(2,"0");(h=this.$message)==null||h.info("数据已更新",`已于 ${o}:${d}:${m} 自动刷新`);const f={};for(const F in this.state.boardData.homework){const H=((k=l[F])==null?void 0:k.content)||"",N=((I=this.state.boardData.homework[F])==null?void 0:I.content)||"";H!==N&&(f[F]=!0)}for(const F in l)this.state.boardData.homework[F]||(f[F]=!0);this.highlightedCards=f,setTimeout(()=>{this.highlightedCards={}},1e4)},800));const e=l=>{var o;if(!l)return;if(l.key==="notification-list"){this.loadPersistentNotifications();return}const n=`classworks-data-${this.state.dateString}`;l.key===n&&(l.action!=="upsert"&&l.action!=="delete"||(o=this.debouncedRealtimeRefresh)==null||o.call(this,l.key))},a=l=>{let n=l;l.content&&l.timestamp&&(n={uuid:l.senderId||"realtime",key:l.content.key,action:l.content.action,created:l.content.created,updatedAt:l.content.updatedAt||l.timestamp,deletedAt:l.content.deletedAt,batch:l.content.batch}),e(n)};this.$offKvChanged=ce("kv-key-changed",a),this.deviceEventHandler=Ct({onKvChanged:e,enableLegacySupport:!0}),this.$offDeviceEvent=ce("device-event",this.deviceEventHandler)}catch(t){console.warn("实时频道初始化失败",t)}},async saveAttendance(){try{await this.trySave(!0),this.state.attendanceDialog=!1}catch(t){console.error("保存出勤状态失败:",t),this.$message.error("保存失败","请重试")}},showMessage(t,e="",a="success"){this.$message[a](t,e)},updateSortedItemsCache(t,e){this._sortedItemsCache={key:t,value:e}},addTestCard(){const t=Date.now().toString();this.state.boardData.homework[`custom-${t}`]={name:"测试卡片",content:`这是一个测试卡片
可以用来测试布局`,type:"custom"},this.state.synced=!1},showConfirmDialog(){return new Promise((t,e)=>{this.confirmDialog={show:!0,resolve:()=>{this.confirmDialog.show=!1,t()},reject:()=>{this.confirmDialog.show=!1,e(new Error("用户取消保存"))}}})},confirmSave(){this.confirmDialog.show=!1,this.confirmDialog.resolve&&this.confirmDialog.resolve(!0)},cancelSave(){this.confirmDialog.show=!1,this.confirmDialog.reject&&this.confirmDialog.reject(new Error("用户取消保存"))},async manualUpload(){return this.trySave(!1)},handleAttendanceChange(){this.state.synced=!1,this.debouncedAttendanceSave()},async handleAttendanceDialogClose(t){!t&&!this.state.synced&&await this.trySave(!0)},toggleFullscreen(){this.state.isFullscreen?this.exitFullscreen():this.enterFullscreen()},enterFullscreen(){const t=document.documentElement;t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullScreen?t.webkitRequestFullScreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen&&t.msRequestFullscreen()},exitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen()},fullscreenChangeHandler(){this.state.isFullscreen=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)},openRandomPicker(){this.$refs.randomPicker&&this.$refs.randomPicker.open()},checkHashForRandomPicker(){window.location.hash==="#random-picker"&&this.$nextTick(()=>{console.log("打开随机点名"),window.location.hash="",this.openRandomPicker()})},parseUrlConfig(){try{const e=new URLSearchParams(window.location.search).get("config");if(!e)return!1;try{const a=atob(e),l=Uint8Array.from(a,h=>h.charCodeAt(0)),n=new TextDecoder().decode(l),o=JSON.parse(n);console.log("从URL读取配置:",o);const d=[],m={},f={};return this.processSpecialSettings(o,d,m),this.processStandardSettings(o,d,m,f),Object.keys(m).length===0?(console.log("URL配置与当前配置相同无需应用"),!1):new Promise(h=>{this.urlConfigDialog={show:!0,config:o,changes:d,validSettings:m,icons:f,confirmHandler:()=>{this.urlConfigDialog.show=!1,this.applyUrlConfig(m),h(!0)},cancelHandler:()=>{this.urlConfigDialog.show=!1,h(!1)}}})}catch(a){return console.error("解析URL配置错误:",a),this.$message.error("URL配置错误","无法解析配置数据"),!1}}catch(t){return console.error("处理URL配置错误:",t),!1}},processSpecialSettings(t,e,a){var l,n;if(t.classNumber!==void 0){const o=S("server.classNumber");t.classNumber!==o&&(e.push({key:"server.classNumber",name:"班级",oldValue:o,newValue:t.classNumber,description:((l=Ne["server.classNumber"])==null?void 0:l.description)||"班级编号",icon:((n=Ne["server.classNumber"])==null?void 0:n.icon)||"mdi-account-group"}),a["server.classNumber"]=t.classNumber)}t.date!==void 0&&t.date!==this.state.dateString&&(e.push({key:"date",name:"日期",oldValue:this.state.dateString,newValue:t.date,description:"查看的日期",icon:"mdi-calendar"}),a.date=t.date),t.subjects&&Array.isArray(t.subjects)&&(e.push({key:"subjects",name:"科目列表",oldValue:`${this.state.availableSubjects.length}个科目`,newValue:`${t.subjects.length}个科目`,description:"可用科目列表",icon:"mdi-notebook"}),a.subjects=t.subjects)},processStandardSettings(t,e,a,l){Object.entries(t).forEach(([n,o])=>{if(["classNumber","date","subjects"].includes(n))return;let d=n,m=Ne[n];if(!m&&!n.includes(".")){const f=["server.","display.","theme.","edit.","refresh.","font.","randomPicker."];for(const h of f){const k=`${h}${n}`;if(Ne[k]){d=k,m=Ne[k];break}}}if(m){let f=this.convertValueToCorrectType(o,m.type);if(m.validate&&!m.validate(f)){console.warn(`URL配置项 ${d} 的值无效: ${o}`);return}const h=S(d);f!==h&&(e.push({key:d,name:this.getSettingDisplayName(d),oldValue:this.formatSettingValue(h),newValue:this.formatSettingValue(f),description:m.description||d,icon:m.icon||"mdi-cog"}),a[d]=f,l[d]=m.icon||"mdi-cog")}else e.push({key:n,name:this.getSettingDisplayName(n),oldValue:"未知",newValue:this.formatSettingValue(o),description:"自定义配置项",icon:"mdi-cog-outline"}),a[n]=o,l[n]="mdi-cog-outline"})},convertValueToCorrectType(t,e){return e==="boolean"?!!t:e==="number"?Number(t):String(t)},formatSettingValue(t){return typeof t=="boolean"?t?"开启":"关闭":t===""||t===null||t===void 0?"空":t.toString()},getSettingDisplayName(t){const e=t.split("."),a=e[e.length-1];return{provider:"数据提供方",domain:"服务器域名",classNumber:"班级编号",emptySubjectDisplay:"空科目显示方式",dynamicSort:"动态排序",showRandomButton:"随机按钮",showFullscreenButton:"全屏按钮",cardHoverEffect:"卡片悬浮效果",enhancedTouchMode:"增强触摸模式",showAntiScreenBurnCard:"防烧屏卡片",mode:"主题模式",size:"字体大小",autoSave:"自动保存",blockNonTodayAutoSave:"禁止自动保存非当日",refreshBeforeEdit:"编辑前刷新",confirmNonTodaySave:"非当日保存确认",auto:"自动刷新",interval:"刷新间隔"}[a]||a},safeBase64Decode(t){try{return _t.decode(t)}catch(e){throw console.error("Base64解码错误:",e),new Error("无法解码配置数据")}},applyUrlConfig(t){for(const[e,a]of Object.entries(t)){if(e==="date"){this.handleDateSelect(a);continue}if(e==="subjects"){this.state.availableSubjects=a;continue}re(e,a),e==="server.classNumber"&&(this.state.classNumber=a)}return this.updateBackendUrl(),this.$message.success("URL配置已应用","已从URL加载配置"),!0},navigateDay(t){const e=new Date(this.state.selectedDateObj);e.setDate(e.getDate()+t),this.handleDateSelect(e)},async copyHomeworkToToday(){if(!this.loading.copyToToday)try{this.loading.copyToToday=!0;const t=this.state.dateString,e=JSON.parse(JSON.stringify(this.state.boardData.homework)),a=this.getToday(),l=this.formatDate(a);this.state.dateString=l,await this.downloadData();const n={};for(const d in e)e[d]&&e[d].content&&(e[d].type==="custom"?n[d]=JSON.parse(JSON.stringify(e[d])):n[d]={content:e[d].content});this.state.boardData.homework=n,this.state.synced=!1,await this.uploadData(),this.state.selectedDate=l,this.state.selectedDateObj=a,this.state.isToday=!0;const o=new URL(window.location);o.searchParams.delete("date"),window.history.pushState({},"",o),this.$message.success("复制成功",`已将 ${t} 的作业内容复制到今天(已替换原有作业)`)}catch(t){console.error("复制作业失败:",t),this.$message.error("复制失败",t.message||"请重试")}finally{this.loading.copyToToday=!1}},parsePreconfigData(){try{const t=new URLSearchParams(window.location.search),e=t.get("namespace"),a=t.get("authCode")||t.get("auth_code"),l=t.get("autoExecute")||t.get("auto_execute");e&&(this.preconfigData.namespace=e,this.preconfigData.authCode=a,this.preconfigData.autoOpen=!0,this.preconfigData.autoExecute=this.parseBoolean(l),console.log("检测到预配数据:",{namespace:this.preconfigData.namespace,hasAuthCode:!!this.preconfigData.authCode,autoExecute:this.preconfigData.autoExecute}),this.cleanupUrlParams(["namespace","authCode","auth_code","autoExecute","auto_execute"]))}catch(t){console.error("解析预配数据失败:",t)}},parseBoolean(t){if(!t)return!1;const e=t.toLowerCase();return e==="true"||e==="1"||e==="yes"},cleanupUrlParams(t){try{const e=new URL(window.location);let a=!1;t.forEach(l=>{e.searchParams.has(l)&&(e.searchParams.delete(l),a=!0)}),a&&window.history.replaceState({},document.title,e.toString())}catch(e){console.error("清理URL参数失败:",e)}},async loadPersistentNotifications(){try{const t=await Z.loadData("notification-list");t&&Array.isArray(t)?this.persistentNotifications=t:t&&t.success!==!1&&Array.isArray(t.data)?this.persistentNotifications=t.data:this.persistentNotifications=[]}catch(t){console.error("加载常驻通知失败",t)}},showNotificationDetail(t){this.currentNotification=t,this.notificationDetailDialog=!0},async removePersistentNotification(t){this.persistentNotifications=this.persistentNotifications.filter(a=>a.id!==t);const e=this.persistentNotifications.length>0?this.persistentNotifications:{};await Z.saveData("notification-list",e),this.notificationDetailDialog=!1}}},Ko={key:2,class:"d-flex"},qo={class:"text-h6 text-truncate font-weight-bold"},Wo={class:"text-h4 font-weight-medium mb-4",style:{"line-height":"1.5"}},Go={class:"text-subtitle-1 text-grey"},Qo={class:"d-flex align-center flex-wrap"},Jo={class:"text-subtitle-1"},Yo={class:"text-grey-darken-1"},Xo={class:"text-primary font-weight-medium"},Zo={key:1,class:"text-center py-4 text-grey"};function el(t,e,a,l,n,o){const d=Bt,m=Ot,f=Rt,h=$t,k=Mt,I=zt,F=Ut,H=At,N=St,K=Vt,Q=Nt,ge=Re,pe=Et,te=Tt,se=pt;return c(),p(E,null,[s(us,{class:"no-select"},{append:i(()=>[n.tokenDisplayInfo.readonly?(c(),b(O,{key:0,class:"mx-2",color:"warning","prepend-icon":"mdi-lock-alert",variant:"tonal"},{default:i(()=>[...e[29]||(e[29]=[u(" 只读 ",-1)])]),_:1})):w("",!0),n.tokenDisplayInfo.show?(c(),b(O,{key:1,style:he({cursor:n.tokenDisplayInfo.disabled?"default":"pointer"}),class:"mx-2",color:"primary","prepend-icon":"mdi-account",variant:"tonal",onClick:o.handleTokenChipClick},{default:i(()=>[u(g(n.tokenDisplayInfo.text),1)]),_:1},8,["style","onClick"])):w("",!0),o.shouldShowUrgentTestButton?(c(),b(y,{key:2,"prepend-icon":"mdi-chat",onClick:e[0]||(e[0]=C=>n.urgentTestDialog=!0),variant:"tonal"},{default:i(()=>[...e[30]||(e[30]=[u("发送通知",-1)])]),_:1})):w("",!0),s(y,{icon:"mdi-chat",variant:"text",onClick:e[1]||(e[1]=C=>n.isChatOpen=!0)}),s(y,{badge:o.unreadCount||void 0,"badge-color":o.unreadCount?"error":void 0,icon:"mdi-bell",variant:"text",onClick:e[2]||(e[2]=C=>t.$refs.messageLog.drawer=!0)},null,8,["badge","badge-color"]),s(y,{icon:"mdi-cog",variant:"text",onClick:e[3]||(e[3]=C=>t.$router.push("/settings"))})]),default:i(()=>[s(ds,null,{default:i(()=>[u(g(o.titleText),1)]),_:1}),s(L)]),_:1}),o.shouldShowInit?(c(),b(d,{key:0,preconfig:n.preconfigData,onDone:e[4]||(e[4]=C=>n.settingsTick++)},null,8,["preconfig"])):w("",!0),o.shouldShowInit?w("",!0):(c(),b(m,{key:1,ref:"studentNameManager",onTokenInfoUpdated:o.updateTokenDisplayInfo},null,8,["onTokenInfoUpdated"])),o.shouldShowInit?w("",!0):(c(),p("div",Ko,[s(Dt,{class:"main-window flex-grow-1 no-select bloom-container",fluid:""},{default:i(()=>[n.persistentNotifications.length>0?(c(),b(ue,{key:0,class:"mb-4"},{default:i(()=>[s(ne,{cols:"12"},{default:i(()=>[(c(!0),p(E,null,U(n.persistentNotifications,C=>(c(),b(_,{key:C.id,color:C.isUrgent?"error":"primary",class:"mb-2 cursor-pointer",variant:"tonal",onClick:z=>o.showNotificationDetail(C)},{default:i(()=>[s(V,{class:"d-flex align-center py-3"},{default:i(()=>[r("span",qo,g(C.message),1),s(L),s(y,{icon:"mdi-chevron-right",variant:"text"})]),_:2},1024)]),_:2},1032,["color","onClick"]))),128))]),_:1})]),_:1})):w("",!0),s(J,{modelValue:n.notificationDetailDialog,"onUpdate:modelValue":e[8]||(e[8]=C=>n.notificationDetailDialog=C),"max-width":"700",scrollable:""},{default:i(()=>[n.currentNotification?(c(),b(_,{key:0,class:"rounded-xl"},{default:i(()=>[s(j,{class:"d-flex align-center pa-4 text-h5"},{default:i(()=>[r("span",{class:fe([n.currentNotification.isUrgent?"text-error":"","font-weight-bold"])},g(n.currentNotification.isUrgent?"强调通知":"通知详情"),3),s(L),s(y,{icon:"mdi-close",variant:"text",onClick:e[5]||(e[5]=C=>n.notificationDetailDialog=!1)})]),_:1}),s(ve),s(V,{class:"pa-6"},{default:i(()=>[r("div",Wo,g(n.currentNotification.message),1),r("div",Go," 发布时间:"+g(o.formatTime(n.currentNotification.timestamp)),1)]),_:1}),s(ve),s(X,{class:"pa-4"},{default:i(()=>[s(y,{color:"error","prepend-icon":"mdi-delete",size:"x-large",variant:"tonal",class:"px-6",onClick:e[6]||(e[6]=C=>o.removePersistentNotification(n.currentNotification.id))},{default:i(()=>[...e[31]||(e[31]=[u(" 删除通知 ",-1)])]),_:1}),s(L),s(y,{color:"primary",size:"x-large",variant:"elevated",class:"px-8",onClick:e[7]||(e[7]=C=>n.notificationDetailDialog=!1)},{default:i(()=>[...e[32]||(e[32]=[u(" 关闭 ",-1)])]),_:1})]),_:1})]),_:1})):w("",!0)]),_:1},8,["modelValue"]),s(f,{"sorted-items":o.sortedItems,"unused-subjects":o.unusedSubjects,"empty-subject-display":o.emptySubjectDisplay,"is-mobile":o.isMobile,"is-editing-disabled":o.isEditingDisabled,"content-style":n.state.contentStyle,"highlighted-cards":n.highlightedCards,onOpenDialog:o.openDialog,onOpenAttendance:o.setAttendanceArea,onDisabledClick:o.handleDisabledClick,onOpenExamDetail:o.openExamDetail},null,8,["sorted-items","unused-subjects","empty-subject-display","is-mobile","is-editing-disabled","content-style","highlighted-cards","onOpenDialog","onOpenAttendance","onDisabledClick","onOpenExamDetail"]),s(h,{synced:n.state.synced,"loading-upload":n.loading.upload,"show-random-picker-button":o.showRandomPickerButton,"show-exam-schedule-button":o.showExamScheduleButton,"show-list-card-button":o.showListCardButton,"show-fullscreen-button":o.showFullscreenButton,"is-fullscreen":n.state.isFullscreen,"show-anti-screen-burn-card":o.showAntiScreenBurnCard,"show-test-card-button":o.showTestCardButton,onUpload:o.manualUpload,onShowSyncMessage:o.showSyncMessage,onOpenRandomPicker:o.openRandomPicker,onToggleFullscreen:o.toggleFullscreen,onAddTestCard:o.addTestCard,onAddExamCard:e[9]||(e[9]=C=>n.showAddExamDialog=!0)},null,8,["synced","loading-upload","show-random-picker-button","show-exam-schedule-button","show-list-card-button","show-fullscreen-button","is-fullscreen","show-anti-screen-burn-card","show-test-card-button","onUpload","onShowSyncMessage","onOpenRandomPicker","onToggleFullscreen","onAddTestCard"]),s(k),n.upcomingExams.length>0&&!o.hasExamCard?(c(),b(_e,{key:1,class:"mt-4",color:"info",variant:"tonal",closable:"",icon:"mdi-calendar-clock",title:"近期有考试安排"},{append:i(()=>[s(y,{color:"primary",variant:"text",onClick:o.addAllUpcomingExams},{default:i(()=>[...e[34]||(e[34]=[u(" 一键添加 ",-1)])]),_:1},8,["onClick"])]),default:i(()=>[r("div",Qo,[e[33]||(e[33]=r("span",{class:"mr-2"},"检测到未来两天内有以下考试:",-1)),(c(!0),p(E,null,U(n.upcomingExams,C=>(c(),b(O,{key:C.id,size:"small",class:"mr-1 mb-1",color:"primary"},{default:i(()=>[u(g(C.examName),1)]),_:2},1024))),128))])]),_:1})):w("",!0)]),_:1}),o.isMobile?w("",!0):(c(),b(I,{key:0,"student-list":n.state.studentList,attendance:n.state.boardData.attendance,"is-editing-disabled":o.isEditingDisabled,onClick:o.setAttendanceArea,onDisabledClick:o.handleDisabledClick},null,8,["student-list","attendance","is-editing-disabled","onClick","onDisabledClick"]))])),s(F,{modelValue:n.state.dialogVisible,"onUpdate:modelValue":e[10]||(e[10]=C=>n.state.dialogVisible=C),"auto-save":o.autoSave,"initial-content":n.state.textarea,title:n.state.dialogTitle,"is-editing-past-data":o.isEditingPastData,"current-date-string":n.state.dateString,onSave:o.handleHomeworkSave},null,8,["modelValue","auto-save","initial-content","title","is-editing-past-data","current-date-string","onSave"]),s(Xt,{modelValue:n.state.snackbar,"onUpdate:modelValue":e[11]||(e[11]=C=>n.state.snackbar=C),timeout:2e3},{default:i(()=>[u(g(n.state.snackbarText),1)]),_:1},8,["modelValue"]),s(H,{modelValue:n.state.attendanceDialog,"onUpdate:modelValue":e[12]||(e[12]=C=>n.state.attendanceDialog=C),"student-list":n.state.studentList,attendance:n.state.boardData.attendance,"date-string":n.state.dateString,onSave:o.saveAttendance,onChange:o.handleAttendanceChange},null,8,["modelValue","student-list","attendance","date-string","onSave","onChange"]),s(N,{ref:"messageLog"},null,512),s(K,{"is-today":o.isToday,loading:n.loading.download,"copy-to-today-loading":n.loading.copyToToday,"selected-date":n.state.selectedDateObj,"unread-count":o.unreadCount,onRefresh:o.downloadData,onZoom:o.zoom,onOpenMessages:e[13]||(e[13]=C=>t.$refs.messageLog.drawer=!0),onOpenSettings:e[14]||(e[14]=C=>t.$router.push("/settings")),onDateSelect:o.handleDateSelect,onPrevDay:e[15]||(e[15]=C=>o.navigateDay(-1)),onNextDay:e[16]||(e[16]=C=>o.navigateDay(1)),onCopyToToday:o.copyHomeworkToToday},null,8,["is-today","loading","copy-to-today-loading","selected-date","unread-count","onRefresh","onZoom","onDateSelect","onCopyToToday"]),s(Q),s(ge,{modelValue:n.isChatOpen,"onUpdate:modelValue":e[17]||(e[17]=C=>n.isChatOpen=C),"show-button":!1},null,8,["modelValue"]),s(pe,{modelValue:n.urgentTestDialog,"onUpdate:modelValue":e[18]||(e[18]=C=>n.urgentTestDialog=C)},null,8,["modelValue"]),s(J,{modelValue:n.confirmDialog.show,"onUpdate:modelValue":e[19]||(e[19]=C=>n.confirmDialog.show=C),"max-width":"400"},{default:i(()=>[s(_,null,{default:i(()=>[s(j,{class:"text-h6"},{default:i(()=>[...e[35]||(e[35]=[u(" 确认保存",-1)])]),_:1}),s(V,null,{default:i(()=>[u(" 您正在修改 "+g(n.state.dateString)+" 的数据,确定要保存吗? ",1)]),_:1}),s(X,null,{default:i(()=>[s(L),s(y,{color:"grey",variant:"text",onClick:n.confirmDialog.reject},{default:i(()=>[...e[36]||(e[36]=[u(" 取消 ",-1)])]),_:1},8,["onClick"]),s(y,{color:"primary",onClick:n.confirmDialog.resolve},{default:i(()=>[...e[37]||(e[37]=[u(" 确认保存",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),s(te,{ref:"randomPicker",attendance:n.state.boardData.attendance,"student-list":n.state.studentList},null,8,["attendance","student-list"]),s(J,{modelValue:n.urlConfigDialog.show,"onUpdate:modelValue":e[20]||(e[20]=C=>n.urlConfigDialog.show=C),"max-width":"500"},{default:i(()=>[s(_,null,{default:i(()=>[s(j,{class:"text-h6"},{default:i(()=>[...e[38]||(e[38]=[u(" 确认应用URL配置",-1)])]),_:1}),s(V,null,{default:i(()=>[e[39]||(e[39]=r("p",null,"以下配置将应用于当前班级:",-1)),s(we,{density:"compact"},{default:i(()=>[(c(!0),p(E,null,U(n.urlConfigDialog.changes,C=>(c(),b(Se,{key:C.key},{prepend:i(()=>[s(D,{icon:C.icon,class:"mr-2",size:"small"},null,8,["icon"])]),default:i(()=>[s($e,{class:"d-flex align-center"},{default:i(()=>[r("span",Jo,g(C.name),1),s(Ze,{activator:"parent",location:"top"},{default:i(()=>[u(g(C.description||C.key),1)]),_:2},1024)]),_:2},1024),s(Pe,null,{default:i(()=>[r("span",Yo,g(C.oldValue),1),s(D,{class:"mx-1",icon:"mdi-arrow-right",size:"small"}),r("span",Xo,g(C.newValue),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1}),s(X,null,{default:i(()=>[s(L),s(y,{color:"grey",variant:"text",onClick:n.urlConfigDialog.cancelHandler},{default:i(()=>[...e[40]||(e[40]=[u(" 取消 ",-1)])]),_:1},8,["onClick"]),s(y,{color:"primary",onClick:n.urlConfigDialog.confirmHandler},{default:i(()=>[...e[41]||(e[41]=[u(" 确认应用 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),s(J,{modelValue:n.showExamDetailDialog,"onUpdate:modelValue":e[23]||(e[23]=C=>n.showExamDetailDialog=C),persistent:"",fullscreen:""},{default:i(()=>[n.selectedExamId?(c(),b(_,{key:0},{default:i(()=>[s(j,{class:"d-flex align-center pa-4"},{default:i(()=>[e[42]||(e[42]=u(" 编辑考试配置 ",-1)),s(L),s(y,{icon:"mdi-close",variant:"text",onClick:e[21]||(e[21]=C=>n.showExamDetailDialog=!1)})]),_:1}),s(V,{class:"pa-4",style:{"max-height":"70vh","overflow-y":"auto"}},{default:i(()=>[s(se,{"config-id":n.selectedExamId,"dialog-mode":!0,onSaved:o.onExamConfigSaved,onDeleted:o.onExamConfigDeleted},null,8,["config-id","onSaved","onDeleted"])]),_:1}),s(ve),s(X,{class:"pa-4"},{default:i(()=>[s(y,{color:"error","prepend-icon":"mdi-delete",variant:"tonal",onClick:o.removeCurrentExamCard},{default:i(()=>[...e[43]||(e[43]=[u(" 移除卡片 ",-1)])]),_:1},8,["onClick"]),s(L),s(y,{color:"primary",variant:"text",onClick:e[22]||(e[22]=C=>n.showExamDetailDialog=!1)},{default:i(()=>[...e[44]||(e[44]=[u(" 关闭 ",-1)])]),_:1})]),_:1})]),_:1})):w("",!0)]),_:1},8,["modelValue"]),s(J,{modelValue:n.showAddExamDialog,"onUpdate:modelValue":e[25]||(e[25]=C=>n.showAddExamDialog=C),"max-width":"500"},{default:i(()=>[s(_,null,{default:i(()=>[s(j,{class:"text-h6"},{default:i(()=>[...e[45]||(e[45]=[u("预览考试看板",-1)])]),_:1}),s(V,null,{default:i(()=>[l.examStore.examList.length>0?(c(),b(we,{key:0},{default:i(()=>[(c(!0),p(E,null,U(l.examStore.examList,C=>{var z;return c(),b(Se,{key:C.id,title:((z=l.examStore.exams[C.id])==null?void 0:z.examName)||C.id,subtitle:C.id,onClick:x=>o.addExamCard(C.id)},{prepend:i(()=>[s(D,{color:"primary"},{default:i(()=>[...e[46]||(e[46]=[u("mdi-calendar-text",-1)])]),_:1})]),append:i(()=>[s(y,{icon:o.isExamCardAdded(C.id)?"mdi-check":"mdi-plus",color:o.isExamCardAdded(C.id)?"success":"grey",variant:"text"},null,8,["icon","color"])]),_:2},1032,["title","subtitle","onClick"])}),128))]),_:1})):(c(),p("div",Zo," 暂无考试配置 "))]),_:1}),s(X,null,{default:i(()=>[s(L),s(y,{color:"primary",variant:"text",onClick:e[24]||(e[24]=C=>n.showAddExamDialog=!1)},{default:i(()=>[...e[47]||(e[47]=[u("关闭",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),s(J,{modelValue:n.notificationDetailDialog,"onUpdate:modelValue":e[28]||(e[28]=C=>n.notificationDetailDialog=C),"max-width":"600"},{default:i(()=>[n.currentNotification?(c(),b(_,{key:0},{default:i(()=>[s(j,{class:fe(["headline",n.currentNotification.isUrgent?"text-error":"text-primary"])},{default:i(()=>[u(g(n.currentNotification.isUrgent?"强调通知":"通知详情"),1)]),_:1},8,["class"]),s(V,{class:"text-h5 py-4"},{default:i(()=>[u(g(n.currentNotification.message),1)]),_:1}),s(X,null,{default:i(()=>[s(y,{color:"error",variant:"text",onClick:e[26]||(e[26]=C=>o.removePersistentNotification(n.currentNotification.id))},{default:i(()=>[...e[48]||(e[48]=[u("删除",-1)])]),_:1}),s(L),s(y,{color:"primary",onClick:e[27]||(e[27]=C=>n.notificationDetailDialog=!1)},{default:i(()=>[...e[49]||(e[49]=[u("关闭",-1)])]),_:1})]),_:1})]),_:1})):w("",!0)]),_:1},8,["modelValue"]),e[50]||(e[50]=r("br",null,null,-1)),e[51]||(e[51]=r("br",null,null,-1)),e[52]||(e[52]=r("br",null,null,-1))],64)}const _l=W(Ho,[["render",el]]);export{_l as default};