import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{a as t,o as n}from"./vendor-motion-COLzAB1Q.js";import{_ as r,c as i,r as a}from"./index-DLFWvoW-.js";import{t as o}from"./format-CdfzwC5x.js";import{t as s}from"./activity-log-BcZldPH3.js";var c=e(n(),1),l=t(),u=()=>{let[e,t]=(0,c.useState)([]),[n,u]=(0,c.useState)(!0),[d,f]=(0,c.useState)(null),p=async()=>{u(!0);let{data:e,error:n}=await i.from(`contact_inquiries`).select(`*`).order(`created_at`,{ascending:!1});n?r.error(`Failed to load inquiries`):t(e||[]),u(!1)};(0,c.useEffect)(()=>{p()},[]);let m=async n=>{let a=e.find(e=>e.id===n);await i.from(`contact_inquiries`).delete().eq(`id`,n),t(e=>e.filter(e=>e.id!==n)),d?.id===n&&f(null),s(`inquiry_deleted`,{name:a?.name,email:a?.email}),r.success(`Deleted`)};return n?(0,l.jsx)(`div`,{className:`text-muted-foreground py-20 text-center`,children:`Loading...`}):(0,l.jsxs)(`div`,{className:`space-y-6`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Contact Inquiries`}),(0,l.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:[e.length,` total`]})]}),(0,l.jsx)(a,{variant:`outline`,size:`sm`,onClick:p,children:`Refresh`})]}),e.length===0?(0,l.jsx)(`div`,{className:`text-center py-20 border border-dashed border-border rounded-xl text-muted-foreground`,children:`No inquiries yet`}):(0,l.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-6`,children:[(0,l.jsx)(`div`,{className:`space-y-2 max-h-[70vh] overflow-y-auto pr-2`,children:e.map(e=>(0,l.jsxs)(`button`,{onClick:()=>f(e),className:`w-full text-left p-4 rounded-xl border transition-all ${d?.id===e.id?`border-primary/50 bg-card`:`border-border bg-card/50 hover:bg-card`}`,children:[(0,l.jsx)(`div`,{className:`font-medium text-sm text-foreground truncate`,children:e.name}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground truncate mt-0.5`,children:e.email}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2 line-clamp-2`,children:e.message}),(0,l.jsx)(`div`,{className:`text-[10px] text-muted-foreground/60 mt-2`,children:o(new Date(e.created_at),`MMM d, yyyy`)})]},e.id))}),(0,l.jsx)(`div`,{className:`lg:col-span-2`,children:d?(0,l.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-6 space-y-6`,children:[(0,l.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-lg font-bold text-foreground`,children:d.name}),(0,l.jsx)(`a`,{href:`mailto:${d.email}`,className:`text-sm text-primary hover:underline`,children:d.email}),d.company&&(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:d.company})]}),(0,l.jsx)(a,{variant:`destructive`,size:`sm`,onClick:()=>m(d.id),children:`Delete`})]}),(0,l.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:`Message`}),(0,l.jsx)(`p`,{className:`text-foreground whitespace-pre-wrap leading-relaxed`,children:d.message})]}),(0,l.jsx)(`div`,{className:`border-t border-border pt-3`,children:(0,l.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Received `,o(new Date(d.created_at),`MMMM d, yyyy 'at' h:mm a`)]})})]}):(0,l.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-20 text-center text-muted-foreground`,children:`Select an inquiry to view details`})})]})]})};export{u as default};