import{aL as c,r as n,c as h,aD as k,bw as f,bC as b,j as e,L as g,bE as j,s as o,e as r,aK as A,af as S,ag as C,aG as I,bD as P}from"./index-dP1W1_bd.js";import{c as L,d as w}from"./scope.selectors-C6FB6Cbj.js";import{A as E}from"./ApiForm-CdjbKaUS.js";const K=()=>{const l=c(L),p=c(w),[d,u]=n.useState(""),[x,t]=h(),s=k(),i=f();b(P.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(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:C.warning})})]}),e.jsx(I,{mb:"15px",ml:"-12px",intent:"inline",alignSelf:"flex-start",onClick:()=>i(o.account.api.list),children:"⇽ all API keys"}),e.jsx(E,{isLoading:l,onSubmit:y})]})};export{K as default};
