var C=Object.defineProperty;var P=(a,e,t)=>e in a?C(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var h=(a,e,t)=>(P(a,typeof e!="symbol"?e+"":e,t),t);import{d as v,r as w,b as A,c as k,w as x,b0 as I,e as l,eA as D,eB as S,eC as $,v as j,ey as B,H as M,er as N,f as b,u as E,bu as K}from"./registerWidgets.1e9167ab.js";import{a as z}from"./asyncComputed.8a644895.js";import{P as V}from"./project.9f45bccb.js";import{C as _}from"./gateway.6096f5a8.js";import{M as H}from"./member.7cd65334.js";import{A as W}from"./activeRecord.60b6bd01.js";import"./index.11f5d4e4.js";import{M as Y}from"./Modal.b646cd22.js";import{o as F}from"./icons.41af03d8.js";import{_ as G}from"./CrudView.vue_vue_type_script_setup_true_lang.e0bf9fc2.js";import{f as O}from"./index.b048d0fb.js";import"./passwordlessManager.b7f590c1.js";import"./pubsub.09eafe35.js";import"./storage.84fcb572.js";import"./Title.d1f45d59.js";import"./transButton.755e702e.js";import"./index.9165a659.js";import"./Text.c8d7b4c0.js";import"./index.32c7f8ee.js";import"./index.d74062f4.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="fe557a5b-6eaf-401f-8f08-006219b559d6",a._sentryDebugIdIdentifier="sentry-dbid-fe557a5b-6eaf-401f-8f08-006219b559d6")}catch{}})();class T{constructor(){h(this,"urlPath","api-keys")}async create({projectId:e,name:t}){return _.post(`projects/${e}/${this.urlPath}`,{name:t})}async delete(e,t){await _.delete(`projects/${e}/${this.urlPath}/${t}`)}async list(e){return _.get(`projects/${e}/${this.urlPath}`)}async get(){throw new Error("Not implemented")}async update(){throw new Error("Not implemented")}}const u=new T;class c{constructor(e){h(this,"record");this.record=W.create(u,e,"id")}static async list(e){return(await u.list(e)).map(r=>new c(r))}static async create(e){const t=await u.create(e);return new c(t)}static async delete(e,t){await u.delete(e,t)}get id(){return this.record.get("id")}get name(){return this.record.get("name")}async save(){await this.record.save()}get createdAt(){return new Date(this.record.get("createdAt"))}hasChanges(){return this.record.hasChanges()}get ownerId(){return this.record.get("createdBy")}get value(){var e;return(e=this.record.get("value"))!=null?e:null}}const U=a=>(S("data-v-3da8363c"),a=a(),$(),a),q={class:"main-text"},J=U(()=>l("div",{class:"separator"},null,-1)),L=["value"],Q=v({__name:"ApiKeyModal",emits:["delete"],setup(a,{expose:e}){const t=w(null),r=w(""),m={maxWidth:"350px",height:"unset",padding:"30px"},y={display:"flex",flexDirection:"column",alignItems:"center",color:"#414A58",justifyContent:"center",lineHeight:"22px",fontSize:"18px",textAlign:"center",borderBottom:"none",gap:"23px",fontWeight:"700",marginBottom:"17px"},d={color:"#6D7C93",fontSize:"14px",textAlign:"center",justifyContent:"space-around"},f=o=>{var n;r.value=o,(n=t==null?void 0:t.value)==null||n.open()},p=()=>{var o;return(o=t==null?void 0:t.value)==null?void 0:o.close()};return e({open:f,close:p}),(o,n)=>(A(),k(Y,{ref_key:"modalRef",ref:t,"container-style":m,"header-style":y,"content-style":d},{header:x(()=>[I(" API Key Created ")]),content:x(()=>[l("div",q,[I(D("Your API key has been created. Please copy it and store it in a safe place. You will not be able to see it again.")+" ",1),J,l("input",{disabled:"",value:r.value},null,8,L),l("div",{class:"buttons"},[l("button",{class:"cancel",onClick:p},"Close")])])]),_:1},512))}});const R=j(Q,[["__scopeId","data-v-3da8363c"]]),we=v({__name:"ApiKeys",setup(a){const e=[{key:"name",label:"API key name"}],r=B().params.projectId,{loading:m,result:y,refetch:d}=z(async()=>Promise.all([c.list(r),V.get(r).then(o=>H.list(o.organizationId))]).then(([o,n])=>o.map(s=>({apiKey:s,member:n.find(i=>i.authorId===s.ownerId)})))),f=async o=>{const n=await c.create({projectId:r,name:o.name});d(),n.value&&prompt("Copy this API key and paste it in the local editor to deploy your app:",n==null?void 0:n.value)},p=M(()=>{var o,n;return{columns:[{name:"Name"},{name:"Creation date"},{name:"Owner"},{name:"Actions"}],rows:(n=(o=y.value)==null?void 0:o.map(({apiKey:s,member:i})=>{var g;return{key:s.id,cells:[{text:s.name},{text:O(s.createdAt,Date.now(),{addSuffix:!0})},{text:(g=i==null?void 0:i.email)!=null?g:"Unknown"},{text:"actions",actions:[{label:"Delete",icon:F,dangerous:!0,onClick:async()=>{await c.delete(r,s.id),d()}}]}]}}))!=null?n:[]}});return(o,n)=>(A(),N(K,null,[b(G,{"entity-name":"API key","create-button-text":"Create API Key",loading:E(m),title:"API Keys",description:"API Keys are used to deploy your app from the local editor.","empty-title":"No API keys here yet",table:p.value,fields:e,onCreate:f},null,8,["loading","table"]),b(R)],64))}});export{we as default};
//# sourceMappingURL=ApiKeys.678e193a.js.map
