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