text: var Y=Object.defineProperty,Z=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var U=(k,a,n)=>a in k?Y(k,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):k[a]=n,q=(k,a)=>{for(var n in a||(a={}))te.call(a,n)&&U(k,n,a[n]);if(L)for(var n of L(a))ae.call(a,n)&&U(k,n,a[n]);return k},x=(k,a)=>Z(k,ee(a));import{x as F,g as O,w as A,i as se}from"./main.d8ec3f25.js";import{i as y,j as E,g as P,k as D,m as R,n as H,q as oe,r as c,o as G,s as X,w as o,t as w,v as $,x as C,y as t,b as s,z as J,A as ne,B as le,c as re,F as ce}from"./vendor.e9042f2c.js";const ie={class:"flex justify-between w-full"},de=["onSubmit"],ue={class:"p-6"},pe={class:"z-0 flex justify-end p-4 border-t border-gray-200 border-solid"},me={setup(k){y(null),y(!1);let a=y(!1),n=y(!1);const S=E(["full","only-db","only-files"]),i=F(),l=O(),p=A(),{t:_}=P(),f=D(()=>l.active&&l.componentName==="BackupModal"),M=D(()=>p.disks.map(r=>x(q({},r),{name:r.name+" \u2014 ["+r.driver+"]"}))),V=D(()=>({currentBackupData:{option:{required:R.withMessage(_("validation.required"),H)},selected_disk:{required:R.withMessage(_("validation.required"),H)}}})),b=oe(V,D(()=>i));async function z(){if(b.value.currentBackupData.$touch(),b.value.currentBackupData.$invalid)return!0;let r={option:i.currentBackupData.option,file_disk_id:i.currentBackupData.selected_disk.id};try{a.value=!0,(await i.createBackup(r)).data&&(a.value=!1,l.refreshData&&l.refreshData(),l.closeModal())}catch{a.value=!1}}async function N(){n.value=!0;let r=await p.fetchDisks({limit:"all"});i.currentBackupData.selected_disk=r.data.data[0],n.value=!1}function I(){l.closeModal(),setTimeout(()=>{b.value.$reset(),i.$reset()})}return(r,B)=>{const e=c("BaseIcon"),d=c("BaseMultiselect"),m=c("BaseInputGroup"),u=c("BaseInputGrid"),h=c("BaseButton"),T=c("BaseModal");return G(),X(T,{show:t(f),onClose:I,onOpen:N},{header:o(()=>[w("div",ie,[$(C(t(l).title)+" ",1),s(e,{name:"XIcon",class:"w-6 h-6 text-gray-500 cursor-pointer",onClick:I})])]),default:o(()=>[w("form",{onSubmit:le(z,["prevent"])},[w("div",ue,[s(u,{layout:"one-column"},{default:o(()=>[s(m,{label:r.$t("settings.backup.select_backup_type"),error:t(b).currentBackupData.option.$error&&t(b).currentBackupData.option.$errors[0].$message,horizontal:"",required:"",class:"py-2"},{default:o(()=>[s(d,{modelValue:t(i).currentBackupData.option,"onUpdate:modelValue":B[0]||(B[0]=v=>t(i).currentBackupData.option=v),options:t(S),"can-deselect":!1,placeholder:r.$t("settings.backup.select_backup_type"),searchable:""},null,8,["modelValue","options","placeholder"])]),_:1},8,["label","error"]),s(m,{label:r.$t("settings.disk.select_disk"),error:t(b).currentBackupData.selected_disk.$error&&t(b).currentBackupData.selected_disk.$errors[0].$message,horizontal:"",required:"",class:"py-2"},{default:o(()=>[s(d,{modelValue:t(i).currentBackupData.selected_disk,"onUpdate:modelValue":B[1]||(B[1]=v=>t(i).currentBackupData.selected_disk=v),"content-loading":t(n),options:t(M),searchable:!0,"allow-empty":!1,label:"name","value-prop":"id",placeholder:r.$t("settings.disk.select_disk"),"track-by":"id",object:""},null,8,["modelValue","content-loading","options","placeholder"])]),_:1},8,["label","error"])]),_:1})]),w("div",pe,[s(h,{class:"mr-3",variant:"primary-outline",type:"button",onClick:I},{default:o(()=>[$(C(r.$t("general.cancel")),1)]),_:1}),s(h,{loading:t(a),disabled:t(a),variant:"primary",type:"submit"},{left:o(v=>[t(a)?ne("",!0):(G(),X(e,{key:0,name:"SaveIcon",class:J(v.class)},null,8,["class"]))]),default:o(()=>[$(" "+C(r.$t("general.create")),1)]),_:1},8,["loading","disabled"])])],40,de)]),_:1},8,["show"])}}},ke={class:"grid my-14 md:grid-cols-3"},fe={class:"inline-block"},Be={setup(k){const a=se(),n=F(),S=O(),i=A(),{t:l}=P(),p=E({selected_disk:{driver:"local"}}),_=y("");let f=y(!0);const M=D(()=>[{key:"path",label:l("settings.backup.path"),thClass:"extra",tdClass:"font-medium text-gray-900"},{key:"created_at",label:l("settings.backup.created_at"),tdClass:"font-medium text-gray-900"},{key:"size",label:l("settings.backup.size"),tdClass:"font-medium text-gray-900"},{key:"actions",label:"",tdClass:"text-right text-sm font-medium",sortable:!1}]),V=D(()=>i.disks.map(e=>x(q({},e),{name:e.name+" \u2014 ["+e.driver+"]"})));N();function b(e){a.openDialog({title:l("general.are_you_sure"),message:l("settings.backup.backup_confirm_delete"),yesLabel:l("general.ok"),noLabel:l("general.cancel"),variant:"danger",hideNoButton:!1,size:"lg"}).then(async d=>{if(d){let m={disk:p.selected_disk.driver,file_disk_id:p.selected_disk.id,path:e.path},u=await n.removeBackup(m);if(u.data.success||u.data.backup)return _.value&&_.value.refresh(),!0}})}function z(){setTimeout(()=>{_.value.refresh()},100)}async function N(){f.value=!0;let e=await i.fetchDisks({limit:"all"});e.data.error,p.selected_disk=e.data.data.find(d=>d.set_as_default==0),f.value=!1}async function I({page:e,filter:d,sort:m}){let u={disk:p.selected_disk.driver,filed_disk_id:p.selected_disk.id};f.value=!0;let h=await n.fetchBackups(u);return f.value=!1,{data:h.data.backups,pagination:{totalPages:1,currentPage:1}}}async function r(){S.openModal({title:l("settings.backup.create_backup"),componentName:"BackupModal",refreshData:_.value&&_.value.refresh,size:"sm"})}async function B(e){f.value=!0,window.axios({method:"GET",url:"/api/v1/download-backup",responseType:"blob",params:{disk:p.selected_disk.driver,file_disk_id:p.selected_disk.id,path:e.path}}).then(d=>{const m=window.URL.createObjectURL(new Blob([d.data])),u=document.createElement("a");u.href=m,u.setAttribute("download",e.path.split("/")[1]),document.body.appendChild(u),u.click(),f.value=!1}).catch(d=>{f.value=!1})}return(e,d)=>{const m=c("BaseIcon"),u=c("BaseButton"),h=c("BaseMultiselect"),T=c("BaseInputGroup"),v=c("BaseDropdownItem"),K=c("BaseDropdown"),Q=c("BaseTable"),W=c("BaseSettingCard");return G(),re(ce,null,[s(me),s(W,{title:e.$tc("settings.backup.title",1),description:e.$t("settings.backup.description")},{action:o(()=>[s(u,{variant:"primary-outline",onClick:r},{left:o(g=>[s(m,{class:J(g.class),name:"PlusIcon"},null,8,["class"])]),default:o(()=>[$(" "+C(e.$t("settings.backup.new_backup")),1)]),_:1})]),default:o(()=>[w("div",ke,[s(T,{label:e.$t("settings.disk.select_disk"),"content-loading":t(f)},{default:o(()=>[s(h,{modelValue:t(p).selected_disk,"onUpdate:modelValue":d[0]||(d[0]=g=>t(p).selected_disk=g),"content-loading":t(f),options:t(V),"track-by":"id",placeholder:e.$t("settings.disk.select_disk"),label:"name",searchable:!0,object:"",class:"w-full","value-prop":"id",onSelect:z},null,8,["modelValue","content-loading","options","placeholder"])]),_:1},8,["label","content-loading"])]),s(Q,{ref:(g,j)=>{j.table=g,_.value=g},class:"mt-10","show-filter":!1,data:I,columns:t(M)},{"cell-actions":o(({row:g})=>[s(K,null,{activator:o(()=>[w("div",fe,[s(m,{name:"DotsHorizontalIcon",class:"text-gray-500"})])]),default:o(()=>[s(v,{onClick:j=>B(g.data)},{default:o(()=>[s(m,{name:"CloudDownloadIcon",class:"mr-3 text-gray-600"}),$(" "+C(e.$t("general.download")),1)]),_:2},1032,["onClick"]),s(v,{onClick:j=>b(g.data)},{default:o(()=>[s(m,{name:"TrashIcon",class:"mr-3 text-gray-600"}),$(" "+C(e.$t("general.delete")),1)]),_:2},1032,["onClick"])]),_:2},1024)]),_:1},8,["columns"])]),_:1},8,["title","description"])],64)}}};export{Be as default};
  