import{bX as c,bp as b,r as o,w as g,bW as S,bx as y,bG as A,bH as h,j as e,L as j,x as r,aJ as L}from"./index-DNBEEyYo.js";import{c as k,d as C}from"./scope.selectors-C6FB6Cbj.js";import{A as P}from"./ApiForm-Boe5ApZi.js";import{A as K}from"./ApiKeyPopup-Cak7j3t0.js";const I=()=>{const p=c(k),l=c(C),{state:t={}}=b(),[u,m]=o.useState(""),[d,i]=g(),s=S(),n=y();A(h.createAPI),o.useEffect(()=>(s.scope.fetch(),()=>{s.api.clear()}),[s]);const x=o.useCallback(async f=>{const{data:a}=await s.api.create({data:f});a!=null&&a.key&&(m(a.key),i())},[s,i]);return l?e.jsx(j,{}):e.jsxs(e.Fragment,{children:[e.jsx(K,{isOpen:d,onClose:i,onSave:()=>n((t==null?void 0:t.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(P,{isLoading:p,onSubmit:x})]})};export{I as default};
