import{d as w,r as A,eB as _,G as h,b as k,eu as C,f as l,u as i,w as d,a_ as v,aq as f,eD as x}from"./outputWidgets.c4f3de67.js";import{a as P}from"./asyncComputed.c75b06d6.js";import{P as D}from"./project.fda53dcc.js";import"./router.88734ca5.js";import{M}from"./member.b73129dc.js";import{A as m}from"./apiKey.77ea6df7.js";import"./columns.aa61756c.js";import{g as T}from"./icons.49e74e71.js";import{C as N}from"./CrudView.4072ea68.js";import{f as j}from"./index.b048d0fb.js";import{b as B,c as K}from"./Text.fcf8f28f.js";import{M as V}from"./transButton.ebe60b80.js";import"./gateway.5578a098.js";import"./record.685c8ba7.js";import"./pubsub.1842fa2d.js";import"./Base.9ed9c296.js";import"./Title.345a4775.js";import"./index.db3809d7.js";import"./url.d2782274.js";import"./index.c4339fad.js";import"./index.b168b141.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]="64dfc987-e7d1-4f77-bac8-6f37f861b6ef",n._sentryDebugIdIdentifier="sentry-dbid-64dfc987-e7d1-4f77-bac8-6f37f861b6ef")}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: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)})))),I=async e=>{const t=await m.create({projectId:s,name:e.name});c(),a.value=t.value},b=h(()=>{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:j(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)=>(k(),C(v,null,[l(N,{"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.8b1a083a.js.map
