import{b3 as o,r as n,P as m,b1 as f,aS as k,aY as b,j as e,a$ as S,b0 as g,b as c,o as r,cR as j,a3 as P,a4 as A,aU as I,aZ as C}from"./index-ea7817a2.js";import{c as v,d as w}from"./scope.selectors-1aab3a9c.js";import{A as L}from"./ApiForm-94bf12df.js";const K=()=>{const l=o(v),p=o(w),[u,d]=n.useState(""),[x,t]=m(),s=f(),i=k();b(C.createAPI),n.useEffect(()=>(s.scope.fetch(),()=>{s.api.clear()}),[s]);const y=n.useCallback(async h=>{const{data:a}=await s.api.create({data:h});a!=null&&a.key&&(d(a.key),t())},[s,t]);return p?e.jsx(S,{}):e.jsxs(e.Fragment,{children:[e.jsxs(g,{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(c.account.api.list)},closeOnEsc:!1,children:[e.jsx(r,{sx:{wordBreak:"break-all"},children:e.jsx(j,{copyButton:!0,content:u,title:"API key"})}),e.jsx(r,{my:"20px",children:e.jsx(P,{content:"Save this API key preciously. It won’t be accessible afterwards",type:A.warning})})]}),e.jsx(I,{mb:"15px",ml:"-12px",intent:"inline",alignSelf:"flex-start",onClick:()=>i(c.account.api.list),children:"⇽ all API keys"}),e.jsx(L,{isLoading:l,onSubmit:y})]})};export{K as default};
