import{bK as c,r as n,w as m,bI as h,bp as k,bx as f,j as e,L as g,bA as j,s as o,d as r,c_ as A,ah as S,ai as I,b4 as P,by as w}from"./index-C1DmWO_C.js";import{c as C,d as L}from"./scope.selectors-C6FB6Cbj.js";import{A as v}from"./ApiForm-BwB4nygF.js";const O=()=>{const l=c(C),p=c(L),[d,u]=n.useState(""),[x,t]=m(),s=h(),i=k();f(w.createAPI),n.useEffect(()=>(s.scope.fetch(),()=>{s.api.clear()}),[s]);const y=n.useCallback(async b=>{const{data:a}=await s.api.create({data:b});a!=null&&a.key&&(u(a.key),t())},[s,t]);return p?e.jsx(g,{}):e.jsxs(e.Fragment,{children:[e.jsxs(j,{title:"Save the key",secondaryText:"Your API key has been generated.",isOpen:x,onClose:t,closeOnBackdropClick:!1,secondaryButtonProps:{children:"I saved the API key",onClick:()=>i(o.account.api.list)},closeOnEsc:!1,children:[e.jsx(r,{sx:{wordBreak:"break-all"},children:e.jsx(A,{copyButton:!0,content:d,title:"API key"})}),e.jsx(r,{my:"20px",children:e.jsx(S,{content:"Save this API key securely. It will not be accessible afterwards.",type:I.warning})})]}),e.jsx(P,{mb:"15px",ml:"-12px",intent:"inline",alignSelf:"flex-start",onClick:()=>i(o.account.api.list),children:"⇽ all API keys"}),e.jsx(v,{isLoading:l,onSubmit:y})]})};export{O as default};
