import{d as w,r as A,ez as k,H as _,b as h,et as C,f as i,u as l,w as d,b9 as v,aB as f,eB as x}from"./outputWidgets.d6334d0e.js";import{a as P}from"./asyncComputed.95fd0999.js";import{P as D}from"./project.2aec9e3e.js";import"./router.c9839d0e.js";import{M}from"./member.ff61f55c.js";import{A as m}from"./apiKey.cecd2cf8.js";import"./columns.6b92da60.js";import{k as T}from"./icons.09e1f108.js";import{C as B}from"./CrudView.a040df87.js";import{f as N}from"./index.b048d0fb.js";import{A as j,a as K}from"./Text.2f6a30da.js";import{M as V}from"./transButton.97ae4a5a.js";import"./gateway.78108c4a.js";import"./activeRecord.aa738a85.js";import"./pubsub.9d7d329e.js";import"./Form.afe8a620.js";import"./Title.132c3f7f.js";import"./index.85dd1fea.js";import"./index.f4ac7424.js";import"./url.dce42ecb.js";import"./index.9476b093.js";import"./index.e0fb68fa.js";import"./index.98d66b02.js";import"./index.2221e01c.js";import"./index.6da051f8.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]="b90a359c-af41-4b07-9aca-b1e43d3a97e6",n._sentryDebugIdIdentifier="sentry-dbid-b90a359c-af41-4b07-9aca-b1e43d3a97e6")}catch{}})();const le=w({__name:"ApiKeys",setup(n){const a=A(null),p=[{key:"name",label:"API key name"}],s=k().params.projectId,{loading:y,result:g,refetch:c}=P(async()=>Promise.all([m.list(s),D.get(s).then(e=>M.list(e.organizationId))]).then(([e,t])=>e.map(o=>({apiKey:o,member:t.find(r=>r.authorId===o.ownerId)})))),b=async e=>{const t=await m.create({projectId:s,name:e.name});c(),a.value=t.value},I=_(()=>{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 u;return{key:o.id,cells:[{text:o.name},{text:N(o.createdAt,Date.now(),{addSuffix:!0})},{text:(u=r==null?void 0:r.email)!=null?u:"Unknown"},{text:"actions",actions:[{label:"Delete",icon:T,dangerous:!0,onClick:async()=>{await m.delete(s,o.id),c()}}]}]}}))!=null?t:[]}});return(e,t)=>(h(),C(v,null,[i(B,{"entity-name":"API key","create-button-text":"Create API Key",loading:l(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:I.value,fields:p,onCreate:b},null,8,["loading","table"]),i(l(V),{open:!!a.value,title:"Api key generated",onCancel:t[0]||(t[0]=o=>a.value=null)},{footer:d(()=>[]),default:d(()=>[i(l(j),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}),i(l(K),{code:"",copyable:""},{default:d(()=>[f(x(a.value),1)]),_:1})]),_:1},8,["open"])],64))}});export{le as default};
//# sourceMappingURL=ApiKeys.a52ff673.js.map
