import{b as y,c as T,d as c,e as v}from"/build/_shared/chunk-XN75JBKL.js";import{a as Y}from"/build/_shared/chunk-4GQGFAPU.js";import{a as E,b as k,c as I,d as A,e as K,f}from"/build/_shared/chunk-EBHCYYOH.js";import{M as D,m as R,n as g,u as w}from"/build/_shared/chunk-FXRQ2H3S.js";import{a as P,b}from"/build/_shared/chunk-JSLPGHFC.js";import{B as V,C as i,e as u}from"/build/_shared/chunk-XIQ3C74K.js";import{a as h}from"/build/_shared/chunk-LR6G3KVW.js";import{d as t}from"/build/_shared/chunk-G5WX4PPA.js";var x=t(Y(),1),W=["Development","Production"],_=o=>x.default.sortBy(o,[n=>{let p=W.indexOf(n.environment.name);return p===-1?W.length:p},"name"]);V();var l=t(i(),1),N=({apiKey:o})=>{let[n,p]=P(),d=()=>p(o),m=n.value===o;return(0,l.jsx)(y,{delayDuration:0,children:(0,l.jsxs)(T,{children:[(0,l.jsx)(c,{asChild:!0,children:(0,l.jsx)(m?R:g,{size:20,className:"cursor-pointer hover:scale-110",onClick:d})}),(0,l.jsx)(v,{children:(0,l.jsx)("p",{children:m?"Copied!":"Copy API Key"})})]})})};var a=t(i(),1),H=({onClick:o})=>(0,a.jsx)(y,{delayDuration:0,children:(0,a.jsxs)(T,{children:[(0,a.jsx)(c,{asChild:!0,children:(0,a.jsx)(w,{size:20,className:"cursor-pointer hover:scale-110",onClick:o})}),(0,a.jsx)(v,{children:(0,a.jsx)("p",{children:"You can only reveal once."})})]})});var s=t(i(),1),B=({handleRotate:o})=>(0,s.jsx)(y,{delayDuration:0,children:(0,s.jsxs)(T,{children:[(0,s.jsx)(c,{asChild:!0,children:(0,s.jsx)(D,{size:20,className:"cursor-pointer hover:scale-110",onClick:o})}),(0,s.jsx)(v,{children:(0,s.jsx)("p",{children:"Rotate"})})]})});var e=t(i(),1),F=({apiKey:o,projectId:n})=>{let p=u(),d=b(),m=b(),C=m.data?.key?void 0:d.data?.key,O=p.envId===o.envId,z=()=>{d.state==="idle"&&(d.submit(null,{method:"POST",action:h.actions.apiKeys.reveal({projectId:n,apiKeyId:o.id})}),m.reset())},S=()=>{m.state==="idle"&&(m.submit(null,{method:"POST",action:h.actions.apiKeys.rotate({projectId:n,apiKeyId:o.id})}),d.reset())};return(0,e.jsxs)(A,{children:[(0,e.jsxs)(f,{className:"font-medium",children:[O&&"\u{1F7E2}"," ",o.environment.name]}),(0,e.jsx)(f,{children:(0,e.jsx)("div",{className:"min-w-80",children:C||o.key})}),(0,e.jsx)(f,{children:(0,e.jsxs)("div",{className:"flex w-14 justify-between gap-1",children:[(0,e.jsx)("div",{children:C?(0,e.jsx)(N,{apiKey:C}):!o.viewed&&(0,e.jsx)(H,{onClick:z})}),(0,e.jsx)(B,{handleRotate:S})]})})]},o.envId)};var r=t(i(),1),mo=({sortedEnvironments:o,projectId:n})=>(0,r.jsxs)(E,{children:[(0,r.jsx)(k,{children:(0,r.jsxs)(A,{children:[(0,r.jsx)(K,{children:"Environment"}),(0,r.jsx)(K,{children:"API Key"}),(0,r.jsx)(K,{children:"Actions"})]})}),(0,r.jsx)(I,{children:o.map(p=>(0,r.jsx)(F,{apiKey:p,projectId:n},p.id))})]});export{mo as a,_ as b};
