import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t}from"./vendor-forms-yQg41KHz.js";import{r as n,t as r}from"./vendor-react-CAGJwf-T.js";import{t as i}from"./arrow-right-lxz0iUkq.js";import{t as a}from"./lock-DKmpnp8M.js";import{t as o}from"./shield-check-CSfhCgyL.js";import{t as s}from"./trending-up-_gu3scpr.js";import{t as c}from"./users-CYR7ECMV.js";import{Pt as l,S as u,T as d,Tt as f,it as p,lt as m,o as h,xt as g}from"./index-Z_bdWDpJ.js";import{t as _}from"./PageHeader-UI75nV23.js";import{t as v}from"./EmptyState-BuyIB74a.js";import{t as y}from"./Skeleton-0UpX2lan.js";import{t as b}from"./reportsRtkApi-d1Hcrxst.js";var x=e(t(),1),S=r(),C={origination:c,servicing:p,collections:g,masters:f,audit:o,summary:s};function w({group:e,className:t}){let n=C[e]??l;return(0,S.jsx)(n,{className:t})}function T({report:e}){let t=e.columns.some(e=>e.sensitive);return(0,S.jsxs)(n,{to:`/admin/reports/${e.slug}`,className:`group block rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-5 hover:border-[var(--color-primary)] hover:shadow-sm transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-primary)]/40`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between mb-3`,children:[(0,S.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-[var(--color-primary)]/[0.08] text-[var(--color-primary)]`,children:(0,S.jsx)(w,{group:e.group,className:`w-5 h-5`})}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,S.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 text-[var(--color-text-muted)]`,title:`Contains sensitive (masked) columns`,"aria-label":`Contains sensitive masked columns`,children:(0,S.jsx)(a,{className:`w-3 h-3`})}),(0,S.jsx)(u,{variant:e.report_type===`summary`?`warning`:`info`,size:`sm`,children:e.report_type===`summary`?`Summary`:`Detail`})]})]}),(0,S.jsx)(`h3`,{className:`text-[14px] font-semibold text-[var(--color-text-primary)] group-hover:text-[var(--color-primary)] transition-colors`,children:e.title}),e.description&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--color-text-muted)] mt-1 leading-relaxed line-clamp-2`,children:e.description}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1 mt-4 text-[12px] font-medium text-[var(--color-primary)] opacity-0 group-hover:opacity-100 transition-opacity`,children:[`Open report `,(0,S.jsx)(i,{className:`w-3.5 h-3.5`})]})]})}function E(){let{data:e,isLoading:t}=b(),[n,r]=(0,x.useState)(``),i=(0,x.useMemo)(()=>e?.groups??[],[e]),a=(0,x.useMemo)(()=>i.reduce((e,t)=>e+t.reports.length,0),[i]),o=(0,x.useMemo)(()=>{let e=n.trim().toLowerCase();return e?i.map(t=>({...t,reports:t.reports.filter(t=>t.title.toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e))})).filter(e=>e.reports.length>0):i},[i,n]);return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(_,{title:`Reports`,description:t?`Loading the reports catalog…`:`${a} report${a===1?``:`s`} across origination, servicing, summary and audit. Open any report to run, filter, and export.`}),(0,S.jsx)(`div`,{className:`mb-6 max-w-md`,children:(0,S.jsx)(d,{value:n,onChange:e=>r(e.target.value),placeholder:`Search reports by name or description…`,"aria-label":`Search reports`})}),t?(0,S.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:6}).map((e,t)=>(0,S.jsx)(y,{variant:`rect`,height:140},t))}):o.length===0?(0,S.jsx)(v,{icon:m,title:n?`No reports match your search`:`No reports available`,description:n?`Try a different search term, or clear the search to browse all reports.`:`No reports are visible to your role. Ask an administrator to grant access.`}):(0,S.jsx)(`div`,{className:`space-y-8`,children:o.map(e=>(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,S.jsx)(w,{group:e.group,className:`w-4 h-4 text-[var(--color-text-muted)]`}),(0,S.jsx)(`h2`,{className:`text-[13px] font-semibold uppercase tracking-[0.06em] text-[var(--color-text-secondary)]`,children:e.label}),(0,S.jsxs)(`span`,{className:`text-[11px] text-[var(--color-text-muted)]`,children:[`· `,e.reports.length,` report`,e.reports.length===1?``:`s`]})]}),(0,S.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:e.reports.map(e=>(0,S.jsx)(T,{report:e},e.slug))})]},e.group))})]})}function D(){return(0,S.jsx)(h,{module:`reports`,children:(0,S.jsx)(E,{})})}export{D as default};