import{b as o}from"./chunk-F7TB6D2I.js";import{C as a,D as i,N as r,R as u,X as n,ta as s}from"./chunk-5ONOZUNN.js";var l=class p{#s=n(o);#p=null;#t=s([]);#e=s([]);#a=s(!1);#i=s(!1);#r=s(null);backups=this.#e.asReadonly();backupsLoading=this.#a.asReadonly();startingBackup=this.#i.asReadonly();deletingBackup=this.#r.asReadonly();draftBackups=this.#t.asReadonly();addDraftBackup(t){let e=crypto.randomUUID();return this.#t.set([...this.#t(),{id:e,data:t}]),e}removeDraftBackupById(t){this.#t.set(this.#t().filter(e=>e.id!==t))}getBackupById(t){return this.#e().find(e=>e.Backup?.ID===t)??null}getBackups(t=!1){let e=this.#p,c=Date.now(),k=e&&c-e<15*60*1e3;!1||!t&&k&&this.#e().length||(this.#p=c,this.#a.set(!0),this.#s.getApiV1Backups().pipe(a(1),r(B=>this.#e.set(B)),i(()=>this.#a.set(!1))).subscribe())}startBackup(t){this.#i.set(!0),this.#s.postApiV1BackupByIdStart({id:t}).pipe(a(1),r(()=>this.getBackups()),i(()=>this.#i.set(!1))).subscribe()}deleteBackup(t){this.#r.set(t),this.#s.deleteApiV1BackupById({id:t}).pipe(a(1),r(()=>this.getBackups()),i(()=>this.#r.set(null))).subscribe()}static \u0275fac=function(e){return new(e||p)};static \u0275prov=u({token:p,factory:p.\u0275fac,providedIn:"root"})};export{l as a};
