import{V as At,a as Ut,_ as nt}from"./ExamConfigEditor-BwGuxjm4.js";import{_ as $,k as C,s as ne,j as x,o as c,w as i,d as s,l as D,q as P,t as u,v as _,x as A,y,z as V,i as r,A as v,B as b,C as g,D as it,F as I,E as Pe,T as Le,G as N,e as oe,H as O,I as Q,n as le,J as he,K as de,L as Ee,M as K,N as je,O as He,P as be,Q as we,R as $e,S as ge,U as zt,W as Mt,X as Se,Y as Lt,Z as Ft,$ as at,a0 as ot,a1 as lt,a2 as Ae,a3 as Re,a4 as z,a5 as G,a6 as Ie,a7 as rt,a8 as Pt,a9 as Ke,aa as ye,ab as xe,ac as dt,ad as ut,ae as $t,af as ke}from"./index-fC3F-cJK.js";import{V as ve}from"./VTextField-KLIWx9fu.js";import{V as Be,a as Rt}from"./VTooltip-DbcN_UHP.js";import{V as M}from"./VChip-hc5GaWzn.js";import{s as Bt,g as ct,j as Fe,o as ae,a as Ot,l as jt}from"./socketClient-CMGEaEUi.js";import{f as Ht,s as Kt,c as mt}from"./deviceEvents-C_k37z0x.js";import{V as se,a as q}from"./VRow-COO-hEtu.js";import{V as qt,a as qe}from"./VPagination-BWykmTs5.js";import{V as Ce}from"./VTextarea-DU_CKJ5N.js";import{d as W,a as Ue,g as ft,b as me,k as Wt}from"./dataProvider-DPEUUGFk.js";import{V as We,a as Ge,b as Gt,c as Qt}from"./VAppBarTitle-CyWUz1A2.js";import{V as ht}from"./VContainer-TRGIjRva.js";import{V as Qe}from"./VForm-BQ9lEcOg.js";import{V as Je}from"./VSwitch-lJkY0_sF.js";import{V as Jt}from"./filter-BiLGsSY6.js";import{p as Ye,_ as gt}from"./index-B62r3f4I.js";import{V as pe}from"./VAlert-IIhuT1k0.js";import{V as Yt,a as Xe,b as Ze,c as et}from"./VExpansionPanels-CLl_e68m.js";import"./VSkeletonLoader-BF1auzu0.js";import"./VCheckboxBtn-Cyr4glMC.js";import"./VSheet-BF6NEguB.js";const Xt={name:"RandomPicker",props:{studentList:{type:Array,required:!0},attendance:{type:Object,required:!0,default:()=>({absent:[],late:[],exclude:[]})}},data(){return{dialog:!1,count:C("randomPicker.defaultCount"),isPickingStarted:!1,isAnimating:!1,pickedStudents:[],animationStudents:[],highlightedIndices:[],animationTimer:null,getSetting:C,tempFilters:{excludeAbsent:C("randomPicker.excludeAbsent"),excludeLate:C("randomPicker.excludeLate"),excludeExcluded:C("randomPicker.excludeExcluded")},pickerMode:C("randomPicker.mode"),minNumber:C("randomPicker.minNumber"),maxNumber:C("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=C("randomPicker.defaultCount"),this.isPickingStarted=!1,this.isAnimating=!1,this.pickedStudents=[],this.tempFilters={excludeAbsent:C("randomPicker.excludeAbsent"),excludeLate:C("randomPicker.excludeLate"),excludeExcluded:C("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){ne("randomPicker.mode",t)}},minNumber:{handler(t){t>this.maxNumber&&(this.minNumber=this.maxNumber),t<1&&(this.minNumber=1),ne("randomPicker.minNumber",this.minNumber)}},maxNumber:{handler(t){t100&&(this.maxNumber=100),ne("randomPicker.maxNumber",this.maxNumber)}}},methods:{open(){this.dialog=!0},incrementCount(){this.count1&&this.count--},startPicking(){this.filteredStudents.length!==0&&(this.isPickingStarted=!0,C("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.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))}}},Zt={class:"d-flex justify-center align-center counter-container"},es={class:"count-display mx-8"},ts={class:"text-h2 font-weight-bold"},ss={class:"mode-switch-container mt-6"},ns={key:0,class:"number-range-container mt-4"},is={class:"d-flex justify-center align-center gap-4"},as={class:"mt-4"},os={key:1,class:"mt-4 text-error"},ls={class:"mt-4 text-caption"},rs={class:"pa-2"},ds={key:0},us={key:1},cs={key:2},ms={key:1,class:"d-flex flex-wrap justify-center gap-2 mt-4"},fs={key:0,class:"animation-container"},hs={class:"animation-wrapper"},gs={key:1,class:"result-container"},ps={class:"mt-8 d-flex justify-center"};function vs(t,e,a,l,n,o){return c(),x(O,{modelValue:n.dialog,"onUpdate:modelValue":e[8]||(e[8]=d=>n.dialog=d),"fullscreen-breakpoint":"sm","max-width":"600",persistent:""},{default:i(()=>[s(D,{border:"",class:"random-picker-card",rounded:"xl"},{default:i(()=>[s(P,{class:"text-h5 d-flex align-center"},{default:i(()=>[s(_,{class:"mr-2",icon:"mdi-account-question"}),e[9]||(e[9]=u(" 随机点名 ",-1)),s(A),s(y,{icon:"mdi-close",variant:"text",onClick:e[0]||(e[0]=d=>n.dialog=!1)})]),_:1}),n.isPickingStarted?(c(),x(V,{key:1,class:"text-center py-6"},{default:i(()=>[n.isAnimating?(c(),v("div",fs,[r("div",hs,[s(Le,{class:"shuffle-container",name:"shuffle",tag:"div"},{default:i(()=>[(c(!0),v(I,null,N(n.animationStudents,(d,m)=>(c(),v("div",{key:d.id,class:oe([{highlighted:n.highlightedIndices.includes(m)},"student-item"])},g(d.name),3))),128))]),_:1})])])):(c(),v("div",gs,[e[19]||(e[19]=r("div",{class:"text-h6 mb-4"},"抽取结果",-1)),(c(!0),v(I,null,N(n.pickedStudents,(d,m)=>(c(),x(D,{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",ps,[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(),x(V,{key:0,class:"text-center py-6"},{default:i(()=>[e[16]||(e[16]=r("div",{class:"text-h6 mb-4"},"请选择抽取人数",-1)),r("div",Zt,[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",es,[r("span",ts,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",ss,[s(it,{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(),v("div",ns,[e[14]||(e[14]=r("div",{class:"text-subtitle-1 mb-2"},"学号范围设置",-1)),r("div",is,[s(ve,{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(ve,{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"])])])):b("",!0),r("div",as,[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(),v("div",os,[n.pickerMode==="name"?(c(),v(I,{key:0},[u(" 没有可抽取的学生,请调整过滤选项 ")],64)):(c(),v(I,{key:1},[u(" 请设置有效的学号范围 ")],64))])):b("",!0),r("div",ls,[u(" 当前可抽取学生: "+g(o.filteredStudents.length)+"人 ",1),n.pickerMode==="name"?(c(),x(Be,{key:0,location:"bottom"},{activator:i(({props:d})=>[s(_,Pe({class:"ml-1",icon:"mdi-information-outline",size:"small"},d),null,16)]),default:i(()=>[r("div",rs,[n.tempFilters.excludeAbsent?(c(),v("div",ds," • 已排除请假学生 ("+g(o.absentCount)+"人) ",1)):b("",!0),n.tempFilters.excludeLate?(c(),v("div",us," • 已排除迟到学生 ("+g(o.lateCount)+"人) ",1)):b("",!0),n.tempFilters.excludeExcluded?(c(),v("div",cs," • 已排除不参与学生 ("+g(o.excludedCount)+"人) ",1)):b("",!0)])]),_:1})):b("",!0),n.pickerMode==="name"?(c(),v("div",ms,[s(M,{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(M,{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(M,{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"])])):b("",!0)])]),_:1}))]),_:1})]),_:1},8,["modelValue"])}const pt=$(Xt,[["render",vs],["__scopeId","data-v-85e7eea6"]]),ys={name:"EventSender",emits:["sent","error"],methods:{async sendEvent(t,e={}){try{return Bt(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})}}},ks={style:{display:"none"}};function xs(t,e,a,l,n,o){return c(),v("div",ks)}const Ve=$(ys,[["render",xs]]),bs={name:"UrgentNotification",components:{EventSender:Ve},data(){return{visible:!1,notificationQueue:[],currentIndex:0,autoCloseTimer:null,urgentSoundTimer: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)||"未知类型"},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)},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.startUrgentSound()):(this.currentIndex=this.notificationQueue.length-1,this.visible=!0,this.sendDisplayedReceipt(),this.playNotificationSound(),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{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)}},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.visible&&this.isUrgent?this.playNotificationSound():this.stopUrgentSound()},1e3)},stopUrgentSound(){this.urgentSoundTimer&&(clearInterval(this.urgentSoundTimer),this.urgentSoundTimer=null)}}},ws={class:"urgent-title mb-6"},Ss={key:0,class:"navigation-controls mt-6"},Cs={class:"notification-counter mb-3"},Ds={class:"navigation-buttons"},_s={class:"mt-8"};function Ts(t,e,a,l,n,o){const d=Ve;return c(),v(I,null,[s(O,{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(D,{class:"urgent-notification-card",color:o.urgencyColor,elevation:"24"},{default:i(()=>[s(V,null,{default:i(()=>{var m,f;return[r("div",ws,g(((f=(m=o.currentNotification)==null?void 0:m.content)==null?void 0:f.message)||"无内容"),1),s(D,{variant:"flat",color:"white"},{default:i(()=>[s(P,null,{default:i(()=>[...e[1]||(e[1]=[u("发送者信息",-1)])]),_:1}),s(V,null,{default:i(()=>[s(M,{class:"mr-2 mb-2",color:"primary",variant:"outlined",size:"small"},{default:i(()=>[s(_,{left:"",size:"16"},{default:i(()=>[...e[2]||(e[2]=[u(" mdi-account ",-1)])]),_:1}),u(" "+g(o.senderName),1)]),_:1}),s(M,{class:"mr-2 mb-2",color:"info",variant:"outlined",size:"small"},{default:i(()=>[s(_,{left:"",size:"16"},{default:i(()=>[...e[3]||(e[3]=[u(" mdi-devices ",-1)])]),_:1}),u(" "+g(o.deviceType),1)]),_:1}),s(M,{class:"mb-2",color:"success",variant:"outlined",size:"small"},{default:i(()=>{var h;return[s(_,{left:"",size:"16"},{default:i(()=>[...e[4]||(e[4]=[u(" mdi-clock ",-1)])]),_:1}),u(" "+g(o.formatTime((h=o.currentNotification)==null?void 0:h.timestamp)),1)]}),_:1})]),_:1})]),_:1}),o.hasMultipleNotifications?(c(),v("div",Ss,[s(D,{variant:"flat",color:"rgba(255,255,255,0.1)"},{default:i(()=>[s(V,{class:"text-center"},{default:i(()=>[r("div",Cs,[s(M,{color:"white",variant:"flat",size:"small"},{default:i(()=>[u(g(o.notificationCountText),1)]),_:1})]),r("div",Ds,[s(y,{disabled:n.currentIndex===0,color:"white",variant:"outlined",size:"small",onClick:o.previousNotification},{default:i(()=>[s(_,null,{default:i(()=>[...e[5]||(e[5]=[u(" mdi-chevron-left ",-1)])]),_:1}),e[6]||(e[6]=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[8]||(e[8]=u(" 下一个 ",-1)),s(_,null,{default:i(()=>[...e[7]||(e[7]=[u(" mdi-chevron-right ",-1)])]),_:1})]),_:1},8,["disabled","onClick"])])]),_:1})]),_:1})])):b("",!0),r("div",_s,[s(y,{color:"white",size:"large",variant:"flat",onClick:o.close},{default:i(()=>[s(_,{left:""},{default:i(()=>[...e[9]||(e[9]=[u(" mdi-check ",-1)])]),_:1}),e[10]||(e[10]=u(" 我知道了 ",-1))]),_:1},8,["onClick"])])]}),_:1})]),_:1},8,["color"])]),_:1},8,["modelValue"]),s(d,{ref:"eventSender"},null,512)],64)}const vt=$(bs,[["render",Ts],["__scopeId","data-v-e250350b"]]),Is={name:"ChatWidget",components:{UrgentNotification:vt},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!!(C("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=ct();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=C("server.kvToken");e&&Fe(e);const a=h=>(...k)=>{if(!this.isDestroying)try{h(...k)}catch(E){console.error("ChatWidget 事件处理错误:",E)}},l=ae("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=ae("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=mt({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=ae("device-event",this.deviceEventHandler),d=ae("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=ae("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=ae("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}}),Kt(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 Ht(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)}}}},Es={class:"text-subtitle-1"},Vs={key:0,ref:"listRef",class:"messages"},Ns={key:0,class:"divider-row"},As={class:"avatar"},Us={class:"bubble"},zs={key:0,class:"sender-name"},Ms={class:"text"},Ls={class:"meta"},Fs={key:0,class:"device-name"},Ps={key:1,class:"events-container"},$s={class:"event-stats mb-3"},Rs={class:"text-h6"},Bs={class:"text-h6"},Os={class:"text-h6"},js={class:"events-list"},Hs={class:"d-flex align-center mb-1"},Ks={class:"text-caption"},qs={key:0,class:"mb-1 text-caption"},Ws={class:"event-content"},Gs={key:0,class:"chat-content"},Qs={key:1,class:"text-caption event-data"},Js={key:0,class:"text-center text-grey pa-4"},Ys={key:0,class:"pagination mt-2"};function Xs(t,e,a,l,n,o){const d=vt;return c(),v(I,null,[o.showToggleButton?(c(),v("div",{key:0,style:le(o.toggleStyle),class:"chat-toggle"},[s(y,{color:"primary",icon:"",variant:"flat",onClick:e[0]||(e[0]=m=>o.open())},{default:i(()=>[s(Rt,{content:n.unreadCount||void 0,"model-value":n.unreadCount>0,color:"error",overlap:""},{default:i(()=>[s(_,null,{default:i(()=>[...e[7]||(e[7]=[u(" mdi-chat ",-1)])]),_:1})]),_:1},8,["content","model-value"])]),_:1})],4)):b("",!0),Q(r("div",{style:le(o.panelStyle),class:"chat-panel"},[s(D,{border:"",class:"chat-card",elevation:"8"},{default:i(()=>[s(P,{class:"d-flex align-center"},{default:i(()=>[s(_,{class:"mr-2"},{default:i(()=>[...e[8]||(e[8]=[u(" mdi-chat-processing ",-1)])]),_:1}),r("span",Es,g(o.modeTitle),1),s(A),s(it,{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(_,null,{default:i(()=>[...e[9]||(e[9]=[u("mdi-chat",-1)])]),_:1})]),_:1}),s(y,{value:"events",size:"small"},{default:i(()=>[s(_,null,{default:i(()=>[...e[10]||(e[10]=[u("mdi-format-list-bulleted",-1)])]),_:1})]),_:1})]),_:1},8,["modelValue"]),s(Be,{location:"top"},{activator:i(({props:m})=>[s(M,Pe({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(_,null,{default:i(()=>[...e[11]||(e[11]=[u("mdi-close",-1)])]),_:1})]),_:1})]),_:1}),s(de),s(V,{class:"chat-body"},{default:i(()=>[n.currentMode==="chat"?(c(),v("div",Vs,[(c(!0),v(I,null,N(o.decoratedMessages,m=>(c(),v(I,{key:m._id},[m._type==="divider"?(c(),v("div",Ns,[s(de,{class:"my-2"}),e[12]||(e[12]=r("div",{class:"divider-text"}," 今天 - 上次访问 ",-1)),s(de,{class:"my-2"})])):(c(),v("div",{key:1,class:oe([{self:m.self},"message-row"])},[r("div",As,[s(Ee,{color:m.self?"primary":"grey",size:"24"},{default:i(()=>[s(_,{size:"small"},{default:i(()=>[u(g(m.self?"mdi-account":"mdi-account-outline"),1)]),_:2},1024)]),_:2},1032,["color"])]),r("div",Us,[!m.self&&m.deviceName?(c(),v("div",zs,g(m.deviceName),1)):b("",!0),r("div",Ms,g(m.text),1),r("div",Ls,[m.self&&m.deviceName?(c(),v("span",Fs,g(m.deviceName)+" • ",1)):b("",!0),u(" "+g(o.formatTime(m.at)),1)])])],2))],64))),128))],512)):(c(),v("div",Ps,[r("div",$s,[s(se,{dense:""},{default:i(()=>[s(q,{cols:"4"},{default:i(()=>[s(D,{color:"success",dark:"",size:"small"},{default:i(()=>[s(V,{class:"text-center pa-2"},{default:i(()=>[r("div",Rs,g(n.eventStats.chat),1),e[13]||(e[13]=r("div",{class:"text-caption"}," 聊天 ",-1))]),_:1})]),_:1})]),_:1}),s(q,{cols:"4"},{default:i(()=>[s(D,{color:"info",dark:"",size:"small"},{default:i(()=>[s(V,{class:"text-center pa-2"},{default:i(()=>[r("div",Bs,g(n.eventStats.kvChanged),1),e[14]||(e[14]=r("div",{class:"text-caption"}," KV变化 ",-1))]),_:1})]),_:1})]),_:1}),s(q,{cols:"4"},{default:i(()=>[s(D,{color:"warning",dark:"",size:"small"},{default:i(()=>[s(V,{class:"text-center pa-2"},{default:i(()=>[r("div",Os,g(n.eventStats.other),1),e[15]||(e[15]=r("div",{class:"text-caption"}," 其他 ",-1))]),_:1})]),_:1})]),_:1})]),_:1})]),r("div",js,[(c(!0),v(I,null,N(o.paginatedEvents,m=>(c(),v("div",{key:m._id,class:"event-item mb-2"},[s(D,{color:o.getEventColor(m.type),size:"small",variant:"outlined"},{default:i(()=>[s(V,{class:"pa-2"},{default:i(()=>{var f;return[r("div",Hs,[s(M,{color:o.getEventColor(m.type),size:"x-small"},{default:i(()=>[u(g(o.getEventTypeLabel(m.type)),1)]),_:2},1032,["color"]),s(A),r("span",Ks,g(o.formatTime(m.timestamp||m.at)),1)]),m.senderInfo?(c(),v("div",qs,[e[16]||(e[16]=r("strong",null,"发送者:",-1)),u(" "+g(o.formatDeviceInfo(m.senderInfo)),1)])):b("",!0),r("div",Ws,[m.type==="chat"||m.type==="chat:message"?(c(),v("div",Gs,g(((f=m.content)==null?void 0:f.text)||m.text),1)):(c(),v("pre",Qs,g(JSON.stringify(m.content||m,null,1)),1))])]}),_:2},1024)]),_:2},1032,["color"])]))),128)),n.allEvents.length===0?(c(),v("div",Js," 暂无事件 ")):b("",!0)]),o.totalPages>1?(c(),v("div",Ys,[s(qt,{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"])])):b("",!0)]))]),_:1}),n.currentMode==="chat"?(c(),x(de,{key:0})):b("",!0),n.currentMode==="chat"?(c(),x(K,{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(_,null,{default:i(()=>[...e[17]||(e[17]=[u("mdi-emoticon-outline",-1)])]),_:1})]),_:1}),s(Ce,{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:[je(He(o.handleEnter,["prevent"]),["enter"]),e[6]||(e[6]=je(He(()=>{},["shift","stop"]),["enter"]))]},null,8,["modelValue","onKeydown"]),s(y,{disabled:!o.canSend,class:"ml-2",color:"primary",onClick:o.send},{default:i(()=>[s(_,{start:""},{default:i(()=>[...e[18]||(e[18]=[u(" mdi-send ",-1)])]),_:1}),e[19]||(e[19]=u(" 发送 ",-1))]),_:1},8,["disabled","onClick"])]),_:1})):b("",!0)]),_:1})],4),[[he,n.visible]]),s(d,{ref:"urgentNotification"},null,512)],64)}const Ne=$(Is,[["render",Xs],["__scopeId","data-v-1a62ac2a"]]),Zs={name:"UrgentTestDialog",components:{ChatWidget:Ne,EventSender:Ve},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 W.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 W.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=ae("notification-displayed",a=>{console.log("收到显示回执:",a),this.updateReceipt(a,"displayed")}),e=ae("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 W.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 W.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 W.saveData("notification-list",l),(e=this.$message)==null||e.success("已删除")}catch(l){console.error("删除失败",l),(a=this.$message)==null||a.error("删除失败")}}}},en={key:0,class:"text-center text-grey py-4"},tn={key:0,class:"text-center text-grey py-8"},sn={class:"d-flex align-center mb-2"},nn={class:"font-weight-medium"},an={class:"text-caption font-weight-medium"},on={class:"text-body-2 mb-3",style:{"max-height":"60px",overflow:"hidden"}},ln={class:"text-caption"},rn={key:0},dn={class:"align-center"},un={class:"text-body-2 font-weight-medium"},cn={class:"text-caption mt-1"},mn={class:"align-center"},fn={class:"text-body-2 font-weight-medium"},hn={class:"text-caption text-grey"},gn={class:"text-caption text-grey mt-1"},pn={key:1};function vn(t,e,a,l,n,o){const d=Ne,m=Ve;return c(),x(O,{modelValue:o.dialog,"onUpdate:modelValue":e[11]||(e[11]=f=>o.dialog=f),fullscreen:"",transition:"dialog-bottom-transition",scrollable:""},{default:i(()=>[s(D,null,{default:i(()=>[s(We,{dark:"",flat:""},{default:i(()=>[s(Ge,null,{default:i(()=>[s(_,{class:"mr-2"},{default:i(()=>[...e[12]||(e[12]=[u(" mdi-chat ",-1)])]),_:1}),e[13]||(e[13]=u(" 发送通知 ",-1))]),_:1}),s(A),s(y,{icon:"mdi-close",onClick:o.close},null,8,["onClick"])]),_:1}),s(V,{class:"pa-0"},{default:i(()=>[s(ht,null,{default:i(()=>[s(se,null,{default:i(()=>[s(q,{cols:"12"},{default:i(()=>[s(D,null,{default:i(()=>[s(V,null,{default:i(()=>[s(Qe,null,{default:i(()=>[s(se,null,{default:i(()=>[s(q,{cols:"12",md:"6"},{default:i(()=>[s(Je,{modelValue:n.notificationForm.isUrgent,"onUpdate:modelValue":e[0]||(e[0]=f=>n.notificationForm.isUrgent=f),label:"强调通知",color:"red",inset:""},null,8,["modelValue"]),s(qe,{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(q,{cols:"12"},{default:i(()=>[s(Ce,{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(K,{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(_,{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(A)]),_:1})]),_:1})]),_:1})]),_:1}),s(se,{class:"mt-4"},{default:i(()=>[s(q,{cols:"12"},{default:i(()=>[s(D,null,{default:i(()=>[s(P,null,{default:i(()=>[s(_,{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(),v("div",en," 暂无常驻通知 ")):(c(),x(be,{key:1},{default:i(()=>[(c(!0),v(I,null,N(n.persistentNotifications,f=>(c(),x(we,{key:f.id,title:f.message,subtitle:o.formatTime(f.timestamp),lines:"two"},{prepend:i(()=>[s(_,{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(se,{class:"mt-4"},{default:i(()=>[s(q,{cols:"12"},{default:i(()=>[s(D,null,{default:i(()=>[s(P,null,{default:i(()=>[s(_,{class:"mr-2"},{default:i(()=>[...e[16]||(e[16]=[u(" mdi-history ",-1)])]),_:1}),e[17]||(e[17]=u(" 消息记录 ",-1)),s(A)]),_:1}),s(V,null,{default:i(()=>[n.sentMessages.length===0?(c(),v("div",tn,[s(_,{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(),x(se,{key:1},{default:i(()=>[(c(!0),v(I,null,N(n.sentMessages.slice().reverse(),f=>(c(),x(q,{key:f.id,cols:"12",md:"6",lg:"4"},{default:i(()=>[s(D,{color:o.getMainCardColor(f.receipts),class:"mb-2"},{default:i(()=>[s(V,null,{default:i(()=>[r("div",sn,[r("span",nn,g(f.isUrgent?"强调通知":"通知"),1),s(A),r("span",an,g(o.getReceiptStatus(f.receipts)),1)]),r("div",on,g(f.message),1),r("div",ln,[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(),v("div",rn,[(c(!0),v(I,null,N(f.receipts.read,h=>(c(),x(D,{key:`${h.senderId}-read`,color:"success",class:"mb-1",size:"small"},{default:i(()=>[s(V,{class:"pa-2"},{default:i(()=>[r("div",dn,[r("span",un,g(h.deviceName),1),e[20]||(e[20]=r("br",null,null,-1)),u(" "+g(h.deviceType),1)]),r("div",cn," 已读于 "+g(o.formatDeviceTime(h.timestamp)),1)]),_:2},1024)]),_:2},1024))),128)),(c(!0),v(I,null,N(o.getDisplayedOnlyDevices(f.receipts),h=>(c(),x(D,{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",mn,[r("span",fn,g(h.deviceName),1),s(A),r("span",hn,g(h.deviceType=="classroom"?"教室设备上的应用":h.deviceType),1)]),r("div",gn," 已显示于 "+g(o.formatDeviceTime(h.timestamp)),1)]),_:2},1024)]),_:2},1024))),128))])):(c(),v("div",pn,[s(D,{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(O,{modelValue:n.editDialog,"onUpdate:modelValue":e[8]||(e[8]=f=>n.editDialog=f),"max-width":"500",fullscreen:t.$vuetify.display.xs},{default:i(()=>[s(D,null,{default:i(()=>[s(We,{flat:"",density:"compact"},{default:i(()=>[s(Ge,null,{default:i(()=>[...e[22]||(e[22]=[u("编辑常驻通知",-1)])]),_:1}),s(A),s(y,{icon:"mdi-close",onClick:e[3]||(e[3]=f=>n.editDialog=!1)})]),_:1}),s(V,null,{default:i(()=>[s(Qe,null,{default:i(()=>[s(Ce,{modelValue:n.editForm.message,"onUpdate:modelValue":e[4]||(e[4]=f=>n.editForm.message=f),label:"通知内容",rows:"3","auto-grow":""},null,8,["modelValue"]),s(Je,{modelValue:n.editForm.isUrgent,"onUpdate:modelValue":e[5]||(e[5]=f=>n.editForm.isUrgent=f),label:"强调通知",color:"error","hide-details":""},null,8,["modelValue"]),s(qe,{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(K,null,{default:i(()=>[s(A),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(O,{modelValue:n.deleteConfirmDialog,"onUpdate:modelValue":e[10]||(e[10]=f=>n.deleteConfirmDialog=f),"max-width":"400"},{default:i(()=>[s(D,null,{default:i(()=>[s(P,{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(K,null,{default:i(()=>[s(A),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 yt=$(Zs,[["render",vn],["__scopeId","data-v-c6850940"]]),yn={name:"FloatingICP"},kn={"aria-label":"xICP备x号",class:"floating-icp-link",href:"https://beian.miit.gov.cn/",rel:"noopener noreferrer",target:"_blank",style:{display:"none"}};function xn(t,e,a,l,n,o){return c(),v("a",kn," xICP备x号 ")}const kt=$(yn,[["render",xn],["__scopeId","data-v-fa73670f"]]),bn={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)}}},wn={class:"floating-toolbar-container"};function Sn(t,e,a,l,n,o){return c(),v("div",wn,[s(zt,null,{default:i(()=>[s(D,{class:oe([{"toolbar-expanded":n.isExpanded},"floating-toolbar"]),elevation:"4",rounded:"xl"},{default:i(()=>[s($e,{class:"toolbar-buttons",variant:"text"},{default:i(()=>[Q(s(y,{title:"查看昨天",class:"toolbar-btn",icon:"mdi-chevron-left",variant:"text",onClick:e[0]||(e[0]=d=>t.$emit("prev-day"))},null,512),[[ge]]),Q(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),[[ge]]),Q(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),[[ge]]),s(Jt,{"close-on-content-click":!1,location:"top"},{activator:i(({props:d})=>[Q(s(y,Pe({title:"选择日期",class:"toolbar-btn",icon:"mdi-calendar"},d,{variant:"text"}),null,16),[[ge]])]),default:i(()=>[s(D,{border:"",class:"date-picker-card"},{default:i(()=>[s(At,{"model-value":a.selectedDate,color:"primary","onUpdate:modelValue":o.handleDateSelect},null,8,["model-value","onUpdate:modelValue"])]),_:1})]),_:1}),Q(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"]),[[ge]]),a.isToday?b("",!0):Q((c(),x(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)),[[ge]])]),_:1})]),_:1},8,["class"])]),_:1}),s(Mt,null,{default:i(()=>[a.isToday?b("",!0):(c(),x(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 xt=$(bn,[["render",Sn],["__scopeId","data-v-7076d3aa"]]),Cn={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}=Se();return{isMobile:t}},data(){return{attendanceSearch:"",attendanceFilter:[]}},computed:{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=Ye(e.name,{toneType:"none"}),n=Ye(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")}}},Dn={class:"d-flex flex-wrap mt-2 gap-1"},_n={class:"d-flex flex-wrap mb-4 gap-2"},Tn={class:"flex-grow-1"},In={class:"d-flex align-center"},En={class:"text-subtitle-1"},Vn={class:"attendance-actions"},Nn={class:"d-flex flex-wrap gap-2"};function An(t,e,a,l,n,o){return c(),x(O,{"model-value":a.modelValue,fullscreen:l.isMobile,"fullscreen-breakpoint":"sm","max-width":"900","onUpdate:modelValue":e[7]||(e[7]=d=>t.$emit("update:modelValue",d))},{default:i(()=>[s(D,null,{default:i(()=>[s(P,{class:"d-flex align-center"},{default:i(()=>[s(_,{class:"mr-2",icon:"mdi-account-group"}),e[8]||(e[8]=u(" 出勤状态管理 ",-1)),s(A),l.isMobile?b("",!0):(c(),x(M,{key:0,class:"ml-2",color:"primary",size:"small"},{default:i(()=>[u(g(a.dateString),1)]),_:1})),l.isMobile?(c(),x(y,{key:1,icon:"mdi-close",variant:"text",onClick:e[0]||(e[0]=d=>t.$emit("update:modelValue",!1))})):b("",!0)]),_:1}),s(V,null,{default:i(()=>[s(se,{class:"mb-4"},{default:i(()=>[s(q,{cols:"12",md:"12"},{default:i(()=>[s(ve,{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",Dn,[(c(!0),v(I,null,N(o.extractedSurnames,d=>(c(),x(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",_n,[r("div",null,[s(M,{"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(M,{"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(M,{"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(M,{"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(se,null,{default:i(()=>[(c(!0),v(I,null,N(o.filteredStudents,d=>(c(),x(q,{key:d,cols:"12",lg:"4",md:"6",sm:"6"},{default:i(()=>[s(D,{border:"",class:"student-card"},{default:i(()=>[s(V,{class:"d-flex align-center pa-2"},{default:i(()=>[r("div",Tn,[r("div",In,[s(Ee,{color:o.getStudentStatusColor(d),class:"mr-2",size:"24"},{default:i(()=>[s(_,{size:"small"},{default:i(()=>[u(g(o.getStudentStatusIcon(d)),1)]),_:2},1024)]),_:2},1032,["color"]),r("div",En,g(d),1)])]),r("div",Vn,[s(y,{color:o.isPresent(d)?"success":"",title:"设为到课",icon:"mdi-account-check",size:l.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:l.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:l.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:l.isMobile?"default":"small",variant:"text",onClick:m=>o.setExclude(d)},null,8,["color","size","onClick"])])]),_:2},1024)]),_:2},1024)]),_:2},1024))),128))]),_:1}),s(se,null,{default:i(()=>[s(q,{cols:"12",md:"12"},{default:i(()=>[s(D,{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",Nn,[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(de),s(K,null,{default:i(()=>[s(A),s(y,{color:"primary",onClick:e[6]||(e[6]=d=>t.$emit("save"))},{default:i(()=>[s(_,{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 bt=$(Cn,[["render",An],["__scopeId","data-v-7f9de516"]]),Un={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}=Se();return{isMobile:t}},data(){return{content:"",templateData:null,currentLine:"",currentLineStart:0,currentLineEnd:0,quickTexts:["课","题","例","变","T","P"]}},computed:{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 C("display.showQuickTools")},autoSavePromptText(){return C("edit.autoSavePromptText")},manualSavePromptText(){return C("edit.manualSavePromptText")}},watch:{async modelValue(t){if(t){this.content=this.initialContent;try{this.templateData=await W.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;ol.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;n0?" ":"")+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;othis.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()}))}}},zn={class:"d-flex"},Mn={class:"flex-grow-1"},Ln={key:0,class:"mt-4"},Fn={key:0,class:"template-buttons"},Pn={key:0,class:"pages-container mt-2"},$n={key:0,class:"pages-container mt-2"},Rn={key:2,class:"button-group"},Bn={key:1,class:"text-center text-body-2 text-disabled mt-2"},On={key:0,class:"quick-tools ml-4",style:{"min-width":"180px"}},jn={class:"numeric-keypad mb-4"},Hn={class:"keypad-row"},Kn={class:"keypad-row"},qn={class:"keypad-row"},Wn={class:"keypad-row"},Gn={class:"keypad-row"},Qn={class:"d-flex flex-wrap gap-1"},Jn={class:"d-flex flex-column"},Yn={class:"text-body-2"};function Xn(t,e,a,l,n,o){return c(),x(O,{modelValue:o.dialogVisible,"onUpdate:modelValue":e[5]||(e[5]=d=>o.dialogVisible=d),fullscreen:l.isMobile,"max-width":"900",width:"auto","onClick:outside":o.handleClose},{default:i(()=>[s(D,{border:""},{default:i(()=>[s(P,{class:"d-flex align-center"},{default:i(()=>[u(g(a.title)+" ",1),s(A),s(y,{icon:"mdi-close",variant:"text",onClick:o.handleClose},null,8,["onClick"])]),_:1}),s(Lt,null,{default:i(()=>[u(g(a.autoSave?o.autoSavePromptText:o.manualSavePromptText),1)]),_:1}),s(V,null,{default:i(()=>{var d;return[r("div",zn,[r("div",Mn,[s(Ce,{ref:"inputRef",modelValue:n.content,"onUpdate:modelValue":e[0]||(e[0]=m=>n.content=m),"auto-grow":"",placeholder:"使用换行表示分条",rows:"5",width:l.isMobile?"100%":"480",onClick:o.updateCurrentLine,onKeyup:o.updateCurrentLine},null,8,["modelValue","width","onClick","onKeyup"]),n.templateData?(c(),v("div",Ln,[o.hasTemplates?(c(),v("div",Fn,[o.subjectBooks?(c(!0),v(I,{key:0},N(o.subjectBooks,(m,f)=>(c(),v("div",{key:f,class:"button-group"},[s(M,{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(),v("div",Pn,[(c(!0),v(I,null,N(m,h=>(c(),x(M,{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))])):b("",!0)]))),128)):b("",!0),o.commonBooks?(c(!0),v(I,{key:1},N(o.commonBooks,(m,f)=>(c(),v("div",{key:f,class:"button-group"},[s(M,{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(),v("div",$n,[(c(!0),v(I,null,N(m,h=>(c(),x(M,{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))])):b("",!0)]))),128)):b("",!0),(d=n.templateData.actions)!=null&&d.length?(c(),v("div",Rn,[(c(!0),v(I,null,N(n.templateData.actions,m=>(c(),x(M,{key:m,class:"ma-1",color:"primary",variant:"flat",onClick:f=>o.insertTemplate(m)},{default:i(()=>[u(g(m),1)]),_:2},1032,["onClick"]))),128))])):b("",!0)])):(c(),v("div",Bn," 暂无可用的模板 "))])):b("",!0)]),o.showQuickTools&&!l.isMobile?(c(),v("div",On,[r("div",jn,[r("div",Hn,[(c(),v(I,null,N(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",Kn,[(c(),v(I,null,N(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",qn,[(c(),v(I,null,N(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",Wn,[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",Gn,[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",Qn,[(c(!0),v(I,null,N(n.quickTexts,m=>(c(),x(y,{key:m,size:"small",variant:"flat",onClick:f=>o.insertAtCursor(m)},{default:i(()=>[u(g(m),1)]),_:2},1032,["onClick"]))),128))])])):b("",!0)])]}),_:1}),a.isEditingPastData?(c(),x(pe,{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",Jn,[e[12]||(e[12]=r("div",{class:"text-h6 mb-1"},"你打算修改历史?",-1)),r("div",Yn," 这是 "+g(new Date(a.currentDateString.slice(0,4),a.currentDateString.slice(4,6)-1,a.currentDateString.slice(6,8)).toLocaleDateString())+" 的作业 • 请谨慎操作,确保不会覆盖重要数据 ",1)])]),_:1})):b("",!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 wt=$(Un,[["render",Xn],["__scopeId","data-v-b3e3018d"]]),Zn={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:Se()}},methods:{handleClick(){this.isEditingDisabled?this.$emit("disabled-click"):this.$emit("click")}}},ei={style:{"white-space":"nowrap"}},ti={style:{"white-space":"nowrap"}},si={style:{"white-space":"nowrap"}},ni={key:0},ii={style:{"white-space":"nowrap"}},ai={style:{"white-space":"nowrap"}},oi={key:0},li={style:{"white-space":"nowrap"}},ri={style:{"white-space":"nowrap"}},di={key:0},ui={style:{"white-space":"nowrap"}};function ci(t,e,a,l,n,o){return a.studentList&&a.studentList.length?Q((c(),x(q,{key:0,class:oe([{"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",ei,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",ti,g(a.studentList.length-a.attendance.absent.length-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",si,g(a.attendance.absent.length)+"人 ",1)]),(c(!0),v(I,null,N(a.attendance.absent,(d,m)=>(c(),v("h3",{key:"absent-"+m,class:"gray-text"},[l.display.lgAndUp.value?(c(),v("span",ni,g(`${m+1}. `),1)):b("",!0),r("span",ii,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",ai,g(a.attendance.late.length)+"人 ",1)]),(c(!0),v(I,null,N(a.attendance.late,(d,m)=>(c(),v("h3",{key:"late-"+m,class:"gray-text"},[l.display.lgAndUp.value?(c(),v("span",oi,g(`${m+1}. `),1)):b("",!0),r("span",li,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",ri,g(a.attendance.exclude.length)+"人 ",1)]),(c(!0),v(I,null,N(a.attendance.exclude,(d,m)=>(c(),v("h3",{key:"exclude-"+m,class:"gray-text"},[l.display.lgAndUp.value?(c(),v("span",di,g(`${m+1}. `),1)):b("",!0),r("span",ui,g(d),1)]))),128))]),_:1},8,["class","onClick"])),[[ge,a.isEditingDisabled?!1:{class:`text-${["primary","secondary","info","success","warning","error"][Math.floor(Math.random()*6)]}`}]]):b("",!0)}const St=$(Zn,[["render",ci],["__scopeId","data-v-8dbe204a"]]),mi={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"]},fi={class:"d-flex flex-wrap align-center mt-4"};function hi(t,e,a,l,n,o){return c(),v(I,null,[r("div",fi,[a.synced?(c(),x(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(),x(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(),x(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})):b("",!0),a.showExamScheduleButton?(c(),x($e,{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})):b("",!0),a.showListCardButton?(c(),x(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})):b("",!0),a.showFullscreenButton?(c(),x(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"])):b("",!0),a.showTestCardButton?(c(),x(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})):b("",!0)]),a.showAntiScreenBurnCard?(c(),x(D,{key:0,border:"",class:"mt-4 anti-burn-card",color:"primary",variant:"tonal"},{default:i(()=>[s(P,{class:"text-subtitle-1"},{default:i(()=>[s(_,{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})):b("",!0)],64)}const Ct=$(mi,[["render",hi]]),gi={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 pi(t,e,a,l,n,o){return c(),v("span",null,g(o.displayTime),1)}const Dt=$(gi,[["render",pi]]),De=Ft("exam",{state:()=>({examList:[],exams:{},loadingList:!1,loadingDetails:{}}),actions:{async fetchExamList(){if(!this.loadingList){this.loadingList=!0;try{const t=await W.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 W.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}}}),vi={name:"ConciseExamCard",components:{RelativeTimeDisplay:Dt},props:{examId:{type:String,required:!0},contentStyle:{type:Object,default:()=>({})},readonly:{type:Boolean,default:!1}},computed:{...ot(De,["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:{...at(De,["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)t.$emit("click"))},{default:i(()=>[s(P,{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",yi,g(((m=o.exam)==null?void 0:m.examName)||"加载中..."),1)]}),_:1}),s(V,{class:"flex-grow-1 pa-4 overflow-y-auto",style:le(a.contentStyle)},{default:i(()=>[o.loading?(c(),v("div",ki,[s(lt,{indeterminate:"",size:"24",color:"primary"})])):o.exam?(c(),v("div",xi,[(c(!0),v(I,null,N(o.groupedExamInfos,(m,f)=>(c(),v("div",{key:f,class:"mb-3"},[r("div",bi,[s(d,{time:m.date},null,8,["time"])]),(c(!0),v(I,null,N(m.infos,(h,k)=>(c(),v("div",{key:k,class:oe(["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",wi,g(h.name),1),r("div",Si,g(o.formatTimeOnly(h.start))+" - "+g(o.formatTimeOnly(h.end)),1)],2))),128))]))),128))])):(c(),v("div",Ci,"无法加载"))]),_:1},8,["style"])]),_:1})}const _t=$(vi,[["render",Di],["__scopeId","data-v-33424f55"]]),_i=["6IO4","5Lmz","6JCd6I6J","5rer","5aW4"],Ti=_i.map(t=>ft.decode(t)),tt=.75,Ii={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*tt}px`,"white-space":"pre-wrap","line-height":"1.6","text-align":"left"}},authorStyle(){return{"font-size":`${this.fontSize*tt*.6}px`,"text-align":"left"}}},async mounted(){this.loadLocalSettings(),await this.loadKvSettings(),this.fetchSentence(),this.startTimer(),this.unwatch=Re(()=>{this.loadLocalSettings(),this.startTimer()})},beforeUnmount(){this.stopTimer(),this.unwatch&&this.unwatch()},methods:{loadLocalSettings(){this.enabled=Ae.getSetting("hitokoto.enabled"),this.refreshInterval=Ae.getSetting("hitokoto.refreshInterval"),this.fontSize=Ae.getSetting("font.size")},async loadKvSettings(){try{const t=await W.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 Ue.get("https://v1.hitokoto.cn/")).data,l=a.hitokoto,n=a.from_who,o=a.from;else if(e==="zhaoyu"){const d=await Ue.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 Ue.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([...Ti,...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}}}}},Ei={key:0,class:"mr-2"},Vi={key:1};function Ni(t,e,a,l,n,o){return c(),x(D,{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:le(o.contentStyle)},g(n.sentence),5),r("div",{class:"text-medium-emphasis serif-font",style:le(o.authorStyle)},[n.author?(c(),v("span",Ei,g(n.author),1)):b("",!0),n.origin?(c(),v("span",Vi,"《"+g(n.origin)+"》",1)):b("",!0)],4)]),_:1})]),_:1},8,["loading","onClick"])}const Tt=$(Ii,[["render",Ni],["__scopeId","data-v-de957b7d"]]),Ai={name:"HomeworkGrid",components:{HitokotoCard:Tt,ConciseExamCard:_t},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"],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)})})},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:{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}%`)}}}},Ui={ref:"gridContainer",class:"grid-masonry"},zi=["data-key"],Mi={key:0,style:{height:"100%"}},Li={key:1,style:{height:"100%"}},Fi={class:"d-flex justify-space-between align-center mb-2"},Pi={class:"text-h6"},$i={key:0,class:"mb-2"},Ri={class:"text-error text-caption mb-1"},Bi={class:"d-flex flex-wrap",style:{gap:"4px"}},Oi={key:1,class:"mb-2"},ji={class:"text-warning text-caption mb-1"},Hi={class:"d-flex flex-wrap",style:{gap:"4px"}},Ki={key:2,class:"mb-2"},qi={class:"text-grey text-caption mb-1"},Wi={class:"d-flex flex-wrap",style:{gap:"4px"}},Gi={key:3,class:"text-success text-center mt-2"},Qi={class:"empty-subjects mt-4"},Ji={key:0,class:"d-flex flex-wrap justify-center"},Yi={key:2,class:"empty-subjects-grid"};function Xi(t,e,a,l,n,o){const d=Tt,m=_t;return c(),v(I,null,[r("div",Ui,[s(Le,{name:"grid"},{default:i(()=>[(c(!0),v(I,null,N(a.sortedItems,f=>(c(),v("div",{key:f.key,ref_for:!0,ref:"items","data-key":f.key,style:le({order:f.order}),class:"grid-item"},[f.type==="hitokoto"?(c(),v("div",Mi,[s(d)])):f.type==="exam"?(c(),v("div",Li,[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(),x(D,{key:2,class:oe([{"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(P,{class:"d-flex align-center"},{default:i(()=>[s(_,{class:"mr-2",color:"primary",icon:"mdi-account-group"}),e[1]||(e[1]=u(" 出勤统计 ",-1))]),_:1}),s(V,null,{default:i(()=>[r("div",Fi,[e[2]||(e[2]=r("span",null,"应到/实到",-1)),r("span",Pi,g(f.data.total-f.data.exclude.length)+"/"+g(f.data.total-f.data.absent.length-f.data.late.length-f.data.exclude.length),1)]),s(de,{class:"mb-2"}),f.data.absent.length>0?(c(),v("div",$i,[r("div",Ri,"请假 ("+g(f.data.absent.length)+")",1),r("div",Bi,[(c(!0),v(I,null,N(f.data.absent,h=>(c(),x(M,{key:h,color:"error",size:"x-small",variant:"flat"},{default:i(()=>[u(g(h),1)]),_:2},1024))),128))])])):b("",!0),f.data.late.length>0?(c(),v("div",Oi,[r("div",ji,"迟到 ("+g(f.data.late.length)+")",1),r("div",Hi,[(c(!0),v(I,null,N(f.data.late,h=>(c(),x(M,{key:h,color:"warning",size:"x-small",variant:"flat"},{default:i(()=>[u(g(h),1)]),_:2},1024))),128))])])):b("",!0),f.data.exclude.length>0?(c(),v("div",Ki,[r("div",qi,"不参与 ("+g(f.data.exclude.length)+")",1),r("div",Wi,[(c(!0),v(I,null,N(f.data.exclude,h=>(c(),x(M,{key:h,color:"grey",size:"x-small",variant:"flat"},{default:i(()=>[u(g(h),1)]),_:2},1024))),128))])])):b("",!0),f.data.absent.length===0&&f.data.late.length===0&&f.data.exclude.length===0?(c(),v("div",Gi," 全勤 ")):b("",!0)]),_:2},1024)]),_:2},1032,["class","onMousemove","onTouchmove"])):f.type==="custom"?(c(),x(D,{key:3,class:oe([{"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(P,{class:"text-primary"},{default:i(()=>[s(_,{class:"mr-2",icon:"mdi-card-text-outline",size:"small"}),u(" "+g(f.name),1)]),_:2},1024),s(V,{style:le(a.contentStyle)},{default:i(()=>[u(g(f.content),1)]),_:2},1032,["style"])]),_:2},1032,["class","onClick","onMousemove","onTouchmove"])):(c(),x(D,{key:4,class:oe([{"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(P,null,{default:i(()=>[u(g(f.name),1)]),_:2},1024),s(V,{style:le(a.contentStyle)},{default:i(()=>[s(be,null,{default:i(()=>[(c(!0),v(I,null,N(o.splitPoint(f.content),h=>(c(),x(we,{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",Qi,[a.isMobile?(c(),v("div",Ji,[(c(!0),v(I,null,N(a.unusedSubjects,f=>(c(),x(M,{key:f.name,class:"ma-1",color:"primary",variant:"tonal",onClick:h=>o.handleCardClick("dialog",f.name)},{default:i(()=>[s(_,{start:"",size:"small"},{default:i(()=>[...e[3]||(e[3]=[u("mdi-plus",-1)])]),_:1}),u(" "+g(f.name),1)]),_:2},1032,["onClick"]))),128))])):a.emptySubjectDisplay==="button"?(c(),x($e,{key:1,divided:"",variant:"tonal"},{default:i(()=>[(c(!0),v(I,null,N(a.unusedSubjects,f=>(c(),x(y,{key:f.name,onClick:h=>o.handleCardClick("dialog",f.name)},{default:i(()=>[s(_,{start:""},{default:i(()=>[...e[4]||(e[4]=[u(" mdi-plus",-1)])]),_:1}),u(" "+g(f.name),1)]),_:2},1032,["onClick"]))),128))]),_:1})):(c(),v("div",Yi,[s(Le,{name:"v-list"},{default:i(()=>[(c(!0),v(I,null,N(a.unusedSubjects,f=>(c(),x(D,{key:f.name,border:"",class:"empty-subject-card",onClick:h=>o.handleCardClick("dialog",f.name)},{default:i(()=>[s(P,{class:"text-subtitle-1"},{default:i(()=>[u(g(f.name),1)]),_:2},1024),s(V,{class:"text-center"},{default:i(()=>[s(_,{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))]),_:1})]),_:2},1032,["onClick"]))),128))]),_:1})]))])],64)}const It=$(Ai,[["render",Xi],["__scopeId","data-v-26d7ac70"]]),Zi={key:0,class:"mt-2 text-caption text-medium-emphasis"},ea={__name:"StudentNameManager",emits:["token-info-updated"],setup(t,{expose:e,emit:a}){const l=a,n=z(!1),o=z(""),d=z([]),m=z(""),f=z(!1),h=z(""),k=z(null),E=G(()=>{var T;return((T=k.value)==null?void 0:T.deviceType)==="student"}),F=G(()=>{var T;return((T=k.value)==null?void 0:T.isReadOnly)===!0}),Y=G(()=>{var T;return((T=k.value)==null?void 0:T.note)||"设置名称"}),L=G(()=>!!R.value),R=G(()=>C("server.kvToken")),J=G(()=>C("server.provider")),fe=G(()=>J.value==="kv-server"||J.value==="classworkscloud"),X=async()=>{if(!(!fe.value||!R.value))try{const T=C("server.domain");if(!T)return;const w=await me.get(`${T}/kv/_token`,{headers:{Authorization:`Bearer ${R.value}`}});if(k.value=w.data,k.value.deviceType!=="student")return;m.value=k.value.note||"";const re=(await me.get(`${T}/kv/classworks-list-main`,{headers:{Authorization:`Bearer ${R.value}`}})).data.value||[];if(d.value=Array.isArray(re)?re:[],d.value.length===0)return;const B=k.value.note||"",Z=d.value.some(H=>H.name===B);(!B||!Z)&&(n.value=!0,o.value="")}catch(T){console.error("检查学生姓名状态失败:",T)}},ue=async()=>{var T,w,U,re;if(!(!o.value||f.value)){h.value="",f.value=!0;try{const B=C("server.domain"),Z=R.value;(await me.post(`${B}/apps/tokens/${Z}/set-student-name`,{name:o.value})).data.success&&(m.value=o.value,n.value=!1,await X(),l("token-info-updated"))}catch(B){const Z=(T=B==null?void 0:B.response)==null?void 0:T.status;Z===400?h.value="该名称不在学生列表中,请选择正确的姓名":Z===403?h.value="只有学生类型的 Token 可以设置姓名":Z===404?h.value="设备未设置学生列表或 Token 不存在":h.value=((re=(U=(w=B==null?void 0:B.response)==null?void 0:w.data)==null?void 0:U.error)==null?void 0:re.message)||(B==null?void 0:B.message)||"设置失败,请稍后重试"}finally{f.value=!1}}},S=()=>{n.value=!1},ie=async()=>{if(console.log("StudentNameManager.openDialog called"),console.log("isStudentToken:",E.value),console.log("studentList.length:",d.value.length),console.log("currentStudentName:",m.value),!E.value){console.log("Not a student token, cannot open dialog");return}d.value=await W.loadData("classworks-list-main"),d.value.length===0?(console.log("Student list is empty, trying to load..."),X().then(()=>{d.value.length>0?(o.value=m.value,n.value=!0):console.warn("Student list is still empty after reload")})):(o.value=m.value,n.value=!0,console.log("Dialog opened, showDialog:",n.value))};return Ie(R,()=>{X()}),Re(()=>{X()}),Ie(k,()=>{l("token-info-updated")},{deep:!0}),rt(()=>{X()}),e({checkStudentNameStatus:X,openDialog:ie,currentStudentName:m,isStudentToken:E,isReadOnly:F,displayName:Y,hasToken:L,tokenInfo:k}),(T,w)=>(c(),v(I,null,[s(O,{modelValue:n.value,"onUpdate:modelValue":w[1]||(w[1]=U=>n.value=U),"max-width":"500",persistent:""},{default:i(()=>[s(D,null,{default:i(()=>[s(P,null,{default:i(()=>[...w[2]||(w[2]=[u("设置学生姓名",-1)])]),_:1}),s(V,null,{default:i(()=>[w[3]||(w[3]=r("div",{class:"mb-2"}," 请从列表中选择您的姓名: ",-1)),s(Ut,{modelValue:o.value,"onUpdate:modelValue":w[0]||(w[0]=U=>o.value=U),items:d.value,clearable:"","hide-details":"","item-title":"name","item-value":"name",label:"学生姓名",placeholder:"选择您的姓名"},null,8,["modelValue","items"]),d.value.length>0?(c(),v("div",Zi," 共 "+g(d.value.length)+" 位学生 ",1)):b("",!0),h.value?(c(),x(pe,{key:1,class:"mt-3",type:"error",variant:"tonal"},{default:i(()=>[u(g(h.value),1)]),_:1})):b("",!0)]),_:1}),s(K,null,{default:i(()=>[s(y,{variant:"text",onClick:S},{default:i(()=>[...w[4]||(w[4]=[u(" 稍后设置 ",-1)])]),_:1}),s(A),s(y,{disabled:!o.value||f.value,loading:f.value,color:"primary",onClick:ue},{default:i(()=>[...w[5]||(w[5]=[u(" 确认 ",-1)])]),_:1},8,["disabled","loading"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),Pt(T.$slots,"header-display",{isStudent:E.value,openDialog:ie,studentName:m.value},void 0)],64))}},Et=$(ea,[["__scopeId","data-v-49cb0f5f"]]),ta={class:"text-center mb-6"},sa={class:"text-body-2"},na={class:"form-section"},ia={__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=z({namespace:"",password:""}),d=z(!1),m=z("");Ie(()=>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,E,F,Y;if(!(!o.value.namespace||d.value)){m.value="",d.value=!0;try{const L=C("server.domain");if(!L)throw new Error("未配置服务器域名");const R=await me.post(`${L}/apps/auth/token`,{namespace:o.value.namespace,password:o.value.password||void 0,appId:"d158067f53627d2b98babe8bffd2fd7d"});if(!R.data.success)throw new Error("设备验证失败");const J=R.data;ne("server.kvToken",J.token),(h=J.device)!=null&&h.uuid&&ne("device.uuid",J.device.uuid),n("success",J)}catch(L){const R=(k=L==null?void 0:L.response)==null?void 0:k.status;R===401||R===403?m.value="密码错误或无权限访问":R===404?m.value="设备不存在,请检查 namespace 是否正确":m.value=((Y=(F=(E=L==null?void 0:L.response)==null?void 0:E.data)==null?void 0:F.error)==null?void 0:Y.message)||(L==null?void 0:L.message)||"认证失败,请稍后重试"}finally{d.value=!1}}};return e({reset:()=>{o.value={namespace:"",password:""},m.value=""}}),(h,k)=>(c(),x(D,{class:"auth-card"},{default:i(()=>[s(V,{class:"pa-8"},{default:i(()=>[r("div",ta,[s(_,{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(D,{class:"pa-4 mb-6",color:"info",variant:"tonal"},{default:i(()=>[r("div",sa,[s(_,{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",na,[s(ve,{modelValue:o.value.namespace,"onUpdate:modelValue":k[0]||(k[0]=E=>o.value.namespace=E),class:"mb-4","hide-details":"auto",label:"命名空间","prepend-inner-icon":"mdi-identifier",variant:"outlined"},null,8,["modelValue"]),s(ve,{modelValue:o.value.password,"onUpdate:modelValue":k[1]||(k[1]=E=>o.value.password=E),label:"认证码","prepend-inner-icon":"mdi-lock-outline",type:"text",variant:"outlined"},null,8,["modelValue"]),m.value?(c(),x(pe,{key:0,class:"mt-4",closable:"",type:"error",variant:"tonal","onClick:close":k[2]||(k[2]=E=>m.value="")},{default:i(()=>[u(g(m.value),1)]),_:1})):b("",!0)])]),_:1}),s(K,{class:"pa-6 pt-0"},{default:i(()=>[t.showCancel?(c(),x(y,{key:0,size:"large",variant:"text",onClick:k[3]||(k[3]=E=>h.$emit("cancel"))},{default:i(()=>[...k[9]||(k[9]=[u(" 取消 ",-1)])]),_:1})):b("",!0),s(A),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(_,{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}))}},aa=$(ia,[["__scopeId","data-v-9e8d02e4"]]),oa={__name:"TokenInputDialog",props:{showCancel:{type:Boolean,default:!1}},emits:["success","cancel"],setup(t,{expose:e,emit:a}){const l=a,n=z(""),o=z(!1),d=z(""),m=async()=>{var f,h,k;if(!(!n.value||o.value)){d.value="",o.value=!0;try{const E=C("server.domain");if(!E)throw new Error("未配置服务器域名");await me.get(`${E}/kv/_info`,{headers:{Accept:"application/json","x-app-token":n.value}}),ne("server.kvToken",n.value),l("success")}catch(E){const F=(f=E==null?void 0:E.response)==null?void 0:f.status;F===401||F===403?d.value="Token 无效或无权限,请确认后重试":F===404?d.value="命名空间不存在或服务器未就绪":d.value=((k=(h=E==null?void 0:E.response)==null?void 0:h.data)==null?void 0:k.message)||(E==null?void 0:E.message)||"验证失败,请稍后重试"}finally{o.value=!1}}};return e({reset:()=>{n.value="",d.value=""}}),(f,h)=>(c(),x(D,null,{default:i(()=>[s(P,null,{default:i(()=>[...h[2]||(h[2]=[u("输入授权 Token",-1)])]),_:1}),s(V,null,{default:i(()=>[s(ve,{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(),x(pe,{key:0,class:"mt-3",type:"error",variant:"tonal"},{default:i(()=>[u(g(d.value),1)]),_:1})):b("",!0)]),_:1}),s(K,null,{default:i(()=>[s(A),t.showCancel?(c(),x(y,{key:0,variant:"text",onClick:h[1]||(h[1]=k=>f.$emit("cancel"))},{default:i(()=>[...h[3]||(h[3]=[u(" 取消 ",-1)])]),_:1})):b("",!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}))}},la={__name:"AlternativeCodeDialog",props:{showCancel:{type:Boolean,default:!1}},emits:["submit","cancel"],setup(t,{expose:e,emit:a}){const l=a,n=z(""),o=()=>{n.value&&l("submit",n.value)};return e({reset:()=>{n.value=""}}),(d,m)=>(c(),x(D,null,{default:i(()=>[s(P,null,{default:i(()=>[...m[2]||(m[2]=[u("输入替代代码",-1)])]),_:1}),s(V,null,{default:i(()=>[s(Ce,{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(pe,{class:"mt-3",type:"info",variant:"tonal"},{default:i(()=>[...m[3]||(m[3]=[u(" 替代代码功能暂未实现,敬请期待 ",-1)])]),_:1})]),_:1}),s(K,null,{default:i(()=>[s(A),t.showCancel?(c(),x(y,{key:0,variant:"text",onClick:m[1]||(m[1]=f=>d.$emit("cancel"))},{default:i(()=>[...m[4]||(m[4]=[u(" 取消 ",-1)])]),_:1})):b("",!0),s(y,{disabled:!n.value,color:"primary",onClick:o},{default:i(()=>[...m[5]||(m[5]=[u(" 提交 ",-1)])]),_:1},8,["disabled"])]),_:1})]),_:1}))}},j=[];for(let t=0;t<256;++t)j.push((t+256).toString(16).slice(1));function ra(t,e=0){return(j[t[e+0]]+j[t[e+1]]+j[t[e+2]]+j[t[e+3]]+"-"+j[t[e+4]]+j[t[e+5]]+"-"+j[t[e+6]]+j[t[e+7]]+"-"+j[t[e+8]]+j[t[e+9]]+"-"+j[t[e+10]]+j[t[e+11]]+j[t[e+12]]+j[t[e+13]]+j[t[e+14]]+j[t[e+15]]).toLowerCase()}let ze;const da=new Uint8Array(16);function ua(){if(!ze){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ze=crypto.getRandomValues.bind(crypto)}return ze(da)}const ca=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),st={randomUUID:ca};function ma(t,e,a){var n;t=t||{};const l=t.random??((n=t.rng)==null?void 0:n.call(t))??ua();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,ra(l)}function fa(t,e,a){return st.randomUUID&&!t?st.randomUUID():ma(t)}const ha={class:"step-content"},ga={class:"text-center mb-6"},pa={class:"step-content"},va={class:"relationship-diagram"},ya={class:"diagram-item"},ka={class:"text-center"},xa={class:"diagram-description mt-3"},ba={class:"diagram-connector"},wa={class:"diagram-item"},Sa={class:"text-center"},Ca={class:"diagram-description mt-3"},Da={class:"step-content"},_a={class:"button-group"},Ta={class:"d-flex flex-column align-center py-2"},Ia={class:"d-flex flex-column align-center py-2"},Ea={class:"step-content"},Va={class:"text-center mb-6"},Na={class:"step-content"},Aa={class:"text-center mb-6"},Ua={class:"d-flex flex-column flex-sm-row align-center"},za={class:"flex-grow-1"},Ma={class:"text-h6 font-weight-bold"},La={class:"text-h5 mb-6"},Fa={class:"text-subtitle-2"},Pa={class:"d-flex align-center"},$a={class:"d-flex align-center"},Ra={class:"step-content"},Ba={class:"text-center mb-6"},Oa={class:"d-flex align-center mb-3"},ja={class:"text-h6 font-weight-medium"},Ha={key:0,class:"text-body-2 mb-2"},Ka={class:"mb-2"},qa={class:"device-code"},Wa={key:1,class:"text-body-2 text-error"},Ga={class:"log-box"},Qa={key:0,class:"text-caption text-medium-emphasis"},Ja={class:"d-flex flex-wrap gap-2 mt-4"},Te=5,Ya={__name:"FirstTimeGuide",emits:["close","success"],setup(t,{emit:e}){const a=e,l=C("server.authDomain"),n=z(1),o=z(""),d=z("idle"),m=z(""),f=z(null),h=z(null),k=z([]),E=z({1:!1,2:!1,3:!1,4:!1}),F=()=>{n.value{n.value>1&&n.value--},L=H=>{o.value=H,F()},R=()=>{a("close")},J=()=>{window.open(l,"_blank")},fe=()=>{n.value=5},X=G(()=>Object.values(E.value).filter(Boolean).length/4*100),ue=G(()=>d.value==="success"?"success":d.value==="error"?"error":"primary"),S=G(()=>d.value==="success"?"mdi-check-circle":d.value==="error"?"mdi-alert-circle":d.value==="registering"?"mdi-progress-clock":"mdi-rocket-launch"),ie=G(()=>d.value==="success"?"完成!设备已创建":d.value==="error"?"创建失败":d.value==="registering"?"正在执行…":"准备开始"),T=H=>{const p=new Date,ee=String(p.getHours()).padStart(2,"0"),te=String(p.getMinutes()).padStart(2,"0"),_e=String(p.getSeconds()).padStart(2,"0");k.value.push({time:`${ee}:${te}:${_e}`,message:H})},w=()=>"Classworks",U=async()=>{var H,p,ee;if(d.value!=="registering"){d.value="registering",m.value="",k.value=[],E.value={1:!1,2:!1,3:!1,4:!1};try{T("正在生成设备信息…");const te=fa(),_e=w(),Oe=C("server.domain");E.value[1]=!0,T("向服务器注册设备…");const Nt=await me.post(`${Oe}/devices`,{uuid:te,deviceName:_e});E.value[2]=!0,f.value={uuid:te,deviceName:_e,createdAt:new Date().toISOString(),registered:!0},localStorage.setItem("Classworks_progressive_device",JSON.stringify(f.value)),T("获取访问令牌…");try{const ce=await me.post(`${Oe}/apps/auth/token`,{namespace:te,password:"",appId:"d158067f53627d2b98babe8bffd2fd7d"});ce.data&&ce.data.token?(h.value=ce.data,ne("server.kvToken",ce.data.token),(H=ce.data.device)!=null&&H.uuid&&ne("device.uuid",ce.data.device.uuid),T("已获取 Token 并写入配置")):T("未返回 Token,您可以稍后在授权页完成配置")}catch(ce){console.warn("自动获取 Token 失败:",ce),T("自动获取 Token 失败,可在授权页手动完成")}E.value[3]=!0,T("完成!您可以应用令牌或前往授权页面继续配置"),E.value[4]=!0,d.value="success"}catch(te){console.error("设备注册失败:",te),m.value=((ee=(p=te.response)==null?void 0:p.data)==null?void 0:ee.message)||te.message||"网络连接失败",T("失败:"+m.value),d.value="error"}}},re=()=>{d.value="idle",m.value="",k.value=[],E.value={1:!1,2:!1,3:!1,4:!1}},B=()=>{const H=f.value;if(!(H!=null&&H.uuid))return;const ee=`${C("server.authDomain")}/?uuid=${encodeURIComponent(H.uuid)}&tolinktoaccount=true`;window.open(ee,"_blank")},Z=()=>{h.value&&a("success",h.value),a("close")};return(H,p)=>(c(),x(D,{class:"guide-card"},{default:i(()=>[s(Ke,{"model-value":n.value/Te*100,color:"primary",height:"6"},null,8,["model-value"]),s(V,{class:"pa-8"},{default:i(()=>[Q(r("div",ha,[r("div",ga,[s(_,{class:"mb-4",color:"primary",size:"80"},{default:i(()=>[...p[2]||(p[2]=[u(" mdi-hand-wave ",-1)])]),_:1}),p[3]||(p[3]=r("h2",{class:"text-h4 mb-3"}," 欢迎使用 Classworks ",-1)),p[4]||(p[4]=r("p",{class:"text-body-1 text-medium-emphasis"}," 适用于班级大屏的作业板小工具 ",-1))])],512),[[he,n.value===1]]),Q(r("div",pa,[p[17]||(p[17]=r("h3",{class:"text-h5 mb-6 text-center"}," Classworks 和 Classworks KV 的关系 ",-1)),s(D,{class:"pa-6 mb-6",color:"primary",variant:"tonal"},{default:i(()=>[r("div",va,[r("div",ya,[s(D,{class:"pa-4",color:"blue-darken-1",elevation:"8"},{default:i(()=>[r("div",ka,[s(_,{color:"white",size:"60"},{default:i(()=>[...p[5]||(p[5]=[u(" mdi-laptop ",-1)])]),_:1}),p[6]||(p[6]=r("h4",{class:"text-h6 text-white mt-2"}," Classworks ",-1)),p[7]||(p[7]=r("p",{class:"text-caption text-white mt-1"}," 作业板应用 ",-1))])]),_:1}),r("div",xa,[s(M,{class:"mb-2",color:"blue",size:"small",variant:"flat"},{default:i(()=>[...p[8]||(p[8]=[u(" 前端应用 ",-1)])]),_:1}),p[9]||(p[9]=r("div",{class:"text-body-2"},[u(" • 显示作业内容"),r("br"),u(" • 管理班级信息"),r("br"),u(" • 提供用户界面 ")],-1))])]),r("div",ba,[s(_,{color:"primary",size:"40"},{default:i(()=>[...p[10]||(p[10]=[u(" mdi-swap-horizontal ",-1)])]),_:1}),p[11]||(p[11]=r("div",{class:"text-caption font-weight-bold mt-2"}," 数据同步 ",-1))]),r("div",wa,[s(D,{class:"pa-4",color:"green-darken-1",elevation:"8"},{default:i(()=>[r("div",Sa,[s(_,{color:"white",size:"60"},{default:i(()=>[...p[12]||(p[12]=[u(" mdi-cloud-sync ",-1)])]),_:1}),p[13]||(p[13]=r("h4",{class:"text-h6 text-white mt-2"}," Classworks KV ",-1)),p[14]||(p[14]=r("p",{class:"text-caption text-white mt-1"}," 云端数据库 ",-1))])]),_:1}),r("div",Ca,[s(M,{class:"mb-2",color:"green",size:"small",variant:"flat"},{default:i(()=>[...p[15]||(p[15]=[u(" 后端服务 ",-1)])]),_:1}),p[16]||(p[16]=r("div",{class:"text-body-2"},[u(" • 存储作业数据"),r("br"),u(" • 多设备同步"),r("br"),u(" • 权限管理 ")],-1))])])])]),_:1})],512),[[he,n.value===2]]),Q(r("div",Da,[p[25]||(p[25]=r("h3",{class:"text-h5 mb-6 text-center"}," 你需要在多个设备上查看作业吗? ",-1)),s(D,{class:"mb-6 pa-4",color:"info",variant:"tonal"},{default:i(()=>[...p[18]||(p[18]=[r("div",{class:"text-body-2"}," 比如:在家里电脑、手机上查看,或者多个教室设备共享数据 ",-1)])]),_:1}),r("div",_a,[s(y,{block:"",class:"mb-4 py-6",color:"primary",size:"x-large",variant:"elevated",onClick:p[0]||(p[0]=ee=>L("cloud"))},{default:i(()=>[r("div",Ta,[s(_,{class:"mb-2",size:"40"},{default:i(()=>[...p[19]||(p[19]=[u(" mdi-cloud-check ",-1)])]),_:1}),p[20]||(p[20]=r("span",{class:"text-h6"},"需要,使用云同步",-1)),p[21]||(p[21]=r("span",{class:"text-caption mt-1"},"多设备访问",-1))])]),_:1}),s(y,{block:"",class:"py-6",size:"x-large",variant:"outlined",onClick:p[1]||(p[1]=ee=>L("local"))},{default:i(()=>[r("div",Ia,[s(_,{class:"mb-2",size:"40"},{default:i(()=>[...p[22]||(p[22]=[u(" mdi-laptop ",-1)])]),_:1}),p[23]||(p[23]=r("span",{class:"text-h6"},"不需要,只用这台设备",-1)),p[24]||(p[24]=r("span",{class:"text-caption mt-1"},"本地存储",-1))])]),_:1})])],512),[[he,n.value===3]]),Q(r("div",Ea,[r("div",Va,[s(_,{class:"mb-4",color:"success",size:"80"},{default:i(()=>[...p[26]||(p[26]=[u(" mdi-check-circle ",-1)])]),_:1}),p[28]||(p[28]=r("h3",{class:"text-h5 mb-4"}," 您可以使用本地模式 ",-1)),s(D,{class:"pa-4 text-left",variant:"tonal"},{default:i(()=>[...p[27]||(p[27]=[r("div",{class:"text-body-1 mb-2"}," 此数据将存储在您的浏览器中,如果您的浏览器不支持IndexedDB,可能会出现问题。如果您经常清除浏览器数据,请谨慎使用本地模式。 ",-1),r("div",{class:"text-body-1 mb-2"}," 在刚才地方点击使用本地模式的按钮使用。 ",-1)])]),_:1})])],512),[[he,n.value===4&&o.value==="local"]]),Q(r("div",Na,[r("div",Aa,[s(_,{class:"mb-4",color:"primary",size:"80"},{default:i(()=>[...p[29]||(p[29]=[u(" mdi-cloud-cog ",-1)])]),_:1}),p[30]||(p[30]=r("h3",{class:"text-h5 mb-4"}," 需要先设置云端账号 ",-1))]),s(D,{class:"pa-6 mb-6",variant:"tonal"},{default:i(()=>[r("div",Ua,[r("div",za,[p[32]||(p[32]=r("h4",{class:"text-h6 font-weight-bold mb-2"}," 自动注册设备 ",-1)),p[33]||(p[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:fe},{default:i(()=>[...p[31]||(p[31]=[u(" 自动注册 ",-1)])]),_:1})])])]),_:1}),p[41]||(p[41]=r("div",{class:"mb-6"}," 也可以手动前往 Classworks KV 控制台获取认证信息: ",-1)),s(D,{color:ye(l)=="https://kv.houlang.cloud"?"primary":"error",variant:ye(l)=="https://kv.houlang.cloud"?"elevated":"outlined",class:"pa-6 mb-6",onClick:J},{default:i(()=>[s(_,{class:"mb-3",size:"48"},{default:i(()=>[...p[34]||(p[34]=[u(" mdi-open-in-new ",-1)])]),_:1}),r("h4",Ma," 请访问 "+g(ye(l)=="https://kv.houlang.cloud"?"Classworks KV":"自定义的 Classworks KV 实例 ")+" 控制台 ",1),r("div",La,g(ye(l)),1),r("h6",Fa,g(ye(l)=="https://kv.houlang.cloud"?"此实例由 Classworks KV 官方提供":"此链接由您的实例、预配代码或管理员管理,当前可能不是 Classworks KV 官方的实例地址。"),1)]),_:1},8,["color","variant"]),s(Yt,{class:"mt-6",variant:"accordion"},{default:i(()=>[s(Xe,null,{default:i(()=>[s(Ze,null,{default:i(()=>[r("div",Pa,[s(_,{class:"mr-3",color:"warning"},{default:i(()=>[...p[35]||(p[35]=[u(" mdi-help-circle ",-1)])]),_:1}),p[36]||(p[36]=r("span",{class:"text-subtitle-1 font-weight-medium"},"我以前已经使用过 Classworks KV?",-1))])]),_:1}),s(et,null,{default:i(()=>[s(D,{class:"pa-4",color:"success",variant:"tonal"},{default:i(()=>[...p[37]||(p[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(Xe,null,{default:i(()=>[s(Ze,null,{default:i(()=>[r("div",$a,[s(_,{class:"mr-3",color:"info"},{default:i(()=>[...p[38]||(p[38]=[u(" mdi-help-circle ",-1)])]),_:1}),p[39]||(p[39]=r("span",{class:"text-subtitle-1 font-weight-medium"},"我如何配置不同类型的设备?",-1))])]),_:1}),s(et,null,{default:i(()=>[s(D,{class:"pa-4",color:"info",variant:"tonal"},{default:i(()=>[...p[40]||(p[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),[[he,n.value===4&&o.value==="cloud"]]),Q(r("div",Ra,[r("div",Ba,[s(Ee,{class:"mb-4",color:"primary",size:"80",variant:"tonal"},{default:i(()=>[s(_,{size:"48"},{default:i(()=>[...p[42]||(p[42]=[u(" mdi-rocket-launch ",-1)])]),_:1})]),_:1}),p[43]||(p[43]=r("h3",{class:"text-h5 font-weight-bold mb-2"}," 渐进式注册 ",-1)),p[44]||(p[44]=r("p",{class:"text-body-2 text-medium-emphasis"}," 您可以暂时不配置 Classworks KV ",-1))]),s(Ke,{"model-value":X.value,class:"mb-6",color:"primary",height:"8",rounded:""},null,8,["model-value"]),s(se,null,{default:i(()=>[s(q,{cols:"12"},{default:i(()=>[s(D,{color:ue.value,variant:"tonal"},{default:i(()=>[s(xe,null,{default:i(()=>[r("div",Oa,[s(_,{color:ue.value,class:"mr-2",size:"32"},{default:i(()=>[u(g(S.value),1)]),_:1},8,["color"]),r("div",ja,g(ie.value),1)]),f.value?(c(),v("div",Ha,[r("div",Ka,[p[45]||(p[45]=r("strong",null,"设备名称:",-1)),u(g(f.value.deviceName),1)]),r("div",null,[p[46]||(p[46]=r("strong",null,"设备 UUID:",-1)),r("code",qa,g(f.value.uuid),1)])])):b("",!0),d.value==="error"?(c(),v("div",Wa,g(m.value),1)):b("",!0)]),_:1})]),_:1},8,["color"])]),_:1}),s(q,{cols:"12"},{default:i(()=>[s(D,{variant:"outlined"},{default:i(()=>[s(xe,null,{default:i(()=>[p[47]||(p[47]=r("div",{class:"text-subtitle-2 font-weight-medium mb-3"}," 过程日志 ",-1)),r("div",Ga,[(c(!0),v(I,null,N(k.value,(ee,te)=>(c(),v("div",{key:te,class:"text-caption log-line"},g(ee.time)+" · "+g(ee.message),1))),128)),k.value.length?b("",!0):(c(),v("div",Qa," 等待开始… "))])]),_:1})]),_:1})]),_:1})]),_:1}),r("div",Ja,[d.value==="idle"?(c(),x(y,{key:0,color:"primary","prepend-icon":"mdi-play",size:"large",onClick:U},{default:i(()=>[...p[48]||(p[48]=[u(" 开始创建 ",-1)])]),_:1})):b("",!0),d.value==="error"?(c(),x(y,{key:1,color:"error","prepend-icon":"mdi-refresh",variant:"outlined",onClick:re},{default:i(()=>[...p[49]||(p[49]=[u(" 重试 ",-1)])]),_:1})):b("",!0),d.value==="registering"?(c(),x(y,{key:2,loading:!0,color:"primary","prepend-icon":"mdi-progress-clock",variant:"tonal"},{default:i(()=>[...p[50]||(p[50]=[u(" 正在执行… ",-1)])]),_:1})):b("",!0),d.value==="success"?(c(),x(y,{key:3,color:"success","prepend-icon":"mdi-check-circle",size:"large",variant:"elevated",onClick:Z},{default:i(()=>[...p[51]||(p[51]=[u(" 应用令牌并关闭 ",-1)])]),_:1})):b("",!0),d.value==="success"?(c(),x(y,{key:4,color:"primary","prepend-icon":"mdi-open-in-new",size:"large",variant:"outlined",onClick:B},{default:i(()=>[...p[52]||(p[52]=[u(" 前往绑定账户 ",-1)])]),_:1})):b("",!0)])],512),[[he,n.value===5]])]),_:1}),s(K,{class:"pa-6 pt-0"},{default:i(()=>[n.value>1?(c(),x(y,{key:0,size:"large",variant:"text",onClick:Y},{default:i(()=>[s(_,{start:""},{default:i(()=>[...p[53]||(p[53]=[u(" mdi-chevron-left ",-1)])]),_:1}),p[54]||(p[54]=u(" 上一步 ",-1))]),_:1})):b("",!0),s(A),n.value[p[56]||(p[56]=u(" 下一步 ",-1)),s(_,{end:""},{default:i(()=>[...p[55]||(p[55]=[u(" mdi-chevron-right ",-1)])]),_:1})]),_:1},8,["disabled"])):b("",!0),n.value===Te||n.value===4?(c(),x(y,{key:2,color:"primary",size:"large",variant:"elevated",onClick:R},{default:i(()=>[...p[57]||(p[57]=[u(" 关闭 ",-1)])]),_:1})):b("",!0)]),_:1})]),_:1}))}},Xa=$(Ya,[["__scopeId","data-v-817c6e0e"]]),Za={key:0,class:"init-overlay"},eo={class:"init-container"},to={class:"main-card-row"},so={class:"card-horizontal-layout"},no={class:"card-icon-wrapper"},io={class:"card-horizontal-layout"},ao={class:"card-icon-wrapper"},oo={class:"card-horizontal-layout"},lo={class:"card-icon-wrapper"},ro={class:"options-buttons"},uo={__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=z(!1),o=z(!1),d=z(!1),m=z(!1),f=z(!1),h=z(null),k=G(()=>C("server.provider")),E=G(()=>k.value==="kv-server"||k.value==="classworkscloud"),F=G(()=>C("server.kvToken")),Y=G(()=>{var T;return(T=a.preconfig)!=null&&T.namespace?{namespace:a.preconfig.namespace,password:a.preconfig.authCode||"",autoExecute:a.preconfig.autoExecute||!1}:null}),L=()=>{const T=window.location.pathname,w=T==="/"||T==="/index"||T==="/index.html",U=E.value&&(!F.value||F.value==="");n.value=w&&U};Ie(()=>a.preconfig,T=>{T!=null&&T.autoOpen&&(T!=null&&T.namespace)&&n.value&&(console.log("检测到预配数据,自动打开设备认证对话框"),setTimeout(()=>{d.value=!0},500))},{immediate:!0,deep:!0}),rt(()=>{L()});const R=()=>{const T=C("server.authDomain"),w="d158067f53627d2b98babe8bffd2fd7d",U=window.location.origin,re=encodeURIComponent(`${U}/authorizecallback`),B=C("device.uuid")||"00000000-0000-4000-8000-000000000000";let Z=`${T}/authorize?app_id=${w}&mode=callback&callback_url=${re}&remark=Classworks 自动授权 来自${window.location.hostname} ${new Date().toLocaleString()}`;B!=="00000000-0000-4000-8000-000000000000"&&(Z+=`&uuid=${encodeURIComponent(B)}`),window.location.href=Z},J=T=>{o.value=!1,console.log("渐进式注册成功:",T),L(),l("done")},fe=T=>{var w;d.value=!1,console.log("认证成功:",T),(w=a.preconfig)!=null&&w.namespace&&console.log(`预配数据认证成功: ${a.preconfig.namespace}`),L(),l("done")},X=()=>{m.value=!1,L(),l("done")},ue=T=>{console.log("替代代码:",T),f.value=!1},S=()=>{ne("server.provider","kv-local"),n.value=!1,window.location.reload(),l("done")},ie=()=>{window.open(C("server.authDomain"),"_blank")};return(T,w)=>n.value?(c(),v("div",Za,[r("div",eo,[w[22]||(w[22]=r("div",{class:"init-header"},[r("div",{class:"title"}," 欢迎使用 Classworks "),r("div",{class:"subtitle"}," 请选择你的使用方式 ")],-1)),r("div",to,[s(D,{class:"main-service-card gradient-new clickable",elevation:"4",onClick:w[0]||(w[0]=U=>o.value=!0)},{default:i(()=>[s(xe,null,{default:i(()=>[r("div",so,[r("div",no,[s(_,{color:"primary",size:"48"},{default:i(()=>[...w[12]||(w[12]=[u(" mdi-new-box ",-1)])]),_:1})]),w[13]||(w[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(D,{class:"main-service-card gradient-registered clickable",elevation:"4",onClick:w[1]||(w[1]=U=>d.value=!0)},{default:i(()=>[s(xe,null,{default:i(()=>[r("div",io,[r("div",ao,[s(_,{color:"success",size:"48"},{default:i(()=>[...w[14]||(w[14]=[u(" mdi-account-check ",-1)])]),_:1})]),w[15]||(w[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(D,{class:"main-service-card clickable",elevation:"4",onClick:ie},{default:i(()=>[s(xe,null,{default:i(()=>[r("div",oo,[r("div",lo,[s(_,{color:"info",size:"48"},{default:i(()=>[...w[16]||(w[16]=[u(" mdi-database-cog ",-1)])]),_:1})]),w[17]||(w[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",ro,[s(y,{"prepend-icon":"mdi-laptop",size:"small",variant:"tonal",onClick:S},{default:i(()=>[...w[18]||(w[18]=[u(" 使用本地模式 ",-1)])]),_:1}),s(y,{"prepend-icon":"mdi-flash",size:"small",variant:"tonal",onClick:R},{default:i(()=>[...w[19]||(w[19]=[u(" 授权码式授权(弃用) ",-1)])]),_:1}),s(y,{"prepend-icon":"mdi-key",size:"small",variant:"tonal",onClick:w[2]||(w[2]=U=>m.value=!0)},{default:i(()=>[...w[20]||(w[20]=[u(" 输入 Token ",-1)])]),_:1}),s(y,{"prepend-icon":"mdi-code-tags",size:"small",variant:"tonal",onClick:w[3]||(w[3]=U=>f.value=!0)},{default:i(()=>[...w[21]||(w[21]=[u(" 输入替代代码 ",-1)])]),_:1})]),w[23]||(w[23]=r("div",{class:"footer-hint"}," 完成授权后可使用作业同步、考试看板等在线功能。 ",-1))]),s(O,{modelValue:o.value,"onUpdate:modelValue":w[5]||(w[5]=U=>o.value=U),"max-width":"600"},{default:i(()=>[s(Xa,{onClose:w[4]||(w[4]=U=>o.value=!1),onSuccess:J})]),_:1},8,["modelValue"]),s(O,{modelValue:d.value,"onUpdate:modelValue":w[7]||(w[7]=U=>d.value=U),"max-width":"500"},{default:i(()=>[s(aa,{ref_key:"deviceAuthDialog",ref:h,preconfig:Y.value,"show-cancel":!0,onCancel:w[6]||(w[6]=U=>d.value=!1),onSuccess:fe},null,8,["preconfig"])]),_:1},8,["modelValue"]),s(O,{modelValue:m.value,"onUpdate:modelValue":w[9]||(w[9]=U=>m.value=U),"max-width":"500"},{default:i(()=>[s(oa,{"show-cancel":!0,onCancel:w[8]||(w[8]=U=>m.value=!1),onSuccess:X})]),_:1},8,["modelValue"]),s(O,{modelValue:f.value,"onUpdate:modelValue":w[11]||(w[11]=U=>f.value=U),"max-width":"500"},{default:i(()=>[s(la,{"show-cancel":!0,onCancel:w[10]||(w[10]=U=>f.value=!1),onSubmit:ue})]),_:1},8,["modelValue"])])):b("",!0)}},Vt=$(uo,[["__scopeId","data-v-cbfbc6db"]]),co={name:"ExamScheduleCard",props:{examId:{type:String,required:!0},contentStyle:{type:Object,default:()=>({})}},computed:{...ot(De,["exams","loadingDetails"]),exam(){return this.exams[this.examId]},loading(){return this.loadingDetails[this.examId]}},mounted(){this.fetchExam(this.examId)},methods:{...at(De,["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}}}},mo={class:"text-truncate"},fo={key:0,class:"d-flex justify-center align-center fill-height",style:{"min-height":"200px"}},ho={class:"d-flex align-center mb-1"},go={class:"font-weight-medium"},po={class:"d-flex align-center"},vo={class:"font-weight-medium"},yo={key:2,class:"d-flex flex-column align-center justify-center fill-height text-grey mt-4"};function ko(t,e,a,l,n,o){return c(),x(D,{class:"fill-height d-flex flex-column rounded-xl",elevation:"2"},{default:i(()=>[s(P,{class:"d-flex align-center py-3 px-4 bg-primary text-white"},{default:i(()=>{var d;return[s(_,{class:"mr-2"},{default:i(()=>[...e[1]||(e[1]=[u("mdi-calendar-clock",-1)])]),_:1}),r("span",mo,g(((d=o.exam)==null?void 0:d.examName)||"加载中..."),1),s(A),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:le(a.contentStyle)},{default:i(()=>[o.loading?(c(),v("div",fo,[s(lt,{indeterminate:"",color:"primary"})])):o.exam?(c(),v(I,{key:1},[o.exam.message?(c(),x(pe,{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})):b("",!0),s(be,{density:"comfortable",class:"pa-0 bg-transparent"},{default:i(()=>[(c(!0),v(I,null,N(o.exam.examInfos,(d,m)=>(c(),x(we,{key:m,class:"px-0 mb-3"},{prepend:i(()=>[s(Ee,{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(dt,{class:"font-weight-bold text-h6 mb-1"},{default:i(()=>[u(g(d.name),1)]),_:2},1024),s(ut,{class:"text-body-1"},{default:i(()=>[r("div",ho,[s(_,{size:"small",color:"success",class:"mr-2"},{default:i(()=>[...e[2]||(e[2]=[u("mdi-clock-start",-1)])]),_:1}),r("span",go,g(o.formatTime(d.start)),1)]),r("div",po,[s(_,{size:"small",color:"error",class:"mr-2"},{default:i(()=>[...e[3]||(e[3]=[u("mdi-clock-end",-1)])]),_:1}),r("span",vo,g(o.formatTime(d.end)),1)])]),_:2},1024)]),_:2},1024))),128))]),_:1})],64)):(c(),v("div",yo,[s(_,{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 xo=$(co,[["render",ko],["__scopeId","data-v-52dc8ca5"]]);function Me(t,e){let a=null;return function(...l){a&&clearTimeout(a),a=setTimeout(()=>{t.apply(this,l)},e)}}function bo(t,e){let a=null,l=0;return function(...n){const o=Date.now();o-l{l=o,t.apply(this,n)},e)):(l=o,t.apply(this,n))}}const wo={name:"Classworks 作业板",components:{MessageLog:gt,RandomPicker:pt,FloatingToolbar:xt,FloatingICP:kt,HomeworkEditDialog:wt,InitServiceChooser:Vt,ChatWidget:Ne,StudentNameManager:Et,UrgentTestDialog:yt,AttendanceSidebar:St,AttendanceManagementDialog:bt,HomeworkGrid:It,HomeActions:Ct,ExamScheduleCard:xo,ExamConfigEditor:nt},setup(){const{mobile:t}=Se(),e=De();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:Se,state:{classNumber:"",namespaceInfo:null,deviceName:"",studentList:[],boardData:{homework:{},attendance:{absent:[],late:[],exclude:[]}},dialogVisible:!1,dialogTitle:"",textarea:"",dateString:"",synced:!1,attendDialogVisible:!1,contentStyle:{"font-size":`${C("font.size")}px`},uploadLoading:!1,downloadLoading:!1,snackbar:!1,snackbarText:"",fontSize:C("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 C("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})}}C("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 C("edit.autoSave")},blockNonTodayAutoSave(){return C("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 C("edit.refreshBeforeEdit")},emptySubjectDisplay(){return C("display.emptySubjectDisplay")},dynamicSort(){return C("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 C("randomPicker.enabled")},showListCardButton(){return C("display.showListCard")},confirmNonTodaySave(){return C("edit.confirmNonTodaySave")},blockPastDataEdit(){return C("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 C("display.showFullscreenButton")},showExamScheduleButton(){return C("display.showExamScheduleButton")},showAntiScreenBurnCard(){return C("display.showAntiScreenBurnCard")},showTestCardButton(){return C("developer.enabled")},shouldShowInit(){var n;const t=C("server.provider"),e=t==="kv-server"||t==="classworkscloud",a=C("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=C("server.provider");return!(t==="kv-server"||t==="classworkscloud")||!C("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=Me(this.uploadData,2e3),this.debouncedAttendanceSave=Me(async()=>{this.autoSave&&await this.trySave(!0)},2e3),this.throttledReflow=bo(()=>{this.$refs.gridContainer&&this.optimizeGridLayout(this.sortedItems)},200)},async mounted(){try{this.updateBackendUrl(),await this.initializeData(),await this.loadDeviceInfo(),this.setupAutoRefresh(),this.unwatchSettings=Re(()=>{this.updateSettings()}),this.$nextTick(()=>{const t=this.$refs.studentNameManager;t&&(this.studentNameInfo.name=t.currentStudentName,this.studentNameInfo.isStudent=t.isStudentToken,this.studentNameInfo.openDialog=()=>t.openDialog(),this.$watch(()=>t.currentStudentName,e=>{this.studentNameInfo.name=e}),this.$watch(()=>t.isStudentToken,e=>{this.studentNameInfo.isStudent=e}))}),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),jt()}catch(t){console.warn("主页面事件清理失败:",t)}},methods:{async loadDeviceInfo(){var t;try{const e=C("server.provider");if(!(e==="kv-server"||e==="classworkscloud"))return;const l=await Wt.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=C("server.provider");if(!(t==="kv-server"||t==="classworkscloud"))return;const a=C("server.kvToken");if(!a)return;const l=C("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;if(this.tokenDisplayInfo.readonly=a,!l){this.tokenDisplayInfo.show=!1;return}this.tokenDisplayInfo.text=e,this.tokenDisplayInfo.color="primary",this.tokenDisplayInfo.icon="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),t&&t.isStudentToken?(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=C("server.provider");const o=C("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 W.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 W.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 W.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 W.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`},ne("font.size",this.state.fontSize)},updateBackendUrl(){const t=C("server.provider"),e=C("server.classNumber");this.provider=t,this.state.classNumber=e},setupAutoRefresh(){const t=C("refresh.auto"),e=C("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=C("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=C("server.kvToken");if(!t){console.warn("未配置 KV Token,无法加入实时频道");return}ct(),Fe(t),this.$offConnect=Ot(()=>Fe(t)),this.debouncedRealtimeRefresh||(this.debouncedRealtimeRefresh=Me(async()=>{var h,k,E;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 Y=((k=l[F])==null?void 0:k.content)||"",L=((E=this.state.boardData.homework[F])==null?void 0:E.content)||"";Y!==L&&(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=ae("kv-key-changed",a),this.deviceEventHandler=mt({onKvChanged:e,enableLegacySupport:!0}),this.$offDeviceEvent=ae("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=C("server.classNumber");t.classNumber!==o&&(e.push({key:"server.classNumber",name:"班级",oldValue:o,newValue:t.classNumber,description:((l=ke["server.classNumber"])==null?void 0:l.description)||"班级编号",icon:((n=ke["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=ke[n];if(!m&&!n.includes(".")){const f=["server.","display.","theme.","edit.","refresh.","font.","randomPicker."];for(const h of f){const k=`${h}${n}`;if(ke[k]){d=k,m=ke[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=C(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 ft.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}ne(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 W.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 W.saveData("notification-list",e),this.notificationDetailDialog=!1}}},So={key:2,class:"d-flex"},Co={class:"text-h6 text-truncate font-weight-bold"},Do={class:"text-h4 font-weight-medium mb-4",style:{"line-height":"1.5"}},_o={class:"text-subtitle-1 text-grey"},To={class:"d-flex align-center flex-wrap"},Io={class:"text-subtitle-1"},Eo={class:"text-grey-darken-1"},Vo={class:"text-primary font-weight-medium"},No={key:1,class:"text-center py-4 text-grey"};function Ao(t,e,a,l,n,o){const d=Vt,m=Et,f=It,h=Ct,k=St,E=wt,F=bt,Y=gt,L=xt,R=kt,J=Ne,fe=yt,X=pt,ue=nt;return c(),v(I,null,[s(Qt,{class:"no-select"},{append:i(()=>[n.tokenDisplayInfo.readonly?(c(),x(M,{key:0,class:"mx-2",color:"warning","prepend-icon":"mdi-lock-alert",variant:"tonal"},{default:i(()=>[...e[29]||(e[29]=[u(" 只读 ",-1)])]),_:1})):b("",!0),n.tokenDisplayInfo.show?(c(),x(M,{key:1,style:le({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"])):b("",!0),o.shouldShowUrgentTestButton?(c(),x(y,{key:2,"prepend-icon":"mdi-chat",onClick:e[0]||(e[0]=S=>n.urgentTestDialog=!0),variant:"tonal"},{default:i(()=>[...e[30]||(e[30]=[u("发送通知",-1)])]),_:1})):b("",!0),s(y,{icon:"mdi-chat",variant:"text",onClick:e[1]||(e[1]=S=>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]=S=>t.$refs.messageLog.drawer=!0)},null,8,["badge","badge-color"]),s(y,{icon:"mdi-cog",variant:"text",onClick:e[3]||(e[3]=S=>t.$router.push("/settings"))})]),default:i(()=>[s(Gt,null,{default:i(()=>[u(g(o.titleText),1)]),_:1}),s(A)]),_:1}),o.shouldShowInit?(c(),x(d,{key:0,preconfig:n.preconfigData,onDone:e[4]||(e[4]=S=>n.settingsTick++)},null,8,["preconfig"])):b("",!0),o.shouldShowInit?b("",!0):(c(),x(m,{key:1,ref:"studentNameManager",onTokenInfoUpdated:o.updateTokenDisplayInfo},null,8,["onTokenInfoUpdated"])),o.shouldShowInit?b("",!0):(c(),v("div",So,[s(ht,{class:"main-window flex-grow-1 no-select bloom-container",fluid:""},{default:i(()=>[n.persistentNotifications.length>0?(c(),x(se,{key:0,class:"mb-4"},{default:i(()=>[s(q,{cols:"12"},{default:i(()=>[(c(!0),v(I,null,N(n.persistentNotifications,S=>(c(),x(D,{key:S.id,color:S.isUrgent?"error":"primary",class:"mb-2 cursor-pointer",variant:"tonal",onClick:ie=>o.showNotificationDetail(S)},{default:i(()=>[s(V,{class:"d-flex align-center py-3"},{default:i(()=>[r("span",Co,g(S.message),1),s(A),s(y,{icon:"mdi-chevron-right",variant:"text"})]),_:2},1024)]),_:2},1032,["color","onClick"]))),128))]),_:1})]),_:1})):b("",!0),s(O,{modelValue:n.notificationDetailDialog,"onUpdate:modelValue":e[8]||(e[8]=S=>n.notificationDetailDialog=S),"max-width":"700",scrollable:""},{default:i(()=>[n.currentNotification?(c(),x(D,{key:0,class:"rounded-xl"},{default:i(()=>[s(P,{class:"d-flex align-center pa-4 text-h5"},{default:i(()=>[r("span",{class:oe([n.currentNotification.isUrgent?"text-error":"","font-weight-bold"])},g(n.currentNotification.isUrgent?"强调通知":"通知详情"),3),s(A),s(y,{icon:"mdi-close",variant:"text",onClick:e[5]||(e[5]=S=>n.notificationDetailDialog=!1)})]),_:1}),s(de),s(V,{class:"pa-6"},{default:i(()=>[r("div",Do,g(n.currentNotification.message),1),r("div",_o," 发布时间:"+g(o.formatTime(n.currentNotification.timestamp)),1)]),_:1}),s(de),s(K,{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]=S=>o.removePersistentNotification(n.currentNotification.id))},{default:i(()=>[...e[31]||(e[31]=[u(" 删除通知 ",-1)])]),_:1}),s(A),s(y,{color:"primary",size:"x-large",variant:"elevated",class:"px-8",onClick:e[7]||(e[7]=S=>n.notificationDetailDialog=!1)},{default:i(()=>[...e[32]||(e[32]=[u(" 关闭 ",-1)])]),_:1})]),_:1})]),_:1})):b("",!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]=S=>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"]),n.upcomingExams.length>0&&!o.hasExamCard?(c(),x(pe,{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",To,[e[33]||(e[33]=r("span",{class:"mr-2"},"检测到未来两天内有以下考试:",-1)),(c(!0),v(I,null,N(n.upcomingExams,S=>(c(),x(M,{key:S.id,size:"small",class:"mr-1 mb-1",color:"primary"},{default:i(()=>[u(g(S.examName),1)]),_:2},1024))),128))])]),_:1})):b("",!0)]),_:1}),o.isMobile?b("",!0):(c(),x(k,{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(E,{modelValue:n.state.dialogVisible,"onUpdate:modelValue":e[10]||(e[10]=S=>n.state.dialogVisible=S),"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($t,{modelValue:n.state.snackbar,"onUpdate:modelValue":e[11]||(e[11]=S=>n.state.snackbar=S),timeout:2e3},{default:i(()=>[u(g(n.state.snackbarText),1)]),_:1},8,["modelValue"]),s(F,{modelValue:n.state.attendanceDialog,"onUpdate:modelValue":e[12]||(e[12]=S=>n.state.attendanceDialog=S),"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(Y,{ref:"messageLog"},null,512),s(L,{"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]=S=>t.$refs.messageLog.drawer=!0),onOpenSettings:e[14]||(e[14]=S=>t.$router.push("/settings")),onDateSelect:o.handleDateSelect,onPrevDay:e[15]||(e[15]=S=>o.navigateDay(-1)),onNextDay:e[16]||(e[16]=S=>o.navigateDay(1)),onCopyToToday:o.copyHomeworkToToday},null,8,["is-today","loading","copy-to-today-loading","selected-date","unread-count","onRefresh","onZoom","onDateSelect","onCopyToToday"]),s(R),s(J,{modelValue:n.isChatOpen,"onUpdate:modelValue":e[17]||(e[17]=S=>n.isChatOpen=S),"show-button":!1},null,8,["modelValue"]),s(fe,{modelValue:n.urgentTestDialog,"onUpdate:modelValue":e[18]||(e[18]=S=>n.urgentTestDialog=S)},null,8,["modelValue"]),s(O,{modelValue:n.confirmDialog.show,"onUpdate:modelValue":e[19]||(e[19]=S=>n.confirmDialog.show=S),"max-width":"400"},{default:i(()=>[s(D,null,{default:i(()=>[s(P,{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(K,null,{default:i(()=>[s(A),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(X,{ref:"randomPicker",attendance:n.state.boardData.attendance,"student-list":n.state.studentList},null,8,["attendance","student-list"]),s(O,{modelValue:n.urlConfigDialog.show,"onUpdate:modelValue":e[20]||(e[20]=S=>n.urlConfigDialog.show=S),"max-width":"500"},{default:i(()=>[s(D,null,{default:i(()=>[s(P,{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(be,{density:"compact"},{default:i(()=>[(c(!0),v(I,null,N(n.urlConfigDialog.changes,S=>(c(),x(we,{key:S.key},{prepend:i(()=>[s(_,{icon:S.icon,class:"mr-2",size:"small"},null,8,["icon"])]),default:i(()=>[s(dt,{class:"d-flex align-center"},{default:i(()=>[r("span",Io,g(S.name),1),s(Be,{activator:"parent",location:"top"},{default:i(()=>[u(g(S.description||S.key),1)]),_:2},1024)]),_:2},1024),s(ut,null,{default:i(()=>[r("span",Eo,g(S.oldValue),1),s(_,{class:"mx-1",icon:"mdi-arrow-right",size:"small"}),r("span",Vo,g(S.newValue),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1}),s(K,null,{default:i(()=>[s(A),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(O,{modelValue:n.showExamDetailDialog,"onUpdate:modelValue":e[23]||(e[23]=S=>n.showExamDetailDialog=S),persistent:"",fullscreen:""},{default:i(()=>[n.selectedExamId?(c(),x(D,{key:0},{default:i(()=>[s(P,{class:"d-flex align-center pa-4"},{default:i(()=>[e[42]||(e[42]=u(" 编辑考试配置 ",-1)),s(A),s(y,{icon:"mdi-close",variant:"text",onClick:e[21]||(e[21]=S=>n.showExamDetailDialog=!1)})]),_:1}),s(V,{class:"pa-4",style:{"max-height":"70vh","overflow-y":"auto"}},{default:i(()=>[s(ue,{"config-id":n.selectedExamId,"dialog-mode":!0,onSaved:o.onExamConfigSaved,onDeleted:o.onExamConfigDeleted},null,8,["config-id","onSaved","onDeleted"])]),_:1}),s(de),s(K,{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(A),s(y,{color:"primary",variant:"text",onClick:e[22]||(e[22]=S=>n.showExamDetailDialog=!1)},{default:i(()=>[...e[44]||(e[44]=[u(" 关闭 ",-1)])]),_:1})]),_:1})]),_:1})):b("",!0)]),_:1},8,["modelValue"]),s(O,{modelValue:n.showAddExamDialog,"onUpdate:modelValue":e[25]||(e[25]=S=>n.showAddExamDialog=S),"max-width":"500"},{default:i(()=>[s(D,null,{default:i(()=>[s(P,{class:"text-h6"},{default:i(()=>[...e[45]||(e[45]=[u("预览考试看板",-1)])]),_:1}),s(V,null,{default:i(()=>[l.examStore.examList.length>0?(c(),x(be,{key:0},{default:i(()=>[(c(!0),v(I,null,N(l.examStore.examList,S=>{var ie;return c(),x(we,{key:S.id,title:((ie=l.examStore.exams[S.id])==null?void 0:ie.examName)||S.id,subtitle:S.id,onClick:T=>o.addExamCard(S.id)},{prepend:i(()=>[s(_,{color:"primary"},{default:i(()=>[...e[46]||(e[46]=[u("mdi-calendar-text",-1)])]),_:1})]),append:i(()=>[s(y,{icon:o.isExamCardAdded(S.id)?"mdi-check":"mdi-plus",color:o.isExamCardAdded(S.id)?"success":"grey",variant:"text"},null,8,["icon","color"])]),_:2},1032,["title","subtitle","onClick"])}),128))]),_:1})):(c(),v("div",No," 暂无考试配置 "))]),_:1}),s(K,null,{default:i(()=>[s(A),s(y,{color:"primary",variant:"text",onClick:e[24]||(e[24]=S=>n.showAddExamDialog=!1)},{default:i(()=>[...e[47]||(e[47]=[u("关闭",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),s(O,{modelValue:n.notificationDetailDialog,"onUpdate:modelValue":e[28]||(e[28]=S=>n.notificationDetailDialog=S),"max-width":"600"},{default:i(()=>[n.currentNotification?(c(),x(D,{key:0},{default:i(()=>[s(P,{class:oe(["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(K,null,{default:i(()=>[s(y,{color:"error",variant:"text",onClick:e[26]||(e[26]=S=>o.removePersistentNotification(n.currentNotification.id))},{default:i(()=>[...e[48]||(e[48]=[u("删除",-1)])]),_:1}),s(A),s(y,{color:"primary",onClick:e[27]||(e[27]=S=>n.notificationDetailDialog=!1)},{default:i(()=>[...e[49]||(e[49]=[u("关闭",-1)])]),_:1})]),_:1})]),_:1})):b("",!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 tl=$(wo,[["render",Ao]]);export{tl as default};