import{r as a,j as e}from"./vendor-react-wBh_31cN.js";import{C as y}from"./code-BwgxKro-.js";import{aq as g,G as h,r as j}from"./index-dNe6i2rS.js";import{C as v,c as A}from"./card-BeQtvmcJ.js";import{u as r,j as k}from"./vendor-redux-CJZrIb6x.js";import{s as C,c as S,d as b}from"./scope.selectors-C6FB6Cbj.js";import{u as K}from"./useDebounce-BiuGz9t2.js";import{u as L}from"./vendor-router-D1GqFWiT.js";import"./vendor-icons-BUUmD6ht.js";import"./vendor-utils-OeoE2qq_.js";import"./vendor-radix-BRyWS4bQ.js";import"./vendor-grid-CeFlDWv4.js";const N=()=>Math.random().toString(32),E=()=>{const[s,i]=a.useState(),t=r(C),p=r(S),m=r(b),o=k(),[l,u]=a.useState(!0);return a.useEffect(()=>{o.scope.fetch()},[o.scope]),a.useEffect(()=>{async function x(){var c,d;const f={name:`default_apiKey_${N().substring(5)}`,scope:t},n=await o.api.create({data:f});(c=n.data)!=null&&c.key&&i((d=n.data)==null?void 0:d.key)}t&&t.length>0&&x()},[o.api,t]),K(p||m,100,u),{apiKey:s,isLoading:l}},$=()=>{const{apiKey:s,isLoading:i}=E(),t=L();return i?e.jsx(g,{}):e.jsxs("div",{className:"flex flex-col w-[830px] mt-[140px]",children:[e.jsx("h1",{className:"text-lg font-bold text-center",children:"Save your Api key"}),e.jsx("div",{className:"mt-10",children:e.jsx(v,{children:e.jsxs(A,{children:[s&&e.jsx("span",{className:"text-xs font-medium mb-5 block",children:"Copy this API key and paste it directly in your code to connect to Hopsworks"}),e.jsx("div",{children:s?e.jsx(y,{copyButton:!0,title:"API key",language:"shell",content:s}):e.jsxs("div",{className:"rounded-md border border-destructive bg-destructive/10 p-3 text-sm text-destructive",children:["Failed to generate Api key",e.jsx(h,{variant:"outline",size:"sm",className:"ml-2",onClick:()=>t(j.account.api.list),children:"Go to Api keys"})]})})]})})})]})};export{$ as default};
