import{C as x}from"./CrudView-BHryVBYL.js";import{e as j,r as C,l as e,b as A,aQ as D,aR as P,f as z,g as M,v as s,p as t,w as l,aS as S,q as _,t as y,T,ae as h,R as V}from"./jwt-decode.esm-CuqABuF0.js";import{a as B}from"./asyncComputed-Ba-hGgzE.js";import{A as p}from"./apiKey-Cu9zMokf.js";import"./router-C-Pd0gHD.js";import{M as E}from"./member-CO0IVq7z.js";import{a as N}from"./project-D3XwUmzI.js";import"./tables-BHu5fUrG.js";import{u as R}from"./projectStore-CgnhEzHY.js";import"./DocsButton.vue_vue_type_script_setup_true_lang-CgCER6dv.js";import"./constants-BofaUPsW.js";import"./url-Cjn6hAfg.js";import"./PhDotsThreeVertical.vue-DRWxiRIS.js";import"./index-MrLvTX6y.js";import"./ts.worker-D20Caz_K.js";import"./string-CcKlk4eJ.js";import"./organizationSwitcher-C3nwECnr.js";import"./organization-CFugdneJ.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},i=new Error().stack;i&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[i]="25240efd-9b9a-4c38-baf9-41631f48e537",r._sentryDebugIdIdentifier="sentry-dbid-25240efd-9b9a-4c38-baf9-41631f48e537")}catch{}})();const ne=j({__name:"ApiKeys",setup(r){const i=C(null),d=[{key:"name",label:e.translate("i18n_apikeysview_field_name")}],o=R(),f=new E;async function w(){return o.organizationId!=null?o.organizationId:(await N.get(o.projectId)).organizationId}const{loading:b,result:v,refetch:c}=B(async()=>{const a=await w(),[n,m]=await Promise.all([p.list(o.projectId),f.list(a)]);return n.map(u=>({apiKey:u,member:m.find(I=>I.authorId===u.ownerId)}))}),g=async a=>{const n=await p.create({projectId:o.projectId,name:a.name});c(),i.value=n.value},k=A(()=>({columns:[{title:e.translate("i18n_apikeysview_column_name")},{title:e.translate("i18n_apikeysview_column_creation_date")},{title:e.translate("i18n_apikeysview_column_owner")},{title:"",align:"right"}],rows:v.value?.map(({apiKey:a,member:n})=>({key:a.id,cells:[{type:"text",text:a.name},{type:"text",text:D(a.createdAt)},{type:"text",text:n?.email??e.translate("i18n_apikeysview_owner_unknown")},{type:"actions",actions:[{label:e.translate("i18n_apikeysview_action_delete"),icon:P,dangerous:!0,onClick:async()=>{await p.delete(o.projectId,a.id),c()}}]}]}))??[]}));return(a,n)=>(M(),z(V,null,[s(x,{"entity-name":t(e).translate("i18n_apikeysview_entity_name"),"create-button-text":t(e).translate("i18n_apikeysview_create_button"),loading:t(b),title:t(e).translate("i18n_apikeysview_title"),description:t(e).translate("i18n_apikeysview_description"),"empty-title":t(e).translate("i18n_apikeysview_empty_title"),table:k.value,fields:d,create:g},null,8,["entity-name","create-button-text","loading","title","description","empty-title","table"]),s(t(h),{open:!!i.value,title:t(e).translate("i18n_apikeysview_modal_title"),onCancel:n[0]||(n[0]=m=>i.value=null)},{footer:l(()=>[...n[1]||(n[1]=[])]),default:l(()=>[s(t(S),null,{default:l(()=>[_(y(t(e).translate("i18n_apikeysview_modal_description")),1)]),_:1}),s(t(T),{code:"",copyable:""},{default:l(()=>[_(y(i.value),1)]),_:1})]),_:1},8,["open","title"])],64))}});export{ne as default};
//# sourceMappingURL=ApiKeys-C-5GhvQD.js.map
