import{bo as w,r as c,f as i,c as x,i as _,de as j,bP as f,d as C,bQ as b,s as D,t as y,bI as E,bJ as m,bx as L,by as T,j as e,D as v,W as k,a as o,aJ as d,L as g,c5 as A,bX as S}from"./index-_eM6l4Nf.js";import{s as M,a as N,b as K}from"./scope.selectors-C6FB6Cbj.js";const W={td:{whiteSpace:"nowrap",textAlign:"left",pr:0},"td:nth-of-type(1)":{pl:"20px"},"td:nth-of-type(6)":{pr:"20px",svg:{fontSize:"14px"}},">table>tbody>tr:first-of-type":{mb:"0px"}},R=(t,n)=>{const s=w(),a=c.useMemo(()=>t.map(({scope:r})=>[i,n.length===r.length?x:i,i,x,x,_]),[t,n]),p=c.useMemo(()=>t.map(({name:r,scope:l,prefix:h,created:u,modified:I})=>[{children:j(r,20)},{...l.length===n.length?{children:"full scope",gray:!0}:{children:j(l.map(P=>P.toLowerCase()).join(", "),65)}},{children:h},{gray:!0,children:f(new Date(u),b.DATE_TIME.DATE)},{gray:!0,children:f(new Date(I),b.DATE_TIME.DATE)},{intent:"ghost",icon:C.edit,tooltip:"Edit",onClick:()=>s(D(y.account.api.edit,"",{name:r}))}]),[t,s,n]);return c.useMemo(()=>[a,p],[a,p])},z=c.memo(S),q=()=>{const t=E(),n=m(M),s=m(N).sort((h,u)=>h.name.localeCompare(u.name));L(T.api);const a=w(),p=m(K),[r,l]=R(s,n);return c.useEffect(()=>{t.api.fetch(),t.scope.fetch()},[t]),p?e.jsx(v,{}):s.length?e.jsxs(e.Fragment,{children:[e.jsxs(k,{width:"1000px",title:"API keys",contentProps:{pb:0,overflow:"auto"},actions:e.jsx(d,{href:A("/user_guides/projects/api_key/create_api_key/"),external:!0,target:"_blank",p:0,intent:"inline",children:"documentation↗"}),children:[e.jsxs(o,{mb:"25x",children:[e.jsxs(o,{width:"100%",children:[e.jsx(i,{primary:!0,children:s.length}),e.jsx(i,{ml:"5px",children:s.length>1?" API keys":" API key"})]}),e.jsx(d,{minWidth:"105px",onClick:()=>a(y.account.api.create),children:"New API key"})]}),e.jsx(g,{mt:"20px",mx:"-20px",sx:W,children:e.jsx(z,{legend:["name","scope","API key prefix","creation","modification"],middleColumn:1,groupComponents:r,groupProps:l})})]}),e.jsx(g,{sx:{height:"20px",width:"100%",backgroundColor:"grayShade3",opacity:0},children:"invisible block margin"})]}):e.jsxs(k,{title:"API keys",actions:e.jsx(d,{href:A("/user_guides/projects/api_key/create_api_key/"),target:"_blank",external:!0,p:0,intent:"inline",children:"documentation↗"}),children:[e.jsxs(o,{mb:"25x",children:[e.jsxs(o,{width:"100%",children:[e.jsx(i,{primary:!0,children:"0"}),e.jsx(i,{ml:"5px",children:"API keys"})]}),e.jsx(d,{minWidth:"105px",onClick:()=>a(y.account.api.create),children:"New API key"})]}),e.jsx(g,{mt:"20px",mx:"-20px",children:e.jsx(o,{height:"50px",mt:"30px",justifyContent:"center",children:e.jsx(x,{fontSize:"18px",gray:!0,children:"No API keys defined"})})})]})};export{q as default};
