import{d as f,G as T,b as y,t as C,y as c,K as _}from"./registerWidgets.d12d7cf9.js";import{f as h,g as k,h as g}from"./icons.a63cb90b.js";import{a as w}from"./CircularLoading.89577a16.js";import{T as i}from"./tables.cffe2d61.js";import{R as x}from"./RuntimeList.3913631a.js";import"./utils.3371dfe5.js";const U=f({__name:"Tables",setup(R){const r=_(),{loading:m,result:o,refetch:l}=w(()=>i.list()),s=({key:e})=>r.push({path:`/_editor/table/${encodeURIComponent(e)}`}),d=async({key:e})=>{var t,a;await((a=(t=o.value)==null?void 0:t.find(n=>n.name===e))==null?void 0:a.duplicate()),l()},u=async()=>{const e=await i.create();s({key:e.name})},b=async({key:e})=>{var t,a;confirm("Are you sure you want to delete this table?")&&(await((a=(t=o.value)==null?void 0:t.find(n=>n.name===e))==null?void 0:a.delete()),l())},p=T(()=>{var e,t;return{columns:[{name:"Table Name"},{name:"Table Actions"}],rows:(t=(e=o.value)==null?void 0:e.map(a=>({key:a.name,cells:[{text:a.name,classes:["title","centered"],link:`/_editor/table/${encodeURIComponent(a.name)}`},{text:"",classes:["centered"],actions:[{icon:h,label:"Delete",onClick:b,dangerous:!0},{icon:k,label:"Edit Table",onClick:s},{icon:g,label:"Duplicate",onClick:d}]}]})))!=null?t:[]}});return(e,t)=>(y(),C(x,{loading:c(m),title:"Database Tables",description:"Create and manage your database tables here.","create-button-text":"Create Table","empty-title":"No tables here yet",table:c(p),onCreate:u},null,8,["loading","table"]))}});export{U as default};
//# sourceMappingURL=Tables.02be8cbd.js.map
