import{d as w,r as A,eB as _,G as k,b as C,eu as h,f as l,u as i,w as d,a_ as v,aq as f,eD as x}from"./outputWidgets.e822ff0f.js";import{a as P}from"./asyncComputed.68870ff7.js";import"./router.8fbd98d9.js";import"./index.3b830ff3.js";import{M as D}from"./member.29cc8137.js";import{A as m}from"./apiKey.fb46be4d.js";import{P as M}from"./project.49fc286a.js";import{g as N}from"./icons.0ab0d55f.js";import{C as T}from"./CrudView.0a0ee0a6.js";import{f as j}from"./index.b048d0fb.js";import{b as B,c as K}from"./Text.4c9d53a2.js";import{M as V}from"./transButton.f06af665.js";import"./Base.775de4d5.js";import"./Title.5afb3003.js";import"./index.bf8163eb.js";import"./record.edca104e.js";import"./pubsub.ae710ef5.js";import"./gateway.349a9491.js";import"./url.c786ab78.js";import"./index.eb9667df.js";import"./index.1b95bbbc.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="d0419f12-6f91-46e6-a022-d23bb9990d1a",n._sentryDebugIdIdentifier="sentry-dbid-d0419f12-6f91-46e6-a022-d23bb9990d1a")}catch{}})();const ne=w({__name:"ApiKeys",setup(n){const a=A(null),p=[{key:"name",label:"API key name"}],s=_().params.projectId,{loading:y,result:g,refetch:u}=P(async()=>Promise.all([m.list(s),M.get(s).then(e=>D.list(e.organizationId))]).then(([e,t])=>e.map(o=>({apiKey:o,member:t.find(r=>r.authorId===o.ownerId)})))),I=async e=>{const t=await m.create({projectId:s,name:e.name});u(),a.value=t.value},b=k(()=>{var e,t;return{columns:[{name:"Name"},{name:"Creation date"},{name:"Owner"},{name:"Actions",align:"right"}],rows:(t=(e=g.value)==null?void 0:e.map(({apiKey:o,member:r})=>{var c;return{key:o.id,cells:[{text:o.name},{text:j(o.createdAt,Date.now(),{addSuffix:!0})},{text:(c=r==null?void 0:r.email)!=null?c:"Unknown"},{text:"actions",actions:[{label:"Delete",icon:N,dangerous:!0,onClick:async()=>{await m.delete(s,o.id),u()}}]}]}}))!=null?t:[]}});return(e,t)=>(C(),h(v,null,[l(T,{"entity-name":"API key","create-button-text":"Create API Key",loading:i(y),title:"API Keys",description:"API Keys are used to deploy your app from the local editor.","empty-title":"No API keys here yet",table:b.value,fields:p,onCreate:I},null,8,["loading","table"]),l(i(V),{open:!!a.value,title:"Api key generated",onCancel:t[0]||(t[0]=o=>a.value=null)},{footer:d(()=>[]),default:d(()=>[l(i(B),null,{default:d(()=>[f("Your API key was successfully generated. Use this code to login on your local development environment or deploy using CI")]),_:1}),l(i(K),{code:"",copyable:""},{default:d(()=>[f(x(a.value),1)]),_:1})]),_:1},8,["open"])],64))}});export{ne as default};
//# sourceMappingURL=ApiKeys.046cd488.js.map
