import{bJ as c,bg as f,r as o,y as g,bI as y,bo as S,bx as A,by as h,j as e,D as j,t as r,aJ as L}from"./index-_eM6l4Nf.js";import{c as k,d as C}from"./scope.selectors-C6FB6Cbj.js";import{A as K}from"./ApiForm-iedxqiR1.js";import{A as P}from"./ApiKeyPopup-BTOgMDpW.js";const J=()=>{const p=c(k),l=c(C),{state:a={}}=f(),[u,m]=o.useState(""),[d,i]=g(),s=y(),n=S();A(h.createAPI),o.useEffect(()=>(s.scope.fetch(),()=>{s.api.clear()}),[s]);const x=o.useCallback(async b=>{const{data:t}=await s.api.create({data:b});t!=null&&t.key&&(m(t.key),i())},[s,i]);return l?e.jsx(j,{}):e.jsxs(e.Fragment,{children:[e.jsx(P,{isOpen:d,onClose:i,onSave:()=>n((a==null?void 0:a.redirectUrl)??r.account.api.list),createdKey:u}),e.jsx(L,{mb:"15px",ml:"-12px",intent:"inline",alignSelf:"flex-start",onClick:()=>n(r.account.api.list),children:"⇽ all API keys"}),e.jsx(K,{isLoading:p,onSubmit:x})]})};export{J as default};
