@machinemetrics/mm-react-components 0.2.3-23 → 0.2.3-24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,7 +54,7 @@ var qe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24
54
54
  *
55
55
  * @license MIT
56
56
  */
57
- function mC(e,t){return e?function(e){return"function"==typeof e&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}(n=e)||"function"==typeof n||function(e){return"object"==typeof e&&"symbol"==typeof e.$$typeof&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}(n)?o.createElement(e,t):e:null;var n}function gC(e,t=[]){return t.length?t:Object.values(e).sort((e,t)=>(e.defaults.order??0)-(t.defaults.order??0)).map(e=>e.defaults.id||e.columnDef.id||"").filter(e=>Boolean(e))}function hC(e,t={}){if(!e)return t;return{...Object.values(e).reduce((e,t)=>{const n=t.defaults.id??t.columnDef.id;return n?(!1===t.defaults.visible&&(e[n]=!1),e):e},{}),...t}}function vC(e={}){const{registry:t,initialSorting:n=[],initialVisibility:r,initialColumnOrder:a,initialPinning:i,initialRowSelection:s}=e,l=o.useMemo(()=>t?gC(t,a):a??[],[t,a]),c=o.useMemo(()=>hC(t,r),[t,r]),[u,d]=o.useState(n),[p,f]=o.useState(c),[m,g]=o.useState(l),[h,v]=o.useState(i??{left:[],right:[]}),[b,y]=o.useState(s??{});return o.useEffect(()=>{l.length&&g(e=>{const t=new Set(e),n=[];l.forEach(e=>{e&&(n.push(e),t.delete(e))});const r=e.filter(e=>t.has(e)),o=n.concat(r);if(o.length!==e.length)return o;for(let a=0;a<o.length;a+=1)if(o[a]!==e[a])return o;return e})},[l]),{sorting:[u,d],columnVisibility:[p,f],columnOrder:[m,g],columnPinning:[h,v],rowSelection:[b,y]}}function bC(e="(max-width: 768px)"){const t=o.useCallback(()=>"undefined"!=typeof window&&window.matchMedia(e).matches,[e]),[n,r]=o.useState(t);return o.useEffect(()=>{const t=window.matchMedia(e),n=e=>r(e.matches);return t.addEventListener("change",n),r(t.matches),()=>t.removeEventListener("change",n)},[e]),n}function yC(e){const{columns:t,data:n,columnRegistry:r,initialState:a,tableId:i,disableGlobalFilter:s,customGlobalFilterFn:l,onRowSelectionChange:c,onSortingChange:u,onPaginationChange:d,onColumnVisibilityChange:p,onColumnOrderChange:f,onBatchAction:m,onRowClick:g,onExportComplete:h}=e,v=i?`mmrc:table:${i}`:void 0,b=o.useMemo(()=>{if(!v)return null;try{const e=localStorage.getItem(v);if(!e)return null;return JSON.parse(e)}catch{return null}},[v]),{sorting:[y,x],columnVisibility:[w,C],columnOrder:[S,k],columnPinning:[j,E],rowSelection:[N,R]}=vC({registry:r,initialSorting:b?.sorting??a?.sorting,initialVisibility:b?.columnVisibility??a?.visibility,initialColumnOrder:b?.columnOrder??a?.columnOrder,initialPinning:a?.columnPinning,initialRowSelection:a?.rowSelection}),D=o.useMemo(()=>{if(!r)return t;const e=Object.entries(r),n=gC(r),o=S.length?S:n,a=new Map(e),i=new Set,s=o.map(e=>{const t=a.get(e);return t?(i.add(e),t.columnDef):null}).filter(Boolean);return e.forEach(([e,t])=>{i.has(e)||s.push(t.columnDef)}),s},[r,t,S]),[M,O]=o.useState(""),[_,P]=o.useState({pageIndex:0,pageSize:25}),T=o.useCallback(e=>{const t="function"==typeof e?e(N):e;if(R(t),c){const e=n.filter((e,n)=>t[n]);c(e,t)}},[N,R,c,n]),A=o.useCallback(e=>{const t="function"==typeof e?e(y):e;x(t),u&&u(t)},[y,x,u]),I=o.useCallback(e=>{const t="function"==typeof e?e(_):e;P(t),d&&d(t.pageIndex,t.pageSize)},[_,P,d]),F=o.useCallback(e=>{const t="function"==typeof e?e(w):e;C(t),p&&p(t)},[w,C,p]),z=o.useCallback(e=>{const t="function"==typeof e?e(S):e;k(t),f&&f(t)},[S,k,f]);o.useEffect(()=>{if(v)try{const e=JSON.stringify({columnOrder:S,columnVisibility:w,sorting:y});localStorage.setItem(v,e)}catch{}},[S,w,y,v]);const L=o.useMemo(()=>s?(e,t,n)=>!0:l||void 0,[s,l]),B=function(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=o.useState(()=>({current:pC(t)})),[r,a]=o.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{a(t),null==e.onStateChange||e.onStateChange(t)}})),n.current}({data:n,columns:D,state:{sorting:y,rowSelection:N,columnVisibility:w,columnOrder:S,globalFilter:M,columnPinning:j,pagination:_},enableRowSelection:!0,enableColumnResizing:!0,enableColumnPinning:!0,enableGlobalFilter:!0,globalFilterFn:L,onRowSelectionChange:T,onSortingChange:A,onColumnVisibilityChange:F,onColumnOrderChange:z,onGlobalFilterChange:O,onColumnPinningChange:E,onPaginationChange:I,getCoreRowModel:e=>jw(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(t,o,a){void 0===o&&(o=0);const i=[];for(let l=0;l<t.length;l++){const c=Ow(e,e._getRowId(t[l],l,a),t[l],l,o,0,null==a?void 0:a.id);var s;n.flatRows.push(c),n.rowsById[c.id]=c,i.push(c),e.options.getSubRows&&(c.originalSubRows=e.options.getSubRows(t[l],l),null!=(s=c.originalSubRows)&&s.length&&(c.subRows=r(c.originalSubRows,o+1,c)))}return i};return n.rows=r(t),n},Ew(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex())),getSortedRowModel:e=>jw(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||null==t||!t.length)return n;const r=e.getState().sorting,o=[],a=r.filter(t=>{var n;return null==(n=e.getColumn(t.id))?void 0:n.getCanSort()}),i={};a.forEach(t=>{const n=e.getColumn(t.id);n&&(i[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});const s=e=>{const t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let r=0;r<a.length;r+=1){var n;const o=a[r],s=i[o.id],l=s.sortUndefined,c=null!=(n=null==o?void 0:o.desc)&&n;let u=0;if(l){const n=void 0===e.getValue(o.id),r=void 0===t.getValue(o.id);if(n||r){if("first"===l)return n?-1:1;if("last"===l)return n?1:-1;u=n&&r?0:n?l:-l}}if(0===u&&(u=s.sortingFn(e,t,o.id)),0!==u)return c&&(u*=-1),s.invertSorting&&(u*=-1),u}return e.index-t.index}),t.forEach(e=>{var t;o.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=s(e.subRows))}),t};return{rows:s(n.rows),flatRows:o,rowsById:n.rowsById}},Ew(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex())),getFilteredRowModel:e=>jw(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,r)=>{if(!t.rows.length||(null==n||!n.length)&&!r){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}const o=[],a=[];(null!=n?n:[]).forEach(t=>{var n;const r=e.getColumn(t.id);if(!r)return;const a=r.getFilterFn();a?o.push({id:t.id,filterFn:a,resolvedValue:null!=(n=null==a.resolveFilterValue?void 0:a.resolveFilterValue(t.value))?n:t.value}):"production"!==process.env.NODE_ENV&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${r.id}.`)});const i=(null!=n?n:[]).map(e=>e.id),s=e.getGlobalFilterFn(),l=e.getAllLeafColumns().filter(e=>e.getCanGlobalFilter());let c,u;r&&s&&l.length&&(i.push("__global__"),l.forEach(e=>{var t;a.push({id:e.id,filterFn:s,resolvedValue:null!=(t=null==s.resolveFilterValue?void 0:s.resolveFilterValue(r))?t:r})}));for(let e=0;e<t.flatRows.length;e++){const n=t.flatRows[e];if(n.columnFilters={},o.length)for(let e=0;e<o.length;e++){c=o[e];const t=c.id;n.columnFilters[t]=c.filterFn(n,t,c.resolvedValue,e=>{n.columnFiltersMeta[t]=e})}if(a.length){for(let e=0;e<a.length;e++){u=a[e];const t=u.id;if(u.filterFn(n,t,u.resolvedValue,e=>{n.columnFiltersMeta[t]=e})){n.columnFilters.__global__=!0;break}}!0!==n.columnFilters.__global__&&(n.columnFilters.__global__=!1)}}return fC(t.rows,e=>{for(let t=0;t<i.length;t++)if(!1===e.columnFilters[i[t]])return!1;return!0},e)},Ew(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex())),getPaginationRowModel:e=>jw(()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded],(t,n)=>{if(!n.rows.length)return n;const{pageSize:r,pageIndex:o}=t;let{rows:a,flatRows:i,rowsById:s}=n;const l=r*o,c=l+r;let u;a=a.slice(l,c),u=e.options.paginateExpandedRows?{rows:a,flatRows:i,rowsById:s}:function(e){const t=[],n=e=>{var r;t.push(e),null!=(r=e.subRows)&&r.length&&e.getIsExpanded()&&e.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}({rows:a,flatRows:i,rowsById:s}),u.flatRows=[];const d=e=>{u.flatRows.push(e),e.subRows.length&&e.subRows.forEach(d)};return u.rows.forEach(d),u},Ew(e.options,"debugTable","getPaginationRowModel")),getFacetedRowModel:(e,t)=>jw(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter,e.getFilteredRowModel()],(n,r,o)=>{if(!n.rows.length||(null==r||!r.length)&&!o)return n;const a=[...r.map(e=>e.id).filter(e=>e!==t),o?"__global__":void 0].filter(Boolean);return fC(n.rows,e=>{for(let t=0;t<a.length;t++)if(!1===e.columnFilters[a[t]])return!1;return!0},e)},Ew(e.options,"debugTable","getFacetedRowModel")),getFacetedUniqueValues:(e,t)=>jw(()=>{var n;return[null==(n=e.getColumn(t))?void 0:n.getFacetedRowModel()]},e=>{if(!e)return new Map;let n=new Map;for(let o=0;o<e.flatRows.length;o++){const a=e.flatRows[o].getUniqueValues(t);for(let e=0;e<a.length;e++){const t=a[e];var r;n.has(t)?n.set(t,(null!=(r=n.get(t))?r:0)+1):n.set(t,1)}}return n},Ew(e.options,"debugTable",`getFacetedUniqueValues_${t}`)),debugTable:!1});o.useEffect(()=>{B.setPageSize(_.pageSize)},[_.pageSize,B]);const V=o.useMemo(()=>r?hC(r):void 0,[r]),$=o.useMemo(()=>r?gC(r):void 0,[r]),W=o.useMemo(()=>{if(r||a)return()=>{if(v)try{localStorage.removeItem(v)}catch{}x(a?.sorting?[...a.sorting]:[]),C(V?{...V}:a?.visibility?{...a.visibility}:{}),$&&$.length?k([...$]):a?.columnOrder&&k([...a.columnOrder]),E(a?.columnPinning?{left:[...a.columnPinning.left??[]],right:[...a.columnPinning.right??[]]}:{left:[],right:[]}),B.resetColumnSizing()}},[r,a,V,$,C,k,E,x,B,v]);return{table:B,resolvedColumns:D,globalFilter:M,setGlobalFilter:O,pagination:_,setPagination:P,handleResetColumns:W,onBatchAction:m,onRowClick:g,onExportComplete:h}}function xC(e,t="data.csv"){const n=e.getVisibleLeafColumns().map(e=>e.id),r=e.getFilteredRowModel().rows.map(e=>e.getVisibleCells().map(e=>{const t=e.getValue();return"string"==typeof t?t:JSON.stringify(t)})),o=[n.join(","),...r.map(e=>e.join(","))].join("\n"),a=new Blob([o],{type:"text/csv"}),i=URL.createObjectURL(a),s=document.createElement("a");s.href=i,s.download=t,s.click(),URL.revokeObjectURL(i)}function wC(e){if(!e.length)return e;let t=e.slice();return t.includes("select")&&"select"!==t[0]&&(t=["select",...t.filter(e=>"select"!==e)]),t.includes("actions")&&"actions"!==t[t.length-1]&&(t=[...t.filter(e=>"actions"!==e),"actions"]),t}function CC(e){switch(e){case"right":return"text-right";case"center":return"text-center";case"left":return"text-left";default:return}}const SC={defaultColumnWidth:160,minColumnWidth:96,maxColumnWidth:420,toolbarGap:8,selectionColumnWidth:44,actionsColumnWidth:64};function kC({header:e,isDragging:t,activeColumnId:n,clampRef:r}){const o=e.column.id,{attributes:a,listeners:i,setNodeRef:s,transform:l,transition:c,isDragging:u}=sx({id:o}),d=(()=>{const{minX:e,maxX:t}=r.current;return l?Math.min(Math.max(l.x,e),t):0})(),p={transform:Gv.Transform.toString({x:d,y:l?.y??0,scaleX:l?.scaleX??1,scaleY:l?.scaleY??1}),transition:c},f=t&&!u&&null!=n,m=e.column.columnDef.meta?.align,g="right"===m?"ml-auto text-right":"center"===m?"mx-auto text-center":void 0,h=e.column.columnDef.meta?.helpText;function v({sorted:e}){return"asc"===e?ke.jsx(Xe,{className:"ml-2 h-4 w-4 text-muted-foreground"}):"desc"===e?ke.jsx(Ye,{className:"ml-2 h-4 w-4 text-muted-foreground"}):null}const b=e.column.columnDef.header,y=e.column.getCanSort(),x="string"==typeof b;return ke.jsx(Fm,{className:me("relative group border-b-0",CC(e.column.columnDef.meta?.align),f?"opacity-40":void 0),style:{width:e.getSize()},"data-col-id":o,children:ke.jsx("div",{ref:s,style:p,className:"flex items-center gap-2 cursor-grab active:cursor-grabbing","aria-grabbed":u,"aria-label":`Reorder column ${o}`,...a,...i,children:ke.jsx("div",{className:me("min-w-0",g,t?"pointer-events-none":void 0),children:e.isPlaceholder?null:ke.jsxs("div",{className:"inline-flex items-center gap-1",children:[y&&x?ke.jsxs(Le,{variant:"ghost",className:"h-8 -ml-3 px-3",onClick:()=>e.column.toggleSorting("asc"===e.column.getIsSorted()),children:[String(b),ke.jsx(v,{sorted:e.column.getIsSorted()})]}):mC(e.column.columnDef.header,e.getContext()),h?ke.jsxs(Tc,{children:[ke.jsx(Ac,{asChild:!0,children:ke.jsx("button",{type:"button","aria-label":"Column info",className:"inline-flex items-center justify-center text-muted-foreground hover:text-foreground",children:ke.jsx(lt,{className:"h-3.5 w-3.5"})})}),ke.jsx(Ic,{children:h})]}):null]})})})},e.id)}function jC({headerGroups:e,sortableHeaderIds:t,isBodyScrolled:n,isDragging:r,activeColumnId:o,clampRef:a}){return ke.jsx("thead",{"data-scrolled":n||void 0,className:"sticky top-0 z-10 bg-[var(--tablehead-bg)] border-b border-[var(--tablehead-border)] shadow-none data-[scrolled=true]:shadow-sm",children:e.map(e=>{const n=e.headers.find(e=>"select"===e.column.id&&e.column.getIsVisible()),i=e.headers.find(e=>"actions"===e.column.id&&e.column.getIsVisible()),s=e.headers.filter(e=>e.column.getIsVisible()),l=t.map(e=>s.find(t=>t.column.id===e)).filter(Boolean);return ke.jsx("tr",{className:"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",children:ke.jsxs(ex,{items:t,strategy:Yy,children:[n?ke.jsx(Fm,{className:me("relative group border-b-0 p-0",CC(n.column.columnDef.meta?.align)),style:{width:SC.selectionColumnWidth,minWidth:SC.selectionColumnWidth,maxWidth:SC.selectionColumnWidth},children:ke.jsx("div",{className:me("min-w-0","right"===n.column.columnDef.meta?.align?"ml-auto text-right":"center"===n.column.columnDef.meta?.align?"mx-auto text-center":void 0),children:mC(n.column.columnDef.header,n.getContext())})},n.id):null,l.map(e=>ke.jsx(kC,{header:e,isDragging:r,activeColumnId:o,clampRef:a},e.id)),i?ke.jsx(Fm,{className:me("relative group border-b-0",CC(i.column.columnDef.meta?.align)),style:{width:SC.actionsColumnWidth,minWidth:SC.actionsColumnWidth,maxWidth:SC.actionsColumnWidth},children:ke.jsx("div",{className:"min-w-0 ml-auto text-right",children:mC(i.column.columnDef.header,i.getContext())})},i.id):null]})},e.id)})})}function EC({children:e,align:t}){const n=o.useRef(null),r="right"===t;return o.useEffect(()=>{const e=n.current;if(!e)return;let t=0;const o=()=>{if(!e.isConnected)return;if(!(null!==e.offsetParent||e.getClientRects().length>0)||0===e.clientWidth)return;const t=e.scrollWidth>e.clientWidth+1;e.classList.toggle("mmc-table-cell__content--fade-right",t&&!r),e.classList.toggle("mmc-table-cell__content--fade-left",t&&r)};t=requestAnimationFrame(o);const a=new ResizeObserver(()=>o());a.observe(e);const i=e.closest("td");i&&a.observe(i);const s=new MutationObserver(()=>o());s.observe(e,{childList:!0,subtree:!0,characterData:!0});const l=new IntersectionObserver(e=>{const t=e[0];t&&t.isIntersecting&&requestAnimationFrame(o)});l.observe(e);const c=()=>o();return window.addEventListener("resize",c),()=>{cancelAnimationFrame(t),window.removeEventListener("resize",c);try{a.disconnect()}catch{}try{s.disconnect()}catch{}try{l.disconnect()}catch{}}},[r]),ke.jsx("span",{ref:n,className:"mmc-table-cell__content",children:e})}function NC({loading:e,resolvedColumns:t,rows:n,renderOrder:r,isDragging:o,activeColumnId:a}){return ke.jsx("tbody",{className:"[&_tr:last-child]:border-0",children:e?[...Array(5)].map((e,n)=>ke.jsx("tr",{children:t.map((e,t)=>ke.jsx("td",{className:me("px-4 py-2.5 align-middle text-xs font-normal transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] will-change-transform",CC(e.meta?.align)),children:ke.jsx(Bm,{className:"h-6 w-full"})},t))},n)):n?.length?n.map(e=>ke.jsx("tr",{"data-state":e.getIsSelected()&&"selected",className:"border-b transition-colors hover:bg-[var(--accent)] data-[state=selected]:bg-muted",children:(o?e.getVisibleCells().slice().sort((e,t)=>r.indexOf(e.column.id)-r.indexOf(t.column.id)):e.getVisibleCells()).map(e=>{const t=o&&null!=a&&e.column.id!==a&&"select"!==e.column.id;return ke.jsx("td",{className:me("px-4 py-2.5 align-middle text-xs font-normal","select"===e.column.id?"p-0":"[&:has([role=checkbox])]:pr-0","actions"===e.column.id?"py-1.5":void 0,CC(e.column.columnDef.meta?.align),t?"opacity-40":void 0),style:"select"===e.column.id?{width:SC.selectionColumnWidth,minWidth:SC.selectionColumnWidth,maxWidth:SC.selectionColumnWidth}:"actions"===e.column.id?{width:SC.actionsColumnWidth,minWidth:SC.actionsColumnWidth,maxWidth:SC.actionsColumnWidth}:{width:e.column.getSize()},"data-col-id":e.column.id,children:ke.jsx(EC,{align:e.column.columnDef.meta?.align,children:mC(e.column.columnDef.cell,e.getContext())})},e.id)})},e.id)):ke.jsx("tr",{children:ke.jsx("td",{colSpan:t.length,className:"h-24 text-center",children:"No results."})})})}function RC({selectedCount:e,onDeleteSelected:t,onBatchAction:n}){return e<=0?null:ke.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[ke.jsxs("span",{className:"text-sm",children:[e," selected"]}),ke.jsx(Le,{variant:"destructive",size:"sm",onClick:()=>{n?n("delete",[]):t?t(e):alert(`Delete ${e} row(s)`)},children:"Delete"})]})}function DC({columns:e,debug:t}){return ke.jsx("colgroup",{children:e.map(e=>{const n="select"===e.id?SC.selectionColumnWidth:"actions"===e.id?SC.actionsColumnWidth:e.getSize();return t&&t("colgroup width",String(e.id),n),ke.jsx("col",{style:{width:n}},String(e.id))})})}function MC({columns:e,data:t,loading:n=!1,columnRegistry:r,initialState:a,tableId:i,toolbar:s,emptyState:l,forceEmptyState:c,onRowSelectionChange:u,onSortingChange:d,onPaginationChange:p,onColumnVisibilityChange:f,onColumnOrderChange:m,onBatchAction:g,onRowClick:h,onExportComplete:v,customGlobalFilterFn:b}){const{table:y,resolvedColumns:x,globalFilter:w,setGlobalFilter:C,handleResetColumns:S,onBatchAction:k,onExportComplete:j}=yC({columns:e,data:t,columnRegistry:r,initialState:a,tableId:i,disableGlobalFilter:s?.disableGlobalFilter,customGlobalFilterFn:b,onRowSelectionChange:u,onSortingChange:d,onPaginationChange:p,onColumnVisibilityChange:f,onColumnOrderChange:m,onBatchAction:g,onRowClick:h,onExportComplete:v}),[E,N]=o.useState(!1),[R,D]=o.useState(null),[M,O]=o.useState([]),_=o.useRef(null),P=o.useRef(null),T=o.useRef({minX:Number.NEGATIVE_INFINITY,maxX:Number.POSITIVE_INFINITY}),[A,I]=o.useState(!1),F=sb(ib(ty,{activationConstraint:{distance:10}}),ib(Xb)),z=y.getState().columnOrder,L=y.getAllLeafColumns().map(e=>e.id),B=wC(z?.length?z:L),V=y.getHeaderGroups(),$=V.length?V[0].headers.filter(e=>e.column.getIsVisible()).map(e=>e.column.id):B,W=wC(E&&M.length?M:$),H=o.useMemo(()=>W.filter(e=>"select"!==e&&"actions"!==e),[W]),q=o.useCallback(e=>{N(!0),D(String(e.active.id));const t=y.getHeaderGroups(),n=t.length?t[0].headers.filter(e=>e.column.getIsVisible()).map(e=>e.column.id):B;O(wC(n));try{const t=String(e.active.id),n=document.querySelector(`th[data-col-id="${t}"]`),r=_.current;if(n&&r){const e=n.getBoundingClientRect(),t=r.getBoundingClientRect();T.current={minX:t.left-e.left,maxX:t.right-e.right}}else T.current={minX:Number.NEGATIVE_INFINITY,maxX:Number.POSITIVE_INFINITY}}catch{T.current={minX:Number.NEGATIVE_INFINITY,maxX:Number.POSITIVE_INFINITY}}},[B,y]),U=o.useCallback(e=>{const{active:t,over:n}=e;if(!n)return;const r=String(t.id),o=String(n.id);r!==o&&O(e=>{const t=e.indexOf(r),n=e.indexOf(o);if(-1===t||-1===n)return e;const a=Hy(e,t,n);if(a.includes("select")){return["select",...a.filter(e=>"select"!==e)]}return a})},[]),G=o.useCallback(e=>{if(N(!1),D(null),!M.length)return;const t=wC(M);JSON.stringify(B)!==JSON.stringify(t)&&y.setColumnOrder(t),O([])},[B,y,M]),Y=!n&&Boolean(c)&&Boolean(l);return ke.jsxs("div",{className:"w-full h-full flex flex-col min-h-0",children:[ke.jsx(ww,{table:y,loading:n,globalFilter:w??"",onGlobalFilterChange:C,onResetColumns:S,columnRegistry:r,onExport:()=>xC(y),onExportComplete:j,options:s}),y.getFilteredSelectedRowModel().rows.length>0&&ke.jsx(RC,{selectedCount:y.getFilteredSelectedRowModel().rows.length,onBatchAction:k?e=>{const t=y.getFilteredSelectedRowModel().rows.map(e=>e.original);k(e,t)}:void 0}),ke.jsx("div",{className:"relative w-full flex-1 min-h-0 overflow-auto",ref:_,onScroll:e=>{const t=e.currentTarget,n=(t?.scrollTop??0)>0;n!==A&&I(n)},children:Y?ke.jsx("div",{className:"mmc-table-empty flex h-full w-full items-center justify-center",role:"region","aria-label":"Empty state",children:l}):ke.jsx(Ly,{sensors:F,collisionDetection:gb,modifiers:[px],onDragStart:q,onDragOver:U,onDragEnd:G,children:ke.jsxs("table",{ref:P,className:"w-full caption-bottom text-sm table-fixed",children:[ke.jsx(DC,{columns:y.getVisibleLeafColumns(),debug:(...e)=>{}}),ke.jsx(jC,{headerGroups:y.getHeaderGroups(),sortableHeaderIds:H,isBodyScrolled:A,isDragging:E,activeColumnId:R,clampRef:T}),ke.jsx(NC,{loading:n,resolvedColumns:x,rows:y.getRowModel().rows,renderOrder:W,isDragging:E,activeColumnId:R})]})})}),Y?null:ke.jsx("div",{className:"border-t border-border bg-[var(--tablehead-bg)]",children:ke.jsx(gx,{table:y,onPageChange:p?e=>p(e,y.getState().pagination?.pageSize??25):void 0,onPageSizeChange:p?e=>p(y.getState().pagination?.pageIndex??0,e):void 0})})]})}const OC={NAME:"left",DESCRIPTION:"left",CATEGORY:"left",STATUS:"left",QUANTITY:"right",AMOUNT:"right",COUNT:"right",TOTAL:"right",PERCENTAGE:"right",RATE:"right",PROGRESS:"right",DATE:"left",ID:"left",REFERENCE:"left",ICON:"center",CHECKBOX:"center",BUTTON:"center"},_C=[{match:e=>"CURRENT_OPERATION"===e,align:"left"},{match:e=>"PART_OPERATION"===e||"PARTOPERATION"===e,align:"left"},{match:e=>"ORDER_OPERATION"===e||"ORDEROPERATION"===e,align:"left"},{match:e=>"OPERATION_TYPE"===e||"OPERATIONTYPE"===e,align:"left"},{match:e=>e.includes("PARTS")&&!e.includes("REF")||"GOODPARTS"===e||"BADPARTS"===e,align:"right"},{match:e=>e.includes("REJECTS")&&!e.includes("REF"),align:"right"},{match:e=>e.includes("QUANTITY")&&!e.includes("REF"),align:"right"},{match:e=>(e.includes("COUNT")||e.includes("TOTAL")||e.includes("ACTIVE")&&e.includes("ORDERS"))&&!e.includes("REF"),align:"right"},{match:e=>e.includes("RATE")&&!e.includes("REF"),align:"right"},{match:e=>e.includes("PERCENTAGE")&&!e.includes("REF"),align:"right"},{match:e=>e.includes("RATIO")||"SETUP_PRODUCTION_RATIO"===e,align:"right"},{match:e=>e.includes("OPERATIONS")&&e.includes("TOTAL"),align:"right"},{match:e=>e.includes("OPERATIONS")&&e.includes("COMPLETED"),align:"right"},{match:e=>e.includes("DURATION")||"DURATION"===e,align:"right"},{match:e=>e.includes("CYCLE")&&e.includes("TIME"),align:"right"},{match:e=>e.includes("SETUP")&&e.includes("TIME"),align:"right"},{match:e=>e.includes("TIME")&&!e.includes("DATE")&&!e.includes("STAMP"),align:"right"},{match:e=>e.includes("ORDER")||e.includes("NUMBER"),align:"left"},{match:e=>e.includes("EMPLOYEE")&&e.includes("ID"),align:"left"},{match:e=>e.includes("RESOURCE")&&e.includes("ID"),align:"left"},{match:e=>e.includes("DATE")||e.includes("TIME"),align:"left"},{match:e=>e.includes("START")||e.includes("END"),align:"left"},{match:e=>e.includes("CLOCKIN")||e.includes("CLOCKOUT"),align:"left"},{match:e=>e.includes("ID")||e.includes("REF")||e.includes("CODE"),align:"left"},{match:e=>e.includes("NAME")||e.includes("DESCRIPTION"),align:"left"},{match:e=>e.includes("CATEGORY")||"CATEGORY"===e,align:"left"},{match:e=>e.includes("OPERATION"),align:"left"},{match:e=>e.includes("ORDEROP"),align:"left"},{match:e=>e.includes("PARTOPERATION"),align:"left"},{match:e=>e.includes("WORKORDEROPERATIONREF"),align:"left"},{match:e=>e.includes("OPERATIONTYPE"),align:"left"},{match:e=>e.includes("LOT")||"LOT"===e,align:"left"},{match:e=>e.includes("SPLIT")||"SPLIT"===e,align:"left"},{match:e=>e.includes("SUB")||"SUB"===e,align:"left"},{match:e=>e.includes("SEQ")||"SEQUENCENUMBER"===e||"SEQUENCE"===e,align:"left"},{match:e=>e.includes("ACTIVITY")||e.includes("STATUS"),align:"left"},{match:e=>e.includes("STATE")||e.includes("TYPE"),align:"left"}];function PC(e){const{id:t,column:n,...r}=e,o={...n.meta};r.align&&void 0===o.align&&(o.align=r.align),r.helpText&&void 0===o.helpText&&(o.helpText=r.helpText);const a={...n,id:n.id??t,meta:o};return null!=r.width&&null==a.size&&(a.size=r.width),null!=r.minWidth&&null==a.minSize&&(a.minSize=r.minWidth),null!=r.maxWidth&&null==a.maxSize&&(a.maxSize=r.maxWidth),!1===r.hideable&&null==a.enableHiding&&(a.enableHiding=!1),function(e,t){if(!t)return;if(!1!==e.enableColumnFilter&&(e.enableColumnFilter=!0),e.filterFn)return;const n=t=>{e.filterFn=t};switch(t.type){case"select":n((e,t,n)=>{if(null==n||""===n)return!0;const r=e.getValue(t);if(null==r)return!1;const o=Array.isArray(n)?n.map(String):[String(n)];return 0===o.length||o.includes(String(r))});break;case"multi-select":n((e,t,n)=>{if(!Array.isArray(n)||0===n.length)return!0;const r=e.getValue(t);if(null==r)return!1;const o=Array.isArray(r)?r.map(String):[String(r)],a=n.map(String);return o.some(e=>a.includes(e))});break;case"numeric-range":n((e,t,n)=>{if(!Array.isArray(n)||0===n.length)return!0;const[r,o]=n;if(null==r&&null==o)return!0;const a=e.getValue(t);if(null==a)return!1;const i="number"==typeof a?a:Number(a);return!(Number.isNaN(i)||null!=r&&i<r||null!=o&&i>o)});break;case"date-range":n((e,t,n)=>{if(!Array.isArray(n)||0===n.length)return!0;const[r,o]=n;if(!r&&!o)return!0;const a=e.getValue(t);if(!a)return!1;const i=a instanceof Date?a:new Date(a);if(Number.isNaN(i.getTime()))return!1;if(r){const e=new Date(r);if(!Number.isNaN(e.getTime())&&i<e)return!1}if(o){const e=new Date(o);if(!Number.isNaN(e.getTime())&&i>e)return!1}return!0});break;case"text":n((e,t,n)=>{if(null==n)return!0;const r=e.getValue(t);if(null==r)return!1;if(Array.isArray(n)){const e=n.map(e=>String(e).toLowerCase());return 0===e.length||(Array.isArray(r)?r.map(e=>String(e).toLowerCase()).some(t=>e.includes(t)):e.includes(String(r).toLowerCase()))}const o=String(n).toLowerCase();return Array.isArray(r)?r.map(String).some(e=>e.toLowerCase().includes(o)):String(r).toLowerCase().includes(o)})}}(a,r.filter),{columnDef:a,defaults:{id:t,visible:!0,hideable:!0,...r}}}function TC(e){return e.defaults.id??e.columnDef.id??e.columnDef.accessorKey??""}function AC(e){const t=e.columnDef.meta;if(t?.mobileLabel)return t.mobileLabel;if(t?.label)return t.label;const n=e.columnDef.header;if("string"==typeof n)return n;return TC(e).replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function IC({row:e,columnRegistry:t,className:n,onRowClick:r}){const a=e.getVisibleCells(),i=new Map(a.map(e=>[e.column.id,e])),s=t||null,l=a.map(e=>{const t=e.column.id,n=s?s[t]:void 0;return n||{columnDef:e.column.columnDef,defaults:{id:t}}});function c(e){return mC(e.column.columnDef.cell,e.getContext())}function u(e){if(o.isValidElement(e)){const t={...e.props};if("string"==typeof t.className){const e=t.className.replace(/\bjustify-end\b/g,"justify-start").replace(/\bjustify-between\b/g,"justify-start").replace(/\btext-right\b/g,"text-left").replace(/\btext-center\b/g,"text-left").replace(/\bml-auto\b/g,"");t.className=e}return t.children&&(t.children=o.Children.map(t.children,e=>u(e))),o.cloneElement(e,t)}return Array.isArray(e)?e.map((e,t)=>ke.jsx(o.Fragment,{children:u(e)},t)):e}const d=l.find(e=>"title"===e.defaults.mobileRole),p=l.find(e=>"subtitle"===e.defaults.mobileRole),f=l.filter(e=>"badge"===e.defaults.mobileRole),m=l.find(e=>"select"===TC(e)),g=m?TC(m):void 0,h=g?i.get(g):void 0,v=l.filter(e=>{const t=e.defaults.mobileRole??"";return TC(e)!==g&&!["title","subtitle","badge"].includes(t)}),b=l.find(e=>"actions"===TC(e)),y=b?b.columnDef.meta?.rowActions??void 0:void 0,x=y?y(e):[],w=x.length>0,[C,S]=o.useState(!1);function k(t){const n=t.target;if(!n)return;n.closest('a,button,input,select,textarea,label,[role=checkbox],[data-slot="table-action-trigger"]')||(r&&r(e.original,e.index),w&&S(e=>!e))}return ke.jsxs("div",{className:me("mmc-row-card rounded-lg border border-border bg-card text-card-foreground shadow-sm p-4 space-y-3",n),role:w?"button":"group","aria-label":(()=>{const t=[];if(d){const n=TC(d),r=e.getValue(n);null!=r&&t.push(String(r))}if(p){const n=TC(p),r=e.getValue(n);null!=r&&t.push(String(r))}return t.join(" — ")||"Row"})(),"data-slot":"row-card",tabIndex:w||r?0:void 0,onClick:w||r?k:void 0,onKeyDown:w||r?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),k(e))}:void 0,"aria-expanded":w?C:void 0,children:[ke.jsxs("header",{className:"mmc-row-card__header flex items-start justify-between gap-3",children:[ke.jsxs("div",{className:"mmc-row-card__header-left flex items-start gap-3",children:[h?ke.jsx("div",{className:"mmc-row-card__selection pt-1",children:c(h)}):null,ke.jsxs("div",{className:"mmc-row-card__title-wrap space-y-1",children:[d?ke.jsx("div",{className:"mmc-row-card__title text-base font-medium",children:(()=>{const t=TC(d),n=i.get(t);return n?c(n):e.getValue(t)})()}):null,p?ke.jsx("div",{className:"mmc-row-card__subtitle text-sm text-muted-foreground",children:(()=>{const t=TC(p),n=i.get(t);return n?c(n):e.getValue(t)})()}):null]})]}),ke.jsx("div",{className:"mmc-row-card__badges flex flex-wrap items-center gap-2","aria-label":"Status",children:f.map(e=>{const t=TC(e),n=i.get(t);return n?ke.jsx("div",{className:"mmc-row-card__badge text-sm font-medium",children:c(n)},t):null})})]}),w&&C?ke.jsx("div",{className:"mmc-row-card__actions rounded-md border p-1",role:"menu","aria-label":"Row actions",children:x.map((t,n)=>ke.jsx("button",{type:"button",className:me("relative flex w-full items-center gap-2 rounded-sm px-2 py-2 text-sm text-left outline-hidden select-none hover:bg-accent","destructive"===t.variant?"text-destructive":void 0),onClick:n=>{n.stopPropagation();try{t.onSelect(e)}finally{S(!1)}},role:"menuitem","data-variant":t.variant??"default",children:t.label},t.key??n))}):ke.jsx("dl",{className:"mmc-row-card__details grid grid-cols-2 gap-3 text-sm sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:v.map(e=>{const t=TC(e),n=i.get(t);return n?ke.jsxs("div",{className:"mmc-row-card__detail flex flex-col gap-1",children:[ke.jsx("dt",{className:"mmc-row-card__label text-xs text-muted-foreground",children:AC(e)}),ke.jsx("dd",{className:"mmc-row-card__value m-0 w-full text-left flex items-center justify-start",children:u(c(n))})]},t):null})})]})}function FC(e,t,n){let r,o=n.initialDeps??[];function a(){var a,i,s,l;let c;n.key&&(null==(a=n.debug)?void 0:a.call(n))&&(c=Date.now());const u=e();if(!(u.length!==o.length||u.some((e,t)=>o[t]!==e)))return r;let d;if(o=u,n.key&&(null==(i=n.debug)?void 0:i.call(n))&&(d=Date.now()),r=t(...u),n.key&&(null==(s=n.debug)?void 0:s.call(n))){const e=Math.round(100*(Date.now()-c))/100,t=Math.round(100*(Date.now()-d))/100,r=t/16,o=(e,t)=>{for(e=String(e);e.length<t;)e=" "+e;return e};console.info(`%c⏱ ${o(t,5)} /${o(e,5)} ms`,`\n font-size: .6rem;\n font-weight: bold;\n color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,null==n?void 0:n.key)}return null==(l=null==n?void 0:n.onChange)||l.call(n,r),r}return a.updateDeps=e=>{o=e},a}function zC(e,t){if(void 0===e)throw new Error("Unexpected undefined");return e}const LC=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}},BC=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},VC=e=>e,$C=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let o=t;o<=n;o++)r.push(o);return r},WC=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=e=>{const{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(o(BC(n)),!r.ResizeObserver)return()=>{};const a=new r.ResizeObserver(t=>{const r=()=>{const e=t[0];if(null==e?void 0:e.borderBoxSize){const t=e.borderBoxSize[0];if(t)return void o({width:t.inlineSize,height:t.blockSize})}o(BC(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},HC={passive:!0},qC="undefined"==typeof window||"onscrollend"in window,UC=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let o=0;const a=e.options.useScrollendEvent&&qC?()=>{}:LC(r,()=>{t(o,!1)},e.options.isScrollingResetDelay),i=r=>()=>{const{horizontal:i,isRtl:s}=e.options;o=i?n.scrollLeft*(s?-1:1):n.scrollTop,a(),t(o,r)},s=i(!0),l=i(!1);l(),n.addEventListener("scroll",s,HC);const c=e.options.useScrollendEvent&&qC;return c&&n.addEventListener("scrollend",l,HC),()=>{n.removeEventListener("scroll",s),c&&n.removeEventListener("scrollend",l)}},GC=(e,t,n)=>{if(null==t?void 0:t.borderBoxSize){const e=t.borderBoxSize[0];if(e){return Math.round(e[n.options.horizontal?"inlineSize":"blockSize"])}}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},YC=(e,{adjustments:t=0,behavior:n},r)=>{var o,a;const i=e+t;null==(a=null==(o=r.scrollElement)?void 0:o.scrollTo)||a.call(o,{[r.options.horizontal?"left":"top"]:i,behavior:n})};class KC{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null;const t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{const t=()=>{this._measureElement(e.target,e)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}):null);return{disconnect:()=>{var n;null==(n=t())||n.disconnect(),e=null},observe:e=>{var n;return null==(n=t())?void 0:n.observe(e,{box:"border-box"})},unobserve:e=>{var n;return null==(n=t())?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{void 0===n&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:VC,rangeExtractor:$C,onChange:()=>{},measureElement:GC,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;null==(n=(t=this.options).onChange)||n.call(t,this,e)},this.maybeNotify=FC(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:"production"!==process.env.NODE_ENV&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t)return void this.maybeNotify();this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.window)??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?"forward":"backward":null,this.scrollOffset=e,this.isScrolling=t,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{const n=new Map,r=new Map;for(let o=t-1;o>=0;o--){const t=e[o];if(n.has(t.lane))continue;const a=r.get(t.lane);if(null==a||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=FC(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(e,t,n,r,o)=>(this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:o}),{key:!1}),this.getMeasurements=FC(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:o},a)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];0===this.measurementsCache.length&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));const i=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const s=this.measurementsCache.slice(0,i);for(let l=i;l<e;l++){const e=r(l),o=1===this.options.lanes?s[l-1]:this.getFurthestMeasurement(s,l),i=o?o.end+this.options.gap:t+n,c=a.get(e),u="number"==typeof c?c:this.options.estimateSize(l),d=i+u,p=o?o.lane:l%this.options.lanes;s[l]={index:l,start:i,size:u,end:d,key:e,lane:p}}return this.measurementsCache=s,s},{key:"production"!==process.env.NODE_ENV&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=FC(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?function({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const o=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:o};let i=XC(0,o,a,n),s=i;if(1===r)for(;s<o&&e[s].end<n+t;)s++;else if(r>1){const a=Array(r).fill(0);for(;s<o&&a.some(e=>e<n+t);){const t=e[s];a[t.lane]=t.end,s++}const l=Array(r).fill(n+t);for(;i>=0&&l.some(e=>e>=n);){const t=e[i];l[t.lane]=t.start,i--}i=Math.max(0,i-i%r),s=Math.min(o,s+(r-1-s%r))}return{startIndex:i,endIndex:s}}({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:"production"!==process.env.NODE_ENV&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=FC(()=>{let e=null,t=null;const n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,o)=>null===r||null===o?[]:e({startIndex:r,endIndex:o,overscan:t,count:n}),{key:"production"!==process.env.NODE_ENV&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=e=>{const t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this._measureElement=(e,t)=>{const n=this.indexFromElement(e),r=this.measurementsCache[n];if(!r)return;const o=r.key,a=this.elementsCache.get(o);a!==e&&(a&&this.observer.unobserve(a),this.observer.observe(e),this.elementsCache.set(o,e)),e.isConnected&&this.resizeItem(n,this.options.measureElement(e,t,this))},this.resizeItem=(e,t)=>{const n=this.measurementsCache[e];if(!n)return;const r=t-(this.itemSizeCache.get(n.key)??n.size);0!==r&&((void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&("production"!==process.env.NODE_ENV&&this.options.debug&&console.info("correction",r),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.measureElement=e=>{e?this._measureElement(e,void 0):this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))})},this.getVirtualItems=FC(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{const n=[];for(let r=0,o=e.length;r<o;r++){const o=t[e[r]];n.push(o)}return n},{key:"production"!==process.env.NODE_ENV&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const t=this.getMeasurements();if(0!==t.length)return zC(t[XC(0,t.length-1,e=>zC(t[e]).start,e)])},this.getOffsetForAlignment=(e,t,n=0)=>{const r=this.getSize(),o=this.getScrollOffset();"auto"===t&&(t=e>=o+r?"end":"start"),"center"===t?e+=(n-r)/2:"end"===t&&(e-=r);const a=this.getTotalSize()+this.options.scrollMargin-r;return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const n=this.measurementsCache[e];if(!n)return;const r=this.getSize(),o=this.getScrollOffset();if("auto"===t)if(n.end>=o+r-this.options.scrollPaddingEnd)t="end";else{if(!(n.start<=o+this.options.scrollPaddingStart))return[o,t];t="start"}const a="end"===t?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,n.size),t]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(e,{align:t="start",behavior:n}={})=>{"smooth"===n&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,t),{adjustments:void 0,behavior:n})},this.scrollToIndex=(e,{align:t="auto",behavior:n}={})=>{"smooth"===n&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),e=Math.max(0,Math.min(e,this.options.count-1));let r=0;const o=t=>{if(!this.targetWindow)return;const r=this.getOffsetForIndex(e,t);if(!r)return void console.warn("Failed to get offset for index:",e);const[o,i]=r;this._scrollToOffset(o,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{const t=this.getScrollOffset(),n=this.getOffsetForIndex(e,i);var r,o;n?(r=n[0],o=t,Math.abs(r-o)<1.01||a(i)):console.warn("Failed to get offset for index:",e)})},a=t=>{this.targetWindow&&(r++,r<10?("production"!==process.env.NODE_ENV&&this.options.debug&&console.info("Schedule retry",r,10),this.targetWindow.requestAnimationFrame(()=>o(t))):console.warn(`Failed to scroll to index ${e} after 10 attempts.`))};o(t)},this.scrollBy=(e,{behavior:t}={})=>{"smooth"===t&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:t})},this.getTotalSize=()=>{var e;const t=this.getMeasurements();let n;if(0===t.length)n=this.options.paddingStart;else if(1===this.options.lanes)n=(null==(e=t[t.length-1])?void 0:e.end)??0;else{const e=Array(this.options.lanes).fill(null);let r=t.length-1;for(;r>=0&&e.some(e=>null===e);){const n=t[r];null===e[n.lane]&&(e[n.lane]=n.end),r--}n=Math.max(...e.filter(e=>null!==e))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(e)}}const XC=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,a=n(o);if(a<r)e=o+1;else{if(!(a>r))return o;t=o-1}}return e>0?e-1:0};const ZC="undefined"!=typeof document?o.useLayoutEffect:o.useEffect;function JC(e){return function(e){const t=o.useReducer(()=>({}),{})[1],r={...e,onChange:(r,o)=>{var a;o?n.flushSync(t):t(),null==(a=e.onChange)||a.call(e,r,o)}},[a]=o.useState(()=>new KC(r));return a.setOptions(r),ZC(()=>a._didMount(),[]),ZC(()=>a._willUpdate()),a}({observeElementRect:WC,observeElementOffset:UC,scrollToFn:YC,...e})}o.createContext(void 0);o.forwardRef(({className:e,...t},n)=>ke.jsx("th",{ref:n,"data-slot":"table-head",className:me("h-10 px-4 text-left align-middle text-xs font-semibold bg-[var(--tablehead-bg)] text-[var(--tablehead-fg)] border-b border-[var(--tablehead-border)] [&:has([role=checkbox])]:pr-0 [&:has([role=checkbox])]:pl-0","[&_button]:text-xs [&_button]:font-semibold [&_[data-slot='button']]:text-xs [&_[data-slot='button']]:font-semibold",e),...t})).displayName="TableHead";const QC=o.forwardRef(({className:e,children:t,autoHeight:n=!0,...r},a)=>{const i=o.useRef(null);o.useImperativeHandle(a,()=>i.current);const s=o.useCallback(()=>{const e=i.current;if(!e)return;let t=!1;if(n){let n=e.nextElementSibling;for(;n;){const e=n,r=window.getComputedStyle(e);if("none"!==r.display&&"hidden"!==r.visibility&&null!==e.offsetParent&&e.offsetHeight>0){t=!0;break}n=n.nextElementSibling}if(!t){const t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;let r=n;const o=e.closest('[data-slot="component_preview"]');if(o){const e=o.getBoundingClientRect(),t=window.getComputedStyle(o),a=parseFloat(t.paddingBottom||"0")||0;r=Math.min(n,e.bottom-a)}const a=Math.max(0,r-t.top);return e.style.height=`${a}px`,void(e.style.minHeight="400px")}}e.style.height="",e.style.minHeight="400px"},[n]);return o.useLayoutEffect(()=>{s();const e=()=>{requestAnimationFrame(s)};return window.addEventListener("resize",e),window.addEventListener("scroll",e,{passive:!0}),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}},[s]),ke.jsx("div",{ref:i,"data-slot":"table-wrapper",className:me("flex min-h-[400px] flex-col rounded-md border p-4",e),...r,children:t})});function eS({columns:e,data:t,loading:n,columnRegistry:r,initialState:a,tableId:i,enableMobileVirtualization:s=!0,virtualizeAt:l=500,overscan:c=8,toolbarOptions:u,emptyState:d,forceEmptyState:p,onRowSelectionChange:f,onSortingChange:m,onPaginationChange:g,onColumnVisibilityChange:h,onColumnOrderChange:v,onBatchAction:b,onRowClick:y,onExportComplete:x,customGlobalFilterFn:w}){const{table:C,globalFilter:S,setGlobalFilter:k,handleResetColumns:j}=yC({columns:e,data:t,columnRegistry:r,initialState:a,tableId:i,customGlobalFilterFn:w,onRowSelectionChange:f,onSortingChange:m,onPaginationChange:g,onColumnVisibilityChange:h,onColumnOrderChange:v,onBatchAction:b,onRowClick:y,onExportComplete:x}),E=o.useRef(null),N=C.getRowModel().rows,R=!n&&s&&N.length>=l,D=JC({count:R?N.length:0,getScrollElement:()=>E.current,estimateSize:()=>128,overscan:c}),M=!n&&Boolean(p)&&Boolean(d);return ke.jsxs("section",{className:"mmc-responsive-table w-full h-full flex flex-col min-h-0 space-y-4","aria-label":"Data table (mobile)",children:[ke.jsx(ww,{table:C,loading:n,globalFilter:S,onGlobalFilterChange:k,onResetColumns:j,columnRegistry:r,onExport:()=>xC(C),options:u}),C.getFilteredSelectedRowModel().rows.length>0&&ke.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[ke.jsxs("span",{className:"text-sm",children:[C.getFilteredSelectedRowModel().rows.length," selected"]}),ke.jsx(Le,{variant:"destructive",size:"sm",onClick:()=>{alert(`Delete ${C.getFilteredSelectedRowModel().rows.length} row(s)`)},children:"Delete"})]}),ke.jsx("div",{ref:E,className:"mmc-row-card-list space-y-3 overflow-auto flex-1 min-h-0",role:"list","aria-label":"Rows",children:M?ke.jsx("div",{className:"mmc-table-empty flex h-full w-full items-center justify-center",role:"region","aria-label":"Empty state",children:d}):(()=>{if(n)return[0,1,2].map(e=>ke.jsxs("div",{className:"mmc-row-card mmc-row-card--skeleton rounded-lg border border-border bg-card p-4 space-y-3",role:"group","aria-label":"Loading row","aria-busy":"true","aria-live":"polite",children:[ke.jsxs("div",{className:"flex items-center justify-between",children:[ke.jsx(Bm,{className:"h-4 w-1/2"}),ke.jsx(Bm,{className:"h-5 w-12"})]}),ke.jsxs("div",{className:"space-y-2",children:[ke.jsx(Bm,{className:"h-3 w-3/4"}),ke.jsx(Bm,{className:"h-3 w-2/3"}),ke.jsx(Bm,{className:"h-3 w-1/2"})]})]},e));if(!N.length&&!M)return ke.jsxs("div",{className:"mmc-row-card-list__empty rounded-lg border border-dashed border-border py-10 text-center text-sm text-muted-foreground",role:"status","aria-live":"polite",children:[ke.jsx("span",{className:"sr-only",children:"No results"}),"No results."]});if(!R)return N.map(e=>ke.jsx(IC,{row:e,columnRegistry:r,className:"mmc-row-card--item w-full",onRowClick:y},e.id));const e=D.getVirtualItems();return ke.jsx("div",{style:{height:D.getTotalSize(),position:"relative"},children:e.map(e=>{const t=N[e.index];return ke.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,transform:`translateY(${e.start}px)`},children:ke.jsx(IC,{row:t,columnRegistry:r,className:"mmc-row-card--item w-full",onRowClick:y})},t.id)})})})()}),M?null:ke.jsx(gx,{table:C})]})}QC.displayName="TableContainer";var tS="Progress",nS=100,[rS]=Nt(tS),[oS,aS]=rS(tS),iS=o.forwardRef((e,t)=>{const{__scopeProgress:n,value:r=null,max:o,getValueLabel:a=cS,...i}=e;!o&&0!==o||pS(o)||console.error(`Invalid prop \`max\` of value \`${`${o}`}\` supplied to \`${"Progress"}\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`);const s=pS(o)?o:nS;null===r||fS(r,s)||console.error(function(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:\n - a positive number\n - less than the value passed to \`max\` (or 100 if no \`max\` prop is set)\n - \`null\` or \`undefined\` if the progress is indeterminate.\n\nDefaulting to \`null\`.`}(`${r}`,"Progress"));const l=fS(r,s)?r:null,c=dS(l)?a(l,s):void 0;return ke.jsx(oS,{scope:n,value:l,max:s,children:ke.jsx(Ct.div,{"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":dS(l)?l:void 0,"aria-valuetext":c,role:"progressbar","data-state":uS(l,s),"data-value":l??void 0,"data-max":s,...i,ref:t})})});iS.displayName=tS;var sS="ProgressIndicator",lS=o.forwardRef((e,t)=>{const{__scopeProgress:n,...r}=e,o=aS(sS,n);return ke.jsx(Ct.div,{"data-state":uS(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...r,ref:t})});function cS(e,t){return`${Math.round(e/t*100)}%`}function uS(e,t){return null==e?"indeterminate":e===t?"complete":"loading"}function dS(e){return"number"==typeof e}function pS(e){return dS(e)&&!isNaN(e)&&e>0}function fS(e,t){return dS(e)&&!isNaN(e)&&e<=t&&e>=0}lS.displayName=sS;var mS=iS,gS=lS;const hS=o.forwardRef(({className:e,value:t,...n},r)=>{const o="number"==typeof t?Math.max(0,Math.min(100,t)):void 0;return ke.jsx(mS,{ref:r,"data-slot":"progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":"number"==typeof o?o:void 0,"data-unknown":"number"!=typeof o?"true":void 0,className:me("relative h-2 w-full overflow-hidden rounded-full",e),...n,children:ke.jsx(gS,{"data-slot":"progress-indicator",className:"h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(o||0)}%)`}})})});hS.displayName="Progress";var vS,bS={exports:{}},yS={exports:{}},xS={};var wS,CS,SS,kS,jS,ES,NS,RS,DS,MS,OS,_S,PS,TS,AS,IS={};
57
+ function mC(e,t){return e?function(e){return"function"==typeof e&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}(n=e)||"function"==typeof n||function(e){return"object"==typeof e&&"symbol"==typeof e.$$typeof&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}(n)?o.createElement(e,t):e:null;var n}function gC(e,t=[]){return t.length?t:Object.values(e).sort((e,t)=>(e.defaults.order??0)-(t.defaults.order??0)).map(e=>e.defaults.id||e.columnDef.id||"").filter(e=>Boolean(e))}function hC(e,t={}){if(!e)return t;return{...Object.values(e).reduce((e,t)=>{const n=t.defaults.id??t.columnDef.id;return n?(!1===t.defaults.visible&&(e[n]=!1),e):e},{}),...t}}function vC(e={}){const{registry:t,initialSorting:n=[],initialVisibility:r,initialColumnOrder:a,initialPinning:i,initialRowSelection:s}=e,l=o.useMemo(()=>t?gC(t,a):a??[],[t,a]),c=o.useMemo(()=>hC(t,r),[t,r]),[u,d]=o.useState(n),[p,f]=o.useState(c),[m,g]=o.useState(l),[h,v]=o.useState(i??{left:[],right:[]}),[b,y]=o.useState(s??{});return o.useEffect(()=>{l.length&&g(e=>{const t=new Set(e),n=[];l.forEach(e=>{e&&(n.push(e),t.delete(e))});const r=e.filter(e=>t.has(e)),o=n.concat(r);if(o.length!==e.length)return o;for(let a=0;a<o.length;a+=1)if(o[a]!==e[a])return o;return e})},[l]),{sorting:[u,d],columnVisibility:[p,f],columnOrder:[m,g],columnPinning:[h,v],rowSelection:[b,y]}}function bC(e="(max-width: 768px)"){const t=o.useCallback(()=>"undefined"!=typeof window&&window.matchMedia(e).matches,[e]),[n,r]=o.useState(t);return o.useEffect(()=>{const t=window.matchMedia(e),n=e=>r(e.matches);return t.addEventListener("change",n),r(t.matches),()=>t.removeEventListener("change",n)},[e]),n}function yC(e){const{columns:t,data:n,columnRegistry:r,initialState:a,tableId:i,disableGlobalFilter:s,customGlobalFilterFn:l,onRowSelectionChange:c,onSortingChange:u,onPaginationChange:d,onColumnVisibilityChange:p,onColumnOrderChange:f,onBatchAction:m,onRowClick:g,onExportComplete:h}=e,v=i?`mmrc:table:${i}`:void 0,b=o.useMemo(()=>{if(!v)return null;try{const e=localStorage.getItem(v);if(!e)return null;return JSON.parse(e)}catch{return null}},[v]),{sorting:[y,x],columnVisibility:[w,C],columnOrder:[S,k],columnPinning:[j,E],rowSelection:[N,R]}=vC({registry:r,initialSorting:b?.sorting??a?.sorting,initialVisibility:b?.columnVisibility??a?.visibility,initialColumnOrder:b?.columnOrder??a?.columnOrder,initialPinning:a?.columnPinning,initialRowSelection:a?.rowSelection}),D=o.useMemo(()=>{if(!r)return t;const e=Object.entries(r),n=gC(r),o=S.length?S:n,a=new Map(e),i=new Set,s=o.map(e=>{const t=a.get(e);return t?(i.add(e),t.columnDef):null}).filter(Boolean);return e.forEach(([e,t])=>{i.has(e)||s.push(t.columnDef)}),s},[r,t,S]),[M,O]=o.useState(""),[_,P]=o.useState({pageIndex:0,pageSize:25}),T=o.useCallback(e=>{const t="function"==typeof e?e(N):e;if(R(t),c){const e=n.filter((e,n)=>t[n]);c(e,t)}},[N,R,c,n]),A=o.useCallback(e=>{const t="function"==typeof e?e(y):e;x(t),u&&u(t)},[y,x,u]),I=o.useCallback(e=>{const t="function"==typeof e?e(_):e;P(t),d&&d(t.pageIndex,t.pageSize)},[_,P,d]),F=o.useCallback(e=>{const t="function"==typeof e?e(w):e;C(t),p&&p(t)},[w,C,p]),z=o.useCallback(e=>{const t="function"==typeof e?e(S):e;k(t),f&&f(t)},[S,k,f]);o.useEffect(()=>{if(v)try{const e=JSON.stringify({columnOrder:S,columnVisibility:w,sorting:y});localStorage.setItem(v,e)}catch{}},[S,w,y,v]);const L=o.useMemo(()=>s?(e,t,n)=>!0:l||void 0,[s,l]),B=function(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=o.useState(()=>({current:pC(t)})),[r,a]=o.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{a(t),null==e.onStateChange||e.onStateChange(t)}})),n.current}({data:n,columns:D,state:{sorting:y,rowSelection:N,columnVisibility:w,columnOrder:S,globalFilter:M,columnPinning:j,pagination:_},enableRowSelection:!0,enableColumnResizing:!0,enableColumnPinning:!0,enableGlobalFilter:!0,...void 0!==L&&{globalFilterFn:L},onRowSelectionChange:T,onSortingChange:A,onColumnVisibilityChange:F,onColumnOrderChange:z,onGlobalFilterChange:O,onColumnPinningChange:E,onPaginationChange:I,getCoreRowModel:e=>jw(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(t,o,a){void 0===o&&(o=0);const i=[];for(let l=0;l<t.length;l++){const c=Ow(e,e._getRowId(t[l],l,a),t[l],l,o,0,null==a?void 0:a.id);var s;n.flatRows.push(c),n.rowsById[c.id]=c,i.push(c),e.options.getSubRows&&(c.originalSubRows=e.options.getSubRows(t[l],l),null!=(s=c.originalSubRows)&&s.length&&(c.subRows=r(c.originalSubRows,o+1,c)))}return i};return n.rows=r(t),n},Ew(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex())),getSortedRowModel:e=>jw(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||null==t||!t.length)return n;const r=e.getState().sorting,o=[],a=r.filter(t=>{var n;return null==(n=e.getColumn(t.id))?void 0:n.getCanSort()}),i={};a.forEach(t=>{const n=e.getColumn(t.id);n&&(i[t.id]={sortUndefined:n.columnDef.sortUndefined,invertSorting:n.columnDef.invertSorting,sortingFn:n.getSortingFn()})});const s=e=>{const t=e.map(e=>({...e}));return t.sort((e,t)=>{for(let r=0;r<a.length;r+=1){var n;const o=a[r],s=i[o.id],l=s.sortUndefined,c=null!=(n=null==o?void 0:o.desc)&&n;let u=0;if(l){const n=void 0===e.getValue(o.id),r=void 0===t.getValue(o.id);if(n||r){if("first"===l)return n?-1:1;if("last"===l)return n?1:-1;u=n&&r?0:n?l:-l}}if(0===u&&(u=s.sortingFn(e,t,o.id)),0!==u)return c&&(u*=-1),s.invertSorting&&(u*=-1),u}return e.index-t.index}),t.forEach(e=>{var t;o.push(e),null!=(t=e.subRows)&&t.length&&(e.subRows=s(e.subRows))}),t};return{rows:s(n.rows),flatRows:o,rowsById:n.rowsById}},Ew(e.options,"debugTable","getSortedRowModel",()=>e._autoResetPageIndex())),getFilteredRowModel:e=>jw(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,r)=>{if(!t.rows.length||(null==n||!n.length)&&!r){for(let e=0;e<t.flatRows.length;e++)t.flatRows[e].columnFilters={},t.flatRows[e].columnFiltersMeta={};return t}const o=[],a=[];(null!=n?n:[]).forEach(t=>{var n;const r=e.getColumn(t.id);if(!r)return;const a=r.getFilterFn();a?o.push({id:t.id,filterFn:a,resolvedValue:null!=(n=null==a.resolveFilterValue?void 0:a.resolveFilterValue(t.value))?n:t.value}):"production"!==process.env.NODE_ENV&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${r.id}.`)});const i=(null!=n?n:[]).map(e=>e.id),s=e.getGlobalFilterFn(),l=e.getAllLeafColumns().filter(e=>e.getCanGlobalFilter());let c,u;r&&s&&l.length&&(i.push("__global__"),l.forEach(e=>{var t;a.push({id:e.id,filterFn:s,resolvedValue:null!=(t=null==s.resolveFilterValue?void 0:s.resolveFilterValue(r))?t:r})}));for(let e=0;e<t.flatRows.length;e++){const n=t.flatRows[e];if(n.columnFilters={},o.length)for(let e=0;e<o.length;e++){c=o[e];const t=c.id;n.columnFilters[t]=c.filterFn(n,t,c.resolvedValue,e=>{n.columnFiltersMeta[t]=e})}if(a.length){for(let e=0;e<a.length;e++){u=a[e];const t=u.id;if(u.filterFn(n,t,u.resolvedValue,e=>{n.columnFiltersMeta[t]=e})){n.columnFilters.__global__=!0;break}}!0!==n.columnFilters.__global__&&(n.columnFilters.__global__=!1)}}return fC(t.rows,e=>{for(let t=0;t<i.length;t++)if(!1===e.columnFilters[i[t]])return!1;return!0},e)},Ew(e.options,"debugTable","getFilteredRowModel",()=>e._autoResetPageIndex())),getPaginationRowModel:e=>jw(()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded],(t,n)=>{if(!n.rows.length)return n;const{pageSize:r,pageIndex:o}=t;let{rows:a,flatRows:i,rowsById:s}=n;const l=r*o,c=l+r;let u;a=a.slice(l,c),u=e.options.paginateExpandedRows?{rows:a,flatRows:i,rowsById:s}:function(e){const t=[],n=e=>{var r;t.push(e),null!=(r=e.subRows)&&r.length&&e.getIsExpanded()&&e.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}({rows:a,flatRows:i,rowsById:s}),u.flatRows=[];const d=e=>{u.flatRows.push(e),e.subRows.length&&e.subRows.forEach(d)};return u.rows.forEach(d),u},Ew(e.options,"debugTable","getPaginationRowModel")),getFacetedRowModel:(e,t)=>jw(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter,e.getFilteredRowModel()],(n,r,o)=>{if(!n.rows.length||(null==r||!r.length)&&!o)return n;const a=[...r.map(e=>e.id).filter(e=>e!==t),o?"__global__":void 0].filter(Boolean);return fC(n.rows,e=>{for(let t=0;t<a.length;t++)if(!1===e.columnFilters[a[t]])return!1;return!0},e)},Ew(e.options,"debugTable","getFacetedRowModel")),getFacetedUniqueValues:(e,t)=>jw(()=>{var n;return[null==(n=e.getColumn(t))?void 0:n.getFacetedRowModel()]},e=>{if(!e)return new Map;let n=new Map;for(let o=0;o<e.flatRows.length;o++){const a=e.flatRows[o].getUniqueValues(t);for(let e=0;e<a.length;e++){const t=a[e];var r;n.has(t)?n.set(t,(null!=(r=n.get(t))?r:0)+1):n.set(t,1)}}return n},Ew(e.options,"debugTable",`getFacetedUniqueValues_${t}`)),debugTable:!1});o.useEffect(()=>{B.setPageSize(_.pageSize)},[_.pageSize,B]);const V=o.useMemo(()=>r?hC(r):void 0,[r]),$=o.useMemo(()=>r?gC(r):void 0,[r]),W=o.useMemo(()=>{if(r||a)return()=>{if(v)try{localStorage.removeItem(v)}catch{}x(a?.sorting?[...a.sorting]:[]),C(V?{...V}:a?.visibility?{...a.visibility}:{}),$&&$.length?k([...$]):a?.columnOrder&&k([...a.columnOrder]),E(a?.columnPinning?{left:[...a.columnPinning.left??[]],right:[...a.columnPinning.right??[]]}:{left:[],right:[]}),B.resetColumnSizing()}},[r,a,V,$,C,k,E,x,B,v]);return{table:B,resolvedColumns:D,globalFilter:M,setGlobalFilter:O,pagination:_,setPagination:P,handleResetColumns:W,onBatchAction:m,onRowClick:g,onExportComplete:h}}function xC(e,t="data.csv"){const n=e.getVisibleLeafColumns().map(e=>e.id),r=e.getFilteredRowModel().rows.map(e=>e.getVisibleCells().map(e=>{const t=e.getValue();return"string"==typeof t?t:JSON.stringify(t)})),o=[n.join(","),...r.map(e=>e.join(","))].join("\n"),a=new Blob([o],{type:"text/csv"}),i=URL.createObjectURL(a),s=document.createElement("a");s.href=i,s.download=t,s.click(),URL.revokeObjectURL(i)}function wC(e){if(!e.length)return e;let t=e.slice();return t.includes("select")&&"select"!==t[0]&&(t=["select",...t.filter(e=>"select"!==e)]),t.includes("actions")&&"actions"!==t[t.length-1]&&(t=[...t.filter(e=>"actions"!==e),"actions"]),t}function CC(e){switch(e){case"right":return"text-right";case"center":return"text-center";case"left":return"text-left";default:return}}const SC={defaultColumnWidth:160,minColumnWidth:96,maxColumnWidth:420,toolbarGap:8,selectionColumnWidth:44,actionsColumnWidth:64};function kC({header:e,isDragging:t,activeColumnId:n,clampRef:r}){const o=e.column.id,{attributes:a,listeners:i,setNodeRef:s,transform:l,transition:c,isDragging:u}=sx({id:o}),d=(()=>{const{minX:e,maxX:t}=r.current;return l?Math.min(Math.max(l.x,e),t):0})(),p={transform:Gv.Transform.toString({x:d,y:l?.y??0,scaleX:l?.scaleX??1,scaleY:l?.scaleY??1}),transition:c},f=t&&!u&&null!=n,m=e.column.columnDef.meta?.align,g="right"===m?"ml-auto text-right":"center"===m?"mx-auto text-center":void 0,h=e.column.columnDef.meta?.helpText;function v({sorted:e}){return"asc"===e?ke.jsx(Xe,{className:"ml-2 h-4 w-4 text-muted-foreground"}):"desc"===e?ke.jsx(Ye,{className:"ml-2 h-4 w-4 text-muted-foreground"}):null}const b=e.column.columnDef.header,y=e.column.getCanSort(),x="string"==typeof b;return ke.jsx(Fm,{className:me("relative group border-b-0",CC(e.column.columnDef.meta?.align),f?"opacity-40":void 0),style:{width:e.getSize()},"data-col-id":o,children:ke.jsx("div",{ref:s,style:p,className:"flex items-center gap-2 cursor-grab active:cursor-grabbing","aria-grabbed":u,"aria-label":`Reorder column ${o}`,...a,...i,children:ke.jsx("div",{className:me("min-w-0",g,t?"pointer-events-none":void 0),children:e.isPlaceholder?null:ke.jsxs("div",{className:"inline-flex items-center gap-1",children:[y&&x?ke.jsxs(Le,{variant:"ghost",className:"h-8 -ml-3 px-3",onClick:()=>e.column.toggleSorting("asc"===e.column.getIsSorted()),children:[String(b),ke.jsx(v,{sorted:e.column.getIsSorted()})]}):mC(e.column.columnDef.header,e.getContext()),h?ke.jsxs(Tc,{children:[ke.jsx(Ac,{asChild:!0,children:ke.jsx("button",{type:"button","aria-label":"Column info",className:"inline-flex items-center justify-center text-muted-foreground hover:text-foreground",children:ke.jsx(lt,{className:"h-3.5 w-3.5"})})}),ke.jsx(Ic,{children:h})]}):null]})})})},e.id)}function jC({headerGroups:e,sortableHeaderIds:t,isBodyScrolled:n,isDragging:r,activeColumnId:o,clampRef:a}){return ke.jsx("thead",{"data-scrolled":n||void 0,className:"sticky top-0 z-10 bg-[var(--tablehead-bg)] border-b border-[var(--tablehead-border)] shadow-none data-[scrolled=true]:shadow-sm",children:e.map(e=>{const n=e.headers.find(e=>"select"===e.column.id&&e.column.getIsVisible()),i=e.headers.find(e=>"actions"===e.column.id&&e.column.getIsVisible()),s=e.headers.filter(e=>e.column.getIsVisible()),l=t.map(e=>s.find(t=>t.column.id===e)).filter(Boolean);return ke.jsx("tr",{className:"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",children:ke.jsxs(ex,{items:t,strategy:Yy,children:[n?ke.jsx(Fm,{className:me("relative group border-b-0 p-0",CC(n.column.columnDef.meta?.align)),style:{width:SC.selectionColumnWidth,minWidth:SC.selectionColumnWidth,maxWidth:SC.selectionColumnWidth},children:ke.jsx("div",{className:me("min-w-0","right"===n.column.columnDef.meta?.align?"ml-auto text-right":"center"===n.column.columnDef.meta?.align?"mx-auto text-center":void 0),children:mC(n.column.columnDef.header,n.getContext())})},n.id):null,l.map(e=>ke.jsx(kC,{header:e,isDragging:r,activeColumnId:o,clampRef:a},e.id)),i?ke.jsx(Fm,{className:me("relative group border-b-0",CC(i.column.columnDef.meta?.align)),style:{width:SC.actionsColumnWidth,minWidth:SC.actionsColumnWidth,maxWidth:SC.actionsColumnWidth},children:ke.jsx("div",{className:"min-w-0 ml-auto text-right",children:mC(i.column.columnDef.header,i.getContext())})},i.id):null]})},e.id)})})}function EC({children:e,align:t}){const n=o.useRef(null),r="right"===t;return o.useEffect(()=>{const e=n.current;if(!e)return;let t=0;const o=()=>{if(!e.isConnected)return;if(!(null!==e.offsetParent||e.getClientRects().length>0)||0===e.clientWidth)return;const t=e.scrollWidth>e.clientWidth+1;e.classList.toggle("mmc-table-cell__content--fade-right",t&&!r),e.classList.toggle("mmc-table-cell__content--fade-left",t&&r)};t=requestAnimationFrame(o);const a=new ResizeObserver(()=>o());a.observe(e);const i=e.closest("td");i&&a.observe(i);const s=new MutationObserver(()=>o());s.observe(e,{childList:!0,subtree:!0,characterData:!0});const l=new IntersectionObserver(e=>{const t=e[0];t&&t.isIntersecting&&requestAnimationFrame(o)});l.observe(e);const c=()=>o();return window.addEventListener("resize",c),()=>{cancelAnimationFrame(t),window.removeEventListener("resize",c);try{a.disconnect()}catch{}try{s.disconnect()}catch{}try{l.disconnect()}catch{}}},[r]),ke.jsx("span",{ref:n,className:"mmc-table-cell__content",children:e})}function NC({loading:e,resolvedColumns:t,rows:n,renderOrder:r,isDragging:o,activeColumnId:a}){return ke.jsx("tbody",{className:"[&_tr:last-child]:border-0",children:e?[...Array(5)].map((e,n)=>ke.jsx("tr",{children:t.map((e,t)=>ke.jsx("td",{className:me("px-4 py-2.5 align-middle text-xs font-normal transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] will-change-transform",CC(e.meta?.align)),children:ke.jsx(Bm,{className:"h-6 w-full"})},t))},n)):n?.length?n.map(e=>ke.jsx("tr",{"data-state":e.getIsSelected()&&"selected",className:"border-b transition-colors hover:bg-[var(--accent)] data-[state=selected]:bg-muted",children:(o?e.getVisibleCells().slice().sort((e,t)=>r.indexOf(e.column.id)-r.indexOf(t.column.id)):e.getVisibleCells()).map(e=>{const t=o&&null!=a&&e.column.id!==a&&"select"!==e.column.id;return ke.jsx("td",{className:me("px-4 py-2.5 align-middle text-xs font-normal","select"===e.column.id?"p-0":"[&:has([role=checkbox])]:pr-0","actions"===e.column.id?"py-1.5":void 0,CC(e.column.columnDef.meta?.align),t?"opacity-40":void 0),style:"select"===e.column.id?{width:SC.selectionColumnWidth,minWidth:SC.selectionColumnWidth,maxWidth:SC.selectionColumnWidth}:"actions"===e.column.id?{width:SC.actionsColumnWidth,minWidth:SC.actionsColumnWidth,maxWidth:SC.actionsColumnWidth}:{width:e.column.getSize()},"data-col-id":e.column.id,children:ke.jsx(EC,{align:e.column.columnDef.meta?.align,children:mC(e.column.columnDef.cell,e.getContext())})},e.id)})},e.id)):ke.jsx("tr",{children:ke.jsx("td",{colSpan:t.length,className:"h-24 text-center",children:"No results."})})})}function RC({selectedCount:e,onDeleteSelected:t,onBatchAction:n}){return e<=0?null:ke.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[ke.jsxs("span",{className:"text-sm",children:[e," selected"]}),ke.jsx(Le,{variant:"destructive",size:"sm",onClick:()=>{n?n("delete",[]):t?t(e):alert(`Delete ${e} row(s)`)},children:"Delete"})]})}function DC({columns:e,debug:t}){return ke.jsx("colgroup",{children:e.map(e=>{const n="select"===e.id?SC.selectionColumnWidth:"actions"===e.id?SC.actionsColumnWidth:e.getSize();return t&&t("colgroup width",String(e.id),n),ke.jsx("col",{style:{width:n}},String(e.id))})})}function MC({columns:e,data:t,loading:n=!1,columnRegistry:r,initialState:a,tableId:i,toolbar:s,emptyState:l,forceEmptyState:c,onRowSelectionChange:u,onSortingChange:d,onPaginationChange:p,onColumnVisibilityChange:f,onColumnOrderChange:m,onBatchAction:g,onRowClick:h,onExportComplete:v,customGlobalFilterFn:b}){const{table:y,resolvedColumns:x,globalFilter:w,setGlobalFilter:C,handleResetColumns:S,onBatchAction:k,onExportComplete:j}=yC({columns:e,data:t,columnRegistry:r,initialState:a,tableId:i,disableGlobalFilter:s?.disableGlobalFilter,customGlobalFilterFn:b,onRowSelectionChange:u,onSortingChange:d,onPaginationChange:p,onColumnVisibilityChange:f,onColumnOrderChange:m,onBatchAction:g,onRowClick:h,onExportComplete:v}),[E,N]=o.useState(!1),[R,D]=o.useState(null),[M,O]=o.useState([]),_=o.useRef(null),P=o.useRef(null),T=o.useRef({minX:Number.NEGATIVE_INFINITY,maxX:Number.POSITIVE_INFINITY}),[A,I]=o.useState(!1),F=sb(ib(ty,{activationConstraint:{distance:10}}),ib(Xb)),z=y.getState().columnOrder,L=y.getAllLeafColumns().map(e=>e.id),B=wC(z?.length?z:L),V=y.getHeaderGroups(),$=V.length?V[0].headers.filter(e=>e.column.getIsVisible()).map(e=>e.column.id):B,W=wC(E&&M.length?M:$),H=o.useMemo(()=>W.filter(e=>"select"!==e&&"actions"!==e),[W]),q=o.useCallback(e=>{N(!0),D(String(e.active.id));const t=y.getHeaderGroups(),n=t.length?t[0].headers.filter(e=>e.column.getIsVisible()).map(e=>e.column.id):B;O(wC(n));try{const t=String(e.active.id),n=document.querySelector(`th[data-col-id="${t}"]`),r=_.current;if(n&&r){const e=n.getBoundingClientRect(),t=r.getBoundingClientRect();T.current={minX:t.left-e.left,maxX:t.right-e.right}}else T.current={minX:Number.NEGATIVE_INFINITY,maxX:Number.POSITIVE_INFINITY}}catch{T.current={minX:Number.NEGATIVE_INFINITY,maxX:Number.POSITIVE_INFINITY}}},[B,y]),U=o.useCallback(e=>{const{active:t,over:n}=e;if(!n)return;const r=String(t.id),o=String(n.id);r!==o&&O(e=>{const t=e.indexOf(r),n=e.indexOf(o);if(-1===t||-1===n)return e;const a=Hy(e,t,n);if(a.includes("select")){return["select",...a.filter(e=>"select"!==e)]}return a})},[]),G=o.useCallback(e=>{if(N(!1),D(null),!M.length)return;const t=wC(M);JSON.stringify(B)!==JSON.stringify(t)&&y.setColumnOrder(t),O([])},[B,y,M]),Y=!n&&Boolean(c)&&Boolean(l);return ke.jsxs("div",{className:"w-full h-full flex flex-col min-h-0",children:[ke.jsx(ww,{table:y,loading:n,globalFilter:w??"",onGlobalFilterChange:C,onResetColumns:S,columnRegistry:r,onExport:()=>xC(y),onExportComplete:j,options:s}),y.getFilteredSelectedRowModel().rows.length>0&&ke.jsx(RC,{selectedCount:y.getFilteredSelectedRowModel().rows.length,onBatchAction:k?e=>{const t=y.getFilteredSelectedRowModel().rows.map(e=>e.original);k(e,t)}:void 0}),ke.jsx("div",{className:"relative w-full flex-1 min-h-0 overflow-auto",ref:_,onScroll:e=>{const t=e.currentTarget,n=(t?.scrollTop??0)>0;n!==A&&I(n)},children:Y?ke.jsx("div",{className:"mmc-table-empty flex h-full w-full items-center justify-center",role:"region","aria-label":"Empty state",children:l}):ke.jsx(Ly,{sensors:F,collisionDetection:gb,modifiers:[px],onDragStart:q,onDragOver:U,onDragEnd:G,children:ke.jsxs("table",{ref:P,className:"w-full caption-bottom text-sm table-fixed",children:[ke.jsx(DC,{columns:y.getVisibleLeafColumns(),debug:(...e)=>{}}),ke.jsx(jC,{headerGroups:y.getHeaderGroups(),sortableHeaderIds:H,isBodyScrolled:A,isDragging:E,activeColumnId:R,clampRef:T}),ke.jsx(NC,{loading:n,resolvedColumns:x,rows:y.getRowModel().rows,renderOrder:W,isDragging:E,activeColumnId:R})]})})}),Y?null:ke.jsx("div",{className:"border-t border-border bg-[var(--tablehead-bg)]",children:ke.jsx(gx,{table:y,onPageChange:p?e=>p(e,y.getState().pagination?.pageSize??25):void 0,onPageSizeChange:p?e=>p(y.getState().pagination?.pageIndex??0,e):void 0})})]})}const OC={NAME:"left",DESCRIPTION:"left",CATEGORY:"left",STATUS:"left",QUANTITY:"right",AMOUNT:"right",COUNT:"right",TOTAL:"right",PERCENTAGE:"right",RATE:"right",PROGRESS:"right",DATE:"left",ID:"left",REFERENCE:"left",ICON:"center",CHECKBOX:"center",BUTTON:"center"},_C=[{match:e=>"CURRENT_OPERATION"===e,align:"left"},{match:e=>"PART_OPERATION"===e||"PARTOPERATION"===e,align:"left"},{match:e=>"ORDER_OPERATION"===e||"ORDEROPERATION"===e,align:"left"},{match:e=>"OPERATION_TYPE"===e||"OPERATIONTYPE"===e,align:"left"},{match:e=>e.includes("PARTS")&&!e.includes("REF")||"GOODPARTS"===e||"BADPARTS"===e,align:"right"},{match:e=>e.includes("REJECTS")&&!e.includes("REF"),align:"right"},{match:e=>e.includes("QUANTITY")&&!e.includes("REF"),align:"right"},{match:e=>(e.includes("COUNT")||e.includes("TOTAL")||e.includes("ACTIVE")&&e.includes("ORDERS"))&&!e.includes("REF"),align:"right"},{match:e=>e.includes("RATE")&&!e.includes("REF"),align:"right"},{match:e=>e.includes("PERCENTAGE")&&!e.includes("REF"),align:"right"},{match:e=>e.includes("RATIO")||"SETUP_PRODUCTION_RATIO"===e,align:"right"},{match:e=>e.includes("OPERATIONS")&&e.includes("TOTAL"),align:"right"},{match:e=>e.includes("OPERATIONS")&&e.includes("COMPLETED"),align:"right"},{match:e=>e.includes("DURATION")||"DURATION"===e,align:"right"},{match:e=>e.includes("CYCLE")&&e.includes("TIME"),align:"right"},{match:e=>e.includes("SETUP")&&e.includes("TIME"),align:"right"},{match:e=>e.includes("TIME")&&!e.includes("DATE")&&!e.includes("STAMP"),align:"right"},{match:e=>e.includes("ORDER")||e.includes("NUMBER"),align:"left"},{match:e=>e.includes("EMPLOYEE")&&e.includes("ID"),align:"left"},{match:e=>e.includes("RESOURCE")&&e.includes("ID"),align:"left"},{match:e=>e.includes("DATE")||e.includes("TIME"),align:"left"},{match:e=>e.includes("START")||e.includes("END"),align:"left"},{match:e=>e.includes("CLOCKIN")||e.includes("CLOCKOUT"),align:"left"},{match:e=>e.includes("ID")||e.includes("REF")||e.includes("CODE"),align:"left"},{match:e=>e.includes("NAME")||e.includes("DESCRIPTION"),align:"left"},{match:e=>e.includes("CATEGORY")||"CATEGORY"===e,align:"left"},{match:e=>e.includes("OPERATION"),align:"left"},{match:e=>e.includes("ORDEROP"),align:"left"},{match:e=>e.includes("PARTOPERATION"),align:"left"},{match:e=>e.includes("WORKORDEROPERATIONREF"),align:"left"},{match:e=>e.includes("OPERATIONTYPE"),align:"left"},{match:e=>e.includes("LOT")||"LOT"===e,align:"left"},{match:e=>e.includes("SPLIT")||"SPLIT"===e,align:"left"},{match:e=>e.includes("SUB")||"SUB"===e,align:"left"},{match:e=>e.includes("SEQ")||"SEQUENCENUMBER"===e||"SEQUENCE"===e,align:"left"},{match:e=>e.includes("ACTIVITY")||e.includes("STATUS"),align:"left"},{match:e=>e.includes("STATE")||e.includes("TYPE"),align:"left"}];function PC(e){const{id:t,column:n,...r}=e,o={...n.meta};r.align&&void 0===o.align&&(o.align=r.align),r.helpText&&void 0===o.helpText&&(o.helpText=r.helpText);const a={...n,id:n.id??t,meta:o};return null!=r.width&&null==a.size&&(a.size=r.width),null!=r.minWidth&&null==a.minSize&&(a.minSize=r.minWidth),null!=r.maxWidth&&null==a.maxSize&&(a.maxSize=r.maxWidth),!1===r.hideable&&null==a.enableHiding&&(a.enableHiding=!1),function(e,t){if(!t)return;if(!1!==e.enableColumnFilter&&(e.enableColumnFilter=!0),e.filterFn)return;const n=t=>{e.filterFn=t};switch(t.type){case"select":n((e,t,n)=>{if(null==n||""===n)return!0;const r=e.getValue(t);if(null==r)return!1;const o=Array.isArray(n)?n.map(String):[String(n)];return 0===o.length||o.includes(String(r))});break;case"multi-select":n((e,t,n)=>{if(!Array.isArray(n)||0===n.length)return!0;const r=e.getValue(t);if(null==r)return!1;const o=Array.isArray(r)?r.map(String):[String(r)],a=n.map(String);return o.some(e=>a.includes(e))});break;case"numeric-range":n((e,t,n)=>{if(!Array.isArray(n)||0===n.length)return!0;const[r,o]=n;if(null==r&&null==o)return!0;const a=e.getValue(t);if(null==a)return!1;const i="number"==typeof a?a:Number(a);return!(Number.isNaN(i)||null!=r&&i<r||null!=o&&i>o)});break;case"date-range":n((e,t,n)=>{if(!Array.isArray(n)||0===n.length)return!0;const[r,o]=n;if(!r&&!o)return!0;const a=e.getValue(t);if(!a)return!1;const i=a instanceof Date?a:new Date(a);if(Number.isNaN(i.getTime()))return!1;if(r){const e=new Date(r);if(!Number.isNaN(e.getTime())&&i<e)return!1}if(o){const e=new Date(o);if(!Number.isNaN(e.getTime())&&i>e)return!1}return!0});break;case"text":n((e,t,n)=>{if(null==n)return!0;const r=e.getValue(t);if(null==r)return!1;if(Array.isArray(n)){const e=n.map(e=>String(e).toLowerCase());return 0===e.length||(Array.isArray(r)?r.map(e=>String(e).toLowerCase()).some(t=>e.includes(t)):e.includes(String(r).toLowerCase()))}const o=String(n).toLowerCase();return Array.isArray(r)?r.map(String).some(e=>e.toLowerCase().includes(o)):String(r).toLowerCase().includes(o)})}}(a,r.filter),{columnDef:a,defaults:{id:t,visible:!0,hideable:!0,...r}}}function TC(e){return e.defaults.id??e.columnDef.id??e.columnDef.accessorKey??""}function AC(e){const t=e.columnDef.meta;if(t?.mobileLabel)return t.mobileLabel;if(t?.label)return t.label;const n=e.columnDef.header;if("string"==typeof n)return n;return TC(e).replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function IC({row:e,columnRegistry:t,className:n,onRowClick:r}){const a=e.getVisibleCells(),i=new Map(a.map(e=>[e.column.id,e])),s=t||null,l=a.map(e=>{const t=e.column.id,n=s?s[t]:void 0;return n||{columnDef:e.column.columnDef,defaults:{id:t}}});function c(e){return mC(e.column.columnDef.cell,e.getContext())}function u(e){if(o.isValidElement(e)){const t={...e.props};if("string"==typeof t.className){const e=t.className.replace(/\bjustify-end\b/g,"justify-start").replace(/\bjustify-between\b/g,"justify-start").replace(/\btext-right\b/g,"text-left").replace(/\btext-center\b/g,"text-left").replace(/\bml-auto\b/g,"");t.className=e}return t.children&&(t.children=o.Children.map(t.children,e=>u(e))),o.cloneElement(e,t)}return Array.isArray(e)?e.map((e,t)=>ke.jsx(o.Fragment,{children:u(e)},t)):e}const d=l.find(e=>"title"===e.defaults.mobileRole),p=l.find(e=>"subtitle"===e.defaults.mobileRole),f=l.filter(e=>"badge"===e.defaults.mobileRole),m=l.find(e=>"select"===TC(e)),g=m?TC(m):void 0,h=g?i.get(g):void 0,v=l.filter(e=>{const t=e.defaults.mobileRole??"";return TC(e)!==g&&!["title","subtitle","badge"].includes(t)}),b=l.find(e=>"actions"===TC(e)),y=b?b.columnDef.meta?.rowActions??void 0:void 0,x=y?y(e):[],w=x.length>0,[C,S]=o.useState(!1);function k(t){const n=t.target;if(!n)return;n.closest('a,button,input,select,textarea,label,[role=checkbox],[data-slot="table-action-trigger"]')||(r&&r(e.original,e.index),w&&S(e=>!e))}return ke.jsxs("div",{className:me("mmc-row-card rounded-lg border border-border bg-card text-card-foreground shadow-sm p-4 space-y-3",n),role:w?"button":"group","aria-label":(()=>{const t=[];if(d){const n=TC(d),r=e.getValue(n);null!=r&&t.push(String(r))}if(p){const n=TC(p),r=e.getValue(n);null!=r&&t.push(String(r))}return t.join(" — ")||"Row"})(),"data-slot":"row-card",tabIndex:w||r?0:void 0,onClick:w||r?k:void 0,onKeyDown:w||r?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),k(e))}:void 0,"aria-expanded":w?C:void 0,children:[ke.jsxs("header",{className:"mmc-row-card__header flex items-start justify-between gap-3",children:[ke.jsxs("div",{className:"mmc-row-card__header-left flex items-start gap-3",children:[h?ke.jsx("div",{className:"mmc-row-card__selection pt-1",children:c(h)}):null,ke.jsxs("div",{className:"mmc-row-card__title-wrap space-y-1",children:[d?ke.jsx("div",{className:"mmc-row-card__title text-base font-medium",children:(()=>{const t=TC(d),n=i.get(t);return n?c(n):e.getValue(t)})()}):null,p?ke.jsx("div",{className:"mmc-row-card__subtitle text-sm text-muted-foreground",children:(()=>{const t=TC(p),n=i.get(t);return n?c(n):e.getValue(t)})()}):null]})]}),ke.jsx("div",{className:"mmc-row-card__badges flex flex-wrap items-center gap-2","aria-label":"Status",children:f.map(e=>{const t=TC(e),n=i.get(t);return n?ke.jsx("div",{className:"mmc-row-card__badge text-sm font-medium",children:c(n)},t):null})})]}),w&&C?ke.jsx("div",{className:"mmc-row-card__actions rounded-md border p-1",role:"menu","aria-label":"Row actions",children:x.map((t,n)=>ke.jsx("button",{type:"button",className:me("relative flex w-full items-center gap-2 rounded-sm px-2 py-2 text-sm text-left outline-hidden select-none hover:bg-accent","destructive"===t.variant?"text-destructive":void 0),onClick:n=>{n.stopPropagation();try{t.onSelect(e)}finally{S(!1)}},role:"menuitem","data-variant":t.variant??"default",children:t.label},t.key??n))}):ke.jsx("dl",{className:"mmc-row-card__details grid grid-cols-2 gap-3 text-sm sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:v.map(e=>{const t=TC(e),n=i.get(t);return n?ke.jsxs("div",{className:"mmc-row-card__detail flex flex-col gap-1",children:[ke.jsx("dt",{className:"mmc-row-card__label text-xs text-muted-foreground",children:AC(e)}),ke.jsx("dd",{className:"mmc-row-card__value m-0 w-full text-left flex items-center justify-start",children:u(c(n))})]},t):null})})]})}function FC(e,t,n){let r,o=n.initialDeps??[];function a(){var a,i,s,l;let c;n.key&&(null==(a=n.debug)?void 0:a.call(n))&&(c=Date.now());const u=e();if(!(u.length!==o.length||u.some((e,t)=>o[t]!==e)))return r;let d;if(o=u,n.key&&(null==(i=n.debug)?void 0:i.call(n))&&(d=Date.now()),r=t(...u),n.key&&(null==(s=n.debug)?void 0:s.call(n))){const e=Math.round(100*(Date.now()-c))/100,t=Math.round(100*(Date.now()-d))/100,r=t/16,o=(e,t)=>{for(e=String(e);e.length<t;)e=" "+e;return e};console.info(`%c⏱ ${o(t,5)} /${o(e,5)} ms`,`\n font-size: .6rem;\n font-weight: bold;\n color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,null==n?void 0:n.key)}return null==(l=null==n?void 0:n.onChange)||l.call(n,r),r}return a.updateDeps=e=>{o=e},a}function zC(e,t){if(void 0===e)throw new Error("Unexpected undefined");return e}const LC=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}},BC=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},VC=e=>e,$C=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let o=t;o<=n;o++)r.push(o);return r},WC=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=e=>{const{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(o(BC(n)),!r.ResizeObserver)return()=>{};const a=new r.ResizeObserver(t=>{const r=()=>{const e=t[0];if(null==e?void 0:e.borderBoxSize){const t=e.borderBoxSize[0];if(t)return void o({width:t.inlineSize,height:t.blockSize})}o(BC(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},HC={passive:!0},qC="undefined"==typeof window||"onscrollend"in window,UC=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let o=0;const a=e.options.useScrollendEvent&&qC?()=>{}:LC(r,()=>{t(o,!1)},e.options.isScrollingResetDelay),i=r=>()=>{const{horizontal:i,isRtl:s}=e.options;o=i?n.scrollLeft*(s?-1:1):n.scrollTop,a(),t(o,r)},s=i(!0),l=i(!1);l(),n.addEventListener("scroll",s,HC);const c=e.options.useScrollendEvent&&qC;return c&&n.addEventListener("scrollend",l,HC),()=>{n.removeEventListener("scroll",s),c&&n.removeEventListener("scrollend",l)}},GC=(e,t,n)=>{if(null==t?void 0:t.borderBoxSize){const e=t.borderBoxSize[0];if(e){return Math.round(e[n.options.horizontal?"inlineSize":"blockSize"])}}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},YC=(e,{adjustments:t=0,behavior:n},r)=>{var o,a;const i=e+t;null==(a=null==(o=r.scrollElement)?void 0:o.scrollTo)||a.call(o,{[r.options.horizontal?"left":"top"]:i,behavior:n})};class KC{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null;const t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{const t=()=>{this._measureElement(e.target,e)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}):null);return{disconnect:()=>{var n;null==(n=t())||n.disconnect(),e=null},observe:e=>{var n;return null==(n=t())?void 0:n.observe(e,{box:"border-box"})},unobserve:e=>{var n;return null==(n=t())?void 0:n.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{void 0===n&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:VC,rangeExtractor:$C,onChange:()=>{},measureElement:GC,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,n;null==(n=(t=this.options).onChange)||n.call(t,this,e)},this.maybeNotify=FC(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:"production"!==process.env.NODE_ENV&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t)return void this.maybeNotify();this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.window)??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?"forward":"backward":null,this.scrollOffset=e,this.isScrolling=t,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{const n=new Map,r=new Map;for(let o=t-1;o>=0;o--){const t=e[o];if(n.has(t.lane))continue;const a=r.get(t.lane);if(null==a||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=FC(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(e,t,n,r,o)=>(this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:o}),{key:!1}),this.getMeasurements=FC(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:o},a)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];0===this.measurementsCache.length&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));const i=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const s=this.measurementsCache.slice(0,i);for(let l=i;l<e;l++){const e=r(l),o=1===this.options.lanes?s[l-1]:this.getFurthestMeasurement(s,l),i=o?o.end+this.options.gap:t+n,c=a.get(e),u="number"==typeof c?c:this.options.estimateSize(l),d=i+u,p=o?o.lane:l%this.options.lanes;s[l]={index:l,start:i,size:u,end:d,key:e,lane:p}}return this.measurementsCache=s,s},{key:"production"!==process.env.NODE_ENV&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=FC(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?function({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const o=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:o};let i=XC(0,o,a,n),s=i;if(1===r)for(;s<o&&e[s].end<n+t;)s++;else if(r>1){const a=Array(r).fill(0);for(;s<o&&a.some(e=>e<n+t);){const t=e[s];a[t.lane]=t.end,s++}const l=Array(r).fill(n+t);for(;i>=0&&l.some(e=>e>=n);){const t=e[i];l[t.lane]=t.start,i--}i=Math.max(0,i-i%r),s=Math.min(o,s+(r-1-s%r))}return{startIndex:i,endIndex:s}}({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:"production"!==process.env.NODE_ENV&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=FC(()=>{let e=null,t=null;const n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,o)=>null===r||null===o?[]:e({startIndex:r,endIndex:o,overscan:t,count:n}),{key:"production"!==process.env.NODE_ENV&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=e=>{const t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this._measureElement=(e,t)=>{const n=this.indexFromElement(e),r=this.measurementsCache[n];if(!r)return;const o=r.key,a=this.elementsCache.get(o);a!==e&&(a&&this.observer.unobserve(a),this.observer.observe(e),this.elementsCache.set(o,e)),e.isConnected&&this.resizeItem(n,this.options.measureElement(e,t,this))},this.resizeItem=(e,t)=>{const n=this.measurementsCache[e];if(!n)return;const r=t-(this.itemSizeCache.get(n.key)??n.size);0!==r&&((void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&("production"!==process.env.NODE_ENV&&this.options.debug&&console.info("correction",r),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.measureElement=e=>{e?this._measureElement(e,void 0):this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))})},this.getVirtualItems=FC(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{const n=[];for(let r=0,o=e.length;r<o;r++){const o=t[e[r]];n.push(o)}return n},{key:"production"!==process.env.NODE_ENV&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const t=this.getMeasurements();if(0!==t.length)return zC(t[XC(0,t.length-1,e=>zC(t[e]).start,e)])},this.getOffsetForAlignment=(e,t,n=0)=>{const r=this.getSize(),o=this.getScrollOffset();"auto"===t&&(t=e>=o+r?"end":"start"),"center"===t?e+=(n-r)/2:"end"===t&&(e-=r);const a=this.getTotalSize()+this.options.scrollMargin-r;return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const n=this.measurementsCache[e];if(!n)return;const r=this.getSize(),o=this.getScrollOffset();if("auto"===t)if(n.end>=o+r-this.options.scrollPaddingEnd)t="end";else{if(!(n.start<=o+this.options.scrollPaddingStart))return[o,t];t="start"}const a="end"===t?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,n.size),t]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(e,{align:t="start",behavior:n}={})=>{"smooth"===n&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,t),{adjustments:void 0,behavior:n})},this.scrollToIndex=(e,{align:t="auto",behavior:n}={})=>{"smooth"===n&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),e=Math.max(0,Math.min(e,this.options.count-1));let r=0;const o=t=>{if(!this.targetWindow)return;const r=this.getOffsetForIndex(e,t);if(!r)return void console.warn("Failed to get offset for index:",e);const[o,i]=r;this._scrollToOffset(o,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{const t=this.getScrollOffset(),n=this.getOffsetForIndex(e,i);var r,o;n?(r=n[0],o=t,Math.abs(r-o)<1.01||a(i)):console.warn("Failed to get offset for index:",e)})},a=t=>{this.targetWindow&&(r++,r<10?("production"!==process.env.NODE_ENV&&this.options.debug&&console.info("Schedule retry",r,10),this.targetWindow.requestAnimationFrame(()=>o(t))):console.warn(`Failed to scroll to index ${e} after 10 attempts.`))};o(t)},this.scrollBy=(e,{behavior:t}={})=>{"smooth"===t&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:t})},this.getTotalSize=()=>{var e;const t=this.getMeasurements();let n;if(0===t.length)n=this.options.paddingStart;else if(1===this.options.lanes)n=(null==(e=t[t.length-1])?void 0:e.end)??0;else{const e=Array(this.options.lanes).fill(null);let r=t.length-1;for(;r>=0&&e.some(e=>null===e);){const n=t[r];null===e[n.lane]&&(e[n.lane]=n.end),r--}n=Math.max(...e.filter(e=>null!==e))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(e)}}const XC=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,a=n(o);if(a<r)e=o+1;else{if(!(a>r))return o;t=o-1}}return e>0?e-1:0};const ZC="undefined"!=typeof document?o.useLayoutEffect:o.useEffect;function JC(e){return function(e){const t=o.useReducer(()=>({}),{})[1],r={...e,onChange:(r,o)=>{var a;o?n.flushSync(t):t(),null==(a=e.onChange)||a.call(e,r,o)}},[a]=o.useState(()=>new KC(r));return a.setOptions(r),ZC(()=>a._didMount(),[]),ZC(()=>a._willUpdate()),a}({observeElementRect:WC,observeElementOffset:UC,scrollToFn:YC,...e})}o.createContext(void 0);o.forwardRef(({className:e,...t},n)=>ke.jsx("th",{ref:n,"data-slot":"table-head",className:me("h-10 px-4 text-left align-middle text-xs font-semibold bg-[var(--tablehead-bg)] text-[var(--tablehead-fg)] border-b border-[var(--tablehead-border)] [&:has([role=checkbox])]:pr-0 [&:has([role=checkbox])]:pl-0","[&_button]:text-xs [&_button]:font-semibold [&_[data-slot='button']]:text-xs [&_[data-slot='button']]:font-semibold",e),...t})).displayName="TableHead";const QC=o.forwardRef(({className:e,children:t,autoHeight:n=!0,...r},a)=>{const i=o.useRef(null);o.useImperativeHandle(a,()=>i.current);const s=o.useCallback(()=>{const e=i.current;if(!e)return;let t=!1;if(n){let n=e.nextElementSibling;for(;n;){const e=n,r=window.getComputedStyle(e);if("none"!==r.display&&"hidden"!==r.visibility&&null!==e.offsetParent&&e.offsetHeight>0){t=!0;break}n=n.nextElementSibling}if(!t){const t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;let r=n;const o=e.closest('[data-slot="component_preview"]');if(o){const e=o.getBoundingClientRect(),t=window.getComputedStyle(o),a=parseFloat(t.paddingBottom||"0")||0;r=Math.min(n,e.bottom-a)}const a=Math.max(0,r-t.top);return e.style.height=`${a}px`,void(e.style.minHeight="400px")}}e.style.height="",e.style.minHeight="400px"},[n]);return o.useLayoutEffect(()=>{s();const e=()=>{requestAnimationFrame(s)};return window.addEventListener("resize",e),window.addEventListener("scroll",e,{passive:!0}),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}},[s]),ke.jsx("div",{ref:i,"data-slot":"table-wrapper",className:me("flex min-h-[400px] flex-col rounded-md border p-4",e),...r,children:t})});function eS({columns:e,data:t,loading:n,columnRegistry:r,initialState:a,tableId:i,enableMobileVirtualization:s=!0,virtualizeAt:l=500,overscan:c=8,toolbarOptions:u,emptyState:d,forceEmptyState:p,onRowSelectionChange:f,onSortingChange:m,onPaginationChange:g,onColumnVisibilityChange:h,onColumnOrderChange:v,onBatchAction:b,onRowClick:y,onExportComplete:x,customGlobalFilterFn:w}){const{table:C,globalFilter:S,setGlobalFilter:k,handleResetColumns:j}=yC({columns:e,data:t,columnRegistry:r,initialState:a,tableId:i,customGlobalFilterFn:w,onRowSelectionChange:f,onSortingChange:m,onPaginationChange:g,onColumnVisibilityChange:h,onColumnOrderChange:v,onBatchAction:b,onRowClick:y,onExportComplete:x}),E=o.useRef(null),N=C.getRowModel().rows,R=!n&&s&&N.length>=l,D=JC({count:R?N.length:0,getScrollElement:()=>E.current,estimateSize:()=>128,overscan:c}),M=!n&&Boolean(p)&&Boolean(d);return ke.jsxs("section",{className:"mmc-responsive-table w-full h-full flex flex-col min-h-0 space-y-4","aria-label":"Data table (mobile)",children:[ke.jsx(ww,{table:C,loading:n,globalFilter:S,onGlobalFilterChange:k,onResetColumns:j,columnRegistry:r,onExport:()=>xC(C),options:u}),C.getFilteredSelectedRowModel().rows.length>0&&ke.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[ke.jsxs("span",{className:"text-sm",children:[C.getFilteredSelectedRowModel().rows.length," selected"]}),ke.jsx(Le,{variant:"destructive",size:"sm",onClick:()=>{alert(`Delete ${C.getFilteredSelectedRowModel().rows.length} row(s)`)},children:"Delete"})]}),ke.jsx("div",{ref:E,className:"mmc-row-card-list space-y-3 overflow-auto flex-1 min-h-0",role:"list","aria-label":"Rows",children:M?ke.jsx("div",{className:"mmc-table-empty flex h-full w-full items-center justify-center",role:"region","aria-label":"Empty state",children:d}):(()=>{if(n)return[0,1,2].map(e=>ke.jsxs("div",{className:"mmc-row-card mmc-row-card--skeleton rounded-lg border border-border bg-card p-4 space-y-3",role:"group","aria-label":"Loading row","aria-busy":"true","aria-live":"polite",children:[ke.jsxs("div",{className:"flex items-center justify-between",children:[ke.jsx(Bm,{className:"h-4 w-1/2"}),ke.jsx(Bm,{className:"h-5 w-12"})]}),ke.jsxs("div",{className:"space-y-2",children:[ke.jsx(Bm,{className:"h-3 w-3/4"}),ke.jsx(Bm,{className:"h-3 w-2/3"}),ke.jsx(Bm,{className:"h-3 w-1/2"})]})]},e));if(!N.length&&!M)return ke.jsxs("div",{className:"mmc-row-card-list__empty rounded-lg border border-dashed border-border py-10 text-center text-sm text-muted-foreground",role:"status","aria-live":"polite",children:[ke.jsx("span",{className:"sr-only",children:"No results"}),"No results."]});if(!R)return N.map(e=>ke.jsx(IC,{row:e,columnRegistry:r,className:"mmc-row-card--item w-full",onRowClick:y},e.id));const e=D.getVirtualItems();return ke.jsx("div",{style:{height:D.getTotalSize(),position:"relative"},children:e.map(e=>{const t=N[e.index];return ke.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,transform:`translateY(${e.start}px)`},children:ke.jsx(IC,{row:t,columnRegistry:r,className:"mmc-row-card--item w-full",onRowClick:y})},t.id)})})})()}),M?null:ke.jsx(gx,{table:C})]})}QC.displayName="TableContainer";var tS="Progress",nS=100,[rS]=Nt(tS),[oS,aS]=rS(tS),iS=o.forwardRef((e,t)=>{const{__scopeProgress:n,value:r=null,max:o,getValueLabel:a=cS,...i}=e;!o&&0!==o||pS(o)||console.error(`Invalid prop \`max\` of value \`${`${o}`}\` supplied to \`${"Progress"}\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`);const s=pS(o)?o:nS;null===r||fS(r,s)||console.error(function(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:\n - a positive number\n - less than the value passed to \`max\` (or 100 if no \`max\` prop is set)\n - \`null\` or \`undefined\` if the progress is indeterminate.\n\nDefaulting to \`null\`.`}(`${r}`,"Progress"));const l=fS(r,s)?r:null,c=dS(l)?a(l,s):void 0;return ke.jsx(oS,{scope:n,value:l,max:s,children:ke.jsx(Ct.div,{"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":dS(l)?l:void 0,"aria-valuetext":c,role:"progressbar","data-state":uS(l,s),"data-value":l??void 0,"data-max":s,...i,ref:t})})});iS.displayName=tS;var sS="ProgressIndicator",lS=o.forwardRef((e,t)=>{const{__scopeProgress:n,...r}=e,o=aS(sS,n);return ke.jsx(Ct.div,{"data-state":uS(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...r,ref:t})});function cS(e,t){return`${Math.round(e/t*100)}%`}function uS(e,t){return null==e?"indeterminate":e===t?"complete":"loading"}function dS(e){return"number"==typeof e}function pS(e){return dS(e)&&!isNaN(e)&&e>0}function fS(e,t){return dS(e)&&!isNaN(e)&&e<=t&&e>=0}lS.displayName=sS;var mS=iS,gS=lS;const hS=o.forwardRef(({className:e,value:t,...n},r)=>{const o="number"==typeof t?Math.max(0,Math.min(100,t)):void 0;return ke.jsx(mS,{ref:r,"data-slot":"progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":"number"==typeof o?o:void 0,"data-unknown":"number"!=typeof o?"true":void 0,className:me("relative h-2 w-full overflow-hidden rounded-full",e),...n,children:ke.jsx(gS,{"data-slot":"progress-indicator",className:"h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(o||0)}%)`}})})});hS.displayName="Progress";var vS,bS={exports:{}},yS={exports:{}},xS={};var wS,CS,SS,kS,jS,ES,NS,RS,DS,MS,OS,_S,PS,TS,AS,IS={};
58
58
  /** @license React v16.13.1
59
59
  * react-is.development.js
60
60
  *