import{g as e}from"./vendor-react-Dzc9WstK.js";import{t}from"./DataTable-Dc5x7VxX.js";import{t as n}from"./arrow-right-BvVjz62x.js";import{_ as r}from"./vendor-flow-IzlrcDx6.js";import{Bn as i}from"./index-HkVQGc9M.js";import{r as a,t as o}from"./format-DOnLYpxL.js";import{t as s}from"./StatusBadge-D6eiAqxN.js";import{t as c}from"./useMasterTable-CIy11KIN.js";import{D as l,n as u,t as d}from"./PricingShell-B3nPyLDu.js";var f=r();function p(e){switch(e.field_changed){case`cost_price`:return`Cost price`;case`mrp`:return`MRP`;case`price`:return e.customer_type_name?`Selling price · ${e.customer_type_name}`:`Selling price`;case`status`:return`Status`;default:return e.field_changed}}function m(){let r=e(),u=c(),{data:d,isLoading:m,isFetching:h}=l(u.params),g=[{accessorKey:`changed_at`,header:`When`,cell:({row:e})=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`p`,{className:`text-[var(--color-text-secondary)]`,children:a(e.original.changed_at)}),(0,f.jsx)(`p`,{className:`text-[11px] text-[var(--color-text-muted)]`,children:e.original.change_type_display})]})},{id:`product`,header:`Product`,enableSorting:!1,cell:({row:e})=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`p`,{className:`font-medium text-[var(--color-text-primary)]`,children:e.original.product_name||`—`}),e.original.product_code&&(0,f.jsx)(`p`,{className:`font-mono text-[11px] text-[var(--color-text-muted)]`,children:e.original.product_code}),e.original.rate_card_name&&(0,f.jsx)(`p`,{className:`text-[11px] text-[var(--color-text-muted)]`,children:e.original.rate_card_name})]})},{id:`field`,header:`Changed`,enableSorting:!1,cell:({row:e})=>(0,f.jsx)(`span`,{className:`text-[var(--color-text-secondary)]`,children:p(e.original)})},{id:`change`,header:`Old → New`,enableSorting:!1,cell:({row:e})=>{let t=e.original,r=t.field_changed!==`status`,i=e=>e==null||e===``?`—`:r?o(e):e;return(0,f.jsxs)(`div`,{className:`flex items-center gap-1.5 tabular-nums`,children:[(0,f.jsx)(`span`,{className:`text-[var(--color-text-muted)] line-through`,children:i(t.old_value)}),(0,f.jsx)(n,{className:`h-3 w-3 text-[var(--color-text-muted)]`}),(0,f.jsx)(`span`,{className:`font-medium text-[var(--color-text-primary)]`,children:i(t.new_value)})]})}},{accessorKey:`changed_by_name`,header:`By`,cell:({getValue:e})=>(0,f.jsx)(`span`,{className:`text-[var(--color-text-secondary)]`,children:e()||`System`})},{id:`batch`,header:`Batch`,enableSorting:!1,cell:({row:e})=>e.original.batch?(0,f.jsxs)(`button`,{type:`button`,onClick:()=>r(`/admin/pricing/batches/${e.original.batch}`),className:`inline-flex items-center gap-1 text-[12px] font-medium text-[var(--color-accent-ink)] hover:underline`,children:[`View batch `,(0,f.jsx)(i,{className:`h-3 w-3`})]}):(0,f.jsx)(s,{label:`Manual`,variant:`default`})}],_=d?.count??0;return(0,f.jsx)(t,{columns:g,data:d?.results??[],isLoading:m,isFetching:h,searchable:!0,searchPlaceholder:`Search by product…`,onSearch:u.onSearch,totalItems:_,currentPage:u.page,pageSize:u.pageSize,totalPages:u.totalPages(_),onPageChange:u.onPageChange,emptyTitle:`No price changes yet`,emptyDescription:`Every edit to a cost, MRP, selling price or card status is recorded here — who changed it, from what to what, and which batch (if any) it belonged to.`})}function h(){return(0,f.jsx)(d,{children:(0,f.jsx)(u,{children:(0,f.jsx)(m,{})})})}export{h as default};