import{G as e,Q as t,et as n,i as r,nt as i,r as a,st as o,ut as s}from"./branding-ClCX8iZg.js";import{t as c}from"./plus-BXvgCskW.js";import{t as l}from"./trash-2-D1mEG7Sg.js";import{t as u}from"./HeaderApp-HWu4NOgP.js";import{t as d}from"./use-document-meta-Br4UMxjt.js";import{t as f}from"./badge-Bq1S7Q7P.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./table-ziljfcNR.js";import{t as y}from"./api-toast-BFyXHsNH.js";import{n as b}from"./actions-DUZCaIbF.js";var x=s(o(),1),S=r();async function C(){return{apiKeys:(await e.get(`/api-keys`)).data}}var w={workflows_read:`Workflows Read`,runs_read:`Runs Read`,runs_write:`Runs Write`,runs_manage:`Runs Manage`,stats_read:`Stats Read`,admin:`Admin`};function T(e){return new Date(e).toLocaleDateString(`fr-FR`,{day:`2-digit`,month:`short`,year:`numeric`})}function E(){let{apiKeys:e}=t(),r=n(),o=i(),[s,C]=(0,x.useState)(null);d({title:`API Keys`,description:`Manage your API keys for programmatic access.`});function E(e,t){C(e),y(b(e),{loading:`Deleting ${t}...`,success:`${t} deleted`}).then(()=>o.revalidate()).catch(()=>{}).finally(()=>C(null))}return(0,S.jsx)(u,{title:`API Keys`,description:`Manage your API keys for programmatic access.`,titleItem:(0,S.jsxs)(a,{onClick:()=>r(`/api-keys/new`),children:[(0,S.jsx)(c,{className:`h-4 w-4 mr-1`}),`New API Key`]}),children:(0,S.jsx)(`div`,{className:`space-y-6`,children:e.length===0?(0,S.jsx)(`div`,{className:`text-center py-16 text-muted-foreground border rounded-lg bg-muted/20`,children:`No API keys yet. Create one to get started.`}):(0,S.jsx)(`div`,{className:`rounded-lg border`,children:(0,S.jsxs)(v,{children:[(0,S.jsx)(p,{children:(0,S.jsxs)(g,{children:[(0,S.jsx)(m,{children:`Name`}),(0,S.jsx)(m,{children:`Prefix`}),(0,S.jsx)(m,{children:`Scopes`}),(0,S.jsx)(m,{children:`Status`}),(0,S.jsx)(m,{children:`Last Used`}),(0,S.jsx)(m,{children:`Created`}),(0,S.jsx)(m,{className:`w-12`})]})}),(0,S.jsx)(h,{children:e.map(e=>(0,S.jsxs)(g,{children:[(0,S.jsx)(_,{className:`font-medium`,children:e.name}),(0,S.jsx)(_,{children:(0,S.jsxs)(`code`,{className:`text-xs bg-muted px-1.5 py-0.5 rounded`,children:[e.key_prefix,`...`]})}),(0,S.jsx)(_,{children:(0,S.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.scopes.map(e=>(0,S.jsx)(f,{variant:`outline`,className:`text-xs`,children:w[e]??e},e))})}),(0,S.jsx)(_,{children:e.is_active?(0,S.jsx)(f,{variant:`default`,className:`bg-green-500/10 text-green-700 border-green-500/20`,children:`Active`}):(0,S.jsx)(f,{variant:`secondary`,children:`Disabled`})}),(0,S.jsx)(_,{className:`text-sm text-muted-foreground`,children:e.last_used_at?T(e.last_used_at):`Never`}),(0,S.jsx)(_,{className:`text-sm text-muted-foreground`,children:T(e.created_at)}),(0,S.jsx)(_,{children:(0,S.jsx)(a,{variant:`ghost`,size:`icon-sm`,onClick:()=>E(e.id,e.name),disabled:s===e.id,children:(0,S.jsx)(l,{className:`h-4 w-4 text-destructive`})})})]},e.id))})]})})})})}export{E as Component,C as loader};