"use strict";exports.id=5875,exports.ids=[5875],exports.modules={5875:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{kX:()=>l,vc:()=>k});var e=c(5242),f=c(7105);c(55104),c(57007);var g=c(10283);c(44195);var h=c(98990),i=c(42597);c(54626),c(24717);var j=a([f,g,h,i]);[f,g,h,i]=j.then?(await j)():j;let m=new Map;async function k(a){m.has(a)&&m.delete(a);let b=await e.db.backupSchedule.findUnique({where:{clientId:a}});b&&b.enabled&&(console.log(`[Scheduler] Scheduling client ${a}: interval polling (every ${b.frequencyHours}h anchored at ${b.windowStart})`),m.set(a,{frequencyHours:b.frequencyHours,windowStart:b.windowStart,lastRun:""}))}function l(a){m.has(a)&&m.delete(a)}d()}catch(a){d(a)}})},10283:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{z:()=>h});var e=c(5242),f=c(74338),g=a([f]);async function h(a,b){let c=await e.db.restoreJob.findUnique({where:{id:a}});if(!c)return{ok:!1,reason:"Restore to resume not found"};if("running"===c.status)return{ok:!1,reason:"That restore is still running"};if("completed"===c.status)return{ok:!1,reason:"That restore already completed"};let d={};try{d=JSON.parse(c.params||"{}")}catch{}let g=d.runFolderId;if(!c.scope||!g)return{ok:!1,reason:"The original restore did not record enough detail to resume"};let h=d.rootJobId||c.id,i=(c.autoResumeCount??0)+ +("system"===b),j=await e.db.restoreJob.create({data:{clientId:c.clientId,status:"running",scope:c.scope,params:JSON.stringify({...d,rootJobId:h,resumeOf:c.id}),autoResumeCount:i}});return await e.db.auditLog.create({data:{clientId:c.clientId,actor:b,action:"system"===b?"RESTORE_AUTO_RESUMED":"RESTORE_RESUMED",detail:`RestoreJob ${j.id} continues ${c.id} (chain root ${h})`}}),(0,f.H8)(c.clientId,j.id,g,c.scope,d.accountEmail,!!d.isLocal,!1,d.targetAccountEmail,d.destinationProfileId??null,h,d.restoreFolderName).catch(async a=>{await e.db.restoreJob.update({where:{id:j.id},data:{status:"failed",completedAt:new Date,errorDetail:a.message}})}),{ok:!0,jobId:j.id}}f=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},44195:(a,b,c)=>{c.d(b,{O:()=>e});var d=c(5242);async function e(a){let b=(await d.db.restoreJob.findMany({where:{clientId:a}})).filter(a=>"running"===a.status||"parked"===a.status);if(0===b.length)return{blocked:!1};let c=b.find(a=>"running"===a.status);if(c)return{blocked:!0,status:"running",restoreJobId:c.id,reason:"A restore is currently running for this client. Backing up now would re-index the restored files as new content, and a full enumeration during a restore can mark live items as deleted."};let e=b[0],f=e.completedAt?new Date(e.completedAt).getTime():Date.now(),g=Math.min(e.parkedUntil?new Date(e.parkedUntil).getTime():f+216e5,f+216e5);return Date.now()<g?{blocked:!0,status:"parked",restoreJobId:e.id,reason:`A restore for this client is parked on Google's daily quota and will resume automatically. Backups are paused until ${new Date(g).toISOString()} so restored files are not re-indexed as new content.`}:{blocked:!1,expired:!0,status:"parked",restoreJobId:e.id,reason:`A restore for this client is still parked, but the 6-hour backup pause has expired — backups are running again. Restored files already written may be indexed as new content.`}}},54626:(a,b,c)=>{c.d(b,{w:()=>e});var d=c(5242);async function e(a){let b=await d.db.client.findUnique({where:{id:a}});if(!b)return{writable:!1,reason:"missing",message:"That client no longer exists."};let c=b.name||a;return"archived"===b.status||b.archivedAt?{writable:!1,reason:"archived",message:`${c} is archived. Its backups are frozen and no new ones will run. Restores still work; un-archive it to resume backups.`}:"suspended"===b.status?{writable:!1,reason:"suspended",message:`${c} is suspended.`}:"active"!==b.status?{writable:!1,reason:"inactive",message:`${c} is not active (status: ${b.status??"unknown"}).`}:{writable:!0}}}};