import{d as f,H as y,K as _,b as g,t as T,z as w}from"./registerWidgets.7afd6438.js";import{f as C,g as h,h as k}from"./icons.0ae396f2.js";import{a as D}from"./asyncComputed.b60ddd9a.js";import{T as d}from"./tables.86ab7c96.js";import{R as I}from"./RuntimeList.9752755f.js";import"./activeRecord.e140ff8e.js";import"./pubsub.9805d82b.js";import"./DropdownMenu.90d44aab.js";import"./CircularLoading.283e573b.js";import"./lottie.36f8e1f2.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[o]="2a7bad54-8a26-4ada-9040-ffd477c5306a",n._sentryDebugIdIdentifier="sentry-dbid-2a7bad54-8a26-4ada-9040-ffd477c5306a")}catch{}})();const H=f({__name:"Tables",setup(n){const o=y(),{loading:r,result:l,refetch:i}=D(()=>d.list()),c=({key:e})=>o.push({path:`/_editor/table/${encodeURIComponent(e)}`}),u=async({key:e})=>{var t,a;await((a=(t=l.value)==null?void 0:t.find(s=>s.name===e))==null?void 0:a.duplicate()),i()},m=async()=>{const e=await d.create();c({key:e.name})},b=async({key:e})=>{var t,a;confirm("Are you sure you want to delete this table?")&&(await((a=(t=l.value)==null?void 0:t.find(s=>s.name===e))==null?void 0:a.delete()),i())},p=_(()=>{var e,t;return{columns:[{name:"Table Name"},{name:"Table Actions"}],rows:(t=(e=l.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:C,label:"Delete",onClick:b,dangerous:!0},{icon:h,label:"Edit Table",onClick:c},{icon:k,label:"Duplicate",onClick:u}]}]})))!=null?t:[]}});return(e,t)=>(g(),T(I,{loading:w(r),title:"Database Tables",description:"Create and manage your database tables here.","create-button-text":"Create Table","empty-title":"No tables here yet",table:p.value,onCreate:m},null,8,["loading","table"]))}});export{H as default};
//# sourceMappingURL=Tables.9bebbb2c.js.map
