mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2026-03-21 09:13:10 +00:00
7 lines
141 KiB
JavaScript
7 lines
141 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-C305lth9.js","./vendor-vuetify-DYDJMXkZ.js","./vendor-vue-PFj_oO9L.js","./index-CXKF55qP.css","./dataProvider-BLWNaKs2.js","./vendor-utils-DDRLRfsI.js","./serverRotation-CMezt1Be.js","./MessageLog-DdVQpYHs.js","./VAppBarTitle-_fugaUpX.js","./VAppBarTitle-CczdD-Q2.css","./MessageLog-BGkFwivK.css","./RandomPicker-C1p-Vu66.js","./VTextField-0hAB9hej.js","./VTextField-DTDEIDq0.css","./VTooltip-i51F1dF1.js","./VTooltip-D7EaNDeY.css","./VChip-BAz4LI6s.js","./VChip-Dmz_1Lnv.css","./RandomPicker-CFzd4pLS.css","./FloatingToolbar-CA5SbKJ5.js","./VSheet-HyWrdTUo.js","./VSheet-DxsDksIw.css","./VDatePicker-DSuAdu7Q.js","./VPicker-DQqGj6aG.js","./VPicker-Dm9DplUc.css","./VDatePicker-zglzEVGT.css","./FloatingToolbar-DbFL4asY.css","./ChatWidget-C65TaUP3.js","./socketClient-BhDBx1xd.js","./vendor-socket-CyTcV1HU.js","./soundList-D9U-Grcp.js","./deviceEvents-BdDlJtiW.js","./VRow-BQOh1CLA.js","./VRow-D2ArqUC2.css","./VPagination-DtF5C3cQ.js","./VPagination-BF2MZmld.css","./VTextarea-6rLGvsne.js","./VTextarea-_xVwaw_z.css","./ChatWidget-DT8kwi-O.css","./HomeworkEditDialog-CauV6ORR.js","./VAlert-CWWQx2wA.js","./VAlert-D_OX1cfW.css","./HomeworkEditDialog-BYeU7sR3.css","./InitServiceChooser-C1t4KK09.js","./VExpansionPanels-BttaA-wE.js","./VExpansionPanels-kEj4ZJQK.css","./InitServiceChooser-CJilcHuq.css","./StudentNameManager-L676MjOe.js","./VAutocomplete-Bjjayd_c.js","./VSelect-CY8W2KzJ.js","./VCheckboxBtn-CeMEzWtF.js","./VSwitch-G7IB1xuY.js","./VSwitch-Bk42mIwg.css","./VSelect-DHZViySU.css","./VAutocomplete-Ygy_KjMW.css","./VCombobox-C9zXoZ4c.js","./VCombobox-r6cc1Iy_.css","./StudentNameManager-tn0RQdqM.css","./UrgentTestDialog-9MfQJHo_.js","./VContainer-DopeAmBG.js","./VContainer-B1KSavhG.css","./VForm-D0ivLYhu.js","./VCheckbox-VmVYHMG6.js","./VCheckbox-ZL-u1kGB.css","./UrgentTestDialog-BdqUELUV.css","./AttendanceSidebar-BPGafVhq.js","./AttendanceManagementDialog-BVh2yfQP.js","./AttendanceManagementDialog-B_Clb251.css","./PwaInstallCard-LcNhfX6l.js","./ExamScheduleCard-Eve4AKjn.js","./VTabs-Dgx9Ksgk.js","./VTable-CsPj98NG.js","./VTable-CNLJxQof.css","./VTabs-566n5b08.css","./ExamScheduleCard-B03q7hf4.css","./ExamConfigEditor-9yfAaq4d.js","./VSkeletonLoader-CtQHOFGP.js","./VSkeletonLoader-C11ZEozu.css","./VTimePicker-BnlAvQ6w.js","./VTimePicker-kg19K8X1.css","./ExamConfigEditor-CMd_Zlpr.css"])))=>i.map(i=>d[i]);
|
||
var $e=Object.defineProperty;var et=(t,e,i)=>e in t?$e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var C=(t,e,i)=>et(t,typeof e!="symbol"?e+"":e,i);import{_ as H,V as ke,c as I,d as T,e as _,S as ne,w as Ce,f as x,g as E,h as b,i as F,j as oe,k as B,l as U,s as J,n as D,o as tt,p as $,q as ee,r as ve,t as we,v as st,x as N,y as ze,z as it,A as X}from"./index-C305lth9.js";import{X as c,_ as g,j as o,N as P,S as h,a5 as nt,a6 as ot,a7 as at,Y as v,Z as a,k as r,F as k,a2 as M,n as O,$ as w,a1 as u,a8 as z,a9 as Ee,P as rt,R as lt,V as dt,U as Re,e as ct,a3 as V}from"./vendor-vue-PFj_oO9L.js";import{d as R,a as ut,k as ht}from"./dataProvider-BLWNaKs2.js";import{a as ge,g as Fe}from"./vendor-utils-DDRLRfsI.js";import{V as L}from"./VChip-BAz4LI6s.js";import{V as Be,a as Z}from"./VTabs-Dgx9Ksgk.js";import{V as Oe,a as Q,b as mt}from"./VTable-CsPj98NG.js";import{V as ae}from"./VAlert-CWWQx2wA.js";import{V as ft,a as gt}from"./VTooltip-i51F1dF1.js";import{V as se}from"./VTextField-0hAB9hej.js";import{p as pt,d as yt}from"./soundList-D9U-Grcp.js";import{V as Ie}from"./VSwitch-G7IB1xuY.js";import{a0 as Se}from"./vendor-vuetify-DYDJMXkZ.js";import{V as je}from"./VContainer-DopeAmBG.js";import{g as bt,j as Ve,o as vt,a as Ne,l as wt}from"./socketClient-BhDBx1xd.js";import{c as St}from"./deviceEvents-BdDlJtiW.js";import{V as Dt,a as xt}from"./VAppBarTitle-_fugaUpX.js";import{V as kt,a as Ct}from"./VRow-BQOh1CLA.js";const Tt={__name:"AsyncLoadingPlaceholder",props:{height:{type:String,default:"120px"}},setup(t){return(e,i)=>(c(),g("div",{class:"async-loading-placeholder d-flex justify-center align-center",style:P({minHeight:t.height})},[o(ke,{indeterminate:"",color:"primary",size:"28",width:"2"})],4))}},ce=H(Tt,[["__scopeId","data-v-2d12e0c7"]]),_t={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,i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=new Date(e.getFullYear(),e.getMonth(),e.getDate()),s=i.getTime()-l.getTime(),n=Math.round(s/(1e3*60*60*24));if(n===0)return"今天";if(n===1)return"明天";if(n===2)return"后天";if(n===-1)return"昨天";if(n===-2)return"前天";const d=l.getDay()||7,m=new Date(l);m.setDate(l.getDate()-d+1);const p=new Date(l);if(p.setDate(l.getDate()+(7-d)),i>=m&&i<=p)return["周日","周一","周二","周三","周四","周五","周六"][t.getDay()];const f=t.getMonth()+1,S=t.getDate();return`${f}月${S}日`}}};function Mt(t,e,i,l,s,n){return c(),g("span",null,h(n.displayTime),1)}const Ue=H(_t,[["render",Mt]]),De=nt("exam",{state:()=>({examList:[],exams:{},loadingList:!1,loadingDetails:{}}),actions:{async fetchExamList(){if(!this.loadingList){this.loadingList=!0;try{const t=await R.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 R.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=[],i=new Date,l=new Date(i.getTime()+2*24*60*60*1e3),s=this.examList.slice(0,t);for(const n of s){let d=this.exams[n.id];d||(d=await this.fetchExam(n.id)),d&&d.examInfos&&Array.isArray(d.examInfos)&&d.examInfos.some(p=>{const f=new Date(p.start);return f>=i&&f<=l})&&e.push({id:n.id,...d})}return e}}}),Et={name:"ConciseExamCard",components:{RelativeTimeDisplay:Ue},props:{examId:{type:String,required:!0},contentStyle:{type:Object,default:()=>({})},readonly:{type:Boolean,default:!1}},computed:{...at(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,s)=>new Date(l.start)-new Date(s.start)),e=[];let i=null;return t.forEach(l=>{const n=new Date(l.start).toDateString();(!i||i.key!==n)&&(i={key:n,date:l.start,infos:[]},e.push(i)),i.infos.push(l)}),e}},mounted(){this.fetchExam(this.examId)},methods:{...ot(De,["fetchExam"]),formatTimeOnly(t){if(!t)return"";try{const e=new Date(t),i=e.getHours().toString().padStart(2,"0"),l=e.getMinutes().toString().padStart(2,"0");return`${i}:${l}`}catch{return""}},isPast(t){return t?new Date(t)<new Date:!1}}},Rt={class:"text-truncate"},It={key:0,class:"d-flex justify-center align-center py-4"},Vt={key:1,class:"d-flex flex-column"},Nt={class:"text-subtitle-2 font-weight-bold text-primary mb-1"},Pt={class:"font-weight-bold mr-2",style:{"font-size":"1.1em"}},At={class:"font-weight-medium text-grey-darken-2",style:{"font-size":"0.85em"}},Lt={key:2,class:"text-center text-caption text-grey py-2"};function zt(t,e,i,l,s,n){const d=Ue;return c(),v(_,{border:"",class:"fill-height d-flex flex-column cursor-pointer hover-elevation",elevation:"0",onClick:e[0]||(e[0]=m=>t.$emit("click"))},{default:a(()=>[o(I,{class:"d-flex align-center py-2 px-3 bg-primary-lighten-5 text-subtitle-1 font-weight-bold"},{default:a(()=>{var m;return[r("span",Rt,h(((m=n.exam)==null?void 0:m.examName)||"加载中..."),1)]}),_:1}),o(T,{class:"flex-grow-1 pa-4 overflow-y-auto",style:P(i.contentStyle)},{default:a(()=>[n.loading?(c(),g("div",It,[o(ke,{indeterminate:"",size:"24",color:"primary"})])):n.exam?(c(),g("div",Vt,[(c(!0),g(k,null,M(n.groupedExamInfos,(m,p)=>(c(),g("div",{key:p,class:"mb-3"},[r("div",Nt,[o(d,{time:m.date},null,8,["time"])]),(c(!0),g(k,null,M(m.infos,(f,S)=>(c(),g("div",{key:S,class:O(["d-flex align-center justify-space-between py-1 border-b-sm",{"border-none":S===m.infos.length-1,"text-grey":n.isPast(f.end)}])},[r("div",Pt,h(f.name),1),r("div",At,h(n.formatTimeOnly(f.start))+" - "+h(n.formatTimeOnly(f.end)),1)],2))),128))]))),128))])):(c(),g("div",Lt,"无法加载"))]),_:1},8,["style"])]),_:1})}const He=H(Et,[["render",zt],["__scopeId","data-v-33424f55"]]),Ft=["6IO4","5Lmz","6JCd6I6J","5rer","5aW4"],Bt=Ft.map(t=>Fe.decode(t)),Pe=.75,Ot={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*Pe}px`,"white-space":"pre-wrap","line-height":"1.6","text-align":"left"}},authorStyle(){return{"font-size":`${this.fontSize*Pe*.6}px`,"text-align":"left"}}},async mounted(){this.loadLocalSettings(),await this.loadKvSettings(),this.fetchSentence(),this.startTimer(),this.unwatch=Ce(()=>{this.loadLocalSettings(),this.startTimer()})},beforeUnmount(){this.stopTimer(),this.unwatch&&this.unwatch()},methods:{loadLocalSettings(){this.enabled=ne.getSetting("hitokoto.enabled"),this.refreshInterval=ne.getSetting("hitokoto.refreshInterval"),this.fontSize=ne.getSetting("font.size")},async loadKvSettings(){try{const t=await R.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(i=>i.trim()).filter(i=>i):[],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 i=null,l="",s="",n="";if(e==="hitokoto")i=(await ge.get("https://v1.hitokoto.cn/")).data,l=i.hitokoto,s=i.from_who,n=i.from;else if(e==="zhaoyu"){const d=await ge.get("https://hub.saintic.com/openservice/sentence/all.json");d.data.success&&(i=d.data.data,l=i.sentence||i.content||i.name,s=i.author,n=i.name||i.origin)}else if(e==="jinrishici")if(this.kvConfig.jinrishiciToken){const d=await ge.get("https://v2.jinrishici.com/one.json?client=npm-sdk/1.0&X-User-Token="+encodeURIComponent(this.kvConfig.jinrishiciToken),{});d.data.status==="success"&&(i=d.data.data,l=i.content,s=i.origin.author,n=i.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([...Bt,...this.kvConfig.sensitiveWords].some(p=>p&&l.includes(p)))return this.loading=!1,this.fetchSentence();this.sentence=l,this.author=s||"",this.origin=n||"未知"}}catch(t){console.error("Failed to fetch sentence",t),this.sentence="获取失败",this.author="",this.origin=""}finally{this.loading=!1}}}}},jt={key:0,class:"mr-2"},Ut={key:1};function Ht(t,e,i,l,s,n){return c(),v(_,{class:"hitokoto-card",elevation:"2",border:"",rounded:"xl",loading:s.loading,height:"100%",onClick:n.fetchSentence},{default:a(()=>[o(T,{class:"pa-6 d-flex flex-column justify-center",style:{height:"100%"}},{default:a(()=>[r("div",{class:"font-weight-medium mb-4 serif-font",style:P(n.contentStyle)},h(s.sentence),5),r("div",{class:"text-medium-emphasis serif-font",style:P(n.authorStyle)},[s.author?(c(),g("span",jt,h(s.author),1)):w("",!0),s.origin?(c(),g("span",Ut,"《"+h(s.origin)+"》",1)):w("",!0)],4)]),_:1})]),_:1},8,["loading","onClick"])}const We=H(Ot,[["render",Ht],["__scopeId","data-v-de957b7d"]]),Te=30,K=50,te=-50,ue=500,re=6,le=-100,Ge=0,Wt=-90,Gt=40;function Kt(t){let e=0,i=0;for(let s=0;s<t.length;s++){const n=t[s],d=Math.abs(n);d>i&&(i=d),e+=n*n}return{rms:Math.sqrt(e/Math.max(1,t.length)),peak:i}}function Yt(t){const e=Math.max(1e-12,t),i=20*Math.log10(e);return Math.max(le,Math.min(Ge,i))}function pe(t){const e=Math.max(1e-12,t.rms),i=Math.max(1e-12,t.baselineRms),l=t.baselineDb+20*Math.log10(e/i);return Math.max(20,Math.min(100,l))}function Ae(t){if(t.length===0)return le;const i=t.reduce((s,n)=>s+Math.pow(10,n/10),0)/t.length,l=10*Math.log10(Math.max(i,1e-12));return Math.max(le,Math.min(Ge,l))}function ie(t,e){if(t.length===0)return le;const i=t.map(p=>Math.pow(10,p/20));i.sort((p,f)=>p-f);const l=(i.length-1)*e,s=Math.floor(l),n=Math.ceil(l),d=l-s,m=s===n?i[s]:i[s]*(1-d)+i[n]*d;return 20*Math.log10(Math.max(m,1e-12))}function ye(t){return Math.max(0,Math.min(1,t))}const xe={maxLevelDb:55,baselineDb:Gt,showRealtimeDb:!0,avgWindowSec:1,sliceSec:Te,frameMs:K,scoreThresholdDbfs:te,segmentMergeGapMs:ue,maxSegmentsPerMin:re,alertSoundEnabled:!1},_e="noise-control-settings",de="NoiseControlSettingsUpdated";function Me(){try{const t=localStorage.getItem(_e);if(t)return{...xe,...JSON.parse(t)}}catch(t){console.warn("Failed to load settings",t)}return{...xe}}function Ke(t){const i={...Me(),...t};i.sliceSec=Te,i.frameMs=K,i.scoreThresholdDbfs=te,i.segmentMergeGapMs=ue,i.maxSegmentsPerMin=re,localStorage.setItem(_e,JSON.stringify(i)),window.dispatchEvent(new CustomEvent(de,{detail:i}))}function qt(){localStorage.removeItem(_e),window.dispatchEvent(new CustomEvent(de,{detail:xe}))}function Jt(t){const e=i=>t(i);return window.addEventListener(de,e),()=>window.removeEventListener(de,e)}function Le(t,e){const i=Math.max(0,t.p50Dbfs-te),l=ye(i/6),s=ye(t.overRatioDbfs/.3),n=t.sampledDurationMs&&t.sampledDurationMs>0?t.sampledDurationMs:e,d=Math.max(1e-6,n/6e4),m=t.segmentCount/d,p=ye(m/Math.max(1e-6,re)),S=100*(1-(.4*l+.3*s+.3*p));return{score:Math.max(0,Math.min(100,Math.round(S*10)/10)),scoreDetail:{sustainedPenalty:l,timePenalty:s,segmentPenalty:p,thresholdsUsed:{scoreThresholdDbfs:te,segmentMergeGapMs:ue,maxSegmentsPerMin:re},sustainedLevelDbfs:t.p50Dbfs,overRatioDbfs:t.overRatioDbfs,segmentCount:t.segmentCount,minutes:d,durationMs:e,sampledDurationMs:t.sampledDurationMs,coverageRatio:t.sampledDurationMs?t.sampledDurationMs/e:1}}}const Xt=()=>Math.random().toString(36).substring(2,15);class Zt{constructor(){C(this,"audioContext",null);C(this,"analyser",null);C(this,"stream",null);C(this,"sourceNode",null);C(this,"status","initializing");C(this,"listeners",new Set);C(this,"animationFrameId",null);C(this,"lastFrameTime",0);C(this,"baselineDb",40);C(this,"baselineRms",Math.pow(10,-60/20));C(this,"lastRms",0);C(this,"calibrationBuffer",[]);C(this,"isCalibrating",!1);C(this,"calibrationTargetDb",0);C(this,"calibrationCallback",null);C(this,"settingsUnsubscribe",null);C(this,"warmupFramesRemaining",0);C(this,"ringBuffer",[]);C(this,"ringBufferCapacity",200);C(this,"currentSliceStart",0);C(this,"sliceDbfsValues",[]);C(this,"sliceAboveThresholdDuration",0);C(this,"sliceFramesTotal",0);C(this,"sliceSampledDuration",0);C(this,"isAboveThreshold",!1);C(this,"segmentCount",0);C(this,"lastSegmentEndTs",0);C(this,"lastProcessedFrameTs",null);C(this,"gapCount",0);C(this,"maxGapMs",0);C(this,"cachedCurrentScore");C(this,"cachedCurrentScoreDetail");C(this,"lastScoreCalcTime",0);C(this,"lastCompletedSlice",null);C(this,"loop",()=>{if(this.status!=="active"||!this.analyser)return;const e=performance.now();e-this.lastFrameTime>=K&&(this.processFrame(e),this.lastFrameTime=e),this.animationFrameId=requestAnimationFrame(this.loop)});this.status="paused";const e=Me();this.updateLocalSettings(e),this.settingsUnsubscribe=Jt(i=>{this.updateLocalSettings(i.detail)})}updateLocalSettings(e){this.baselineDb=e.baselineDb,e.baselineRms&&e.baselineRms>0&&(this.baselineRms=e.baselineRms)}calibrate(e,i){if(this.status!=="active"){i==null||i(!1,"请先启动监测");return}this.isCalibrating=!0,this.calibrationTargetDb=e,this.calibrationBuffer=[],this.calibrationCallback=i||null,console.log(`Starting calibration to ${e}dB...`)}processCalibrationFrame(e){var l;if(!this.isCalibrating)return;this.calibrationBuffer.push(e);const i=3e3/K;if(this.calibrationBuffer.length>=i){const n=this.calibrationBuffer.reduce((d,m)=>d+m,0)/this.calibrationBuffer.length;this.isCalibrating=!1,this.baselineRms=n,this.baselineDb=this.calibrationTargetDb,Ke({baselineDb:this.calibrationTargetDb,baselineRms:n}),console.log(`Calibration complete: RMS ${n.toFixed(6)} -> ${this.calibrationTargetDb}dB`),(l=this.calibrationCallback)==null||l.call(this,!0,`校准完成!平均RMS: ${n.toFixed(6)}`),this.calibrationCallback=null}}subscribe(e){return this.listeners.add(e),this.emit(),()=>this.listeners.delete(e)}emit(){const e=this.ringBuffer.length>0?this.ringBuffer[this.ringBuffer.length-1]:null,i={status:this.status,currentDbfs:(e==null?void 0:e.dbfs)??-100,currentDisplayDb:(e==null?void 0:e.displayDb)??20,ringBuffer:[...this.ringBuffer],lastSlice:this.lastCompletedSlice,currentScore:this.cachedCurrentScore,currentScoreDetail:this.cachedCurrentScoreDetail};this.listeners.forEach(l=>l(i))}async start(){if(this.status!=="active")try{this.status="initializing",this.warmupFramesRemaining=10,this.emit(),this.audioContext=new(window.AudioContext||window.webkitAudioContext),this.stream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1}}),this.sourceNode=this.audioContext.createMediaStreamSource(this.stream);const e=this.audioContext.createBiquadFilter();e.type="highpass",e.frequency.value=80;const i=this.audioContext.createBiquadFilter();i.type="lowpass",i.frequency.value=8e3,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2048,this.analyser.smoothingTimeConstant=0,this.sourceNode.connect(e),e.connect(i),i.connect(this.analyser),this.status="active",this.resetSlice(),this.loop()}catch(e){console.error("Mic Error",e),this.status="permission-denied",this.emit()}}stop(){var e,i;this.status!=="paused"&&(this.sliceDbfsValues.length>0&&this.finalizeSlice(),this.status="paused",this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),(e=this.stream)==null||e.getTracks().forEach(l=>l.stop()),(i=this.audioContext)==null||i.close(),this.audioContext=null,this.analyser=null,this.stream=null,this.emit())}processFrame(e){if(!this.analyser)return;if(this.warmupFramesRemaining>0){this.warmupFramesRemaining--;return}const i=new Float32Array(this.analyser.fftSize);this.analyser.getFloatTimeDomainData(i);const l=Date.now(),{rms:s}=Kt(i);this.lastRms=s,this.isCalibrating&&this.processCalibrationFrame(s);const n=Yt(s),d=pe({rms:s,baselineRms:this.baselineRms,baselineDb:this.baselineDb});this.ringBuffer.push({t:l,dbfs:n,displayDb:d}),this.ringBuffer.length>this.ringBufferCapacity&&this.ringBuffer.shift();let m=K;if(this.lastProcessedFrameTs!==null){const p=l-this.lastProcessedFrameTs,f=Math.max(1e3,K*5);p>f?(this.gapCount++,this.maxGapMs=Math.max(this.maxGapMs,p),m=K):m=p}if(this.lastProcessedFrameTs=l,n>=Wt){this.sliceDbfsValues.push(n),this.sliceFramesTotal++,this.sliceSampledDuration+=m;const p=n>te;if(p&&(this.sliceAboveThresholdDuration+=m),p){if(!this.isAboveThreshold){const f=Date.now()-this.lastSegmentEndTs;(this.lastSegmentEndTs===0||f>ue)&&this.segmentCount++,this.isAboveThreshold=!0}}else this.isAboveThreshold&&(this.isAboveThreshold=!1,this.lastSegmentEndTs=Date.now())}e-this.lastScoreCalcTime>250&&(this.updateInterimScore(),this.lastScoreCalcTime=e),this.emit(),Date.now()-this.currentSliceStart>=Te*1e3&&this.finalizeSlice()}updateInterimScore(){if(this.sliceDbfsValues.length<10){this.cachedCurrentScore=100,this.cachedCurrentScoreDetail=void 0;return}Ae(this.sliceDbfsValues),Math.max(...this.sliceDbfsValues);const e=ie(this.sliceDbfsValues,.5);ie(this.sliceDbfsValues,.95);const i=this.sliceSampledDuration>0?this.sliceAboveThresholdDuration/this.sliceSampledDuration:0,l={p50Dbfs:e,overRatioDbfs:i,segmentCount:this.segmentCount,sampledDurationMs:this.sliceSampledDuration,gapCount:this.gapCount,maxGapMs:this.maxGapMs},s=Date.now()-this.currentSliceStart,{score:n,scoreDetail:d}=Le(l,s);this.cachedCurrentScore=n,this.cachedCurrentScoreDetail=d}resetSlice(){this.currentSliceStart=Date.now(),this.sliceDbfsValues=[],this.sliceAboveThresholdDuration=0,this.sliceFramesTotal=0,this.sliceSampledDuration=0,this.segmentCount=0,this.isAboveThreshold=!1,this.lastSegmentEndTs=0,this.gapCount=0,this.maxGapMs=0,this.lastProcessedFrameTs=null,this.cachedCurrentScore=100,this.cachedCurrentScoreDetail=void 0}finalizeSlice(){if(this.sliceDbfsValues.length===0){this.resetSlice();return}const e=Ae(this.sliceDbfsValues),i=Math.max(...this.sliceDbfsValues),l=ie(this.sliceDbfsValues,.5),s=ie(this.sliceDbfsValues,.95),n=this.sliceSampledDuration>0?this.sliceAboveThresholdDuration/this.sliceSampledDuration:0,d=pe({rms:Math.pow(10,e/20),baselineRms:this.baselineRms,baselineDb:this.baselineDb}),m=pe({rms:Math.pow(10,s/20),baselineRms:this.baselineRms,baselineDb:this.baselineDb}),p={avgDbfs:e,maxDbfs:i,p50Dbfs:l,p95Dbfs:s,overRatioDbfs:n,segmentCount:this.segmentCount,sampledDurationMs:this.sliceSampledDuration,gapCount:this.gapCount,maxGapMs:this.maxGapMs},f=Date.now()-this.currentSliceStart,{score:S,scoreDetail:j}=Le(p,f),A={id:Xt(),start:this.currentSliceStart,end:Date.now(),frames:this.sliceFramesTotal,raw:p,display:{avgDb:d,p95Db:m},score:S,scoreDetail:j};this.lastCompletedSlice=A,this.saveSlice(A),this.resetSlice()}saveSlice(e){try{const i=localStorage.getItem("noise-slices-v2"),l=i?JSON.parse(i):[];l.push(e);const s=14*24*60*60*1e3,n=Date.now(),d=l.filter(m=>n-m.end<s);d.length>1e3&&d.shift(),localStorage.setItem("noise-slices-v2",JSON.stringify(d))}catch(i){console.warn("Storage Full",i)}}getHistory(){try{const e=localStorage.getItem("noise-slices-v2");return e?JSON.parse(e):[]}catch{return[]}}clearHistory(){localStorage.removeItem("noise-slices-v2")}}const G=new Zt,Qt={name:"NoiseMonitorDetail",props:{modelValue:{type:Boolean,default:!1},status:{type:String,default:""},currentDb:{type:[Number,String],default:"--"},currentDbfs:{type:Number,default:0},noiseLevel:{type:String,default:"未知"},dbColor:{type:String,default:"grey"},currentScore:{type:Number,default:null},scoreDetail:{type:Object,default:null},ringBuffer:{type:Array,default:()=>[]},lastSlice:{type:Object,default:null},history:{type:Array,default:()=>[]},isMonitoring:{type:Boolean,default:!1},micPermissionState:{type:String,default:""},sessionActive:{type:Boolean,default:!1},sessionData:{type:Object,default:null},reportMeta:{type:Object,default:()=>({dates:{}})},selectedDate:{type:String,default:""},dateReports:{type:Array,default:()=>[]}},emits:["update:modelValue","start","stop","clear-history","select-date","clear-date-reports","clear-all-reports"],data(){return{activeTab:"realtime",confirmClearMode:"",waveformWidth:600,reportChartWidth:600,selectedReportIndex:0,showCalibrateDialog:!1,calibrationSettings:{},calibrateTargetDb:40,isCalibrating:!1,calibrateMessage:"",calibrateSuccess:!1,editBaselineDb:40,editBaselineRms:"",editMaxLevelDb:100}},computed:{scoreColor(){return this.currentScore===null?"grey":this.currentScore>=80?"success":this.currentScore>=60?"warning":"error"},scoreLabel(){return this.currentScore===null?"暂无评分":this.currentScore>=90?"非常安静":this.currentScore>=80?"环境良好":this.currentScore>=60?"需要注意":this.currentScore>=40?"比较嘈杂":"极度嘈杂"},alertThreshold(){var t;return((t=this.sessionConfig)==null?void 0:t.alertThresholdDb)||55},scorePenaltyItems(){if(!this.scoreDetail)return[];const t=100;return[{label:"持续",icon:"mdi-volume-high",color:"amber",percent:Math.round(this.scoreDetail.sustainedPenalty/t*100)},{label:"时长",icon:"mdi-clock-alert",color:"orange",percent:Math.round(this.scoreDetail.timePenalty/t*100)},{label:"打断",icon:"mdi-flash-alert",color:"pink",percent:Math.round(this.scoreDetail.segmentPenalty/t*100)}]},gridLines(){return[20,40,60,80].map(t=>({val:t,y:this.dbToY(t)}))},reportGridLines(){return[20,40,60,80].map(t=>({val:t,y:this.reportDbToY(t)}))},waveformPath(){if(!this.ringBuffer||this.ringBuffer.length<2)return null;const t=this.waveformWidth,e=this.ringBuffer.slice(-120),i=t/(e.length-1);return e.map((l,s)=>{const n=s*i,d=this.dbToY(l.displayDb??0);return`${s===0?"M":"L"}${n.toFixed(1)},${d.toFixed(1)}`}).join(" ")},waveformFillPath(){return this.waveformPath?`${this.waveformPath} L${this.waveformWidth},120 L0,120 Z`:null},showConfirmClear(){return this.confirmClearMode!==""},sortedDateKeys(){var t;return(t=this.reportMeta)!=null&&t.dates?Object.keys(this.reportMeta.dates).sort().reverse():[]},selectedReport(){return this.dateReports[this.selectedReportIndex]||null},reportCoverage(){var t,e,i;return!((e=(t=this.selectedReport)==null?void 0:t.samples)!=null&&e.length)||!((i=this.selectedReport)!=null&&i.duration)?0:(this.selectedReport.samples.length*2/(this.selectedReport.duration/1e3)*100).toFixed(1)},reportWaveformPath(){var l,s;if(!((s=(l=this.selectedReport)==null?void 0:l.samples)!=null&&s.length))return null;const t=this.selectedReport.samples;if(t.length<2)return null;const i=this.reportChartWidth/(t.length-1);return t.map((n,d)=>{const m=d*i,p=this.reportDbToY(n.db);return`${d===0?"M":"L"}${m.toFixed(1)},${p.toFixed(1)}`}).join(" ")},reportWaveformFillPath(){return this.reportWaveformPath?`${this.reportWaveformPath} L${this.reportChartWidth},140 L0,140 Z`:null},levelDistribution(){var d,m;if(!((m=(d=this.selectedReport)==null?void 0:d.samples)!=null&&m.length))return[{label:"安静",percent:0,color:"#4caf50"},{label:"正常",percent:0,color:"#8bc34a"},{label:"吵闹",percent:0,color:"#ff9800"},{label:"极吵",percent:0,color:"#f44336"}];const t=this.selectedReport.samples.map(p=>p.db),e=t.length;let i=0,l=0,s=0,n=0;return t.forEach(p=>{p<45?i++:p<60?l++:p<75?s++:n++}),[{label:"安静",percent:Math.round(i/e*100),color:"#4caf50"},{label:"正常",percent:Math.round(l/e*100),color:"#8bc34a"},{label:"吵闹",percent:Math.round(s/e*100),color:"#ff9800"},{label:"极吵",percent:Math.round(n/e*100),color:"#f44336"}]},reportPenaltyItems(){var e;if(!((e=this.selectedReport)!=null&&e.scorePenalties))return[];const t=this.selectedReport.scorePenalties;return[{label:"持续",color:"amber",percent:Math.min(100,Math.round(t.sustained/40*100))},{label:"时长",color:"orange",percent:Math.min(100,Math.round(t.time/30*100))},{label:"打断",color:"pink",percent:Math.min(100,Math.round(t.segment/30*100))}]}},watch:{modelValue(t){t&&this.$nextTick(()=>{this.updateWaveformWidth(),this.updateReportChartWidth()})},activeTab(){this.$nextTick(()=>{this.updateWaveformWidth(),this.updateReportChartWidth()})},selectedReportIndex(){this.$nextTick(()=>this.updateReportChartWidth())},selectedDate(){this.selectedReportIndex=0}},mounted(){this.updateWaveformWidth(),window.addEventListener("resize",this.handleResize)},beforeUnmount(){window.removeEventListener("resize",this.handleResize)},methods:{handleResize(){this.updateWaveformWidth(),this.updateReportChartWidth()},updateWaveformWidth(){this.$refs.waveformContainer&&(this.waveformWidth=this.$refs.waveformContainer.offsetWidth||600)},updateReportChartWidth(){this.$refs.reportChartContainer&&(this.reportChartWidth=this.$refs.reportChartContainer.offsetWidth||600)},dbToY(t){return 120-Math.max(0,Math.min(100,t))/100*120},reportDbToY(t){return 140-Math.max(0,Math.min(100,t))/100*140},doClearReports(){this.confirmClearMode==="all"?this.$emit("clear-all-reports"):this.confirmClearMode==="date"&&this.$emit("clear-date-reports",this.selectedDate),this.confirmClearMode="",this.selectedReportIndex=0},formatDateLabel(t){if(!t)return"";const e=new Date,i=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,l=new Date(e);l.setDate(l.getDate()-1);const s=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`;if(t===i)return"今天";if(t===s)return"昨天";const n=t.split("-");return`${parseInt(n[1])}月${parseInt(n[2])}日`},formatTime(t){const e=new Date(t);return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`},metaScoreColor(t){return t>=80?"success":t>=60?"warning":"error"},formatFullTime(t){if(!t)return"--";const e=new Date(t);return`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`},formatDuration(t){if(!t)return"0 分钟";const e=Math.floor(t/6e4),i=Math.floor(e/60),l=e%60;return i>0?`${i} 小时 ${l} 分钟`:`${l} 分钟`},formatSeconds(t){if(!t||t<0)return"0秒";const e=Math.floor(t/60),i=t%60;return e>0?`${e}分${i}秒`:`${i}秒`},reportScoreLabel(t){return t>=90?"优秀":t>=80?"良好":t>=60?"一般":t>=40?"较差":"极差"},openCalibrateDialog(){this.refreshCalibrationSettings(),this.showCalibrateDialog=!0},refreshCalibrationSettings(){const t=Me();this.calibrationSettings=t,this.editBaselineDb=t.baselineDb,this.editBaselineRms=t.baselineRms!=null?String(t.baselineRms):"",this.editMaxLevelDb=t.maxLevelDb},doAutoCalibrate(){this.isCalibrating=!0,this.calibrateMessage="",G.calibrate(this.calibrateTargetDb,(t,e)=>{this.isCalibrating=!1,this.calibrateSuccess=t,this.calibrateMessage=e,t&&this.refreshCalibrationSettings(),setTimeout(()=>{this.calibrateMessage=""},5e3)})},saveManualCalibration(){const t={baselineDb:this.editBaselineDb,maxLevelDb:this.editMaxLevelDb},e=parseFloat(this.editBaselineRms);!isNaN(e)&&e>0&&(t.baselineRms=e),Ke(t),this.refreshCalibrationSettings()},resetCalibration(){qt(),this.refreshCalibrationSettings()}}},$t={class:"noise-dashboard pa-5"},es={class:"d-flex align-center justify-center"},ts={class:"text-center"},ss={class:"noise-gauge-inner d-flex flex-column align-center justify-center"},is={class:"noise-level-bar mt-5 mx-auto",style:{"max-width":"500px"}},ns={class:"noise-gradient-bar"},os={class:"pa-5"},as={class:"d-flex align-center mb-3"},rs={class:"text-caption text-medium-emphasis"},ls={ref:"waveformContainer",class:"noise-waveform"},ds=["viewBox"],cs=["y1","x2","y2"],us=["y1","x2","y2"],hs=["d"],ms=["d"],fs={class:"pa-5"},gs={class:"d-flex align-center mb-3"},ps={key:0,class:"d-flex flex-wrap ga-4"},ys={class:"text-h6 font-weight-bold"},bs={class:"text-subtitle-1 font-weight-bold"},vs={class:"d-flex align-center"},ws={class:"text-body-2"},Ss={class:"d-flex align-center",style:{"min-width":"140px"}},Ds={class:"text-caption font-weight-medium",style:{"min-width":"36px","text-align":"right"}},xs={key:1,class:"text-center text-medium-emphasis py-4"},ks={class:"pa-4 d-flex align-center"},Cs={key:0,class:"text-center text-medium-emphasis py-12"},Ts={class:"pa-4"},_s={class:"d-flex align-center flex-wrap ga-2 mb-3"},Ms={class:"d-flex flex-wrap ga-2"},Es={key:0,class:"pa-4 pb-0"},Rs={class:"d-flex align-center ga-3 flex-wrap"},Is={class:"text-h6 font-weight-bold"},Vs={key:1,class:"text-center text-medium-emphasis py-8"},Ns={key:2,class:"pa-4 pt-3 d-flex flex-wrap ga-2"},Ps={class:"text-caption ml-1"},As={key:4,class:"report-content"},Ls={class:"pa-5 pb-0"},zs={class:"text-h6 font-weight-bold d-flex align-center"},Fs={class:"pa-5"},Bs={class:"report-grid"},Os={class:"report-stat-card"},js={class:"text-h6 font-weight-bold"},Us={class:"report-stat-card"},Hs={class:"text-h6 font-weight-bold"},Ws={class:"text-caption"},Gs={class:"report-stat-card"},Ks={class:"text-h6 font-weight-bold"},Ys={class:"report-stat-card"},qs={class:"text-h6 font-weight-bold"},Js={class:"report-stat-card"},Xs={class:"text-h6 font-weight-bold"},Zs={class:"report-stat-card"},Qs={class:"text-h6 font-weight-bold"},$s={class:"pa-5"},ei={ref:"reportChartContainer",class:"noise-waveform"},ti=["viewBox"],si=["y1","x2","y2"],ii=["y1","x2","y2"],ni=["d"],oi=["d"],ai={class:"text-caption text-medium-emphasis mt-2"},ri={class:"pa-5"},li={class:"d-flex flex-wrap ga-4"},di={class:"noise-level-distribution"},ci={class:"d-flex",style:{height:"16px","border-radius":"8px",overflow:"hidden"}},ui={class:"d-flex flex-wrap ga-3 mt-3 justify-center"},hi={class:"text-caption text-medium-emphasis"},mi={class:"text-body-2 mr-3",style:{"min-width":"32px"}},fi={class:"text-body-2 font-weight-bold",style:{"min-width":"40px","text-align":"right"}},gi={class:"d-flex align-center ga-6 flex-wrap"},pi={class:"text-body-1 font-weight-bold"},yi={class:"text-body-1 font-weight-bold font-monospace"},bi={class:"text-body-1 font-weight-bold"},vi={class:"d-flex align-center mb-2"},wi={class:"d-flex align-center ga-3 mb-5 flex-wrap"},Si={key:0,class:"text-caption text-warning"},Di={class:"d-flex align-center mb-2"},xi={class:"d-flex align-center ga-3 mb-4 flex-wrap"};function ki(t,e,i,l,s,n){return c(),v(B,{"model-value":i.modelValue,"max-width":"900",scrollable:"","onUpdate:modelValue":e[15]||(e[15]=d=>t.$emit("update:modelValue",d))},{default:a(()=>[o(_,{class:"rounded-xl noise-detail-card"},{default:a(()=>[o(I,{class:"d-flex align-center pa-4"},{default:a(()=>[o(x,{class:"mr-2",color:"primary"},{default:a(()=>[...e[16]||(e[16]=[u(" mdi-waveform ",-1)])]),_:1}),e[18]||(e[18]=r("span",{class:"text-h6 font-weight-bold"},"环境噪音监测",-1)),o(E),i.sessionActive?(c(),v(L,{key:0,color:"teal",size:"small",variant:"tonal",class:"mr-2"},{default:a(()=>{var d;return[o(x,{start:"",size:"12"},{default:a(()=>[...e[17]||(e[17]=[u(" mdi-record-circle ",-1)])]),_:1}),u(" "+h(((d=i.sessionData)==null?void 0:d.sessionName)||"自习中"),1)]}),_:1})):w("",!0),o(L,{color:i.isMonitoring?"success":"grey",size:"small",variant:"tonal",class:"mr-2"},{default:a(()=>[u(h(i.isMonitoring?"监测中":"已停止"),1)]),_:1},8,["color"]),o(b,{icon:"mdi-close",size:"small",variant:"text",onClick:e[0]||(e[0]=d=>t.$emit("update:modelValue",!1))})]),_:1}),o(Be,{modelValue:s.activeTab,"onUpdate:modelValue":e[1]||(e[1]=d=>s.activeTab=d),color:"primary",density:"compact",grow:""},{default:a(()=>[o(Z,{value:"realtime"},{default:a(()=>[o(x,{start:"",size:"18"},{default:a(()=>[...e[19]||(e[19]=[u(" mdi-pulse ",-1)])]),_:1}),e[20]||(e[20]=u(" 实时监测 ",-1))]),_:1}),o(Z,{value:"reports"},{default:a(()=>[o(x,{start:"",size:"18"},{default:a(()=>[...e[21]||(e[21]=[u(" mdi-chart-bar ",-1)])]),_:1}),e[22]||(e[22]=u(" 统计报告 ",-1))]),_:1})]),_:1},8,["modelValue"]),o(F),o(T,{class:"pa-0",style:{"max-height":"70vh"}},{default:a(()=>[o(Oe,{modelValue:s.activeTab,"onUpdate:modelValue":e[6]||(e[6]=d=>s.activeTab=d)},{default:a(()=>[o(Q,{value:"realtime"},{default:a(()=>[i.micPermissionState==="denied"?(c(),v(ae,{key:0,type:"error",variant:"tonal",class:"ma-4 mb-0",prominent:""},{prepend:a(()=>[o(x,{icon:"mdi-microphone-off",size:"28"})]),default:a(()=>[e[23]||(e[23]=r("div",{class:"text-subtitle-2 font-weight-bold mb-1"}," 麦克风权限被拒绝 ",-1)),e[24]||(e[24]=r("div",{class:"text-body-2"}," 浏览器已拒绝麦克风访问,无法进行噪音监测。请在浏览器地址栏左侧的锁图标中重新授予麦克风权限,然后刷新页面。 ",-1))]),_:1})):i.micPermissionState==="unavailable"?(c(),v(ae,{key:1,type:"warning",variant:"tonal",class:"ma-4 mb-0",prominent:""},{prepend:a(()=>[o(x,{icon:"mdi-microphone-question",size:"28"})]),default:a(()=>[e[25]||(e[25]=r("div",{class:"text-subtitle-2 font-weight-bold mb-1"}," 未检测到麦克风 ",-1)),e[26]||(e[26]=r("div",{class:"text-body-2"}," 当前设备未检测到麦克风硬件,无法进行噪音监测。请连接麦克风后刷新页面重试。 ",-1))]),_:1})):w("",!0),r("div",$t,[r("div",es,[r("div",ts,[r("div",{class:O(["noise-gauge-ring",`ring-${i.dbColor}`])},[r("div",ss,[r("span",{class:O(["noise-gauge-value font-weight-bold",`text-${i.dbColor}`])},h(i.currentDb),3),e[27]||(e[27]=r("span",{class:"text-caption text-medium-emphasis"},"dB",-1))])],2),r("div",{class:O(["text-subtitle-1 font-weight-medium mt-3",`text-${i.dbColor}`])},h(i.noiseLevel),3)])]),r("div",is,[e[28]||(e[28]=r("div",{class:"d-flex justify-space-between text-caption text-medium-emphasis mb-1"},[r("span",null,"0 dB"),r("span",null,"50"),r("span",null,"100 dB")],-1)),r("div",ns,[i.isMonitoring&&typeof i.currentDb=="number"?(c(),g("div",{key:0,class:"noise-indicator",style:P({left:`${Math.min(100,Math.max(0,i.currentDb))}%`})},null,4)):w("",!0)])])]),o(F),r("div",os,[r("div",as,[o(x,{class:"mr-2",size:"18",color:"primary"},{default:a(()=>[...e[29]||(e[29]=[u(" mdi-chart-line ",-1)])]),_:1}),e[30]||(e[30]=r("span",{class:"text-subtitle-2 font-weight-medium"},"噪音走势",-1)),o(E),r("span",rs," 最近 "+h(i.ringBuffer.length)+" 个采样 ",1)]),r("div",ls,[(c(),g("svg",{width:"100%",height:"120",viewBox:`0 0 ${s.waveformWidth} 120`,preserveAspectRatio:"none"},[(c(!0),g(k,null,M(n.gridLines,d=>(c(),g("line",{key:`grid-${d.val}`,x1:"0",y1:d.y,x2:s.waveformWidth,y2:d.y,stroke:"currentColor","stroke-opacity":"0.08","stroke-dasharray":"4,4"},null,8,cs))),128)),n.alertThreshold?(c(),g("line",{key:0,x1:"0",y1:n.dbToY(n.alertThreshold),x2:s.waveformWidth,y2:n.dbToY(n.alertThreshold),stroke:"rgb(var(--v-theme-error))","stroke-opacity":"0.5","stroke-dasharray":"6,3","stroke-width":"1.5"},null,8,us)):w("",!0),n.waveformPath?(c(),g("path",{key:1,d:n.waveformFillPath,fill:"url(#waveGradient-rt)",opacity:"0.3"},null,8,hs)):w("",!0),n.waveformPath?(c(),g("path",{key:2,d:n.waveformPath,fill:"none",stroke:"rgb(var(--v-theme-primary))","stroke-width":"2","stroke-linejoin":"round","stroke-linecap":"round"},null,8,ms)):w("",!0),e[31]||(e[31]=r("defs",null,[r("linearGradient",{id:"waveGradient-rt",x1:"0",y1:"0",x2:"0",y2:"1"},[r("stop",{offset:"0%","stop-color":"rgb(var(--v-theme-primary))","stop-opacity":"0.4"}),r("stop",{offset:"100%","stop-color":"rgb(var(--v-theme-primary))","stop-opacity":"0.02"})])],-1))],8,ds))],512)]),o(F),r("div",fs,[r("div",gs,[o(x,{class:"mr-2",size:"18",color:"amber"},{default:a(()=>[...e[32]||(e[32]=[u(" mdi-star-circle ",-1)])]),_:1}),e[33]||(e[33]=r("span",{class:"text-subtitle-2 font-weight-medium"},"实时评分",-1))]),i.currentScore!==null?(c(),g("div",ps,[o(_,{variant:"tonal",color:n.scoreColor,rounded:"xl",class:"flex-grow-1","min-width":"200"},{default:a(()=>[o(T,{class:"d-flex align-center pa-4"},{default:a(()=>[o(ke,{"model-value":i.currentScore,color:n.scoreColor,size:56,width:5,class:"mr-4"},{default:a(()=>[r("span",ys,h(i.currentScore),1)]),_:1},8,["model-value","color"]),r("div",null,[r("div",bs,h(n.scoreLabel),1),e[34]||(e[34]=r("div",{class:"text-caption text-medium-emphasis"}," 综合评分 (0-100) ",-1))])]),_:1})]),_:1},8,["color"]),i.scoreDetail?(c(),v(_,{key:0,variant:"outlined",rounded:"xl",class:"flex-grow-1","min-width":"200"},{default:a(()=>[o(T,{class:"pa-4"},{default:a(()=>[e[35]||(e[35]=r("div",{class:"text-subtitle-2 font-weight-medium mb-2"}," 扣分扣因 ",-1)),(c(!0),g(k,null,M(n.scorePenaltyItems,d=>(c(),g("div",{key:d.label,class:"d-flex align-center justify-space-between mb-1"},[r("div",vs,[o(x,{color:d.color,size:"14",class:"mr-2"},{default:a(()=>[u(h(d.icon),1)]),_:2},1032,["color"]),r("span",ws,h(d.label),1)]),r("div",Ss,[o(oe,{"model-value":d.percent,color:d.color,height:"6",rounded:"",class:"mr-2"},null,8,["model-value","color"]),r("span",Ds,h(d.percent)+"% ",1)])]))),128))]),_:1})]),_:1})):w("",!0)])):(c(),g("div",xs,[o(x,{size:"32",class:"mb-2"},{default:a(()=>[...e[36]||(e[36]=[u(" mdi-chart-arc ",-1)])]),_:1}),e[37]||(e[37]=r("div",{class:"text-body-2"}," 开始监测后将显示评分 ",-1))]))]),o(F),r("div",ks,[i.isMonitoring?(c(),v(b,{key:1,color:"error",variant:"tonal","prepend-icon":"mdi-stop",size:"large",class:"px-6",onClick:e[3]||(e[3]=d=>t.$emit("stop"))},{default:a(()=>[...e[39]||(e[39]=[u(" 停止监测 ",-1)])]),_:1})):(c(),v(b,{key:0,color:"success",variant:"elevated","prepend-icon":"mdi-play",size:"large",class:"px-6",disabled:i.micPermissionState==="denied"||i.micPermissionState==="unavailable",onClick:e[2]||(e[2]=d=>t.$emit("start"))},{default:a(()=>[...e[38]||(e[38]=[u(" 开始监测 ",-1)])]),_:1},8,["disabled"])),o(E),o(b,{variant:"tonal",color:"deep-purple","prepend-icon":"mdi-crosshairs-gps",onClick:n.openCalibrateDialog},{default:a(()=>[...e[40]||(e[40]=[u(" 校准 ",-1)])]),_:1},8,["onClick"])])]),_:1}),o(Q,{value:"reports"},{default:a(()=>[n.sortedDateKeys.length===0?(c(),g("div",Cs,[o(x,{size:"48",class:"mb-3"},{default:a(()=>[...e[41]||(e[41]=[u(" mdi-chart-box-outline ",-1)])]),_:1}),e[42]||(e[42]=r("div",{class:"text-body-1"}," 暂无统计报告 ",-1)),e[43]||(e[43]=r("div",{class:"text-caption mt-1"}," 在配置的晚自习时间段内,系统会自动记录并生成报告 ",-1))])):(c(),g(k,{key:1},[r("div",Ts,[r("div",_s,[o(x,{size:"18",color:"teal",class:"mr-1"},{default:a(()=>[...e[44]||(e[44]=[u(" mdi-calendar ",-1)])]),_:1}),e[46]||(e[46]=r("span",{class:"text-subtitle-2 font-weight-medium"},"选择日期",-1)),o(E),o(b,{color:"error",size:"x-small",variant:"text","prepend-icon":"mdi-delete-sweep",onClick:e[4]||(e[4]=d=>s.confirmClearMode="all")},{default:a(()=>[...e[45]||(e[45]=[u(" 清空全部 ",-1)])]),_:1})]),r("div",Ms,[(c(!0),g(k,null,M(n.sortedDateKeys,d=>(c(),v(L,{key:d,color:i.selectedDate===d?"primary":void 0,variant:i.selectedDate===d?"elevated":"tonal",size:"small",onClick:m=>t.$emit("select-date",d)},{default:a(()=>[o(x,{start:"",size:"14"},{default:a(()=>[...e[47]||(e[47]=[u(" mdi-calendar-blank ",-1)])]),_:1}),u(" "+h(n.formatDateLabel(d))+" ",1),o(ft,{content:i.reportMeta.dates[d].count,color:"primary",inline:"",class:"ml-1"},null,8,["content"])]),_:2},1032,["color","variant","onClick"]))),128))])]),o(F),i.selectedDate&&i.reportMeta.dates[i.selectedDate]?(c(),g("div",Es,[r("div",Rs,[r("div",Is,h(n.formatDateLabel(i.selectedDate)),1),o(L,{size:"small",color:n.metaScoreColor(i.reportMeta.dates[i.selectedDate].avgScore),variant:"tonal"},{default:a(()=>[u(" 均分 "+h(i.reportMeta.dates[i.selectedDate].avgScore),1)]),_:1},8,["color"]),o(L,{size:"small",variant:"tonal"},{default:a(()=>[u(h(i.reportMeta.dates[i.selectedDate].count)+" 条记录 ",1)]),_:1}),o(E),o(b,{color:"error",size:"x-small",variant:"text","prepend-icon":"mdi-delete",onClick:e[5]||(e[5]=d=>s.confirmClearMode="date")},{default:a(()=>[...e[48]||(e[48]=[u(" 清空当日 ",-1)])]),_:1})])])):w("",!0),i.dateReports.length===0&&i.selectedDate?(c(),g("div",Vs,[o(x,{size:"32"},{default:a(()=>[...e[49]||(e[49]=[u(" mdi-file-document-outline ",-1)])]),_:1}),e[50]||(e[50]=r("div",{class:"text-body-2 mt-1"}," 该日期暂无报告数据 ",-1))])):w("",!0),i.dateReports.length>0?(c(),g("div",Ns,[(c(!0),g(k,null,M(i.dateReports,(d,m)=>(c(),v(L,{key:d.startTime,color:s.selectedReportIndex===m?"teal":void 0,variant:s.selectedReportIndex===m?"elevated":"outlined",size:"small",onClick:p=>s.selectedReportIndex=m},{default:a(()=>[u(h(d.sessionName)+" ",1),r("span",Ps,h(n.formatTime(d.startTime)),1)]),_:2},1032,["color","variant","onClick"]))),128))])):w("",!0),n.selectedReport?(c(),v(F,{key:3})):w("",!0),n.selectedReport?(c(),g("div",As,[r("div",Ls,[r("div",zs,h(n.selectedReport.sessionName)+" 统计报告 ",1)]),r("div",Fs,[e[57]||(e[57]=r("div",{class:"d-flex align-center mb-3"},[r("span",{class:"report-section-line bg-teal"}),r("span",{class:"text-subtitle-2 font-weight-bold ml-2"},"报告概览")],-1)),r("div",Bs,[r("div",Os,[e[51]||(e[51]=r("div",{class:"text-caption text-medium-emphasis"}," 时长 ",-1)),r("div",js,h(n.formatDuration(n.selectedReport.duration)),1)]),r("div",Us,[e[52]||(e[52]=r("div",{class:"text-caption text-medium-emphasis"}," 表现 ",-1)),r("div",Hs,[u(h(n.selectedReport.score)+" 分 ",1),r("span",Ws,"("+h(n.reportScoreLabel(n.selectedReport.score))+")",1)])]),r("div",Gs,[e[53]||(e[53]=r("div",{class:"text-caption text-medium-emphasis"}," 峰值 ",-1)),r("div",Ks,h(n.selectedReport.maxDb)+" dB ",1)]),r("div",Ys,[e[54]||(e[54]=r("div",{class:"text-caption text-medium-emphasis"}," 平均 ",-1)),r("div",qs,h(n.selectedReport.avgDb)+" dB ",1)]),r("div",Js,[e[55]||(e[55]=r("div",{class:"text-caption text-medium-emphasis"}," 超阈时长 ",-1)),r("div",Xs,h(n.formatSeconds(n.selectedReport.overThresholdDuration)),1)]),r("div",Zs,[e[56]||(e[56]=r("div",{class:"text-caption text-medium-emphasis"}," 打断次数 ",-1)),r("div",Qs,h(n.selectedReport.segmentCount),1)])])]),r("div",$s,[e[59]||(e[59]=r("div",{class:"d-flex align-center mb-3"},[r("span",{class:"report-section-line bg-teal"}),r("span",{class:"text-subtitle-2 font-weight-bold ml-2"},"噪音走势")],-1)),r("div",ei,[(c(),g("svg",{width:"100%",height:"140",viewBox:`0 0 ${s.reportChartWidth} 140`,preserveAspectRatio:"none"},[(c(!0),g(k,null,M(n.reportGridLines,d=>(c(),g("line",{key:`rg-${d.val}`,x1:"0",y1:d.y,x2:s.reportChartWidth,y2:d.y,stroke:"currentColor","stroke-opacity":"0.1","stroke-dasharray":"4,4"},null,8,si))),128)),r("line",{x1:"0",y1:n.reportDbToY(n.selectedReport.alertThresholdDb||55),x2:s.reportChartWidth,y2:n.reportDbToY(n.selectedReport.alertThresholdDb||55),stroke:"rgb(var(--v-theme-error))","stroke-opacity":"0.6","stroke-dasharray":"6,3","stroke-width":"1.5"},null,8,ii),n.reportWaveformPath?(c(),g("path",{key:0,d:n.reportWaveformFillPath,fill:"url(#reportGrad)",opacity:"0.3"},null,8,ni)):w("",!0),n.reportWaveformPath?(c(),g("path",{key:1,d:n.reportWaveformPath,fill:"none",stroke:"rgb(var(--v-theme-primary))","stroke-width":"1.5","stroke-linejoin":"round"},null,8,oi)):w("",!0),e[58]||(e[58]=r("defs",null,[r("linearGradient",{id:"reportGrad",x1:"0",y1:"0",x2:"0",y2:"1"},[r("stop",{offset:"0%","stop-color":"rgb(var(--v-theme-primary))","stop-opacity":"0.3"}),r("stop",{offset:"100%","stop-color":"rgb(var(--v-theme-primary))","stop-opacity":"0.02"})])],-1))],8,ti))],512),r("div",ai," 统计范围:"+h(n.formatFullTime(n.selectedReport.startTime))+" - "+h(n.formatFullTime(n.selectedReport.endTime))+"; 噪音报警阈值: "+h(n.selectedReport.alertThresholdDb||55)+" dB; 覆盖率: "+h(n.reportCoverage)+"% ",1)]),r("div",ri,[e[62]||(e[62]=r("div",{class:"d-flex align-center mb-3"},[r("span",{class:"report-section-line bg-teal"}),r("span",{class:"text-subtitle-2 font-weight-bold ml-2"},"更多统计")],-1)),r("div",li,[o(_,{variant:"outlined",rounded:"xl",class:"flex-grow-1","min-width":"280"},{default:a(()=>[o(T,{class:"pa-4"},{default:a(()=>[e[60]||(e[60]=r("div",{class:"text-subtitle-2 font-weight-medium mb-3"}," 噪音等级分布 ",-1)),r("div",di,[r("div",ci,[(c(!0),g(k,null,M(n.levelDistribution,d=>(c(),g("div",{key:d.label,style:P({width:`${d.percent}%`,backgroundColor:d.color,minWidth:d.percent>0?"4px":"0"})},null,4))),128))]),r("div",ui,[(c(!0),g(k,null,M(n.levelDistribution,d=>(c(),g("div",{key:`leg-${d.label}`,class:"d-flex align-center"},[r("span",{class:"d-inline-block mr-1",style:P({width:"10px",height:"10px",borderRadius:"2px",backgroundColor:d.color})},null,4),r("span",hi,h(d.label)+" ("+h(d.percent)+"%) ",1)]))),128))])])]),_:1})]),_:1}),o(_,{variant:"outlined",rounded:"xl",class:"flex-grow-1","min-width":"280"},{default:a(()=>[o(T,{class:"pa-4"},{default:a(()=>[e[61]||(e[61]=r("div",{class:"text-subtitle-2 font-weight-medium mb-3"}," 扣分扣因 (越长扣分越多) ",-1)),(c(!0),g(k,null,M(n.reportPenaltyItems,d=>(c(),g("div",{key:d.label,class:"d-flex align-center mb-2"},[r("span",mi,h(d.label),1),o(oe,{"model-value":d.percent,color:d.color,height:"10",rounded:"",class:"flex-grow-1 mr-2"},null,8,["model-value","color"]),r("span",fi,h(d.percent)+"%",1)]))),128))]),_:1})]),_:1})])])])):w("",!0)],64))]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1}),o(B,{modelValue:s.showCalibrateDialog,"onUpdate:modelValue":e[12]||(e[12]=d=>s.showCalibrateDialog=d),"max-width":"560",scrollable:""},{default:a(()=>[o(_,{class:"rounded-xl"},{default:a(()=>[o(I,{class:"d-flex align-center pa-4"},{default:a(()=>[o(x,{class:"mr-2",color:"deep-purple"},{default:a(()=>[...e[63]||(e[63]=[u(" mdi-crosshairs-gps ",-1)])]),_:1}),e[64]||(e[64]=r("span",{class:"text-h6 font-weight-bold"},"分贝校准",-1)),o(E),o(b,{icon:"mdi-close",size:"small",variant:"text",onClick:e[7]||(e[7]=d=>s.showCalibrateDialog=!1)})]),_:1}),o(F),o(T,{class:"pa-5"},{default:a(()=>[o(_,{variant:"outlined",class:"mb-5"},{default:a(()=>[o(T,{class:"py-3"},{default:a(()=>[e[68]||(e[68]=r("div",{class:"text-caption text-medium-emphasis mb-1"}," 当前校准值 ",-1)),r("div",gi,[r("div",null,[e[65]||(e[65]=r("span",{class:"text-body-2 text-medium-emphasis"},"基准分贝:",-1)),r("span",pi,h(s.calibrationSettings.baselineDb)+" dB ",1)]),r("div",null,[e[66]||(e[66]=r("span",{class:"text-body-2 text-medium-emphasis"},"基准 RMS:",-1)),r("span",yi,h(s.calibrationSettings.baselineRms!=null?s.calibrationSettings.baselineRms.toFixed(6):"未校准"),1)]),r("div",null,[e[67]||(e[67]=r("span",{class:"text-body-2 text-medium-emphasis"},"最大分贝:",-1)),r("span",bi,h(s.calibrationSettings.maxLevelDb)+" dB ",1)])])]),_:1})]),_:1}),r("div",vi,[o(x,{size:"18",class:"mr-2",color:"primary"},{default:a(()=>[...e[69]||(e[69]=[u(" mdi-auto-fix ",-1)])]),_:1}),e[70]||(e[70]=r("span",{class:"text-subtitle-2 font-weight-medium"},"自动校准",-1))]),e[74]||(e[74]=r("div",{class:"text-caption text-medium-emphasis mb-3"}," 在已知环境分贝的场景下,输入当前环境的真实分贝值,点击开始后保持环境安静 3 秒。 ",-1)),r("div",wi,[o(se,{modelValue:s.calibrateTargetDb,"onUpdate:modelValue":e[8]||(e[8]=d=>s.calibrateTargetDb=d),modelModifiers:{number:!0},density:"compact",variant:"outlined",type:"number",label:"目标分贝",suffix:"dB","hide-details":"",style:{"max-width":"160px"},min:20,max:80},null,8,["modelValue"]),o(b,{color:"deep-purple",variant:"tonal","prepend-icon":"mdi-crosshairs-gps",loading:s.isCalibrating,disabled:!i.isMonitoring,onClick:n.doAutoCalibrate},{default:a(()=>[...e[71]||(e[71]=[u(" 开始校准 ",-1)])]),_:1},8,["loading","disabled","onClick"]),i.isMonitoring?w("",!0):(c(),g("span",Si," 需先开启监测 ")),s.calibrateMessage?(c(),g("span",{key:1,class:O(["text-caption",s.calibrateSuccess?"text-success":"text-error"])},h(s.calibrateMessage),3)):w("",!0)]),o(F,{class:"mb-5"}),r("div",Di,[o(x,{size:"18",class:"mr-2",color:"orange"},{default:a(()=>[...e[72]||(e[72]=[u(" mdi-pencil-ruler ",-1)])]),_:1}),e[73]||(e[73]=r("span",{class:"text-subtitle-2 font-weight-medium"},"手动校准 / 参数调整",-1))]),e[75]||(e[75]=r("div",{class:"text-caption text-medium-emphasis mb-3"}," 直接输入校准参数。修改后点击保存生效。 ",-1)),r("div",xi,[o(se,{modelValue:s.editBaselineDb,"onUpdate:modelValue":e[9]||(e[9]=d=>s.editBaselineDb=d),modelModifiers:{number:!0},density:"compact",variant:"outlined",type:"number",label:"基准分贝",suffix:"dB","hide-details":"",style:{"max-width":"160px"},min:20,max:80},null,8,["modelValue"]),o(se,{modelValue:s.editBaselineRms,"onUpdate:modelValue":e[10]||(e[10]=d=>s.editBaselineRms=d),density:"compact",variant:"outlined",label:"基准 RMS","hide-details":"",style:{"max-width":"200px"},placeholder:"如 0.003200"},null,8,["modelValue"]),o(se,{modelValue:s.editMaxLevelDb,"onUpdate:modelValue":e[11]||(e[11]=d=>s.editMaxLevelDb=d),modelModifiers:{number:!0},density:"compact",variant:"outlined",type:"number",label:"最大显示分贝",suffix:"dB","hide-details":"",style:{"max-width":"180px"},min:40,max:120},null,8,["modelValue"])])]),_:1}),o(U,{class:"px-4 pb-4"},{default:a(()=>[o(b,{variant:"text","prepend-icon":"mdi-restore",onClick:n.resetCalibration},{default:a(()=>[...e[76]||(e[76]=[u(" 恢复默认 ",-1)])]),_:1},8,["onClick"]),o(E),o(b,{color:"primary",variant:"elevated","prepend-icon":"mdi-content-save",onClick:n.saveManualCalibration},{default:a(()=>[...e[77]||(e[77]=[u(" 保存校准 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),o(B,{modelValue:n.showConfirmClear,"onUpdate:modelValue":e[14]||(e[14]=d=>n.showConfirmClear=d),"max-width":"360"},{default:a(()=>[o(_,null,{default:a(()=>[o(I,null,{default:a(()=>[...e[78]||(e[78]=[u("确认清空",-1)])]),_:1}),o(T,null,{default:a(()=>[u(h(s.confirmClearMode==="all"?"确定要清空所有日期的统计报告吗?此操作不可撤销。":`确定要清空 ${n.formatDateLabel(i.selectedDate)} 的统计报告吗?此操作不可撤销。`),1)]),_:1}),o(U,null,{default:a(()=>[o(E),o(b,{variant:"text",onClick:e[13]||(e[13]=d=>s.confirmClearMode="")},{default:a(()=>[...e[79]||(e[79]=[u(" 取消 ",-1)])]),_:1}),o(b,{color:"error",onClick:n.doClearReports},{default:a(()=>[...e[80]||(e[80]=[u(" 确认清空 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["model-value"])}const Ye=H(Qt,[["render",ki],["__scopeId","data-v-5d732295"]]),Ci=Object.freeze(Object.defineProperty({__proto__:null,default:Ye},Symbol.toStringTag,{value:"Module"})),Ti=z(()=>N(()=>Promise.resolve().then(()=>Ci),void 0,import.meta.url)),_i=2,Mi=.9,Ei=.6,Ri={name:"TimeCard",components:{NoiseMonitorDetail:Ti},data(){return{now:new Date,timer:null,unwatch:null,fontSize:28,showFullscreen:!1,showSettings:!1,timeCardEnabled:!0,fullscreenMode:"clock",toolbarVisible:!0,toolbarTimer:null,countdownHours:0,countdownMinutes:5,countdownSeconds:0,countdownRunning:!1,countdownRemaining:0,countdownTotal:0,countdownTimer:null,countdownLastTick:null,countdownPresets:[{label:"1 分钟",h:0,m:1,s:0},{label:"3 分钟",h:0,m:3,s:0},{label:"5 分钟",h:0,m:5,s:0},{label:"10 分钟",h:0,m:10,s:0},{label:"15 分钟",h:0,m:15,s:0},{label:"30 分钟",h:0,m:30,s:0},{label:"1 小时",h:1,m:0,s:0}],countdownEndedDialog:!1,overtimeElapsed:0,overtimeTimer:null,overtimeLastTick:null,stopwatchRunning:!1,stopwatchElapsed:0,stopwatchTimer:null,stopwatchLastTick:null,laps:[],lastLapElapsed:0,noiseEnabled:!1,noiseMonitoring:!1,noiseStatus:"initializing",noiseCurrentDbfs:-100,noiseCurrentDisplayDb:0,noiseSmoothedDb:0,noiseScore:null,noiseScoreDetail:null,noiseRingBuffer:[],noiseLastSlice:null,noiseHistory:[],noiseUnsubscribe:null,showNoiseDetail:!1,noiseSessionConfig:null,noiseSessionActive:!1,noiseSessionData:null,noiseSessionCheckTimer:null,noiseReportMeta:{},noiseSelectedDate:"",noiseCurrentDateReports:[],showMicPermissionDialog:!1,micPermissionState:""}},computed:{timeString(){const t=String(this.now.getHours()).padStart(2,"0"),e=String(this.now.getMinutes()).padStart(2,"0");return`${t}:${e}`},secondsString(){return`:${String(this.now.getSeconds()).padStart(2,"0")}`},dateString(){const t=this.now.getFullYear(),e=this.now.getMonth()+1,i=this.now.getDate();return`${t}年${e}月${i}日`},weekdayString(){return["星期日","星期一","星期二","星期三","星期四","星期五","星期六"][this.now.getDay()]},periodOfDay(){const t=this.now.getHours();return t<6?"凌晨":t<8?"早晨":t<11?"上午":t<13?"中午":t<17?"下午":t<19?"傍晚":t<22?"晚上":"深夜"},dayProgressPercent(){const t=this.now.getHours(),e=this.now.getMinutes(),i=this.now.getSeconds();return((t*3600+e*60+i)/86400*100).toFixed(1)},timeStyle(){return{"font-size":`${this.fontSize*_i}px`,"font-weight":"700","line-height":"1","letter-spacing":"4px","font-variant-numeric":"tabular-nums"}},secondsStyle(){return{"font-size":`${this.fontSize*Mi}px`,"font-variant-numeric":"tabular-nums","vertical-align":"baseline","margin-left":"4px",opacity:"0.6"}},dateStyle(){return{"font-size":`${this.fontSize*Ei}px`,"letter-spacing":"1px"}},countdownTotalSetSeconds(){return this.countdownHours*3600+this.countdownMinutes*60+this.countdownSeconds},countdownDisplay(){const t=Math.max(0,Math.ceil(this.countdownRemaining/1e3)),e=Math.floor(t/3600),i=Math.floor(t%3600/60),l=t%60;return e>0?`${String(e).padStart(2,"0")}:${String(i).padStart(2,"0")}:${String(l).padStart(2,"0")}`:`${String(i).padStart(2,"0")}:${String(l).padStart(2,"0")}`},countdownProgressPercent(){return this.countdownTotal<=0?0:(this.countdownTotal-this.countdownRemaining)/this.countdownTotal*100},overtimeDisplay(){const t=Math.floor(this.overtimeElapsed/1e3),e=Math.floor(t/3600),i=Math.floor(t%3600/60),l=t%60;return e>0?`${e}小时${i}分${l}秒`:i>0?`${i}分${l}秒`:`${l}秒`},stopwatchDisplay(){const t=this.stopwatchElapsed,e=Math.floor(t/1e3),i=Math.floor(e/3600),l=Math.floor(e%3600/60),s=e%60,n=Math.floor(t%1e3/10);return i>0?`${String(i).padStart(2,"0")}:${String(l).padStart(2,"0")}:${String(s).padStart(2,"0")}.${String(n).padStart(2,"0")}`:`${String(l).padStart(2,"0")}:${String(s).padStart(2,"0")}.${String(n).padStart(2,"0")}`},noiseDisplayDb(){return!this.noiseMonitoring||this.noiseStatus!=="active"?"--":Math.round(this.noiseSmoothedDb)},noiseDbColor(){const t=typeof this.noiseDisplayDb=="number"?this.noiseDisplayDb:0;return t<40?"success":t<55?"light-green":t<70?"warning":t<85?"orange":"error"},noiseIconColor(){return this.noiseMonitoring?this.noiseDbColor:"grey"},noiseStatusText(){if(!this.noiseMonitoring||this.noiseStatus!=="active")return"未监测";const t=typeof this.noiseDisplayDb=="number"?this.noiseDisplayDb:0;return t<30?"极其安静":t<40?"非常安静":t<50?"安静":t<60?"正常交谈":t<70?"较为嘈杂":t<80?"嘈杂":t<90?"非常嘈杂":"极度嘈杂"}},watch:{showFullscreen(t){t?(this.handleKeydown=e=>{e.key==="Escape"&&(this.showSettings?this.showSettings=!1:this.countdownEndedDialog&&this.dismissCountdownDialog(),e.preventDefault(),e.stopPropagation())},window.addEventListener("keydown",this.handleKeydown,!0),this.showToolbar()):(this.handleKeydown&&(window.removeEventListener("keydown",this.handleKeydown,!0),this.handleKeydown=null),this.clearToolbarTimer())}},async mounted(){if(this.loadSettings(),this.startTimer(),this.unwatch=Ce(()=>{this.loadSettings()}),this.noiseEnabled=D("noiseMonitor.enabled"),this.noiseEnabled){this.noiseHistory=G.getHistory();const t=await this.checkMicPermission();this.micPermissionState=t,t==="granted"?this.loadNoiseSessionConfig().then(()=>{this.startSessionCheck(),D("noiseMonitor.autoStart")&&!this.noiseMonitoring&&this.startNoise()}):t==="prompt"&&(D("noiseMonitor.permissionDismissed")||(this.showMicPermissionDialog=!0))}},beforeUnmount(){this.stopTimer(),this.clearCountdownTimer(),this.clearStopwatchTimer(),this.clearToolbarTimer(),this.dismissCountdownDialog(),this.stopNoise(),this.stopSessionCheck(),this.unwatch&&this.unwatch(),this.handleKeydown&&window.removeEventListener("keydown",this.handleKeydown,!0)},methods:{loadSettings(){this.fontSize=ne.getSetting("font.size"),this.timeCardEnabled=D("timeCard.enabled"),this.noiseEnabled=D("noiseMonitor.enabled")},setTimeCardEnabled(t){this.timeCardEnabled=t,J("timeCard.enabled",t)},startTimer(){this.timer=setInterval(()=>{this.now=new Date},1e3)},stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=null)},showToolbar(){this.toolbarVisible=!0,this.clearToolbarTimer(),this.toolbarTimer=setTimeout(()=>{this.toolbarVisible=!1},3e3)},clearToolbarTimer(){this.toolbarTimer&&(clearTimeout(this.toolbarTimer),this.toolbarTimer=null)},applyCountdownPreset(t){this.countdownHours=t.h,this.countdownMinutes=t.m,this.countdownSeconds=t.s},startCountdown(){const t=this.countdownTotalSetSeconds*1e3;t<=0||(this.countdownTotal=t,this.countdownRemaining=t,this.countdownRunning=!0,this.countdownLastTick=Date.now(),this.countdownTimer=setInterval(()=>{this.tickCountdown()},50))},tickCountdown(){const t=Date.now(),e=t-this.countdownLastTick;this.countdownLastTick=t,this.countdownRemaining=Math.max(0,this.countdownRemaining-e),this.countdownRemaining<=0&&(this.countdownRunning=!1,this.clearCountdownTimer(),pt(yt),this.showCountdownEndedDialog())},toggleCountdown(){this.countdownRunning?(this.countdownRunning=!1,this.clearCountdownTimer()):(this.countdownRunning=!0,this.countdownLastTick=Date.now(),this.countdownTimer=setInterval(()=>{this.tickCountdown()},50))},resetCountdown(){this.countdownRunning=!1,this.countdownRemaining=0,this.countdownTotal=0,this.clearCountdownTimer(),this.dismissCountdownDialog()},showCountdownEndedDialog(){this.countdownEndedDialog=!0,this.overtimeElapsed=0,this.overtimeLastTick=Date.now(),this.overtimeTimer=setInterval(()=>{const t=Date.now();this.overtimeElapsed+=t-this.overtimeLastTick,this.overtimeLastTick=t},200)},dismissCountdownDialog(){this.countdownEndedDialog=!1,this.overtimeElapsed=0,this.overtimeTimer&&(clearInterval(this.overtimeTimer),this.overtimeTimer=null)},formatCountdownTotal(t){const e=Math.round(t/1e3),i=Math.floor(e/3600),l=Math.floor(e%3600/60),s=e%60,n=[];return i>0&&n.push(`${i}小时`),l>0&&n.push(`${l}分钟`),s>0&&n.push(`${s}秒`),n.join("")||"0秒"},clearCountdownTimer(){this.countdownTimer&&(clearInterval(this.countdownTimer),this.countdownTimer=null)},toggleStopwatch(){this.stopwatchRunning?(this.stopwatchRunning=!1,this.clearStopwatchTimer()):(this.stopwatchRunning=!0,this.stopwatchLastTick=Date.now(),this.stopwatchTimer=setInterval(()=>{this.tickStopwatch()},30))},tickStopwatch(){const t=Date.now();this.stopwatchElapsed+=t-this.stopwatchLastTick,this.stopwatchLastTick=t},addLap(){const t=this.stopwatchElapsed-this.lastLapElapsed;this.laps.unshift({split:t,total:this.stopwatchElapsed}),this.lastLapElapsed=this.stopwatchElapsed},resetStopwatch(){this.stopwatchRunning=!1,this.stopwatchElapsed=0,this.lastLapElapsed=0,this.laps=[],this.clearStopwatchTimer()},clearStopwatchTimer(){this.stopwatchTimer&&(clearInterval(this.stopwatchTimer),this.stopwatchTimer=null)},formatMs(t){const e=Math.floor(t/1e3),i=Math.floor(e/60),l=e%60,s=Math.floor(t%1e3/10);return`${String(i).padStart(2,"0")}:${String(l).padStart(2,"0")}.${String(s).padStart(2,"0")}`},async checkMicPermission(){try{return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices&&!(await navigator.mediaDevices.enumerateDevices()).some(l=>l.kind==="audioinput")?"unavailable":!navigator.permissions||!navigator.permissions.query?"granted":(await navigator.permissions.query({name:"microphone"})).state}catch{return"prompt"}},async grantMicPermission(){this.showMicPermissionDialog=!1,await this.loadNoiseSessionConfig(),this.startSessionCheck(),await this.startNoise(),this.micPermissionState=await this.checkMicPermission()},dismissMicPermission(){this.showMicPermissionDialog=!1,J("noiseMonitor.permissionDismissed",!0)},onPermissionDialogToggle(t){this.noiseEnabled=t,J("noiseMonitor.enabled",t),t||(this.showMicPermissionDialog=!1,J("noiseMonitor.permissionDismissed",!0))},async startNoise(){try{await G.start(),this.noiseMonitoring=!0,this.noiseUnsubscribe=G.subscribe(t=>{this.noiseStatus=t.status,this.noiseCurrentDbfs=t.currentDbfs,this.noiseCurrentDisplayDb=t.currentDisplayDb;const e=.25,i=t.currentDisplayDb;this.noiseSmoothedDb=this.noiseSmoothedDb===0?i:this.noiseSmoothedDb*(1-e)+i*e,this.noiseRingBuffer=t.ringBuffer||[],this.noiseLastSlice=t.lastSlice||null,this.noiseScore=t.currentScore??null,this.noiseScoreDetail=t.currentScoreDetail??null,this.noiseHistory=G.getHistory(),this.noiseSessionActive&&this.noiseSessionData&&this.collectSessionSample(t)})}catch(t){console.error("噪音监测启动失败:",t),this.noiseStatus="error"}},stopNoise(){this.noiseUnsubscribe&&(this.noiseUnsubscribe(),this.noiseUnsubscribe=null),this.noiseMonitoring&&G.stop(),this.noiseMonitoring=!1,this.noiseStatus="initializing",this.noiseSmoothedDb=0,this.noiseScore=null,this.noiseScoreDetail=null},clearNoiseHistory(){G.clearHistory(),this.noiseHistory=[]},onNoiseClick(){if(this.micPermissionState==="denied"||this.micPermissionState==="unavailable"){this.showNoiseDetail=!0;return}this.noiseMonitoring?this.showNoiseDetail=!0:this.startNoise()},async loadNoiseSessionConfig(){try{const t=await R.loadData("noise-session-config"),e=(t==null?void 0:t.data)||t;e&&e.sessions?this.noiseSessionConfig=e:this.noiseSessionConfig={sessions:[{name:"第1节晚自习",start:"19:20",duration:70,enabled:!0},{name:"第2节晚自习",start:"20:20",duration:110,enabled:!0}],alertThresholdDb:55},await this.loadSessionReports()}catch(t){console.error("加载噪音会话配置失败:",t),this.noiseSessionConfig={sessions:[{name:"第1节晚自习",start:"19:20",duration:70,enabled:!0},{name:"第2节晚自习",start:"20:20",duration:110,enabled:!0}],alertThresholdDb:55}}},async saveNoiseSessionConfig(){try{await R.saveData("noise-session-config",this.noiseSessionConfig)}catch(t){console.error("保存噪音会话配置失败:",t)}},formatDateKey(t){const e=new Date(t);return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`},async loadReportMeta(){try{const t=await R.loadData("noise-reports-meta"),e=(t==null?void 0:t.data)||t;if(e&&e.dates){const i=new Date;i.setDate(i.getDate()-30);const l=this.formatDateKey(i.getTime()),s={};for(const[n,d]of Object.entries(e.dates))n>=l&&(s[n]=d);this.noiseReportMeta={dates:s}}else this.noiseReportMeta={dates:{}}}catch{this.noiseReportMeta={dates:{}}}},async saveReportMeta(){try{await R.saveData("noise-reports-meta",this.noiseReportMeta)}catch{console.error("保存报告元数据失败")}},async loadReportsForDate(t){this.noiseSelectedDate=t;try{const e=await R.loadData(`noise-reports-${t}`),i=(e==null?void 0:e.data)||e;this.noiseCurrentDateReports=Array.isArray(i)?i:[]}catch{this.noiseCurrentDateReports=[]}},async saveReportToDate(t){const e=this.formatDateKey(t.startTime);let i=[];try{const s=await R.loadData(`noise-reports-${e}`),n=(s==null?void 0:s.data)||s;Array.isArray(n)&&(i=n)}catch{}i.push(t),await R.saveData(`noise-reports-${e}`,i),this.noiseReportMeta.dates||(this.noiseReportMeta.dates={});const l=i.map(s=>s.score);this.noiseReportMeta.dates[e]={count:i.length,avgScore:Math.round(l.reduce((s,n)=>s+n,0)/l.length),sessions:i.map(s=>s.sessionName),lastUpdated:Date.now()},await this.saveReportMeta(),this.noiseSelectedDate===e&&(this.noiseCurrentDateReports=i)},async loadSessionReports(){await this.loadReportMeta();const t=this.formatDateKey(Date.now());await this.loadReportsForDate(t)},startSessionCheck(){this.checkSessionTime(),this.noiseSessionCheckTimer=setInterval(()=>{this.checkSessionTime()},3e4)},stopSessionCheck(){this.noiseSessionCheckTimer&&(clearInterval(this.noiseSessionCheckTimer),this.noiseSessionCheckTimer=null)},checkSessionTime(){var l;if(!((l=this.noiseSessionConfig)!=null&&l.sessions))return;const t=new Date,e=t.getHours()*60+t.getMinutes(),i=this.noiseSessionConfig.sessions.find(s=>{if(!s.enabled)return!1;const[n,d]=s.start.split(":").map(Number),m=n*60+d,p=m+(s.duration||70);return e>=m&&e<p});i&&!this.noiseSessionActive?this.beginSession(i):!i&&this.noiseSessionActive&&this.endSession()},beginSession(t){this.noiseSessionActive=!0,this.noiseSessionData={sessionName:t.name,startTime:Date.now(),endTime:null,samples:[],slices:[],alertThresholdDb:this.noiseSessionConfig.alertThresholdDb||55},this.noiseMonitoring||this.startNoise()},endSession(){if(!this.noiseSessionData){this.noiseSessionActive=!1;return}this.noiseSessionData.endTime=Date.now(),this.noiseSessionData.slices=[...this.noiseHistory];const t=this.generateSessionReport(this.noiseSessionData);this.saveReportToDate(t),this.noiseSessionActive=!1,this.noiseSessionData=null},collectSessionSample(t){if(!this.noiseSessionData)return;const e=t.currentDisplayDb;if(typeof e=="number"&&e>0){const i=this.noiseSessionData.samples,l=i.length>0?i[i.length-1].t:0;Date.now()-l>=2e3&&i.push({t:Date.now(),db:Math.round(e*10)/10})}},generateSessionReport(t){const e=t.samples,i=e.map(W=>W.db),l=t.alertThresholdDb,s=t.endTime-t.startTime;if(i.length===0)return{sessionName:t.sessionName,startTime:t.startTime,endTime:t.endTime,duration:s,avgDb:0,maxDb:0,score:100,overThresholdDuration:0,overThresholdRatio:0,segmentCount:0,samples:[],scorePenalties:{sustained:0,time:0,segment:0}};const n=Math.round(i.reduce((W,me)=>W+me,0)/i.length*10)/10,d=Math.round(Math.max(...i)*10)/10;let m=0;i.forEach(W=>{W>l&&m++});const p=m/i.length,f=Math.round(p*s/1e3);let S=0,j=!1;i.forEach(W=>{W>l&&!j&&(S++,j=!0),W<=l&&(j=!1)});const A=Math.min(40,Math.max(0,(n-l)/30*40)),Y=Math.min(30,p*30),q=Math.min(30,S/Math.max(1,s/6e4)/6*30),he=Math.max(0,Math.round(100-A-Y-q));return{sessionName:t.sessionName,startTime:t.startTime,endTime:t.endTime,duration:s,avgDb:n,maxDb:d,score:he,overThresholdDuration:f,overThresholdRatio:Math.round(p*1e3)/10,segmentCount:S,samples:e.length>500?this.downsampleArray(e,500):e,scorePenalties:{sustained:Math.round(A),time:Math.round(Y),segment:Math.round(q)},alertThresholdDb:l}},downsampleArray(t,e){const i=t.length/e,l=[];for(let s=0;s<e;s++)l.push(t[Math.floor(s*i)]);return l},async onSelectReportDate(t){await this.loadReportsForDate(t)},async onClearDateReports(t){try{await R.saveData(`noise-reports-${t}`,[])}catch{}this.noiseReportMeta.dates&&(delete this.noiseReportMeta.dates[t],await this.saveReportMeta()),this.noiseSelectedDate===t&&(this.noiseCurrentDateReports=[])},async onClearAllReports(){if(this.noiseReportMeta.dates)for(const t of Object.keys(this.noiseReportMeta.dates))try{await R.saveData(`noise-reports-${t}`,[])}catch{}this.noiseReportMeta={dates:{}},await this.saveReportMeta(),this.noiseCurrentDateReports=[]}}},Ii={class:"d-flex align-center",style:{gap:"16px"}},Vi={class:"flex-grow-1"},Ni={key:0,class:"text-caption text-medium-emphasis mt-1",style:{"font-size":"10px",cursor:"pointer"}},Pi={class:"text-center pt-8 pb-2"},Ai={class:"d-flex align-start mb-2"},Li={class:"d-flex align-start mb-2"},zi={class:"d-flex align-start mb-4"},Fi={class:"fullscreen-toolbar"},Bi={class:"fullscreen-time-body flex-grow-1 d-flex flex-column align-center justify-center"},Oi={class:"d-flex flex-column align-center justify-center"},ji={class:"fullscreen-time-display"},Ui={class:"fullscreen-seconds"},Hi={class:"fullscreen-date-line mt-6"},Wi={class:"fullscreen-progress mt-10"},Gi={class:"text-caption text-medium-emphasis mb-1"},Ki={class:"d-flex flex-column align-center justify-center"},Yi={class:"countdown-setup d-flex align-center ga-4"},qi={class:"text-center"},Ji={class:"countdown-digit"},Xi={class:"text-center"},Zi={class:"countdown-digit"},Qi={class:"text-center"},$i={class:"countdown-digit"},en={class:"mt-8 d-flex ga-3 flex-wrap justify-center"},tn={class:"mt-8"},sn={class:"fullscreen-date-line mt-4 text-medium-emphasis"},nn={class:"mt-8 d-flex ga-3"},on={class:"d-flex flex-column align-center justify-center"},an={class:"fullscreen-time-display"},rn={class:"fullscreen-date-line mt-4 text-medium-emphasis"},ln={class:"mt-8 d-flex ga-3"},dn={key:0,class:"stopwatch-laps mt-6"},cn={class:"fullscreen-actions"},un={class:"text-h4 font-weight-bold my-4",style:{"font-variant-numeric":"tabular-nums"}},hn={key:0,class:"mt-4"};function mn(t,e,i,l,s,n){const d=Ye;return c(),g(k,null,[o(_,{class:"time-card",elevation:"2",border:"",rounded:"xl",height:"100%",style:{cursor:"pointer"},onClick:e[3]||(e[3]=m=>s.showFullscreen=!0)},{default:a(()=>[o(T,{class:"pa-6 d-flex flex-column",style:{height:"100%"}},{default:a(()=>[r("div",Ii,[r("div",Vi,[r("div",{class:"time-display",style:P(n.timeStyle)},[u(h(n.timeString),1),r("span",{class:"seconds-text",style:P(n.secondsStyle)},h(n.secondsString),5)],4),r("div",{class:"date-line mt-3",style:P(n.dateStyle)},h(n.dateString)+" "+h(n.weekdayString)+" "+h(n.periodOfDay),5)]),s.noiseEnabled?(c(),g("div",{key:0,class:"d-flex flex-column align-center justify-center",style:{"min-width":"80px"},onClick:e[0]||(e[0]=Ee((...m)=>n.onNoiseClick&&n.onNoiseClick(...m),["stop"]))},[s.micPermissionState==="denied"?(c(),g(k,{key:0},[o(x,{color:"error",size:"24"},{default:a(()=>[...e[18]||(e[18]=[u(" mdi-microphone-off ",-1)])]),_:1}),e[19]||(e[19]=r("div",{class:"text-caption text-error mt-1",style:{"white-space":"nowrap","font-size":"10px"}}," 权限被拒绝 ",-1))],64)):s.micPermissionState==="unavailable"?(c(),g(k,{key:1},[o(x,{color:"warning",size:"24"},{default:a(()=>[...e[20]||(e[20]=[u(" mdi-microphone-question ",-1)])]),_:1}),e[21]||(e[21]=r("div",{class:"text-caption text-warning mt-1",style:{"white-space":"nowrap","font-size":"10px"}}," 无麦克风 ",-1))],64)):(c(),g(k,{key:2},[r("div",{class:O(["noise-side-db font-weight-bold",`text-${n.noiseDbColor}`]),style:P({fontSize:`${s.fontSize*.9}px`,lineHeight:1,fontVariantNumeric:"tabular-nums"})},h(n.noiseDisplayDb),7),r("div",{class:O(["text-caption mt-1",`text-${n.noiseDbColor}`]),style:{"white-space":"nowrap","font-size":"11px"}},h(n.noiseStatusText),3),s.noiseMonitoring?w("",!0):(c(),g("div",Ni," 点击开启 "))],64))])):w("",!0)])]),_:1}),s.noiseEnabled?(c(),v(d,{key:0,modelValue:s.showNoiseDetail,"onUpdate:modelValue":e[1]||(e[1]=m=>s.showNoiseDetail=m),status:s.noiseStatus,"current-db":n.noiseDisplayDb,"current-dbfs":s.noiseCurrentDbfs,"noise-level":n.noiseStatusText,"db-color":n.noiseDbColor,"current-score":s.noiseScore,"score-detail":s.noiseScoreDetail,"ring-buffer":s.noiseRingBuffer,"last-slice":s.noiseLastSlice,history:s.noiseHistory,"is-monitoring":s.noiseMonitoring,"mic-permission-state":s.micPermissionState,"session-active":s.noiseSessionActive,"session-data":s.noiseSessionData,"report-meta":s.noiseReportMeta,"selected-date":s.noiseSelectedDate,"date-reports":s.noiseCurrentDateReports,onStart:n.startNoise,onStop:n.stopNoise,onClearHistory:n.clearNoiseHistory,onSelectDate:n.onSelectReportDate,onClearDateReports:n.onClearDateReports,onClearAllReports:n.onClearAllReports},null,8,["modelValue","status","current-db","current-dbfs","noise-level","db-color","current-score","score-detail","ring-buffer","last-slice","history","is-monitoring","mic-permission-state","session-active","session-data","report-meta","selected-date","date-reports","onStart","onStop","onClearHistory","onSelectDate","onClearDateReports","onClearAllReports"])):w("",!0),o(B,{modelValue:s.showMicPermissionDialog,"onUpdate:modelValue":e[2]||(e[2]=m=>s.showMicPermissionDialog=m),"max-width":"480",persistent:""},{default:a(()=>[o(_,{rounded:"xl"},{default:a(()=>[r("div",Pi,[o(tt,{color:"primary",size:"72"},{default:a(()=>[o(x,{icon:"mdi-microphone-outline",size:"36"})]),_:1})]),o(I,{class:"text-center text-h6 pt-4"},{default:a(()=>[...e[22]||(e[22]=[u(" 开启环境噪音监测 ",-1)])]),_:1}),o(T,{class:"text-body-2 text-medium-emphasis px-6"},{default:a(()=>[e[27]||(e[27]=r("p",{class:"mb-3"}," 该功能可以实时监测教室环境噪音,帮助营造安静的学习氛围: ",-1)),r("div",Ai,[o(x,{icon:"mdi-chart-line",size:"18",color:"primary",class:"mr-2 mt-1 flex-shrink-0"}),e[23]||(e[23]=r("span",null,"实时显示环境分贝数与噪音等级评估",-1))]),r("div",Li,[o(x,{icon:"mdi-clock-check-outline",size:"18",color:"primary",class:"mr-2 mt-1 flex-shrink-0"}),e[24]||(e[24]=r("span",null,"在晚自习时段自动记录并生成统计报告",-1))]),r("div",zi,[o(x,{icon:"mdi-shield-check-outline",size:"18",color:"primary",class:"mr-2 mt-1 flex-shrink-0"}),e[25]||(e[25]=r("span",null,"音频数据仅在本地处理,不会上传或存储录音",-1))]),o(ae,{type:"info",variant:"tonal",density:"compact",class:"mb-2"},{default:a(()=>[...e[26]||(e[26]=[u(" 需要授予麦克风权限才能使用此功能。浏览器将弹出权限请求,请点击「允许」。 ",-1)])]),_:1})]),_:1}),o(F),o(T,{class:"px-6 py-3"},{default:a(()=>[o($,{density:"compact",class:"pa-0"},{default:a(()=>[o(ee,{class:"px-0"},{prepend:a(()=>[o(x,{icon:"mdi-microphone",class:"mr-3"})]),append:a(()=>[o(Ie,{"model-value":s.noiseEnabled,"hide-details":"",density:"comfortable","onUpdate:modelValue":n.onPermissionDialogToggle},null,8,["model-value","onUpdate:modelValue"])]),default:a(()=>[o(ve,null,{default:a(()=>[...e[28]||(e[28]=[u("启用噪音监测",-1)])]),_:1}),o(we,{class:"text-caption"},{default:a(()=>[...e[29]||(e[29]=[u(" 关闭后将不再提醒 ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),o(U,{class:"px-6 pb-5"},{default:a(()=>[o(b,{variant:"text",onClick:n.dismissMicPermission},{default:a(()=>[...e[30]||(e[30]=[u(" 暂不开启 ",-1)])]),_:1},8,["onClick"]),o(E),o(b,{color:"primary",variant:"elevated","prepend-icon":"mdi-microphone",disabled:!s.noiseEnabled,onClick:n.grantMicPermission},{default:a(()=>[...e[31]||(e[31]=[u(" 授权并开始 ",-1)])]),_:1},8,["disabled","onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1}),o(B,{modelValue:s.showFullscreen,"onUpdate:modelValue":e[14]||(e[14]=m=>s.showFullscreen=m),fullscreen:"",scrim:!1,persistent:"",transition:"dialog-bottom-transition"},{default:a(()=>[o(_,{class:"fullscreen-time-card d-flex flex-column",onMousemove:n.showToolbar,onTouchstart:n.showToolbar},{default:a(()=>[o(rt,{name:"toolbar-fade"},{default:a(()=>[lt(r("div",Fi,[o(Be,{modelValue:s.fullscreenMode,"onUpdate:modelValue":e[4]||(e[4]=m=>s.fullscreenMode=m),density:"comfortable",color:"primary","align-tabs":"center",class:"fullscreen-tabs"},{default:a(()=>[o(Z,{value:"clock"},{default:a(()=>[o(x,{start:"",icon:"mdi-clock-outline"}),e[32]||(e[32]=u(" 时钟 ",-1))]),_:1}),o(Z,{value:"countdown"},{default:a(()=>[o(x,{start:"",icon:"mdi-timer-sand"}),e[33]||(e[33]=u(" 倒计时 ",-1))]),_:1}),o(Z,{value:"stopwatch"},{default:a(()=>[o(x,{start:"",icon:"mdi-timer-outline"}),e[34]||(e[34]=u(" 秒表 ",-1))]),_:1})]),_:1},8,["modelValue"])],512),[[dt,s.toolbarVisible]])]),_:1}),r("div",Bi,[o(Oe,{modelValue:s.fullscreenMode,"onUpdate:modelValue":e[11]||(e[11]=m=>s.fullscreenMode=m),class:"fullscreen-tabs-window"},{default:a(()=>[o(Q,{value:"clock"},{default:a(()=>[r("div",Oi,[r("div",ji,[u(h(n.timeString),1),r("span",Ui,h(n.secondsString),1)]),r("div",Hi,h(n.dateString)+" "+h(n.weekdayString)+" "+h(n.periodOfDay),1),r("div",Wi,[r("div",Gi," 今日已过 "+h(n.dayProgressPercent)+"% ",1),o(oe,{"model-value":n.dayProgressPercent,color:"primary",height:"6",rounded:"",style:{"max-width":"400px",width:"80vw"}},null,8,["model-value"])]),e[35]||(e[35]=r("div",{class:"fullscreen-extra mt-8 text-medium-emphasis d-flex ga-8"},null,-1))])]),_:1}),o(Q,{value:"countdown"},{default:a(()=>[r("div",Ki,[!s.countdownRunning&&s.countdownRemaining<=0?(c(),g(k,{key:0},[r("div",Yi,[r("div",qi,[o(b,{icon:"mdi-chevron-up",variant:"text",size:"small",onClick:e[5]||(e[5]=m=>s.countdownHours=Math.min(s.countdownHours+1,99))}),r("div",Ji,h(String(s.countdownHours).padStart(2,"0")),1),o(b,{icon:"mdi-chevron-down",variant:"text",size:"small",onClick:e[6]||(e[6]=m=>s.countdownHours=Math.max(s.countdownHours-1,0))}),e[36]||(e[36]=r("div",{class:"text-caption text-medium-emphasis"}," 时 ",-1))]),e[39]||(e[39]=r("div",{class:"countdown-sep"}," : ",-1)),r("div",Xi,[o(b,{icon:"mdi-chevron-up",variant:"text",size:"small",onClick:e[7]||(e[7]=m=>s.countdownMinutes=Math.min(s.countdownMinutes+1,59))}),r("div",Zi,h(String(s.countdownMinutes).padStart(2,"0")),1),o(b,{icon:"mdi-chevron-down",variant:"text",size:"small",onClick:e[8]||(e[8]=m=>s.countdownMinutes=Math.max(s.countdownMinutes-1,0))}),e[37]||(e[37]=r("div",{class:"text-caption text-medium-emphasis"}," 分 ",-1))]),e[40]||(e[40]=r("div",{class:"countdown-sep"}," : ",-1)),r("div",Qi,[o(b,{icon:"mdi-chevron-up",variant:"text",size:"small",onClick:e[9]||(e[9]=m=>s.countdownSeconds=Math.min(s.countdownSeconds+1,59))}),r("div",$i,h(String(s.countdownSeconds).padStart(2,"0")),1),o(b,{icon:"mdi-chevron-down",variant:"text",size:"small",onClick:e[10]||(e[10]=m=>s.countdownSeconds=Math.max(s.countdownSeconds-1,0))}),e[38]||(e[38]=r("div",{class:"text-caption text-medium-emphasis"}," 秒 ",-1))])]),r("div",en,[(c(!0),g(k,null,M(s.countdownPresets,m=>(c(),v(b,{key:m.label,variant:"tonal",rounded:"xl",onClick:p=>n.applyCountdownPreset(m)},{default:a(()=>[u(h(m.label),1)]),_:2},1032,["onClick"]))),128))]),r("div",tn,[o(b,{color:"primary",size:"x-large",rounded:"xl",disabled:n.countdownTotalSetSeconds<=0,"prepend-icon":"mdi-play",onClick:n.startCountdown},{default:a(()=>[...e[41]||(e[41]=[u(" 开始 ",-1)])]),_:1},8,["disabled","onClick"])])],64)):(c(),g(k,{key:1},[r("div",{class:O(["fullscreen-time-display",{"countdown-ended":s.countdownRemaining<=0&&!s.countdownRunning}])},h(n.countdownDisplay),3),r("div",sn,h(s.countdownRunning?"倒计时进行中":s.countdownRemaining<=0?"时间到!":"已暂停"),1),o(oe,{"model-value":n.countdownProgressPercent,color:s.countdownRemaining<=0?"error":"primary",class:"mt-8",height:"6",rounded:"",style:{"max-width":"400px",width:"80vw"}},null,8,["model-value","color"]),r("div",nn,[s.countdownRemaining>0?(c(),v(b,{key:0,icon:s.countdownRunning?"mdi-pause":"mdi-play",color:s.countdownRunning?"warning":"primary",size:"x-large",variant:"tonal",onClick:n.toggleCountdown},null,8,["icon","color","onClick"])):w("",!0),o(b,{icon:"mdi-stop",color:"error",size:"x-large",variant:"tonal",onClick:n.resetCountdown},null,8,["onClick"])])],64))])]),_:1}),o(Q,{value:"stopwatch"},{default:a(()=>[r("div",on,[r("div",an,h(n.stopwatchDisplay),1),r("div",rn,h(s.stopwatchRunning?"计时中":s.stopwatchElapsed>0?"已暂停":"秒表"),1),r("div",ln,[o(b,{icon:s.stopwatchRunning?"mdi-pause":"mdi-play",color:s.stopwatchRunning?"warning":"primary",size:"x-large",variant:"tonal",onClick:n.toggleStopwatch},null,8,["icon","color","onClick"]),s.stopwatchRunning?(c(),v(b,{key:0,icon:"mdi-flag",color:"info",size:"x-large",variant:"tonal",onClick:n.addLap},null,8,["onClick"])):w("",!0),!s.stopwatchRunning&&s.stopwatchElapsed>0?(c(),v(b,{key:1,icon:"mdi-stop",color:"error",size:"x-large",variant:"tonal",onClick:n.resetStopwatch},null,8,["onClick"])):w("",!0)]),o(st,null,{default:a(()=>[s.laps.length>0?(c(),g("div",dn,[o(mt,{density:"compact",class:"stopwatch-laps-table"},{default:a(()=>[e[42]||(e[42]=r("thead",null,[r("tr",null,[r("th",null," # "),r("th",null," 计次 "),r("th",null," 总计 ")])],-1)),r("tbody",null,[(c(!0),g(k,null,M(s.laps,(m,p)=>(c(),g("tr",{key:p},[r("td",null,h(s.laps.length-p),1),r("td",null,h(n.formatMs(m.split)),1),r("td",null,h(n.formatMs(m.total)),1)]))),128))])]),_:1})])):w("",!0)]),_:1})])]),_:1})]),_:1},8,["modelValue"])]),r("div",cn,[o(b,{icon:"mdi-cog",variant:"text",size:"large",onClick:e[12]||(e[12]=Ee(m=>s.showSettings=!0,["stop"]))}),o(b,{icon:"mdi-close",variant:"text",size:"large",class:"ml-2",onClick:e[13]||(e[13]=m=>s.showFullscreen=!1)})])]),_:1},8,["onMousemove","onTouchstart"])]),_:1},8,["modelValue"]),o(B,{modelValue:s.countdownEndedDialog,"onUpdate:modelValue":e[15]||(e[15]=m=>s.countdownEndedDialog=m),"max-width":"480",persistent:""},{default:a(()=>[o(_,{rounded:"xl"},{default:a(()=>[o(I,{class:"d-flex align-center justify-center pt-6"},{default:a(()=>[o(x,{color:"error",size:"32",class:"mr-2",icon:"mdi-alarm"}),e[43]||(e[43]=u(" 时间到! ",-1))]),_:1}),o(T,{class:"text-center pb-2"},{default:a(()=>[r("div",un,h(n.formatCountdownTotal(s.countdownTotal)),1),e[44]||(e[44]=r("div",{class:"text-body-1 text-medium-emphasis"}," 设定的倒计时已结束 ",-1)),s.overtimeElapsed>0?(c(),g("div",hn,[o(L,{color:"error",variant:"tonal",size:"large","prepend-icon":"mdi-clock-alert-outline"},{default:a(()=>[u(" 已超时 "+h(n.overtimeDisplay),1)]),_:1})])):w("",!0)]),_:1}),o(U,{class:"justify-center pb-6"},{default:a(()=>[o(b,{color:"primary",variant:"tonal",size:"large",rounded:"xl","prepend-icon":"mdi-check",onClick:n.dismissCountdownDialog},{default:a(()=>[...e[45]||(e[45]=[u(" 知道了 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),o(B,{modelValue:s.showSettings,"onUpdate:modelValue":e[17]||(e[17]=m=>s.showSettings=m),"max-width":"420",scrim:!0},{default:a(()=>[o(_,{rounded:"xl"},{default:a(()=>[o(I,{class:"d-flex align-center"},{default:a(()=>[o(x,{class:"mr-2",icon:"mdi-cog"}),e[46]||(e[46]=u(" 时间卡片设置 ",-1))]),_:1}),o(T,null,{default:a(()=>[o($,null,{default:a(()=>[o(ee,null,{prepend:a(()=>[o(x,{class:"mr-3",icon:"mdi-clock-outline"})]),append:a(()=>[o(Ie,{"model-value":s.timeCardEnabled,"hide-details":"",density:"comfortable","onUpdate:modelValue":n.setTimeCardEnabled},null,8,["model-value","onUpdate:modelValue"])]),default:a(()=>[o(ve,null,{default:a(()=>[...e[47]||(e[47]=[u("显示时间卡片",-1)])]),_:1}),o(we,null,{default:a(()=>[...e[48]||(e[48]=[u("在首页显示时间卡片,刷新后生效。",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),o(U,null,{default:a(()=>[o(E),o(b,{variant:"text",onClick:e[16]||(e[16]=m=>s.showSettings=!1)},{default:a(()=>[...e[49]||(e[49]=[u(" 完成 ",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])],64)}const qe=H(Ri,[["render",mn],["__scopeId","data-v-7c6af54a"]]),fn={name:"HomeworkGrid",computed:{settings(){return settings}},components:{HitokotoCard:We,TimeCard:qe,ConciseExamCard:He},props:{sortedItems:{type:Array,required:!0},unusedSubjects:{type:Array,required:!0},emptySubjectDisplay:{type:String,default:"button"},isMobile:{type:Boolean,default:!1},isEditingDisabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})},highlightedCards:{type:Object,default:()=>({})}},emits:["open-dialog","open-attendance","disabled-click"],data(){return{isReadOnlyToken:!1}},async mounted(){this.resizeObserver=new ResizeObserver(()=>{this.resizeAllGridItems()}),this.$refs.gridContainer&&this.resizeObserver.observe(this.$refs.gridContainer),this.$nextTick(()=>{this.resizeAllGridItems(),this.$refs.items&&this.$refs.items.forEach(t=>{t.firstElementChild&&this.resizeObserver.observe(t.firstElementChild)})}),await this.checkReadOnlyStatus()},updated(){this.$nextTick(()=>{this.resizeAllGridItems(),this.$refs.items&&this.$refs.items.forEach(t=>{t.firstElementChild&&this.resizeObserver.observe(t.firstElementChild)})})},beforeUnmount(){this.resizeObserver&&this.resizeObserver.disconnect()},methods:{getSetting:D,async checkReadOnlyStatus(){try{let t=null;if(this.$parent&&this.$parent.$refs&&this.$parent.$refs.studentNameManager?t=this.$parent.$refs.studentNameManager:this.$root&&this.$root.$refs&&this.$root.$refs.studentNameManager&&(t=this.$root.$refs.studentNameManager),t&&typeof t.isReadOnly<"u")this.isReadOnlyToken=t.isReadOnly;else{const{getSetting:e}=await N(async()=>{const{getSetting:l}=await import("./index-C305lth9.js").then(s=>s.aI);return{getSetting:l}},__vite__mapDeps([0,1,2,3]),import.meta.url),i=e("server.kvToken");if(i){const{default:l}=await N(async()=>{const{default:n}=await import("./dataProvider-BLWNaKs2.js").then(d=>d.c);return{default:n}},__vite__mapDeps([4,5,0,1,2,3,6]),import.meta.url),s=e("server.domain");if(s)try{const n=await l.get(`${s}/kv/_token`,{headers:{Authorization:`Bearer ${i}`}});n.data&&typeof n.data.isReadOnly<"u"&&(this.isReadOnlyToken=n.data.isReadOnly)}catch(n){console.error("获取Token信息失败:",n)}}}}catch(t){console.error("检查只读状态失败:",t)}},resizeGridItem(t){const e=this.$refs.gridContainer;if(!e)return;const i=parseInt(window.getComputedStyle(e).getPropertyValue("grid-auto-rows")),l=parseInt(window.getComputedStyle(e).getPropertyValue("gap")),s=t.firstElementChild;if(!s)return;const n=s.getBoundingClientRect().height,d=Math.ceil((n+l)/(i+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,i=e.getBoundingClientRect(),l=(t.clientX-i.left)/i.width*100,s=(t.clientY-i.top)/i.height*100;e.style.setProperty("--x",`${l}%`),e.style.setProperty("--y",`${s}%`)},handleTouchMove(t){if(t.touches.length===1){const e=t.touches[0],i=t.currentTarget,l=i.getBoundingClientRect(),s=(e.clientX-l.left)/l.width*100,n=(e.clientY-l.top)/l.height*100;i.style.setProperty("--x",`${s}%`),i.style.setProperty("--y",`${n}%`)}}}},gn={ref:"gridContainer",class:"grid-masonry"},pn=["data-key"],yn={key:0,style:{height:"100%"}},bn={key:1,style:{height:"100%"}},vn={key:2,style:{height:"100%"}},wn={class:"d-flex justify-space-between align-center mb-2"},Sn={class:"text-h6"},Dn={key:0,class:"mb-2"},xn={class:"text-error text-caption mb-1"},kn={class:"d-flex flex-wrap",style:{gap:"4px"}},Cn={key:1,class:"mb-2"},Tn={class:"text-warning text-caption mb-1"},_n={class:"d-flex flex-wrap",style:{gap:"4px"}},Mn={key:2,class:"mb-2"},En={class:"text-grey text-caption mb-1"},Rn={class:"d-flex flex-wrap",style:{gap:"4px"}},In={key:3,class:"text-success text-center mt-2"},Vn={class:"empty-subjects mt-4"},Nn={key:0,class:"d-flex flex-wrap justify-center"},Pn={key:2,class:"empty-subjects-grid"};function An(t,e,i,l,s,n){const d=qe,m=We,p=He;return c(),g(k,null,[r("div",gn,[o(Re,{name:"grid"},{default:a(()=>[(c(!0),g(k,null,M(i.sortedItems,f=>(c(),g("div",{key:f.key,ref_for:!0,ref:"items","data-key":f.key,style:P({order:f.order}),class:"grid-item"},[f.type==="time"?(c(),g("div",yn,[o(d)])):f.type==="hitokoto"?(c(),g("div",bn,[o(m)])):f.type==="exam"?(c(),g("div",vn,[o(p,{"exam-id":f.data.examId,"content-style":i.contentStyle,onClick:S=>t.$emit("open-exam-detail",f.data.examId)},null,8,["exam-id","content-style","onClick"])])):f.type==="attendance"?(c(),v(_,{key:3,class:O([{"glow-highlight":i.highlightedCards[f.key],"cursor-not-allowed":i.isEditingDisabled,"cursor-pointer":!i.isEditingDisabled},"glow-track"]),border:"",height:"100%",onClick:e[0]||(e[0]=S=>n.handleCardClick("attendance",null)),onMousemove:n.handleMouseMove,onTouchmove:n.handleTouchMove},{default:a(()=>[o(I,{class:"d-flex align-center"},{default:a(()=>[o(x,{class:"mr-2",color:"primary",icon:"mdi-account-group"}),e[1]||(e[1]=u(" 出勤统计 ",-1))]),_:1}),o(T,null,{default:a(()=>[r("div",wn,[e[2]||(e[2]=r("span",null,"应到/实到",-1)),r("span",Sn,h(f.data.total-f.data.exclude.length)+"/"+h(f.data.total-f.data.absent.length-!n.getSetting("display.lateStudentsArePresent")*f.data.late.length-f.data.exclude.length),1)]),o(F,{class:"mb-2"}),f.data.absent.length>0?(c(),g("div",Dn,[r("div",xn,"请假 ("+h(f.data.absent.length)+")",1),r("div",kn,[(c(!0),g(k,null,M(f.data.absent,S=>(c(),v(L,{key:S,color:"error",size:"x-small",variant:"flat"},{default:a(()=>[u(h(S),1)]),_:2},1024))),128))])])):w("",!0),f.data.late.length>0?(c(),g("div",Cn,[r("div",Tn,"迟到 ("+h(f.data.late.length)+")",1),r("div",_n,[(c(!0),g(k,null,M(f.data.late,S=>(c(),v(L,{key:S,color:"warning",size:"x-small",variant:"flat"},{default:a(()=>[u(h(S),1)]),_:2},1024))),128))])])):w("",!0),f.data.exclude.length>0?(c(),g("div",Mn,[r("div",En,"不参与 ("+h(f.data.exclude.length)+")",1),r("div",Rn,[(c(!0),g(k,null,M(f.data.exclude,S=>(c(),v(L,{key:S,color:"grey",size:"x-small",variant:"flat"},{default:a(()=>[u(h(S),1)]),_:2},1024))),128))])])):w("",!0),f.data.absent.length===0&&f.data.late.length===0&&f.data.exclude.length===0?(c(),g("div",In," 全勤 ")):w("",!0)]),_:2},1024)]),_:2},1032,["class","onMousemove","onTouchmove"])):f.type==="custom"?(c(),v(_,{key:4,class:O([{"glow-highlight":i.highlightedCards[f.key],"cursor-not-allowed":i.isEditingDisabled,"cursor-pointer":!i.isEditingDisabled},"glow-track"]),border:"",height:"100%",onClick:S=>n.handleCardClick("dialog",f.key),onMousemove:n.handleMouseMove,onTouchmove:n.handleTouchMove},{default:a(()=>[o(I,{class:"text-primary"},{default:a(()=>[o(x,{class:"mr-2",icon:"mdi-card-text-outline",size:"small"}),u(" "+h(f.name),1)]),_:2},1024),o(T,{style:P(i.contentStyle)},{default:a(()=>[u(h(f.content),1)]),_:2},1032,["style"])]),_:2},1032,["class","onClick","onMousemove","onTouchmove"])):(c(),v(_,{key:5,class:O([{"glow-highlight":i.highlightedCards[f.key],"cursor-not-allowed":i.isEditingDisabled,"cursor-pointer":!i.isEditingDisabled},"glow-track"]),border:"",height:"100%",rounded:"xl",onClick:S=>n.handleCardClick("dialog",f.key),onMousemove:n.handleMouseMove,onTouchmove:n.handleTouchMove},{default:a(()=>[o(I,null,{default:a(()=>[u(h(f.name),1)]),_:2},1024),o(T,{style:P(i.contentStyle)},{default:a(()=>[o($,null,{default:a(()=>[(c(!0),g(k,null,M(n.splitPoint(f.content),S=>(c(),v(ee,{key:S},{default:a(()=>[u(h(S),1)]),_:2},1024))),128))]),_:2},1024)]),_:2},1032,["style"])]),_:2},1032,["class","onClick","onMousemove","onTouchmove"]))],12,pn))),128))]),_:1})],512),r("div",Vn,[i.isMobile?(c(),g("div",Nn,[(c(!0),g(k,null,M(i.unusedSubjects,f=>(c(),v(L,{key:f.name,class:"ma-1",color:"primary",variant:"tonal",onClick:S=>n.handleCardClick("dialog",f.name)},{default:a(()=>[o(x,{start:"",size:"small"},{default:a(()=>[u(h(s.isReadOnlyToken?"mdi-cancel":"mdi-plus"),1)]),_:1}),u(" "+h(f.name),1)]),_:2},1032,["onClick"]))),128))])):i.emptySubjectDisplay==="button"?(c(),v(ze,{key:1,divided:"",variant:"tonal"},{default:a(()=>[(c(!0),g(k,null,M(i.unusedSubjects,f=>(c(),v(b,{key:f.name,onClick:S=>n.handleCardClick("dialog",f.name)},{default:a(()=>[o(x,{start:""},{default:a(()=>[u(h(s.isReadOnlyToken?"mdi-cancel":"mdi-plus"),1)]),_:1}),u(" "+h(f.name),1)]),_:2},1032,["onClick"]))),128))]),_:1})):(c(),g("div",Pn,[o(Re,{name:"v-list"},{default:a(()=>[(c(!0),g(k,null,M(i.unusedSubjects,f=>(c(),v(_,{key:f.name,border:"",rounded:"xl",class:"empty-subject-card",onClick:S=>n.handleCardClick("dialog",f.name)},{default:a(()=>[o(I,{class:"text-subtitle-1"},{default:a(()=>[u(h(f.name),1)]),_:2},1024),o(T,{class:"text-center"},{default:a(()=>[s.isReadOnlyToken?(c(),g(k,{key:0},[o(x,{color:"grey",size:"small"},{default:a(()=>[...e[3]||(e[3]=[u(" mdi-cancel ",-1)])]),_:1}),e[4]||(e[4]=r("div",{class:"text-caption text-grey"}," 当日无作业 ",-1))],64)):(c(),g(k,{key:1},[o(x,{color:"grey",size:"small"},{default:a(()=>[...e[5]||(e[5]=[u(" mdi-plus ",-1)])]),_:1}),e[6]||(e[6]=r("div",{class:"text-caption text-grey"}," 点击添加作业 ",-1))],64))]),_:1})]),_:2},1032,["onClick"]))),128))]),_:1})]))])],64)}const Ln=H(fn,[["render",An],["__scopeId","data-v-0c1610f8"]]),zn={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"]},Fn={class:"d-flex flex-wrap align-center mt-4"};function Bn(t,e,i,l,s,n){return c(),g(k,null,[r("div",Fn,[i.synced?(c(),v(b,{key:1,color:"success",size:"large",onClick:e[1]||(e[1]=d=>t.$emit("show-sync-message")),rounded:"xl"},{default:a(()=>[...e[9]||(e[9]=[u(" 同步完成 ",-1)])]),_:1})):(c(),v(b,{key:0,loading:i.loadingUpload,class:"ml-2",color:"error",size:"large",onClick:e[0]||(e[0]=d=>t.$emit("upload")),rounded:"xl"},{default:a(()=>[...e[8]||(e[8]=[u(" 上传 ",-1)])]),_:1},8,["loading"])),i.showRandomPickerButton?(c(),v(b,{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:a(()=>[...e[10]||(e[10]=[u(" 随机点名 ",-1)])]),_:1})):w("",!0),i.showExamScheduleButton?(c(),v(ze,{key:3,class:"ml-2",color:"green",variant:"elevated",divided:""},{default:a(()=>[o(b,{"prepend-icon":"mdi-calendar-check",size:"large",onClick:e[3]||(e[3]=d=>t.$router.push("/examschedule"))},{default:a(()=>[...e[11]||(e[11]=[u(" 考试看板 ",-1)])]),_:1}),o(b,{icon:"mdi-plus",size:"large",onClick:e[4]||(e[4]=d=>t.$emit("add-exam-card"))})]),_:1})):w("",!0),i.showListCardButton?(c(),v(b,{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:a(()=>[...e[12]||(e[12]=[u(" 列表 ",-1)])]),_:1})):w("",!0),i.showFullscreenButton?(c(),v(b,{key:5,color:i.isFullscreen?"blue-grey":"blue","prepend-icon":i.isFullscreen?"mdi-fullscreen-exit":"mdi-fullscreen",class:"ml-2",size:"large",onClick:e[6]||(e[6]=d=>t.$emit("toggle-fullscreen"))},{default:a(()=>[u(h(i.isFullscreen?"退出全屏":"全屏显示"),1)]),_:1},8,["color","prepend-icon"])):w("",!0),i.showTestCardButton?(c(),v(b,{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:a(()=>[...e[13]||(e[13]=[u(" 添加测试卡片 ",-1)])]),_:1})):w("",!0)]),i.showAntiScreenBurnCard?(c(),v(_,{key:0,border:"",class:"mt-4 anti-burn-card",color:"primary",variant:"tonal"},{default:a(()=>[o(I,{class:"text-subtitle-1"},{default:a(()=>[o(x,{icon:"mdi-shield-check",size:"small",start:""}),e[14]||(e[14]=u(" 屏幕保护技术已启用 ",-1))]),_:1}),o(T,{class:"text-body-2"},{default:a(()=>[...e[15]||(e[15]=[r("p",null," 为防止OLED/LCD屏幕烧屏,界面元素会定期微调位置。 ",-1),r("p",{class:"text-caption text-grey"}," 此功能不会影响正常使用,仅在长时间静止显示时生效。 ",-1),r("p",{class:"text-caption text-grey"}," 建议在放学后关闭显示器以节约能源。 ",-1)])]),_:1})]),_:1})):w("",!0)],64)}const On=H(zn,[["render",Bn]]),jn={name:"FloatingICP"},Un={"aria-label":"xICP备x号",class:"floating-icp-link",href:"https://beian.miit.gov.cn/",rel:"noopener noreferrer",target:"_blank",style:{display:"none"}};function Hn(t,e,i,l,s,n){return c(),g("a",Un," xICP备x号 ")}const Wn=H(jn,[["render",Hn],["__scopeId","data-v-fa73670f"]]),Gn={class:"skeleton-grid"},Kn={__name:"HomeSkeleton",setup(t){const{mobile:e}=Se(),i=ct(()=>e.value?3:6);return(l,s)=>(c(),v(je,{class:"main-window",fluid:""},{default:a(()=>[r("div",Gn,[(c(!0),g(k,null,M(i.value,n=>(c(),g("div",{key:n,class:"skeleton-card"},[...s[0]||(s[0]=[r("div",{class:"skeleton-heading skeleton-pulse"},null,-1),r("div",{class:"skeleton-line skeleton-pulse"},null,-1),r("div",{class:"skeleton-line skeleton-line--short skeleton-pulse"},null,-1)])]))),128))]),s[1]||(s[1]=r("div",{class:"d-flex justify-center mt-6 ga-3"},[r("div",{class:"skeleton-btn skeleton-pulse"}),r("div",{class:"skeleton-btn skeleton-pulse"})],-1))]),_:1}))}},Yn=H(Kn,[["__scopeId","data-v-ea69d8df"]]);function be(t,e){let i=null;return function(...l){i&&clearTimeout(i),i=setTimeout(()=>{t.apply(this,l)},e)}}function qn(t,e){let i=null,l=0;return function(...s){const n=Date.now();n-l<e?(i&&clearTimeout(i),i=setTimeout(()=>{l=n,t.apply(this,s)},e)):(l=n,t.apply(this,s))}}const Jn=z({loader:()=>N(()=>import("./MessageLog-DdVQpYHs.js").then(t=>t.M),__vite__mapDeps([7,0,1,2,3,8,9,10]),import.meta.url),loadingComponent:ce,delay:200}),Xn=z({loader:()=>N(()=>import("./RandomPicker-C1p-Vu66.js"),__vite__mapDeps([11,0,1,2,3,12,13,14,15,16,17,18]),import.meta.url),delay:0}),Zn=z({loader:()=>N(()=>import("./FloatingToolbar-CA5SbKJ5.js"),__vite__mapDeps([19,0,1,2,3,20,21,22,14,15,23,24,25,26]),import.meta.url),delay:200}),Qn=z({loader:()=>N(()=>import("./ChatWidget-C65TaUP3.js").then(t=>t.C),__vite__mapDeps([27,28,29,0,1,2,3,6,30,16,17,31,14,15,32,33,34,35,36,12,13,37,38]),import.meta.url),delay:0}),$n=z({loader:()=>N(()=>import("./HomeworkEditDialog-CauV6ORR.js"),__vite__mapDeps([39,4,5,0,1,2,3,6,36,12,13,37,16,17,40,41,42]),import.meta.url),delay:0}),eo=z({loader:()=>N(()=>import("./InitServiceChooser-C1t4KK09.js"),__vite__mapDeps([43,0,1,2,3,4,5,6,12,13,40,41,36,37,16,17,44,45,32,33,46]),import.meta.url),loadingComponent:ce,delay:200}),to=z({loader:()=>N(()=>import("./StudentNameManager-L676MjOe.js"),__vite__mapDeps([47,0,1,2,3,4,5,6,48,12,13,49,20,21,50,51,52,16,17,53,54,55,56,40,41,57]),import.meta.url),delay:200}),so=z({loader:()=>N(()=>import("./UrgentTestDialog-9MfQJHo_.js"),__vite__mapDeps([58,27,28,29,0,1,2,3,6,30,16,17,31,14,15,32,33,34,35,36,12,13,37,38,4,5,8,9,59,60,61,51,52,62,50,63,64]),import.meta.url),delay:0}),io=z({loader:()=>N(()=>import("./AttendanceSidebar-BPGafVhq.js"),__vite__mapDeps([65,0,1,2,3,32,33,57]),import.meta.url),loadingComponent:ce,delay:200}),no=z({loader:()=>N(()=>import("./AttendanceManagementDialog-BVh2yfQP.js"),__vite__mapDeps([66,0,1,2,3,16,17,32,33,12,13,67]),import.meta.url),delay:0}),oo=z({loader:()=>N(()=>import("./PwaInstallCard-LcNhfX6l.js"),__vite__mapDeps([68,2,0,1,3,16,17]),import.meta.url),delay:200}),ao=z({loader:()=>N(()=>import("./ExamScheduleCard-Eve4AKjn.js"),__vite__mapDeps([69,2,0,1,3,40,41,4,5,6,16,17,70,71,72,73,14,15,12,13,30,51,52,59,60,28,29,31,8,9,32,33,74]),import.meta.url),loadingComponent:ce,delay:200}),ro=z({loader:()=>N(()=>import("./ExamConfigEditor-9yfAaq4d.js"),__vite__mapDeps([75,4,5,0,1,2,3,6,40,41,76,77,14,15,16,17,32,33,12,13,36,37,51,52,48,49,20,21,50,53,54,22,23,24,25,78,79,80]),import.meta.url),delay:0}),lo={name:"Classworks 作业板",components:{MessageLog:Jn,RandomPicker:Xn,FloatingToolbar:Zn,FloatingICP:Wn,HomeworkEditDialog:$n,InitServiceChooser:eo,ChatWidget:Qn,StudentNameManager:to,UrgentTestDialog:so,AttendanceSidebar:io,AttendanceManagementDialog:no,HomeworkGrid:Ln,HomeActions:On,PwaInstallCard:oo,ExamScheduleCard:ao,ExamConfigEditor:ro,HomeSkeleton:Yn},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":`${D("font.size")}px`},uploadLoading:!1,downloadLoading:!1,snackbar:!1,snackbarText:"",fontSize:D("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},dataReady:!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 D("display.forceDesktopMode")?!1:this.mobile},titleText(){var p,f,S;const t=D("server.provider"),e=t==="kv-server"||t==="classworkscloud";let i;e&&this.state.namespaceInfo?i=((p=this.state.namespaceInfo)==null?void 0:p.name)||((S=(f=this.state.namespaceInfo)==null?void 0:f.device)==null?void 0:S.name)||this.state.classNumber||"高三八班":i=this.state.classNumber||"高三八班";const l=this.getToday(),s=new Date(l);s.setDate(s.getDate()-1);const n=this.state.dateString,d=this.formatDate(l),m=this.formatDate(s);return n===d?i+" - 今天的作业":n===m?i+" - 昨天的作业":`${i} - ${n}的作业`},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 i=this.state.boardData.homework[e];t.push({key:e,name:"考试安排",type:"exam",data:{examId:i.examId},order:-100,rowSpan:200})}for(const e of this.state.availableSubjects){const i=e.name,l=this.state.boardData.homework[i];if(l&&l.content){const n=100+l.content.split(`
|
||
`).filter(d=>d.trim()).length*24;t.push({key:i,name:i,type:"homework",content:l.content,order:e.order,rowSpan:n})}}D("timeCard.enabled")&&t.push({key:"time-card",name:"时间",type:"time",order:9997,rowSpan:150}),D("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 i=this.state.boardData.homework[e],s=100+i.content.split(`
|
||
`).filter(n=>n.trim()).length*24;t.push({key:e,name:i.name,type:"custom",content:i.content,order:9999,rowSpan:s})}return t.sort((e,i)=>e.order-i.order),t},unusedSubjects(){const t=Object.keys(this.state.boardData.homework).filter(e=>{var i;return(i=this.state.boardData.homework[e].content)==null?void 0:i.trim()});return this.state.availableSubjects.filter(e=>!t.includes(e.name)).sort((e,i)=>e.order-i.order)},emptySubjects(){return this.emptySubjectDisplay!=="button"?[]:this.unusedSubjects},autoSave(){return D("edit.autoSave")},blockNonTodayAutoSave(){return D("edit.blockNonTodayAutoSave")},isToday(){const t=(()=>{const e=new Date,i=e.getFullYear(),l=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${i}${l}${s}`})();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 D("edit.refreshBeforeEdit")},emptySubjectDisplay(){return D("display.emptySubjectDisplay")},dynamicSort(){return D("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 D("randomPicker.enabled")},showListCardButton(){return D("display.showListCard")},confirmNonTodaySave(){return D("edit.confirmNonTodaySave")},blockPastDataEdit(){return D("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 D("display.showFullscreenButton")},showExamScheduleButton(){return D("display.showExamScheduleButton")},showAntiScreenBurnCard(){return D("display.showAntiScreenBurnCard")},showTestCardButton(){return D("developer.enabled")},shouldShowInit(){var s;const t=D("server.provider"),e=t==="kv-server"||t==="classworkscloud",i=D("server.kvToken"),l=((s=this.$route)==null?void 0:s.path)==="/";return this.settingsTick,l&&e&&(!i||i==="")},hasExamCard(){for(const t in this.state.boardData.homework)if(t.startsWith("exam-"))return!0;return!1},shouldShowUrgentTestButton(){const t=D("server.provider");return!(t==="kv-server"||t==="classworkscloud")||!D("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=be(this.uploadData,2e3),this.debouncedAttendanceSave=be(async()=>{this.autoSave&&await this.trySave(!0)},2e3),this.throttledReflow=qn(()=>{this.$refs.gridContainer&&this.optimizeGridLayout(this.sortedItems)},200)},async mounted(){try{this.updateBackendUrl(),await this.initializeData(),this.dataReady=!0,await this.loadDeviceInfo(),this.setupAutoRefresh(),this.unwatchSettings=Ce(()=>{this.updateSettings()}),this.$nextTick(()=>{const t=this.$refs.studentNameManager;t&&(this.studentNameInfo.name=t.currentStudentName||t.currentTeacherName||"",this.studentNameInfo.isStudent=t.isStudentToken,this.studentNameInfo.isTeacher=t.isTeacherToken,this.studentNameInfo.openDialog=()=>t.openDialog(),this.$watch(()=>t.currentStudentName,e=>{this.studentNameInfo.name=e,this.updateTokenDisplayInfo()}),this.$watch(()=>t.currentTeacherName,e=>{t.isTeacherToken&&(this.studentNameInfo.name=e,this.updateTokenDisplayInfo())}),this.$watch(()=>t.isStudentToken,e=>{this.studentNameInfo.isStudent=e,this.updateTokenDisplayInfo()}),this.$watch(()=>t.isTeacherToken,e=>{this.studentNameInfo.isTeacher=e,this.updateTokenDisplayInfo()}))}),document.addEventListener("fullscreenchange",this.fullscreenChangeHandler),document.addEventListener("webkitfullscreenchange",this.fullscreenChangeHandler),document.addEventListener("mozfullscreenchange",this.fullscreenChangeHandler),document.addEventListener("MSFullscreenChange",this.fullscreenChangeHandler),this.checkHashForRandomPicker(),window.addEventListener("hashchange",this.checkHashForRandomPicker),this.setupRealtimeChannel(),this.$nextTick(()=>{this.updateTokenDisplayInfo()}),await this.loadTokenInfo(),this.loadPersistentNotifications()}catch(t){console.error("初始化失败:",t),this.showError("初始化失败,请刷新页面重试")}},beforeUnmount(){this.unwatchSettings&&this.unwatchSettings(),this.state.refreshInterval&&clearInterval(this.state.refreshInterval),document.removeEventListener("fullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("webkitfullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("mozfullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("MSFullscreenChange",this.fullscreenChangeHandler),window.removeEventListener("hashchange",this.checkHashForRandomPicker);try{this.$offKvChanged&&typeof this.$offKvChanged=="function"&&(this.$offKvChanged(),this.$offKvChanged=null),this.$offDeviceEvent&&typeof this.$offDeviceEvent=="function"&&(this.$offDeviceEvent(),this.$offDeviceEvent=null),this.$offConnect&&typeof this.$offConnect=="function"&&(this.$offConnect(),this.$offConnect=null),wt()}catch(t){console.warn("主页面事件清理失败:",t)}},methods:{async loadDeviceInfo(){var t;try{const e=D("server.provider");if(!(e==="kv-server"||e==="classworkscloud"))return;const l=await ht.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=D("server.provider");if(!(t==="kv-server"||t==="classworkscloud"))return;const i=D("server.kvToken");if(!i)return;const l=D("server.domain");if(!l)return;const s=await ut.get(`${l}/kv/_token`,{headers:{Authorization:`Bearer ${i}`}});this.tokenInfo=s.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,i=t.isReadOnly,l=t.isStudentToken,s=t.isTeacherToken;if(this.tokenDisplayInfo.readonly=i,!l&&!s){this.tokenDisplayInfo.show=!1;return}this.tokenDisplayInfo.text=e,this.tokenDisplayInfo.color="primary",this.tokenDisplayInfo.icon=s?"mdi-school":"mdi-account",this.tokenDisplayInfo.disabled=i,this.tokenDisplayInfo.show=!0},handleTokenChipClick(){console.log("Token chip clicked");const t=this.$refs.studentNameManager;console.log("Manager:",t),console.log("Is student token:",t==null?void 0:t.isStudentToken),console.log("Is teacher token:",t==null?void 0:t.isTeacherToken),t&&(t.isStudentToken||t.isTeacherToken)?(console.log("Opening dialog..."),t.openDialog()):console.log("Cannot open dialog - conditions not met")},ensureDate(t){if(t instanceof Date)return t;if(typeof t=="string"){const e=new Date(t);if(!isNaN(e.getTime()))return e}return new Date},formatDate(t){const e=this.ensureDate(t),i=e.getFullYear(),l=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${i}${l}${s}`},formatTime(t){return t?new Date(t).toLocaleString():""},getToday(){return new Date},async initializeData(){this.parsePreconfigData();const t=await this.parseUrlConfig(),i=new URLSearchParams(window.location.search).get("date"),l=this.getToday();let s=l;if(i){if(/^\d{8}$/.test(i)){const n=i.substring(0,4),d=i.substring(4,6),m=i.substring(6,8);s=new Date(`${n}-${d}-${m}`)}else s=new Date(i);isNaN(s.getTime())&&(s=l)}if(this.state.dateString=this.formatDate(s),this.state.selectedDate=this.state.dateString,this.state.selectedDateObj=s,this.state.isToday=this.formatDate(s)===this.formatDate(l),!t){this.provider=D("server.provider");const n=D("server.classNumber");this.state.classNumber=n}await Promise.all([this.downloadData(),this.loadConfig()]),await this.examStore.fetchExamList();for(const n of this.examStore.examList)this.examStore.fetchExam(n.id);this.checkUpcomingExams()},async checkUpcomingExams(){this.upcomingExams=await this.examStore.getUpcomingExams()},loadExamCards(){},saveExamCards(){},addExamCard(t,e=!1,i=!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,i||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,i,l;if(!this.loading.download)try{this.loading.download=!0;const s=await R.loadData("classworks-data-"+this.state.dateString);if(s.success==!1)if(s.error.code==="NOT_FOUND")this.state.showNoDataMessage=!0,this.state.noDataMessage=s.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(s.error.message);else this.state.boardData={homework:s.homework||{},attendance:{absent:((e=s.attendance)==null?void 0:e.absent)||[],late:((i=s.attendance)==null?void 0:i.late)||[],exclude:((l=s.attendance)==null?void 0:l.exclude)||[]}},this.state.synced=!0,this.state.showNoDataMessage=!1,this.$message.success("下载成功","数据已更新")}catch(s){console.error("数据加载失败:",s),this.$message.error("下载失败",s.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 i;if(!this.currentEditSubject)return;const t=this.state.textarea.trim(),e=((i=this.state.boardData.homework[this.currentEditSubject])==null?void 0:i.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 R.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 R.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 R.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 i=this.$refs.studentNameManager;i!=null&&i.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(i){console.error("刷新数据失败:",i),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(i=>i.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`},J("font.size",this.state.fontSize)},updateBackendUrl(){const t=D("server.provider"),e=D("server.classNumber");this.provider=t,this.state.classNumber=e},setupAutoRefresh(){const t=D("refresh.auto"),e=D("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=D("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),i=this.formatDate(e);if(i===this.state.dateString)return;this.state.dateString=i,this.state.selectedDate=i,this.state.selectedDateObj=e,this.state.isToday=i===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=D("server.kvToken");if(!t){console.warn("未配置 KV Token,无法加入实时频道");return}bt(),Ve(t),this.$offConnect=vt(()=>Ve(t)),this.debouncedRealtimeRefresh||(this.debouncedRealtimeRefresh=be(async()=>{var f,S,j;const l=JSON.parse(JSON.stringify(this.state.boardData.homework));await this.downloadData();const s=new Date,n=String(s.getHours()).padStart(2,"0"),d=String(s.getMinutes()).padStart(2,"0"),m=String(s.getSeconds()).padStart(2,"0");(f=this.$message)==null||f.info("数据已更新",`已于 ${n}:${d}:${m} 自动刷新`);const p={};for(const A in this.state.boardData.homework){const Y=((S=l[A])==null?void 0:S.content)||"",q=((j=this.state.boardData.homework[A])==null?void 0:j.content)||"";Y!==q&&(p[A]=!0)}for(const A in l)this.state.boardData.homework[A]||(p[A]=!0);this.highlightedCards=p,setTimeout(()=>{this.highlightedCards={}},1e4)},800));const e=l=>{var n;if(!l)return;if(l.key==="notification-list"){this.loadPersistentNotifications();return}const s=`classworks-data-${this.state.dateString}`;l.key===s&&(l.action!=="upsert"&&l.action!=="delete"||(n=this.debouncedRealtimeRefresh)==null||n.call(this,l.key))},i=l=>{let s=l;l.content&&l.timestamp&&(s={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(s)};this.$offKvChanged=Ne("kv-key-changed",i),this.deviceEventHandler=St({onKvChanged:e,enableLegacySupport:!0}),this.$offDeviceEvent=Ne("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="",i="success"){this.$message[i](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 i=atob(e),l=Uint8Array.from(i,f=>f.charCodeAt(0)),s=new TextDecoder().decode(l),n=JSON.parse(s);console.log("从URL读取配置:",n);const d=[],m={},p={};return this.processSpecialSettings(n,d,m),this.processStandardSettings(n,d,m,p),Object.keys(m).length===0?(console.log("URL配置与当前配置相同,无需应用"),!1):new Promise(f=>{this.urlConfigDialog={show:!0,config:n,changes:d,validSettings:m,icons:p,confirmHandler:()=>{this.urlConfigDialog.show=!1,this.applyUrlConfig(m),f(!0)},cancelHandler:()=>{this.urlConfigDialog.show=!1,f(!1)}}})}catch(i){return console.error("解析URL配置错误:",i),this.$message.error("URL配置错误","无法解析配置数据"),!1}}catch(t){return console.error("处理URL配置错误:",t),!1}},processSpecialSettings(t,e,i){var l,s;if(t.classNumber!==void 0){const n=D("server.classNumber");t.classNumber!==n&&(e.push({key:"server.classNumber",name:"班级",oldValue:n,newValue:t.classNumber,description:((l=X["server.classNumber"])==null?void 0:l.description)||"班级编号",icon:((s=X["server.classNumber"])==null?void 0:s.icon)||"mdi-account-group"}),i["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"}),i.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"}),i.subjects=t.subjects)},processStandardSettings(t,e,i,l){Object.entries(t).forEach(([s,n])=>{if(["classNumber","date","subjects"].includes(s))return;let d=s,m=X[s];if(!m&&!s.includes(".")){const p=["server.","display.","theme.","edit.","refresh.","font.","randomPicker."];for(const f of p){const S=`${f}${s}`;if(X[S]){d=S,m=X[S];break}}}if(m){let p=this.convertValueToCorrectType(n,m.type);if(m.validate&&!m.validate(p)){console.warn(`URL配置项 ${d} 的值无效: ${n}`);return}const f=D(d);p!==f&&(e.push({key:d,name:this.getSettingDisplayName(d),oldValue:this.formatSettingValue(f),newValue:this.formatSettingValue(p),description:m.description||d,icon:m.icon||"mdi-cog"}),i[d]=p,l[d]=m.icon||"mdi-cog")}else e.push({key:s,name:this.getSettingDisplayName(s),oldValue:"未知",newValue:this.formatSettingValue(n),description:"自定义配置项",icon:"mdi-cog-outline"}),i[s]=n,l[s]="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("."),i=e[e.length-1];return{provider:"数据提供方",domain:"服务器域名",classNumber:"班级编号",emptySubjectDisplay:"空科目显示方式",dynamicSort:"动态排序",showRandomButton:"随机按钮",showFullscreenButton:"全屏按钮",cardHoverEffect:"卡片悬浮效果",enhancedTouchMode:"增强触摸模式",showAntiScreenBurnCard:"防烧屏卡片",mode:"主题模式",size:"字体大小",autoSave:"自动保存",blockNonTodayAutoSave:"禁止自动保存非当日",refreshBeforeEdit:"编辑前刷新",confirmNonTodaySave:"非当日保存确认",auto:"自动刷新",interval:"刷新间隔"}[i]||i},safeBase64Decode(t){try{return Fe.decode(t)}catch(e){throw console.error("Base64解码错误:",e),new Error("无法解码配置数据")}},applyUrlConfig(t){for(const[e,i]of Object.entries(t)){if(e==="date"){this.handleDateSelect(i);continue}if(e==="subjects"){this.state.availableSubjects=i;continue}J(e,i),e==="server.classNumber"&&(this.state.classNumber=i)}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)),i=this.getToday(),l=this.formatDate(i);this.state.dateString=l,await this.downloadData();const s={};for(const d in e)e[d]&&e[d].content&&(e[d].type==="custom"?s[d]=JSON.parse(JSON.stringify(e[d])):s[d]={content:e[d].content});this.state.boardData.homework=s,this.state.synced=!1,await this.uploadData(),this.state.selectedDate=l,this.state.selectedDateObj=i,this.state.isToday=!0;const n=new URL(window.location);n.searchParams.delete("date"),window.history.pushState({},"",n),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"),i=t.get("authCode")||t.get("auth_code"),l=t.get("autoExecute")||t.get("auto_execute");e&&(this.preconfigData.namespace=e,this.preconfigData.authCode=i,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 i=!1;t.forEach(l=>{e.searchParams.has(l)&&(e.searchParams.delete(l),i=!0)}),i&&window.history.replaceState({},document.title,e.toString())}catch(e){console.error("清理URL参数失败:",e)}},async loadPersistentNotifications(){try{const t=await R.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(i=>i.id!==t);const e=this.persistentNotifications.length>0?this.persistentNotifications:{};await R.saveData("notification-list",e),this.notificationDetailDialog=!1}}},co={key:3,class:"d-flex"},uo={class:"text-h6 text-truncate font-weight-bold"},ho={class:"text-h4 font-weight-medium mb-4",style:{"line-height":"1.5"}},mo={class:"text-subtitle-1 text-grey"},fo={class:"d-flex align-center flex-wrap"},go={class:"text-subtitle-1"},po={class:"text-grey-darken-1"},yo={class:"text-primary font-weight-medium"},bo={key:1,class:"text-center py-4 text-grey"};function vo(t,e,i,l,s,n){const d=V("init-service-chooser"),m=V("StudentNameManager"),p=V("HomeSkeleton"),f=V("homework-grid"),S=V("home-actions"),j=V("pwa-install-card"),A=V("attendance-sidebar"),Y=V("homework-edit-dialog"),q=V("attendance-management-dialog"),he=V("message-log"),W=V("floating-toolbar"),me=V("FloatingICP"),Je=V("ChatWidget"),Xe=V("UrgentTestDialog"),Ze=V("random-picker"),Qe=V("exam-config-editor");return c(),g(k,null,[o(xt,{class:"no-select"},{append:a(()=>[s.tokenDisplayInfo.readonly?(c(),v(L,{key:0,class:"mx-2",color:"warning","prepend-icon":"mdi-lock-alert",variant:"tonal"},{default:a(()=>[...e[29]||(e[29]=[u(" 只读 ",-1)])]),_:1})):w("",!0),s.tokenDisplayInfo.show?(c(),v(L,{key:1,style:P({cursor:s.tokenDisplayInfo.disabled?"default":"pointer"}),class:"mx-2",color:"primary","prepend-icon":"mdi-account",variant:"tonal",onClick:n.handleTokenChipClick},{default:a(()=>[u(h(s.tokenDisplayInfo.text),1)]),_:1},8,["style","onClick"])):w("",!0),n.shouldShowUrgentTestButton?(c(),v(b,{key:2,"prepend-icon":"mdi-chat",onClick:e[0]||(e[0]=y=>s.urgentTestDialog=!0),variant:"tonal"},{default:a(()=>[...e[30]||(e[30]=[u("发送通知",-1)])]),_:1})):w("",!0),o(b,{icon:"mdi-chat",variant:"text",onClick:e[1]||(e[1]=y=>s.isChatOpen=!0)}),o(b,{badge:n.unreadCount||void 0,"badge-color":n.unreadCount?"error":void 0,icon:"mdi-bell",variant:"text",onClick:e[2]||(e[2]=y=>t.$refs.messageLog.drawer=!0)},null,8,["badge","badge-color"]),o(b,{icon:"mdi-cog",variant:"text",onClick:e[3]||(e[3]=y=>t.$router.push("/settings"))})]),default:a(()=>[o(Dt,null,{default:a(()=>[u(h(n.titleText),1)]),_:1}),o(E)]),_:1}),n.shouldShowInit?(c(),v(d,{key:0,preconfig:s.preconfigData,onDone:e[4]||(e[4]=y=>s.settingsTick++)},null,8,["preconfig"])):w("",!0),n.shouldShowInit?w("",!0):(c(),v(m,{key:1,ref:"studentNameManager",onTokenInfoUpdated:n.updateTokenDisplayInfo},null,8,["onTokenInfoUpdated"])),!n.shouldShowInit&&!s.dataReady?(c(),v(p,{key:2})):w("",!0),!n.shouldShowInit&&s.dataReady?(c(),g("div",co,[o(je,{class:"main-window flex-grow-1 no-select bloom-container",fluid:""},{default:a(()=>[s.persistentNotifications.length>0?(c(),v(kt,{key:0,class:"mb-4"},{default:a(()=>[o(Ct,{cols:"12"},{default:a(()=>[(c(!0),g(k,null,M(s.persistentNotifications,y=>(c(),v(_,{key:y.id,color:y.isUrgent?"error":"primary",class:"mb-2 cursor-pointer",variant:"tonal",onClick:fe=>n.showNotificationDetail(y)},{default:a(()=>[o(T,{class:"d-flex align-center py-3"},{default:a(()=>[r("span",uo,h(y.message),1),o(E),o(b,{icon:"mdi-chevron-right",variant:"text"})]),_:2},1024)]),_:2},1032,["color","onClick"]))),128))]),_:1})]),_:1})):w("",!0),o(B,{modelValue:s.notificationDetailDialog,"onUpdate:modelValue":e[8]||(e[8]=y=>s.notificationDetailDialog=y),"max-width":"700",scrollable:""},{default:a(()=>[s.currentNotification?(c(),v(_,{key:0,class:"rounded-xl"},{default:a(()=>[o(I,{class:"d-flex align-center pa-4 text-h5"},{default:a(()=>[r("span",{class:O([s.currentNotification.isUrgent?"text-error":"","font-weight-bold"])},h(s.currentNotification.isUrgent?"强调通知":"通知详情"),3),o(E),o(b,{icon:"mdi-close",variant:"text",onClick:e[5]||(e[5]=y=>s.notificationDetailDialog=!1)})]),_:1}),o(F),o(T,{class:"pa-6"},{default:a(()=>[r("div",ho,h(s.currentNotification.message),1),r("div",mo," 发布时间:"+h(n.formatTime(s.currentNotification.timestamp)),1)]),_:1}),o(F),o(U,{class:"pa-4"},{default:a(()=>[o(b,{color:"error","prepend-icon":"mdi-delete",size:"x-large",variant:"tonal",class:"px-6",onClick:e[6]||(e[6]=y=>n.removePersistentNotification(s.currentNotification.id))},{default:a(()=>[...e[31]||(e[31]=[u(" 删除通知 ",-1)])]),_:1}),o(E),o(b,{color:"primary",size:"x-large",variant:"elevated",class:"px-8",onClick:e[7]||(e[7]=y=>s.notificationDetailDialog=!1)},{default:a(()=>[...e[32]||(e[32]=[u(" 关闭 ",-1)])]),_:1})]),_:1})]),_:1})):w("",!0)]),_:1},8,["modelValue"]),o(f,{"sorted-items":n.sortedItems,"unused-subjects":n.unusedSubjects,"empty-subject-display":n.emptySubjectDisplay,"is-mobile":n.isMobile,"is-editing-disabled":n.isEditingDisabled,"content-style":s.state.contentStyle,"highlighted-cards":s.highlightedCards,onOpenDialog:n.openDialog,onOpenAttendance:n.setAttendanceArea,onDisabledClick:n.handleDisabledClick,onOpenExamDetail:n.openExamDetail},null,8,["sorted-items","unused-subjects","empty-subject-display","is-mobile","is-editing-disabled","content-style","highlighted-cards","onOpenDialog","onOpenAttendance","onDisabledClick","onOpenExamDetail"]),o(S,{synced:s.state.synced,"loading-upload":s.loading.upload,"show-random-picker-button":n.showRandomPickerButton,"show-exam-schedule-button":n.showExamScheduleButton,"show-list-card-button":n.showListCardButton,"show-fullscreen-button":n.showFullscreenButton,"is-fullscreen":s.state.isFullscreen,"show-anti-screen-burn-card":n.showAntiScreenBurnCard,"show-test-card-button":n.showTestCardButton,onUpload:n.manualUpload,onShowSyncMessage:n.showSyncMessage,onOpenRandomPicker:n.openRandomPicker,onToggleFullscreen:n.toggleFullscreen,onAddTestCard:n.addTestCard,onAddExamCard:e[9]||(e[9]=y=>s.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"]),o(j),s.upcomingExams.length>0&&!n.hasExamCard?(c(),v(ae,{key:1,class:"mt-4",color:"info",variant:"tonal",closable:"",icon:"mdi-calendar-clock",title:"近期有考试安排"},{append:a(()=>[o(b,{color:"primary",variant:"text",onClick:n.addAllUpcomingExams},{default:a(()=>[...e[34]||(e[34]=[u(" 一键添加 ",-1)])]),_:1},8,["onClick"])]),default:a(()=>[r("div",fo,[e[33]||(e[33]=r("span",{class:"mr-2"},"检测到未来两天内有以下考试:",-1)),(c(!0),g(k,null,M(s.upcomingExams,y=>(c(),v(L,{key:y.id,size:"small",class:"mr-1 mb-1",color:"primary"},{default:a(()=>[u(h(y.examName),1)]),_:2},1024))),128))])]),_:1})):w("",!0)]),_:1}),n.isMobile?w("",!0):(c(),v(A,{key:0,"student-list":s.state.studentList,attendance:s.state.boardData.attendance,"is-editing-disabled":n.isEditingDisabled,onClick:n.setAttendanceArea,onDisabledClick:n.handleDisabledClick},null,8,["student-list","attendance","is-editing-disabled","onClick","onDisabledClick"]))])):w("",!0),o(Y,{modelValue:s.state.dialogVisible,"onUpdate:modelValue":e[10]||(e[10]=y=>s.state.dialogVisible=y),"auto-save":n.autoSave,"initial-content":s.state.textarea,title:s.state.dialogTitle,"is-editing-past-data":n.isEditingPastData,"current-date-string":s.state.dateString,onSave:n.handleHomeworkSave},null,8,["modelValue","auto-save","initial-content","title","is-editing-past-data","current-date-string","onSave"]),o(it,{modelValue:s.state.snackbar,"onUpdate:modelValue":e[11]||(e[11]=y=>s.state.snackbar=y),timeout:2e3},{default:a(()=>[u(h(s.state.snackbarText),1)]),_:1},8,["modelValue"]),o(q,{modelValue:s.state.attendanceDialog,"onUpdate:modelValue":e[12]||(e[12]=y=>s.state.attendanceDialog=y),"student-list":s.state.studentList,attendance:s.state.boardData.attendance,"date-string":s.state.dateString,onSave:n.saveAttendance,onChange:n.handleAttendanceChange},null,8,["modelValue","student-list","attendance","date-string","onSave","onChange"]),o(he,{ref:"messageLog"},null,512),o(W,{"is-today":n.isToday,loading:s.loading.download,"copy-to-today-loading":s.loading.copyToToday,"selected-date":s.state.selectedDateObj,"unread-count":n.unreadCount,onRefresh:n.downloadData,onZoom:n.zoom,onOpenMessages:e[13]||(e[13]=y=>t.$refs.messageLog.drawer=!0),onOpenSettings:e[14]||(e[14]=y=>t.$router.push("/settings")),onDateSelect:n.handleDateSelect,onPrevDay:e[15]||(e[15]=y=>n.navigateDay(-1)),onNextDay:e[16]||(e[16]=y=>n.navigateDay(1)),onCopyToToday:n.copyHomeworkToToday},null,8,["is-today","loading","copy-to-today-loading","selected-date","unread-count","onRefresh","onZoom","onDateSelect","onCopyToToday"]),o(me),o(Je,{modelValue:s.isChatOpen,"onUpdate:modelValue":e[17]||(e[17]=y=>s.isChatOpen=y),"show-button":!1},null,8,["modelValue"]),o(Xe,{modelValue:s.urgentTestDialog,"onUpdate:modelValue":e[18]||(e[18]=y=>s.urgentTestDialog=y)},null,8,["modelValue"]),o(B,{modelValue:s.confirmDialog.show,"onUpdate:modelValue":e[19]||(e[19]=y=>s.confirmDialog.show=y),"max-width":"400"},{default:a(()=>[o(_,null,{default:a(()=>[o(I,{class:"text-h6"},{default:a(()=>[...e[35]||(e[35]=[u(" 确认保存",-1)])]),_:1}),o(T,null,{default:a(()=>[u(" 您正在修改 "+h(s.state.dateString)+" 的数据,确定要保存吗? ",1)]),_:1}),o(U,null,{default:a(()=>[o(E),o(b,{color:"grey",variant:"text",onClick:s.confirmDialog.reject},{default:a(()=>[...e[36]||(e[36]=[u(" 取消 ",-1)])]),_:1},8,["onClick"]),o(b,{color:"primary",onClick:s.confirmDialog.resolve},{default:a(()=>[...e[37]||(e[37]=[u(" 确认保存",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),o(Ze,{ref:"randomPicker",attendance:s.state.boardData.attendance,"student-list":s.state.studentList},null,8,["attendance","student-list"]),o(B,{modelValue:s.urlConfigDialog.show,"onUpdate:modelValue":e[20]||(e[20]=y=>s.urlConfigDialog.show=y),"max-width":"500"},{default:a(()=>[o(_,null,{default:a(()=>[o(I,{class:"text-h6"},{default:a(()=>[...e[38]||(e[38]=[u(" 确认应用URL配置",-1)])]),_:1}),o(T,null,{default:a(()=>[e[39]||(e[39]=r("p",null,"以下配置将应用于当前班级:",-1)),o($,{density:"compact"},{default:a(()=>[(c(!0),g(k,null,M(s.urlConfigDialog.changes,y=>(c(),v(ee,{key:y.key},{prepend:a(()=>[o(x,{icon:y.icon,class:"mr-2",size:"small"},null,8,["icon"])]),default:a(()=>[o(ve,{class:"d-flex align-center"},{default:a(()=>[r("span",go,h(y.name),1),o(gt,{activator:"parent",location:"top"},{default:a(()=>[u(h(y.description||y.key),1)]),_:2},1024)]),_:2},1024),o(we,null,{default:a(()=>[r("span",po,h(y.oldValue),1),o(x,{class:"mx-1",icon:"mdi-arrow-right",size:"small"}),r("span",yo,h(y.newValue),1)]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1}),o(U,null,{default:a(()=>[o(E),o(b,{color:"grey",variant:"text",onClick:s.urlConfigDialog.cancelHandler},{default:a(()=>[...e[40]||(e[40]=[u(" 取消 ",-1)])]),_:1},8,["onClick"]),o(b,{color:"primary",onClick:s.urlConfigDialog.confirmHandler},{default:a(()=>[...e[41]||(e[41]=[u(" 确认应用 ",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),o(B,{modelValue:s.showExamDetailDialog,"onUpdate:modelValue":e[23]||(e[23]=y=>s.showExamDetailDialog=y),persistent:"",fullscreen:""},{default:a(()=>[s.selectedExamId?(c(),v(_,{key:0},{default:a(()=>[o(I,{class:"d-flex align-center pa-4"},{default:a(()=>[e[42]||(e[42]=u(" 编辑考试配置 ",-1)),o(E),o(b,{icon:"mdi-close",variant:"text",onClick:e[21]||(e[21]=y=>s.showExamDetailDialog=!1)})]),_:1}),o(T,{class:"pa-4",style:{"max-height":"70vh","overflow-y":"auto"}},{default:a(()=>[o(Qe,{"config-id":s.selectedExamId,"dialog-mode":!0,onSaved:n.onExamConfigSaved,onDeleted:n.onExamConfigDeleted},null,8,["config-id","onSaved","onDeleted"])]),_:1}),o(F),o(U,{class:"pa-4"},{default:a(()=>[o(b,{color:"error","prepend-icon":"mdi-delete",variant:"tonal",onClick:n.removeCurrentExamCard},{default:a(()=>[...e[43]||(e[43]=[u(" 移除卡片 ",-1)])]),_:1},8,["onClick"]),o(E),o(b,{color:"primary",variant:"text",onClick:e[22]||(e[22]=y=>s.showExamDetailDialog=!1)},{default:a(()=>[...e[44]||(e[44]=[u(" 关闭 ",-1)])]),_:1})]),_:1})]),_:1})):w("",!0)]),_:1},8,["modelValue"]),o(B,{modelValue:s.showAddExamDialog,"onUpdate:modelValue":e[25]||(e[25]=y=>s.showAddExamDialog=y),"max-width":"500"},{default:a(()=>[o(_,null,{default:a(()=>[o(I,{class:"text-h6"},{default:a(()=>[...e[45]||(e[45]=[u("预览考试看板",-1)])]),_:1}),o(T,null,{default:a(()=>[l.examStore.examList.length>0?(c(),v($,{key:0},{default:a(()=>[(c(!0),g(k,null,M(l.examStore.examList,y=>{var fe;return c(),v(ee,{key:y.id,title:((fe=l.examStore.exams[y.id])==null?void 0:fe.examName)||y.id,subtitle:y.id,onClick:So=>n.addExamCard(y.id)},{prepend:a(()=>[o(x,{color:"primary"},{default:a(()=>[...e[46]||(e[46]=[u("mdi-calendar-text",-1)])]),_:1})]),append:a(()=>[o(b,{icon:n.isExamCardAdded(y.id)?"mdi-check":"mdi-plus",color:n.isExamCardAdded(y.id)?"success":"grey",variant:"text"},null,8,["icon","color"])]),_:2},1032,["title","subtitle","onClick"])}),128))]),_:1})):(c(),g("div",bo," 暂无考试配置 "))]),_:1}),o(U,null,{default:a(()=>[o(E),o(b,{color:"primary",variant:"text",onClick:e[24]||(e[24]=y=>s.showAddExamDialog=!1)},{default:a(()=>[...e[47]||(e[47]=[u("关闭",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),o(B,{modelValue:s.notificationDetailDialog,"onUpdate:modelValue":e[28]||(e[28]=y=>s.notificationDetailDialog=y),"max-width":"600"},{default:a(()=>[s.currentNotification?(c(),v(_,{key:0},{default:a(()=>[o(I,{class:O(["headline",s.currentNotification.isUrgent?"text-error":"text-primary"])},{default:a(()=>[u(h(s.currentNotification.isUrgent?"强调通知":"通知详情"),1)]),_:1},8,["class"]),o(T,{class:"text-h5 py-4"},{default:a(()=>[u(h(s.currentNotification.message),1)]),_:1}),o(U,null,{default:a(()=>[o(b,{color:"error",variant:"text",onClick:e[26]||(e[26]=y=>n.removePersistentNotification(s.currentNotification.id))},{default:a(()=>[...e[48]||(e[48]=[u("删除",-1)])]),_:1}),o(E),o(b,{color:"primary",onClick:e[27]||(e[27]=y=>s.notificationDetailDialog=!1)},{default:a(()=>[...e[49]||(e[49]=[u("关闭",-1)])]),_:1})]),_:1})]),_:1})):w("",!0)]),_:1},8,["modelValue"]),e[50]||(e[50]=r("br",null,null,-1)),e[51]||(e[51]=r("br",null,null,-1)),e[52]||(e[52]=r("br",null,null,-1))],64)}const wo=H(lo,[["render",vo]]),jo=Object.freeze(Object.defineProperty({__proto__:null,default:wo},Symbol.toStringTag,{value:"Module"}));export{jo as i,De as u};
|