import{a as x,j as e,b as u,c as y,R as c,B as p,r as g}from"./index-C-gKvEDq.js";import{P as j}from"./page-header--nE6NVdA.js";import{S as l}from"./stats-card-Bu-NuPUd.js";import{D as h}from"./data-table-1lm2JMeq.js";import{D as r}from"./data-table-column-header-CHnvH8B_.js";import{f as t,a as _}from"./format-DcyqLq2i.js";import{E as f}from"./eye-CPt1Lma-.js";import{a as v,b as N}from"./use-payer-aging-DO5f8MeY.js";import{I as A}from"./input-B9yFYvyi.js";import{L as C}from"./label-B3YRGmn1.js";import{L as D}from"./loader-circle-MiR2w4nF.js";import"./command-CyAetjD5.js";import"./separator-Cnu0xg_i.js";import"./chevrons-up-down-BLR0y9k5.js";import"./eye-off-C4jQEr1z.js";function P({report:s,onExport:d}){const i=x(),n=[{accessorKey:"payer_code",header:({column:a})=>e.jsx(r,{column:a,title:"Code"})},{accessorKey:"payer_name",header:({column:a})=>e.jsx(r,{column:a,title:"Payer"}),cell:({row:a})=>e.jsx("button",{onClick:()=>i(c.PAYER_AGING_DETAIL.replace(":payerId",a.original.payer_id)),className:"text-blue-600 hover:text-blue-800 hover:underline text-left",children:a.original.payer_name})},{accessorKey:"current",header:({column:a})=>e.jsx(r,{column:a,title:"Current",className:"justify-end"}),cell:({row:a})=>e.jsx("div",{className:"text-right",children:t(a.original.current)})},{accessorKey:"days_31_60",header:({column:a})=>e.jsx(r,{column:a,title:"31-60 Days",className:"justify-end"}),cell:({row:a})=>e.jsx("div",{className:"text-right",children:t(a.original.days_31_60)})},{accessorKey:"days_61_90",header:({column:a})=>e.jsx(r,{column:a,title:"61-90 Days",className:"justify-end"}),cell:({row:a})=>e.jsx("div",{className:"text-right",children:t(a.original.days_61_90)})},{accessorKey:"days_91_120",header:({column:a})=>e.jsx(r,{column:a,title:"91-120 Days",className:"justify-end"}),cell:({row:a})=>e.jsx("div",{className:"text-right",children:t(a.original.days_91_120)})},{accessorKey:"days_121_plus",header:({column:a})=>e.jsx(r,{column:a,title:"121+ Days",className:"justify-end"}),cell:({row:a})=>e.jsx("div",{className:"text-right",children:t(a.original.days_121_plus)})},{accessorKey:"total_outstanding",header:({column:a})=>e.jsx(r,{column:a,title:"Total",className:"justify-end"}),cell:({row:a})=>e.jsx("div",{className:"text-right font-bold",children:t(a.original.total_outstanding)})},{id:"actions",header:"Actions",cell:({row:a})=>e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>i(c.PAYER_AGING_DETAIL.replace(":payerId",a.original.payer_id)),children:e.jsx(f,{className:"h-4 w-4"})})}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(l,{title:"Total Outstanding",value:t(s.summary.total_outstanding)}),e.jsx(l,{title:"Current",value:t(s.summary.total_current),description:`${s.summary.percentage_current.toFixed(1)}%`}),e.jsx(l,{title:"Overdue",value:t(s.summary.total_overdue),valueClassName:"text-red-600",description:`${s.summary.percentage_overdue.toFixed(1)}%`}),e.jsx(l,{title:"Total Payers",value:s.summary.total_payers})]}),e.jsx(u,{children:e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs("div",{children:[e.jsx(y,{children:"Payer Aging Report"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["As of ",_(s.as_of_date)]})]})})}),e.jsx(h,{columns:n,data:s.lines,searchableColumns:[{id:"payer_name",title:"Payer"},{id:"payer_code",title:"Code"}]})]})}function Y(){const[s,d]=g.useState(new Date().toISOString().split("T")[0]),{data:i,isLoading:n}=v({as_of_date:s}),a=N();if(n)return e.jsx("div",{className:"flex items-center justify-center h-96",children:e.jsx(D,{className:"h-8 w-8 animate-spin"})});if(!i)return e.jsx("div",{children:"No data available"});const m=o=>{a.mutate({format:o,filters:{as_of_date:s}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(j,{title:"Payer Aging Report",description:"Insurance payer aging analysis"}),e.jsx("div",{className:"flex items-end gap-4",children:e.jsxs("div",{className:"w-64",children:[e.jsx(C,{children:"As of Date"}),e.jsx(A,{type:"date",value:s,onChange:o=>d(o.target.value)})]})}),e.jsx(P,{report:i,onExport:m})]})}export{Y as PayerAgingReportPage};
