import{G as e,Q as t,et as n,i as r,nt as i,r as a}from"./branding-ClCX8iZg.js";import{t as o}from"./createLucideIcon-Bj0ivoOU.js";import{t as s}from"./plus-BXvgCskW.js";import{t as c}from"./shield-CGWs7KvF.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,r as x}from"./actions-HfS_qx7k.js";var S=o(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),C=r();async function w(){return{users:(await e.get(`/users?page=1&per_page=100`)).data}}function T(e){return new Date(e).toLocaleDateString(`fr-FR`,{day:`2-digit`,month:`short`,year:`numeric`})}function E(){d({title:`Users`});let{users:e}=t(),r=n(),o=i(),w=(e,t)=>{confirm(`Delete user "${t}"? This cannot be undone.`)&&y(b(e),{loading:`Deleting user...`,success:`User deleted`,error:`Failed to delete user`}).then(()=>o.revalidate()).catch(()=>{})},E=(e,t)=>{let n=t?`demote`:`promote`;y(x(e,!t),{loading:`${n===`promote`?`Promoting`:`Demoting`} user...`,success:`User ${n}d`,error:`Failed to ${n} user`}).then(()=>o.revalidate()).catch(()=>{})};return(0,C.jsx)(u,{title:`Users`,description:`Manage user accounts and roles.`,titleItem:(0,C.jsxs)(a,{onClick:()=>r(`/users/new`),children:[(0,C.jsx)(s,{className:`h-4 w-4 mr-1`}),`New User`]}),children:(0,C.jsx)(`div`,{className:`space-y-6`,children:e.length===0?(0,C.jsx)(`div`,{className:`text-center py-16 text-muted-foreground border rounded-lg bg-muted/20`,children:`No users yet. Create one to get started.`}):(0,C.jsx)(`div`,{className:`rounded-lg border`,children:(0,C.jsxs)(v,{children:[(0,C.jsx)(p,{children:(0,C.jsxs)(g,{children:[(0,C.jsx)(m,{children:`Username`}),(0,C.jsx)(m,{children:`Email`}),(0,C.jsx)(m,{children:`Role`}),(0,C.jsx)(m,{children:`Created`}),(0,C.jsx)(m,{className:`w-12`})]})}),(0,C.jsx)(h,{children:e.map(e=>(0,C.jsxs)(g,{children:[(0,C.jsx)(_,{className:`font-medium`,children:e.username}),(0,C.jsx)(_,{children:e.email}),(0,C.jsx)(_,{children:(0,C.jsx)(f,{variant:e.is_admin?`default`:`secondary`,children:e.is_admin?`Admin`:`Member`})}),(0,C.jsx)(_,{children:T(e.created_at)}),(0,C.jsx)(_,{children:(0,C.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,C.jsx)(a,{variant:`ghost`,size:`icon-sm`,onClick:()=>E(e.id,e.is_admin),title:e.is_admin?`Demote to member`:`Promote to admin`,children:e.is_admin?(0,C.jsx)(S,{className:`h-4 w-4`}):(0,C.jsx)(c,{className:`h-4 w-4`})}),(0,C.jsx)(a,{variant:`ghost`,size:`icon-sm`,onClick:()=>w(e.id,e.username),children:(0,C.jsx)(l,{className:`h-4 w-4 text-destructive`})})]})})]},e.id))})]})})})})}export{E as Component,w as loader};